beautypg.com

21 programming examples, 1 visual c#.net examples, Programming examples -1 – Echelon i.LON SmartServer 2.0 User Manual

Page 353: Visual c#.net examples -1, Chapter 21

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-1

21

Programming Examples

This chapter includes programming examples, written in Visual C# (.NET 3.5 and .NET 2.0
Frameworks) and Visual Basic with Microsoft Visual Studio 2008, that demonstrate how to use the
SmartServer’s SOAP API to create custom applications. These programming examples create simple
console applications that do the following:

• Read and write data point values.

• Create and read a data logger.

• Create a scheduler and a calendar.

• Create and install L

ON

W

ORKS

devices

• Commission unconfigured external devices.

• Discover and install uncommissioned external devices.

• Configure the SmartServer (with System Service Methods).

Notes:

All examples assume that you are using a SmartServer that has been set to its factory default settings.
This prevents compilation errors based on mismatching properties of the objects in the
L

ON

W

ORKS

network hierarchy (network/channel/device/functional block/data point).

You can download these programming examples from the i.LON SmartServer Community Web site at

ilonsmartserver.com

.

21.1

Visual C#.NET Examples

21.1.1

Reading and Writing Data Point Values in Visual C# .NET

This C# console example toggles the SmartServer’s digital relay outputs when run. It demonstrates
how to use an xSelect statement to filter items returned by a List() method, and it demonstrates how to
write to data points using values and presets.

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.

For more information on the data point properties set and read in this example, see section 4.3.2,
Using the Get Function on the Data Server
, and section 4.3.3, Using the Read Function on the Data
Server
, respectively.

using

System;

using

System.Collections.Generic;

using

System.Linq;

using

System.Text;

namespace

SmartServerConsoleExample

{

class

DpProgram

{

// 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

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;