Virtual (or calculated) Items are items that can be trended, but which have not been read from an underlying control system. Each Virtual item requires a user specified name and a calculation that is to be evaluated each time the active plot updates. Descriptions and Engineering Units can also be provided if so desired.
Virtual items are stored at the client level. That is to say that they are not historized within SapphireTrend. However, Virtual items are stored in the associated plot file for the active plot and can therefore be 'recovered'. Thus whilst they are not historized themselves, they will give the appearance of having been stored when they are used with a data source capable of supplying historical values (such as an HDA OPCServer or the Sapphire Collector).
An expression can be a combination of one or more:
genuine OPC items
literals
operators
functions
Once created, Virtual items can be manipulated in stPro in an identical manner as 'genuine' OPC items.
Tip: The Items used within an expression do not need to have been assigned to pens.
See the Syntax page for a definition of the constructs that can be used to define an expression.
Note: Virtual items can be added to stOCX by specifying a data location of "__VIRT__" when adding the pen via the AddPen method. The SetPenAttribute method can then be used to define the required expression for the pen.
Virtual Items are created by Clicking the "Virtual..." button on the Plot Properties Mapping tab. This will launch the Virtual Item dialog where the details of the required Virtual Item can be entered.
The Expression for an existing Virtual Item can be edited by clicking the "Expression..." button on the Plot Properties Pens tab. This will launch the Virtual Item dialog where the details of the Virtual Item can be modified.
The following plot is an example of the use of Virtual items within stPro. It displays a harmonic series for a sine wave.
The red pen is trending a sine wave (or first harmonic) and is shown with a display title of "Fundamental" . The green, yellow and blue pens represent the 3rd, 5th and 7th harmonics whilst the cyan pen shows the sum of each of the harmonics.
Within stPro, the Virtual item definitions for pens 2 through 6 are as follows:
Pen No: |
Pen Color: |
Item Name |
Expression: |
1 |
Red |
Fundamental |
N/A - genuine OPC item of math.sine |
2 |
Green |
3rd harmonic |
sin(asin(math.sine)*3)/3 |
3 |
Yellow |
5th Harmonic |
sin(asin(math.sine)*5)/5 |
4 |
Blue |
7th Harmonic |
sin(asin(math.sine)*7)/7 |
5 |
Cyan |
Summed |
"3rd Harmonic" + "5th Harmonic" + "7th Harmonic" + "math.sine" |