fix pumps
Took 8 minutes
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user