03-06-2012 07:27 AM
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 😄
03-07-2012 11:13 AM
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.
03-08-2012 02:07 AM
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,
03-08-2012 03:46 AM
This is .c and .h files,the dll hasn't been created yet.I cannot solve it!!!!!!!!!!!!!!!!!!!!!!
03-08-2012 03:49 AM
#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);
}
}
03-08-2012 03:51 AM
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
03-08-2012 09:31 AM - edited 03-08-2012 09:31 AM
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?
03-09-2012 02:07 AM
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,
03-12-2012 11:46 AM
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?
03-15-2012 07:41 AM
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,