question

Kevin A2 avatar image
0 Likes"
Kevin A2 asked Kevin A2 commented

Question on the average stay time of individual item with them being combined

Hi, in my simulation model, there is a combiner which combines items (boxes) into a pallet before items leaving at the sink. The items (boxes) are created at different times, but they leaves at the same time as they are on the same pallet. I want to know the average stay time of these items (boxes) in the system (from the moment it is created, to the moment it exits at the sink), how can I do this?

https://answers.flexsim.com/questions/23239/tracking-staytime-of-two-different-itemtypes.html

I've read the above example, but it seems that this method can only get the creation time of the pallet, but not the items (boxes) itself

Thanks!

FlexSim 17.2.5
stay time
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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Kevin A2 commented

The main problem is how you interpret the variable item inside the function getcreationtime(item).

If you look into the manual of the function, you can see that item is just a reference or pointer to the object, you want to get the creation time on. A pallet consists of several items stacked or packed on it. You need a reference to each item on the pallet to get the creation time. Those items are subnodes of the pallet as long as you haven't joined them in the combiner. The first item on the pallet

Object stackedItem1 = item.subnodes[1];

You can get with this reference the creation time.

double modelStayTime = time() - getcreationtime(stackedItem1);
· 3
5 |100000

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

Kevin A2 avatar image Kevin A2 commented ·

Thanks, this really helps.

However, in my model the no. of items on a pallet could be different. Is there a command for counting the no. of items on a pallet? (no. of subnodes of the pallet?) So that I can have a proper loop to get the stay time of all the items on a pallet without error. Thank you very much!

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Kevin A2 commented ·
int itemsOnPallet = item.subnodes.length;

Please look into the manual

References>Coding in FlexSim > Flexscript Class Reference

Class type "treenode" Properties "subnodes"

0 Likes 0 ·
Kevin A2 avatar image Kevin A2 Joerg Vogel commented ·

Thank you very much!

0 Likes 0 ·