question

Trevor Manzanares avatar image
0 Likes"
Trevor Manzanares asked Trevor Manzanares answered

Calculate Span Time Excluding Scheduled Down Time?

This question was asked a few years ago with no definitive answer. I'd like to calculate raw manufacturing days, not absolute days. In the Setup Trigger, I set a label with the model time, then fix setup time at 5 seconds. In the OnSetupFinish trigger, I calculate how much time has elapsed for the process time. Since this combiner obeys a work schedule, the span time calculation is often longer than 5 seconds because of weekends and days off. Any idea how to calculate span time just when the combiner is not scheduled down?

FlexSim 18.0.0
calculate times
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
0 Likes"
Jordan Johnson answered Jordan Johnson commented

In this model, I calculate the amount of time (in days) that the object has been in all states except Scheduled Down. This can be accomplished with a Statistics Collector. Here are the steps that I followed:

  1. Create a new Statistics Collector (use the Toolbox add button)
  2. On the Data Recording tab, set the Row Mode to Enumerate
  3. Add the combiner to the Enumerated Rows list using the sampler button
  4. In the Columns section, add a column and name it Object. Set its update mode to When Row is Added, and set its value to the ID of the row value (using the pick option)
  5. Add another column called ManufacturingDays. Set its update mode to Always, and set its value to the following code:
DateTime(Model.statisticalTime - data.rowValue.as(Object).stats.state().getTotalTimeAt(STATE_SCHEDULED_DOWN)).totalDays

On the General Tab, click the View Table button. Reset and Run the model, and you will see the ManufacturingDays column slowly increment. It takes a while, because the combiner is down so often.

This model demonstrates the steps given above:

span-time-with-work-schedule-2.fsm


· 2
5 |100000

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

Trevor Manzanares avatar image Trevor Manzanares commented ·

Thanks @jordan.johnson, this is a great start. What about calculating the manufacturing time for each object that gets processed by the combiner? I imagine it would be the same calculation you gave me, but wrapped in a for loop?

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Trevor Manzanares commented ·

If you mean the total time for all items excluding setup, you can get that using getTotalTimeAt(STATE_SETUP) or something similar. If you want a list of times, one time for each item, see the attached model. I use a Process Flow to listen to events, and to record the duration between those events. Then I use a Statistics Collector to log that data in a table. There is a column for how long the item was in the combiner, and another for how long the item was in the combiner, without the scheduled down time.

span-time-with-work-schedule-3.fsm

0 Likes 0 ·
Trevor Manzanares avatar image
0 Likes"
Trevor Manzanares answered

Found a workaround, on SetupFinish I calculate an average setup time for each item by dividing the total setup time by the number of single items coming in from Source1. It's close, but not exact.


5 |100000

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