fix pumps
Took 3 minutes
This commit is contained in:
parent
536de17d31
commit
e7c3e26b52
@ -19,6 +19,7 @@ import {clearInterval} from "timers";
|
||||
import {RejectReason} from "./RejectReason";
|
||||
import {Settings} from "./Settings";
|
||||
import axios from "axios";
|
||||
import GPIO from "rpi-gpio";
|
||||
|
||||
const log = debug("itender:station");
|
||||
const mixLog = debug("itender:mix");
|
||||
@ -135,15 +136,19 @@ export class iTender {
|
||||
let timers: NodeJS.Timeout[] = [];
|
||||
for (let x of job.amounts) {
|
||||
// Start pump here
|
||||
//await GPIO.setup(x.container.pumpPin, GPIO.DIR_OUT);
|
||||
//await GPIO.write(x.container.pumpPin, true);
|
||||
try {
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
let waitTime = (Settings.get("secondsPer100ml") as number) / 100 * x.amount * 1000;
|
||||
mixLog(`Starting output of pump ${x.container.pumpPin}`);
|
||||
//mixLog(x.ingredient + " takes " + (waitTime / 1000) + "s for " + x.amount + "ml");
|
||||
let timer = setTimeout(() => {
|
||||
// Stop pump here
|
||||
//GPIO.write(x.container.pumpPin, false);
|
||||
let timer = setTimeout(async () => {
|
||||
|
||||
|
||||
// Remove from list of timers
|
||||
let arr: NodeJS.Timer[] = [];
|
||||
@ -151,7 +156,14 @@ export class iTender {
|
||||
if (timers[i] != timer)
|
||||
arr.push(timers[i]);
|
||||
}
|
||||
mixLog(`Stopping output of pump ${x.container.pumpPin}`)
|
||||
mixLog(`Stopping output of pump ${x.container.pumpPin}`);
|
||||
// Stop pump here
|
||||
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");
|
||||
}
|
||||
|
||||
timers = arr;
|
||||
|
||||
}, waitTime);
|
||||
|
Loading…
x
Reference in New Issue
Block a user