beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 354

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-2

try

{

// See Section 20.2.1 (NET 3.5) or 20.2.2 (NET 2.0)for more information on iLON_SoapCalls class

SmartServerConsoleExample.iLON_SmartServer.

E_xSelect

xSelect =

new

SmartServerConsoleExample.iLON_SmartServer.

E_xSelect

();


xSelect.xSelect =

"//Item[@xsi:type=\"Dp_Cfg\"][contains(UCPTaliasName,\"nviClaValue\")]"

;

iLON_SmartServer.

Item_Coll

ItemColl = SmartServer.List(xSelect);

iLON_SmartServer.

Item_DataColl

ItemDataColl = SmartServer.Read(ItemColl);



if

(ItemColl.UCPTfaultCount > 0)

{

Console

.Out.WriteLine(

"you've got errors"

);

}

else

{

for

(

int

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

{
iLON_SmartServer.

Item

Dps = ItemColl.Item[i];

Console

.Out.WriteLine(Dps.UCPTname);

iLON_SmartServer.

Dp_Data

DpValues =

(iLON_SmartServer.

Dp_Data

)ItemDataColl.Item[i];

Console

.Out.WriteLine(DpValues.UCPTvalue[0].Value);



if

(DpValues.UCPTvalue[0].Value ==

"0.0 0"

)

{
DpValues.UCPTvalue[0].Value =

"100.0 1"

;

DpValues.UCPTvalue[1].Value =

"ON"

;


Console

.Out.WriteLine(DpValues.UCPTvalue[0].Value);

}

else

if

(DpValues.UCPTvalue[0].Value ==

"100.0 1"

)

{
DpValues.UCPTvalue[0].Value =

"0.0 0"

;

DpValues.UCPTvalue[1].Value =

"OFF"

;


Console

.Out.WriteLine(DpValues.UCPTvalue[0].Value);

}

}

SmartServer.Write(ItemDataColl);

}

Console

.ReadLine();

}

finally

{

iLON_SoapCalls

.CloseBindingToSmartServer();

}


}
}
}

21.1.2

Creating and Reading a Data Logger in Visual C# .NET

The following C# console example creates a data logger and then reads the data recorded by it. You
can execute this code after you have referenced and inherited from the SmartServer WSDL as
described in section 20.1, and instantiated and initialized the Web service client as described in section
20.2.