Quantcast
Channel: OSIsoft Users Community
Viewing all articles
Browse latest Browse all 1120

Unexpected Behavior (PI Calculation Expression)

$
0
0

Note: I am very new to PI so excuse me if my terminology is not on point. I notice the GUI and the VB API use different terminology for some things which adds some confusion.

 

I created a ProcessBook Display with a number of "Values" on it. These values are set to display the results of a PI Calculation (these are set by a subroutine at initialization). Each of the values also has a Multi-State set so that its color indicates its status. The appearance of the display is configured to match exactly what is seen on a particular computer display from another system, which uses a 16 color palette on a black background.

 

My display works as intended, but it is entirely illegible when printed. I tried to use the BeforePrint event to change the appearance of the display to print in black and white as follows:

Private Sub Display_BeforePrint(bCancel As Boolean)
    Static AfterPrint As Boolean
    Dim i As Integer
    
    If Not AfterPrint Then
        AfterPrint = True
        
        ' Change display colors to grayscale '
        CreateColorDataSets 0, &HC0C0C0, 0, 0, 0
        Rectangle1.FillColor = vbWhite
        For i = 13 To 64
            ' Change labels to black '
            ThisDisplay.Symbols("Text" & i).LineColor = vbBlack
        Next
        
        ' Print using grayscale colors '
        ThisDisplay.PrintOut
        
        ' Set default colors '
        CreateColorDataSets
        Rectangle1.FillColor = &H363436
        For i = 13 To 64
            ' Change labels to white '
            ThisDisplay.Symbols("Text" & i).LineColor = vbWhite
        Next
        
        AfterPrint = False
        
        ' Cancel the print attempt with colored display '
        bCancel = True
    End If
End Sub

In the included code, the subroutine "CreateColorDataSets" redefines the MultiStates and the Values associated with each of the color-coded symbols on the display. Whenever the DataSet expressions are redefined, the display will recalculate (as expected). The problem is: it is recalculating using the "current" time values for the PI points, rather than the "display" time.

 

i.e. If I am showing live data and hit the print button, it works fine. If I rewind the display to yesterday at noon and hit the print button, the color-coded points switch to grayscale and display the current values, while everything else on the display continues to show values for yesterday at noon. After a few seconds (one or 2 display updates after the change), the color-coded values return to showing the values yesterday at noon. If the display is paused, the values will not return to displaying the old data until it is unpaused.

 

As a result, this display prints out incorrect data whenever it is paused or displaying historic values.

 

I have attached (redacted) pictures showing what the display looks like before and after clicking the print button (with the display paused at the time shown on "Time of Last Update"). The "Last Rod Motion" time is obtained from the highlighted symbol using the Symbol.GetValue method. Even though the time on the display did not advance, the symbols on the matrix reverted to the current time when the DataSets were updated. If I press Play, the matrix reverts to the time shown on "Time of Last Update".

 

Is this a bug? I haven't been able to find a good way to work around it.

 

Before:

beforeprint.jpg

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

After:

afterprint.jpg


Viewing all articles
Browse latest Browse all 1120

Trending Articles