LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use postlv user event in labview

Hi sir 

 I am sending data labwindow cvi dll call to labview,for that we need postlv user event.please any one knows to use postlv user evenet in labview.

Below will  be the  structureand i need to update in labview .

 

 


typedef struct
{
unsigned
uDSPIO,
// uDAQMode,
// bControllerActive,
bShutDown,

bPowerOn,
bPowerHi,
bPowerFault,

bSGIdle,
bSGHold,

uBitsIn,
uBitsOut,

uCycleCount,
uCycResidue,
uBlockCount,
uLogChannels,
uCurrentMode,
uAsigndPhysCh[LOG_CHANNELS];

float
fSetPoint,
fDAQRate,
fRange[LOG_CHANNELS],
fReadout[LOG_CHANNELS],
fMax[LOG_CHANNELS],
fMin[LOG_CHANNELS];
char
sChID[LOG_CHANNELS][32],
sChUnits[LOG_CHANNELS][16];
}
CTRL_CHANNEL_STATUS;

0 Kudos
Message 1 of 2
(2,813 Views)

AThe fixed size arrays in your structure are inlined byt the C compiler. This means they are not an array pointer (and definitely never a LabVIEW array handle) but rather LOG_CHANNELS amount of unsigned ints and floats directly embedded in the structure. In LabVIEW terms this is most easily represented as a cluster with LOG_CHANNELS elements inside the main cluster.

 

So basically your uAsigndPhysCh needs to be a cluster with LOG_CHANNELS elements of unsigned ints and  fRange,  fReadout, fMax and fin are clusters with LOG_CHANNELS single precision float values, and then sChID is a cluster with 32 * LOG_CHANNELS chars and sChUnits one with 16 * LOG_CHANNELS chars.

 

However I would personally rethink this strategy. This huge cluster monster is passed into PostLVUserEvent() each time and copied into the event data on every event, causing quite a bit of overhead that way. Is it really necessary to post all this data every time?

 

Also you have commented out uDAQMode and bControllerActive in your C structure but included it in the LabVIEW cluster which will certainly throw off your data. Last but not least the b prefix would probably indicate that you are only using that element as a boolean value, so why not consider to use bit fields there? In LabVIEW you can easily seperate those bitfields by either translating the resulting uInt32 into a boolean array or even more efficiently use boolean logic to detect the bits.

 

And in order to let LabVIEW react on a user event you have to create that user event with the correct datatype (your cluster monster) and then pass the user event refnum to your DLL. This DLL then calls PostLVUserEvent() with the user event refnum as first parameter and a pointer to a data structure that matches the LabVIEW user event datatype EXACTLY whenever it wants to post an event to LabVIEW. The user event is also registered in an event structure in LabVIEW which will then get triggered everytime your DLL posts an event by correctly calling PostLVUserEvent().

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 2
(2,796 Views)