#ifndef __AQUISITION_C__ #define __AQUISITION_C__ #endif #include #include #include #include #include #include #include #include #include #include #include #include "camac.h" #include "dc_int.h" #include "daq.h" short int open_flag; FILE *filed = NULL; void daq_I_O_cntl(struct io_control *i_cntl, int ioc_flag) { short int j = 0; short int fadc_module, sadc_module, tdc_module; /* * Fadc_Station Number of FADC */ #include "station.h" /*#include "adc_station.h"*/ fadc_module = sizeof(fadc_station)/sizeof(short int); sadc_module = sizeof(sadc_station)/sizeof(short int); tdc_module = sizeof(tdc_station)/sizeof(short int); /* * Run Ininialize & Open Output file */ if (ioc_flag == 0) { if (!open_flag) { if (i_cntl->disk_flag) { /* Disk I/O control */ open_flag = 1; if (fopen(i_cntl->data_output, "r+") == NULL) { if ((filed = fopen(i_cntl->data_output, "w")) == NULL) { sprintf(i_cntl->warning_comment, "%s", "Can't open output file, I don't know why."); i_cntl->status = 0; open_flag = 0; } } else { sprintf(i_cntl->warning_comment, "%s", "Required file is already exited."); i_cntl->status = 0; open_flag = 0; } } /* end Disk I/O control */ } if (open_flag) { if (i_cntl->disk_flag) { /* write header on disk */ fwrite(i_cntl->start_comment, sizeof(i_cntl->start_comment), 1, filed); fwrite((char *) &(i_cntl->start_time), sizeof(time_t), 1, filed); fwrite((char *) &(i_cntl->run_number), sizeof(unsigned int), 1, filed); fwrite((char *) &fadc_module, sizeof(short int), 1, filed); fwrite((char *) &sadc_module, sizeof(short int), 1, filed); fwrite((char *) &tdc_module, sizeof(short int), 1, filed); fwrite((char *) &(i_cntl->number_of_events), sizeof(unsigned int), 1, filed); for (j = 0; j < fadc_module; j++) { fwrite((char *)i_cntl->f_adc[j].thred, sizeof(unsigned int), 2, filed); } } /* end write header on disk */ i_cntl->word_point = -1; } } /* End run initialize & open output file */ /* * over 2000 word_point */ else if (ioc_flag == 1) { if (i_cntl->disk_flag) { /* write data on disk */ fwrite((char *)i_cntl->word, sizeof(short int), i_cntl->word_point + 1, filed); } /* end write data on disk */ i_cntl->word_point = -1; } /* End over 2000 word_point */ /* * write run-end comment */ else if (ioc_flag == 2) { if (open_flag) { if (i_cntl->disk_flag) { i_cntl->word[++i_cntl->word_point] = -100; if (i_cntl->word_point > -1) { fwrite((char *)i_cntl->word, sizeof(short int), i_cntl->word_point + 1, filed); } fwrite((char *)&(i_cntl->real_events), sizeof(unsigned int), 1, filed); fwrite((char *)&(i_cntl->stop_time), sizeof(time_t), 1, filed); fwrite(i_cntl->end_comment, sizeof(i_cntl->end_comment), 1, filed); fclose(filed); open_flag = 0; } } } /* end write run-end comment (ioc_flag = 2) */ }