Prevent frame from running if _state.frame.active is true.

This commit is contained in:
mmcwilliams 2019-10-31 00:43:44 -04:00
parent 7ac2e7ed67
commit 5611ea338a
4 changed files with 17 additions and 8 deletions

View File

@ -188,6 +188,7 @@ function rCounter (req, res, next) {
async function rFrame (req, res, next) { async function rFrame (req, res, next) {
let dir = true let dir = true
let exposure = 0 let exposure = 0
let success = false
if (intval._state.frame.dir !== true) { if (intval._state.frame.dir !== true) {
dir = false dir = false
} }
@ -226,8 +227,8 @@ async function rFrame (req, res, next) {
log.info('/frame', { method : req.method, dir : dir, exposure : exposure }) log.info('/frame', { method : req.method, dir : dir, exposure : exposure })
if (exposure < 30000) { if (exposure < 30000) {
await intval.frame(dir, exposure) success = await intval.frame(dir, exposure)
res.send({ dir : dir, len : exposure }) res.send({ dir : dir, len : exposure, success })
return next() return next()
} else { } else {
intval.frame(dir, exposure) intval.frame(dir, exposure)
@ -388,6 +389,7 @@ function rRestart (req, res, next) {
async function bFrame (obj, cb) { async function bFrame (obj, cb) {
let dir = true let dir = true
let exposure = 0 let exposure = 0
let success = false
if (sequence.active) { if (sequence.active) {
return cb() return cb()
@ -416,7 +418,7 @@ async function bFrame (obj, cb) {
log.info('frame', { method : 'ble', dir : dir, exposure : exposure }) log.info('frame', { method : 'ble', dir : dir, exposure : exposure })
if (exposure < 5000) { if (exposure < 5000) {
await intval.frame(dir, exposure) success = await intval.frame(dir, exposure)
return cb() return cb()
} else { } else {
intval.frame(dir, exposure) intval.frame(dir, exposure)

View File

@ -406,6 +406,9 @@ class Intval {
* *
*/ */
async frame(dir = null, exposure = null) { async frame(dir = null, exposure = null) {
if (this._state.frame.active) {
return false;
}
if (dir === true || (dir === null && this._state.frame.dir === true)) { if (dir === true || (dir === null && this._state.frame.dir === true)) {
dir = true; dir = true;
} }
@ -452,7 +455,7 @@ class Intval {
this._state.frame.cb = (len) => { this._state.frame.cb = (len) => {
this._state.counter++; this._state.counter++;
this._storeState(); this._storeState();
return resolve(); return resolve(true);
}; };
}.bind(this)); }.bind(this));
} }
@ -461,7 +464,7 @@ class Intval {
this._state.frame.cb = (len) => { this._state.frame.cb = (len) => {
this._state.counter--; this._state.counter--;
this._storeState(); this._storeState();
return resolve(); return resolve(true);
}; };
}.bind(this)); }.bind(this));
} }

File diff suppressed because one or more lines are too long

View File

@ -474,6 +474,10 @@ export default class Intval {
*/ */
public async frame (dir : boolean = null, exposure : number = null) { public async frame (dir : boolean = null, exposure : number = null) {
if (this._state.frame.active) {
return false
}
if (dir === true || (dir === null && this._state.frame.dir === true) ) { if (dir === true || (dir === null && this._state.frame.dir === true) ) {
dir = true; dir = true;
} else { } else {
@ -523,7 +527,7 @@ export default class Intval {
this._state.frame.cb = (len : number) => { this._state.frame.cb = (len : number) => {
this._state.counter++ this._state.counter++
this._storeState() this._storeState()
return resolve() return resolve(true)
} }
}.bind(this)) }.bind(this))
} else { } else {
@ -531,7 +535,7 @@ export default class Intval {
this._state.frame.cb = (len : number) => { this._state.frame.cb = (len : number) => {
this._state.counter-- this._state.counter--
this._storeState() this._storeState()
return resolve() return resolve(true)
} }
}.bind(this)) }.bind(this))
} }