Porovnávané verzie

Kľúč

  • Tento riadok sa pridal
  • Riadok je odstránený.
  • Formátovanie sa zmenilo.

...

If we want to calculate the average temperature for all rows and write it in the TAvg column, it is enough to create creating one structured eval tag is sufficient. Enter the Value Type "Ae - Analog" and enter the arithmetic average as the expression

...

By specifying row [0] we define that we are working with all rows. We want to store the result in the TAvg column, so we set the Destination column to SV.MyPlc[0]^TAvg.

Info

In fact, such Such an eval tag definition causes the D2000 Calc process, which is the parent of the eval tags, to create one "shadow" eval tag for each row of the destination structure and generate the corresponding calculation for it:

  • 1. row: ( SV.MyPlc[1]^T1 + SV.MyPlc[1]^T2 + SV.MyPlc[1]^T3) / 3
  • 2. row: ( SV.MyPlc[2]^T1 + SV.MyPlc[2]^T2 + SV.MyPlc[2]^T3) / 3
  • 3. row: ( SV.MyPlc[3]^T1 + SV.MyPlc[3]^T2 + SV.MyPlc[3]^T3) / 3
  • ... etc.

The advantage of structured eval tags is that we define the calculation for all rows of the structure in a simple way. In addition, if we add more rows to the structure, new "shadow" eval tags for the new rows will automatically be created, so we do not have to modify the eval tag at all. And if we need to change some parameter of the calculation (e.g. add a new temperature T4), it is convenient to do it in one place.

Such a structured eval tag only publishes values to a structured variable, it itself has no value of its own.


Info
titleTip

We recommend naming the structured eval tag so that it contains the name of the structured variable and the name of the target column - in our case P.MyPlc.TAvg - then it will be easier to search using referential integrity.

...

Info
titleAdvanced tips

Various mathematical functions and expressions can be used in eval tags, including a conditional expression.

The so-called extended syntax is also supported, which allows dividing the calculation into several steps, defining local variables, using the condition IF - THEN - ELSE, and jumping to the label - GOTO.


Structured historical values

...

Info
titleTip

When we have a structured variable selected in D2000 Cnf and we click the "Insert to a list of archives" icon, we can select the columns we want to archive. We do not recommend archiving the entire structure as a whole. 

If we create historical values by clicking on the "New object" icon in the toolbar, it is advisable to create derive their names from the name of the structured variable and the name of the archived respective column.

Similar to the structured eval tag, we specify the archiving of the entire column (SV.MyPlc[0]^T1, SV.MyPlc[0]^T2, and SV.MyPlc[0]^T3).

...

The next step is to create a calculated structured historical value that will calculate the average of temperatures. We will create a historical value named H.MyPlc_TAvg, and set the the Archive purpose to Calculate archived values by defined statement.

We will set the Archive size to any of the three source archives, e.g. H.MyPlc_T1 (it is also possible to use a structured variable item for the dimension, e.g. SV.MyPlc[0]^TAvg, in this case, it would also be possible to check Publish values and the calculated averages would be published in the specified column (so we would not even need the above created structured eval tag P.MyPlc.TAvg).

...

(H.MyPlc_T1[0] + H.MyPlc_T2[0] + H.MyPlc_T3[0]) / 3

In the statement, other only historical values and constants may appear, but not other types of D2000 objects (e.g. I/O tags). If we want to use the values of another type of object, we must first configure the primary historical value for it.


Info

In fact, such a definition of the calculated historical value will cause the D2000 Archiv process, which is the parent of the historical values, to create for each row of the archived structure (according to the Archive Size parameter) one "shadow" historical value and generate the corresponding calculation for it:

  • 1. row: (H.MyPlc_T1[1] + H.MyPlc_T2[1] + H.MyPlc_T3[1]) / 3
  • 2. row: (H.MyPlc_T1[2] + H.MyPlc_T2[2] + H.MyPlc_T3[2]) / 3
  • 3. row: (H.MyPlc_T1[3] + H.MyPlc_T2[3] + H.MyPlc_T3[3]) / 3
  • ... etc.

The advantage of structured calculated historical values is that we define the calculation for the entire column of the structure in a simple way. In addition, if we add more rows to the structure, new "shadow" historical values will automatically be created for the new rows, so we don't have to modify the historical value at all. And if we need to change some archiving parameter (e.g. history depth) or change some calculation parameter (e.g. add a new temperature T4), it is convenient to do it in one place.

...

Info
titleAdvanced tips

As with the eval tags, it is possible to replace invalid values with zero, use the %IsNull function, and use various mathematical functions and expressions, including a conditional expression.

The so-called extended syntax is also supported, which allows dividing the calculation into several steps, defining local variables, using the condition IF - THEN - ELSE, and jumping to the label - GOTO.

In addition, special functions for calculated historical values are available. It is also possible to use the @EvalTime system constant in the calculation, which represents the time for which the calculation is performed.

Podobne ako v prípade počítaného bodu je možné nahradiť neplatné hodnoty nulou, použiť funkciu %IsNull a použiť rôzne matematické funkcie a výrazy, včítane podmieneného výrazu.

Podporená je aj takzvaná rozšírená syntax, ktorá umožňuje definovanie lokálnych premenných, použitie IF - THEN - ELSE a GOTO.

Navyše sú dostupné špeciálne funkcie pre vypočítané archivované hodnoty. Je taktiež možné vo výpočte použiť systémovú konštantu @EvalTime, ktorá reprezentuje čas výpočtu.



Statistical structured historical value

And finallyFinally, we will create a statistical historical value value H.MyPlc_TAvg_5MinWAvg, for which we will set the Archive purpose to Calculate archived values by statistical function. We set the source Historical value to the calculated historical value with average temperature H.MyPlc_TAvg.

...