Description
Reads the program directory of all the programs registered in the CNC.
Reads "Program Number", "Comment", "Date (created and modified)" and Program size" data of which the specified amount of programs are registered programs in the CNC, starting from the program with the specified Program number.
Universal Fanuc Driver
Fanuc Focas Library CD
Declaration
Arguments
Specify the library handle. See "Library handle" for details.
0 | : | "Program number" only |
1 | : | "Program number" and "Comment" |
2 | : | "Program number", "Comment", "Date" 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 PRGDIR3 structure where program directory data are returned.
The PRGDIR3 structure is as follows.
typedef struct prgdir3 {
long number;
long length;
long page;
char comment[52];
struct{
short year;
short month;
short day;
short hour;
short minute;
short dummy;
} mdate;
struct{
short year;
short month;
short day;
short hour;
short minute;
short dummy;
} cdate;
} PRGDIR3;
- number
- Program number
- Program number is returned.
- length
- Program size (number of characters)
- Program size is returned by character unit.
- Valid when 2 is specified for the arguments "type".
- page
- Program size (number of pages)
- (16i/18i-W only)
- Program size is returned by page unit.
- 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 including 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".
- mdate
- Modified date (Invaid for Series 15i)
- Modified date is returned.
- Valid when 2 is specified for the argument "type".
- The meaning of structure is as follows.
year : Year month : Month day : Day hour : Hour (Invaid for 16i/18i-W) minute : Minute (Invaid for 16i/18i-W) - cdate
- Created date (16i/18i-W only)
- Created date is returned.
- Valid when 2 is specified for the arguments "type".
- The meaning of structure is equal to mdate.
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 |
---|---|
(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_rdprogdir2 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()
{
PRGDIR3 prg[BUFSIZE];
short i, num;
long top = 0;
short ret;
do {
num = BUFSIZE;
ret = cnc_rdprogdir3( 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.PRGDIR3_data prg = new Focas1.PRGDIR3_data();
short i, num;
int 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_rdprogdir3(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 = prg.number + 1;
} while (num >= BUFSIZE);
Marshal.FreeCoTaskMem(ptrWork);
}
}