bug fixes
This commit is contained in:
parent
b7f9bacfa1
commit
283f963e38
6
.vscode/pssnippets.code-snippets
vendored
6
.vscode/pssnippets.code-snippets
vendored
@ -27,5 +27,11 @@
|
|||||||
"prefix": "onpi",
|
"prefix": "onpi",
|
||||||
"body": "if (process.env.ONPI == 'true') {\n\t$1\n} else {\n\t$2\n}$0",
|
"body": "if (process.env.ONPI == 'true') {\n\t$1\n} else {\n\t$2\n}$0",
|
||||||
"description": "Run something only if the ONPI env var is set"
|
"description": "Run something only if the ONPI env var is set"
|
||||||
|
},
|
||||||
|
"Error": {
|
||||||
|
"scope": "javascript",
|
||||||
|
"prefix": "err",
|
||||||
|
"body": "console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: $1`);\n$0",
|
||||||
|
"description": "Log an error to the console with timestamp"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1 +1 @@
|
|||||||
{"debugMode":true,"status":{"igniter":0,"blower":0,"auger":0,"igniterFinished":false,"shutdown":0,"vacuum":0,"pof":0},"timestamps":{"procStart":1673037430589,"blowerOn":0,"blowerOff":0,"igniterOn":0,"igniterOff":0},"intervals":{"augerOn":"700","augerOff":"1300","igniterStart":5000,"blowerStop":5000},"web":{"port":8080,"ip":"0.0.0.0"}}
|
{"debugMode":true,"status":{"igniter":0,"blower":0,"auger":0,"igniterFinished":false,"shutdown":0,"vacuum":0,"pof":0},"timestamps":{"procStart":1673042241248,"blowerOn":0,"blowerOff":0,"igniterOn":0,"igniterOff":0},"intervals":{"augerOn":"500","augerOff":"1500","pause":"5000","igniterStart":5000,"blowerStop":5000},"web":{"port":8080,"ip":"0.0.0.0"}}
|
11
functions.js
11
functions.js
@ -17,6 +17,7 @@ const fs = require('fs');
|
|||||||
const { time } = require('console');
|
const { time } = require('console');
|
||||||
|
|
||||||
const main = (gpio) => {
|
const main = (gpio) => {
|
||||||
|
functions.commands.refreshConfig().then(res => {
|
||||||
// If the auger is enabled
|
// If the auger is enabled
|
||||||
if (config.status.auger == 1) {
|
if (config.status.auger == 1) {
|
||||||
// Run a cycle of the auger
|
// Run a cycle of the auger
|
||||||
@ -36,6 +37,10 @@ const main = (gpio) => {
|
|||||||
main(gpio);
|
main(gpio);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}).catch(rej => {
|
||||||
|
console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: Problem refreshing the config file.`);
|
||||||
|
main(gpio);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// The functions we'll export to be used in other files
|
// The functions we'll export to be used in other files
|
||||||
@ -144,6 +149,7 @@ const functions = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
refreshConfig(newSettings) {
|
refreshConfig(newSettings) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
// When the reload button is pressed, the call to this function will contain new config values
|
// When the reload button is pressed, the call to this function will contain new config values
|
||||||
// {
|
// {
|
||||||
// augerOff: 500,
|
// augerOff: 500,
|
||||||
@ -156,8 +162,11 @@ const functions = {
|
|||||||
config.intervals.pause = newSettings.pause;
|
config.intervals.pause = newSettings.pause;
|
||||||
}
|
}
|
||||||
fs.writeFile('./config.json', JSON.stringify(config), (err) => {
|
fs.writeFile('./config.json', JSON.stringify(config), (err) => {
|
||||||
if (err) throw err;
|
if (err) reject(err);
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Sleeps for any given milliseconds
|
// Sleeps for any given milliseconds
|
||||||
|
21
websvr.js
21
websvr.js
@ -11,10 +11,21 @@ const express = require('express');
|
|||||||
const app = express();
|
const app = express();
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
const config = require('./config.json');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
// const bodyParser = require('body-parser');
|
// const bodyParser = require('body-parser');
|
||||||
const fn = require('./functions.js').functions;
|
var config;
|
||||||
|
var fn;
|
||||||
|
|
||||||
|
// First thing is to copy the template config to main config file
|
||||||
|
fs.readFile('./templates/config.json', (err, data) => {
|
||||||
|
fs.writeFile('./config.json', data, (err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log(`I: Config Template copied.`);
|
||||||
|
config = require('./config.json');
|
||||||
|
fn = require('./functions.js').functions;
|
||||||
|
server.listen(config.web.port, config.web.ip);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.use(express.urlencoded());
|
app.use(express.urlencoded());
|
||||||
|
|
||||||
@ -45,12 +56,8 @@ app.post('/', (req, res) => {
|
|||||||
fn.commands.refreshConfig({
|
fn.commands.refreshConfig({
|
||||||
augerOff: req.body.augerOff,
|
augerOff: req.body.augerOff,
|
||||||
augerOn: req.body.augerOn,
|
augerOn: req.body.augerOn,
|
||||||
pause: req.body.pause
|
pause: req.body.pauseInt
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// res.send(200);
|
|
||||||
});
|
});
|
||||||
// console.log(req.body);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(config.web.port, config.web.ip);
|
|
@ -9,9 +9,15 @@ html, body {
|
|||||||
#title {
|
#title {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 35px;
|
font-size: 35px;
|
||||||
|
margin-top: 10px;
|
||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#title a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
#status {
|
#status {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
@ -71,7 +77,7 @@ html, body {
|
|||||||
font-family: times;
|
font-family: times;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
height: 35px;
|
height: 35px;
|
||||||
width: 100px;
|
width: 150px;
|
||||||
border-top-left-radius: 0px;
|
border-top-left-radius: 0px;
|
||||||
border-bottom-left-radius: 0px;
|
border-bottom-left-radius: 0px;
|
||||||
border-top-right-radius: 0px;
|
border-top-right-radius: 0px;
|
||||||
|
@ -32,30 +32,26 @@ function refreshData() {
|
|||||||
const log = document.getElementById('log-area');
|
const log = document.getElementById('log-area');
|
||||||
log.contentWindow.location.reload();
|
log.contentWindow.location.reload();
|
||||||
sleep(100).then(() => {
|
sleep(100).then(() => {
|
||||||
document.getElementById('log-area').contentWindow.scrollTo(0, 9999999);
|
document.getElementById('log-area').contentWindow.scrollTo(0, 9999999999);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get the elements we need to update
|
||||||
const augerStatus = document.getElementById('auger-status');
|
const augerStatus = document.getElementById('auger-status');
|
||||||
// const augerOn = document.getElementById('auger-on');
|
const augerOn = document.getElementById('auger-on');
|
||||||
// const augerOff = document.getElementById('auger-off');
|
const augerOff = document.getElementById('auger-off');
|
||||||
const igniterStatus = document.getElementById('igniter-status');
|
const pauseInt = document.getElementById('pause-int');
|
||||||
const blowerStatus = document.getElementById('blower-status');
|
|
||||||
// const pauseInt = document.getElementById('pause-int');
|
|
||||||
const vacuumStatus = document.getElementById('vacuum-status');
|
|
||||||
const pofStatus = document.getElementById('pof-status');
|
|
||||||
|
|
||||||
|
// Get the config file
|
||||||
const config = readJSON('./config.json');
|
const config = readJSON('./config.json');
|
||||||
|
// console.log(config);
|
||||||
|
|
||||||
augerStatus.innerHTML = parseStatus(config.status.auger);
|
augerStatus.innerHTML = parseStatus(config.status.auger);
|
||||||
// augerOn.innerHTML = parseStatus(config.intervals.augerOn);
|
augerOn.value = config.intervals.augerOn;
|
||||||
// augerOff.innerHTML = parseStatus(config.intervals.augerOff);
|
augerOff.value = config.intervals.augerOff;
|
||||||
igniterStatus.innerHTML = parseStatus(config.status.igniter);
|
pauseInt.value = config.intervals.pause;
|
||||||
blowerStatus.innerHTML = parseStatus(config.status.blower);
|
|
||||||
// pauseInt.innerHTML = parseStatus(config.intervals.pause);
|
|
||||||
vacuumStatus.innerHTML = parseStatus(config.status.vacuum);
|
|
||||||
pofStatus.innerHTML = parseStatus(config.status.pof);
|
|
||||||
|
|
||||||
sleep(2000).then(() => {
|
// Run this again after 2 seconds
|
||||||
|
sleep(5000).then(() => {
|
||||||
refreshData();
|
refreshData();
|
||||||
});
|
});
|
||||||
};
|
};
|
@ -6,14 +6,13 @@
|
|||||||
</head>
|
</head>
|
||||||
<body onload="refreshData()">
|
<body onload="refreshData()">
|
||||||
<%- include('trial.html') -%>
|
<%- include('trial.html') -%>
|
||||||
<div id="title">Hestia Web Portal</div>
|
<div id="title"><a href='./'>Hestia Web Portal</a></div>
|
||||||
<div id="status">Auger: <span id="auger-status"></span> | Igniter: <span id="igniter-status"></span> | Combustion Blower: <span id="blower-status"></span></div>
|
<div id="status">Auger: <span id="auger-status"></span></div>
|
||||||
<div id="safeties">Vacuum: <span id="vacuum-status"></span> | Proof of Fire: <span id="pof-status"></span></div>
|
|
||||||
<div id="controls-container">
|
<div id="controls-container">
|
||||||
<form action="/" method="post">
|
<form action="/" method="post">
|
||||||
<!-- Start | Shutdown | Reload Settings -->
|
<!-- Start | Shutdown | Reload Settings -->
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<input class="button-unselected" type="submit" id="ignite" value="Start" name="start"><input class="button-unselected" type="submit" id="shutdown" value="Shutdown" name="shutdown"><input class="button-unselected" type="submit" id="reload" value="Reload" name="reload"><br>
|
<input class="button-unselected" type="submit" id="ignite" value="Enable Auger" name="start"><input class="button-unselected" type="submit" id="shutdown" value="Disable Auger" name="shutdown"><input class="button-unselected" type="submit" id="reload" value="Reload" name="reload"><br>
|
||||||
</div>
|
</div>
|
||||||
<!-- Set feed rates -->
|
<!-- Set feed rates -->
|
||||||
<label for="augerOn">Auger On Interval: </label><input type="number" id="auger-on" name="augerOn" min="500" max="1000" step="100" value="<%= intervals.augerOn %>">ms<br>
|
<label for="augerOn">Auger On Interval: </label><input type="number" id="auger-on" name="augerOn" min="500" max="1000" step="100" value="<%= intervals.augerOn %>">ms<br>
|
||||||
@ -21,17 +20,17 @@
|
|||||||
<label for="pauseInt">App Pause Interval: </label><input type="number" id="pause-int" name="pauseInt" min="1000" max="600000" step="1000" value="<%= intervals.pause %>">ms<br>
|
<label for="pauseInt">App Pause Interval: </label><input type="number" id="pause-int" name="pauseInt" min="1000" max="600000" step="1000" value="<%= intervals.pause %>">ms<br>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="subheading">
|
<!-- <div class="subheading">
|
||||||
Pellet Feed Rate
|
Pellet Feed Rate
|
||||||
</div>
|
</div>
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<button class="button-unselected" id="low-level">LOW</button><button class="button-unselected" id="med-level">MED</button><button class="button-unselected" id="hi-level">HI</button>
|
<button class="button-unselected" id="low-level">LOW</button><button class="button-unselected" id="med-level">MED</button><button class="button-unselected" id="hi-level">HI</button>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<img src="./dancing_jesus.gif">
|
<img src="./dancing_jesus.gif">
|
||||||
</div>
|
</div>
|
||||||
<div id="log-container">
|
<div id="log-container">
|
||||||
<button id="refresh-log" onclick="refreshLog()">Refresh Log</button><br>
|
<button id="refresh-log" onclick="refreshData()">Refresh Log</button><br>
|
||||||
<!-- <textarea id="log-area"></textarea> -->
|
<!-- <textarea id="log-area"></textarea> -->
|
||||||
<iframe id="log-area" src="log.txt"></iframe>
|
<iframe id="log-area" src="log.txt"></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user