flag the start of a sequence and stop it.
This commit is contained in:
parent
b1085cb77c
commit
11bf8b95f8
12
index.js
12
index.js
|
@ -287,13 +287,15 @@ function rSequence (req, res, next) {
|
|||
exposure = req.body.exposure
|
||||
}
|
||||
}
|
||||
if (sequence._state.active) {
|
||||
return sequence.stop(() => {
|
||||
if (intval._state.sequence && sequence._state.active) {
|
||||
return sequence.setStop(() => {
|
||||
intval._state.sequence = false
|
||||
res.send({ stopped : true })
|
||||
return next()
|
||||
})
|
||||
} else {
|
||||
console.time('sequence time')
|
||||
intval._state.sequence = true
|
||||
sequence.start({
|
||||
loop : [ (next) => {
|
||||
intval.frame(dir, exposure, (len) => {
|
||||
|
@ -433,12 +435,14 @@ function bSequence (obj, cb) {
|
|||
exposure = obj.exposure
|
||||
}
|
||||
}
|
||||
if (sequence._state.active) {
|
||||
return sequence.stop(() => {
|
||||
if (intval._state.sequence && sequence._state.active) {
|
||||
return sequence.setStop(() => {
|
||||
intval._state.sequence = false
|
||||
return cb()
|
||||
})
|
||||
} else {
|
||||
console.time('sequence time')
|
||||
intval._state.sequence = true
|
||||
sequence.start({
|
||||
loop : [ (next) => {
|
||||
intval.frame(dir, exposure, (len) => {
|
||||
|
|
|
@ -43,8 +43,9 @@ sequence.start = function (options, cb) {
|
|||
sequence.step()
|
||||
}
|
||||
|
||||
sequence.setStop = function () {
|
||||
sequence.setStop = function (cb) {
|
||||
sequence._state.active = false
|
||||
sequence._state.input = cb
|
||||
}
|
||||
|
||||
sequence.stop = function () {
|
||||
|
@ -57,7 +58,9 @@ sequence.stop = function () {
|
|||
sequence._loop.arr = []
|
||||
|
||||
if (sequence._state.stop) sequence._state.stop()
|
||||
if (sequence._state.input) sequence._state.input()
|
||||
sequence._state.stop = null
|
||||
sequence._state.input = null
|
||||
}
|
||||
|
||||
sequence.pause = function () {
|
||||
|
@ -75,6 +78,7 @@ sequence.step = function () {
|
|||
if (sequence._state.count > sequence._state.arr.length) {
|
||||
return sequence.stop()
|
||||
}
|
||||
log.info('step')
|
||||
return sequence._state.arr[sequence._state.count](() => {
|
||||
sequence._state.count++
|
||||
sequence.step()
|
||||
|
@ -84,9 +88,10 @@ sequence.step = function () {
|
|||
sequence._state.count = 0
|
||||
sequence._loop.count++
|
||||
}
|
||||
if (sequence._loop.max > 0 &&sequence._loop.count > sequence._loop.max) {
|
||||
if (sequence._loop.max > 0 && sequence._loop.count > sequence._loop.max) {
|
||||
return sequence.stop()
|
||||
}
|
||||
log.info()
|
||||
return sequence._loop.arr[sequence._state.count](() => {
|
||||
sequence._state.count++
|
||||
sequence.step()
|
||||
|
@ -95,9 +100,9 @@ sequence.step = function () {
|
|||
return sequence.stop()
|
||||
}
|
||||
} else if (sequence._state.paused) {
|
||||
log.info('Sequence paused', { loop : sequence._loop.count, count : sequence._state.count })
|
||||
log.info('step', 'Sequence paused', { loop : sequence._loop.count, count : sequence._state.count })
|
||||
} else if (!sequence._state.active) {
|
||||
log.info('Sequence stopped', { loop : sequence._loop.count, count : sequence._state.count })
|
||||
log.info('step', 'Sequence stopped', { loop : sequence._loop.count, count : sequence._state.count })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue