fix pumps

Took 8 minutes
This commit is contained in:
Tobias Hopp 2022-11-28 12:05:10 +01:00
parent 6aad142664
commit b5704f4359

View File

@ -105,7 +105,7 @@ export class iTender {
job.estimatedTime = 0; job.estimatedTime = 0;
let tolerance = 3; let tolerance = 3;
for (let x of amounts) { for (let x of amounts) {
let c = await Container.findOne({$and: [{enabled: true}, {filled: {$gt: x.amount + tolerance}}]}); let c = await Container.findOne({$and: [{enabled: true}, {filled: {$gt: x.amount + tolerance}}, {content: x.ingredient}]});
if (!c) { if (!c) {
mixLog("Not enough ingredients!"); mixLog("Not enough ingredients!");
reject(RejectReason.NOT_ENOUGH_INGREDIENTS); reject(RejectReason.NOT_ENOUGH_INGREDIENTS);
@ -118,6 +118,7 @@ export class iTender {
} }
console.log(amounts);
job.drink = drink job.drink = drink
job.amounts = amounts as { ingredient: IIngredient, amount: number, container: IContainer }[]; job.amounts = amounts as { ingredient: IIngredient, amount: number, container: IContainer }[];
if( job.estimatedTime < 0.5 ) if( job.estimatedTime < 0.5 )
@ -143,7 +144,7 @@ export class iTender {
let timers: NodeJS.Timeout[] = []; let timers: NodeJS.Timeout[] = [];
for (let x of job.amounts) { for (let x of job.amounts) {
console.log(x);
// Start pump here // Start pump here
try { try {
await MyGPIO.setup(x.container.pumpPin, GPIO.DIR_OUT) await MyGPIO.setup(x.container.pumpPin, GPIO.DIR_OUT)