Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 527 -
[Example]
The following program reads the amount of tool, the tool life value
and the tool life counter within the specified tool group range, and
displays them.
#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
/* start/end are start/end index number of groups to be read. */
int example( int start, int end )
{
struct iodbpsd prm ;
struct iodbtr *buf ;
int ret, idx ;
buf = (struct iodbtr *)malloc( 6+12*(end-start+1) ) ;
cnc_rdparam( 6800, 0, 4+1*1, &prm ) ;
ret = cnc_rdtoolrng( start, end, 6+12*(end-start+1), buf ) ;
if ( !ret ) {
printf( "GROUP# Number_of_TOOL TOOL_life "
"TOOL_life_counter\n" ) ;
printf( "------+--------------+---------+"
"-----------------\n" ) ;
for ( idx = 0 ; idx <= end-start ; idx++ )
printf( "%3d %4ld %4ld %4ld\n",
idx+start, buf->data[idx].ntool,
buf->data[idx].life, buf->data[idx].count ) ;
printf( " %s %s\n",
(prm.u.cdata & 0x04)?" [min]":"[times]",
(prm.u.cdata & 0x04)?" [min]":"[times]" ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}