Try new startup init

This commit is contained in:
Skylar Grant 2024-09-02 13:16:21 -04:00
parent 0a90a93269
commit 2a756065e7
2 changed files with 58 additions and 43 deletions

View File

@ -61,9 +61,9 @@
], ],
"power": { "power": {
"start": { "start": {
"exhaustDelay": 30000, "exhaustDelay": 5000,
"augerDelay": 60000, "igniterPreheat": 60000,
"fireCheckDelay": 420000 "igniterDelay": 420000
}, },
"stop": { "stop": {
"exhaustDelay": 600000 "exhaustDelay": 600000

View File

@ -63,53 +63,68 @@ module.exports = {
module.exports.log(changes); module.exports.log(changes);
}).catch(e => console.error(e)); }).catch(e => console.error(e));
// Power on igniter // Start the exhaust
gpio.setPin(process.pinMap.get('igniter').board, 1).then(async () => { this.exhaust().then(() => {
// Wait for igniter preheat // Check for vacuum
await module.exports.sleep(config.power.start.exhaustDelay); this.vacuum().then(() => {
// Start the auger
this.auger().then(() => {
resolve('Startup sequence complete.');
}).catch(e => console.error(e));
// Preheat the igniter
this.igniter().then(() => {
module.exports.sleep(config.power.start.igniterDelay).then(() => {
// Check for fire
this.fire().then(() => {
}).catch(e => console.error(e));
});
}).catch(e => console.error(e));
}).catch(e => console.error(e));
}).catch(e => console.error(e)); }).catch(e => console.error(e));
});
},
exhaust() {
return new Promise(async (resolve, reject) => {
// Start exhaust // Start exhaust
gpio.setPin(process.pinMap.get('exhaust').board, 1).then(async () => { gpio.setPin(process.pinMap.get('exhaust').board, 1).then(() => {
// Finish igniter preheat // Wait to resolve
await module.exports.sleep(config.power.start.augerDelay); module.exports.sleep(config.power.start.exhaustDelay).then(() => {
resolve('Exhaust started.');
}
}).catch(e => console.error(e)); }).catch(e => console.error(e));
});
},
vacuum() {
return new Promise(async (resolve, reject) => {
// Check for vacuum // Check for vacuum
gpio.readPin(process.pinMap.get('vacuum').board).then(state => { gpio.readPin(process.pinMap.get('vacuum').board).then(state => {
if (state === '0') { if (state === '0') {
// Power off exhaust reject(new Error('Vacuum failure.'));
gpio.setPin(process.pinMap.get('exhaust').board, 0).then(() => {
// Report vacuum failure
reject(new Error('Vacuum failure.'));
return;
}).catch(e => console.error(e));
} else { } else {
// Start auger resolve('Vacuum established.');
gpio.setPin(process.pinMap.get('auger').board, 1).then(async () => { }
// Wait for fire }).catch(e => console.error(e));
await module.exports.sleep(config.power.start.fireCheckDelay); });
},
// Power off igniter igniter() {
gpio.setPin(process.pinMap.get('igniter').board, 0).then(() => { return new Promise(async (resolve, reject) => {
// Check for fire on pof // Start igniter
gpio.readPin(process.pinMap.get('pof').board).then(state => { gpio.setPin(process.pinMap.get('igniter').board, 1).then(() => {
if (state === '0') { // Wait to resolve
// Power off auger module.exports.sleep(config.power.start.igniterPreheat).then(() => {
gpio.setPin(process.pinMap.get('auger').board, 0).then(() => { resolve('Igniter preheated.');
// Report failed ignition });
reject(new Error('Failed ignition.')); }).catch(e => console.error(e));
}).catch(e => console.error(e)); });
} else { },
// Power off auger fire() {
gpio.setPin(process.pinMap.get('auger').board, 0).then(() => { return new Promise(async (resolve, reject) => {
// Report successful ignition // Check for fire
resolve('Successful ignition.'); gpio.readPin(process.pinMap.get('pof').board).then(state => {
}).catch(e => console.error(e)); if (state === '0') {
} reject(new Error('Failed ignition.'));
}).catch(e => console.error(e)); } else {
}).catch(e => console.error(e)); resolve('Successful ignition.');
}).catch(e => console.error(e));
} }
}).catch(e => console.error(e)); }).catch(e => console.error(e));
}); });