Download ISaGRAF C Tools User Manual

Transcript
setClockAlarm
Sets real time clock alarm.
Real Time Clock Macros
The ctools.h file defines the following macros for real time clock alarms. Refer to the C
Tools Macros section for details on each macro listed.
AT_ABSOLUTE
Specifies a fixed time of day alarm.
AT_NONE
Disables alarms
Real Time Clock Structures
The ctools.h file defines the structures Real Time Clock Structure and Alarm Settings
Structure for real time clock information. Refer to the C Tools Structures and Types
section for complete information on structures and enumeration types.
Real Time Clock Program Example
The following program illustrates how the date and time can be set and displayed. All fields
of the clock structure must be set with valid values for the clock to operate properly.
#include <ctools.h>
void main(void)
{
struct clock now;
/* Set to 12:01:00 on January 1, 1994 */
now.hour
now.minute
now.second
now.day
now.month
now.year
now.dayofweek
=
=
=
=
=
=
=
12;
1;
0;
1;
1;
94;
6;
/* set the time */
/* set the date */
/* day is Sat. */
request_resource(IO_SYSTEM);
setclock(&now);
now = getclock();
release_resource(IO_SYSTEM);
/* Display current hour, minute and second */
printf("%2d:%2d:%2d", now.hour, now.minute,
now.second);
}
Stopwatch Timer Functions
The stopwatch is a counter that increments every 10 ms. The stopwatch is useful for
measuring execution times or generating delays where a fine time base is required. The
stopwatch time rolls over to 0 when it reaches the maximum value for an unsigned long
integer: 4,294,967,295 ms (or about 497 days).
There is one library function to access the stopwatch time. Refer to the readStopwatch
section for details.
readStopwatch
ISaGRAF C Tools User and Reference Manual
May 8, 2007
reads the stopwatch timer.
44