In this example we have Machine device that submit how many details where produced. We want to find what is production rate of our machines.
Let’s define our states:
Here is condition that chack does machine in Low Production state or not:
Here steps required to do this:
Our view ready and now we know how much time(in percent) machines spent in different states.
We can also use multiple fields from different assets\devices to calculate state. In this example we want detect how much time machines spent in critical state. Such visualisation will give an understanding how machine prorforms compered to other machines and when it should be maintained to prevent downtime.
We know that our machines is in critical state when pressure goes up and rotation speed goes down. So let’s find how much time spent in critical state.
Here is a formal definition of Critical state:
Here is a list of supported aggregation functions for state fields:
Before applying transformation you need to get a reference to the original field value. Here is an example how to do this:
double temp = avg(Machine.temperature);
All 3 parts are required, you can not access original field value without aggregation function.
If original field value is an attribute, entity name or owner name - you should use uniq() aggregation function.
This template can be used for comparing text fields:
String currentState = none(machine.status);
return "running".equals(currentState);
State fields supports following aggregation functions:
Each function allows only 1 argument - reference to the filed on format EntityName.fieldName. For example:
sum(Machine.temperature)
Commonly, states are used for calculating how much time device/asset spent in different states. To get more precise results it is recommended yo use none() aggregation - in this case system will process only raw telemetry to define is device inside defined state or not.
Aggregation function applied to a grouped dataset. Find more details about Grouping and Aggregation in this article
In most cases amount of data analysed during state calculation is big enoguh. To guarantee performance function should be defined using Java language (Java 8).