4 Replies Latest reply on Aug 25, 2011 1:18 PM by dtakara

    Pi Status tags

    sandeep.narang

      Hi

       

       

       

      We are using PI eventing to get get notified for Pi tag value changes. Just want to know if PI tag has some kind of status well that get changes?

       

      If yes , how can we access that status in OnNewVal Event handler?

       

       

       

      Thanks

       

      Sachin

        • Re: Pi Status tags
          dtakara

          Hi Sachin,

           

          The Value property of a PIValue object indicates:

          • the actual value of the PI tag, if the value is good
          • the status code of the PI tag, if the value is not good

          This is some sample code in VB .NET that you could add to the OnNewValue event handler:

           
              Private myEventPipe As PISDK.EventPipe
              Private myPIEventObject As PISDK.PIEventObject
              Private myPointValue As PISDK.PointValue
              Private myPIValue As PISDK.PIValue
              Private epEvents As PISDK._DEventPipeEvents_Event
          
              '.....
          
              Private Sub epEvents_OnNewValue()
          
                  Try
                      myPIEventObject = myEventPipe.Take()
                      myPointValue = DirectCast(myPIEventObject.EventData, PISDK.PointValue)
                      myPIValue = myPointValue.PIValue
                      If Not myPIValue.IsGood Then
                          MessageBox.Show("time: " & myPIValue.TimeStamp.LocalDate.ToString & _
                                        " - status: " & DirectCast(myPIValue.Value, PISDK.DigitalState).Name)
                      Else
                          MessageBox.Show("time: " & myPIValue.TimeStamp.LocalDate.ToString & _
                                        " - value: " & myPIValue.Value.ToString)
                      End If
                  Catch ex As Exception
                      MessageBox.Show("error: " + ex.Message)
                  End Try
              End Sub
          

           

           

          Please let us know if this helps.

           

           

           

          {post edited: removed irrelevant commands from code}