beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 386

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-34

PrintGetError(ItemColl)

Else

Dim

myDataLogger

As

iLON_SmartServer.Item = ItemColl.Item(0)

Console.WriteLine(

"Data Logger = "

& myDataLogger.UCPTname & vbCr & vbLf & vbCr & vbLf)

End

If

'we use an xSelect to read only the last 10 records in the Data Logger for one data point

ItemColl.xSelect =

"//Item[UCPTpointName=""Net/LON/iLON App/Digital Output 1/nviClaValue_1""][position()>=last()-10]"

' Read Data Logger

Dim

dataLogger

As

iLON_SmartServer.Item_DataColl = SmartServer._iLON.Read(ItemColl)


For

i

As

Integer

= 0

To

dataLogger.Item.Length - 1

Dim

dataLoggerDataCheck

As

iLON_SmartServer.UFPTdataLogger_Data =

TryCast

(dataLogger.Item(i), iLON_SmartServer.UFPTdataLogger_Data)


If

dataLoggerDataCheck

IsNot

Nothing

Then

Dim

dataLoggerData

As

iLON_SmartServer.UFPTdataLogger_Data =

DirectCast

(dataLogger.Item(i), iLON_SmartServer.UFPTdataLogger_Data)

Console.Out.WriteLine(((dataLoggerData.UCPTname &

" was "

) +

dataLoggerData.UCPTvalue(0).Value

&

" at "

) + dataLoggerData.UCPTlastUpdate & vbCr & vbLf)

Next

Console.ReadLine()

Finally

SmartServer.CloseBindingToSmartServer()

End Try

End

Sub

End Module

21.2.3

Creating a Scheduler and Calendar in Visual Basic.NET

This VB console example creates a Scheduler and Calendar for hypothetically controlling the lighting
and heating of a store. 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.

The example creates a new Scheduler from an existing uninstantiated (hidden) Scheduler on the
SmartServer. It creates separate daily schedules for weekdays, Saturdays, and Sundays, and it
specifies that the scheduler turn on and off the SmartServer’s digital relay outputs (the Net/LON/iLON
App/Digital Output 1/nviClaValue_1 and Net/LON/iLON App/Digital Output 2/nviClaValue_2 data
points) at specific times based on the day of the week. The example then creates an exception that
keeps the lighting and heating off on holidays.

After creating the Scheduler, this example either gets the Calendar on the SmartServer if it has already
been instantiated or creates a new Calendar. The example then specifies the dates of the holidays for
the exception created in the Scheduler, and it specifies over how many years the holiday exceptions are
to occur.

For more information on the Scheduler and Calendar properties set in this example, see section 9.3.2,
Using the Get Function a Scheduler and section 10.3.2, Using the Get Function a Calendar,
respectively.

Note: The property is the unique identifier for exceptions defined in the
Scheduler and Calendar. This means that the property of new exceptions
you create must be unique to the Calendar; otherwise, the exception you create will overwrite an
existing exception. To prevent overwriting an existing exception, you can loop through the existing
exceptions on the Calendar and check whether the property of the exception
you are creating matches that of any existing exceptions. This example assumes that your SmartServer
has been set to its factory default settings and therefore does not perform this check.

Module

SchedulerModule


Private

Sub

PrintGetError(

ByVal

ItemCfgColl

As

iLON_SmartServer.Item_CfgColl)