Echelon i.LON SmartServer 2.0 User Manual
Page 359
![background image](/manuals/735732/359/background.png)
i.LON SmartServer 2.0 Programmer’s Reference
21-7
Console
.ReadLine();
}
finally
{
iLON_SoapCalls
.CloseBindingToSmartServer();
}
}
}
}
21.1.3
Creating a Scheduler and Calendar in Visual C# .NET
This C# 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
Scheduler and Calendar. This means that the
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
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.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading;
namespace
SmartServerConsoleExample
{
class
Program
{
// 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
PrintGetError(iLON_SmartServer.
Item_CfgColl
ItemCfgColl)
{
// print out error and exit
Console
.Out.WriteLine(
"An error occurred:"
);
for
(
int
j = 0; j < ItemCfgColl.Item.Length; j++)
{
if
(ItemCfgColl.Item[j].fault !=
null
)
{