question

Travis Cunningham avatar image
1 Like"
Travis Cunningham asked Travis Cunningham answered

Time in System - Dashboard Issue

I am having trouble displaying average time in system.

I am trying to use custom code in a model documentation window on a dashboard.

I want to show average time in system, but only for specific item types.

Can you please provide me with a code that will do this, preferably one that will work in the dashboard.

Thank you,

FlexSim 7.7.4
dashboardsitem typetime in system
5 |100000

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

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Phil BoBo edited

Here are two different ways you could collect this type of data.

Using Tracked Variables

You could create a tracked variable for each itemtype, and set the tracked variable OnEntry of each Sink with the staytime of the item (time() - getcreationtime(item)). Then you could display a Dashboard chart for each tracked variable or use a Model Documentation chart to display the average value of each tracked variable.

Attached is an example model (staytime-by-itemtype-with-trackedvariable-labels) that shows how this can be done.

This example will automatically record an arbitrary number of itemtypes without any adjustments to the model (the tracked variables are added dynamically as the model runs). If you have multiple sinks, you will need to adjust the code of each sink so that they reference the "staytimes" label on one Sink though.

Using ProcessFlow Zones

Another way to gather and display this type of stats in a single chart is to use a ProcessFlow Zone Subset Dashboard chart.

Attached is an example model (staytime-by-itemtype-with-processflow-zones) that shows how you can listen to events using ProcessFlow to gather custom statistics like this using the Zone object.

How it works:

The ProcessFlow starts with an Event-triggered Source to listen for the creation of each item at each source in the model. (You could add additional Sources to listen to in the activity.)

Then it adds a label to the token with the itemtype of the item of the model.

Then it enters the Zone, which has subsets for each itemtype.

Then it uses a Wait for Event to listen for the destruction of each item in each sink in the model. (You could add additional Sinks to listen to in the activity.)

Then the token exits the Zone.

Note: In FlexSim 2016 Update 1, Zones can be partitioned by itemtype instead of creating a subset for each itemtype. That will make collecting these type of stats easier.

5 |100000

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

Regan Blackett avatar image
3 Likes"
Regan Blackett answered Jordan Johnson commented

I think the easiest way to accomplish this is through the use of a Process Flow "Zone" to help gather the right stats. this solution requires v2016 of FlexSim.

The basic idea will be to create a Token when a Flowitem is released into the model, and let it dwell in a stats gathering "Zone" until the Flowitem leaves the system. Therefore the Staytime of the Token in the Zone will equal the Flowitem's time in System.

Attached is a little sample model of some processors in series, and a small block of Process Flow activities. The 3D model just does what it would do normally, and the Process Flow block is going to help us gather the stats, the same block of activities can probably be applied to just about any 3D model you are working on as-is, I'll go through the individual activities one by one.

First is an Event Triggered Source activity that is set to create a token whenever Source2 in the model releases a Flowitem. Where it says "Exiting item" I've typed the word 'item' which will create a label on the Token. this new 'item' label will allow me to save a reference to the Flowitem the Source just released to the Token we just made. (Note that you can name the 'item' label whatever you want, as long as you are consistent with its use, but it's a convenient name to use because of the next activity)

Next is an Assign Label activity that will capture the itemtype value from the Flowitem, and write it to a label on the Token. I named my Token label 'Type' and used a the "Get Itemtype" option On the 'Value' field. This option assumes that the item reference on the Token is stored in a label called 'item', hence the note in the last paragraph.

The next activity is an Enter Zone activity, which requires a 'Zone' shared asset, which I have named Time in System Zone. In order to make this Zone gather the stat we're interested in I had to do a couple of things. First, I had to create what's called a Subset for each set of Tokens (and thus, Flowitems since each Token is carrying a reference to a unique Flowitem on it, via the 'item' label) whose stats I want to track. The Zone will naturally gather the Staytime for everything that Enters it, but to break out the stat by type like you want I need to the Subsets, defined as shown on the Zone's "More Properties" window:

This allows each type of Flowitem to be assigned to it's own subset, based on the Token label called 'Type'.

The next activity is called "Wait for Event" and it's job is to hold the token from continuing on it's flow until it "hears" a specific event take place in the model, in this case I've told the event to Listen for the OnEntry trigger of the Sink in the 3D model.

'Wait for Event' will hold any token on this event until the desired event takes place and then release them all to whatever activity you want to happen next. However we only want to release a particular token whose 'item' reference is the one that just entered the SInk object. So where it says "Entering Item" I've typed the name of our 'item' label, and selected the 'match' operation so that the 'item' label has to match the involved Flowitem in the OnEntry trigger, thereby only releasing the one Token associated with that Flowitem.

Once the token is released, it leaves the Zone through the Exit Zone activity and reports it's Staytime, from the time it left the Source object to the time to arrived at the Sink object (note the Zone's stats are only updated when something leaves the Zone).

Now in the Dashboard, I can create a Zone Subset chart and use the Sampler in the properties window to associate my dashboard widget with my Zone. on the Statistics tab, I can click the Add Stat button to add my desired stat.

On the 'Value' drop down on that same tab, choose "Average"

Click 'Ok' and run the model and you should see the Staytimes for all three Subsets individually. I hope this helps!

time-in-system-with-a-zone.fsm


ets-activity.png (9.3 KiB)
assign-type.png (8.6 KiB)
subsets.png (28.3 KiB)
wait.png (9.8 KiB)
chart.png (30.7 KiB)
avg.png (8.0 KiB)
· 1
5 |100000

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

Jordan Johnson avatar image Jordan Johnson ♦♦ commented ·

In this example, to get the current value of a subset's staytime in FlexScript, use

getstat(getactivity("ProcessFlow", "Time in System Zone"), "SubsetStaytime", STAT_AVERAGE, 0, "Type 2")

The first parameter is the object that has the desired statistc, in this case the Zone itself. The next is the name of the desired statistic. The third parameter is the value for that statistic (which could also be STAT_CURRENT, STAT_MIN, or STAT_MAX). These parameters are required for all calls to the getstat command.

The fourth parameter, (sometimes required for Process Flow objects), deals with the particular instance object. For general process flows, this parameter is ignored. For FixedResource and TaskExecuter process flows, this parameter should be the name of an attached object. The fifth, in this case, is the name of the subset.

2 Likes 2 ·
Travis Cunningham avatar image
0 Likes"
Travis Cunningham answered

Thank you all for the help on this issue.

I really appreciate it.

I used the Using Tracked Variables by phil.bobo

Thanks all,

5 |100000

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