System information

Table Of Contents
i.LON SmartServer 2.0 Programmer’s Reference
21-4
// -------------- CREATING A DATA LOGGER --------------
//Create an xSelect object and then specify the filter to be used
iLON_SmartServer.E_xSelect xSelect =
new iLON_SmartServer.E_xSelect();
xSelect.xSelect =
"//Item[@xsi:type=\"LON_Fb_Cfg\"][contains(UCPTname,\"Log\")][UCPThidden = \"1\"]";
//Create an ItemColl that stores objects returned by List()function that takes an xSelect object
iLON_SmartServer.Item_Coll ItemColl = SmartServer.List(xSelect);
//Create an ItemCfgColl that stores the objects to be returned by a Get() function
//that takes the ItemColl returned by the List()
ItemColl.xSelect = "//Item[@xsi:type=\"LON_Fb_Cfg\"]";
iLON_SmartServer.Item_CfgColl ItemCfgColl = SmartServer.Get(ItemColl);
//check that there are obejcts in the ItemCfgColl
if (ItemCfgColl.UCPTfaultCount > 0)
{
PrintGetError(ItemCfgColl);
}
else
{
//Create LON_Fb_Cfg item
ItemCfgColl.Item[0].UCPThidden = 0;
ItemCfgColl.Item[0].UCPTname = "Net/LON/iLON App/myDataLogger";
iLON_SmartServer.Item_Coll ItemColl_SetReturn = SmartServer.Set(ItemCfgColl);
//create new Data Logger from existing one
iLON_SmartServer.UFPTdataLogger_Cfg myDataLogger =
new ConsoleApplication_CSharp_Test_3._5.iLON_SmartServer.UFPTdataLogger_Cfg();
myDataLogger.UCPTname = "Net/LON/iLON App/myDataLogger";
myDataLogger.UCPTannotation = "#8000010128000000[4].UFPTdataLogger";
myDataLogger.UCPTlogFileName = "Net/LON/iLON App/myDataLogger.csv";
myDataLogger.UCPTlogSize = 100;
myDataLogger.UCPTlogLevelAlarm = 50;
myDataLogger.UCPTlogType =
new ConsoleApplication_CSharp_Test_3._5.iLON_SmartServer.E_LonString();
myDataLogger.UCPTlogType.Value = "LT_HISTORICAL";
myDataLogger.UCPTlogType.LonFormat = "UCPTlogType";
myDataLogger.UCPTlogFormat =
new ConsoleApplication_CSharp_Test_3._5.iLON_SmartServer.E_LonString();
myDataLogger.UCPTlogFormat.Value = "LF_TEXT";
myDataLogger.UCPTlogFormat.LonFormat = "UCPTlogFormat";
//create DP reference array to store data points by new Data Logger
myDataLogger.DataPoint =
new ConsoleApplication_CSharp_Test_3._5.iLON_SmartServer.E_DpRef[2];
//speficy data points to be logged by new Data Logger
iLON_SmartServer.UFPTdataLogger_DpRef dataPointRef1 =
new iLON_SmartServer.UFPTdataLogger_DpRef();
dataPointRef1.UCPTname = "Net/LON/iLON App/Digital Output 2/nviClaValue_2";
dataPointRef1.UCPTformatDescription = "#0000000000000000[0].SNVT_switch";
dataPointRef1.UCPTpollRate = 60;
dataPointRef1.dpType = "Input";
iLON_SmartServer.UFPTdataLogger_DpRef dataPointRef2 =
new iLON_SmartServer.UFPTdataLogger_DpRef();
dataPointRef2.UCPTname = "Net/LON/iLON App/Digital Output 1/nviClaValue_1";
dataPointRef2.UCPTformatDescription = "#0000000000000000[0].SNVT_switch";