📄 hpe1463a.c
字号:
* this function returns the HPE1463A_ERROR_NO_SUCH_PATH error. *****************************************************************************/ViStatus _VI_FUNC hpe1463a_GetPath (ViSession vi, ViConstString channel1, ViConstString channel2, ViInt32 bufSize, ViChar pathList[]){ ViStatus error = VI_SUCCESS; ViString path = VI_NULL; ViInt32 pathLength; checkErr( Ivi_LockSession (vi, VI_NULL)); if (pathList == VI_NULL && bufSize != 0) viCheckParm( IVI_ERROR_INVALID_PARAMETER, 4, "Null address for Path List"); checkErr( hpe1463a_GetExistingPath (vi, channel1, channel2, &path)); pathLength = strlen (path) + 1; if (bufSize == 0) error = pathLength; else { strncpy (pathList, path, bufSize-1); pathList[bufSize-1] = '\0'; if (pathLength > bufSize) error = pathLength; else error = VI_SUCCESS; } Error: if (path != VI_NULL) Ivi_Free (vi, path); Ivi_UnlockSession (vi, VI_NULL); return error;}/***************************************************************************** * Function: hpe1463a_SetPath * Purpose: This function connects two external channels using a channel * list. This list specifies the switch channels that form a unique * path between two external channels. In case of failure, this * function provides the primary error, secondary error, and error * elaboration that describes the conditions under which the error * occurred: * - HPE1463A_ERROR_INVALID_SWITCH_PATH if the syntax of the path * string is not valid. * - HPE1463A_ERROR_EXPLICIT_CONNECTION_EXISTS, if a path already * exists between the two channels. * - HPE1463A_ERROR_ATTEMPT_TO_CONNECT_SOURCES, if setting this path * would connect two sources; * - HPE1463A_ERROR_IS_CONFIGURATION_CHANNEL, if either of the channels * at the ends of the path is a configuration channel. * - HPE1463A_ERROR_RSRC_IN_USE, if any of the channels in the path * are already connected. * - HPE1463A_ERROR_CHANNELS_ALREADY_CONNECTED, if any of the channels * in the path are already connected. *****************************************************************************/ViStatus _VI_FUNC hpe1463a_SetPath (ViSession vi, ViConstString pathList){ ViStatus error = VI_SUCCESS; ViChar *cleanPath; ViInt32 pathLength; checkErr( Ivi_LockSession (vi, VI_NULL)); if (pathList == VI_NULL) viCheckParm( IVI_ERROR_INVALID_PARAMETER, 2, "Null passed for the Path List."); checkErr( Ivi_Alloc (vi, strlen (pathList) + 1, (ViAddr*)&cleanPath)); strcpy (cleanPath, pathList); hpe1463a_CleanPath (cleanPath); if (Ivi_RangeChecking (vi)) { checkErr( hpe1463a_VerifyPath (vi, cleanPath)); } checkErr( hpe1463a_ConnectPathOnInstrument (vi, VI_NULL, cleanPath)); checkErr( hpe1463a_MarkPathAsConnected (vi, cleanPath)); Error: Ivi_Free (vi, cleanPath); Ivi_UnlockSession (vi, VI_NULL); return error;}/***************************************************************************** * Function: hpe1463a_CanConnect * Purpose: This function tells the user whether the switch module is * capable of connecting the two channels. Possible * values for the pathCapabilityRef output parameter are: * - HPE1463A_VAL_PATH_UNSUPPORTED indicates that the * driver cannot create the path. * - HPE1463A_VAL_PATH_AVAILABLE indicates that the * driver can create the path at this time. * - HPE1463A_VAL_RSRC_IN_USE indicates that the path * is valid, but the driver cannot create the path in the switch * module until the user releases another configuration channel by * destroying some other path. * - HPE1463A_VAL_PATH_EXISTS indicates that the * channels are already connected. * - HPE1463A_VAL_SOURCE_CONFLICT indicates that * connecting these two channels would connect two source channels * eiher explicitly or implicitly. * - HPE1463A_VAL_CHANNEL_NOT_AVAILABLE indicates * that one of the two channels is a configuration channel. * This function returns the HPE1463A_WARN_IMPLICIT_CONNECTION_EXISTS * warning if the path between the channels is not available, the * channels are not explicitly connected, but the implicit * connection exists between them. *****************************************************************************/ViStatus _VI_FUNC hpe1463a_CanConnect (ViSession vi, ViConstString channel1, ViConstString channel2, ViInt32 *pathCapabilityRef){ ViStatus error = VI_SUCCESS; ViInt32 ndxChannel1, ndxChannel2, **connections; ViBoolean pathAvailable, muxChannelConnected, confChanConflict; ViBoolean explicitlyConnected, pathSupported, sourceConflict; ViBoolean connectionExists; ViInt32 pathCapability; ViInt32 maxDepth; checkErr( Ivi_LockSession (vi, VI_NULL)); checkErr( Ivi_GetChannelIndex (vi, channel1, &ndxChannel1)); checkErr( Ivi_GetChannelIndex (vi, channel2, &ndxChannel2)); if (ndxChannel1 == ndxChannel2) pathCapability = HPE1463A_VAL_PATH_UNSUPPORTED; else { checkErr( Ivi_GetAttributeViAddr (vi, VI_NULL, HPE1463A_ATTR_CHANNEL_MATRIX, 0, (ViAddr*)&connections)); explicitlyConnected = hpe1463a_ChannelsAreExplicitlyConnected( ndxChannel1, ndxChannel2); if (explicitlyConnected) pathCapability = HPE1463A_VAL_PATH_EXISTS; else { checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL, HPE1463A_ATTR_MAXIMUM_DEPTH, 0, &maxDepth)); checkErr( hpe1463a_IsPathSupported (vi, ndxChannel1, ndxChannel2, connections, maxDepth, &pathSupported)); if (!pathSupported) pathCapability = HPE1463A_VAL_PATH_UNSUPPORTED; else { checkErr( hpe1463a_SourceChannelConflict (vi, channel1, channel2, &sourceConflict)); if (sourceConflict) pathCapability = HPE1463A_VAL_SOURCE_CONFLICT; else { checkErr( hpe1463a_IsEitherAConfigChannel (vi, channel1, channel2, &confChanConflict)); if (confChanConflict) pathCapability = HPE1463A_VAL_CHANNEL_NOT_AVAILABLE; else { checkErr( hpe1463a_IsPathAvailable (vi, ndxChannel1, ndxChannel2, connections, maxDepth, &pathAvailable)); checkErr( hpe1463a_IsConnectedMuxChannel (vi, channel2, &muxChannelConnected)); checkErr( hpe1463a_ImplicitConnectionExists (vi, channel1, channel2, &connectionExists)); if (connectionExists) viCheckWarn( HPE1463A_WARN_IMPLICIT_CONNECTION_EXISTS); if (pathAvailable && !muxChannelConnected) pathCapability = HPE1463A_VAL_PATH_AVAILABLE; else pathCapability = HPE1463A_VAL_RSRC_IN_USE; } } } } }Error: *pathCapabilityRef = pathCapability; Ivi_UnlockSession (vi, VI_NULL); return error;}/***************************************************************************** * Function: hpe1463a_IsDebounced * Purpose: This function returns the state of the switch module. It * indicates if all the paths that you created have settled. *****************************************************************************/ViStatus _VI_FUNC hpe1463a_IsDebounced (ViSession vi, ViBoolean *isDebounced){ ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); checkErr( Ivi_GetAttributeViBoolean (vi, VI_NULL, HPE1463A_ATTR_IS_DEBOUNCED, 0, isDebounced));Error: Ivi_UnlockSession (vi, VI_NULL); return error;}/***************************************************************************** * Function: hpe1463a_WaitForDebounce * Purpose: This function returns after all the paths that you create have * settled. If the maximum time you specify with the Maximum Time * parameter elapses before the switch settles, this function * returns a timeout error. * NOTE: If the simluation is enabled, * HPE1463A_ATTR_IS_DEBOUNCED always returns VI_TRUE with * no delay. *****************************************************************************/ViStatus _VI_FUNC hpe1463a_WaitForDebounce (ViSession vi, ViInt32 maxMilliseconds){ ViStatus error = VI_SUCCESS; ViBoolean debounced = VI_FALSE; ViReal64 startTime, maxSeconds; checkErr( Ivi_LockSession (vi, VI_NULL)); startTime = Timer (); maxSeconds = (ViReal64)maxMilliseconds / 1000.0; while (!debounced && (Timer () < (startTime + maxSeconds))) { checkErr( Ivi_GetAttributeViBoolean (vi, VI_NULL, HPE1463A_ATTR_IS_DEBOUNCED, 0, &debounced)); } if (!debounced) viCheckErr( VI_ERROR_TMO);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -