Echelon i.LON SmartServer 2.0 User Manual
Page 377
![background image](/manuals/735732/377/background.png)
i.LON SmartServer 2.0 Programmer’s Reference
21-25
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"
;
}
//Call the Set() function
iLON_SmartServer.
Item_Coll
Device_Return_ItemColl = SmartServer.Set(itemCfgColl);
Device_Return_ItemColl.xSelect =
"//Item[@xsi:type=\"LON_Device_Cfg\"]"
;
if
(Device_Return_ItemColl.UCPTfaultCount > 0)
{
// print out error and exit
Console
.WriteLine(
"An error occurred:"
);
for
(
int
j = 0; j < Device_Return_ItemColl.Item.Length; j++)
{
if
(Device_Return_ItemColl.Item[j].fault !=
null
)
{
Console
.WriteLine(
"Item: "
+ Device_Return_ItemColl.Item[j].UCPTname +
", fault code: "
+ Device_Return_ItemColl.Item[j].fault.faultcode +
",
fault
string:
"
+
Device_Return_ItemColl.Item[j].fault.faultstring);
}
}
}
else
{
itemCfgColl = SmartServer.Get(Device_Return_ItemColl);
for
(
int
j = 0; j < itemCfgColl.Item.Length; j++)
{
if
(itemCfgColl.Item[j].fault !=
null
)
{
Console
.WriteLine(
"Item: "
+ itemCfgColl.Item[j].UCPTname
+
", fault code: "
+ itemCfgColl.Item[j].fault.faultcode +
",
fault
string:
"
+
itemCfgColl.Item[j].fault.faultstring);
}
else
{
iLON_SmartServer.
LON_Device_Cfg
newDevice =
(iLON_SmartServer.
LON_Device_Cfg
)itemCfgColl.Item[j];
Console
.WriteLine(
"New Device Created = "
+ newDevice.UCPTname +
". Status = "
+ newDevice.UCPTcommissionStatus.Value +
" and "
+ newDevice.UCPTapplicationStatus.Value +
"."
);
}
}
}
Console
.ReadLine();
}