From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write c wrapper it containing callback functions to link with labview

hi here shambhu ,please any body help to write " C wrapper" for  below callback function. Below call can be containing some C functions , please any one to write "C Wrapper"  those dll can be labVIEW.Its for my final year B.E project needed these calls.

 

 

 

int CVICALLBACK RegisterStation (int panel, int control, int event,void *callbackData, int eventData1, int eventData2)
{
int i;
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal(panel, control, &i);
if(i > 0)
{
CCS = &CCS1[0];
GetCtrlVal (panel, PN_MAIN_TXB_SITE_ID, sPortID);
GetCtrlVal (panel, PN_MAIN_NUM_STN_IND, &uStationIndex);
i = GDSRegisterStation(sPortID, "Template", uStationIndex, (GDSCallback) GDSStatusCallback); //how to write GDS callback function in "C Wrapper" for passing                                                                                                                                                                                     - into labVIEW
if(i > -1)
bOnline = TRUE;
}
else
{
if(bOnline)
{
GDSUnregisterStation();
bOnline = FALSE;
}
}
break;
}
return 0;
}

//GDS Install Callbacks
GDSCallback GDSStatusCallback(CTRL_CHANNEL_STATUS *CCS2)//GDS Callback pointing here
{
int i, iError;


//Read Station Status here
if(bFirstGDSStatus)
{
if(GDSFetchNoOfActuators() != 1)
{
if(bOnline)
{
GDSUnregisterStation();
bOnline = FALSE;
}
return 0;
}
CCS = CCS2;
if(CCS->uLogChannels < 6)
{
if(bOnline)
{
GDSUnregisterStation();
bOnline = FALSE;
}
return 0;
}

 

//Function for these calls

 

_export int GDSRegisterStation(char *sPort, char* sPanel, int iStation, GDSCallback lpGDSTaskCall// Create C Wrapper for this call

 

//Structure defintion

 

#ifdef __cplusplus
extern "C" {
#endif
#define LOG_STREAM_ALL 0x0001 // Continuous indefinite streaming
#define LOG_STREAM 0x0002 // Conditional streaming
#define LOG_PKV 0x0004 // Peak/valley

#define LOG_START_NOW 0x0010 // Start immediately
#define LOG_START_TIME 0x0020 // Start at specified calendar time
#define LOG_START_CYC 0x0040 // Start at specified cycle count
#define LOG_START_PULSE 0x0080 // Start on external pulse input
#define LOG_END_POINTS 0x0100 // End upon specified data points
#define LOG_END_MILSECS 0x0200 // End upon specified duration (ms)
#define LOG_END_CYC 0x0400 // End upon specified incremental cycle count
#define LOG_END_PULSE 0x0800 // End on external pulse input


#define LIN_MEASURED 0
#define LIN_REFERENCE 1

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;

Download All
0 Kudos
Message 1 of 3
(2,763 Views)

Sorry, but it's unlikely anyone will be able to help you here without a lot more information (and even then, it's probably more work than anyone would be willing to do as free advice). You've provided some random C code, with no explanation of what it does, and asked for a "C wrapper" - do you actually know what you want, or are you just quoting someone else who said you need a wrapper in C? What does this have to do with LabVIEW?

0 Kudos
Message 2 of 3
(2,726 Views)
0 Kudos
Message 3 of 3
(2,716 Views)