Computed tags allow users to calculate functions based on other tags within the DATAlake.
To create a computed tag, first, it is is necessary to create a New Tag.
To create a new tag:
It is obligatory to put the folder, tag name and tag type. Choose a folder which has access to all tags needed for the calculation of the computed tag.
After the creation of the shell ID it is necessary to create the computed tag.
To Add Computed tags:
From this menu, create jobs for computed tags or exports to DATAmaestro analytics.
Letter | Description |
---|---|
s | second |
m | minute |
h | hour |
d | day |
In this tab it is possible to edit all the properties of the job in a JSON format. For computed tags the properties that can be edited are:
The truncate option is explained in editing computed tags. |
function (values) { return values["Tag 1"] * values["Tag 2"]; } |
function (values) { if (values["Tag 1"] <= 10.0) { return values["Tag 1"]; } else { return 10.0 } } |
function (values, time) { var d = new Date(time); var w; if (d.getDay() == 0 || d.getDay() == 6) { w = "WEEK-END"; } else { w = "WEEK"; } return w; } |
A computed tag can be updated at any point after creation. The changes may be applied to the entire history or only from the date of change onwards.
Use Save if a periodical change is needed. Use Truncate for example if an error was made in the computed tag formula; this is equivalent to deleting past values and replacing them with new correct ones. |
Example: Calculate the sum of two tags (Tag1 and Tag2).
In the current implementation, for each different combination of tag values, one value of the ComputedTag is calculated. The ComputedTag calculation adopts the precautionary principle, it checks the dates associated with the input tag’s values and it stops at the tag value with the earliest (oldest) date. The main reason for that, is that there is no indication that the last value is with certainty the last one for a while or if another value will be coming soon. Moreover, Tag1 or Tag2 can themselves be computed tags.
Let’s give an example:
- Tag1 corresponds to an index in thousands of m3 of gas. At 10h00 the value is equal to 151.000 m3.
- Tag2 corresponds to an index in units of m3 of gas. At 10h00 the value is equal to 271 m3.
- The ComputedTag adds the values of Tag1 and Tag2.
Now let's assume that at 10h00, both tags Tag1 and Tag2 get a new value. The dates are the same, the calculation is launched and provides a value to the ComputedTag (151.271 m3). At 10h04, the Tag2 gets a new value (272 m3). A simple rule of combination could launch the calculation of the ComputedTag taking into account the new value of Tag2 and it could search for a more recent value of Tag1 (151.000 m3). The calculated value would be 151.272 m3. At 10h09, there is a new value for Tag2 (273 m3) that could be combined with the most recent value of Tag1 (151.000 m3) to calculate the next ComputedTag (151.273 m3).
As the calculation of the ComputedTag, in DM Lake, uses the precautionary principle, it grants the earliest (oldest) tag date. Therefore, in the example presented, at 10h04, Tag2 gets a new value but the last value for Tag1 is at 10h00 (earliest date). Therefore, no calculated value is launched for the ComputedTag despite the fact there is a new value of Tag2 at 10h04. The same happens at 10h09, even though there is a new value for Tag2.
The use of the precautionary principle can be explained by the fact that the tag values are not pushed to DM Lake individually (one at the time), but in packages. The DM Collector works in a buffer mode. Moreover, the data can come from different sources and can have different time delays. Therefore, if we use a simple combination of the tag values Tag1 and Tag2, there is a risk that the ComputedTag values can be incorrect and must be recalculated.
If, for example, Tag1 is stored within a certain delay (in green in the figure below, the pair value/ timestamp 152.000/10h06). If at the moment the Tag2 gets a new value, at 10h09, the computed tag is calculated by a simple combination of Tag1 and Tag2, the new value of Tag1 is stored with a certain delay, the value of the computed tag becomes incorrect.
In summary, the calculation of a computed tag in DM Lake is based on the precautionary principle instead of a simple combination of the tag values. No new value is calculated beyond the earliest date in which the tags were stored, even if certain tags propose more recent values (more recent dates). The most recent date of the calculated tag is the oldest date of the tags.