Description
Reads the program directory of all the programs registered in the CNC.
Reads specified number of "Program Number","Comment" and "Program size (number of characters)" data of the registered programs in the CNC, starting from the program with the specified Program number.
It has the function to specify the number of programs to be read in order to get the information corresponding to the number of programs which is set by the application.
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. See Program number 8 digits for details.
Universal Fanuc Driver
Fanuc Focas Library CD
Declaration
For the program number 8 digits :
FWLIBAPI short WINAPI cnc_rdprogdir2(unsigned short FlibHndl, short type, long *top_prog, short *num_prog, PRGDIR2 *buf);
Arguments
Specify the library handle. See "Library handle" for details.
0 | : | "Program number" only |
1 | : | "Program number" and "Comment" |
2 | : | "Program number", "Comment" and "Program size" |
Pointer to the starting program number.
The program number of the first program actually read is stored after this function call.
Pointer to the number of programs to be read.
Actual number of programs being read is stored after this function call.
Pointer to the PRGDIR2 structure where program directory data are returned.
The PRGDIR2 structure is as follows.
For program number 4 digits,
typedef struct prgdir2 {
short number;
long length;
char comment[51];
char dummy;
} PRGDIR2;
For program number 8 digits,
typedef struct prgdir2 {
long number;
long length;
char comment[51];
char dummy;
} PRGDIR2;
- number
- Program number
- Program number is returned.
- length
- Program size
- Program size is returned.
- Valid when 2 is specified for the arguments "type".
- comment
- Comment
- The "Comment" stored next to the "Program number" in the CNC is returned.
The maximum length of the comment stored is 48 characters (50 characters includ- ing leading "(" and trailing ")"). When the "Comment" is longer than 48 characters, the part after the 48th character is ignored.
When no "Comment" is registered only parentheses ("()") are returned.
The "Comment" character string is terminated with NULL character.
Valid when 1 or 2 is specified for the argument "type".
When no programs are registered or no programs match the specified condition, "0" is returned to "num_prog".
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. |
(2) |
The number of readout(num_prog) is wrong. |
(3) |
The start number of program(top_prog) is wrong. |
(4) |
Output format(type) is wrong. |
As for the other return codes or the details, see "Return status of Data window function"
CNC option
And this function is related to the following CNC option.
- Series 15/15i
Program name 48 characters
If this option does not exist, the maximum program name is 16 characters.
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 not related to CNC parameter.
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.
See Also
cnc_rdprogdir cnc_rdprogdir3 cnc_rdprogdir4
Example(C Language)
The following program reads all registration information of NC program,
and displays program number list.
#include "fwlib32.h"
#define BUFSIZE 100
void example()
{
PRGDIR2 prg[BUFSIZE];
short i, num;
short top = 0;
short ret;
do {
num = BUFSIZE;
ret = cnc_rdprogdir2( h, 0, &top, &num, prg );
if ( ret == EW_NUMBER ) {
break;
}
if ( ret ) {
printf( "ERROR: %d\n", ret );
break;
}
for ( i = 0 ; i < num ; i++ ) {
printf( "O%d\n", prg[i].number );
}
top = prg[num-1].number + 1;
} while ( num >= BUFSIZE );
}
Example(C#)
The following program reads all registration information of NC program,
and displays program number list.
class example
{
public const short BUFSIZE = 100;
public void sample()
{
Focas1.PRGDIR2_data prg = new Focas1.PRGDIR2_data();
short i, num;
short top = 0;
short ret;
byte[] bytes = new byte[Marshal.SizeOf(prg) * BUFSIZE];
IntPtr ptrWork = Marshal.AllocCoTaskMem(Marshal.SizeOf(prg));
do
{
num = BUFSIZE;
ret = Focas1.cnc_rdprogdir2(h, 0, ref top, ref num, bytes);
if (ret == (short)Focas1.focas_ret.EW_NUMBER)
{
break;
}
if (ret != Focas1.EW_OK)
{
Console.WriteLine("ERROR: {0}", ret);
break;
}
for (i = 0; i < num; i++)
{
Marshal.Copy(bytes, i * Marshal.SizeOf(prg), ptrWork, Marshal.SizeOf(prg));
Marshal.PtrToStructure(ptrWork, prg);
Console.WriteLine("O{0}", prg.number);
}
top = (short)(prg.number + 1);
} while (num >= BUFSIZE);
Marshal.FreeCoTaskMem(ptrWork);
}
}