Jump to content
Excelsior Forums

mustang80

Members
  • Content count

    0
  • Joined

  • Last visited

    Never

Community Reputation

0 Neutral

About mustang80

  • Rank
    Newbie
  • Birthday 01/01/01
  1. Something wrong, but on which side?

    Ok Thx, so: the corect convert is: C/C++ Java DWORD -- int WORD -- short BYTE -- char it is???
  2. Something wrong, but on which side?

    Hi, I use xFunction and everything was ok to now... I have function which was written in C: BOOL GxSetTrigger(GX_LEVELTRIG* ptrig) The struct looks like bellow: typedef struct { ? ? ?DWORD ? ? ? ? ? ?andor; ? ? ?BYTE ? ? ? ? ? ?status[128]; ? ? ?BYTE ? ? ? ? ? ?percent[128]; ? ? ?GX_TRIGGERBIT* ptrbit; } GX_LEVELTRIG; typedef struct { BYTE andor[128]; BYTE diobit[128][16]; } GX_TRIGGERBIT; So I wrote code in Java which should calls this function: GX_LEVELTRIG.class import com.excelsior.xFunction.*; class GX_LEVELTRIG extends Structure { ? ?long andor; ? ? ? ? ? ? //Setting of AND/OR condition ? ?char[] status; ? ? ? ? ?//Setting of ignore/up/down/bit condition ? ?char[] persent; ? ? ? ? //Setting of a trigger level ? ?Pointer ptrbit; ? ? ? ? // Setting of a trigger for each bit ? ? ? ?public String defineLayout() ? ?{ ? ? ? ?return "long andor, char[128] status, char[128] persent, GX_TRIGGERBIT* ptrbit"; ? ?} ? ?public GX_LEVELTRIG() ? ?{ ? ? ? ?status = new char[128]; ? ? ? ?persent = new char[128]; ? ? ? ?try ? ? ? ?{ ? ? ? ? ? ?ptrbit = Pointer.create("GX_TRIGGERBIT*"); ? ? ? ?} ? ? ? ?catch(Exception e) ? ? ? ?{ ? ? ? ? ? ?throw new ExceptionInInitializerError(e); ? ? ? ?} ? ?} } and test.java: public int GxSetTrigger(long l_andor, char[] ch_status, char[] ch_persent) throws xFunctionException ? ?{ ? ? ? ?xFunction gx_set_trigger = new xFunction("Gx02", "int GxSetTrigger(GX_LEVELTRIG*)"); ? ? ? ?Gx_LevelTrig.andor = l_andor; ? ? ? ?for(int i = 0; i < 16; i++) ? ? ? ?{ ? ? ? ? ? ?Gx_LevelTrig.status[i] = ch_status[i]; ? ? ? ? ? ?Gx_LevelTrig.persent[i] = ch_persent[i]; ? ? ? ?} ? ? ? ?int GxSetTrigger_result = ((Integer)gx_set_trigger.invoke(Pointer.createPointerTo(Gx_LevelTrig))).intValue(); ? ? ? ?if (GxSetTrigger_result == 1) ? ? ? ?{ ? ? ? ? ? ?return GxSetTrigger_result; ? ? ? ?} ? ? ? ?else ? ? ? ?{ ? ? ? ? ? ?return GxGetLastError(); ? ? ? ?} ? ?} arguments for this example lokks like following: char[] status = new char[16]; char[] percent = new char[16]; for(int i=0;i<16;i++) { status[i] = 1; percent[i] = 30; } andor = 2; I omit pointer to GX_TRIGGERBIT because I don't need use it. This function should sets my channels from 0 to 15. Also should sets this channels on level 30%(trigerring). But the problem is that this function sets only channels from 4 to 15 and omit 4 channels (always 0,1,2,3). It loses 4 bajts but where??? Another function works fine. dll from I invoke this function is use also by another program wrote in C and everything is ok(trigerring works). Wher could be a problem?
  3. WinApi types and short* as an argument

    Yes it is corect. It is works for me.
  4. WinApi types and short* as an argument

    Hi, Yes I tried myself and I got error, because I didn't know that my function returns an array of short. I changed my code, because now I know that my array should be: short[508]. so, my code looks like bellow: Pointer arg_view = (Pointer)Argument.create("short*", new short[508]); int GetViewData_result = ((Integer)GxGetViewData.invoke(arg_view)).intValue(); short[] result = (short[])arg_view.createArray(508); for(int a=1; a<508; a++) { System.out.println("Result["+a+"]= " + result[a]); } It is corect???
  5. WINAPI types and xFunction ???

    Thx, it works.
  6. Hi, I have the function as below: GXAPI HANDLE WINAPI GxInitReal(GX_REALINFO* pInfo); where: typedef struct { ? ? ?LPCTSTR ? ? ? ? ? ?filename; ? ? ?DWORD ? ? ? ? ? ?limit; ? ? ?DWORD ? ? ? ? ? ?time; ? ? ?BOOL ? ? ? ? ? ?memosave; ? ? ?LPSAVECALLBACK lpfunc; ? ? ?HWND ? ? ? ? ? ?hWnd; ? ? ? } GX_REALINFO; where: #define ? ? ?DWORD ? ? ? ? ? ?unsigned long #define ? ? ?BOOL ? ? ? ? ? ?bool I declared it as following: xFunction GxInitReal = new xFunction("Gx02", "int GxInitReal(GX_REALINFO*)"); and I invoked it as below: Gx_RealInfo.filename = "D:\\dirjava\\GX-1Data\\pomiar_1"; Gx_RealInfo.limit = 0; Gx_RealInfo.time = 1000; Gx_RealInfo.memosave = 0; Gx_RealInfo.lpFunction = null; Gx_RealInfo.hWnd = 0; int InitReal_result = ((Integer)GxInitReal.invoke(Pointer.createPointerTo(Gx_RealInfo))).intValue(); class GX_REALINFO extends Structure { ? ? ?String filename; ? ? ?// Full path file name ? ? ?int limit; ? ? ? ? ? ? ? ? ? ? ? ? ? // Limitation value for the remaining HD space. ? ? ?int time; ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Acquisition interval ? ? ?int memosave; ? ? ? ? ? ? ? ? ? // Whether to save voice memo ? ? ?String lpFunction; // Call back function ? ? ?int hWnd; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Window HANDLE ? ? ?public String defineLayout() ? ? ?{ ? ? ? ? ? ?return "CSTRING filename, int limit, int time, int memosave, CSTRING lpFunction, int hWnd"; ? ? ?} ? ? ?public GX_REALINFO() {} } My question is: ? Is it correct??? I am afraid this part: Gx_RealInfo.filename = "D:\\dirjava\\GX-1Data\\pomiar_1"; Gx_RealInfo.lpFunction = null; because last time I had this function: GXAPI BOOL WINAPI GxSaveData(HANDLE hStandby, LPCTSTR filename, LPSAVECALLBACK pFunc, HWND hWnd); and I built it as following: xFunction GxSaveData = new xFunction("Gx02", "int GxSaveData(int,CSTRING,int*,int)"); Argument arg1_save = new Argument(GetStandby_result); Argument arg2_save = new Argument("D:\\dirjava\\GX-1Data\\pomiar_1", Argument.CSTRING); Argument arg3_save = new Argument("", Argument.CSTRING); arg3_save = Pointer.NULL; Argument arg4_save = new Argument(0); int GxSaveData_result = ((Integer)GxSaveData.invoke(arg1_save, arg2_save, arg3_save, arg4_save)).intValue(); just like You advised me and it works for my. But this time ?I have to declare it like: Gx_RealInfo.filename = "D:\\dirjava\\GX-1Data\\pomiar_1"; Gx_RealInfo.lpFunction = null; so is it correct? I have one more question: I have following function: GXAPI BOOL WINAPI GxGetViewData(short* pData); where: (1) Feature Acquires view data at the current settings. (2) Arguments pData ?...... ?Pointer for storing acquired data. ?Sizes to be secured in advance are as follows: ? ? ? ? ? ?------------------------------------------------------------------------------------ (Waveform) Number of channels * 1000 + 16 bytes ? ? ? ? ? ?(FFT) Number of channels * 512 + 16 bytes ? ? ? ? ? ?(BAR) Number of channels * 4 + 16 bytes ? ? ? ? ? ?------------------------------------------------------------------------------------ so in Java I declared this function like below: xFunction GxGetViewData = new xFunction("Gx02", "int GxGetViewData(short*)"); and I invoked it: Pointer arg_view = Pointer.create("short* ?"); int GetViewData_result = ((Integer)GxGetViewData.invoke(arg_view)).intValue(); Short result = ((Short)arg_view.deref()).shortValue(); It is correct?
  7. WINAPI types and xFunction ???

    Hi, Thank You for quickly replay. I managed with three of four this functions. Unfortunatelly I couldn't manage with this one, which would seems to be easy. So, this functions works for me: GXAPI HANDLE WINAPI GxOpenData(GX_DATAINFO* pInfo); GXAPI HANDLE WINAPI GxGetStandby(HANDLE hFile); GXAPI BOOL WINAPI GxSaveData(HANDLE hStandby, LPCTSTR filename, LPSAVECALLBACK pFunc, HWND hWnd); but this one doesn't works: GXAPI BOOL WINAPI GxGetData(HANDLE hStandby, UINT nCh, short* pData, long nSize); where: hStandby- Handel returned with GxGetStandby nch- The number of channel pData- Pointer to the buffer to store acquired data nSize- Size of data be acquired (by a byte) So, I simple declared this function as follows: xFunction GxGetData = new xFunction("Gx02", "int GxGetData(int,int,short*,long)"); Argument arg1 = new Argument(GetStandby_result); Argument arg2 = new Argument(n_chanel); short[] array3 = new short[512]; Pointer arg3 = (Pointer)Argument.create("short*", array3); Argument arg4 = new Argument(10000000); int GetData_result = ((Integer)GxGetData.invoke(arg1,arg2,arg3,arg4)).intValue(); but I got this error: Exception in thread "main" com.excelsior.xFunction.IncompatibleArgumentTypeException: The argument number '3' is not compatible with the one specified in signature. What could be wrong with this code???
  8. WINAPI types and xFunction ???

    Hi, I am wondering if is possible to use WINAPI types with xFunction??? I have following functions which I have to call form Gx02.dll in Java in following sequence: GXAPI HANDLE WINAPI GxOpenData(GX_DATAINFO* pInfo); GXAPI HANDLE WINAPI GxGetStandby(HANDLE hFile); GXAPI BOOL WINAPI GxGetData(HANDLE hStandby, UINT nCh, short* pData, long nSize); GXAPI BOOL WINAPI GxSaveData(HANDLE hStandby, LPCTSTR filename, LPSAVECALLBACK pFunc, HWND hWnd); where: first function (GxOpenData) returnes: 0 if there is an error 1 if everything is right and GX_DATAINFO is declared: typedef struct { WORD device; WORD id; DWORD startsample; DWORD endsample; BYTE rsv[4]; char name[8]; char dir[8]; } [b]GX_DATAINFO[/b]; second function (GxGetStandby) returnes: handle for standby for downloading and: hFile - handle returned with GxOpenData third function: GxGetData has argument: hStandby- handle returned with GxGetStandby and last function has arguments as below: hStandby- handle returned with GxGetStandby filename- name of a file to be save pFunc- call back function hWnd- window HANDLE passed with GxSaveData function where: // callback function typedef BOOL (CALLBACK SAVECALLBACK)(UINT nSave, UINT nRate, HWND hWnd); typedef SAVECALLBACK FAR* LPSAVECALLBACK; I know how I should declare: - GX_DATAINFO struct in Java - UINT nCh, short* pData, long nSize because it is in examples, but I have not idea how I should declare: 1. returned value, I mean HANDLE in first function: xFunction GxOpenData = new xFunction("Gx02", " GxOpenData(GX_DATAINFO*)"); 2. LPCTSTR filename, LPSAVECALLBACK pFunc, HWND hWnd and: typedef BOOL (CALLBACK SAVECALLBACK)(UINT nSave, UINT nRate, HWND hWnd); typedef SAVECALLBACK FAR* LPSAVECALLBACK; in the last function??? Any help will be appreciate.
  9. Problem with unsigned char

    Thank You soo much. It works for my perfectly:)
  10. Problem with unsigned char

    Thank You for replay. I write program in Java which contorls electrical device (this device can recording vibration signal from 16 channel). I have to call functions from DLL. For examlpe: #define GXAPI extern "C" __declspec(dllimport) GXAPI BOOL WINAPI GxSetEachAmp(UINT nCh, GX_EACHAMP* pAmp); where: // dlldef.h ? typedef struct { BYTE ?range; BYTE ?sample; BYTE ?use; BYTE ?misc1; WORD ?misc2; WORD ?misc3; double ?xpc; } GX_EACHAMP; In specyfication is written that: ? #define BYTE unsigned char ? #define WORD unsigned short ? #define BOOL bool File Gx02.dll (file where are functions to control GX-1 device) was compiled in C or C++ So: in C type: unsigned char ? ?has ? ?8 bits in Java type: ? ? ? ? ? ?char ? ?has ? ?16bits ? ?and ?type: ? ? ? ? ? ?byte ? ?has ? ?8 bits thus I wanted use byte type. How You think, if I use "char" instead of "byte" it is going to works???
  11. Problem with unsigned char

    Hi everyone I write a program which calls Gx02.dll (writeen in C++). There is a function which I try call: GxSetEachAmp(UINT nCh, GX_EACHAMP* pAmp); where: -nCh ... channel number -pAmp ... pointer to the GX_EACHAMP When I try run my program I have an error: Exception in thread "main" com.excelsior.xFunction.IllegalSignatureException: Il legal type to make an Argument: byte at com.excelsior.xFunction.xFunction.parseSignature(xFunction.java:209) at com.excelsior.xFunction.xFunction.<init>(xFunction.java:30) at Start.main(Start.java:7) This function is declared in defdll.h: #define GXAPI extern "C" __declspec(dllimport) GXAPI BOOL WINAPI GxSetEachAmp(UINT nCh, GX_EACHAMP* pAmp); where: typedef struct { BYTE range; BYTE sample; BYTE use; BYTE misc1; WORD misc2; WORD misc3; double xpc; } GX_EACHAMP; and: #define BYTE unsigned char #define WORD unsigned short #define BOOL bool My program looks like below: Start.java: import com.excelsior.xFunction.*; public class Start { public static void main(String[] args) throws xFunctionException { xFunction GxSetEachAmp = new xFunction("Gx02", "int GxSetEachAmp(int,GX_EACHAMP*)"); GX_EACHAMP Gx_EachAmp = new GX_EACHAMP(); //GxSetEachAmp Gx_EachAmp.range = 0; Gx_EachAmp.sample = 6; Gx_EachAmp.use = 0; Gx_EachAmp.misc1 = 8; Gx_EachAmp.misc2 = 3; Gx_EachAmp.misc3 = 0; Gx_EachAmp.xpc = 2.1; int Gx_SetEachAmp_result = ((Integer)GxSetEachAmp.invoke(new Argument(0),Pointer.createPointerTo(Gx_EachAmp))).intValue(); } } and GX_EACHAMP.java: import com.excelsior.xFunction.*; class GX_EACHAMP extends Structure { byte range; // Range information byte sample; // Sampling frequency information byte use; // Channel ON/OFF information short misc1; // Other information 1 short misc2; // Other information 2 short misc3; // Other information 3 double xpc; // Coefficient information (write only) public String defineLayout() { return "byte range, byte sample, byte use, short misc1, short misc2, short misc3, double xpc"; } public GX_EACHAMP() {} } Who could help me, and tell me why I have this error??? Any help will by apprieciate I use WindowsXP and j2sdk1.4.2_04
  12. Problem with boolean GxInitialize() method

    Hi, I know how it should be done: public class Gx02Tester { public static void main(String[] args) throws xFunctionException { xFunction init = new xFunction("Gx02","int GxInitialize()"); xFunction fan = new xFunction("Gx02","int GxFan(int)"); init.invoke(); fan.invoke(new Argument(0)); } } In Gx02.dll this methods are declared: bool GxInitialize(); bool GxFan(bool fanOn); but it works for me.
  13. Hi, I have a problem with my method the type of this method is ?boolean GxInitialize() my java code looks that: import com.excelsior.xFunction.*; public class Gx02Tester { ? ? ?public static void main(String[] args) throws xFunctionException ? ? ?{ ? ? ? ? ? ?xFunction b = new xFunction("Gx02","int GxInitialize()"); ? ? ?} } but I dont know how I should ?call this method. This method returns false or true Any help will be appreciate
×