fix pumps
Took 8 minutes
This commit is contained in:
parent
e7c3e26b52
commit
85ea181daf
@ -26,6 +26,7 @@
|
||||
"buffer": "^6.0.3",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"debug": "^4.3.4",
|
||||
"detect-rpi": "^1.4.0",
|
||||
"express": "~4.16.1",
|
||||
"express-ws": "^5.0.2",
|
||||
"hc-sr04": "^0.0.1",
|
||||
|
@ -21,6 +21,8 @@ import {Settings} from "./Settings";
|
||||
import axios from "axios";
|
||||
import GPIO from "rpi-gpio";
|
||||
|
||||
const isPI = require("detect-rpi");
|
||||
|
||||
const log = debug("itender:station");
|
||||
const mixLog = debug("itender:mix");
|
||||
|
||||
@ -140,7 +142,14 @@ export class iTender {
|
||||
await GPIO.setup(x.container.pumpPin, GPIO.DIR_OUT);
|
||||
await GPIO.write(x.container.pumpPin, true);
|
||||
} catch (e) {
|
||||
log("[ERROR] If iTender is running not on a pi, this is normal, if not this is an critical GPIO Error");
|
||||
if (isPI()) {
|
||||
log("[ERROR] GPIO I/O Error " + e);
|
||||
iTender.cancelFill();
|
||||
return;
|
||||
} else {
|
||||
log("[WARNING] GPIO I/O Error, but it's normal cause you are not on raspberry");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +170,13 @@ export class iTender {
|
||||
try {
|
||||
GPIO.write(x.container.pumpPin, false);
|
||||
} catch (e) {
|
||||
log("[ERROR] If iTender is running not on a pi, this is normal, if not this is an critical GPIO Error");
|
||||
if (isPI()) {
|
||||
log("[ERROR] GPIO I/O Error " + e);
|
||||
iTender.cancelFill();
|
||||
return;
|
||||
} else {
|
||||
log("[WARNING] GPIO I/O Error, but it's normal cause you are not on raspberry");
|
||||
}
|
||||
}
|
||||
|
||||
timers = arr;
|
||||
@ -184,19 +199,23 @@ export class iTender {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
static cancelFill() {
|
||||
static async cancelFill() {
|
||||
if (!this._currentJob || this.status != iTenderStatus.FILLING)
|
||||
return;
|
||||
clearInterval(this._jobCheckInterval);
|
||||
this._currentJob.successful = false;
|
||||
this._currentJob.endAt = new Date();
|
||||
this._currentJob.save();
|
||||
await this._currentJob.save();
|
||||
|
||||
|
||||
for (let x of this._currentJob.amounts) {
|
||||
// stop pump pin
|
||||
//x.container.pumpPin
|
||||
//GPIO.write(x.container.pumpPin, false);
|
||||
try {
|
||||
await GPIO.write(x.container.pumpPin, false);
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
iTender.setStatus(iTenderStatus.READY);
|
||||
|
@ -1643,6 +1643,11 @@ destroy@~1.0.4:
|
||||
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
|
||||
integrity sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==
|
||||
|
||||
detect-rpi@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/detect-rpi/-/detect-rpi-1.4.0.tgz#f2fe3da65793d608d62f99b8404734721b7c77bb"
|
||||
integrity sha512-EeAj8C7zCdjzNqJCYEVmKcBvu9DmxJncCOkwvAfa7J4I0ZLRywZ1jSeeqI2Kvx/2Gn2OOa1lSXSigZ4wy4M6Tg==
|
||||
|
||||
diff@^4.0.1:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
|
||||
|
Loading…
x
Reference in New Issue
Block a user