System information

Table Of Contents
i.LON SmartServer 2.0 Programmer’s Reference
21-24
Console.WriteLine("Neuron ID = " + NID);
String PID = NID_PID.Substring(13, 16);
Console.WriteLine("Program ID = " + PID);
//set Neuron ID, which is a byte[]
my_LON_Device.UCPTuniqueId = (HexStringToArray(NID));
//set Program ID, which is a byte[]
my_LON_Device.UCPTprogramId = (HexStringToArray(PID));
//set template
iLON_SmartServer.E_xSelect xSelect = new iLON_SmartServer.E_xSelect();
xSelect.xSelect = "//Item[@xsi:type=\"TemplateManager_Cfg\"]
[UCPTfileType=\"TEMPLATE_OR_XIF\"]
[UCPTprogramId=\"" + PID + "\"]";
itemColl = SmartServer.List(xSelect);
iLON_SmartServer.TemplateManager_Surrogate_Cfg template =
(iLON_SmartServer.TemplateManager_Surrogate_Cfg)itemColl.Item[0];
String templateName = template.UCPTname;
Console.WriteLine("Device Template = " + templateName);
my_LON_Device.UCPTurlTemplate = templateName;
//set the device name
//1. get the name of the channel ("Net/LON")
xSelect.xSelect = "//Item[@xsi:type=\"LON_Channel_Cfg\"][UCPThidden=0]";
itemColl = SmartServer.List(xSelect);
iLON_SmartServer.Item channel = itemColl.Item[0];
//2. get the name of the xif
string[] separator = new string[] { "/" };
String[] templateName_justxif = templateName.Split(separator, 0);
int templateNameLength = templateName_justxif.Length;
String xifName = templateName_justxif[templateNameLength - 1];
Console.WriteLine("XIF Name = " + xifName);
//3. name device using channel name, /device [index], and xif name
// ("Net/LON/Device 1 (ai-10v3.xif)")
String deviceName = channel.UCPTname + "/" + "Device " + i + " (" + xifName + ")";
Console.WriteLine("Device Name = " + deviceName);
Console.WriteLine("===========================================================");
my_LON_Device.UCPTname = deviceName;
//set Commission status
iLON_SmartServer.E_LonString commissionStatus_LonString =
new iLON_SmartServer.E_LonString();
commissionStatus_LonString.Value = "COMMISSIONED";
my_LON_Device.UCPTcommissionStatus = commissionStatus_LonString;
//set Application status
iLON_SmartServer.E_LonString applicationStatus_LonString =
new iLON_SmartServer.E_LonString();
applicationStatus_LonString.Value = "APP_RUNNING";
my_LON_Device.UCPTapplicationStatus = applicationStatus_LonString;
//set tree and app icon; based on program ID
my_LON_Device.UCPTannotation = PID;
//++++send device commands++++++
//commission device
//create a command array to store device commands to be sent
my_LON_Device.Command = new iLON_SmartServer.LON_Device_CfgCommand[3];
//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 =