Initialize PISDK.PIValue

Discussion created by flynnk on Apr 20, 2010
Latest reply on Apr 20, 2010 by spilon

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?