int asill_save_pars(struct asill_s *A) { char fname[MAX_PATH]; snprintf(fname, MAX_PATH, "%s/.ASILL_%d_%d", get_home(), A->model, A->n); return save_hdr(A, fname, time(NULL), 0); }
void file_sekop_write_transact_block(Tfsekop_transact *sekop_transact, const void *packet, int packet_size, int packet_num, time_t fin_time) { sekop_transact->res = FSEKOP_TRANSACT_OK; if(sekop_transact->opened != 1) { sekop_transact->res = FSEKOP_TRANSACT_ENOPEN; return; } if(sekop_transact->hdr.pnum >= packet_num) { sekop_transact->res = FSEKOP_TRANSACT_EEXIST; return; } int written_size = sekop_transact->hdr.size; if((written_size + packet_size) > sekop_transact->size) { sekop_transact->res = FSEKOP_TRANSACT_ENOSPC; return; } lseek_(sekop_transact, buff_offset(sekop_transact) + written_size, SEEK_SET); IF_ERROR_RETURN(); write_(sekop_transact, packet, packet_size); IF_ERROR_RETURN(); sekop_transact->hdr.size = written_size + packet_size; sekop_transact->hdr.pnum = packet_num; sekop_transact->hdr.time = fin_time; save_hdr(sekop_transact); }
void file_sekop_transact_clean(Tfsekop_transact *sekop_transact) { sekop_transact->res = FSEKOP_TRANSACT_OK; memset(&sekop_transact->hdr, 0, sizeof(Tfsekop_transact_hdr)); sekop_transact->hdr.pnum = 0;//-1; save_hdr(sekop_transact); }
UI_headerEditorWindow::UI_headerEditorWindow(QWidget *w_parent) { mainwindow = (UI_Mainwindow *)w_parent; setWindowTitle("EDF+/BDF+ header editor"); edf = 0; bdf = 0; edfplus = 0; bdfplus = 0; edfsignals = 0; file = NULL; setMinimumSize(690, 525); setMaximumSize(690, 525); tabholder = new QTabWidget(this); tabholder->setGeometry(0, 0, 690, 455); tab1 = new QWidget; tab2 = new QWidget; fileNameLabel = new QLabel(tab1); fileNameLabel->setGeometry(10, 10, 670, 25); startTimeDateLabel = new QLabel(tab1); startTimeDateLabel->setGeometry(10, 45, 80, 25); startTimeDateLabel->setText("Starttime"); startTimeDateLabel->setVisible(false); startTimeDate = new QDateTimeEdit(tab1); startTimeDate->setGeometry(100, 45, 250, 25); startTimeDate->setDisplayFormat("dd.MM.yyyy hh:mm:ss"); startTimeDate->setMinimumDate(QDate(1970, 1, 1)); startTimeDate->setMaximumDate(QDate(2299, 12, 31)); startTimeDate->setVisible(false); label1 = new QLabel(tab1); label1->setGeometry(10, 80, 80, 25); label1->setText("Subject"); label1->setVisible(false); lineEdit1 = new QLineEdit(tab1); lineEdit1->setGeometry(100, 80, 580, 25); lineEdit1->setMaxLength(80); lineEdit1->setVisible(false); label2 = new QLabel(tab1); label2->setGeometry(10, 115, 80, 25); label2->setText("Recording"); label2->setVisible(false); lineEdit2 = new QLineEdit(tab1); lineEdit2->setGeometry(100, 115, 580, 25); lineEdit2->setMaxLength(80); lineEdit2->setVisible(false); label3 = new QLabel(tab1); label3->setGeometry(10, 80, 80, 25); label3->setText("Subject code"); label3->setVisible(false); lineEdit3 = new QLineEdit(tab1); lineEdit3->setGeometry(100, 80, 580, 25); lineEdit3->setMaxLength(80); lineEdit3->setVisible(false); label4 = new QLabel(tab1); label4->setGeometry(10, 115, 80, 25); label4->setText("Subject name"); label4->setVisible(false); lineEdit4 = new QLineEdit(tab1); lineEdit4->setGeometry(100, 115, 580, 25); lineEdit4->setMaxLength(80); lineEdit4->setVisible(false); label11 = new QLabel(tab1); label11->setGeometry(10, 150, 80, 25); label11->setText("Gender"); label11->setVisible(false); comboBox1 = new QComboBox(tab1); comboBox1->setGeometry(100, 150, 125, 25); comboBox1->addItem("unknown"); comboBox1->addItem("male"); comboBox1->addItem("female"); comboBox1->setVisible(false); charsleft1Label = new QLabel(tab1); charsleft1Label->setGeometry(500, 150, 120, 25); charsleft1Label->setVisible(false); label12 = new QLabel(tab1); label12->setGeometry(10, 185, 80, 25); label12->setText("Birthdate"); label12->setVisible(false); dateEdit1 = new QDateEdit(tab1); dateEdit1->setGeometry(100, 185, 125, 25); dateEdit1->setDisplayFormat("d MMM yyyy"); dateEdit1->setVisible(false); checkBox1 = new QCheckBox("No birthdate", tab1); checkBox1->setGeometry(245, 185, 125, 25); checkBox1->setTristate(false); checkBox1->setCheckState(Qt::Unchecked); checkBox1->setVisible(false); label5 = new QLabel(tab1); label5->setGeometry(10, 220, 80, 25); label5->setText("Additional info"); label5->setVisible(false); lineEdit5 = new QLineEdit(tab1); lineEdit5->setGeometry(100, 220, 580, 25); lineEdit5->setMaxLength(80); lineEdit5->setVisible(false); label6 = new QLabel(tab1); label6->setGeometry(10, 255, 80, 25); label6->setText("Admin. code"); label6->setVisible(false); lineEdit6 = new QLineEdit(tab1); lineEdit6->setGeometry(100, 255, 580, 25); lineEdit6->setMaxLength(80); lineEdit6->setVisible(false); label7 = new QLabel(tab1); label7->setGeometry(10, 290, 80, 25); label7->setText("Technician"); label7->setVisible(false); lineEdit7 = new QLineEdit(tab1); lineEdit7->setGeometry(100, 290, 580, 25); lineEdit7->setMaxLength(80); lineEdit7->setVisible(false); label8 = new QLabel(tab1); label8->setGeometry(10, 325, 80, 25); label8->setText("Device"); label8->setVisible(false); lineEdit8 = new QLineEdit(tab1); lineEdit8->setGeometry(100, 325, 580, 25); lineEdit8->setMaxLength(80); lineEdit8->setVisible(false); label9 = new QLabel(tab1); label9->setGeometry(10, 360, 80, 25); label9->setText("Additional info"); label9->setVisible(false); lineEdit9 = new QLineEdit(tab1); lineEdit9->setGeometry(100, 360, 580, 25); lineEdit9->setMaxLength(80); lineEdit9->setVisible(false); charsleft2Label = new QLabel(tab1); charsleft2Label->setGeometry(500, 395, 120, 25); charsleft2Label->setVisible(false); signallist = new QTableWidget(tab2); signallist->setGeometry(10, 10, 670, 375); signallist->setSelectionMode(QAbstractItemView::NoSelection); signallist->setEditTriggers(QAbstractItemView::NoEditTriggers); signallist->setColumnCount(4); signallist->setSelectionMode(QAbstractItemView::NoSelection); signallist->setColumnWidth(0, 180); signallist->setColumnWidth(1, 120); signallist->setColumnWidth(2, 520); signallist->setColumnWidth(3, 520); QStringList horizontallabels; horizontallabels += "Label"; horizontallabels += "Physical dimension"; horizontallabels += "Prefilter"; horizontallabels += "Transducer"; signallist->setHorizontalHeaderLabels(horizontallabels); pushButton1 = new QPushButton(this); pushButton1->setGeometry(580, 475, 100, 25); pushButton1->setText("Close"); pushButton2 = new QPushButton(this); pushButton2->setGeometry(200, 475, 100, 25); pushButton2->setText("Save"); pushButton3 = new QPushButton(this); pushButton3->setGeometry(10, 475, 100, 25); pushButton3->setText("Select file"); connect(pushButton1, SIGNAL(clicked()), this, SLOT(close())); connect(pushButton2, SIGNAL(clicked()), this, SLOT(save_hdr())); connect(pushButton3, SIGNAL(clicked()), this, SLOT(open_file())); tabholder->addTab(tab1, "Header"); tabholder->addTab(tab2, "Signals"); hdr = (char *)malloc(256 * 2050); QMessageBox messagewindow(QMessageBox::Warning, "Warning", "Always make a backup copy of your file before using this tool!"); messagewindow.exec(); exec(); }
static void *worker(void *A_) { struct asill_s *A = (struct asill_s *) A_; while (A->running) { int transfered, ret; run_q(A); A->T = (get_reg_r(A, 0x30b2) & 0x7ff) * A->Tk + A->T0; if ((ret = libusb_bulk_transfer(A->h, 0x82, A->d, A->width * A->height * (A->fmt == ASILL_FMT_RAW16 ? 2 : 1) / (A->bin * A->bin), &transfered, 1000 + (A->exposure_us / 1000))) == 0) { struct timeval now; gettimeofday(&now, NULL); if (A->data && !A->data_ready) { memcpy(A->data, A->d, A->width * A->height * (A->fmt == ASILL_FMT_RAW16 ? 2 : 1) / (A->bin * A->bin)); A->data_ready = 1; } if (A->cb) { A->cb(A->d, A->width / A->bin, A->height / A->bin); } A->fps_n += 1; if (A->last_fps_comp.tv_sec == 0 && A->last_fps_comp.tv_usec == 0) gettimeofday(&A->last_fps_comp, NULL); else { int e; e = diff_us(A->last_fps_comp, now); if (e > 1000000) { float xframe = ((float) e) / A->fps_n; A->fps = 1000000.0 / xframe; A->last_fps_comp = now; A->fps_n = 0; } } if (A->save_path[0]) { struct timeval tv; char fname[MAX_PATH]; FILE *f; gettimeofday(&tv, NULL); snprintf(fname, MAX_PATH, "%s/%010lu_%06lu.hdr", A->save_path, tv.tv_sec, tv.tv_usec); save_hdr(A, fname, tv.tv_sec, tv.tv_usec); snprintf(fname, MAX_PATH, "%s/%010lu_%06lu.pgm", A->save_path, tv.tv_sec, tv.tv_usec); f = fopen(fname, "w"); if (f) { fprintf(f, "P%d\n%d %d\n%d\n", 5, A->width, A->height, A->fmt == ASILL_FMT_RAW16 ? 65535 : 255); fwrite(A->d, A->width * A->height * (A->fmt == ASILL_FMT_RAW16 ? 2 : 1), 1, f); fclose(f); } } } else { fprintf(stderr, "bulk transfer failed: %d\n", ret); if (0) { stop(A); init(A); } } } return NULL; }
int main( int ac, char **av ) { if( ac < 3 || av[0][0] == '-' ) { printf( "mkbulk: combine Phantom class files to a special\n" "bulk file to bundle with kernel (classes boot module)\n" "\n" "Usage: mkbulk outfile infile [...]\n" ); exit(1); } ac--; av++; char *outfn = av[0]; ac--; av++; outf = fopen( outfn, "wb" ); if( outf == NULL ) { printf("Can't open %s for write\n", outfn); exit(1); } //printf("Writing bulk to %s: ", outfn); while( ac-- ) { const char *infn = *av++; const cns = 1024; char cn[cns]; int fail = fn2cn( cn, infn, cns ); if(fail) continue; FILE *inf = fopen( infn, "rb" ); if( outf == NULL ) { printf("can't open %s, skip%c ", infn, ac == 0 ? ' ' : ','); continue; } //printf("%s%c ", infn, ac == 0 ? ' ' : ',' ); if( fseek( inf, 0, SEEK_END ) ) { printf("can't seek %s, skip%c ", infn, ac == 0 ? ' ' : ','); fclose(inf); continue; } long size = ftell(inf); // TODO read class name from the class file! save_hdr( cn, size ); copyf( outf, inf, (int)size ); if(ferror(inf) || ferror(outf)) { printf("I/O error\n"); exit(2); } fclose( inf ); } fclose(outf); //printf("done\n"); return 0; }