Events
Prerequisites
Before configuring the event types, make sure the Measurements and Asset tree are configured.
Configuring the event types
Let's start by creating the Mixing batch event type. Go the the Events page and click + Create event type. Enter the following:
- Name: Mixing batch
- Description: The entire mixing process
- Parent: no parent
With the event created, select it and click the purple icon Add property. Attach the following properties to the Mixing batch event type:
Name | Description | Datatype | Type | UoM |
|---|---|---|---|---|
Average power | The average power usage for the batch | number | simple | kwatt |
BatchID | The unique batch identifier | string | simple | |
Max Level | The max. tank level | number | simple | litre |
Recipe | The recipe used for this batch | string | simple | |
Total energy (J) | The total energy usage of all the steps | number | simple | joule |
Total energy (kWh) | The total energy usage of all the steps | number | simple | kwatth |
Next, let's create the sub-events for the 3 phases of our batch. Go the the Events page and click + Create event type. Create an event type for each:
Name | Description | Parent |
|---|---|---|
Filling step | Mixing batch filling step | Mixing batch |
Mixing step | Mixing batch mixing step | Mixing batch |
Emptying step | Mixing batch emptying step | Mixing batch |
For each of these event types, add a single event type property:
Name | Description | Datatype | Type | UoM |
|---|---|---|---|---|
Total energy (J) | Energy usage of step | number | simple | joule |
Now we have created all event types, we go back to the asset tree and attach our event types to our Mixer assets.
Associating the event types to the assets
Go the the Assets page and select Line 1 > Mixer. Click the yellow + configure event. Set the following:
- Basis:
- Detection mode: historian
- Event type: Mixing batch
- Parent: empty
- Settings:
- Data reference:
- Data reference: AssetProperty
- Asset property: select Line 1 > Mixer > Running from the tree.
- Refresh interval: 1m
- Grace period: 0m
The Mixing batch event type is now attached to the Line 1 Mixer. Now, let's configure the Event properties. Unfold the Mixing batch event type attached to the Mixer of Line 1, and configure the event properties as follows:
- Max Level:
- Basis:
- Detection mode: historian
- Priority: 0
- Settings:
- Data reference: Asset property: Line 1 > Mixer > Level
- Aggregation: max
- Start offset: 0s
- Stop offset: 0s
- Close after: 1m
- Preview enabled: On
- Good points only: On
- Recipe: same as Max Level, with the following changes:
- Settings:
- Data reference: Asset property: Line 1 > Mixer > Current recipe
- Aggregation: first
- Total energy (J): same as Max Level, with the following changes:
- Settings:
- Data reference: Asset property: Line 1 > Mixer > Energy usage
- Aggregation: integral
- Average power:
- Basis:
- Detection mode: calculation
- Priority: 1
- Inputs:
- Alias: _E
- Data reference type: EventTypeProperty
- Event type property: Total energy (J)
- Script:
currentEvent := local.get("CurrentEvent")
dur_s := times.duration_seconds(currentEvent.Duration)
if is_equal(dur_s, 0) {
return
}
if _E.Value == undefined {
return
}
return (_E.Value / dur_s) / 1000- BatchID:
- Basis:
- Detection mode: calculation
- Priority: 0
- Settings:
- Close after: 1m
- Preview enabled: Off
- Script:
// return a random batch number
return format("BATCH_Line1_%04.f", rand.float() * 10000.0)- Total energy (kWh):
- Basis:
- Detection mode: calculation
- Priority: 1
- Inputs:
- Alias: _E
- Data reference type: EventTypeProperty
- Event type property: Total energy (J)
- Script:
return _E.Value / 3600000.0Now, for each of the 3 steps in the Mixing batch (Filling, Mixing and Emptying), attach the event type the the Mixer asset as follows:
Event type | Detection mode | Data reference | Parent |
|---|---|---|---|
Filling step | historian | Assetproperty Line 1 > Mixer > Filling | Mixing batch |
Mixing step | historian | Assetproperty Line 1 > Mixer > Mixing | Mixing batch |
Emptying step | historian | Assetproperty Line 1 > Mixer > Emptying | Mixing batch |
For each event type, configure the following event property:
- Total energy (J):
- Basis:
- Detection mode: historian
- Priority: 0
- Settings:
- Data reference: Asset property: Line 1 > Mixer > Energy usage
- Aggregation: integral
- Start offset: 0s
- Stop offset: 0s
- Close after: 1m
- Preview enabled: On
- Good points only: On
Repeat this process for the Mixer of Line 2.
With these steps done, Factry Historian will detect events in the background based on incoming data from the faketory dataset. Allow some time to pass, or use the Re-evaluation of events function to speed things up.