IPIPoints2 Example

 

Option Explicit

Private Sub Command1_Click()
'
Dim myServer As Server
Dim IPIP2 As IPIPoints2 ' IPIPoints2 interface
Dim nvsAddRemove As New NamedValues ' NamedValues collection for adding and removing tags
Dim nvsEdit As New NamedValues ' NamedValues collection for editing tags
Dim nvsTagAttr As New NamedValues ' Add attributes for all tags
Dim nvsEditAttr1 As New NamedValues ' Edit attributes for tag 1
Dim nvsEditAttr2 As New NamedValues ' Edit attributes for tag 2
Dim nvsEditAttr3 As New NamedValues ' Edit attributes for tag 3
Dim myAddErrors As PIErrors ' errors collection for adding
Dim myPtList As PointList ' Point list returned from adding tags
Dim myEditErrors As PIErrors ' errors collection for editing
Dim myRemoveErrors As PIErrors ' errors collection for removing
'
' Get the server and the IPIPoints2 interface
'
Set myServer = PISDK.Servers.DefaultServer
Set IPIP2 = myServer.PIPoints
'
' Populate the tag attributes collection
'
nvsTagAttr.Add "ptclassName", "classic"
nvsTagAttr.Add "pointtype", pttypFloat32
'
' Add three tags with these attributes
'
nvsAddRemove.Add "AER1", nvsTagAttr
nvsAddRemove.Add "AER2", nvsTagAttr
nvsAddRemove.Add "AER3", nvsTagAttr
IPIP2.AddTags nvsAddRemove, myAddErrors, myPtList
'
' Add a descriptor to each tag by editing them all at once
'
nvsEditAttr1.Add "Descriptor", "Descriptor for Tag 1"
nvsEditAttr2.Add "Descriptor", "Descriptor for Tag 2"
nvsEditAttr3.Add "Descriptor", "Descriptor for Tag 3"
nvsEdit.Add "AER1", nvsEditAttr1
nvsEdit.Add "AER2", nvsEditAttr2
nvsEdit.Add "AER3", nvsEditAttr3
IPIP2.EditTags nvsEdit, myEditErrors
'
' Now remove all the tags. We can use the same NamedValues collection as
' adding since it will ignore any values below the tag name
'
IPIP2.RemoveTags nvsAddRemove, myRemoveErrors

End Sub

Enabling Operational Intelligence