beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 369

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-17

my_LON_Device1.Command[1].UCPTstatus.Value =

"STATUS_REQUEST"

;


//get the device template to show FBs and DPs in Web UI

my_LON_Device1.Command[2] =

new

iLON_SmartServer.

LON_Device_CfgCommand

();

my_LON_Device1.Command[2].UCPTcommand =

new

iLON_SmartServer.

LON_Device_eCommand

();

my_LON_Device1.Command[2].UCPTcommand = iLON_SmartServer.

LON_Device_eCommand

.GetTemplate;

my_LON_Device1.Command[2].UCPTstatus =

new

ConsoleApplication_LON_Device.iLON_SmartServer.

E_LonString

();

my_LON_Device1.Command[2].UCPTstatus.LonFormat =

"UCPTstatus"

;

my_LON_Device1.Command[2].UCPTstatus.Value =

"STATUS_REQUEST"

;


//=====CREATING AND INSTALLING LON DEVICE #2==================


// specify properties of new LON Device #2

my_LON_Device2.UCPTname =

"Net/LON/DIO-2"

;

my_LON_Device2.UCPTlocal = 0;

my_LON_Device2.UCPTuniqueId

=

HexStringToArray(

"00a145784600"

);

my_LON_Device2.UCPTprogramId

=

HexStringToArray(

"80000105288a0403"

);

my_LON_Device2.UCPTurlTemplate =

"/root/lonWorks/Import/Echelon/LonPoint/Version3/dio-10v3.XIF"

;

my_LON_Device2.UCPTcommissionStatus =

new

iLON_SmartServer.

E_LonString

();

my_LON_Device2.UCPTcommissionStatus.Value =

"COMMISSIONED"

;

my_LON_Device2.UCPTapplicationStatus =

new

iLON_SmartServer.

E_LonString

();

my_LON_Device2.UCPTapplicationStatus.Value =

"APP_RUNNING"

;


//create a command array to store device commands to be sent

my_LON_Device2.Command =

new

iLON_SmartServer.

LON_Device_CfgCommand

[3];


//commission device

my_LON_Device2.Command[0] =

new

iLON_SmartServer.

LON_Device_CfgCommand

();

my_LON_Device2.Command[0].UCPTcommand =

new

iLON_SmartServer.

LON_Device_eCommand

();

my_LON_Device2.Command[0].UCPTcommand = iLON_SmartServer.

LON_Device_eCommand

.ChangeCommissionStatus;

my_LON_Device2.Command[0].UCPTstatus =

new

ConsoleApplication_LON_Device.iLON_SmartServer.

E_LonString

();

my_LON_Device2.Command[0].UCPTstatus.LonFormat =

"UCPTstatus"

;

my_LON_Device2.Command[0].UCPTstatus.Value =

"STATUS_REQUEST"

;


//run device application

my_LON_Device2.Command[1] =

new

iLON_SmartServer.

LON_Device_CfgCommand

();

my_LON_Device2.Command[1].UCPTcommand =

new

iLON_SmartServer.

LON_Device_eCommand

();

my_LON_Device2.Command[1].UCPTcommand = iLON_SmartServer.

LON_Device_eCommand

.ChangeApplicationStatus;

my_LON_Device2.Command[1].UCPTstatus =

new

ConsoleApplication_LON_Device.iLON_SmartServer.

E_LonString

();

my_LON_Device2.Command[1].UCPTstatus.LonFormat =

"UCPTstatus"

;

my_LON_Device2.Command[1].UCPTstatus.Value =

"STATUS_REQUEST"

;


//get the device template to show FBs and DPs in Web UI

my_LON_Device2.Command[2] =

new

iLON_SmartServer.

LON_Device_CfgCommand

();

my_LON_Device2.Command[2].UCPTcommand =

new

iLON_SmartServer.

LON_Device_eCommand

();

my_LON_Device2.Command[2].UCPTcommand = iLON_SmartServer.

LON_Device_eCommand

.GetTemplate;

my_LON_Device2.Command[2].UCPTstatus =

new

ConsoleApplication_LON_Device.iLON_SmartServer.

E_LonString

();

my_LON_Device2.Command[2].UCPTstatus.LonFormat =

"UCPTstatus"

;

my_LON_Device2.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

.Out.WriteLine(

"An error occurred:"

);


for

(

int

j = 0; j < Device_Return_ItemColl.Item.Length; j++)

{

if

(Device_Return_ItemColl.Item[j].fault !=

null

)

{

Console

.Out.WriteLine(

"Item: "

+ Device_Return_ItemColl.Item[j].UCPTname +

", fault code: "

+ Device_Return_ItemColl.Item[j].fault.faultcode +