beautypg.com

5 commissioning external devices in visual c# .net – Echelon i.LON SmartServer 2.0 User Manual

Page 370

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-18

",

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++)

{
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

+

".\r"

);

}
}

Console

.ReadLine();

}

finally

{

iLON_SoapCalls

.CloseBindingToSmartServer();

}

}
}
}

21.1.5

Commissioning External Devices in Visual C# .NET

This C# console example reads the of external LonWorks devices (obtained using
an xSelect), commissions any unconfigured devices, and reports the status of the network management
commands.

You can execute this code after you have referenced and inherited from the SmartServer WSDL as
described in section 20.1, and instantiated and initialized the Web service client as described in section
20.2.

For more information on the network management commands issued in this example, see section
14.3.3.1, Issuing Network Management Commands.

using

System;

using

System.Collections.Generic;

using

System.Linq;

using

System.Text;

using

System.Threading;

namespace

SmartServerConsoleExample

{

class

MyDeviceProgram

{

// If you are using NET 2.0 Framework, uncomment the following line of code to enter your

// SmartServer’s IP Address


// public static string _iLonEndpointIpAddress = "<SmartServer IP Address>";


static

void

PrintGetError(iLON_SmartServer.

Item_CfgColl

ItemCfgColl)

{

// print out error and exit

Console

.Out.WriteLine(

"An error occurred:"

);

for

(

int

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

{

if

(ItemCfgColl.Item[j].fault !=

null

)

{

Console

.Out.WriteLine(

"Item: "

+ ItemCfgColl.Item[j].UCPTname +

", fault code: "

+

ItemCfgColl.Item[j].fault.faultcode +

", fault string: "

+

ItemCfgColl.Item[j].fault.faultstring);

}
}
}