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 number of programs are registered programs in the CNC, starting from the program with the specified number(from the first program).
Universal Fanuc Driver
Fanuc Focas Library CD
Declaration
Arguments : HSSB
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" |
Specified the program number from the head to want to acquire program information.(1-)
The program is acquired in ascending order.
Pointer to the number of programs to be read. Actual number of programs being read is stored after this function call.
Pointer to the PRGDIR4 structure where program directory data are returned.
The PRGDIR4 structure is as follows.
PRGDIR4 structure is same as PRGDIR3.
typedef struct prgdir4 {
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;
} PRGDIR4;
- 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
- unused
- 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
- Modified date is returned.
- Valid when 2 is specified for the arguments "type".
- The meaning of structure is as follows.
year : Year month : Month day : Day hour : Hour minute : Minute - cdate
- unused
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_number) 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
For HSSB connection,
The extended driver/library function is necessary.
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 | X |
"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_rdprogdir3
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()
{
PRGDIR4 prg[BUFSIZE];
short i, num;
long top = 0;
short ret;
do {
num = BUFSIZE;
ret = cnc_rdprogdir4( 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.PRGDIR4_data prg = new Focas1.PRGDIR4_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_rdprogdir4(h, 0, 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);
}
}