Prevent frame from running if _state.frame.active is true.
This commit is contained in:
parent
7ac2e7ed67
commit
5611ea338a
8
index.js
8
index.js
|
@ -188,6 +188,7 @@ function rCounter (req, res, next) {
|
|||
async function rFrame (req, res, next) {
|
||||
let dir = true
|
||||
let exposure = 0
|
||||
let success = false
|
||||
if (intval._state.frame.dir !== true) {
|
||||
dir = false
|
||||
}
|
||||
|
@ -226,8 +227,8 @@ async function rFrame (req, res, next) {
|
|||
log.info('/frame', { method : req.method, dir : dir, exposure : exposure })
|
||||
|
||||
if (exposure < 30000) {
|
||||
await intval.frame(dir, exposure)
|
||||
res.send({ dir : dir, len : exposure })
|
||||
success = await intval.frame(dir, exposure)
|
||||
res.send({ dir : dir, len : exposure, success })
|
||||
return next()
|
||||
} else {
|
||||
intval.frame(dir, exposure)
|
||||
|
@ -388,6 +389,7 @@ function rRestart (req, res, next) {
|
|||
async function bFrame (obj, cb) {
|
||||
let dir = true
|
||||
let exposure = 0
|
||||
let success = false
|
||||
|
||||
if (sequence.active) {
|
||||
return cb()
|
||||
|
@ -416,7 +418,7 @@ async function bFrame (obj, cb) {
|
|||
log.info('frame', { method : 'ble', dir : dir, exposure : exposure })
|
||||
|
||||
if (exposure < 5000) {
|
||||
await intval.frame(dir, exposure)
|
||||
success = await intval.frame(dir, exposure)
|
||||
return cb()
|
||||
} else {
|
||||
intval.frame(dir, exposure)
|
||||
|
|
|
@ -406,6 +406,9 @@ class Intval {
|
|||
*
|
||||
*/
|
||||
async frame(dir = null, exposure = null) {
|
||||
if (this._state.frame.active) {
|
||||
return false;
|
||||
}
|
||||
if (dir === true || (dir === null && this._state.frame.dir === true)) {
|
||||
dir = true;
|
||||
}
|
||||
|
@ -452,7 +455,7 @@ class Intval {
|
|||
this._state.frame.cb = (len) => {
|
||||
this._state.counter++;
|
||||
this._storeState();
|
||||
return resolve();
|
||||
return resolve(true);
|
||||
};
|
||||
}.bind(this));
|
||||
}
|
||||
|
@ -461,7 +464,7 @@ class Intval {
|
|||
this._state.frame.cb = (len) => {
|
||||
this._state.counter--;
|
||||
this._storeState();
|
||||
return resolve();
|
||||
return resolve(true);
|
||||
};
|
||||
}.bind(this));
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -474,6 +474,10 @@ export default class Intval {
|
|||
*/
|
||||
|
||||
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) ) {
|
||||
dir = true;
|
||||
} else {
|
||||
|
@ -523,7 +527,7 @@ export default class Intval {
|
|||
this._state.frame.cb = (len : number) => {
|
||||
this._state.counter++
|
||||
this._storeState()
|
||||
return resolve()
|
||||
return resolve(true)
|
||||
}
|
||||
}.bind(this))
|
||||
} else {
|
||||
|
@ -531,7 +535,7 @@ export default class Intval {
|
|||
this._state.frame.cb = (len : number) => {
|
||||
this._state.counter--
|
||||
this._storeState()
|
||||
return resolve()
|
||||
return resolve(true)
|
||||
}
|
||||
}.bind(this))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue