In this task, you will create a Statistics Collector that records the content in inventory by type over time:
This task is based on the same model that was used in the Task 1 of this series. For information on how to open the model, please refer to that task:
In this step you will add events to the statistics collector. To do this:
In this step, you listened to the On Slot Entry and On Slot Exit event. In both cases, you added a label to both events called Delta. Delta will be used later to increment or decrement the content, as items enter or exit inventory. Both events also use the item's Type label as the row value.
In this step, you will add columns to the Statistics Collector. To do this:
In this step, you added three columns: Time, Type, and Content. The Time
and Type columns are straightforward; whenever an item enters or exits
two columns will record the current time and the Type associated with each
row. The third column doesn't record a value when the row is added.
Instead, it is connected to both events. Once the row has been
added, then the statistics collector will fire its On Row Updating
trigger, and then update the connected column.
When that event happens,
the Content column will record the value of Content, a row label on the
One remaining task is to make sure that the Content label has the correct data, which you will do later in this task.
This step has a single step: click on the Row Options tab, and check the Keep value and labels for finished rows box.
Normally, when you finish a row, the statistics collector deletes the labels connected with that row value. By checking this box, you can tell the statistics collector to keep those labels, as well as the row value. The row is still finished, however, and the row value and labels are disconnected from that row. The next time an event produces the row value, the statistics collector will add a new row, and connect the row value and the row labels to the new row.
This option allow the statistics collector to remember values between events, even though both events finish the row.
In this step, you will add triggers to the Statistics Collector. To do this:
You can right click on the ContentByTypeOverTime collector in the Toolbox and select the View Table option. If you reset and run the model, you will see the table record the output by type each hour. You may wish to run the model as fast as possible to see the data populate.
When an item enters the Storage System, the statistics collector
data entity and adds two important labels:
itemlabel (an event parameter label) records which item entered.
Deltalabel (an additional label) records a value of
This event returns the type of the item as the Row Value. Since the statistics collector always finishes its rows, it doesn't have a row for that row value. This means that it will always add a row for the value. However, because you checked the Keep value and labels for finished rows box, the Content label for that row is present, and remembers the previous value of Content for that row. Since the row value is the Type of the item, the Content label on this row matches the content for that Type.
When the row is added, the Time and Type columns are recorded. Then, the On Row Updating trigger fires, where you incremented the Content row label by Delta. In this case, Delta is 1, so the Content increases.
After the trigger fires, the statistics collector sets the Event Value of the Content column, because it is connected to the current event. In this case, the statistics collector records the value of the Content row label.
When an item exits the Storage System, the same process happens, except that the Content label is decremented, rather than incremented.
Now you will create a chart to show the data in the statistics collector as a time plot. To do this:
If you reset and run the model now, you will be able to see the chart show a time plot of your ContentByTypeOverTime collector. As before you may have to run the model for some time to see the results.