beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 374

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-22

{

int

nLen = str.Length / 2;

byte

[] arr =

new

byte

[nLen];


for

(

int

i = 0; i < nLen; i++)

{

string

strByte = str.Substring(i * 2, 2);

arr[i] =

Byte

.Parse(strByte, System.Globalization.

NumberStyles

.HexNumber);

}

return

arr;

}

static

void

Main(

string

[] args)

{

iLON_SoapCalls

.BindClientToSmartServer();

iLON_SmartServer.

iLON100portTypeClient

SmartServer =

iLON_SoapCalls

._iLON;


try

{

//create LONNetworkScanCommandInvoke item and ScanCommand attribute

iLON_SmartServer.

LON_Network_ScanCommand_Invoke

networkScan =

new

iLON_SmartServer.

LON_Network_ScanCommand_Invoke

();

networkScan.ScanCommand = iLON_SmartServer.

LON_Network_eScanCommand

.SetScan;


//***set LONNetworkScanCommandInvoke properties***

//1. Set network UCPTname

networkScan.UCPTname =

"Net"

;


//2. Set Scan Command

//a. set scan frequency

iLON_SmartServer.

LON_Network_ScanCommand_InvokeCommand

scanFrequency =

new

iLON_SmartServer.

LON_Network_ScanCommand_InvokeCommand

();

scanFrequency.UCPTcommand = iLON_SmartServer.

LON_Device_IlonNi_eCommand

.ScanOnce;


//b. set scan status

iLON_SmartServer.

E_LonString

scanStatus =

new

iLON_SmartServer.

E_LonString

();

scanStatus.LonFormat =

"UCPTstatus"

;

scanStatus.Value =

"STATUS_REQUEST"

;

scanFrequency.UCPTstatus = scanStatus;

//c. add scan command to LONNetworkScanCommandInvoke item

networkScan.Command =

new

iLON_SmartServer.

LON_Network_ScanCommand_InvokeCommand

[1];

networkScan.Command[0] = scanFrequency;

//3. Set UCPTscan

iLON_SmartServer.

E_LonString

domain =

new

iLON_SmartServer.

E_LonString

();

domain.LonFormat =

"ucptScan"

;

domain.Value =

"NST_ILON_DOMAIN"

;

networkScan.UCPTscan =

new

iLON_SmartServer.

E_LonString

[1];

networkScan.UCPTscan[0] = domain;

//send InvokeCmd

iLON_SmartServer.

Item_Coll

itemColl =

new

iLON_SmartServer.

Item_Coll

();

itemColl.Item =

new

iLON_SmartServer.

Item

[1];

itemColl.Item[0] = networkScan;
SmartServer.InvokeCmd(

ref

itemColl);


Console

.WriteLine(

"starting scan"

);


//send the GetScan command to check network scan progress

iLON_SmartServer.

LON_Network_ScanCommand_Invoke

networkScan_Check =

new

iLON_SmartServer.

LON_Network_ScanCommand_Invoke

();

networkScan_Check.ScanCommand = iLON_SmartServer.

LON_Network_eScanCommand

.GetScan;

networkScan_Check.UCPTname =

"Net"

;


iLON_SmartServer.

Item_Coll

itemColl_Check =

new

iLON_SmartServer.

Item_Coll

();

itemColl_Check.Item =

new

iLON_SmartServer.

Item

[1];

itemColl_Check.Item[0] = networkScan_Check;