0% found this document useful (0 votes)
57 views3 pages

CNC - Rdmacror: Public Static Extern Short Ushort Short Short Short

This document discusses and provides code examples for the cnc_rdmacror function in CNC controller API. cnc_rdmacror reads custom macro variables within a specified range on the CNC. It takes a library handle, start number, end number, length, and macro data structure as parameters. It returns return codes to indicate success or errors like invalid length or number ranges. The code demonstrates calling cnc_rdmacror to read macro variables 100 to 104 into a IODBMR data structure.

Uploaded by

Kession Hou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views3 pages

CNC - Rdmacror: Public Static Extern Short Ushort Short Short Short

This document discusses and provides code examples for the cnc_rdmacror function in CNC controller API. cnc_rdmacror reads custom macro variables within a specified range on the CNC. It takes a library handle, start number, end number, length, and macro data structure as parameters. It returns return codes to indicate success or errors like invalid length or number ranges. The code demonstrates calling cnc_rdmacror to read macro variables 100 to 104 into a IODBMR data structure.

Uploaded by

Kession Hou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

cnc_rdmacror

声明
/* read custom macro variables(area specified) */
[DllImport("FWLIB32.dll", EntryPoint = "cnc_rdmacror")]
public static extern short cnc_rdmacror(ushort FlibHndl, short a,
short b, short c, [Out, MarshalAs(UnmanagedType.LPStruct)] IODBMR d);

描述
读指定范围用户宏变量。(最多读 5 个用户宏变量)

参数
(1)FlibHndl 库句柄;[ in ]
(2)s_number [ in ]  
(3)e_number [ in ]
(4)length [ out ]
(5)macror [ out ]
/* cnc_rdmacror:read custom macro variables(area specified) */
/* cnc_wrmacror:write custom macro variables(area specified)
*/
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public class IODBMR_data
{
public int mcr_val; /* macro variable */
public short dec_val; /* decimal point */
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public class IODBMR1
{
public IODBMR_data data1 = new IODBMR_data();
public IODBMR_data data2 = new IODBMR_data();
public IODBMR_data data3 = new IODBMR_data();
public IODBMR_data data4 = new IODBMR_data();
public IODBMR_data data5 = new IODBMR_data();
} /* In case that the number of data is 5 */
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public class IODBMR
{
public short datano_s; /* start macro number */
public short dummy; /* dummy */
public short datano_e; /* end macro number */
public IODBMR1 data = new IODBMR1();
}

函数返回值
函数运行正常返回 EW_OK。
Return code Meaning/Error handling

EW_LENGTH Data block length error


(2) Size of IODBMR structure(length) is wrong.

EW_NUMBER Data number error


(3) Custom macro variable number(s_number, e_number) is wrong.

EW_NOOPT No option
(6) This function needs the custom macro option.

代码
NC 侧实际情况:

调试结果:
class Program
{
static void Main(string[] args)
{
ushort Flibhndl = 0;

short ret; // 返回值

// 获取库句柄 ( Ethernet )
ret = Focas1.cnc_allclibhndl3("192.168.0.224", 8193, 10, out
Flibhndl);
if (ret != Focas1.EW_OK)
{
Console.WriteLine("发生异常,请检查!");
return;
}

#region cnc_rdmacror

short s_number = 100;


short e_number = 104;
short length = 100;
Focas1.IODBMR macror = new Focas1.IODBMR();
ret = Focas1.cnc_rdmacror(Flibhndl, s_number, e_number, length,
macror);
#endregion
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy