Echelon i.LON SmartServer Technical Information Page 337

  • Download
  • Add to my manuals
  • Print
  • Page
    / 443
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 336
i.LON SmartServer 2.0 Programmer’s Reference
20-15
Note: The following examples assume that you are using a SmartServer that has been set to its factory
default settings. This prevents compilation errors based on mismatching <UCPTname> properties of
the objects in the L
ONWORKS network hierarchy (network/channel/device/functional block/data point).
20.3.1
Reading and Writing Data Point Values in Visual C# .NET 3.5
The following Visual C# .NET 3.5 example reads the value of the Net/LON/iLON App/Digital Output
1/nviClaValue_1 data point on the SmartServer, and then writes a value of “100.0 1” to it. This
SNVT_switch data point is one of the relay outputs on the SmartServer. You can execute this code
after you have completed section 20.1.1,
Referencing and Inheriting from the WSDL Using .NET 3.5
Framework, and section 20.2.1,
Instantiating the Web Service Client in Visual C# .NET 3.5.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SmartServerConsoleExample
{
class Program
{
static void Main(string[] args)
{
iLON_SoapCalls.BindClientToSmartServer();
iLON_SmartServer.iLON100portTypeClient SmartServer = iLON_SoapCalls._iLON;
// -------------- READING A DATA POINT VALUE --------------
try
{
// instantiate the member object
iLON_SmartServer.Item_Coll itemColl = new iLON_SmartServer.Item_Coll();
itemColl.Item = new iLON_SmartServer.Item[1];
itemColl.Item[0] = new iLON_SmartServer.Dp_Data();
// set the DP name
itemColl.Item[0].UCPTname = "Net/LON/iLON App/Digital Output 1/nviClaValue_1";
// set maxAge to get the updated DP value in case it has been cached for more than 10
// seconds on the Data Server (see section 4.3.4.1 for more information)
((iLON_SmartServer.Dp_Data)(itemColl.Item[0])).UCPTmaxAge = 10;
((iLON_SmartServer.Dp_Data)(itemColl.Item[0])).UCPTmaxAgeSpecified = true;
//call the Read Function
iLON_SmartServer.Item_DataColl dataColl = SmartServer.Read(itemColl);
if (dataColl.Item == null)
{
// sanity check. this should not happen
Console.Out.WriteLine("No items were returned");
}
else if (dataColl.Item[0].fault != null)
{
// error
Console.Out.WriteLine("An error occurred. Fault code = " +
dataColl.Item[0].fault.faultcode +
". Fault text = %s." +
dataColl.Item[0].fault.faultstring);
}
else
{
// success
Console.Out.WriteLine("Read is successful");
Console.Out.WriteLine(((iLON_SmartServer.Dp_Data)dataColl.Item[0]).UCPTname + " = " +
((iLON_SmartServer.Dp_Data)dataColl.Item[0]).UCPTvalue[0].Value + "\n");
}
Page view 336
1 2 ... 332 333 334 335 336 337 338 339 340 341 342 ... 442 443

Comments to this Manuals

No comments