Push dev work to master #2
|
@ -38,6 +38,19 @@ const PINS = {
|
||||||
/** Object representing the intval3 features */
|
/** Object representing the intval3 features */
|
||||||
const intval = {}
|
const intval = {}
|
||||||
|
|
||||||
|
intval._frame = {
|
||||||
|
open : 250, //delay before pausing frame in open state
|
||||||
|
openBwd : 400,
|
||||||
|
closed : 100, //time that frame actually remains closed for
|
||||||
|
expected : 630 //expected length of frame, in ms
|
||||||
|
}
|
||||||
|
intval._release = {
|
||||||
|
min : 20,
|
||||||
|
seq : 1000
|
||||||
|
}
|
||||||
|
intval._microDelay = 10 // delay after stop signal before stopping motors
|
||||||
|
intval._pin = {}
|
||||||
|
|
||||||
intval.init = function () {
|
intval.init = function () {
|
||||||
if (!fs.existsSync('./state')) fs.mkdirSync('./state')
|
if (!fs.existsSync('./state')) fs.mkdirSync('./state')
|
||||||
storage.init({
|
storage.init({
|
||||||
|
@ -51,37 +64,26 @@ intval.init = function () {
|
||||||
ttl: false, // ttl* [NEW], can be true for 24h default or a number in MILLISECONDS
|
ttl: false, // ttl* [NEW], can be true for 24h default or a number in MILLISECONDS
|
||||||
expiredInterval: 2 * 60 * 1000, // [NEW] every 2 minutes the process will clean-up the expired cache
|
expiredInterval: 2 * 60 * 1000, // [NEW] every 2 minutes the process will clean-up the expired cache
|
||||||
forgiveParseErrors: false // [NEW]
|
forgiveParseErrors: false // [NEW]
|
||||||
}).then((res) => {
|
}).then(intval._restoreState).catch((err) => {
|
||||||
//console.dir(res)
|
|
||||||
storage.getItem('_state', 'test').then(intval._setState).catch((err) => {
|
|
||||||
intval._setState(undefined)
|
|
||||||
log.error('init', err)
|
|
||||||
})
|
|
||||||
}).catch((err) => {
|
|
||||||
log.error('init', err)
|
log.error('init', err)
|
||||||
fs.rmdirSync('./state')
|
fs.rmdirSync('./state')
|
||||||
log.warn('Restarting')
|
log.warn('Restarting')
|
||||||
process.exit()
|
return process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
intval._frame = {
|
|
||||||
open : 250, //delay before pausing frame in open state
|
|
||||||
openBwd : 400,
|
|
||||||
closed : 100, //time that frame actually remains closed for
|
|
||||||
expected : 630 //expected length of frame, in ms
|
|
||||||
}
|
|
||||||
intval._release = {
|
|
||||||
min : 20,
|
|
||||||
seq : 1000
|
|
||||||
}
|
|
||||||
intval._microDelay = 10 // delay after stop signal before stopping motors
|
|
||||||
intval._pin = {}
|
|
||||||
|
|
||||||
intval._declarePins()
|
|
||||||
process.on('SIGINT', intval._undeclarePins)
|
process.on('SIGINT', intval._undeclarePins)
|
||||||
process.on('uncaughtException', intval._undeclarePins)
|
process.on('uncaughtException', intval._undeclarePins)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intval._restoreState = function (res) {
|
||||||
|
//console.dir(res)
|
||||||
|
storage.getItem('_state', 'test').then(intval._setState).catch((err) => {
|
||||||
|
intval._setState(undefined)
|
||||||
|
log.error('init', err)
|
||||||
|
})
|
||||||
|
intval._declarePins()
|
||||||
|
}
|
||||||
|
|
||||||
intval._setState = function (data) {
|
intval._setState = function (data) {
|
||||||
if (typeof data !== 'undefined') {
|
if (typeof data !== 'undefined') {
|
||||||
intval._state = data
|
intval._state = data
|
||||||
|
|
Loading…
Reference in New Issue