Echelon i.LON SmartServer 2.0 User Manual
Page 341

i.LON SmartServer 2.0 Programmer’s Reference
20-19
20.3.3
Reading and Writing Data Point Values in Visual Basic .NET 3.5
The following Visual Basic .NET 3.5 example reads the value of the Net/LON/iLON App/Digital
Output 1/nviClaValue_1 data point on the SmartServer, and then writes a value of “100.0 1” to it. This
SNVT_switch data point is one of the relay outputs on the SmartServer. You can execute this code
after you have completed section 20.1.1, Referencing and Inheriting from the WSDL Using .NET 3.5
Framework, and section 20.2.3,Instantiating the Web Service Client in Visual Basic .NET 3.5.
Module
Module1
Sub
Main()
Dim
SmartServer
As
iLON_SoapCalls =
New
iLON_SoapCalls
// Enter your SmartServer's IpAddress
SmartServer.BindClientToSmartServer(
"<SmartServer IP Address>"
)
Try
' -------------- READING A DATA POINT VALUE --------------
' instantiate the member object
Dim
itemColl
As
New
iLON_SmartServer.Item_Coll()
itemColl.Item =
New
iLON_SmartServer.Item(0) {}
itemColl.Item(0) =
New
iLON_SmartServer.Dp_Data()
' set the DP name
itemColl.Item(0).UCPTname =
"Net/LON/iLON App/Digital Output 1/nviClaValue_1"
' set maxAge to get the updated DP value in case it has been cached for more than 10
' seconds on the Data Server (see section 4.3.4.1 for more information)
DirectCast
((itemColl.Item(0)), iLON_SmartServer.Dp_Data).UCPTmaxAge = 10
DirectCast
((itemColl.Item(0)), iLON_SmartServer.Dp_Data).UCPTmaxAgeSpecified =
True
'call the Read Function
Dim
dataColl
As
iLON_SmartServer.Item_DataColl = SmartServer._iLON.Read(itemColl)
If
dataColl.Item
Is
Nothing
Then
' sanity check. this should not happen
Console.Out.WriteLine(
"No items were returned"
)
ElseIf
dataColl.Item(0).fault
IsNot
Nothing
Then
' error
Console.Out.WriteLine((
"An error occurred. Fault code = "
+
dataColl.Item(0).fault.faultcode.Value +
". Fault text = %s."
) +
dataColl.Item(0).fault.faultstring)
Else
' success
Console.Out.WriteLine(
"Read is successful"
)
Console.Out.WriteLine((
DirectCast
(dataColl.Item(0), iLON_SmartServer.Dp_Data).UCPTname &
" = "
) +
DirectCast
(dataColl.Item(0), iLON_SmartServer.Dp_Data).UCPTvalue(0).Value &
vbLf)
End
If
' -------------- WRITING A DATA POINT VALUE --------------
' reset the DP priority (see section 4.3.6 for more information)
Dim
itemCollInvoke
As
New
iLON_SmartServer.Item_Coll()
itemCollInvoke.Item =
New
iLON_SmartServer.Item(0) {}
itemCollInvoke.Item(0) =
New
iLON_SmartServer.Dp_ResetPrio_Invoke()
DirectCast
((itemCollInvoke.Item(0)), iLON_SmartServer.Dp_ResetPrio_Invoke).UCPTname =
"Net/LON/iLON App/Digital Output 1/nviClaValue_1"
DirectCast
((itemCollInvoke.Item(0)), iLON_SmartServer.Dp_ResetPrio_Invoke).UCPTpriority = 200
DirectCast
((itemCollInvoke.Item(0)), iLON_SmartServer.Dp_ResetPrio_Invoke).UCPTprioritySpecified =
True