System information

Table Of Contents
i.LON SmartServer 2.0 Programmer’s Reference
21-30
21.2
Visual Basic.NET Examples
21.2.1
Reading and Writing Data Point Values in Visual Basic.NET
This VB console example toggles the SmartServer’s digital relay outputs when run. It demonstrates
how to use an xSelect statement to filter items returned by a List() method, and it demonstrates how to
write to data points using values and presets.
You can execute this code after you have referenced and inherited from the SmartServer WSDL as
described in
section 20.1, and instantiated and initialized the Web service client as described in section
20.2.3.
For more information on the data point properties set and read in this example, see
section 4.3.2,
Using the Get Function on the Data Server, and section 4.3.3, Using the Read Function on the Data
Server, respectively.
Module DpModule
Sub Main()
'See Section 20.2.3 for more information on iLON_SoapCalls class
Dim SmartServer As iLON_SoapCalls = New iLON_SoapCalls
SmartServer.BindClientToSmartServer()
Try
Console.Out.WriteLine(vbNewLine + vbNewLine + "Reading and Writing DP Values with an xSelect"
+ vbNewLine + "-------------------------------" + vbNewLine)
'we create an xSelect object and then specify the filter to be used
Dim xSelect As iLON_SmartServer.E_xSelect = New iLON_SmartServer.E_xSelect
xSelect.xSelect = "//Item[@xsi:type=""Dp_Cfg""][contains (UCPTname,""nviClaValue"")]"
'Create an ItemColl that stores the objects returned by a List() function that takes our
'xSelect object
Dim ItemColl As iLON_SmartServer.Item_Coll = SmartServer._iLON.List(xSelect)
'we create an ItemDataColl that stores the objects returned by a Read() function that takes
'the ItemColl returned by the List()
Dim ItemDataColl As iLON_SmartServer.Item_DataColl = SmartServer._iLON.Read(ItemColl)
'check that there are obejcts in the ItemDataColl
If (ItemDataColl.UCPTfaultCount > 0) Then
Console.Out.WriteLine("you've got Read errors")
Else
Console.Out.WriteLine("Reading Data Point Values" + vbNewLine)
For i As Integer = 0 To ItemDataColl.Item.Length - 1
' we allocate a Item-Data array object to read DP names and values
Dim dpItems As iLON_SmartServer.Dp_Data = ItemDataColl.Item(i)
Console.Out.WriteLine(dpItems.UCPTname + " = " + dpItems.UCPTvalue(0).Value)
If (dpItems.UCPTvalue(0).Value = "100.0 1") Then
dpItems.UCPTvalue(0).Value = "0.0 0"
dpItems.UCPTvalue(1).Value = "OFF"
ElseIf (dpItems.UCPTvalue(0).Value = "0.0 0") Then
dpItems.UCPTvalue(0).Value = "100.0 1"
dpItems.UCPTvalue(1).Value = "ON"
End If