Echelon i.LON SmartServer 2.0 User Manual
Page 402

i.LON SmartServer 2.0 Programmer’s Reference
21-50
my_LON_Device.Command =
New
iLON_SmartServer.LON_Device_CfgCommand(2) {}
'commission device
my_LON_Device.Command(0) =
New
iLON_SmartServer.LON_Device_CfgCommand()
my_LON_Device.Command(0).UCPTcommand =
New
iLON_SmartServer.LON_Device_eCommand()
my_LON_Device.Command(0).UCPTcommand =
iLON_SmartServer.LON_Device_eCommand.ChangeCommissionStatus
my_LON_Device.Command(0).UCPTstatus =
New
iLON_SmartServer.E_LonString()
my_LON_Device.Command(0).UCPTstatus.LonFormat =
"UCPTstatus"
my_LON_Device.Command(0).UCPTstatus.Value =
"STATUS_REQUEST"
'run device application
my_LON_Device.Command(1) =
New
iLON_SmartServer.LON_Device_CfgCommand()
my_LON_Device.Command(1).UCPTcommand =
New
iLON_SmartServer.LON_Device_eCommand()
my_LON_Device.Command(1).UCPTcommand =
iLON_SmartServer.LON_Device_eCommand.ChangeApplicationStatus
my_LON_Device.Command(1).UCPTstatus =
New
iLON_SmartServer.E_LonString()
my_LON_Device.Command(1).UCPTstatus.LonFormat =
"UCPTstatus"
my_LON_Device.Command(1).UCPTstatus.Value =
"STATUS_REQUEST"
'get the device template to show FBs and DPs in Web UI
my_LON_Device.Command(2) =
New
iLON_SmartServer.LON_Device_CfgCommand()
my_LON_Device.Command(2).UCPTcommand =
New
iLON_SmartServer.LON_Device_eCommand()
my_LON_Device.Command(2).UCPTcommand =
iLON_SmartServer.LON_Device_eCommand.GetTemplate
my_LON_Device.Command(2).UCPTstatus =
New
iLON_SmartServer.E_LonString()
my_LON_Device.Command(2).UCPTstatus.LonFormat =
"UCPTstatus"
my_LON_Device.Command(2).UCPTstatus.Value =
"STATUS_REQUEST"
Next
'Call the Set() function
Dim
Device_Return_ItemColl
As
iLON_SmartServer.Item_Coll =
SmartServer._iLON.[Set](itemCfgColl)
Device_Return_ItemColl.xSelect =
"//Item[@xsi:type=""LON_Device_Cfg""]"
If
Device_Return_ItemColl.UCPTfaultCount > 0
Then
' print out error and exit
Console.WriteLine(
"An error occurred:"
)
For
j
As
Integer
= 0
To
Device_Return_ItemColl.Item.Length - 1
If
Device_Return_ItemColl.Item(j).fault
IsNot
Nothing
Then
Console.WriteLine(((
"Item: "
& Device_Return_ItemColl.Item(j).UCPTname
&
", fault code: "
) & Device_Return_ItemColl.Item(j).fault.faultcode.Value
&
", fault string: "
) & Device_Return_ItemColl.Item(j).fault.faultstring)
End
If
Next
Else
itemCfgColl = SmartServer._iLON.[Get](Device_Return_ItemColl)
For
j
As
Integer
= 0
To
itemCfgColl.Item.Length - 1
If
itemCfgColl.Item(j).fault
IsNot
Nothing
Then
Console.WriteLine(((
"Item: "
& itemCfgColl.Item(j).UCPTname &
", fault code: "
) & itemCfgColl.Item(j).fault.faultcode.Value &
", fault string: "
) & itemCfgColl.Item(j).fault.faultstring)
Else
Dim
newDevice
As
iLON_SmartServer.LON_Device_Cfg =
DirectCast
(itemCfgColl.Item(j), iLON_SmartServer.LON_Device_Cfg)
Console.WriteLine(((
"New Device Created = "
& newDevice.UCPTname &
". Status = "
) & newDevice.UCPTcommissionStatus.Value &
" and "
) &
newDevice.UCPTapplicationStatus.Value &
"."
)
End
If
Next
End
If
Console.ReadLine()
Finally
SmartServer.CloseBindingToSmartServer()
End
Try
End
Sub
End
Module