3 messages in net.java.dev.jna.users[jna-users] union containing struct a...
FromSent OnAttachments
Schneider JannMay 19, 2009 1:00 am 
Timothy WallMay 19, 2009 7:31 am 
Schneider JannMay 20, 2009 3:18 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[jna-users] union containing struct and other way round Actions...
From:Schneider Jann (j.sc@ssi-schaefer-noell.com)
Date:May 19, 2009 1:00:58 am
List:net.java.dev.jna.users

Hi,

I am currently working with a 3rd party lib and mapped almost everything i need in java now. But there is some code i don't know how to map. This code defines an union containing a struct and afterwards a struct using this union:

#pragma pack(4) // dunno exactly what this does, but might be important ?? union AXST { int status_word; struct { /* axst: Error- & Status-Bits */ unsigned toasm : 1; /* Bit 0: MCU-6000, APCI-8401 only, MCU-3000 / APCI-8001 = 0 */ unsigned eo : 1; /* Bit 1: Emergency out */ unsigned dnr : 1; /* Bit 2: Drive not ready */ unsigned lslh : 1; /* Bit 3: Limit switch left hardware */ unsigned lsrh : 1; /* Bit 4: Limit switch right hardware */ unsigned lsls : 1; /* Bit 5: Limit switch left software */ unsigned lsrs : 1; /* Bit 6: Limit switch right software */ unsigned mpe : 1; /* Bit 7: Maximum Position Error */ unsigned dhef : 1; /* Bit 8: data handling error flag */ unsigned cef : 1; /* Bit 9: configuration error flag */ unsigned nc : 2; /* Bit 10..11: currently not used */

/* Status-Bits */ unsigned pe : 1; /* Bit 12: Profile end */ unsigned cl : 1; /* Bit 13: Closed loop */ unsigned ip : 1; /* Bit 14: In Position */ unsigned ui : 1; /* Bit 15: user input */ unsigned lpsf : 1; /* Bit 16: latched position synchronous flag */ unsigned ref : 1; /* Bit 17: Axis is referenced (per SHP) */ unsigned temp2 : 12; /* Bit 18..29: currently not used */

unsigned : 2; /* Bit 30..31: for internal use only */ } bit; };

struct TSRP { /* Common-Data for DLL-interface-driver MCUG3.DLL and PC-Application-Program(s) */ int an; /* Axis-Number */ double kp; /* PIDF filter parameter kp */ double ki; /* PIDF filter parameter ki */ double kd; /* PIDF filter parameter kd */ double kpl; /* PIDF filter parameter kpl */ double kfca; /* PIDF forward compensation acceleration */ double kfcv; /* PIDF forward compensation velocity */ double jac; /* jog acceleration */ double jvl; /* jog velocity */ double jtvl; /* target velocity */ double jovr; /* jog override */ double hac; /* home acceleration */ double hvl; /* home velocity */ double rp; /* real position */ double dp; /* desired position */ double tp; /* target position */ double dv; /* desired velocity */ double lp; /* latched postion */ double aux; /* auxilary value */ double sll; /* software limit left */ double slr; /* software limit right */ double ipw; /* in position window */ double mpe; /* maximum position error */ double sdec; /* stop deceleration */ double gf; /* gear factor */ int mcp; /* motor command port */ union AXST axst; /* axis status */ int lsm; /* left spool memory */

int epc; /* eeprom programming cycle */ int digi; /* dig. inputs = asmi (MCU-6000, APCI-8401) */ int digo; /* dig outputs = asmo (MCU-6000, APCI-8401)*/ int ifs; /* interface status = asms (MCU-6000, APCI-8401) */

int scratch[4]; /* reserved space don't delete!! */ };

Could i map it like this:

public class Bit extends Structure { ... dunno how to map these bits here }

public class Axst extends Structure { public int statusWord; public Bit bit; }

public class Tsrp extends Structure { public double ... all these double fields here public Axst axst; public int .. fields here }

Could you please help me to get this mapped?

thanks in advance!

Regards Jann