Restore device state in app, set counter in webapp,
This commit is contained in:
parent
253c8c2a54
commit
a9e13ac2a6
|
@ -322,7 +322,13 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
|
||||||
};
|
};
|
||||||
web.getStateSuccess = function (res) {
|
web.getStateSuccess = function (res) {
|
||||||
'use strict';
|
'use strict';
|
||||||
console.dir(res);
|
if (res.frame.dir !== true) {
|
||||||
|
$('#dir').prop('checked', true);
|
||||||
|
setDirLabel(false);
|
||||||
|
}
|
||||||
|
$('#counter').val(res.counter);
|
||||||
|
$('#exposure').val(res.frame.exposure);
|
||||||
|
$('#delay').val(res.frame.delay);
|
||||||
};
|
};
|
||||||
web.init = function () {
|
web.init = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -330,6 +336,7 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
|
||||||
getState = web.getState;
|
getState = web.getState;
|
||||||
setDir = web.setDir;
|
setDir = web.setDir;
|
||||||
setExposure = web.setExposure;
|
setExposure = web.setExposure;
|
||||||
|
|
||||||
web.getState();
|
web.getState();
|
||||||
};
|
};
|
||||||
web.init();
|
web.init();
|
||||||
|
|
31
index.js
31
index.js
|
@ -25,6 +25,8 @@ function createServer () {
|
||||||
app.post('/dir', rDir)
|
app.post('/dir', rDir)
|
||||||
app.get( '/exposure', rExposure)
|
app.get( '/exposure', rExposure)
|
||||||
app.post('/exposure', rExposure)
|
app.post('/exposure', rExposure)
|
||||||
|
app.get( '/counter', rCounter)
|
||||||
|
app.post('/counter', rCounter)
|
||||||
app.get( '/frame', rFrame)
|
app.get( '/frame', rFrame)
|
||||||
app.post('/frame', rFrame)
|
app.post('/frame', rFrame)
|
||||||
app.get( '/sequence', () => {})
|
app.get( '/sequence', () => {})
|
||||||
|
@ -119,6 +121,35 @@ function rDelay (req, res, next) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rCounter (req, res, next) {
|
||||||
|
let counter = 0
|
||||||
|
let set = false
|
||||||
|
if (req.query && typeof req.query.counter !== 'undefined') {
|
||||||
|
if (typeof req.query.counter === 'string') {
|
||||||
|
counter = parseInt(req.query.counter)
|
||||||
|
} else {
|
||||||
|
counter = req.query.counter
|
||||||
|
}
|
||||||
|
set = true
|
||||||
|
}
|
||||||
|
if (req.body && typeof req.body.counter !== 'undefined') {
|
||||||
|
if (typeof req.body.counter !== 'string') {
|
||||||
|
counter = parseInt(req.body.counter)
|
||||||
|
} else {
|
||||||
|
counter = req.body.counter
|
||||||
|
}
|
||||||
|
set = true
|
||||||
|
}
|
||||||
|
if (set) {
|
||||||
|
intval.setCounter(counter)
|
||||||
|
} else {
|
||||||
|
counter = intval._state.counter
|
||||||
|
}
|
||||||
|
log.info('/counter', { method : req.method, set : set, counter : counter })
|
||||||
|
req.send({ counter : counter })
|
||||||
|
return next()
|
||||||
|
}
|
||||||
|
|
||||||
function rFrame (req, res, next) {
|
function rFrame (req, res, next) {
|
||||||
let dir = true
|
let dir = true
|
||||||
let exposure = 0
|
let exposure = 0
|
||||||
|
|
|
@ -54,7 +54,8 @@ intval.init = function () {
|
||||||
micro : {
|
micro : {
|
||||||
time : 0,
|
time : 0,
|
||||||
primed : false //is ready to stop frame
|
primed : false //is ready to stop frame
|
||||||
}
|
},
|
||||||
|
counter : 0
|
||||||
}
|
}
|
||||||
intval._frame = {
|
intval._frame = {
|
||||||
open : 250, //delay before pausing frame in open state
|
open : 250, //delay before pausing frame in open state
|
||||||
|
@ -264,6 +265,10 @@ intval.setDelay = function (val = 0) {
|
||||||
intval._state.frame.delay = val
|
intval._state.frame.delay = val
|
||||||
log.info('setDelay', { delay : val })
|
log.info('setDelay', { delay : val })
|
||||||
}
|
}
|
||||||
|
intval.setCounter = function (val = 0) {
|
||||||
|
intval._state.counter = val
|
||||||
|
log.info('setCounter', { counter : val })
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Begin a single frame with set variables or defaults
|
* Begin a single frame with set variables or defaults
|
||||||
*
|
*
|
||||||
|
@ -313,9 +318,17 @@ intval.frame = function (dir = null, time = null, cb = () => {}) {
|
||||||
}, time + intval._frame.closed)
|
}, time + intval._frame.closed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dir) {
|
||||||
intval._state.frame.cb = (len) => {
|
intval._state.frame.cb = (len) => {
|
||||||
|
intval._state.counter++
|
||||||
cb(len)
|
cb(len)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
intval._state.frame.cb = (len) => {
|
||||||
|
intval._state.counter--
|
||||||
|
cb(len)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Start a sequence of frames, using defaults or explicit instructions
|
* Start a sequence of frames, using defaults or explicit instructions
|
||||||
|
|
Loading…
Reference in New Issue