Page 1 of 1

Batch size server

Posted: Thursday 03 September, 2015 - 14:25
by EvelineHermans
Hello!

I'm currently struggling with the batch size (B) in a server.
I have two different products that can enter this server (red and blue) and they have to be converted from one barrel to an amount (in kgs). The red barrels consist of 75 kgs, while the blue barrels have 100 kgs. Using the Batch Rule (1 to B) I would like to convert the product from a barrel to kgs. I have defined the number of kgs per barrel in a table to make sure that I can change it easily.

But... I can't get my code for the Batch-definition working.

So far I have the following code for B:

Code: Select all

Do(
if(Label([barrel], i) = 1,Cell(1,1, refkgs_barrel)),
if(Label([barrel], i) = 2,Cell(1,2, refkgs_barrel))
)
Barrel_batch_size.mod
(12.27 KiB) Downloaded 343 times
Can someone tell me what I do wrong?

Thanks,
Eveline

Re: Batch size server

Posted: Tuesday 08 September, 2015 - 12:01
by HarryBunnik
Ha Eveline,

You're very close. Your problems lays in the fact that when you have a red product (Label([Barrel], i) = 1) the first IF-statement is nicely returning 75. However, in the next line of code (that also will be executed) you check if the label([Barrel], i) might be 2. This returns a false and that is then the number (0) that is returned, instead of the 75 that you want (since destroying a product in a Server is not allowed, it will simply push through the main product and continue).

So the last value calculated, is what is returned and used as batchsize.

I think that if you use a case statement :

Code: Select all

Case(
  WhichIsTrue(
    Label([barrel], i) = 1,
    Label([barrel], i) = 2
  ),    
  Cell(1,1, refkgs_barrel),
  Cell(1,2, refkgs_barrel)
)
your problem would be solved.

Cheers,

Harry

Re: Batch size server

Posted: Tuesday 08 September, 2015 - 12:11
by SimonvdW
Hi Eveline,

in addition: The conclusion of Harry is correct. For barrels of type 2 (blue) the second evaluation result in a 0. As a result no copy is made and just the original will move on.

An easy way of writing the Batchrule code is :

Cell(1, Label([barrel], i), refkgs_barrel)

Here the label value is used as second parameter to refer to the correct column in the table.

Regard, Simon

Re: Batch size server

Posted: Thursday 10 September, 2015 - 09:15
by EvelineHermans
Thanks a lot! I now indeed see and understand where it went wrong..