📄 rs.c
字号:
return Ivi_GetAttributeViString (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, bufSize, value);} ViStatus _VI_FUNC RS_GetAttributeViBoolean (ViSession vi, ViConstString channelName, ViAttr attributeId, ViBoolean *value){ return Ivi_GetAttributeViBoolean (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_GetAttributeViSession (ViSession vi, ViConstString channelName, ViAttr attributeId, ViSession *value){ return Ivi_GetAttributeViSession (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} /***************************************************************************** * Function: RS_SetAttribute<type> Functions * Purpose: These functions enable the instrument driver user to set * attribute values directly. There are typesafe versions for * ViInt32, ViReal64, ViString, ViBoolean, and ViSession datatypes. *****************************************************************************/ViStatus _VI_FUNC RS_SetAttributeViInt32 (ViSession vi, ViConstString channelName, ViAttr attributeId, ViInt32 value){ return Ivi_SetAttributeViInt32 (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_SetAttributeViReal64 (ViSession vi, ViConstString channelName, ViAttr attributeId, ViReal64 value){ return Ivi_SetAttributeViReal64 (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_SetAttributeViString (ViSession vi, ViConstString channelName, ViAttr attributeId, ViConstString value) { return Ivi_SetAttributeViString (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_SetAttributeViBoolean (ViSession vi, ViConstString channelName, ViAttr attributeId, ViBoolean value){ return Ivi_SetAttributeViBoolean (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_SetAttributeViSession (ViSession vi, ViConstString channelName, ViAttr attributeId, ViSession value){ return Ivi_SetAttributeViSession (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} /***************************************************************************** * Function: RS_CheckAttribute<type> Functions * Purpose: These functions enable the instrument driver user to check * attribute values directly. These functions check the value you * specify even if you set the RS_ATTR_RANGE_CHECK * attribute to VI_FALSE. There are typesafe versions for ViInt32, * ViReal64, ViString, ViBoolean, and ViSession datatypes. *****************************************************************************/ViStatus _VI_FUNC RS_CheckAttributeViInt32 (ViSession vi, ViConstString channelName, ViAttr attributeId, ViInt32 value){ return Ivi_CheckAttributeViInt32 (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);}ViStatus _VI_FUNC RS_CheckAttributeViReal64 (ViSession vi, ViConstString channelName, ViAttr attributeId, ViReal64 value){ return Ivi_CheckAttributeViReal64 (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_CheckAttributeViString (ViSession vi, ViConstString channelName, ViAttr attributeId, ViConstString value) { return Ivi_CheckAttributeViString (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_CheckAttributeViBoolean (ViSession vi, ViConstString channelName, ViAttr attributeId, ViBoolean value){ return Ivi_CheckAttributeViBoolean (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} ViStatus _VI_FUNC RS_CheckAttributeViSession (ViSession vi, ViConstString channelName, ViAttr attributeId, ViSession value){ return Ivi_CheckAttributeViSession (vi, channelName, attributeId, IVI_VAL_DIRECT_USER_CALL, value);} /***************************************************************************** * Function: RS_LockSession and RS_UnlockSession Functions * Purpose: These functions enable the instrument driver user to lock the * session around a sequence of driver calls during which other * execution threads must not disturb the instrument state. * * NOTE: The callerHasLock parameter must be a local variable * initialized to VI_FALSE and passed by reference, or you can pass * VI_NULL. *****************************************************************************/ViStatus _VI_FUNC RS_LockSession (ViSession vi, ViBoolean *callerHasLock) { return Ivi_LockSession(vi,callerHasLock); } ViStatus _VI_FUNC RS_UnlockSession (ViSession vi, ViBoolean *callerHasLock) { return Ivi_UnlockSession(vi,callerHasLock); } /***************************************************************************** * Function: RS_GetErrorInfo and RS_ClearErrorInfo Functions * Purpose: These functions enable the instrument driver user to * get or clear the error information the driver associates with the * IVI session. *****************************************************************************/ViStatus _VI_FUNC RS_GetErrorInfo (ViSession vi, ViStatus *primaryError, ViStatus *secondaryError, ViChar errorElaboration[256]) { return Ivi_GetErrorInfo(vi, primaryError, secondaryError, errorElaboration); } ViStatus _VI_FUNC RS_ClearErrorInfo (ViSession vi) { return Ivi_ClearErrorInfo (vi); }/***************************************************************************** * Function: WriteInstrData and ReadInstrData Functions * Purpose: These functions enable the instrument driver user to * write and read commands directly to and from the instrument. * * Note: These functions bypass the IVI attribute state caching. * WriteInstrData invalidates the cached values for all * attributes. *****************************************************************************/ViStatus _VI_FUNC RS_WriteInstrData (ViSession vi, ViConstString writeBuffer) { return Ivi_WriteInstrData (vi, writeBuffer); } ViStatus _VI_FUNC RS_ReadInstrData (ViSession vi, ViInt32 numBytes, ViChar rdBuf[], ViInt32 *bytesRead) { return Ivi_ReadInstrData (vi, numBytes, rdBuf, bytesRead); } /***************************************************************************** *-------------------- Utility Functions (Not Exported) ---------------------* *****************************************************************************//***************************************************************************** * Function: RS_CheckStatus * Purpose: This function checks the status of the instrument to detect * whether the instrument has encountered an error. This function * is called at the end of most exported driver functions. If the * instrument reports an error, this function returns * IVI_ERROR_INSTR_SPECIFIC. The user can set the * IVI_ATTR_QUERY_INSTR_STATUS attribute to VI_FALSE to disable this * check and increase execution speed. * * Note: Call this function only when the session is locked. *****************************************************************************/static ViStatus RS_CheckStatus (ViSession vi){ ViStatus error = VI_SUCCESS; if (Ivi_QueryInstrStatus (vi) && Ivi_NeedToCheckStatus (vi) && !Ivi_Simulating (vi)) { checkErr( RS_CheckStatusCallback (vi, Ivi_IOSession(vi))); checkErr( Ivi_SetNeedToCheckStatus (vi, VI_FALSE)); } Error: return error;}/***************************************************************************** * Function: RS_WaitForOPC * Purpose: This function waits for the instrument to complete the * execution of all pending operations. This function is a * wrapper for the WaitForOPCCallback. It can be called from * other instrument driver functions. * * The maxTime parameter specifies the maximum time to wait for * operation complete in milliseconds. * * Note: Call this function only when the session is locked. *****************************************************************************/static ViStatus RS_WaitForOPC (ViSession vi, ViInt32 maxTime) { ViStatus error = VI_SUCCESS; if (!Ivi_Simulating(vi)) { ViInt32 oldOPCTimeout; checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL, RS_ATTR_OPC_TIMEOUT, 0, &oldOPCTimeout)); Ivi_SetAttributeViInt32 (vi, VI_NULL, RS_ATTR_OPC_TIMEOUT, 0, maxTime); error = RS_WaitForOPCCallback (vi, Ivi_IOSession(vi)); Ivi_SetAttributeViInt32 (vi, VI_NULL, RS_ATTR_OPC_TIMEOUT, 0, oldOPCTimeout); viCheckErr( error); }Error: return error;}/***************************************************************************** * Function: RS_DefaultInstrSetup * Purpose: This function sends a default setup to the instrument. The * RS_reset function calls this function. The * RS_IviInit function calls this function when the * user passes VI_FALSE for the reset parameter. This function is * useful for configuring settings that other instrument driver * functions require. * * Note: Call this function only when the session is locked. *****************************************************************************/static ViStatus RS_DefaultInstrSetup (ViSession vi){ ViStatus error = VI_SUCCESS; /* Invalidate all attributes */ checkErr( Ivi_InvalidateAllAttributes (vi)); if (!Ivi_Simulating(vi)) { ViSession io = Ivi_IOSession(vi); /* call only when locked */ checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE)); /*=CHANGE:===============================================================* Change the following command string so that it executes the default setup for your instrument. The example does the following: *CLS clears the event/status registers *ESE 1 sets the standard event status enable register to recognize operation complete. *SRE 32 sets the service request register to enable a service request on operation complete These settings are required for the default implementation of the WaitForOPCCallback to work correctly. viCheckErr( viPrintf (io, "*CLS;*ESE 1;*SRE 32")); *============================================================END=CHANGE=*/ } Error: return error;}/***************************************************************************** * Function: ReadToFile and WriteFromFile Functions * Purpose: Functions for instrument driver developers to read/write * instrument data to/from a file. *****************************************************************************/static ViStatus RS_ReadToFile (ViSession vi, ViConstString filename, ViInt32 maxBytesToRead, ViInt32 fileAction, ViInt32 *totalBytesWritten) { return Ivi_ReadToFile (vi, filename, maxBytesToRead, fileAction, totalBytesWritten); } static ViStatus RS_WriteFromFile (ViSession vi, ViConstString filename, ViInt32 maxBytesToWrite, ViInt32 byteOffset, ViInt32 *totalBytesWritten)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -