From b343eacdf78a2a573036dc48bdae1cb49f65b7e1 Mon Sep 17 00:00:00 2001 From: liefersfl Date: Mon, 16 Apr 2018 13:42:32 +0200 Subject: [PATCH] in getMachineProgram amount per component is now rounded to integer. --- src/app/model/cocktail.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/app/model/cocktail.ts b/src/app/model/cocktail.ts index 5fa80fe..99ece9b 100644 --- a/src/app/model/cocktail.ts +++ b/src/app/model/cocktail.ts @@ -42,7 +42,7 @@ export class Cocktail { var lines: any[] = [] // total fragments var fragmentsCount = this.getFragmentsCount() - + this.layers.reverse().forEach(layer => { var programComponents: any[] = [] layer.components.forEach(component => { @@ -60,13 +60,19 @@ export class Cocktail { "amount": this.amount / fragmentsCount }); } - }); - lines.push({ - "components": programComponents, - "timing": 2, - "sleep": 0 - }); - } + }); + + // Round all component amount to integers + programComponents.forEach(pc => { + pc["amount"] = Math.round(pc["amount"]) + }); + + lines.push({ + "components": programComponents, + "timing": 2, + "sleep": 0 + }); + } ) var program = { "recipe": {