int waveform (int color, int data_file) { static char write_buffer[100], read_buffer[10000] ; int numToRead=10000; int written_bytes; //////////////////////////////////////////////// memset(read_buffer, 0, 10000); ibsic(device); strcpy (write_buffer, "DATA:STARt 1"); ibwrt (device, write_buffer, strlen(write_buffer)); sprintf (write_buffer, "DATA:STOP 10000"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "ACQUIRE:MODE SAMPLE"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "ACQUIRE:STOPAFTER SEQUENCE"); ibwrt (device, write_buffer, strlen(write_buffer)); //read pump intensity, mask type and scan ref get_intensity(); // Delay(0.5); strcpy (write_buffer, "ACQUIRE:STATE ON"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "*WAI"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "CURVe?"); ibwrt (device, write_buffer, strlen(write_buffer)); Delay(0.3); ibrd (device, read_buffer, numToRead); //Delay(1); ConvertArrayType (read_buffer, VAL_CHAR, data2fit, VAL_DOUBLE, 10000); written_bytes=WriteFile (data_file,read_buffer ,10000 ); CloseFile (data_file); if (written_bytes!=10000) { printf("Error writing file!!\n"); } plot_data(color); GetCtrlVal (ERG_panel, ERG_panel_fit_live, &j); // printf ("%d", j); if (j==1) { fit_data (); } return 1; }
int waveform (int color, int data_file) { static char write_buffer[100]; int numToRead=10000; char * read_buffer; read_buffer = malloc (numToRead); memset(read_buffer, 0, 10000); ibsic(device); strcpy (write_buffer, "DATA:STARt 1"); ibwrt (device, write_buffer, strlen(write_buffer)); sprintf (write_buffer, "DATA:STOP 10000"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "ACQUIRE:MODE SAMPLE"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "ACQUIRE:STOPAFTER SEQUENCE"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "ACQUIRE:STATE ON"); ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "*WAI"); // wait for trigger to continue ibwrt (device, write_buffer, strlen(write_buffer)); strcpy (write_buffer, "CURVe?"); ibwrt (device, write_buffer, strlen(write_buffer)); Delay(0.3); ibrd (device, read_buffer, numToRead); ConvertArrayType (read_buffer, VAL_CHAR, data2fit, VAL_DOUBLE, 10000); free (read_buffer) ; plot_data(color); // check if live-fitting is enabled GetCtrlVal (Fit_pnl_handle, Fit_panel_fit_live, &fit_status); if (fit_status==1) { fit_data (); } return 1; }
int CVICALLBACK load_plot (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int color; static char read_buffer[10000] ; switch (event) { case EVENT_COMMIT: color=0; FileSelectPopupEx ("d:\\data\\test", "*.*", "txt", "Load data", VAL_LOAD_BUTTON, 0, 0, pathname); memset(data2fit, 0, sizeof(data2fit)); FileToArray (pathname, read_buffer, VAL_CHAR, 10000, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_BINARY); ConvertArrayType (read_buffer, VAL_CHAR, data2fit, VAL_DOUBLE, 10000); // printf("%s, value:%f\n",pathname, data2fit[100]); plot_data (color); break; } return 0; }