"No Data" is system digital state in PI. You can pass digital state code (248) as value to PI point and it will write "No Data" value.
@Lal Babu Shaik
Thanks for the reply. I know that "No Data" is a Digital State in PI. But I don´t know how to write that using VBA con Excel. Also I don´t know if that works on a IMD tag that collects String data.
The code line that I am using to write is this one:
"srv.PIPoints(Sheet5.Cells(IntFilaTA_1, IntColTA_1).Text).Data.UpdateValue DBLValorTA_1, DTFechaTA, dmReplaceDuplicates IntContadorTA_1 = IntContadorTA_1 + 1"
Sheet5.Cells(IntFilaTA_1, IntColTA_1 --> Here is the tagname to write
DBLValorTA_1 --> Here is the value to write to the tag.
DTFechaTA --> The date to write the PI Point.
Can you help me with this.
According to the PI SDK Programming reference the method updatevalue syntax is:
object.UpdateValue NewValue, TimeStamp, [MergeType], [AsyncStatus]
Where NewValue has many possible values types. One of them is VT_BSTR. This type can be used as follows:
"Supported for all point types. Note, value coercion may be required for numeric types with can result in lowered precision of the value. For TimeStamp points, a string is parsed according to the time string parsing rules on the PI server. See the PI Server Reference Guide for more information on valid PI Server time string representations. For digital points, a positive numeric value is interpreted as an offset in its digital state set, a negative value is interpreted as an offset in the System Digital State Set. For digital points, the string representation of a digital state, either system or for the point's own digital state set, can be passed to the PI SDK which will coerce the string into a DigitalState object. For all other point types, if a non-numeric string is passed to a numeric point type, the PI SDK will attempt to coerce the string to a system DigitalState object only."
Therefore, if you are using a numeric tag you can use a string with the Digital Set Name such as "No Data".
However, you mentioned a string data. Therefore, I believe that , when using a string type PI Point the best option would be to create a digital state variable and use it as the NewValue parameter. See code below:
Dim srv As server 'Server declaration Dim tag As PIPoint 'PIPoint declaration Dim timestamp As String 'Time stamp variable declaration Dim tagValue As Variant 'New value variable declaration Dim myDigState As DigitalState Dim myStateSet As StateSet Set srv = PISDK.Servers.DefaultServer 'Setting the declared server as the default server(MARC-RAS) Set tag = srv.PIPoints(txtTagName.Text) 'Setting the declared PIPoint as the PIPoint with the same name written in the textbox timestamp = txtTime.Text 'Assigning the text written in the textbox(txtTime) to the string timestamp Set myStateSet = srv.StateSets("SYSTEM") 'Assigning the SYSTEM Digital Set Set myDigState = myStateSet("No Data") 'Assigning the "No Data" as digital State tag.Data.UpdateValue myDigState, timestamp, dmReplaceDuplicates 'Replace the value stored at the chosen timestamp with the new value