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