예제 #1
0
int main(void) {
	// setup:
	parse_config_file(".config");
	open_status_file_for_reading_and_writing();
	read_status_file();
	create_directory_if_necessary(location_of_raw_datafiles);
	generate_new_base_filename();
	setup_pci(card_id);
	readout_all_pending_data();
	setup_filenames_for_fiber();
	if (init_camac("CAMAC_config.txt")) {
		cerr << "ERROR:  could not connect to CAMAC crate" << endl;
//		exit(7);
	}
//	if (CAMAC_initialized) {
//		CAMAC_initialize_3377s();
		open_CAMAC_file();
//	}
	setup_to_catch_ctrl_c(close_all_files);
	open_logfile();
	open_files_for_all_enabled_fiber_channels();
	unsigned short int beginning_window = 0;
	unsigned short int ending_window = 63;
	set_start_and_end_windows(beginning_window, ending_window);
	usleep(50000);

	// testing:
	should_soft_trigger = true;

	// actual running:
	while (1) {
		wait_for_start_of_spill();
		while (spill_is_active()) {
			readout_an_event(true);
			read_data_from_CAMAC_and_write_to_CAMAC_file();
//			CAMAC_read_3377s();
			printf("\n");
		}
//		increment_spill_number();
//		write_status_file();
//		generate_new_base_filename();
//		split_fiber_file_to_prepare_for_next_spill();
//		split_CAMAC_file_to_prepare_for_next_spill();
//		usleep(250000);
//		sync();
	}

	// cleanup:
	close_all_files();
	return 0;
}
예제 #2
0
void oracle::save_predictions(const string& dirname) const {

    cout << "Saving all predictions." << endl;

    // Get phenotypes and genes to predict for
    const gvector& genes  = dest->gene_vector(); assert(genes.size() > 0);
    const pvector& phenes = dest->phene_vector();

    create_directory_if_necessary(dirname);

    // For each phenotype, get the matrix column we want to print, and also
    // what is known.
    cout << "Total items to save: " << phenes.size() << endl << endl;
    progress_display show_progress(phenes.size());

    for (pvector::const_iterator j = phenes.begin(); j != phenes.end(); ++j, ++show_progress)
        // Map genes to the prediction value and write them
        write_predictions_by_phenotype(dirname, *j, find_predictions_by_phenotype(*j, genes));
}