beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 397

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-45

'we create an xSelect object and then specify the filter to be used

Dim

xSelect_Device

As

ILON_SmartServer.E_xSelect =

New

iLON_SmartServer.E_xSelect

xSelect_Device.xSelect =

"//Item[@xsi:type=""LON_Device_Cfg""][UCPTitemStatus=""IS_UNCONFIGURED""]"

'we create an ItemColl that stores the objects returned by a List() function that takes our

'xSelect object

Dim

ItemColl_Device

As

ILON_SmartServer.Item_Coll = SmartServer._iLON.List(xSelect_Device)


'we use an xSelect to further filter the items returned by the List() function

ItemColl_Device.xSelect =

"//Item[@xsi:type=""LON_Device_Cfg""][UCPTlocal =""0""]"

'we create an ItemCfgColl that stores the objects returned by a Get() function that takes the

'ItemColl returned by the List()

Dim

ItemCfgColl

As

ILON_SmartServer.Item_CfgColl = SmartServer._iLON.Get(ItemColl_Device)


'check that there are obejcts in the ItemCfgColl

If

(ItemCfgColl.UCPTfaultCount > 0)

Then

Console.Out.WriteLine(

"you've got Get errors"

)


Else

For

i

As

Integer

= 0

To

ItemCfgColl.Item.Length - 1


' we allocate a Item-Data array object to read Device configurations

Dim

deviceItems

As

iLON_SmartServer.LON_Device_Cfg = ItemCfgColl.Item(i)

Console.Out.WriteLine(deviceItems.UCPTname +

", STATUS = "

+

deviceItems.UCPTitemStatus.Value + vbNewLine)


deviceItems.UCPTcommissionStatus.Value =

"COMMISSIONED"

deviceItems.UCPTapplicationStatus.Value =

"APP_RUNNING"

ReDim

deviceItems.Command(0

To

2)


deviceItems.Command(0) =

New

iLON_SmartServer.LON_Device_CfgCommand

deviceItems.Command(0).UCPTcommand =

iLON_SmartServer.LON_Device_eCommand.ChangeApplicationStatus

deviceItems.Command(0).UCPTstatus =

New

iLON_SmartServer.E_LonString

deviceItems.Command(0).UCPTstatus.Value =

"STATUS_REQUEST"

deviceItems.Command(1) =

New

iLON_SmartServer.LON_Device_CfgCommand

deviceItems.Command(1).UCPTcommand =

iLON_SmartServer.LON_Device_eCommand.ChangeCommissionStatus

deviceItems.Command(1).UCPTstatus =

New

iLON_SmartServer.E_LonString

deviceItems.Command(1).UCPTstatus.Value =

"STATUS_REQUEST"

deviceItems.Command(2) =

New

iLON_SmartServer.LON_Device_CfgCommand

deviceItems.Command(2).UCPTcommand = iLON_SmartServer.LON_Device_eCommand.Reset
deviceItems.Command(2).UCPTstatus =

New

iLON_SmartServer.E_LonString

deviceItems.Command(2).UCPTstatus.Value =

"STATUS_REQUEST"

Console.Out.WriteLine(vbNewLine +

"*DEVICE CONFIGURATION CHECK*"

+ vbNewLine +

vbNewLine + deviceItems.UCPTname + vbNewLine +

"STATUS = "

+ deviceItems.UCPTitemStatus.Value + vbNewLine +

"COMMISSION STATUS = "

+ deviceItems.UCPTcommissionStatus.Value + vbNewLine +

"APPLICATION STATUS = "

+ deviceItems.UCPTapplicationStatus.Value + vbNewLine)


Next

End

If

Dim

ItemColl_SetReturn

As

ILON_SmartServer.Item_Coll = SmartServer._iLON.Set(ItemCfgColl)