beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 433

background image

i.LON SmartServer 2.0 Programmer’s Reference

22-28

new

LONNetworkScanCommandInvoke.Command();

scanFrequency.setUCPTcommand(LONDeviceIlonNiECommand.SCAN_ONCE);

//b.

set

scan

status

ELonString

scanStatus

=

new

ELonString();

scanStatus.setLonFormat("UCPTstatus");
scanStatus.setValue("STATUS_REQUEST");
scanFrequency.setUCPTstatus(scanStatus);

//c. add scan command to LONNetworkScanCommandInvoke item

networkScan.getCommand().add(scanFrequency);

//3. Set UCPTscan

ELonString

domain

=

new

ELonString();

domain.setLonFormat("ucptScan");
domain.setValue("NST_ILON_DOMAIN");
networkScan.getUCPTscan().add(domain);

//send

InvokeCmd

ItemColl

itemColl

=

new

ItemColl();

itemColl.getItem().add(networkScan);

//**note that invokeCmd requires ItemColl to be placed in Holder class**

Holder

holder

=

new

Holder();

holder.value

=

itemColl;

SmartServer.invokeCmd(holder);
System.out.println("starting

scan");

//send the GetScan command to check network scan progress

LONNetworkScanCommandInvoke

networkScan_Check

=

new

LONNetworkScanCommandInvoke();

networkScan_Check.setScanCommand(LONNetworkEScanCommand.GET_SCAN);
networkScan_Check.setUCPTname("Net");

ItemColl

itemColl_Check

=

new

ItemColl();

itemColl_Check.getItem().add(networkScan_Check);

Holder

holder_Check

=

new

Holder();

holder_Check.value

=

itemColl_Check;

//Check

scan

status

boolean

scanDone

=

false;

while

(!scanDone)

{

SmartServer.invokeCmd(holder_Check);

InvokeCmdResponse

scanCheck_Response

=

new

InvokeCmdResponse();

scanCheck_Response.setILonItem(holder_Check.value);

LONNetworkScanCommandInvoke

scanStatusCheck

=

(LONNetworkScanCommandInvoke)

scanCheck_Response.getILonItem().getItem().get(0);

//if the scan is done set scanDone flag to true

if

(scanStatusCheck.getCommand().get(0).getUCPTstatus().getValue().

compareTo("STATUS_DONE")==

0)

{

System.out.println("Network Scan Status = " +

scanStatusCheck.getCommand().get(0).getUCPTstatus().getValue());

scanDone

=

true;

}

//if the scan is not done, keep scanDone flag at false, wait 10 seconds, and check again

else

if

(scanStatusCheck.getCommand().get(0).getUCPTstatus().getValue().

compareTo("STATUS_DONE")!=

0)

{

System.out.println("Network Scan Status = " +

scanStatusCheck.getCommand().get(0).getUCPTstatus().getValue());

Thread.sleep(10000);

}

}