beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 358

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-6

Console

.Out.WriteLine(

"Item: "

+ ItemColl.Item[j].UCPTname +

", fault code: "

+

ItemColl.Item[j].fault.faultcode +

", fault string: "

+

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

}
}
}

static

void

Main(

string

[] args)

{

iLON_SoapCalls

.BindClientToSmartServer();

// If you are using NET 2.0 Framework, comment out the previous line of code, and then
// uncomment the following line of code

// iLON_SoapCalls.BindClientToSmartServer(_iLonEndpointIpAddress);


iLON_SmartServer.

iLON100portTypeClient

SmartServer =

iLON_SoapCalls

._iLON;

try

{


// -------------- READING A DATA LOGGER --------------

//Create an xSelect object and then specify the UCPTname of the Data Logger created

// in the previous section as the filter (“Net/LON/iLON App/myDataLogger”)

ConsoleApplication_CSharp_Test_3._5.iLON_SmartServer.

E_xSelect

xSelect =

new

ConsoleApplication_CSharp_Test_3._5.iLON_SmartServer.

E_xSelect

();


xSelect.xSelect =

"//Item[UCPTname = \"Net/LON/iLON App/myDataLogger\"]"

;


//Create an ItemColl that stores objects returned by List()function that takes an xSelect object

iLON_SmartServer.

Item_Coll

ItemColl = SmartServer.List(xSelect);


//check that there are obejcts in the ItemColl

if

(ItemColl.UCPTfaultCount > 0)

{
PrintGetError(ItemColl);
}

else

{

iLON_SmartServer.

Item

myDataLogger = ItemColl.Item[0];

Console

.WriteLine(

"Data Logger = "

+ myDataLogger.UCPTname +

"\r\n"

);

}

//we use an xSelect to read only the last 10 records in the Data Logger for one data point

ItemColl.xSelect =

"//Item

[UCPTpointName=\"Net/LON/iLON App/Digital Output 1/nviClaValue_1\"]

[position()>=last()-10]"

;


// Read Data Logger

iLON_SmartServer.

Item_DataColl

dataLogger = SmartServer.Read(ItemColl);


for

(

int

i = 0; i < dataLogger.Item.Length; i++)

{
iLON_SmartServer.

UFPTdataLogger_Data

dataLoggerDataCheck =

dataLogger.Item[i]

as

iLON_SmartServer.

UFPTdataLogger_Data

;


if

(dataLoggerDataCheck !=

null

)

{
iLON_SmartServer.

UFPTdataLogger_Data

dataLoggerData =

(iLON_SmartServer.

UFPTdataLogger_Data

)dataLogger.Item[i];


Console

.Out.WriteLine(dataLoggerData.UCPTname +

" was "

+

dataLoggerData.UCPTvalue[0].Value +

" at "

+

dataLoggerData.UCPTlastUpdate

+

"\r\n"

);

}
}