int main (int argc, char **argv) { const char *datadir = "data/streams"; gboolean gen_data = TRUE; char *stream_name = NULL; char path[256], *p; GDir *dir, *outdir; const char *dent; int i; g_mime_init (0); testsuite_init (argc, argv); for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { datadir = argv[i]; break; } } testsuite_start ("Stream tests"); p = g_stpcpy (path, datadir); *p++ = G_DIR_SEPARATOR; strcpy (p, "output"); if (!(outdir = g_dir_open (path, 0, NULL))) { if (gen_test_data (datadir, &stream_name) == -1 || !(outdir = g_dir_open (path, 0, NULL))) goto exit; gen_data = FALSE; } p = g_stpcpy (p, "input"); if (!(dir = g_dir_open (path, 0, NULL))) { if (!gen_data || gen_test_data (datadir, &stream_name) == -1 || !(dir = g_dir_open (path, 0, NULL))) { g_dir_close (outdir); goto exit; } gen_data = FALSE; } if (gen_data) { while ((dent = g_dir_read_name (dir))) { if (dent[0] == '.' || !strcmp (dent, "README")) continue; gen_data = FALSE; break; } g_dir_rewind (dir); if (gen_data && gen_test_data (datadir, &stream_name) == -1) goto exit; } *p++ = G_DIR_SEPARATOR; *p = '\0'; while ((dent = g_dir_read_name (dir))) { if (dent[0] == '.' || !strcmp (dent, "README")) continue; test_streams (outdir, datadir, dent); strcpy (p, dent); test_stream_buffer_gets (path); } if (gen_data && stream_name && testsuite_total_errors () == 0) { /* since all tests were successful, unlink the generated test data */ strcpy (p, stream_name); unlink (path); p = g_stpcpy (path, datadir); *p++ = G_DIR_SEPARATOR; p = g_stpcpy (p, "output"); *p++ = G_DIR_SEPARATOR; g_dir_rewind (outdir); while ((dent = g_dir_read_name (outdir))) { if (!strncmp (dent, stream_name, strlen (stream_name))) { strcpy (p, dent); unlink (path); } } g_free (stream_name); } g_dir_close (outdir); g_dir_close (dir); exit: testsuite_end (); g_mime_shutdown (); return testsuite_exit (); }
void MainWindow::timerPlotEvent(void) { uint8_t index = 0; int y[PLOT_BUF_LEN]; //We go through the list and we update the appropriate data: data_to_plot[0] = ui->cBoxvar1->currentIndex(); data_to_plot[1] = ui->cBoxvar2->currentIndex(); data_to_plot[2] = ui->cBoxvar3->currentIndex(); data_to_plot[3] = ui->cBoxvar4->currentIndex(); data_to_plot[4] = ui->cBoxvar5->currentIndex(); data_to_plot[5] = ui->cBoxvar6->currentIndex(); for(index = 0; index < VAR_NUM; index++) { //Update buffers with latest results: switch(data_to_plot[index]) { case 0: //"**Unused**" update_graph_array(index, 0); break; case 1: //"Accel X" update_graph_array(index, exec1.accel.x); break; case 2: //"Accel Y" update_graph_array(index, exec1.accel.y); break; case 3: //"Accel Z" update_graph_array(index, exec1.accel.z); break; case 4: //"Gyro X" update_graph_array(index, exec1.gyro.x); break; case 5: //"Gyro Y" update_graph_array(index, exec1.gyro.y); break; case 6: //"Gyro Z" update_graph_array(index, exec1.gyro.z); break; case 7: //"Encoder" update_graph_array(index, exec1.enc_display); break; case 8: //"Motor current" update_graph_array(index, exec1.current); break; case 9: //"Analog[0]" update_graph_array(index, (int) exec1.analog[0]); break; case 10: //"Strain" update_graph_array(index, exec1.strain); break; case 11: //"+VB" update_graph_array(index, exec1.volt_batt); break; case 12: //"+VG" update_graph_array(index, exec1.volt_int); break; case 13: //"Temp" update_graph_array(index, exec1.temp); break; case 14: //"Fake Data" update_graph_array(index, gen_test_data()); break; case 15: //"Setpoint (square)" update_graph_array(index, ctrl_setpoint); break; case 16: //"Setpoint (trap)" update_graph_array(index, ctrl_setpoint_trap); break; case 17: //"Strain ch1" update_graph_array(index, strain[0].strain_filtered); break; case 18: //"Strain ch2" update_graph_array(index, strain[1].strain_filtered); break; case 19: //"Strain ch3" update_graph_array(index, strain[2].strain_filtered); break; case 20: //"Strain ch4" update_graph_array(index, strain[3].strain_filtered); break; case 21: //"Strain ch5" update_graph_array(index, strain[4].strain_filtered); break; case 22: //"Strain ch6" update_graph_array(index, strain[5].strain_filtered); break; case 23: //"AS5047 (Mot.)" update_graph_array(index, ricnu_1.ex.enc_commut); break; case 24: //"AS5048 (Joint)" update_graph_array(index, ricnu_1.ex.enc_control); break; } //Copy buffers and plot: qCopy(graph_yarray[index], graph_yarray[index] + plot_len, y); refreshPlot(graph_xarray, y, plot_len, index); } }