void* DLLEXPORT PowerMeter_MeasureModulatedPower( int hInstrumentHandle , int iChannel , double timeout , double *value ) { STD_ERROR StdError = {0}; float fPower = 0; switch(iChannel) { case 1: iChannel = AGE441X_CHANNEL_A; break; case 2: iChannel = AGE441X_CHANNEL_B; break; default: iChannel = AGE441X_CHANNEL_A; break; } DelayWithEventProcessing( timeout ); *value = (double)fPower; Error: RETURN_STDERR_POINTER; }
void* DLLEXPORT PowerMeter_MeasureModulatedPower( int hInstrumentHandle , int iChannel , double timeout , double *value ) { errEV ret = {0}; errEV *pRet = NULL; float fPower = 0; short statusbyte = 0, failbyte = 0, averageCount = 0; switch(iChannel) { case 1: iChannel = AGE441X_CHANNEL_A; break; case 2: iChannel = AGE441X_CHANNEL_B; break; default: iChannel = AGE441X_CHANNEL_A; break; } DelayWithEventProcessing( timeout ); *value = (double)fPower; Error: CALLOC_COPY(pRet,1,sizeof(errEV),&ret,sizeof(errEV)); return ((void*)pRet); }
void* DLLEXPORT SpectrumAnalyzer_GetSweep( ViSession viInstrumentHandle , double lfTimeOut ) { STD_ERROR StdError = {0}; double sweepTime = 0.0; CHK_ERR( hp8563e_querySwpTime ( viInstrumentHandle , &sweepTime )); if ( sweepTime > lfTimeOut ) sweepTime = lfTimeOut; DelayWithEventProcessing( sweepTime ); CHK_ERR( hp8563e_waitUntilDone ( viInstrumentHandle , MAX_TIMEOUT )); Error: RETURN_STDERR_POINTER; }
int PRE_OcultarPanel(int iPanel) { int iLeft=0; int i=0; GetPanelAttribute(iPanel, ATTR_LEFT, &iLeft); i=0; while (i<50) { SetPanelAttribute(iPanel, ATTR_LEFT, iLeft-i); DelayWithEventProcessing(0.0); i+=10; } SetPanelAttribute (iPanel, ATTR_VSCROLL_OFFSET, 0); SetPanelAttribute (iPanel, ATTR_HSCROLL_OFFSET, 0); HidePanel(iPanel); PRE_PanelVisible(iPanel); return 0; }
/***************************************************************************** . . Función C: PRE_UbicarPanel . Responsable: César Armando Cruz Mendoza . Descripcion: Despliega un panel en pantalla considerando las . condiciones de la misma como lo es la posicion del . panel anterior y si existe el menu desplegado . Parámetro de entrada: Ninguno . Parámetro de salida: Referencia a la cadena de caracteres con el mensaje . Fecha de creación: 31 de Marzo de 2014 . *****************************************************************************/ int PRE_UbicarPanel(int iPanel) { int iBarra=0; int iAlto=0; int iAncho=0; int iExistePanel=0; int iLeftPanelExiste=0; static int iPanelAnterior=0; if (iPanel!=0) { if (iPanelAnterior != 0) GetPanelAttribute (iPanelAnterior, ATTR_LEFT, &iLeftPanelExiste); if ((iPanelAnterior != 0) && (iPanelAnterior != iPanel)) { //implementa la animación de salida int i=0; while (i<60) { SetPanelAttribute(iPanelAnterior, ATTR_LEFT, iLeftPanelExiste-i); DelayWithEventProcessing (.001); i+=20; } SetPanelAttribute (iPanelAnterior, ATTR_VSCROLL_OFFSET, 0); SetPanelAttribute (iPanelAnterior, ATTR_HSCROLL_OFFSET, 0); HidePanel(iPanelAnterior); } GetPanelAttribute(iPanelMenuPrincipal, ATTR_VISIBLE, &iExistePanel); if (iExistePanel==1) iLeftPanelExiste = ANCHO_MENU; GetPanelAttribute (iPanelPrincipal, ATTR_HEIGHT, &iAlto); GetPanelAttribute (iPanelPrincipal, ATTR_WIDTH, &iAncho); GetCtrlAttribute(iPanelPrincipal, pPrincipal_SPLITTER, ATTR_TOP, &iBarra); SetPanelAttribute(iPanel, ATTR_TOP, iBarra+8); SetPanelAttribute(iPanel, ATTR_LEFT, iLeftPanelExiste); SetPanelAttribute (iPanel, ATTR_TITLEBAR_VISIBLE, 0); SetPanelAttribute (iPanel, ATTR_FRAME_STYLE, VAL_HIDDEN_FRAME); SetPanelAttribute (iPanel, ATTR_HEIGHT, iAlto-120); SetPanelAttribute (iPanel, ATTR_WIDTH, iAncho-iLeftPanelExiste); GetPanelAttribute(iPanel, ATTR_VISIBLE, &iExistePanel); if (iExistePanel==0) { DisplayPanel(iPanel); iPanelVisible = iPanel; } iPanelAnterior = iPanel; } return 0; }
int PAT_CargaMovimientoSecuencial(stPosicion destino, stTipo t, int indiceMovimiento) { u8 vectorSpaceNum; // Vector space that will use the X and Y axes u8 xAxisNum; // X Axis number u8 yAxisNum; // Y Axis number i32 xTargetPosition; // Position to which the X axis will move when started i32 yTargetPosition; // Position to which the Y axis will move when started f64 velocity_RPM; // Maximum vector velocity of the axes in RPM f64 acceleration_RPSPS; // Vector acceleration rate for the axes i32 status; // Error checking variable u8 boardID; // Reference number for board to use (from Board Configuration Utility) u8 mustOn; u8 mustOff; u32 timeout; //Variables for modal error handling u16 commandID; // The commandID of the function u16 resourceID; // The resource ID u16 csr = 0; // Communication Status Register i32 errorCode; u16 estado; double dTiempo=0; //tiempo para cada movimiento if (t==EMBRAGUE) { dTiempo = dTiempoEmbrague; } else { dTiempo=dTiempoVelocidad; } velocity_RPM = PAT_CalculaVelocidad(destino,dTiempo); vectorSpaceNum = NIMC_VECTOR_SPACE1; //esta configuracion solo se debe ejecutar en una ocasion if (iPaso==0) { flex_config_vect_spc (1, vectorSpaceNum, 1, 2, 0); flex_set_op_mode (1, vectorSpaceNum, NIMC_ABSOLUTE_POSITION); flex_load_rpsps (1, vectorSpaceNum, NIMC_BOTH, 900, HOST); iPaso=1; } flex_load_rpm (1, vectorSpaceNum, velocity_RPM, HOST); flex_load_vs_pos (1, vectorSpaceNum, destino.iRotacional, destino.iLineal, 0, HOST); flex_start (1, vectorSpaceNum, 0); do { if (EstadoEjecucion == DESHABILITAR_MOVIMIENTO) { flex_stop_motion (1, vectorSpaceNum, NIMC_DECEL_STOP, 0x0); return 0; } flex_read_trajectory_status_rtn (1, vectorSpaceNum, NIMC_MOVE_COMPLETE_STATUS, &estado); DelayWithEventProcessing(0.01); } while ((estado & 0x02)==0); return 0; }
int PAT_Acercar(char *cRuta) { char cPatron[100]={0}; char cInicio[20]={0}; char cDestino[20]={0}; char *c; int iControl=0; long iRotacional; long iLineal; //GetCtrlVal (panelHandle, PANEL_strDetalle, cPatron); //GetCtrlVal (panelHandle, PANEL_strCerca, cInicio); //Fmt(cPatron,"%s<%s",ENT_LeerDesplazamientoPrueba()); <------------- Fmt(cPatron,"%s<%s",cRuta); // <------------- ENT_ColocaMensaje("PAT_Acercar()"); ENT_ColocaMensaje(GRA_Strcat(2,"cPatron -> ", cPatron)); DelayWithEventProcessing(2.0); MOT_PosicionActual(&iRotacional, &iLineal); Fmt(cInicio,"%s<%s",PAT_PosicionCercaDe(600, miLista, iRotacional, iLineal)); ENT_ColocaMensaje(GRA_Strcat(2,"cInicio -> ", cInicio)); if (strlen(cPatron)>0) { char cLista[30][30]={0}; int iTotal=0; UTL_Split(cPatron, "->", cLista, &iTotal); Fmt(cPatron,"%s<%s%s%s",cInicio,"->",cLista[0]); Fmt(cDestino,"%s<%s",cLista[0]); ENT_ColocaMensaje(GRA_Strcat(2,"El movimiento de acercamiento es de ", cPatron)); //verifica que la palanca se encuentre en una poscion diferente al inicio if (CompareStrings(cInicio,0,cDestino,0,0) != 0) { UTL_Split(cPatron, "->", cLista, &iTotal); c=PAT_AnalizarMovimientoLista2(cLista); ENT_ColocaMensaje(GRA_Strcat(2,"c -> ", c)); UTL_Split(c, "->", cLista, &iTotal); for (int i=0;i<iTotal;i++) { if (iControl==0) { //Busca la primer coincidencia if (CompareStrings(cLista[i],0,cInicio,0,0)==0) { Fmt(cPatron,"%s<%s",cInicio); strcat(cPatron,"->"); iControl++; } } else { //espera hasta encontrar cDestino if (CompareStrings(cLista[i],0,cDestino,0,0)==0) { strcat(cPatron,cDestino); strcat(cPatron,"->"); i=iTotal; } else { strcat(cPatron,cLista[i]); strcat(cPatron,"->"); } } } //SetCtrlVal (panelHandle, PANEL_strRutaAcercar, cPatron); ENT_ColocaMensaje(GRA_Strcat(2,"Se va a ejecutar --> ", cPatron)); ENT_LeeEsperaBoton(); PAT_EjecucionPorPatron2(cPatron); } } return 0; }
int PAT_EjecutaMovimiento(stPosicion destino) { u8 vectorSpaceNum; // Vector space that will use the X and Y axes u8 xAxisNum; // X Axis number u8 yAxisNum; // Y Axis number i32 xTargetPosition; // Position to which the X axis will move when started i32 yTargetPosition; // Position to which the Y axis will move when started f64 velocity_RPM; // Maximum vector velocity of the axes in RPM f64 acceleration_RPSPS; // Vector acceleration rate for the axes i32 status; // Error checking variable u8 boardID; // Reference number for board to use (from Board Configuration Utility) //Variables for modal error handling u16 commandID; // The commandID of the function u16 resourceID; // The resource ID u16 csr = 0; // Communication Status Register i32 errorCode; u16 estado; double dTiempo=0; //tiempo para cada movimiento //Analiza a que velocidad debe realizar el movimiento //GetCtrlVal (panelHandle, PANEL_numTiempo, &dTiempo); dTiempo = dVelocidadMovimiento; velocity_RPM = PAT_CalculaVelocidad(destino,dTiempo); vectorSpaceNum = NIMC_VECTOR_SPACE1; errorCode = flex_config_vect_spc (1, vectorSpaceNum, 1, 2, 0); errorCode = flex_set_op_mode (1, vectorSpaceNum, NIMC_ABSOLUTE_POSITION); errorCode = flex_load_rpm (1, vectorSpaceNum, velocity_RPM, HOST); errorCode = flex_load_rpsps (1, vectorSpaceNum, NIMC_BOTH, 900, HOST); errorCode = flex_load_vs_pos (1, vectorSpaceNum, destino.iRotacional, destino.iLineal, 0, HOST); errorCode = flex_start (1, vectorSpaceNum, 0); estado=0; //printf("************************************************\n"); //i32 rota; //i32 linea; do { //flex_read_pos_rtn (1, 1, &rota); //flex_read_pos_rtn (1, 2, &linea); //printf("[%d,%d] de [%d,%d]\n",rota, linea, destino.iRotacional, destino.iLineal); if (EstadoEjecucion == DESHABILITAR_MOVIMIENTO) { flex_stop_motion (1, vectorSpaceNum, NIMC_DECEL_STOP, 0x0); return 0; } errorCode = flex_read_trajectory_status_rtn (1, vectorSpaceNum, NIMC_MOVE_COMPLETE_STATUS, &estado); DelayWithEventProcessing(0.010); } while ((estado & 0x02)==0); DelayWithEventProcessing(0.050); //GetKey (); return 0; }
void* MINI_CIRCUITS_STD_Driver_SetValue( int hHandle , char *pCommandName , void *pValue , int iValueLength , int iValueSize , ... ) { STD_ERROR StdError = {0}; tsLocalStorage *pLocalStorage = NULL; int iCommandIndex = 0, bCommandFound = 0; char szCommand[LOW_STRING] = {0}; unsigned int iValue = 0; short value = 0; char *retStr = NULL; char *pError = szCommand, *pCommand = szCommand; double lfDelay = 0.0, lfCurrentTime = 0.0; IF (( hHandle == 0 ) , "Handle can't be zero." ); CHK_CMT( CmtGetTSVPtr ( hHandle, &pLocalStorage)); IF (( pValue == NULL ) ,"Value pointer is NULL" ); for ( iCommandIndex = 0 ; iCommandIndex < pLocalStorage->listSize ; iCommandIndex++ ) if ((strlen(pLocalStorage->pMINI_CIRCUITS_CommandList[iCommandIndex].szCommandName)) && ( strcmp( pCommandName , pLocalStorage->pMINI_CIRCUITS_CommandList[iCommandIndex].szCommandName ) == 0 )) { bCommandFound = 1; break; } IF (( bCommandFound == 0 ) , "Command was not found."); pLocalStorage->iLastIndex = iCommandIndex; switch(iValueSize) { case 1: if ( iValueLength == 1 ) iValue = *((char*)pValue); if ( iValueLength > 1 ) iValue = atoi((char*)pValue); break; case 2: iValue = *((short*)pValue); break; case 4: iValue = *((int*)pValue); break; case 8: iValue = (char)*((__int64*)pValue); break; default: break; } sprintf( szCommand , ":%s:%s:STATE:%d" , pLocalStorage->pMINI_CIRCUITS_CommandList[iCommandIndex].szSubDeviceName , pLocalStorage->pMINI_CIRCUITS_CommandList[iCommandIndex].szSubDeviceLocation , iValue ); GetCurrentDateTime (&lfCurrentTime); lfDelay = pLocalStorage->pMINI_CIRCUITS_CommandList[iCommandIndex].lfSetDelay - ( lfCurrentTime - pLocalStorage->lfLastSendCommandTime ); if ( lfDelay > 0.0 ) DelayWithEventProcessing(lfDelay); STD_ERR( ModularZT__USB_ControlSend_SCPI ( pLocalStorage->hDriverHandle , NULL , &pCommand ,&retStr, &value )); pLocalStorage->lfLastSendCommandTime = lfCurrentTime; IF (( value == 0 ) , "Not successfully." ); if ( retStr ) { StdError.error = atoi(retStr); if ( StdError.error < 0 ) { pError = strchr( retStr , ' ' ); if ( pError ) { FORCE_ERR( StdError.error , pError ) } } }