diff --git a/src/_EMR/main.js b/src/_EMR/auger_loop.js similarity index 85% rename from src/_EMR/main.js rename to src/_EMR/auger_loop.js index 1e345e7..75f2a8f 100644 --- a/src/_EMR/main.js +++ b/src/_EMR/auger_loop.js @@ -21,9 +21,6 @@ setInterval(() => { }, process.env.AUGER_CYCLE_TIME || 500); }, 2000); -fn.log('Setting exhaust to low to keep NC relay closed and fan running', 'DEBUG'); -gpio.setPin(process.pinMap.get('exhaust').board, 0); - process.on('SIGINT', () => { fn.log(`Exiting gracefully...`, 'INFO'); gpio.setPin(process.pinMap.get('auger').board, 0); diff --git a/src/_EMR/exh_off.js b/src/_EMR/exh_off.js new file mode 100644 index 0000000..a7e930f --- /dev/null +++ b/src/_EMR/exh_off.js @@ -0,0 +1,17 @@ +// Import modules +const gpio = require('../custom_modules/VoidGPIO.js'); +const config = require('../custom_modules/config.json'); +const fn = require('../custom_modules/functions.js'); + +// Variables +process.pinMap = new Map(); + +fn.log('Initializing pinMap', 'DEBUG'); +for (const pin of config.pins) { + process.pinMap.set(pin.key, pin); +} + +fn.log('Turning off exhaust', 'INFO'); +gpio.setPin(process.pinMap.get('exhaust').board, 1); +fn.log('Exhast off', 'INFO'); +process.exit(); \ No newline at end of file diff --git a/src/_EMR/exh_on.js b/src/_EMR/exh_on.js new file mode 100644 index 0000000..ff0a12b --- /dev/null +++ b/src/_EMR/exh_on.js @@ -0,0 +1,17 @@ +// Import modules +const gpio = require('../custom_modules/VoidGPIO.js'); +const config = require('../custom_modules/config.json'); +const fn = require('../custom_modules/functions.js'); + +// Variables +process.pinMap = new Map(); + +fn.log('Initializing pinMap', 'DEBUG'); +for (const pin of config.pins) { + process.pinMap.set(pin.key, pin); +} + +fn.log('Turning on exhaust', 'INFO'); +gpio.setPin(process.pinMap.get('exhaust').board, 0); +fn.log('Exhast on', 'INFO'); +process.exit(); \ No newline at end of file diff --git a/src/_EMR/panel.sh b/src/_EMR/panel.sh new file mode 100644 index 0000000..3561999 --- /dev/null +++ b/src/_EMR/panel.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Path variables +ROOT_PATH="/srv/hestia" +EMR_FOLDER="src/_EMR" + +# Prompt for input +echo "##########################################" +echo "# Hestia Emergency Control Panel #" +echo "##########################################" +echo "# 1. Exhaust ON #" +echo "# 2. Exhaust OFF #" +echo "# 3. Igniter ON #" +echo "# 4. Igniter OFF #" +echo "# 5. Start Auger Loop #" +echo "# 6. Stop Auger Loop #" +echo "##########################################" +echo "# 0. Exit #" +echo "##########################################" + +# Read user input +read -p "Menu Option: " choice + +# Switch case on input +case $choice in + 1) + echo "Turning Exhaust ON" + cd $ROOT_PATH + node $EMR_FOLDER/exh_on.js + ;; + 2) + echo "Turning Exhaust OFF" + cd $ROOT_PATH + node $EMR_FOLDER/exh_off.js + ;; + 3) + echo "Turning Igniter ON" + cd $ROOT_PATH + node $EMR_FOLDER/ign_on.js + ;; + 4) + echo "Turning Igniter OFF" + cd $ROOT_PATH + node $EMR_FOLDER/ign_off.js + ;; + 5) + echo "Starting Auger Loop" + cd $ROOT_PATH + pm2 start $EMR_FOLDER/auger_loop.js --name hestia-emr + ;; + 6) + echo "Stopping Auger Loop" + cd $ROOT_PATH + pm2 stop hestia-emr + ;; + 0) + echo "Exiting" + ;; + *) + echo "Invalid input" + ;; +esac \ No newline at end of file