PIProperties Example

 

Option Explicit

 

Private Sub Command1_Click()

 

   Dim Module As PIModule

   Dim i As Integer

   Dim iTemp As Integer

   Dim strTemp As String

   Dim Property As PIProperty

   Dim ParentProperty As PIProperty

   Dim myPropertyList As New PIPropertyList

  

   PISDK.Servers.DefaultServer.Open

   On Error Resume Next

   Set Module = PISDK.Servers.DefaultServer.PIModuleDB.PIModules.Add("PIPropertyTest1")

   On Error GoTo 0

   Set Module = PISDK.Servers.DefaultServer.PIModuleDB.PIModules.Item("PIPropertyTest1")

   For i = 1 To 20

      On Error Resume Next

      Set Property = Module.PIProperties.Add("temp_" & i, i)

      On Error GoTo 0

      Set Property = Module.PIProperties.Item("temp_" & i)

      iTemp = Property.Value

      Property.Value = iTemp + 1

      myPropertyList.Insert Property   ' insert into list

   Next i

  

   Set ParentProperty = Module.PIProperties.Item(1)

   For i = 1 To 20

      On Error Resume Next

      Set Property = ParentProperty.PIProperties.Add("SubTemp_" & i, i)

      On Error GoTo 0

      Set Property = ParentProperty.PIProperties.Item("SubTemp_" & i)

      iTemp = Property.Value

      Property.Value = iTemp + 1

   Next i

  

   List1.Clear

   i = 0

  

   For Each Property In Module.PIProperties

      strTemp = Property.Name & " " & Property.Value

      List1.AddItem strTemp, i

      i = i + 1

   Next Property

  

   List2.Clear

   i = 0

   Set Property = Module.PIProperties.Item(1)

   For Each Property In Property.PIProperties

      strTemp = Property.Name & " " & Property.Value

      List2.AddItem strTemp, i

      i = i + 1

   Next Property

  

   MsgBox "Now listing the Properties in the PIPropertyList to the second list box."

  

   List2.Clear

   i = 0

   For Each Property In myPropertyList

      strTemp = Property.Name & " " & Property.Value

      List2.AddItem strTemp, i

      i = i + 1

   Next Property

 

End Sub

 
Enabling Operational Intelligence