question

Mauricio R23 avatar image
0 Likes"
Mauricio R23 asked Mauricio R23 commented

Get tracked variable per hour

Hello, what is the best way to obtain a tracked variable per hour? I am currently using a tracked variable to count the number of times a forklift passes through a node, and I would like to have that same value but on an hourly basis. Should I use Statistics collectors for this purpose? How?

Thanks.


FlexSim 23.1.2
tracked variables
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

·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Mauricio R23 commented

In the attached example I get the value of a number label every hour, but the general setup can be used for any value you might want to track. In this example I keep the tracked value untouched. If you don't need the total value, you can also build a simpler collector by resetting the value every time you record it.

The Statistics Collector uses a Timer/On Reset event that repeats once every hour. Every time it fires, it writes the current value of the tracked label/variable/... to the label newValue on the data object. I used a row value of 1 in the example. The actual value doesn't matter. It is only important that the event does have a fixed row value (not leaving the field blank) and that the rows are still "finished" after the event.

capture1.png

In the Columns tab, the current time and value of the last hour is recorded. The value is calculated as the difference between the newValue label (current total) and the previousValue label (previous total). The ? operator first checks if the label actually exists and returns a 0 if it doesn't. It is needed because the previousValue label will not exist yet when the data is recorded for the first time.

capture2.png

The previousValue label is created/updated in the On Row Added trigger, where its value is set to the current newValue label.

Because we finish the rows (in order to create a new row for every event despite the fixed row value), you have to the check the option to keep row labels for finished rows, so the previousValue label is not lost between events.

capture3.pngvalue-per-hour-collector-fm.fsm


capture1.png (27.6 KiB)
capture2.png (32.1 KiB)
capture3.png (39.9 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.

Mauricio R23 avatar image Mauricio R23 commented ·

Thank you very much, it works perfectly! And as you mentioned, I was able to apply it to other variables and it works well too.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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