LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

c++ struct into LABVIEW

Hello, I'm quite new with LABVIEW, and have a question. I'm trying to translate the following C++ code into LABVIEW, but have no idea how it works. The libraryfunction is read into a CALL LIBRARY FUNTION NODE
 
The idea is that with the pointer from the AVS_GetParameter the data from the structs is loaded..
 
Please help
 
 
Koert 
 
typedef struct
{
    float           aFit[NR_FIT_COEF];
    float           Gain;               //
    float           Offset;             //
    unsigned short  StartPixel;
    unsigned short  StopPixel;
} ChannelParmType;
typedef struct
{
    char            Version[VERSION_LEN];   //Type device, version, date
    unsigned short  DeviceId;               // Device identification number
} DeviceInfoType;
typedef struct
{
    unsigned char   NrChannels;         // number of channels
    unsigned short  NrPixels;           // number of pixels
    unsigned char   Sensor;             // Sensortype
} DeviceConfigType;
typedef struct
{
    DeviceInfoType      DeviceInfo;
    DeviceConfigType    DeviceConfig;
    ChannelParmType     Channel[MAX_NR_CHANNELS];
} DeviceParmType;                       // Total size xxxx bytes
 
//----------------------------------------------------------------------------
//
// Name         : AVS_GetParameter
//
// Description  : Returns the device parameter structure
//
// Parameters   : -
//
// Returns      : integer         : 0, info available
//                                  error code on error
//                a_pDeviceParm   : pointer to structure for device information
//
// Remark(s)    : -
//
//----------------------------------------------------------------------------
// JR - 10-7-2002 remove ifdef avaspec
#ifndef AVASPEC
DLL_API int __stdcall AVS_GetParameter
(
    DeviceParmType* a_pDeviceParm
);
#endif
 
 
0 Kudos
Message 1 of 2
(3,043 Views)
Due to the amount of pointer indirection, you are going to be better off creating a wrapper library. The reason is that LabVIEW's data structures and C++ don't match and so you won't be able to walk the pointer trees in this structure.
 
Also, the signature of the AVS_GetParameter function indicates that it expects you to pass in a pre-allocated structure - something you can't do easily from LabVIEW.
 
If this is on Windows, I would recommend using VisualStudio .NET 2003 and managed C++ to create the wrapper library - integrating .NET APIs with LabVIEW (using at least LV 7.0) is very straightforward. If you don't want to do that, or are on platform other than Windows, you'll need to use C/C++ to create a helper library that exposes simple C APIs that do the pointer work for you.
 
It is hard to explain more in a general context, but if you post back some examples of how you need to use the structure, we can give you some tips on the helper API you would want to create.
0 Kudos
Message 2 of 2
(3,030 Views)