preferencedialog::preferencedialog(QWidget *parent) : QDialog(parent), ui(new Ui::preferencedialog) { ui->setupUi(this); check = true; bla = new QStringListModel; ui->listView->setViewMode(QListView::IconMode); ui->listView->setMovement(QListView::Static); ui->listView->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->detTable->setSelectionMode(QAbstractItemView::NoSelection); readCal(); setWindowTitle("Preferences"); ui->calTab->setCurrentIndex(0); connect(ui->calTab, SIGNAL(currentChanged(int)), this, SLOT(tabWasChanged(int))); }
// initialize things and start the clock void appBase::start( uint32_t cycle ) { // cycle == 0, program calculates loop time delay( 100 ); Wire.begin(); Serial.begin( baud ); initAmb(); // initialize the ambient sensor setAmbCfg(); // set to default values setADCcfg(); // set to default values if( lcd != NULL ) { lcd->begin( lcd_ncol, lcd_nrow ); lcd->backlight(); lcd->setCursor( 0, 0 ); lcd->print( banner ); // display version banner } if( buttons != NULL ) { buttons->begin( 4 ); buttons->readButtons(); buttons->ledAllOff(); } readCal(); // write header to serial port Serial.print("# time,ambient,T1,rate1"); if( chan.getNumActv() >= 2 ) Serial.print(",T2,rate2"); if( chan.getNumActv() >= 3 ) Serial.print(",T3,rate3"); if( chan.getNumActv() >= 4 ) Serial.print(",T4,rate4"); Serial.println(); userloop = cycle; uint16_t dADC = adc.getConvTime(); uint16_t tconv = amb.getConvTime(); tconv = tconv > dADC ? tconv : dADC; uint16_t n = ( chan.getNumActv() * tconv + 50 ) / _LOOP_INCR + 1; looptime = _LOOP_INCR * n; looptime = ( cycle > looptime ) ? cycle : looptime; timestamp = 0.0; delay( 800 ); // to show banner nextLoop = millis() + 100; // allow 100ms float reftime = 0.001 * nextLoop; // initialize reftime to the time of first sample first = true; if( lcd != NULL ) lcd->clear(); }
int main(int argc, char **argv) { int i, j, k, degree, index; double coeff[5], channel, list_channel, energy; char *ext, ext_mcal[]=".mcal", ext_cal[]=".cal"; printf("\n---------\nGainMatch v1.0\n---------\n"); if (argc < 3) { printf("Usage: gmatch (.cal/.mcal file containing calibration coefficients) (file containing a list [Det#] [Energy] [Channel]) \n "); exit(0); } FILE *calFile, *listFile; if(fopen(argv[1], "rt")) calFile = fopen(argv[1], "rt"); else { printf("ERROR: Cannot open %s\n", argv[1]); exit(0);} if(fopen(argv[2], "rt")) listFile = fopen(argv[2], "rt"); else { printf("ERROR: Cannot open %s\n", argv[2]); exit(0);} ext = strrchr(argv[1], '.'); printf("Extension is %s\n", ext); // .cal or .mcal FILE *fo; char filename[100], calname[100]; sscanf(argv[1], "%[^.]s", calname); sprintf(filename, "gMatch_%s.cal", calname); fo = fopen (filename, "wt"); printf ("Printing in %s\n\n", filename); while ( fscanf(listFile, "%d %lf %lf", &index, &energy, &list_channel)!=EOF ) { printf("Det #%d\t", index); if (strcmp(ext,ext_mcal)==0) { degree = readMCal(calFile, coeff, index, energy); } if (strcmp(ext,ext_cal)==0) { degree = readCal (calFile, coeff, index, energy);} channel = ChanFromEnergy(coeff, degree, energy); degree = 2; // finding the gain change coeff[0]=0; coeff[1]=channel/list_channel; printf("Gain = %lf %lf %lf\n", coeff[1], channel, list_channel); writeGainCal(fo, coeff, degree, index); rewind(calFile); } fclose(fo); fclose(calFile); fclose(listFile); exit(0); }