7 Replies Latest reply on Sep 23, 2015 7:30 AM by Nicolas.Isambourg

    [PI-ProcessBook] How to hide a value symbol if the user has no read access on the associated PI Tag

    Nicolas.Isambourg

      Dear Forum Members,

       

      I would like to hide a value symbol if the connected user has no read access on the associated PI Tag.

      How can I do it ?

       

      Thanks,

      Best regards,

      Nicolas         

        • Re:  [PI-ProcessBook] How to hide a value symbol if the user has no read access on the associated PI Tag
          Rhys Kirk

          You could take a general approach and hide the value for any bad status bu multistating the symbol. For example, if you have a Value symbol set to Sinusoid then multistate it based on Sinusoid too. Then for the "Color for bad data" set it to No Color:

          Note, that will hide it for any bad status.

           

          If you want to get a particular bad status then you'll likely best to use VBA (without the need of using an AF Formula or Dataset calculation).

          An example of how to handle it via VBA would be as follows - you'll need to adjust the status number for the No Data error state:

          Dim st As Variant, val As Variant
          val = Value1.GetValue("*", st)
          If st = 248 Then
              Value1.Visible = False
          Else
              Value1.Visible = True
          End If
          
          1 of 1 people found this helpful
          • Re:  [PI-ProcessBook] How to hide a value symbol if the user has no read access on the associated PI Tag
            bshang

            I believe the PB symbol.GetValue implementation might be different than the more familiar PI SDK calls/conventions. What is the version of PB? I wonder if there is some PI API functions being used. For example, -1 can indicate Bad Point Number in PI API...

             

            To resolve the issue, a more familiar approach (rather than trying to decipher the peculiars of vrStatus) might be to get the tagname associated with the symbol, and make a test PISDK snapshot call. The returned PIValue.Value should be a DigitalState object (if value.IsGood=false), and then the digstate.Name or Code can be inspected and different system digital states can be handled as desired.

              • Re:  [PI-ProcessBook] How to hide a value symbol if the user has no read access on the associated PI Tag
                Nicolas.Isambourg

                Hello Barry, Patrice and Rhys,

                 

                thank you for all your replies.

                I did what Barry suggested. I use PB 2015.

                I developed the following code:

                 

                Private Sub Display_Open()
                
                    Dim srv As Server, piPt As PIPoint, piVal As PIValue
                    Set srv = Servers.DefaultServer
                   
                    On Error GoTo ErrHandler
                   
                    Set piPt = srv.PIPoints("MyPoint")
                    Set piVal = piPt.Data.Snapshot
                   
                    If (Not piVal.IsGood()) Then
                        Dim digState As DigitalState
                        Set digState = piVal.Value
                       
                        If (digState.Code = 248) Then
                            ' Read access error, hide the symbols
                        End If
                       
                    End If
                   
                    Exit Sub
                   
                ErrHandler:
                   
                    Dim errCode As String
                    errCode = Hex(Err.Number)
                   
                    If (errCode = "80070005") Or (errCode = "8004040B") Then
                        ' Read access error, hide the symbols
                    End If
                       
                End Sub
                

                 

                Actually, if the user has no read access on the PITag, the PIData.Snapshot property raises an exception. That's why, I check the error number in the error handler.

                Is there a better way to check if the user has read access on a PI Tag ?

                If there is no better way, I will content with this solution.

                 

                Thanks,

                Best regards,

                Nico