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
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.

...

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.

...