Push dev work to master #2
|
@ -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,8 +318,16 @@ intval.frame = function (dir = null, time = null, cb = () => {}) {
|
||||||
}, time + intval._frame.closed)
|
}, time + intval._frame.closed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intval._state.frame.cb = (len) => {
|
if (dir) {
|
||||||
cb(len)
|
intval._state.frame.cb = (len) => {
|
||||||
|
intval._state.counter++
|
||||||
|
cb(len)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
intval._state.frame.cb = (len) => {
|
||||||
|
intval._state.counter--
|
||||||
|
cb(len)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue