Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 560 -
Store the date value or time value in each member of "buf.data.date"
or "buf.data.time" with binary format as follows.
Member Setting data Range of value
-----------------------+---------------+---------------
buf.data.date.year Year 1987 - 2037
buf.data.date.month Month 1 - 12
buf.data.date.date Date 1 - 31
buf.data.time.hour Hour 0 - 23
buf.data.time.minute Minute 0 - 59
buf.data.time.second Second 0 - 59
That is, the time "00:00:00, Jan. 1, 1987" through
"23:59:59, Dec. 31, 2037" can be set.
This function doesn't check strictly validity of date format
(buf.data.date.*). For example, "Feb. 31" can be set. In this case,
"Mar. 3" is read by "time()" function (not a leap year), "Feb. 31"
is displayed in the setting scrren of CNC.
This function is available for only FS16/18 Model C or later.
[Example]
The following program sets the date and time input by keyboad to the
calendar timer.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
int example( void )
{
struct iodbtimer buf ;
int ret, year, month, date, hour, minute, second ;
printf( "Year =" ) ;
scanf( "%d", &year ) ;
printf( "Month =" ) ;
scanf( "%d", &month ) ;
printf( "Date =" ) ;
scanf( "%d", &date ) ;
printf( "Hour =" ) ;
scanf( "%d", &hour ) ;
printf( "Minute=" ) ;
scanf( "%d", &minute ) ;
printf( "Second=" ) ;
scanf( "%d", &second ) ;
buf.type = 0 ;
buf.data.date.year = year ;
buf.data.date.month = month ;
buf.data.date.date = date ;
ret = cnc_settimer( &buf ) ;
if ( ret == 5 ) printf( "Error while writing DATE.\n" ) ;
buf.type = 1 ;
buf.data.time.hour = hour ;
buf.data.time.minute = minute ;
buf.data.time.second = second ;
ret = cnc_settimer( &buf ) ;
if ( ret == 5 ) printf( "Error while writing TIME.\n" ) ;
}