diff --git a/app/index.html b/app/index.html index 28d8275..f7d4391 100644 --- a/app/index.html +++ b/app/index.html @@ -236,7 +236,7 @@
- +

Light

diff --git a/app/lib/intval/index.js b/app/lib/intval/index.js index d7a836d..1e6d726 100644 --- a/app/lib/intval/index.js +++ b/app/lib/intval/index.js @@ -1,16 +1,14 @@ 'use strict' const req = require('request') -const devices = {} class Intval { - constructor (device, url) { - devices[device] = `http://${url}` + constructor (url) { + this._baseUrl = `http://${url}` } - move (device, cb) { + move (cb) { const timeStart = +new Date() - const baseUrl = devices[device] - const url = `${baseUrl}/frame` + const url = `${this._baseUrl}/frame` //console.log(url) req(url, (err, res, body) => { let ms = (+new Date()) - timeStart @@ -20,10 +18,9 @@ class Intval { cb(ms) }) } - setDir (device, dir, cb) { + setDir (dir, cb) { const timeStart = +new Date() - const baseUrl = devices[device] - const url = `${baseUrl}/dir?dir=${dir}` + const url = `${this._baseUrl}/dir?dir=${dir}` //console.log(url) req(url, (err, res, body) => { let ms = (+new Date()) - timeStart @@ -34,10 +31,9 @@ class Intval { }) } - setExposure (device, exposure, cb) { + setExposure (exposure, cb) { const timeStart = +new Date() - const baseUrl = devices[device] - const url = `${baseUrl}/exposure?exposure=${exposure}` + const url = `${this._baseUrl}/exposure?exposure=${exposure}` //console.log(url) req(url, (err, res, body) => { let ms = (+new Date()) - timeStart @@ -47,6 +43,24 @@ class Intval { cb(ms) }) } + connect (cb) { + const timeStart = +new Date() + const url = `${this._baseUrl}/status` + const opts = { + method : 'GET', + uri : url, + timeout: 5000 + } + + req(opts, (err, res, body) => { + let ms = (+new Date()) - timeStart + if (err) { + //console.error(err) + return cb(err, ms) + } + cb(null, ms, body) + }) + } } module.exports = Intval \ No newline at end of file diff --git a/app/lib/ui/devices.js b/app/lib/ui/devices.js index 25055c6..91e3250 100644 --- a/app/lib/ui/devices.js +++ b/app/lib/ui/devices.js @@ -1,3 +1,4 @@ + var devices = {}; devices.init = function () { @@ -10,20 +11,63 @@ devices.listen = function () { 'use strict'; ipcRenderer.on('ready', devices.ready); + ipcRenderer.on('intval', devices.intvalCb); }; devices.ready = function (event, arg) { 'use strict'; let opt; + let devs = []; gui.spinner(false); gui.overlay(false); for (let i in arg) { + if (arg[i] !== '/dev/fake') { + devs.push(arg[i]); + } opt = $('