Description
Reads program number(modal O number) of the program which is being currently selected in CNC.
As for Series 15i, 16/18/21, 16i/18i/21i, 0i, 30i, Power Mate i, PMi-A, if CNC exetues the sub-program, this function can read also the main program number. In this case, that main program number is the root program number which was selected on the CNC for the execution. If the program being executed is not a sub-program, the same program number is set to both 'Running program number' and 'Main program number'.
This function is used for management of NC programs in CNC by the application program, etc.
The program numbers are stored in "buf.data" and 'buf.mdata" with unsigned binary format.
In Series 16/18, 16i/18i, 0i-F, 30i, Power mate i, it is possible to use this function for
the program number 8 digits, however it is necessary to switch API to the one for the
program number 8 digits.
In Series 15i, it is necessary to switch API to the one for the program number 8 digits.
See Program number 8 digits for details.
Universal Fanuc Driver
Fanuc Focas Library CD
Declaration
Arguments
Specify the library handle. See "Library handle" for details.
Pointer to the ODBPRO structure including the program numbe being executed.
The ODBPRO structure is as follows.
For program number 4 digits,
typedef struct odbpro {
short dummy[2] ; /* Not used. */
short data ; /* Running program number. */
short mdata ; /* Main program number. */
} ODBPRO ; /* */
For program number 8 digits,
typedef struct odbpro {
short dummy[2] ; /* Not used */
long data ; /* Running program number. */
long mdata ; /* Main program number. */
} ODBPRO ; /* */
Return
EW_OK is returned on successful completion, otherwise any value except EW_OK is returned.
The major error codes are as follows.
Return code | Meaning/Error handling |
---|---|
(1) |
This application is not customized for the program number 8 digits. See Program number 8 digits for details. |
(9) |
7613#0=0 when CNC is turned on. Set CNC parameter again. |
As for the other return codes or the details, see "Return status of Data window function"
CNC option
For HSSB connection,
For Ethernet connection,
The Ethernet function and the extended driver/library function are necessary. However, in case of Series 16i/18i/21i-B, 0i-B/C/D/F, Series 30i and PMi-A, the required CNC option is as follows. When Embedded Ethernet is used,above two optional functions are not required.
When Ethernet board is used,
- only Ethernet function is required.
CNC parameter
This function is related to the following CNC parameter.
See the manual of CNC parameter for details.
CNC mode
This function can be used in any CNC mode.
Available CNC
0i-A | 0i-B/C(Note) | 0i-D | 0i-F | 15 | 15i | 16 | 18 | 21 | 16i-A | 18i-A | 21i-A | 16i-B | 18i-B | 21i-B | 30i-A | 30i-B | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
M (Machining) | |||||||||||||||||
T (Turning) | - | ||||||||||||||||
LC (Loader) | - | - | - | - | - | - | - | - |
0i-D | 0i-F | 16i | 18i | 30i-A | 30i-B | |
---|---|---|---|---|---|---|
P (Punch press) | - | |||||
L (Laser) | - | - | - | - | ||
W (Wire) | - | - |
Power Mate i-D | |
Power Mate i-H | |
Power Motion i-A | O |
"O" | : | Both Ethernet and HSSB | |
"E" | : | Ethernet | |
"H" | : | HSSB | |
"X" | : | Cannot be used | |
"-" | : | None |
Note) 0i-C does not support the HSSB function.
Example(C Language)
The next program displays "CURRENT(O9876) MAIN(O1234)" while the block
"O9876/N210" of the following NC program is being executed.
#include "fwlib32.h"
void example( void )
{
struct odbpro buf ;
cnc_rdprgnum( h, &buf ) ;
printf( "CURRENT(O%d) MAIN(O%d)\n", buf.data, buf.mdata ) ;
}
O1234 ; O5678 ; O9876 ;
N10 M98 P5678 ; N110 M98 P9876 ; N210 M45 ;
N20 M30 ; N120 M99 ; N220 M99 ;
Example(C#)
The next program displays "CURRENT(O9876) MAIN(O1234)" while the block
"O9876/N210" of the following NC program is being executed.
class example
{
public void sample()
{
Focas1.ODBPRO buf = new Focas1.ODBPRO();
Focas1.cnc_rdprgnum(h, buf);
Console.WriteLine("CURRENT(O{0}) MAIN(O{1})", buf.data, buf.mdata);
}
}
O1234 ; O5678 ; O9876 ;
N10 M98 P5678 ; N110 M98 P9876 ; N210 M45 ;
N20 M30 ; N120 M99 ; N220 M99 ;