LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a dll

Hi,i created a CVI and I need the .dll file in order to use it in Test Stand.Can you tell me how creating this dll please.

I don't have Labwindows /CVI Core 2 😄

0 Kudos
Message 1 of 10
(3,786 Views)

Hi,

 

To create a DLL in CVI, follow the directions in this Developer Zone article. You should be able to use it in TestStand. Also, there is a manual called "Using LabVIEW and LabWindows/CVI with TestStand" that you might find helpful.

Rohama K.
0 Kudos
Message 2 of 10
(3,766 Views)

Hi,thanks for your help but i still have a problem.I followed the steps to create my dll but it seems there is a problem in the .h file,in other words i create my .dll for example using the PFE.h file is shows me an error that RohamaK.h is is not found and i should search it!!!!!!!!!!!!!!!!!!!!!!!!

Regards,

0 Kudos
Message 3 of 10
(3,756 Views)

This is .c and .h files,the dll hasn't been created yet.I cannot solve it!!!!!!!!!!!!!!!!!!!!!!

0 Kudos
Message 4 of 10
(3,747 Views)

#include "tsutil.h"


#include <cvirte.h>
#include <userint.h>
#include <NIDAQmx.h>
#include <DAQmxIOctrl.h>
#include "WriteDigChan.h"

#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else

static int panelHandle;

int main(int argc, char *argv[])
{
if( InitCVIRTE(0,argv,0)==0 )
return -1; /* out of memory */
if( (panelHandle=LoadPanel(0,"WriteDigChan.uir",PANEL))<0 )
return -1;
SetCtrlAttribute(panelHandle,PANEL_DECORATION_BLUE,ATTR_FRAME_COLOR,VAL_BLUE);
NIDAQmx_NewPhysChanDOLineCtrl(panelHandle,PANEL_CHANNEL,1);
DisplayPanel(panelHandle);
RunUserInterface();
DiscardPanel(panelHandle);
return 0;
}

int CVICALLBACK PanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2)
{
if( event==EVENT_CLOSE )
QuitUserInterface(0);
return 0;
}

int CVICALLBACK WriteCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
int error=0;
TaskHandle taskHandle=0;
char chan[256];
uInt8 data[8];
char errBuff[2048]={'\0'};

if( event==EVENT_COMMIT ) {
GetCtrlVal(panel,PANEL_CHANNEL,chan);
GetCtrlVal(panel,PANEL_BINARYSWITCH_0,&data[0]);
GetCtrlVal(panel,PANEL_BINARYSWITCH_1,&data[1]);
GetCtrlVal(panel,PANEL_BINARYSWITCH_2,&data[2]);
GetCtrlVal(panel,PANEL_BINARYSWITCH_3,&data[3]);
GetCtrlVal(panel,PANEL_BINARYSWITCH_4,&data[4]);
GetCtrlVal(panel,PANEL_BINARYSWITCH_5,&data[5]);
GetCtrlVal(panel,PANEL_BINARYSWITCH_6,&data[6]);
GetCtrlVal(panel,PANEL_BINARYSWITCH_7,&data[7]);

/*********************************************/
// DAQmx Configure Code
/*********************************************/
SetWaitCursor(1);
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines));

/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));

/*********************************************/
// DAQmx Write Code
/*********************************************/
DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));

}

Error:
SetWaitCursor(0);
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
MessagePopup("DAQmx Error",errBuff);
return 0;
}

void __declspec(dllexport) __stdcall WriteDigChan(CAObjHandle seqContextCVI,
char reportText[1024], short *errorOccurred, long *errorCode, char errorMsg[1024])
{
int error = 0;
// The tsErrChk macro expects the following two variables to exist. This macro is like the CVI toolbox.h macro errChk except that it also retrieves the error message from an ActiveX function and places it in errMsg.
ErrMsg errMsg = {'\0'};
ERRORINFO errorInfo;
char *lastUserName = NULL;

// INSERT YOUR SPECIFIC TEST CODE HERE

// The following code shows how to access a property or variable via the TestStand ActiveX API
//tsErrChk (TS_PropertyGetValString(seqContextCVI, &errorInfo,
// "StationGlobals.TS.LastUserName",
//0, &lastUserName));

Error:
// FREE RESOURCES
if (lastUserName != NULL)
CA_FreeMemory(lastUserName);

// If an error occurred, set the error flag to cause a run-time error in TestStand.
if (error < 0)
{
*errorOccurred = TRUE;

// OPTIONALLY SET THE ERROR CODE AND STRING
*errorCode = error;
strcpy(errorMsg, errMsg);
}
}

0 Kudos
Message 5 of 10
(3,745 Views)

this one is the .h

 

 

#include <userint.h>
#include "tsapicvi.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Panels and Controls: */

#define PANEL 1 /* callback function: PanelCallback */
#define PANEL_CHANNEL 2
#define PANEL_BINARYSWITCH_0 3
#define PANEL_BINARYSWITCH_1 4
#define PANEL_BINARYSWITCH_2 5
#define PANEL_BINARYSWITCH_3 6
#define PANEL_BINARYSWITCH_4 7
#define PANEL_BINARYSWITCH_5 8
#define PANEL_BINARYSWITCH_6 9
#define PANEL_BINARYSWITCH_7 10
#define PANEL_TEXTMSG 11
#define PANEL_COMMANDBUTTON 12 /* callback function: WriteCallback */
#define PANEL_TEXTMSG_2 13
#define PANEL_DECORATION_BLUE 14


/* Menu Bars, Menus, and Menu Items: */

/* (no menu bars in the resource file) */


/* Callback Prototypes: */

int CVICALLBACK PanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK WriteCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);


#ifdef __cplusplus
}
#endif

0 Kudos
Message 6 of 10
(3,744 Views)

Did you write this code or are you running an example? What version of CVI are you using? Also, are you getting errors when trying to create a DLL?

Rohama K.
0 Kudos
Message 7 of 10
(3,728 Views)

Hi,

I copied this code from find examples to another project and i added tsapi.fp file to this project.I succeded in creating my dll ,however,when i tried to call it from Test Stand it shows me an error that the cvi could not be run.I use Labwindows CVI 9 and Test Stand 2010.

Regards,

0 Kudos
Message 8 of 10
(3,717 Views)

Hi,

 

Could you attach your CVI project and your DLL in a zip file? Also, what example are you using? Have you taken a look at the Using LabWindows/CVI with TestStand manual?

Rohama K.
0 Kudos
Message 9 of 10
(3,686 Views)

Hi Rohama K,

I am traying to solve it and i may find the right solution.I'll tell you if there is any news.Thanks.

Regards, 

0 Kudos
Message 10 of 10
(3,664 Views)