1 Reply Latest reply on Apr 20, 2010 4:44 PM by spilon

    Initialize PISDK.PIValue


      This is probably a dumb question, but.... is there a simple way to create and initialize a blank PISDK.PIValue object?

      I have tried creating an object as follows:

      Imports PISDK
      Imports PISDKCommon

      Module Module1

          Sub Main()
              Dim n As New PISDK.PIValue
              n.ValueAttributes = New PISDKCommon.NamedValues
              n.TimeStamp = New PITimeServer.PITime
              n.Value = 25
          End Sub

      End Module


      but no matter what I try, I can't seem to initialize it correctly.  It dies on the SetToCurrent line with the error "PIValue is not properly initialized".


      What I have resorted to as a workaround is to start with an existing PIValue, like this:

      Public Function GetBlankPIValue() As PISDK.PIValue
              Return srv.PIPoints("sinusoid").Data.Snapshot
      End Function

      and then overwrite the value and timestamp.

      Any suggestions?

        • Re: Initialize PISDK.PIValue

          Simply make sure you start by setting the Timestamp property to a valid instance of a PITime (PITimeServer.PITime, to be more specific) object:

          Dim t As New PITimeServer.PITime()

          Dim n As New PISDK.PIValue
          n.TimeStamp = t
          n.Value = 25
          n.ValueAttributes = New PISDKCommon.NamedValues