question

Ashwath M avatar image
0 Likes"
Ashwath M asked Felix Möhlmann answered

Add Item Label values from Combiner

Pallet Weight.fsmHello,

I have boxes that follow a weight distribution. The Pallet combines 4 of the boxes and sends to the next process. The Boxes have a label created as weight and takes a value from the distribution that I give. The Pallets have a unique ID number that is created. I'm trying to figure out a way to create a label called "Total Weight" on the pallet, that calculates the total weight of the 4 boxes that it holds. Ex : The individual weights of Boxes could be 4, 4.5, 3.8 & 3.9. I'm looking to add these individual weights and create a new label for the pallet that indicates "Total Weight" : 16.2. Attached is a sample model

FlexSim 22.0.11
combinerlabellabel valuetree nodemodel tree
pallet-weight.fsm (30.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

I would suggest to use a code snippet in the OnExit trigger to sum up the label values of all subnodes (items) on the pallet and assign it to a label.

double totalWeight = 0;
for(int i = 1; i <= item.subnodes.length; i++)
{
    totalWeight += item.subnodes[i].weight;
}
item.labels.assert("Total Weight").value = totalWeight;
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.