question

Ahmed Azab avatar image
0 Likes"
Ahmed Azab asked Adrian Haws commented

how to get the total stay time for a flow item through a model with a multiple processors and queues ?

Other (please specify)
Other
staytimetracked variabletime in systemgetcreationtime
5 |100000

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

Ben Wilson avatar image
3 Likes"
Ben Wilson answered

In addition to @Jörg Vogel's manual method for individual items, you can also use the TimeInSystem tracked variable, available by default in every model, to do bulk tracking, graphing, and data manipulation.

You can add a Time In System histogram dashboard that will show the staytimes of your items in bulk buckets.

You can also drill down into the TimeInSystem tracked variable itself to get all the individual stay times from every item. A tracked variable keeps its data in a bundle, and you could access that bundle using the FlexScript bundle commands to use the data however you want.

If needed, you can create additional custom tracked variables. Learn more about them in the User Manual.


5 |100000

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

Joerg Vogel avatar image
4 Likes"
Joerg Vogel answered

Typically you get the creation time of a Flowitem by the command getcreationtime(item). "item" is the reference or pointer to the item you are testing. The difference "time() - getcreationtime(item)" is the staytime where ever you compute the statement. If you process the statement at the sink, you get the model staytime.

5 |100000

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

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Adrian Haws commented

I store the staytime of each item type in a single global table (e.g. name: Staytime_Type_1). If you create a global table before you need a table in the triggers, you can select the tablename while writing the code. In the sink you find in OnEntry Trigger the picklist item Add row and Data to GlobalTable. In the Template editor you find 4 data entry code lines to the global table. The first line writes the name of the item as a string in the table. The other lines are writing different number values to the table. here I start to change the entry. "settablenum(tablename,rows,2,time()-getcreationtime(item));". That is the code to get the staytime of the item. The other code lines can stay the same. You can other values to them, too.

If you distinguish between different itemtypes, the standard methods works only if you use for each itemtype a single sink, because the event to reset the table is the first input of the sink. But that event fitts only to one itemtype. Here I have attached a model, which uses labels in the sink to count the entering of the itemtypes. The OnReset-Trigger sets the label value back to zero. If an itemtype item enters the sink, the labels are checked to reset the table sizes. If the labels are greater than 0 the table is resized. Because I don't use the suggested template the first and second columns contains number data.. First column contains the current simulation time, the second the staytime:

  1. settablenum(tablename,rows,2,time()-getcreationtime(item));

The last code line increments the label of itemtype in the Sink4 by 1.

In the code the names of the labels and tables are set by concenating strings and converted numbers to strings. File Flexsim 5.1.2


staytime-v5.fsm (54.3 KiB)
· 4
5 |100000

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