In this tutorial you will create a Statistics Collector that record the output of the Stations. This tutorial is based on the same model that was used in the Tutorial 1 of this series. For information on how to load the model, please refer to that tutorial:
After following this tutorial, you should have a new Statistic Collector and chart that looks like the following.
In this step you will create and setup a new statistics collector. To do this:
0
. In this case we want the value for the
Output to be 0
when the Row is added, but we will get the actual output of the station in
the Event Value box.data.newValue
.This will use the label that was created on the On Output Change event parameters, which looks at what the new value for the event is when it fires. In this case, it is the station’s output.
Reset and run the model. If you right click on the StationOutput collector object in your Toolbox tab, and select View Table, you will be able to see the statistic collector’s table update for each station.
The statistics collector can listen to a group of objects. If any of the objects in the group fire the event, the statistics collector will respond to that event. In this task, you listened to the On Output Change event of all the objects in the Stations group. This means that if any Station fires its On Output Change event, then the statistics collector will respond.
When you listen to an object event, that event may have parameters.
In this example, you listened to the On Output Change event,
which has two parameters: the new and old values of the output statistic.
These parameters are assigned as labels on the data
entity. In this task, you used data.newValue
in the
value of the Output column. newValue
is a parameter
of the On Output Change event, and is assigned a label
on the data
object.
current
In the statistics collector, the keyword current
refers
to the object that fired the event. When any of the stations
fire their On Output Change event, current
will
refer to the station that fired the event.
You can connect an event to one or more columns. When the event fires and yields its row value, then the statistics collector will make sure there is a row for that value. Then, for each connected column, the statistics collector will record the Event Value for that column on the current row. In this task, you connected the On Output Change event to the Output column. When a station's output changes, the statistics collector will make sure there is a row for that station, and then it will write the new output value in the Output column.
The statistics collector allows you to control how much memory is required per column. In this task, you set the Storage Type to Integer. This means that the field will only be able to store integer values, but it will require less memory than a Double column.
Right now, the statistics collector adds a row for each station when its output changes for the first time. This means the order of rows in the table depends on how the model runs.
To fix this:
If you reset and run the model now, you can view the table and should now see that the StationOutput collector's table has ordered the stations correctly.
When the Stations - On Reset event fires, it yields an array containing all objects in the Stations group. These objects are in the order shown in the Group properties window. Later, when the Stations - On Output Change event fires, there is already a row for the station, so the Statistics Collector doesn't add a new row. However, that event is connected to the Output column, so the Output column on the station's row is updated.
Next we will add a simple table chart to display the output in the dashboard. When finished the table should look something like this.
To create the chart:
If you reset and run the model you can now see that the table chart will track the station output. You may need to run the model at a higher speed to see this happen.
In the next task we will use the Statistics Collector to display the stations content over time.