typedefstructodbst { short hdck ; /* handl retrace status */ short tmmode ; /* T/M mode */ short aut ; /* selected automatic mode */ short run ; /* running status */ short motion ; /* axis, dwell status */ short mstb ; /* m, s, t, b status */ short emergency ; /* emergency stop status */ short alarm ; /* alarm status */ short edit ; /* editting status */ } ODBST ;
对应aardio表定义和传参写法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
//设备状态结构体定义 ptODBST = { word hdck ; /* handl retrace status */ word tmmode ; /* T/M mode */ word aut ; /* selected automatic mode */ word run ; /* running status */ word motion ; /* axis, dwell status */ word mstb ; /* m, s, t, b status */ word emergency ; /* emergency stop status */ word alarm ; /* alarm status */ word edit ; /* editting status */ }
ptODBST=cStruct.ptODBST var ret,ptODBST=dll.getCNCStatus(pthndl.x,ptODBST) mainForm.static16.text=enumPack.ODBSTrun[ptODBST.run]; console.log("getCNCStatus:",ret)
typedefstructodbexeprg { char name[36]; /* running program name */ long o_num; /* running program number */ } ODBEXEPRG; /* */
对应aardio表定义和传参写法
1 2 3 4 5 6 7 8 9
var ptODBEXEPRG= { byte name[36] ; /* running program name */ long64 o_num; /* running program number */ }
var ret,ptODBEXEPRG=dll.getExePrgname(pthndl.x,ptODBEXEPRG) console.log("getExePrgname:",ret) mainForm.static17.text=ptODBEXEPRG.name;
结构体嵌套和结构体数组传参
C函数和结构体定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14
typedefstructiodbpsd { short datano ; /* data number */ short type ; /* axis number */ union { char cdata ; /* parameter / setting data */ short idata ; long ldata ; REALPRM rdata ; char cdatas[MAX_AXIS] ; short idatas[MAX_AXIS] ; long ldatas[MAX_AXIS] ; REALPRM rdatas[MAX_AXIS] ; } u ; } IODBPSD ;
ptiodbpsd ={ word datano ; /* data number */ word typePra ; /* axis number */ union u= { byte cdata ; /* parameter / setting data */ word idata ; int ldata ; rdata={ int prm_val; int dec_val ;} byte cdatas[]={length = MAX_AXIS;} ; word idatas[]={length = MAX_AXIS;} ; int ldatas[]={length = MAX_AXIS;} ; struct rdatas[] ={length = MAX_AXIS; {int prm_val; int dec_val ;}}; } ; } ;
cStruct.MAX_AXIS=3 ptiodbpsd=cStruct.ptiodbpsd var ret,ptiodbpsd=dll.getParam(pthndl.x,6712,0, (4+4*3), ptiodbpsd ) mainForm.static18.text=ptiodbpsd.u.ldata;