int CreateProgressPanel ( char* szMainTitle , int iNumberOfBars ) { int hPanelWait = 0; if (( iNumberOfBars > WAIT_MAX_BARS ) || ( iNumberOfBars < 1 )) return -1; hPanelWait = LoadPanel ( 0 , "database.uir" , PROGRESS ); if ( hPanelWait < 1 ) return -1; if ( szMainTitle != NULL ) SetPanelAttribute ( hPanelWait , ATTR_TITLE , szMainTitle ); SetPanelAttribute ( hPanelWait , ATTR_HEIGHT , WAIT_BAR_START + ( WAIT_BAR_STEP * iNumberOfBars ) ); InstallPopup (hPanelWait); MakeApplicationActive (); SetActivePanel ( hPanelWait ); ProcessDrawEvents(); return hPanelWait; }
void UpdateBarTitle ( int hProgressHandle , int iBarNumber , char* szBarTitle ) { if ( hProgressHandle < 1 ) return; if ( szBarTitle == NULL ) return; switch (iBarNumber) { case 1: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_1 , ATTR_LABEL_TEXT , szBarTitle ); break; case 2: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_2 , ATTR_LABEL_TEXT , szBarTitle ); break; case 3: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_3 , ATTR_LABEL_TEXT , szBarTitle ); break; case 4: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_4 , ATTR_LABEL_TEXT , szBarTitle ); break; case 5: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_5 , ATTR_LABEL_TEXT , szBarTitle ); break; case 6: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_6 , ATTR_LABEL_TEXT , szBarTitle ); break; case 7: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_7 , ATTR_LABEL_TEXT , szBarTitle ); break; case 8: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_8 , ATTR_LABEL_TEXT , szBarTitle ); break; case 9: SetCtrlAttribute ( hProgressHandle , PROGRESS_BAR_9 , ATTR_LABEL_TEXT , szBarTitle ); break; default: break; } ProcessDrawEvents(); }
int UpdateBarProgress ( int hProgressHandle , int iBreakAllowFromBarNumber , int iBarNumber , int iProgress , int iCount ) { int iBarCtrlID = 0, iCountCtrlID = 0; int iGetPanel = 0, iGetControl = 0, event = 0; char szCount[32] = {0}; if ( hProgressHandle < 1 ) return 0; if ( iProgress < 0 ) iProgress = 0; if ( iProgress > 100 ) iProgress = 100; if ( iCount > 0 ) sprintf ( szCount , "%d" , iCount ); else strcpy ( szCount , "" ); switch (iBarNumber) { case 1: iBarCtrlID = PROGRESS_BAR_1; iCountCtrlID = PROGRESS_COUNT_1; break; case 2: iBarCtrlID = PROGRESS_BAR_2; iCountCtrlID = PROGRESS_COUNT_2; break; case 3: iBarCtrlID = PROGRESS_BAR_3; iCountCtrlID = PROGRESS_COUNT_3; break; case 4: iBarCtrlID = PROGRESS_BAR_4; iCountCtrlID = PROGRESS_COUNT_4; break; case 5: iBarCtrlID = PROGRESS_BAR_5; iCountCtrlID = PROGRESS_COUNT_5; break; case 6: iBarCtrlID = PROGRESS_BAR_6; iCountCtrlID = PROGRESS_COUNT_6; break; case 7: iBarCtrlID = PROGRESS_BAR_7; iCountCtrlID = PROGRESS_COUNT_7; break; case 8: iBarCtrlID = PROGRESS_BAR_8; iCountCtrlID = PROGRESS_COUNT_8; break; case 9: iBarCtrlID = PROGRESS_BAR_9; iCountCtrlID = PROGRESS_COUNT_9; break; default: break; } SetCtrlVal ( hProgressHandle , iBarCtrlID , iProgress ); SetCtrlVal ( hProgressHandle , iCountCtrlID , szCount ); ProcessDrawEvents(); if (( iBarNumber != 0 ) && ( iBarNumber <= iBreakAllowFromBarNumber )) { event = GetUserEvent ( 0 , &iGetPanel , &iGetControl ); if ( iGetPanel == hProgressHandle ) if ( event == USER_REQUEST_BREAK ) return 1; } return 0; }
void UpdateProgressPanel ( int hProgressHandle , char* szNewMainTitle , int iNewNumberOfBars ) { if ( hProgressHandle < 1 ) return; if (( iNewNumberOfBars > WAIT_MAX_BARS ) || ( iNewNumberOfBars < 1 )) return; if ( szNewMainTitle != NULL ) SetPanelAttribute ( hProgressHandle , ATTR_TITLE , szNewMainTitle ); SetPanelAttribute ( hProgressHandle , ATTR_HEIGHT , WAIT_BAR_START + ( WAIT_BAR_STEP * iNewNumberOfBars ) ); ProcessDrawEvents(); }
int PAT_EjecucionPorSecuencia(int iNumCiclos, char *cRuta) { char cPatron[260]={0}; char cLista[30][30]={0}; int iTotal=0; u16 estado; stPosicion p; //fin stPosicion q; //inicio stTipo t; stTipo eje; int iCiclos=0; ENT_ColocaMensaje("PAT_EjecucionPorSecuencia()"); //Fmt(cPatron,"%s<%s",ENT_LeerDesplazamientoPrueba()); Fmt(cPatron,"%s<%s",cRuta); ENT_ColocaMensaje(GRA_Strcat(2,"cPatron -> ", cPatron)); iCiclos=iNumCiclos; UTL_Split(cPatron, "->", cLista, &iTotal); q=PAT_Informacion(cLista[0]); iPaso=0; for (int j=0;j<iCiclos;j++) { for (int i=1;i<iTotal; i++) { p=PAT_Informacion(cLista[i]); t = PAT_TipodeMovimiento(q,p); ENT_ColocaMensaje(GRA_Strcat(4,"Moviendo de ",q.cDescripcion," a ",p.cDescripcion)); ENT_LeeEsperaBoton(); if (EstadoEjecucion == DESHABILITAR_MOVIMIENTO) break; if (t == EMBRAGUE) { Delay (dPausaMovimientoEmb); /* Se debe notificar que a partir de este momento se registre la fuerza en una lista paralela <<---- Insertar llamada a función aquí!!! DAQ_CapturaFuerza(INICIAR); */ } eje = PAT_MoviendoEje(q,p); if (t == EMBRAGUE) { /* Se debe validar si se ha alcanzado el máximo de fuerza solicitado <<---- Insertar llamada de código a partir de aqui DAQ_CapturaFuerza(FINALIZAR); La funcion RegistroFuerzaMaxima se sugiere se implemente: - Descargar todo el contenido de la lista Fuerza - Para cada elemento de la lista, obtener el máximo del vector - El valor maximo resultante, será la fuerza máxima aplicada - Limpiar la lista de Fuerza if (RegistroFuerzaMaxima() < FUERZA_LIMITE) { DAQ_CapturaFuerza(INICIAR); PAT_EjecutaSobreViaje(); DAQ_CapturaFuerza(FINALIZAR); Registrar la nueva fuerza alcanzada Imprimir RegistroFuerzaMaxima() } */ } //Aqui ejecuta el movimiento (Embrague - Desembrague - Neutral) PAT_CargaMovimientoSecuencial(p,t, i); if (t == EMBRAGUE) { Delay (dPausaMovimientoDes); /* Se debe notificar que a partir de este momento se registre la fuerza en una lista paralela <<---- Insertar llamada a función aquí!!! DAQ_CapturaFuerza(INICIAR); */ } q = p; //if (t == EMBRAGUE) // DelayWithEventProcessing(1.0); if (EstadoEjecucion == DESHABILITAR_MOVIMIENTO) break; } ENT_CicloConcluido(); ProcessSystemEvents(); ProcessDrawEvents(); if (EstadoEjecucion == DESHABILITAR_MOVIMIENTO) break; } return 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; }
STD_ERROR DLLEXPORT GRAPH_Plot( void *Data , int iYAxisPrecision ) { STD_ERROR StdError = {0}; int panel = 0; int numberOfPoints = 0, numberOfTraces = 0, maxNumberOfPoints = 0; int index = 0, tempIndex = 0, totalIndex = 0, PlotIndex = 0; int *pPointCounter = NULL; double *pSinglePlot = NULL; double lfCurrentX = 0.0, lfStepX = 0.0; double lfY_axis_min = 0.0, lfY_axis_max = 0.0; tsPlotGraphData *pData = NULL; IF ( (Data == NULL) , "Pointer passed NULL"); pData = (tsPlotGraphData*)Data; IF( ( pData->TraceList == NULL ) , "No traces added."); IF( ( pData->numberOfTraces == 0 ) , "No traces added."); panel = pData->panel; numberOfTraces = pData->numberOfTraces; lfCurrentX = pData->start_x; if ( pData->numberOfPoints ) lfStepX = ( pData->stop_x - pData->start_x ) / (double)(pData->numberOfPoints-1); else lfStepX = pData->stop_x - pData->start_x; ProcessDrawEvents(); numberOfPoints = pData->numberOfPoints; if ( numberOfPoints == 0 ) { for ( index = 0 ; index < numberOfTraces ; index++ ) if ( pData->TraceList[index].numberOfPoints > numberOfPoints ) numberOfPoints = pData->TraceList[index].numberOfPoints; } maxNumberOfPoints = numberOfPoints * numberOfTraces; CALLOC_ERR( pSinglePlot , maxNumberOfPoints+128 , sizeof(double)); CALLOC_ERR( pPointCounter , numberOfTraces+1 , sizeof(int)); IF (( pSinglePlot == NULL ), "Can't allocate Memory."); IF (( pPointCounter == NULL ), "Can't allocate Memory."); SetCtrlAttribute ( panel , pData->control , ATTR_NUM_TRACES , numberOfTraces ); SetCtrlAttribute ( panel , pData->control , ATTR_SCROLL_MODE , VAL_CONTINUOUS ); SetCtrlAttribute (panel, pData->control, ATTR_GRID_COLOR, VAL_BLACK); SetCtrlAttribute ( panel , pData->control , ATTR_POINTS_PER_SCREEN , numberOfPoints ); lfY_axis_min = pData->y_axis_min; lfY_axis_max = pData->y_axis_max; if (( IsNotANumber (lfY_axis_min) == 0 ) && ( IsNotANumber (lfY_axis_max) == 0 ) && ( fabs( lfY_axis_min ) > 1E-20 ) && ( fabs( lfY_axis_max ) > 1E-20 )) { SetAxisScalingMode (panel, pData->control, VAL_LEFT_YAXIS,VAL_MANUAL, lfY_axis_min , lfY_axis_max); } SetAxisScalingMode (panel, pData->control, VAL_BOTTOM_XAXIS ,VAL_MANUAL, pData->start_x , lfStepX ); SetCtrlAttribute (panel, pData->control, ATTR_YPRECISION , iYAxisPrecision ); if ( pData->szY_AxisName ) SetCtrlAttribute ( panel , pData->control , ATTR_YNAME , pData->szY_AxisName ); if ( pData->szX_AxisName ) SetCtrlAttribute (panel, pData->control , ATTR_XNAME , pData->szX_AxisName ); SetCtrlAttribute ( panel , pData->control , ATTR_LEGEND_NUM_VISIBLE_ITEMS , numberOfTraces ); for ( index = 0 ; index < numberOfTraces ; index++ ) { SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_COLOR , pData->TraceList[index].trace_color ); SetTraceAttributeEx ( panel , pData->control , index+1 , ATTR_TRACE_LG_TEXT , pData->TraceList[index].szTraceName ); SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_LG_TEXT_COLOR , VAL_BLACK ); SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_LG_VISIBLE , 1 ); if ( pData->TraceList[index].iThickness > 0 ) SetTraceAttribute (panel, pData->control, index+1 ,ATTR_TRACE_THICKNESS, pData->TraceList[index].iThickness ); SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_VISIBLE , 1 ); } for ( PlotIndex = 0 ; PlotIndex < numberOfPoints ; PlotIndex++ ) { for ( index = 0 ; index < numberOfTraces ; index++ ) { if ( ( lfCurrentX >= pData->TraceList[index].start_x ) && ( pPointCounter[index] < pData->TraceList[index].numberOfPoints ) && ( pPointCounter[index] < numberOfPoints )) { tempIndex = pPointCounter[index] + pData->TraceList[index].startTraceFromIndex; pSinglePlot[totalIndex++] = pData->TraceList[index].Trace[tempIndex]; pPointCounter[index]++; } else { tempIndex = pData->TraceList[index].startTraceFromIndex; pSinglePlot[totalIndex++] = pData->TraceList[index].Trace[tempIndex]; pPointCounter[index]++; } } lfCurrentX += lfStepX; } PlotStripChart ( panel , pData->control , pSinglePlot , totalIndex , 0 , 0 , VAL_DOUBLE ); Error: if ( pSinglePlot ) free(pSinglePlot); if ( pPointCounter ) free( pPointCounter ); ProcessDrawEvents(); return StdError; }