VCI开发的DLL,现在要把代码移植到VC平台下开发成DLL,有没有人懂啊解决方案
VCI开发的DLL,现在要把代码移植到VC平台下开发成DLL,有没有人懂啊
本来是VCI开发的DLL,现在要把代码移植到VC平台下开发成DLL,有没有人了解的提供些帮助啊,我看CVI里好多东西要在用C++重写,还有变量的转换,比如ViSession在VC下应该是什么变量啊??我看了两天的cvi程度真的头大,求高手指点迷津。。比如下面一个函数怎么转过来
/*****************************************************************************
* Function: Test65_IviInit
* Purpose: This function is called by Test65_InitWithOptions
* or by an IVI class driver. This function initializes the I/O
* interface, optionally resets the device, optionally performs an
* ID query, and sends a default setup to the instrument.
*****************************************************************************/
//Test65开头的都是自定义函数
static ViStatus Test65_IviInit (ViRsrc resourceName, ViBoolean IDQuery,
ViBoolean reset, ViSession vi)
{
ViStatus error = VI_SUCCESS;
ViSession io = VI_NULL;
checkErr( Ivi_BuildChannelTable (vi, CHANNEL_LIST, VI_FALSE, VI_NULL));
/* Add attributes */
checkErr( Test65_InitAttributes (vi));
if (!Ivi_Simulating(vi))
{
ViSession rmSession = VI_NULL;
/* Open instrument session */
checkErr( Ivi_GetAttributeViSession (vi, VI_NULL, IVI_ATTR_VISA_RM_SESSION, 0,
&rmSession));
viCheckErr( viOpen (rmSession, resourceName, VI_NULL, VI_NULL, &io));
/* io session owned by driver now */
checkErr( Ivi_SetAttributeViSession (vi, VI_NULL, IVI_ATTR_IO_SESSION, 0, io));
/* Configure VISA Formatted I/O */
viCheckErr( viSetAttribute (io, VI_ATTR_TMO_VALUE, 5000 ));
viCheckErr( viSetBuf (io, VI_READ_BUF | VI_WRITE_BUF, 4000));
viCheckErr( viSetAttribute (io, VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS));
viCheckErr( viSetAttribute (io, VI_ATTR_RD_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS));
//viCheckErr(Test_SysRemMode(vi));
}
/*- Reset instrument ----------------------------------------------------*/
if (reset)
checkErr( Test65_reset (vi));
else /*- Send Default Instrument Setup ---------------------------------*/
checkErr( Test65_DefaultInstrSetup (vi));
/*- Identification Query ------------------------------------------------*/
if (IDQuery)
{
ViChar rdBuffer[BUFFER_SIZE];
#define VALID_RESPONSE_STRING_START "ITECH Ltd., IT6512, 0123456789AF, 1.00-1.00"
checkErr( Ivi_GetAttributeViString (vi, VI_NULL, ITE6512_ATTR_ID_QUERY_RESPONSE,
0, BUFFER_SIZE, rdBuffer));
if (strncmp (rdBuffer, VALID_RESPONSE_STRING_START,
strlen(VALID_RESPONSE_STRING_START)) != 0)
{
viCheckErr( VI_ERROR_FAIL_ID_QUERY);
}
}
checkErr( Test65_CheckStatus (vi));
Error:
if (error < VI_SUCCESS)
{
if (!Ivi_Simulating (vi) && io)
viClose (io);
}
return error;
}
------解决方案--------------------
如果能包含那些VCI定义的头文件,那就应该不用重写那些东西了
本来是VCI开发的DLL,现在要把代码移植到VC平台下开发成DLL,有没有人了解的提供些帮助啊,我看CVI里好多东西要在用C++重写,还有变量的转换,比如ViSession在VC下应该是什么变量啊??我看了两天的cvi程度真的头大,求高手指点迷津。。比如下面一个函数怎么转过来
/*****************************************************************************
* Function: Test65_IviInit
* Purpose: This function is called by Test65_InitWithOptions
* or by an IVI class driver. This function initializes the I/O
* interface, optionally resets the device, optionally performs an
* ID query, and sends a default setup to the instrument.
*****************************************************************************/
//Test65开头的都是自定义函数
static ViStatus Test65_IviInit (ViRsrc resourceName, ViBoolean IDQuery,
ViBoolean reset, ViSession vi)
{
ViStatus error = VI_SUCCESS;
ViSession io = VI_NULL;
checkErr( Ivi_BuildChannelTable (vi, CHANNEL_LIST, VI_FALSE, VI_NULL));
/* Add attributes */
checkErr( Test65_InitAttributes (vi));
if (!Ivi_Simulating(vi))
{
ViSession rmSession = VI_NULL;
/* Open instrument session */
checkErr( Ivi_GetAttributeViSession (vi, VI_NULL, IVI_ATTR_VISA_RM_SESSION, 0,
&rmSession));
viCheckErr( viOpen (rmSession, resourceName, VI_NULL, VI_NULL, &io));
/* io session owned by driver now */
checkErr( Ivi_SetAttributeViSession (vi, VI_NULL, IVI_ATTR_IO_SESSION, 0, io));
/* Configure VISA Formatted I/O */
viCheckErr( viSetAttribute (io, VI_ATTR_TMO_VALUE, 5000 ));
viCheckErr( viSetBuf (io, VI_READ_BUF | VI_WRITE_BUF, 4000));
viCheckErr( viSetAttribute (io, VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS));
viCheckErr( viSetAttribute (io, VI_ATTR_RD_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS));
//viCheckErr(Test_SysRemMode(vi));
}
/*- Reset instrument ----------------------------------------------------*/
if (reset)
checkErr( Test65_reset (vi));
else /*- Send Default Instrument Setup ---------------------------------*/
checkErr( Test65_DefaultInstrSetup (vi));
/*- Identification Query ------------------------------------------------*/
if (IDQuery)
{
ViChar rdBuffer[BUFFER_SIZE];
#define VALID_RESPONSE_STRING_START "ITECH Ltd., IT6512, 0123456789AF, 1.00-1.00"
checkErr( Ivi_GetAttributeViString (vi, VI_NULL, ITE6512_ATTR_ID_QUERY_RESPONSE,
0, BUFFER_SIZE, rdBuffer));
if (strncmp (rdBuffer, VALID_RESPONSE_STRING_START,
strlen(VALID_RESPONSE_STRING_START)) != 0)
{
viCheckErr( VI_ERROR_FAIL_ID_QUERY);
}
}
checkErr( Test65_CheckStatus (vi));
Error:
if (error < VI_SUCCESS)
{
if (!Ivi_Simulating (vi) && io)
viClose (io);
}
return error;
}
------解决方案--------------------
如果能包含那些VCI定义的头文件,那就应该不用重写那些东西了