Ejemplo n.º 1
0
int		WaitForOperationCompletion( int sessionHandle , double lfTimeout , double lfLowLevelTimeout )
{
	double			lfStartTime						=	0.0,
					lfCurrentTime					=	0.0;

	int				iOpcStatus						=	0;
	
	char			szReadFeedback[LOW_STRING]		=	{0};
	
	int				count							=	0;
	
	int				iTimeout						=	0;
	
	int				iError							=	0;
	
	viGetAttribute ( sessionHandle , VI_ATTR_TMO_VALUE , &iTimeout );   
	
	SetBreakOnLibraryErrors (0); 
	
	viSetAttribute ( sessionHandle , VI_ATTR_TMO_VALUE , (lfLowLevelTimeout*1E3) );  
	
	GetCurrentDateTime(&lfStartTime);
	
	do
	{
		viPrintf( sessionHandle , "*OPC?\n" );
						
		viRead( sessionHandle, szReadFeedback , (LOW_STRING-1) , &count );
	
		iOpcStatus = atoi(szReadFeedback);
		
		if ( iOpcStatus )
			break;
		
		GetCurrentDateTime(&lfCurrentTime);
		
	} while((lfCurrentTime-lfStartTime) < lfTimeout );
	
	if ( iOpcStatus )
	{
		viPrintf( sessionHandle , ":SYST:ERR?\n" );
		SetBreakOnLibraryErrors (0);
		viRead( sessionHandle, szReadFeedback , LOW_STRING , &count );
		SetBreakOnLibraryErrors (1);
	
		iError = atoi(szReadFeedback);
	
		if ( iError == -420 )
		{
			viPrintf( sessionHandle , "*CLS\n" );  
		}
	}
	
	viSetAttribute ( sessionHandle , VI_ATTR_TMO_VALUE , iTimeout );  
	
	SetBreakOnLibraryErrors (1); 
	
	return iOpcStatus;
}
/* 系统辅助函数-Init [Directory Sets] this System needs */
void initDirectorySets(void){
	char dirName[MAX_PATHNAME_LEN];
	char DataDirPath[MAX_PATHNAME_LEN];
	char LogDirPath[MAX_PATHNAME_LEN];
	GetProjectDir(dirName);
	sprintf(DataDirPath, "%s\\DataStorage", dirName);
	sprintf(LogDirPath, "%s\\Logs", dirName);
	int oldValue;
	oldValue = SetBreakOnLibraryErrors(0);
	int isDataDirExisted = MakeDir(DataDirPath);
	int isLogDirExisted = MakeDir(LogDirPath);
	SetBreakOnLibraryErrors (oldValue);
	if(isDataDirExisted == 0)
		addLog("Successfully create the Directory:\n\"DataStorage\" and \"Logs\"", 0, panelHdl);
	else if( isDataDirExisted == -9)
		addLog("\"DataStorage\" and \"Logs\" \nDirectory has already existed!", 0, panelHdl);
	
}
Ejemplo n.º 3
0
/**
 * @brief ICS_SetPortConfiguration
 *
 * @param[in] Handle (int) - handle 
 * @param[in] ucPortNumber (unsigned char) - the specific port
 * @param[in] ucPortPolarity (unsigned char) - the configuration pins to set polarity.
 */
