|
BACnet Server API - Time Schedule Tutorial
Download application - 41.5 Kb
Download Winpcap - Version 3.0
Introduction
BACnet has the ability to schedule operations using a standard object type
called a TimeSchedule object. The Weekly Schedule property of this object
is used to control the Present Value property based on the 7 days of the week. Each
day of the week has a corresponding Daily Schedule containing On/Off times
that are used for that day. The Weekly Schedule property can be overriden by
the Exception Schedule property which can be configured based on a list of
dates residing in a Calendar Object, a Date, or a Data Range.
The configuration of BACnet Schedule objects may not be possible via BACnet Services.
This example and corresponding application demonstrates how the properties
of a Time Schedule object can be configured using standard BACnet Services. If
a device does not support configuration, then an error will be returned by that device.
Installation and Running the Sample
To Install the sample application you will need to unzip the contents of the
application into a directory and then install winpcap. Once Winpcap is installed
just start the object_access.exe application. When it starts will be asked to
enter a device ID for the application, you can leave this as zero. You should
then see a screen that lists all of the options available as shown by the screenshot
above. The source code for this sample is available from the downloads
area of this web site as part of the BACnet Server API using either Windows or Linux.
The source code demonstrates which BACnet Services are used and all of parameters
required to use the services.
To use the example application it is best to have another device connected to the
network, and it needs to be running BACnet/IP. This device needs to have a different
device ID to the one you enterred for the application. If you do not have another device,
you can create object inside the application using the Create Object option described below.
Creating Time Schedule Object
You can create a Time Schedule object inside the application, or on
another BACnet device using this option. When the application starts it will
not have a Time Schedule Object configured. You will need to create one first if
you do not have another device available.
If there is another device available, then you can skip this step.
Select Option 1 to create a Time Schedule Object
Enter Device ID = 0 (This will create an object internal to the application.)
Enter Instance Number = 0
Reading the Present Value
To read the present value of the Time Schedule Object stored in any device
select option 1.
You will be prompted to enter a device ID corresponding to the device you wish to read from.
Enter Device ID = 0 (This will read from an object internal object.)
Enter Instance Number = 0
Reading the Day Schedule
The Day Schedule is stored inside the Weekly Schedule property of the Time Schedule
Object. This property is an array of size 7 with each element of the array
corresponding to a Day of the Week. The Day Schedule is a list of Time Values
that are used to activate the Present Value of the Object.
To read the Day Schedule of the Time Schedule Object stored in any device
select option 3.
Enter Device ID = 0 (This will read from an object internal object.)
Enter Instance Number = 0
Day Of The Week = 1
If there is no error, then a list of time values will be returned. Each Time Value
is stored inside curly braces, with a set of braces enclosing the entire list.
If the Day Schedule is empty then you will see {{}}
Editing the Day Schedule
The application can be used to write to a Day Schedule stored
inside the Weekly Schedule property of the Time Schedule Object.
This property is an array of size 7 with each element of the array
corresponding to a Day of the Week. The Day Schedule is a list of Time Values
that are used to activate the Present Value of the Object.
The application will read the Day Schedule, and the prompt the user with
each Time Value currently stored in the device and then allow new Time Values
to be added.
To write the Day Schedule of the Time Schedule Object stored in any device
select option 4. This example will create activate the time schedule
from 9:00 am to 4:00 pm on every Monday of the week.
Enter Device ID = 0 (This will read from an object internal object.)
Enter Instance Number = 0
Day Of The Week = 1
Enter an Hour of the Day = 9
Enter a Minute of the Hour = 0
Enter a switch type = 1
Would you like to add a day schedule entry = 1
Enter an Hour of the Day = 16
Enter a Minute of the Hour = 0
Enter a switch type = 0
Would you like to add a day schedule entry = 0
If there is no error, then a success message will be returned
Reading the Exception Schedule
The Exception Schedule is a property of the Time Schedule Object.
It consists of a list of Special Events that are used to override
the Weekly Schedule property of the Time Schedule Object. It can be used for holidays,
or for one off events. In the case of Holidays, it would normally reference
a Calendar Object which contains Dates that apply to the Special Event. A Calendar
Object does not necessarily need to be used, the Special Event could be used
with it's own list of Dates.
To read the Exception Schedule of the Time Schedule Object stored in any device
select option 5.
Enter Device ID = 0 (This will read from an object internal object.)
Enter Instance Number = 0
If there is no error, then a list of time values will be returned. Each Special
Event is stored inside curly braces, with a set of braces enclosing the entire list.
If the Exception Schedule is empty then you will see {{}}
Editing the Exception Schedule
The Exception Schedule is a property of the Time Schedule Object.
It consists of a list of Special Events that are used to override
the Weekly Schedule property of the Time Schedule Object. It can be used for holidays,
or for one off events. In the case of Holidays, it would normally reference
a Calendar Object which contains Dates that apply to the Special Event. A Calendar
Object does not necessarily need to be used, the Special Event could be used
with it's own list of Dates.
To write to the Exception Schedule of the Time Schedule Object stored in any device
select option 6.
This example will store 1 special event which is set to activate the schedule
on 1 April 2006 between 9:00 am and 16:00 pm.
Enter Device ID = 0 (This will read from an object internal object.)
Enter Instance Number = 0
Enter a year = 2006
Enter a month = 4
Enter a day = 1
Enter an Hour of the Day = 9
Enter a Minute of the Hour = 0
Enter a switch type = 1
Would you like to add a day schedule entry = 1
Enter an Hour of the Day = 16
Enter a Minute of the Hour = 0
Enter a switch type = 0
Would you like to add a day schedule entry = 0
Would you like to add a special event = 0
If there is no error, then a success message will be returned
Examine the Code
The entire source code for this sample is available from the downloads
area of this web site as part of the BACnet Server API using either Windows or Linux.
The code has many comments that describe the use of the standard BACnet Services
used to configure the Time Schedule Object.
Further Reading
|