Pull delay setting out of the _state.frame object into the _state object. Ugh this is such a mess.

This commit is contained in:
mmcwilliams 2019-10-30 23:47:34 -04:00
parent d566c2160b
commit 3667c8dd36
6 changed files with 14 additions and 34 deletions

View File

@ -149,7 +149,7 @@ function rDelay (req, res, next) {
if (set) { if (set) {
intval.setDelay(delay) intval.setDelay(delay)
} else { } else {
delay = intval._state.frame.delay delay = intval._state.delay
} }
log.info('/delay', { method: req.method, set : set, delay : delay }) log.info('/delay', { method: req.method, set : set, delay : delay })
res.send({ delay : delay }) res.send({ delay : delay })
@ -222,20 +222,7 @@ async function rFrame (req, res, next) {
exposure = req.body.exposure exposure = req.body.exposure
} }
} }
if (req.query && typeof req.query.delay !== 'undefined') {
if (typeof req.query.delay === 'string') {
delay = parseInt(req.query.delay)
} else {
delay = req.query.delay
}
}
if (req.body && typeof req.body.delay !== 'undefined') {
if (typeof req.body.delay === 'string') {
delay = parseInt(req.body.delay)
} else {
delay = req.body.delay
}
}
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) {
@ -265,8 +252,8 @@ async function rSequence (req, res, next) {
if (intval._state.frame.exposure !== 0) { if (intval._state.frame.exposure !== 0) {
exposure = intval._state.frame.exposure exposure = intval._state.frame.exposure
} }
if (intval._state.frame.delay !== 0) { if (intval._state.delay !== 0) {
delay = intval._state.frame.delay options.delay = intval._state.delay
} }
if (req.query && typeof req.query.dir !== 'undefined') { if (req.query && typeof req.query.dir !== 'undefined') {
@ -508,8 +495,8 @@ function bSequence (obj, cb) {
if (intval._state.frame.exposure !== 0) { if (intval._state.frame.exposure !== 0) {
exposure = intval._state.frame.exposure exposure = intval._state.frame.exposure
} }
if (intval._state.frame.delay !== 0) { if (intval._state.delay !== 0) {
delay = intval._state.frame.delay delay = intval._state.delay
} }
if (typeof obj.dir !== 'undefined') { if (typeof obj.dir !== 'undefined') {

View File

@ -142,10 +142,10 @@ class Intval {
active: false, active: false,
paused: false, paused: false,
exposure: 0, exposure: 0,
delay: 0,
current: {}, current: {},
cb: () => { } cb: () => { }
}, },
delay: 0,
counter: 0, counter: 0,
sequence: false sequence: false
}; };

File diff suppressed because one or more lines are too long

View File

@ -55,13 +55,13 @@ class Sequence {
if (multiple > 1) { if (multiple > 1) {
for (let x = 0; x < multiple; x++) { for (let x = 0; x < multiple; x++) {
await this.intval.frame(); await this.intval.frame();
log.info('start', { id: this.id, count: this.count }); log.info('frame', { id: this.id, count: this.count });
this.count++; this.count++;
} }
} }
else { else {
await this.intval.frame(); await this.intval.frame();
log.info('start', { id: this.id, count: this.count }); log.info('frame', { id: this.id, count: this.count });
this.count++; this.count++;
} }
if (this.delay > 0 && i < len - 1) { if (this.delay > 0 && i < len - 1) {

View File

@ -177,10 +177,10 @@ export default class Intval {
active : false, //should frame be running active : false, //should frame be running
paused : false, paused : false,
exposure : 0, //length of frame exposure, in ms exposure : 0, //length of frame exposure, in ms
delay : 0, //delay before start of frame, in ms
current : {}, //current settings current : {}, //current settings
cb : () => {} cb : () => {}
}, },
delay : 0, //delay before start of frame, in ms
counter : 0, counter : 0,
sequence : false sequence : false
} }
@ -505,21 +505,14 @@ export default class Intval {
this._state.frame.paused = true; this._state.frame.paused = true;
if (dir) { if (dir) {
await delay(this._frame.open) await delay(this._frame.open)
this._pause() this._pause()
await delay(exposure + this._frame.closed) await delay(exposure + this._frame.closed)
this._state.frame.paused = false this._state.frame.paused = false
this._startFwd() this._startFwd()
} else { } else {
await delay(this._frame.openBwd) await delay(this._frame.openBwd)
this._pause() this._pause()
await delay(exposure + this._frame.closed) await delay(exposure + this._frame.closed)
this._state.frame.paused = false; this._state.frame.paused = false;
this._startBwd() this._startBwd()
} }

View File

@ -68,12 +68,12 @@ export class Sequence {
if (multiple > 1) { if (multiple > 1) {
for (let x = 0; x < multiple; x++) { for (let x = 0; x < multiple; x++) {
await this.intval.frame() await this.intval.frame()
log.info('start', { id : this.id, count : this.count }) log.info('frame', { id : this.id, count : this.count })
this.count++ this.count++
} }
} else { } else {
await this.intval.frame() await this.intval.frame()
log.info('start', { id : this.id, count : this.count }) log.info('frame', { id : this.id, count : this.count })
this.count++ this.count++
} }