void*    ICS_SetPortConfiguration( int Handle , unsigned char ucPortNumber , unsigned char ucPortPolarity )
{
	STD_ERROR		StdError							=	{0};
	
	tsHandle		*pLocalHandle						=	NULL; 

	char			szString[128]						=	{0},
					szReadFeedback[LOW_STRING]			=	{0};
	
	unsigned char 	ucPortPolarityRead					=	0;
	
	int				iActualSize							=	0;
	
	IF (( Handle == 0 ) , "Empty Handle" );
	
	CHK_CMT( CmtGetTSVPtr ( Handle , &pLocalHandle  ));
	
	sprintf( szString , "OP%d %d\n" , ucPortNumber , ucPortPolarity );
	
	CHK_VSA ( viPrintf( pLocalHandle->sessionHandle ,szString ));
	
	sprintf( szString , "P%d\n" , ucPortNumber );   
	
	CHK_VSA ( viPrintf( pLocalHandle->sessionHandle ,szString ));
	
	SetBreakOnLibraryErrors (0);
	viRead( pLocalHandle->sessionHandle, szReadFeedback , (LOW_STRING-1) , &iActualSize );
	SetBreakOnLibraryErrors (1);
		
	ucPortPolarityRead = atoi(szReadFeedback);
	
	IF (( ucPortPolarityRead != ucPortPolarity ) , "Can't set polarity of the port." );
	
Error:	
	
	if( Handle ) 
		CmtReleaseTSVPtr ( Handle );
	
	return ICS_GetErrorTextMessage(Handle,StdError.error,NULL);
}
Ejemplo n.º 4
0
STD_ERROR   DLLEXPORT	DRV_FunctionGenerator_Init ( char *pszDriverLocation , char *pszAddressString , int *pHandle )
{		   					
	STD_ERROR                                   StdError                                    =   {0};
	
	tsDriverInfo								*pDriverInfo							=	NULL;
	
	CmtTSVHandle 								VariableHandle							=	0;
	
	CmtThreadLockHandle 						LockHandle								=	0;
	
	pfFunctionGenerator_Init					pWrapperFunction						=	NULL;
	
	char										szCurrentDirectory[STD_STRING]			=	{0},
												szDriverLocation[STD_STRING]			=	{0},
												szMessage[STD_STRING]					=	{0},
												*pTemp									=	NULL;
	
	int											iTry									=	0,
												bHandleExists							=	0;
	
	int											bLocked									=	0;
	
	char										*pTempString							=	NULL;

	pfSTD_Config_Install_CommentCallback        pConfig_Install_CommentCallback			=	NULL;
	pfSTD_Config_Install_ConfigValueCallback    pConfig_Install_ConfigValueCallback		=	NULL;
	pfSTD_Config_Install_CheckForBreakCallback  pConfig_Install_CheckForBreakCallback	=	NULL;
	pfSTD_Config_Copy_STD_CallBackSet			pConfig_Copy_STD_CallBackSet			=	NULL;

	HINSTANCE									LibraryHandle							=	NULL;
	
	if (( pszDriverLocation == NULL ) || ( pszAddressString == NULL ))
		{STD_ERR (DRV_ERROR_PASSED_NULL);}
	
	strcpy( szDriverLocation , pszDriverLocation );
	
	do
	{
		pTemp = strstr( pszDriverLocation , ":\\" );
	
		if ( pTemp )
			break;
		
		pTemp = strchr( pszDriverLocation , '\\' ); 
		
		if ( pTemp == NULL )
			break;
			
		GetModuleDir( __CVIUserHInst , szCurrentDirectory ); 
		
		if ( pTemp == pszDriverLocation )
			sprintf( szDriverLocation , "%s%s" , szCurrentDirectory , pszDriverLocation );
		else
			sprintf( szDriverLocation , "%s\\%s" , szCurrentDirectory , pszDriverLocation ); 
		
	} while(0);
	
	if ( FileExists(szDriverLocation,NULL) == 0 )
	{
		sprintf( szMessage , "Loading Function Generator Driver\n\"%s\"\n\nFailed, File has not found." , szDriverLocation );
		ShowMessage ( INSTR_TYPE_CONTINUE , "Equipment driver file error..." , szMessage , NULL );
		
		FORCE_ERR(-5,szMessage);
	}
			 
	if ( pHandle )
	{
		if ( CmtNewTSV ( sizeof(tsDriverInfo) , &VariableHandle ) != 0 )
			{STD_ERR (DRV_ERROR_CREATE_TSV_HANDLE);}

		if ( VariableHandle == 0 )
			{STD_ERR (DRV_ERROR_CREATE_TSV_HANDLE);}
	
		do
		{
			*pHandle = VariableHandle;
	
			if ( CmtGetTSVPtr ( VariableHandle , &pDriverInfo ) < 0 )
			{
				{STD_ERR (DRV_ERROR_GET_TSV_POINTER);}
				break;
			}
	
			pDriverInfo->InstrumentType = DRIVER_TYPE_FUNCTION_GENERATOR;
	
			CALLOC_COPY_STRING( pDriverInfo->pInstrumentAddress , pszAddressString );  
		
			bHandleExists = DRIVER_MANAGER_IsConnectionExists( pszAddressString , &(pDriverInfo->InstrumentHandle) , &(pDriverInfo->InstrumentLockHandle) );

			//--------- Load Library ---------------------//
	
			pDriverInfo->LibraryHandle = LoadLibrary(szDriverLocation);

			CALLOC_COPY_STRING( pDriverInfo->pDriverFileName,szDriverLocation);
		
			if ( pDriverInfo->LibraryHandle == 0 )
			{
				{STD_ERR (DRV_ERROR_DLL_FILE_NOT_OPENED);}
				break;
			}	
		
		
			//--------------- Load functions ------------------//
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Install_CommentCallback								= (pfSTD_Config_Install_CommentCallback) GetProcAddress( pDriverInfo->LibraryHandle , 		"Config_Install_CommentCallback");      
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Install_ConfigValueCallback							= (pfSTD_Config_Install_ConfigValueCallback) GetProcAddress( pDriverInfo->LibraryHandle , 	"Config_Install_ConfigValueCallback");  
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Install_CheckForBreakCallback							= (pfSTD_Config_Install_CheckForBreakCallback) GetProcAddress( pDriverInfo->LibraryHandle , "Config_Install_CheckForBreakCallback");
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_LOG_SetAllowState										= (pfSTD_Config_LOG_SetAllowState) GetProcAddress( pDriverInfo->LibraryHandle , "Config_LOG_SetAllowState");
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Copy_STD_CallBackSet									= (pfSTD_Config_Copy_STD_CallBackSet) GetProcAddress( pDriverInfo->LibraryHandle , "Config_Copy_STD_CallBackSet");
			
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_GetErrorTextMessage     					= (pfFunctionGenerator_GetErrorTextMessage) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_GetErrorTextMessage");         
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Init                        				= (pfFunctionGenerator_Init) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Init");                        
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Close                       				= (pfFunctionGenerator_Close) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Close");                       
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Reset										= (pfFunctionGenerator_Reset) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Reset"); 
		
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Initiate              						= (pfFunctionGenerator_Initiate) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Initiate");                    
		    pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Signel_Off           						= (pfFunctionGenerator_Signel_Off) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Signel_Off");                 
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Signel_On            						= (pfFunctionGenerator_Signel_On) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Signel_On");            
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Save_State     							= (pfFunctionGenerator_Save_State) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Save_State");     
			pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Load_State      							= (pfFunctionGenerator_Load_State) GetProcAddress( pDriverInfo->LibraryHandle , "FunctionGenerator_Load_State");      
		
			pDriverInfo->tInstrDB.Equipment_Info      																			= (pfSTD_Equipment_Info) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_Info");      
			pDriverInfo->tInstrDB.Equipment_IsSupported																			= (pfSTD_Equipment_IsSupported) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_IsSupported");   
		
			pDriverInfo->tInstrDB.Equipment_SendStateFile																		= (pfSTD_Equipment_SendStateFile) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_SendStateFile");
			pDriverInfo->tInstrDB.Equipment_ReceiveStateFile																	= (pfSTD_Equipment_ReceiveStateFile) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_ReceiveStateFile");
			pDriverInfo->tInstrDB.Equipment_GetFileCatalog																		= (pfSTD_Equipment_GetFileCatalog) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_GetFileCatalog");
			pDriverInfo->tInstrDB.Equipment_MakeFileCatalog																		= (pfSTD_Equipment_MakeFileCatalog) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_MakeFileCatalog"); 			
			pDriverInfo->tInstrDB.Equipment_DeleteFileCatalog																	= (pfSTD_Equipment_DeleteFileCatalog) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_DeleteFileCatalog");
			pDriverInfo->tInstrDB.Equipment_DeleteStateFile																		= (pfSTD_Equipment_DeleteStateFile) GetProcAddress( pDriverInfo->LibraryHandle , "Equipment_DeleteStateFile");
			
			pDriverInfo->tInstrDB.Config_SetAttribute																			= (pfSTD_Config_SetAttribute) GetProcAddress( pDriverInfo->LibraryHandle , "Config_SetAttribute"); 		
			
			pWrapperFunction = pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.FunctionGenerator_Init;
	
			if ( pWrapperFunction == NULL )
			{
				char	szMessage[LOW_STRING]	= {0};
				
				sprintf( szMessage , "Method \"%s\"\nis not implemented in driver:\n%s" , "FunctionGenerator_Init" , pDriverInfo->pDriverFileName );
				
				ShowMessage ( INSTR_TYPE_CONTINUE , "Implementation Error . . ." , szMessage , NULL );
			
				{STD_ERR (DRV_ERROR_WRONG_WRAPPER);}
			}
		
			if ( !bHandleExists )
				DRIVER_MANAGER_AddConnection( pszAddressString , &(pDriverInfo->InstrumentHandle) , DRIVER_TYPE_FUNCTION_GENERATOR , &(pDriverInfo->InstrumentLockHandle) );
		
			LockHandle = pDriverInfo->InstrumentLockHandle;
		
			if ( LockHandle == 0 )
				{STD_ERR (DRV_ERROR_CREATE_LOCK_HANDLE);}
		
			CHK_PROCCESS_GET_LOCK ( LockHandle );
		
			DRIVER_MANAGER_IsConnectionExists( pszAddressString, &(pDriverInfo->InstrumentHandle) , NULL );
		
			//===================== Install Calbacks ==========================================================================================//
			pConfig_Install_CommentCallback = pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Install_CommentCallback;		
			pConfig_Install_ConfigValueCallback	= pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Install_ConfigValueCallback;		
			pConfig_Install_CheckForBreakCallback = pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Install_CheckForBreakCallback;		
			pConfig_Copy_STD_CallBackSet = pDriverInfo->tInstrDB.functionGeneratorDriverFunctions.Config_Copy_STD_CallBackSet;
		
			DRIVER_MANAGER_GetCopyCallbacksStructure( VariableHandle , &(pDriverInfo->ptCallbacks) , 1 , pszAddressString ); 
			
			if ( pConfig_Copy_STD_CallBackSet && ( pDriverInfo->ptCallbacks ))
			{
				FREE_STDERR_COPY_ERR( pConfig_Copy_STD_CallBackSet( &pDriverInfo->InstrumentHandle , pDriverInfo->ptCallbacks ));
				
				pDriverInfo->ptCallbacks = NULL;
			}
			else
			{
				if ( pConfig_Install_CommentCallback && ( pDriverInfo->ptCallbacks ))
				{
					FREE_STDERR_COPY_ERR( pConfig_Install_CommentCallback( &pDriverInfo->InstrumentHandle , (pDriverInfo->ptCallbacks)->fCommentCallback , (pDriverInfo->ptCallbacks)->pCommentCallbackData , (pDriverInfo->ptCallbacks)->commentType ));
				}
				
				if ( pConfig_Install_ConfigValueCallback && ( pDriverInfo->ptCallbacks ))
				{
					FREE_STDERR_COPY_ERR( pConfig_Install_ConfigValueCallback( &pDriverInfo->InstrumentHandle , (pDriverInfo->ptCallbacks)->fConfigValueCallback , (pDriverInfo->ptCallbacks)->pConfigValueCallbackData , (pDriverInfo->ptCallbacks)->configType ));
				}
		
				if ( pConfig_Install_CheckForBreakCallback && ( pDriverInfo->ptCallbacks ))
				{
					FREE_STDERR_COPY_ERR( pConfig_Install_CheckForBreakCallback( &pDriverInfo->InstrumentHandle , (pDriverInfo->ptCallbacks)->fCheckForBreakCallback , (pDriverInfo->ptCallbacks)->pCheckForBreakCallbackData , (pDriverInfo->ptCallbacks)->breakType ));
				}
			}
		
			if (pDriverInfo->ptCallbacks)
				pDriverInfo->bDemoMode = (pDriverInfo->ptCallbacks)->bDemoMode;
			//=================================================================================================================================//
		
			for ( iTry = 0 ; iTry < 3 ; iTry++ )
			{
				if ( pDriverInfo->bDemoMode == 1 )
				{
					pDriverInfo->bConnected = 1;
					break;
				}
			
				if ( pWrapperFunction )
				{
					FREE_STDERR_COPY( pWrapperFunction( pDriverInfo->InstrumentHandle , pszAddressString , &pDriverInfo->InstrumentHandle , &pDriverInfo->bConnected , &pDriverInfo->ChannelQuantity )); 
				}
				else
					break;
			
				if ( StdError.error )
					if ( ShowMessage ( INSTR_TYPE_YES_NO , "Function Genrator Error !!!", "Check connection and Power On the Device." , NULL ) )
						continue;
			
				break;
			}
		
			CHK_STDERR(StdError);
		
			if (pDriverInfo->bConnected == 0)
				{STD_ERR (DRV_ERROR_CONNECTION);}
	
			if ( !bHandleExists ) 
				DRIVER_MANAGER_UpdateConnection( pszAddressString , pDriverInfo->InstrumentHandle , NULL );
		
		} while (0);
	}
	else
	{
		pfSTD_Equipment_IsSupported					pWrapperFunction							=	NULL;
		int											iCount										=	0, 
													status										=	0, 
													bSupport									=	0, 
													defaultRM									=	0,
													hConnectionHandle							=	0;
		char										szReadBuffer[LOW_STRING]					=	{0};
		//------------------ Checking for driver supporting ------------------------//
		
		viOpenDefaultRM (&defaultRM);

		SetBreakOnLibraryErrors (0);
		
		status = viOpen ( defaultRM , pszAddressString , NULL, NULL, &hConnectionHandle );
		
		if ( status == 0 )
		{	
			status = viPrintf ( hConnectionHandle , "*IDN?\n" );
		
			if ( status == 0 )
			{
				viRead ( hConnectionHandle , szReadBuffer , (LOW_STRING-1) , &iCount );
			}
		}
		
		if ( hConnectionHandle )
			viClose(hConnectionHandle); 
		
		SetBreakOnLibraryErrors (1);  
		
		LibraryHandle = LoadLibrary(szDriverLocation);
		
		if ( LibraryHandle == 0 )
		{
			sprintf( szMessage , "Loading Driver File\n\"%s\"\n\nFailed, File corrupted." , szDriverLocation );
			ShowMessage ( INSTR_TYPE_CONTINUE , "Equipment driver file error..." , szMessage , NULL );
		
			FORCE_ERR(-6,szMessage);
		}
		
		pWrapperFunction = (pfSTD_Equipment_IsSupported) GetProcAddress( LibraryHandle , "Equipment_IsSupported");   
	
		if ( pWrapperFunction )
		{
			FREE_STDERR_COPY_ERR( pWrapperFunction( 0, pszAddressString , NULL , szReadBuffer , &bSupport , NULL )); 
			
			IF (( bSupport == 0 ) , "This driver is not support the current Equipment." );
		}
		else
		{
			char	szMessage[LOW_STRING]	= {0};
		
			sprintf( szMessage , "Method \"%s\"\nis not implemented in driver:\n%s" , "Equipment_IsSupported" , szDriverLocation );
		
			ShowMessage ( INSTR_TYPE_CONTINUE , "Implementation Error . . ." , szMessage , NULL );
		}			
	}
	
Error:
	
	if ( LibraryHandle )
		FreeLibrary(LibraryHandle); 

	if ( LockHandle && bLocked ) 
		CmtReleaseLock (LockHandle);
	
	if ( VariableHandle ) 
		CmtReleaseTSVPtr ( VariableHandle );

	if ( StdError.error )
	{
		DRV_FunctionGenerator_GetErrorTextMessage ( VariableHandle , StdError.error , &pTempString );
		
		if ( pTempString && ( strlen(pTempString)))
		{
			SET_DESCRIPTION(pTempString);
		}
		
		FREE(pTempString);
		DRV_FunctionGenerator_Close( &VariableHandle ); 
		
		if ( pHandle )
			*pHandle = 0;
	}
	
	return StdError;
}
Ejemplo n.º 5
0
void*	DLLEXPORT		Equipment_Info ( int hLowLevelHandle , char *pAddress , char **pVendor , char **pSerialNumber , char **pModel , char **pFirmware )
{
	STD_ERROR						StdError									=	{0};
	
	int								iCount										=	0, 
									status										=	0, 
									//iIndex										=	0, 
									//bSupport									=	0, 
									defaultRM									=	0,
									hConnectionHandle							=	0;
	
	char							szIdentificationText[LOW_STRING]			=	{0},
									szIdentificationUpperText[LOW_STRING]		=	{0},
									*pTemp										=	NULL;

	if ( hLowLevelHandle == 0 )
	{
		viOpenDefaultRM (&defaultRM);

		SetBreakOnLibraryErrors (0);
	
		status = viOpen ( defaultRM , pAddress , NULL, NULL, &hConnectionHandle );
	}
	else
	{
		hConnectionHandle = hLowLevelHandle;	
	}
		
	if ( status == 0 )
	{	
		status = viPrintf ( hConnectionHandle , "*IDN?\n" );
	
		if ( status == 0 )
		{
			viRead ( hConnectionHandle , szIdentificationText , (LOW_STRING-1) , &iCount );
			RemoveSurroundingWhiteSpace (szIdentificationText); 
		}
	}
		
	if (( hLowLevelHandle == 0 ) && hConnectionHandle )
		viClose(hConnectionHandle); 
		
	SetBreakOnLibraryErrors (1);

	do
	{
		strcpy( szIdentificationUpperText , szIdentificationText );
		StringUpperCase (szIdentificationUpperText);
		
		IF ((( strstr( szIdentificationUpperText , "AGILENT TECHNOLOGIES" ) == NULL ) && ( strstr( szIdentificationUpperText ,"HEWLETT-PACKARD") == NULL )) , "Is not supported" );
	
		pTemp = strrchr( szIdentificationText , ',' );

		if ( pTemp )
		{
			*pTemp = 0;
			pTemp++;
	
			if ( pFirmware )
			{
				CALLOC_COPY_STRING( *pFirmware , pTemp );
			}
		}
		else
			break;
	
		pTemp = strrchr( szIdentificationText , ',' );

		if ( pTemp )
		{
			*pTemp = 0;
			pTemp++;
	
			if ( pSerialNumber )
			{
				CALLOC_COPY_STRING( *pSerialNumber , pTemp );
			}
		}
		else
			break;
	
		pTemp = strrchr( szIdentificationText , ',' );

		if ( pTemp )
		{
			*pTemp = 0;
			pTemp++;
	
			if ( pModel )
			{
				CALLOC_COPY_STRING( *pModel , pTemp );
			}
		}
		else
			break;
	
		if ( pVendor )
		{
			CALLOC_COPY_STRING( *pVendor , szIdentificationText );  
		}
		
	} while(0);
		
Error:
		
	RETURN_STDERR_POINTER;
}
Ejemplo n.º 6
0
void*	DLLEXPORT		Equipment_IsSupported ( int hLowLevelHandle , char *pAddress , char *pID_String , char *pIdentificationText , int *pbSupporting , void **pLocalData )
{
	STD_ERROR						StdError									=	{0};
	
	int								iCount										=	0, 
									status										=	0, 
									bSupport									=	0, 
									defaultRM									=	0,
									hConnectionHandle							=	0;
	
	char							szIdentificationText[LOW_STRING]			=	{0},
									szIdentificationUpperText[LOW_STRING]		=	{0}; 
	
	if (( pIdentificationText == NULL ) || ( strlen(pIdentificationText) < 10 ))
	{
		SetBreakOnLibraryErrors (0);   
		
		if ( hLowLevelHandle == 0 )
		{
			viOpenDefaultRM (&defaultRM);

			SetBreakOnLibraryErrors (0);
	
			status = viOpen ( defaultRM , pAddress , NULL, NULL, &hConnectionHandle );
		}
		else
		{
			hConnectionHandle = hLowLevelHandle;	
		}
		
		if ( status == 0 )
		{	
			status = viPrintf ( hConnectionHandle , "*IDN?\n" );
		
			if ( status == 0 )
			{
				viRead ( hConnectionHandle , szIdentificationText , (LOW_STRING-1) , &iCount );
				RemoveSurroundingWhiteSpace (szIdentificationText); 
			}
		}
		
		if (( hLowLevelHandle == 0 ) && hConnectionHandle )
			viClose(hConnectionHandle); 
		
		SetBreakOnLibraryErrors (1);  	
	}
	else
	{
		if ( strlen(pIdentificationText) < LOW_STRING )
			strcpy( szIdentificationText , pIdentificationText );
		else
			memcpy( szIdentificationText , pIdentificationText , (LOW_STRING-1) );  
	}
		
	do
	{
		strcpy( szIdentificationUpperText , szIdentificationText );
		StringUpperCase (szIdentificationUpperText);
		
		if (( strstr( szIdentificationUpperText , "AGILENT TECHNOLOGIES" ) == NULL ) && ( strstr( szIdentificationUpperText ,"HEWLETT-PACKARD") == NULL ))
			break;	
	
		if ( strstr( szIdentificationText , ",E441" ))
		{
			bSupport = 1;
			break;
		}
					
	}while(0);
	
	if (pbSupporting)
		*pbSupporting = bSupport;
	
	RETURN_STDERR_POINTER;
}
Ejemplo n.º 7
0
void*	DLLEXPORT		Equipment_IsSupported ( int hLowLevelHandle , char *pAddress , char *pID_String , char *pIdentificationText , int *pbSupporting , void **pLocalData )
{
	STD_ERROR						StdError									=	{0};
	
	int								iCount										=	0, 
									status										=	0, 
									iIndex										=	0, 
									bSupport									=	0, 
									defaultRM									=	0,
									hConnectionHandle							=	0;
	
	char							szIdentificationText[LOW_STRING]			=	{0},
									vszSupportdedModels[][12]					=	{{"E4428C"},{"E4438C"},{"N5181A"},{"N5182A"},{"N5183A"},{"N5171B"},{"N5181B"},{"N5172B"},{"N5173B"},{"N5182B"},{"E8241A"},{"E8244A"},{"E8251A"},{"E8254A"},{"E8247C"},{"E8257C"},{"E8267C"},{"E8257D"},{"E8267D"},{"E8663B"},{"E8257N"}};
									
	if (( pIdentificationText == NULL ) || ( strlen(pIdentificationText) < 10 ))
	{
		SetBreakOnLibraryErrors (0);   
		
		if ( hLowLevelHandle == 0 )
		{
			viOpenDefaultRM (&defaultRM);

			SetBreakOnLibraryErrors (0);
	
			status = viOpen ( defaultRM , pAddress , NULL, NULL, &hConnectionHandle );
		}
		else
		{
			hConnectionHandle = hLowLevelHandle;	
		}
		
		if ( status == 0 )
		{	
			status = viPrintf ( hConnectionHandle , "*IDN?\n" );
		
			if ( status == 0 )
			{
				viRead ( hConnectionHandle , szIdentificationText , (LOW_STRING-1) , &iCount );
				RemoveSurroundingWhiteSpace (szIdentificationText); 
			}
		}
		
		if (( hLowLevelHandle == 0 ) && hConnectionHandle )
			viClose(hConnectionHandle); 
		
		SetBreakOnLibraryErrors (1);  	
	}
	else
	{
		if ( strlen(pIdentificationText) < LOW_STRING )
			strcpy( szIdentificationText , pIdentificationText );
		else
			memcpy( szIdentificationText , pIdentificationText , (LOW_STRING-1) );  
	}
		
	do
	{
		if ( strstr( szIdentificationText , "Agilent Technologies" ) == NULL ) 
			break;
	
		for ( iIndex = 0; iIndex < (sizeof(vszSupportdedModels) / sizeof(vszSupportdedModels[0])); iIndex++ )
			if ( strstr( szIdentificationText , vszSupportdedModels[iIndex]) )
			{
				bSupport = 1; 
				break;
			}
					
	}while(0);
	
	if (pbSupporting)
		*pbSupporting = bSupport;
	
	RETURN_STDERR_POINTER;	
}
Ejemplo n.º 8
0
void*  ICS_GetErrorTextMessage ( int hInstrumentHandle , int iError , char *pErrorMessage )
{
	STD_ERROR		StdError							=	{0};
	
	tsHandle		*pLocalHandle						=	{0};

	int				handle								=	0;
	
	char			szCommand[LOW_STRING]				=	{0},
					szReadBuffer[LOW_STRING]			=	{0},
					szErrorDescription[LOW_STRING]		=	{0};
	
	int				count								=	0;
	
	char			*pTemp								=	NULL;
	
	IF (( hInstrumentHandle == 0 ) , "Handle is empty" );
	
	handle = hInstrumentHandle;
	
	CHK_CMT ( CmtGetTSVPtr ( handle , &pLocalHandle ));
	
	strcpy( szCommand , ":SYST:ERR?\n" );
	
	CHK_VSA( viPrintf( pLocalHandle->sessionHandle , szCommand ));
	
	SetBreakOnLibraryErrors (0);
	viRead( pLocalHandle->sessionHandle, szReadBuffer , LOW_STRING , &count );
	SetBreakOnLibraryErrors (1);
	
	iError = atoi(szReadBuffer);
	
	pTemp = strchr( szReadBuffer , '"' );
	
	if ( pTemp )
	{
		pTemp++;
		
		strcpy( szErrorDescription , pTemp );  
		
		pTemp = strchr( szErrorDescription , '"' );
		
		if ( pTemp )
			*pTemp = 0;
	}
	
	viPrintf( pLocalHandle->sessionHandle , "*CLS\n" );
	
	if ( pErrorMessage )
	{
		strcpy( pErrorMessage , szErrorDescription ); 
	}

	StdError.error = iError;
	
	if ( iError )
	{
		CALLOC_COPY_STRING( StdError.pszErrorDescription , szErrorDescription );
	}
	
Error:

	if ( handle )
		CmtReleaseTSVPtr ( handle );
	
	RETURN_STDERR_POINTER;	
}
Ejemplo n.º 9
0
STD_ERROR	DLLEXPORT	GRAPH_AddLabel( void *Data , double X_Position , double Y_Position , char *szLabelText  , int color , int label_type )
{
	STD_ERROR				StdError						=	{0};

	int					iStart_Y  				=	0,
						iStart_X  				=	0,
						iStop_Y   				=	0,
						iStop_X   				=	0,
						iPointLeft				=	0,
						iPointTop				=	0; 
	
	tsLabelItem			*pCurrentLabel			=	NULL,
						*pReferenceLabel		=	NULL; 
	
	int					derection				=	0,
						temp					=	0;
	
	int					min_digits				=	0,
						min_digits_counts		=	0,
						max_digits				=	0, 
						max_digits_counts		=	0,
						x_offset				=	0;
	
	double				xPosition				=	0.0,
						yPosition				=	0.0;
	
	tsPlotGraphData		*pData					=	NULL;
	
	SetBreakOnLibraryErrors (0);
	
	IF ( (Data == NULL) , "Pointer passed NULL");
	
	pData = (tsPlotGraphData*)Data;
	
	IF (( pData->panel == 0 ) , "No Graph Data Created.");  
	IF (( szLabelText == 0 ) , "Label Text is NULL pointer."); 
	
	xPosition = X_Position;
	yPosition = Y_Position;
	
	pCurrentLabel = &pData->Labels;
		
	if ( pCurrentLabel->controlID )
		do
		{
			if ( pCurrentLabel->pNextLabel == NULL )
			{
				CALLOC_ERR( pCurrentLabel->pNextLabel , 1 , sizeof(tsLabelItem));
				
				pCurrentLabel = pCurrentLabel->pNextLabel;
				break;
			}
			else
			{
				pCurrentLabel = pCurrentLabel->pNextLabel;	
			}
			
		} while(pCurrentLabel);
	
	switch(label_type)
	{
		case 1:
			
			pCurrentLabel->controlID = DuplicateCtrl ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , pData->panel , szLabelText , 0 , 0 );
			
			break;
			
		default:
			
			pCurrentLabel->controlID = DuplicateCtrl ( pData->panel , GRAPH_BUIL_UP_LABEL , pData->panel , szLabelText , 0 , 0 );

			break;
	}
	
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_UP_LABEL , ATTR_TOP , &iStop_Y );
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_UP_LABEL , ATTR_LEFT , &iStart_X );
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , ATTR_TOP , &iStart_Y );
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , ATTR_LEFT , &iStop_X );
	
	GetCtrlAttribute ( pData->panel , pData->control , ATTR_POINTS_PER_SCREEN, &temp );
		
	X_Position = ( X_Position - pData->start_x ) / ( pData->stop_x - pData->start_x );
	Y_Position = ( Y_Position - pData->y_axis_min ) / ( pData->y_axis_max - pData->y_axis_min ); 
	
	Y_Position = 1.0 - Y_Position;
	
	min_digits = pData->y_axis_min; 
	min_digits_counts = 0;
	max_digits = pData->y_axis_max; 
	max_digits_counts = 0;
	
	do
	{
		min_digits /= 10;
		min_digits_counts++;
	}while(min_digits);
	do
	{
		max_digits /= 10;
		max_digits_counts++;
	}while(max_digits);

	if (( max_digits_counts > min_digits_counts ) || ( pData->y_axis_min >= 0.0 ))
	{
		max_digits_counts--;
		
		x_offset = max_digits_counts * 6; // 6 digit points
	}
	else
	{
		min_digits_counts--;
		
		x_offset = min_digits_counts * 6; // 6 digit points
		x_offset += 3; // - points
	}
	
	iPointLeft = (( iStop_X - iStart_X ) * X_Position ) + iStart_X + x_offset;
	iPointTop = (( iStop_Y - iStart_Y ) * Y_Position ) + iStart_Y; 
	
	SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_TOP , iPointTop );
	SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LEFT , iPointLeft );
	
	if ( color )
	{
		SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_OFF_COLOR , color );
		SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_BGCOLOR , color );
	}
	
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_LEFT , &pCurrentLabel->left );  
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_TOP , &pCurrentLabel->top );
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_HEIGHT , &pCurrentLabel->bottom );  
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_WIDTH , &pCurrentLabel->right );
	
	pCurrentLabel->bottom += pCurrentLabel->top;
	pCurrentLabel->right += pCurrentLabel->left;
	
	pCurrentLabel->X_Position = xPosition; 
	pCurrentLabel->Y_Position = yPosition;
	
	if (szLabelText)
		strcpy(pCurrentLabel->szLabelText , szLabelText);
	
	pCurrentLabel->label_type = label_type;
	
	pReferenceLabel = &pData->Labels;
		
	if ( pReferenceLabel->controlID )
		do
		{
			if ( pCurrentLabel != pReferenceLabel )
			{
				if ( marge_protection( &derection , pCurrentLabel , pReferenceLabel , iStop_X ))
				{
					SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_LEFT , pCurrentLabel->left );  
					SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_TOP , pCurrentLabel->top );
	
					// chack again
					pReferenceLabel = &pData->Labels;
				}
			}
			
			pReferenceLabel = pReferenceLabel->pNextLabel;	
			
		} while(pReferenceLabel);
	
	
	SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_VISIBLE , 1 ); 
	
	ProcessDrawEvents();
	
Error:											   
	
	SetBreakOnLibraryErrors (1);
	
	return StdError;									   
}