Description
Reads the P code macro variables(variable for the macro-executor) specified by "s_number", "e_number". The data is stored in "IODBPR" with signed binary format.
It is possible to exchange the type of P code macro variable by cnc_setpmactype function. In case of the integer type variable, this indication is invalid and always regarded as the decimal form floating-point type.
- decimal form floating-point type (data format=M*10**(-E))
- binary form floating-point type (data format=M*2**(-E))
mcr_val | : | value of variable (=M) 4-byte binary data with sign (available range:999999999,..,-999999999, integer type:-32768,..,32767) |
dec_val | : | number of places of decimals (=E) 2-byte binary data with sign (available range:-128,..,127, integer type : 0) |
mcr_val always returns by nine digits and adjusts the amount with the value of dec_val.
Example: When the variable value is 12.345, mcr_val and dec_val are read as follows.
mcr_val = 123450000
dec_val = 7
mcr_val | : | numerical part of variable (=M) 4-byte binary data with sign (available range:No limitation) |
dec_val | : | exponent part of variable (=E) 2-byte binary data with sign (available range:-128,..,127) |
The value of an undefined variable is called "vacant", and it is expressed as follows both at decimal form floating-point type and at binary form floating-point type.
mcr_val = 0
dec_val = -1
See the "PROGRAMING MANUAL" of the macro-executor for details of the P code macro variable.
Universal Fanuc Driver
Fanuc Focas Library CD
Declaration
Arguments
Specify the library handle. See "Library handle" for details.
Specify the start P code macro variable number. See the description of cnc_rdpmacroinfo function about the available range.
Specify the end P code macro variable number.
Specify the data block length (size of IODBPR structure).
12+8*(Number of P code macro variable)
IODBPR
N : Number of P code macro variable
Pointer to the IODBPR structure including the P code macro variable. The IODBPR structure is as follows.
typedef struct iodbpr {
long datano_s; /* start P code macro variable number*/
short dummy; /* (not used) */
long datano_e; /* end P code macro variable number */
struct {
long mcr_val; /* value of P code macro */
short dec_val; /* number of places of decimals */
} data[N]; /* N:Number of P code macro variable */
} IODBPR;
- datano_s
- The P code macro variable number which was read first is returned.
- datano_e
- The P code macro variable number which was read last is returned.
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) |
Size of IODBPR structure(length) is wrong. |
(3) |
P code macro variable number(s_number, e_number) is wrong. |
(6) |
This function needs the macro-executor option. |
(17) |
( Series 16i/18i/21i, 0i-A/B/C ) |
As for the other return codes or the details, see "Return status of Data window function"
CNC option
This function need the following CNC option.
And this function is related to the following CNC option.
- Series 16/18, 16i/18i This function is related to the high-speed cycle cutting 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 not related to CNC parameter.
But, this function is related to the compile parameter of the macro-executor. See the "PROGRAMING MANUAL" of the macro-executor for details of the compile 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_rdpmacro cnc_wrpmacro cnc_wrpmacror cnc_rdpmacror2 cnc_wrpmacror2 cnc_rdpmacroinfo cnc_getpmactype cnc_setpmactype
Example(C Language)
The following program reads the P code macro variables within the specified
range and displays them.
#include "fwlib32.h"
/* start/end are start/end variable number to be read. */
short example( long start, long end )
{
IODBPR *pmacror ;
char strbuf[12] ;
short ret ;
long idx ;
pmacror = (IODBPR *)malloc( 1000 ) ;
ret = cnc_rdpmacror( h, start, end, 1000, pmacror ) ;
if ( !ret )
for ( idx = 0 ; idx <= end-start ; idx++ ) {
sprintf( &strbuf[0], " %09ld",
abs(pmacror->data[idx].mcr_val) );
strncpy( &strbuf[1], &strbuf[2],
10 - pmacror->data[idx].dec_val ) ;
strbuf[10-pmacror->data[idx].dec_val] = '.' ;
if(pmacror->data[idx].dec_val <= 0)
strbuf[strlen(strbuf)-1] = '\0';
if(pmacror->data[idx].mcr_val < 0) strbuf[0] = '-';
printf( "#%04ld %s\n", start+idx, strbuf ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( pmacror ) ;
return ( ret ) ;
}
Example(C#)
The following program reads the P code macro variables within the specified
range and displays them.
class example
{
/* start/end are start/end variable number to be read. */
public short sample(int start, int end)
{
Focas1.IODBPR_data pmcrData = new Focas1.IODBPR_data();
string strVal;
short ret;
int idx;
byte[] bytes = new byte[1000];
IntPtr ptrData = Marshal.AllocCoTaskMem(Marshal.SizeOf(pmcrData));
ret = Focas1.cnc_rdpmacror(h, start, end, 1000, bytes);
if (ret == Focas1.EW_OK)
{
for (idx = 0; idx <= end - start; idx++)
{
int pos = 12 + idx * Marshal.SizeOf(pmcrData);
Marshal.Copy(bytes, pos, ptrData, Marshal.SizeOf(pmcrData));
Marshal.PtrToStructure(ptrData, pmcrData);
strVal = string.Format("{0:d9}", Math.Abs(pmcrData.mcr_val));
if (0 < pmcrData.dec_val) strVal = strVal.Insert(9 - pmcrData.dec_val, ".");
if (pmcrData.mcr_val < 0) strVal = "-" + strVal;
Console.WriteLine("#{0:d4} {1}", start + idx, strVal);
}
}
else
{
Console.WriteLine("ERROR!({0})", ret);
}
Marshal.FreeCoTaskMem(ptrData);
return (ret);
}
}