beautypg.com

2 reading a data logger – Echelon i.LON SmartServer 2.0 User Manual

Page 357

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-5

dataPointRef2.UCPTpollRate = 60;
dataPointRef2.dpType =

"Input"

;


//store data points in DP reference array

myDataLogger.DataPoint[0] = dataPointRef1;
myDataLogger.DataPoint[1] = dataPointRef2;

//call Set function

iLON_SmartServer.

Item_CfgColl

itemCfgColl =

new

iLON_SmartServer.

Item_CfgColl

();

itemCfgColl.Item =

new

iLON_SmartServer.

Item_Cfg

[1];

itemCfgColl.Item[0] = myDataLogger;


iLON_SmartServer.

Item_Coll

ItemColl_Set_DataLogger_Return =

SmartServer.Set(itemCfgColl);


if

(ItemColl_Set_DataLogger_Return.UCPTfaultCount > 0)

{
PrintGetError(ItemColl_Set_DataLogger_Return);
}

else

{
iLON_SmartServer.

Item

newDataLogger = ItemColl_Set_DataLogger_Return.Item[0];

Console

.WriteLine(

"New Data Logger = "

+ newDataLogger.UCPTname);

}

}

Console

.ReadLine();

}


finally

{

iLON_SoapCalls

.CloseBindingToSmartServer();

}


}
}
}

21.1.2.2 Reading a Data Logger

The following C# console example reads and prints out the last 10 entries for one of the two data
points recorded by the new data logger you created in the previous section, Creating a Data Logger.
For more information on the data logger properties used in this example, see section 5.3.4, Using the
Read Function on a Data Logger
.

using

System;

using

System.Collections.Generic;

using

System.Linq;

using

System.Text;

using

System.Threading;

namespace

SmartServerConsoleExample

{

class

Program

{

// If you are using NET 2.0 Framework, uncomment the following line of code to enter your

// SmartServer’s IP Address

// public static string _iLonEndpointIpAddress = "<SmartServer IP Address>";


static

void

PrintGetError(iLON_SmartServer.

Item_Coll

ItemColl)

{

// print out error and exit

Console

.Out.WriteLine(

"An error occurred:"

);

for

(

int

j = 0; j < ItemColl.Item.Length; j++)

{

if

(ItemColl.Item[j].fault !=

null

)

{