/*---------------------------------------------------------------------------- ------------------------------------------------------------------------------ . Función: GRA_Pausa . Descripcion: Implementa una pausa asociada al ProcessSystemEvents con la . finalidad de no perder respuesta al panel frontal del usuario . Argumentos: double dTiempo | Valor en segundos que se desea implementar . como pausa en el sistema. . Retorno: Cero ------------------------------------------------------------------------------ ----------------------------------------------------------------------------*/ int GRA_Pausa(double dTiempo) { double dT1; double dT2; dT1=Timer(); dT2=Timer(); while ((dT2-dT1)<dTiempo) { dT2 = Timer(); ProcessSystemEvents(); } return 0; }
/***************************************************************************** . . Función C: UTIL_Wait . Responsable: César Armando Cruz Mendoza . Descripcion: Implementa una pausa . Parámetro de entrada: double delay | valor double de retardo en segundos . Parámetro de salida: cero . Fecha de creación: 18 de Febrero de 2011 . *****************************************************************************/ int UTIL_Wait (double delay) { static double time1; static double time2; time1 = Timer(); time2 = Timer(); while ((time2-time1) < delay) { time2 = Timer(); ProcessSystemEvents(); } return 0; }
////////////////////////////////////////////////////////////////////selfdefined function////////////////////////////////////// static int ExecutableProcess(char *cmd, char *checkpoint) { FILE *hFile; char buffer[300]; // long enough for single line of output from ipconfig char tempFileName[L_tmpnam]; char command[L_tmpnam + 25]; int hProc; int res=0; int checkflag = 0; tmpnam(tempFileName); sprintf(command, "cmd.exe /C %s > %s", cmd,tempFileName); // sprintf(command, "cmd.exe /C %s", cmd); // if (LaunchExecutableEx(command, LE_SHOWNORMAL, &hProc) >= 0) if (LaunchExecutableEx(command, LE_HIDE, &hProc) >= 0) { SetLed("running...please wait...",0); ProcessSystemEvents (); WriteLog(); ResetTextBox (panelHandle, PANEL_TEXTBOX, ""); while (!ExecutableHasTerminated(hProc)); { RetireExecutableHandle(hProc); } if (hFile = fopen(tempFileName, "r")) { while (fgets(buffer, (int)sizeof(buffer), hFile)) { SetCtrlVal (panelHandle, PANEL_TEXTBOX, buffer); if (!checkflag) { if(NULL != strstr (buffer, checkpoint)) { checkflag = 1; res = 1; } } } fclose(hFile); // DeleteFile(tempFileName); remove (tempFileName); } } return res; }
static void k236_GetLevels (gpibioPtr dev) { char msg[256]; short statusbyte; k236Ptr smu = dev->device; gpibio_GetStatusByte (dev, &statusbyte); util_Delay(.05); while (!(statusbyte & K236_SRE_READINGDONE)) { if (statusbyte & K236_SRE_READYFORTRIGGER) k236_Out (dev, "H0X", .02); ProcessSystemEvents(); util_Delay(.05); gpibio_GetStatusByte (dev, &statusbyte); } k236_Out (dev, "H0X", .02); k236_In (dev, msg); Scan (msg, "%s>%f,%f", &smu->source->acqchan->reading, &smu->measure->reading); smu->source->acqchan->newreading = TRUE; smu->measure->newreading = TRUE; }
void acquire_scans (void) { int color; int Nleft=0; char file [ FILENAME_MAX ]; char filename[FILENAME_MAX]; int data_file; SetCtrlAttribute (ERG_panel, ERG_panel_acquire, ATTR_DIMMED, 1); SetCtrlAttribute (ERG_panel, ERG_panel_abortscan, ATTR_DIMMED, 1); GetCtrlVal (ERG_panel, ERG_panel_nscans, &Nscans); DirSelectPopup ("d:\\data\\test", "Select Directory", 1, 1, pathname); //acquire preambule strcpy(filename, pathname); sprintf(file, "\\scope_info.txt"); strcat(filename, file); IO_output = fopen (filename, "w"); wavepreamble(); fclose(IO_output); //acquire scaling coefficients strcpy(filename, pathname); sprintf(file, "\\scope_xinterval.txt"); strcat(filename, file); IO_output = fopen (filename, "w"); wavexinterval(); fclose(IO_output); strcpy(filename, pathname); sprintf(file, "\\scope_yscaling.txt"); strcat(filename, file); IO_output = fopen (filename, "w"); waveyscaling(); fclose(IO_output); strcpy(filename, pathname); sprintf(file, "\\scope_x0.txt"); strcat(filename, file); IO_output = fopen (filename, "w"); wavex0(); fclose(IO_output); i=0; SetCtrlAttribute (ERG_panel, ERG_panel_pause, ATTR_DIMMED, 0); SetCtrlAttribute (ERG_panel, ERG_panel_abortscan, ATTR_DIMMED, 0); // start trigger SRS_flag=2; SRS_onoff(); // prepare file for intensity values, mask type and scan ref strcpy(filename, pathname); sprintf(file, "\\intensity.txt"); strcat(filename, file); IO_intensity = fopen (filename, "w"); //prepare file name for acquiring data while ( i < Nscans ) { strcpy(filename, pathname); sprintf(file, "\\scope_data%d.txt", i); strcat(filename, file); data_file=OpenFile (filename, VAL_WRITE_ONLY, VAL_OPEN_AS_IS, VAL_BINARY); color=floor(256/Nscans)*i; waveform(color, data_file); //the increment is done within the waveform function i++; Nleft=Nscans-i+1; SetCtrlVal (ERG_panel, ERG_panel_nremain, Nleft); ProcessSystemEvents(); if (pause_flag) { while (pause_flag) ProcessSystemEvents(); } } SetCtrlVal (ERG_panel, ERG_panel_nremain, 0); SetCtrlAttribute (ERG_panel, ERG_panel_pause, ATTR_DIMMED, 1); SetCtrlAttribute (ERG_panel, ERG_panel_abortscan, ATTR_DIMMED, 1); SetCtrlAttribute (ERG_panel, ERG_panel_acquire, ATTR_DIMMED, 0); // stop trigger SRS_flag=0; SRS_onoff(); //clean buffer strcpy(filename, pathname); sprintf(file, "\\junk.txt"); strcat(filename, file); IO_output = fopen (filename, "w"); cleanbuffer(); fclose(IO_output); //close file if (Nscans==0) { fclose(IO_intensity); } return; }
void acquire_scans (void) { int color; int Nleft=0; char file [ FILENAME_MAX ]; SetCtrlAttribute (Main_pnl_handle, ERG_panel_acquire, ATTR_DIMMED, 1); SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 1); if (experiment==1){ GetCtrlVal (Sequence_pnl_handle, Seq_panel_seq_number, &seq_num); Nscans= seq_num*m; } else { GetCtrlVal (Main_pnl_handle, ERG_panel_nscans, &Nscans); } DirSelectPopup ("d:\\data\\test", "Select Directory", 1, 1, pathname); i=0; SetCtrlAttribute (Main_pnl_handle, ERG_panel_pause, ATTR_DIMMED, 0); SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 0); // start trigger SRS_flag=2; SRS_onoff(); DeleteGraphPlot (Main_pnl_handle, ERG_panel_mask_display, -1, VAL_IMMEDIATE_DRAW); if (experiment==1){ // mode sequence for (i=0;i<seq_num;i++) { for (h=0;h<m;h++){ SetCtrlIndex (Sequence_pnl_handle, Seq_panel_mask_list, h); for (k=0;k<Npixel;k++){ drive_level[k]=mask[h].voltages[k]; } display_masks(); ProcessSystemEvents(); GetLabelFromIndex (Sequence_pnl_handle, Seq_panel_mask_list, h, &mask_filename); strcpy(filename, pathname); //prepare file to write sprintf(file, "\\sequence%d_%s.txt", i, mask_filename); strcat(filename, file); data_file = OpenFile (filename, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII); //enable oscillo then wait for trigger and get ERG trace color=floor(256/Nscans)*(i*m+h); waveform(color, data_file); get_intensity(); //write header file headerfile(); //write ERG trace ArrayToFile (filename, data2fit, VAL_DOUBLE, 10000, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_TAB, 100, VAL_ASCII, VAL_APPEND); nmeasure[0]=i*m+h+1; displaychannel(); Nleft=Nscans-(i*m+h); SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, Nleft); ProcessSystemEvents(); if (pause_flag) { while (pause_flag) ProcessSystemEvents(); } } } } else{ // mode normal //prepare file name for acquiring data while ( i < Nscans ) { strcpy(filename, pathname); sprintf(file, "\\scope_data%d.txt", i); strcat(filename, file); data_file = OpenFile (filename, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII); color=floor(256/Nscans)*i; waveform(color, data_file); get_intensity(); headerfile(); ArrayToFile (filename, data2fit, VAL_DOUBLE, 10000, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_TAB, 100, VAL_ASCII, VAL_APPEND); i++; Nleft=Nscans-i+1; SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, Nleft); ProcessSystemEvents(); if (pause_flag) { while (pause_flag) ProcessSystemEvents(); } CloseFile (data_file); } } SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, 0); SetCtrlAttribute (Main_pnl_handle, ERG_panel_pause, ATTR_DIMMED, 1); SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 1); SetCtrlAttribute (Main_pnl_handle, ERG_panel_acquire, ATTR_DIMMED, 0); // stop trigger SRS_flag=0; SRS_onoff(); ibsic(device); return; }
void util_Delay (double sec) { double time; time = Timer(); while ((Timer()-time) < sec) ProcessSystemEvents(); }
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; }