Jump to content

How to read this structure with union from my Call Library Function Node?


Recommended Posts

Trying to call the function below. I would like to read CL_MEASDATA information. Actually just need Evxy.

 

ER_CODE KMAPI CLGetMeasData(DEVICE_HANDLE hDevice, CL_COLORSPACE Type, CL_MEASDATA* pColor); 

typedef union tCL_MEASDATA

{

        CL_EvxyDATA           Evxy;                                       

        CL_EvuvDATA          Evuv;                                       

        CL_EvTduvDATA       EvTduv;                                   

        CL_EvDWPeDATA    EvDWPe;                                 

        CL_XYZDATA            XYZ;                                

        CL_RenderingDATA Rendering;                      

        CL_PWDATA            Pw;                                         

        CL_SPCDATA            Spc;                                 

}

CL_MEASDATA;

 

typedef struct tCL_EvxyDATA
{
float Ev;
float x;
float y;
}
CL_EvxyDATA;


 

typedef struct tCL_EvuvDATA
{
float Ev;
float u;
float v;
}
CL_EvuvDATA;


 

typedef struct tCL_EvTduvDATA
{
float Ev;
float T;
float duv;
}
CL_EvTduvDATA;


 

typedef struct tCL_EvDWPeDATA
{
float Ev;
float DW;
float Pe;
}
CL_EvDWPeDATA;


 

typedef struct tCL_XYZDATA
{
float X;
float Y;
float Z;
}
CL_XYZDATA;


 

typedef struct tCL_RenderingDATA
{
float Data[CL_RENDERING_LEN];
}
CL_RenderingDATA;

 
The RenderingDATAis stored in the array in below order
0 1 2 ・・・ 14 15
Ra R1 R2 ・・・ R14 R15


 

typedef struct tCL_PWDATA
{
float PeakWave;
}
CL_PWDATA;


 

typedef struct tCL_ScotopicDATA
{
float Ev;
float Es;
float SP;
}
CL_ScotopicDATA;


 

Link to comment
2 hours ago, IAN CHUNG said:

Trying to call the function below...

ER_CODE KMAPI CLGetMeasData(DEVICE_HANDLE hDevice, CL_COLORSPACE Type, CL_MEASDATA* pColor);

So here are more details about the other parts of the function: https://stackoverflow.com/questions/38632316/typeloadexception-using-dllimport

  • ER_CODE: I32
  • KMAPI: stdcall
  • DEVICE_HANDLE: Pointer
  • CL_COLORSPACE: Enum (size is not well-defined in C, but it's usually 32-bit)

 

Your CLFN must have Calling Convention = "stdcall (WINAPI)" and have 4 parameters:

 
     
Name Type Data Type/Format
return type        Numeric Signed 32-bit Integer
hDevice Numeric Signed/Unsigned Pointer-sized Integer (pass by Value)
Type Numeric Signed/Unsigned 32-bit Integer (pass by Value)
pColor Adapt to Type        Handles by Value

 

2 hours ago, IAN CHUNG said:

Actually just need Evxy.

...

typedef union tCL_MEASDATA

{

        CL_EvxyDATA           Evxy;                                       

        // ...                           

}

CL_MEASDATA;

 

typedef struct tCL_EvxyDATA
{
float Ev;
float x;
float y;
}
CL_EvxyDATA;

If you only want to read Evxy from the function, you can pretend that the parameter type is CL_EvxyDATA* instead of CL_MEASDATA*. This works because is a CL_MEASDATA union and CL_EvxyDATA is one of the structs it can store.

Make a Type Definition: A Cluster that contains 3 SGL numbers, and use this cluster to to tell the CLFN how to interpret the data.

CLFN_CLGetMeasData.png.635dcd56d0dcc4962404ecaf788d538d.png

Edited by JKSH
Add snippet
Link to comment
1 hour ago, IAN CHUNG said:

But it will show this error or the program crashed.

Oops, sorry... I didn't notice CL_RenderingDATA. This means the union is 64 bytes long.

Try using a cluster of 16 SGLs, and only read the first 3 values.

Or, try changing the parameter configuration:

  • Type: Array
  • Data type: 4-byte Single
  • Dimensions: 1
  • Array format: Array Data Pointer
  • Minimum Size: 16
Link to comment
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.