Echelon i.LON SmartServer 2.0 User Manual
Page 431
![background image](/manuals/735732/431/background.png)
i.LON SmartServer 2.0 Programmer’s Reference
22-26
LONDeviceCfg.Command getTemplate_my_LON_Device2 = new LONDeviceCfg.Command();
getTemplate_my_LON_Device2.setUCPTcommand(LONDeviceECommand.GET_TEMPLATE);
ELonString my_LON_Device2_templateStatus = new ELonString();
my_LON_Device2_templateStatus.setLonFormat("UCPTstatus");
my_LON_Device2_templateStatus.setValue("STATUS_REQUEST");
getTemplate_my_LON_Device2.setUCPTstatus(my_LON_Device2_templateStatus);
my_LON_Device2.getCommand().add(getTemplate_my_LON_Device2);
//Call the Set() function
ItemColl Device_Return_ItemColl = SmartServer.set(itemCfgColl);
Device_Return_ItemColl.setXSelect("//Item[@xsi:type=\"LON_Device_Cfg\"]");
if (Device_Return_ItemColl.getUCPTfaultCount() > 0)
{
// print out error and exit
System.out.println("An error occurred:");
for (int j = 0; j < Device_Return_ItemColl.getItem().size(); j++)
{
if (Device_Return_ItemColl.getItem().get(j).getFault() != null)
{
System.out.println("Item: " +
Device_Return_ItemColl.getItem().get(j).getUCPTname() + ", fault code: " +
Device_Return_ItemColl.getItem().get(j).getFault().getFaultcode() +
", fault string: " +
Device_Return_ItemColl.getItem().get(j).getFault().getFaultstring());
}
}
}
else
{
itemCfgColl = SmartServer.get(Device_Return_ItemColl);
for (int j = 0; j < itemCfgColl.getItem().size(); j++)
{
LONDeviceCfg newDevice = (LONDeviceCfg)itemCfgColl.getItem().get(j);
System.out.println("New Device Created = " + newDevice.getUCPTname() +
".Status = " + newDevice.getUCPTcommissionStatus().getValue()+ " and " +
newDevice.getUCPTapplicationStatus().getValue()
+
".\r");
}
}
}
catch
(Exception
e)
{
System.out.println(e.getMessage());
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
finally
{
iLon100
=
null;
SmartServer
=
null;
}
}
}
22.3.4
Discovering and Installing External Devices in JAVA
This Java example scans a L
ON
W
ORKS
network for uncommissioned devices, processes the Neuron ID
and program ID data of the discovered devices, and then commissions the devices, starts the devices’
applications, and gets the devices’ templates (to display the devices’ functional blocks and data points
in the SmartServer Web interface). The example then prints out the names and statuses of the devices
that have been installed.