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
3 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:

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.

Joerg Vogel avatar image Joerg Vogel commented ·

In the situation of a partial stay time you have to store the entry time of an object in a label at the item.

1. alternative, writing beginning stay time to label OnEntry trigger by template Create and Initialize Label or by source code

addlabel(item,"staytime1", time());

2. alternative, writing to a label in any other object's trigger by above template or by source code

addlabel(item,"staytime1", getentrytime(item));

To compute the partial stay time you go to the OnExit trigger of the last object you evaluate the stay time for. In the source code editor you create a local variable to store the stay time.

double staytimeLocal = time() - getlabelnum(item, "Staytime1");

The local variable contains now your stay time. You use the variable to store its value in a persistent place like a global table.

Another approach is to store each entry of every item in every object in a global table. The table can store in this Flexsim version numbers or strings. You have to convert the item and the object to numbers to filter the table to identify the entry time. The command tonum(item) or tonum(current) do that. In the object you like to get the partial stay time you look for a row where the item value as number and the entry object's number matches your requirement. Then you use this row to evaluate the entry time and compute the stay time. This approach works only for smaller models or shorter run times, because you could get a vast amount of data, which slows the simulation.

1 Like 1 ·
Ahmed Azab avatar image Ahmed Azab commented ·

@Jörg Vogel

to do this .. shall i use the Flexsript window or i can use the triggers and labels ?

please give me a detailed explanation for how to do this step by step on flexsim 5

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Ahmed Azab commented ·

@Ahmed Azab if you look for further methods and hints to use an older Flexsim version you could take a look into the previous forum. There you have to use the search to find the information for your own, because it is read only. But ithe forum has its own value.

1 Like 1 ·
Ahmed Azab avatar image Ahmed Azab commented ·

Dear @Jörg Vogel

Thank you for your help .. it is very helpful > one more questions please:

How to get the partial stay time of the flow item in the system ?

for example : if i have a simple multistage model of 4 processors and 4 queues , and i want to get the stay time of an item form entering the second processor to the time to the sink or to the entry to the fourth processor. (Flexsim 5 used)

Thank you

0 Likes 0 ·