26 for(i=0; i<
i_mon; i++)
37 for(i=0; i<
i_det; i++)
45 for(i=0; i<
i_use; i++)
47 for(j=0; j<
i_det; j++)
49 ut[i*i_det+j] = (float)j;
63 for(i=0; i<
i_det; i++)
95 for(i=0; i<
u_len; i++)
120 static const int hdr_size =
sizeof(
hdr) /
sizeof(
char);
121 static const int rrpb_size =
sizeof(
rpb) /
sizeof(
float);
122 static const int irpb_size =
sizeof(
rpb) /
sizeof(
int);
237 else if (!stricmp(crpt->
sample_type,
"sample, no can"))
297 i = crpt->
mdet[0] - 1;
309 i = crpt->
mdet[1] - 1;
344 for(i=0; i<crpt->
ntrg; i++)
368 if ( (crpt->
ntrg == 2) && (crpt->
ntc[0] == crpt->
ntc[1]) )
411 for(i=0; i<
u_len; i++)
599 for(i=0; i<crpt->
ntrg; i++)
641 int ndata, len_log, i;
642 fpos_t add_pos, dhdr_pos, keep_pos;
657 fgetpos(file, &add_pos);
695 ioRAW(file, &i, 1, from_file);
703 fgetpos(file, &dhdr_pos);
705 int ndes, nout, nwords, outbuff_size = 5 * (
t_ntc1+1), offset;
706 if (outbuff_size < 100000)
707 outbuff_size = 100000;
708 char* outbuff =
new char[outbuff_size];
732 offset = 33 + ndes * 2;
734 memset(outbuff, 0, outbuff_size);
735 for(i=0; i<ndes; i++)
740 ioRAW(file, outbuff, 4*nwords, from_file);
746 nwords = (3 + nout) / 4;
750 ioRAW(file, outbuff, 4*nwords, from_file);
769 int uncomp_filesize =
add.
ad_data - 1 + uncomp_data_size + len_log;
770 dhdr.
d_crdata = (float)uncomp_data_size / (
float)curr_data_size;
771 dhdr.
d_crfile = (float)uncomp_filesize / (
float)curr_filesize;
773 fgetpos(file, &keep_pos);
775 fsetpos(file, &add_pos);
778 fsetpos(file, &dhdr_pos);
781 fsetpos(file, &keep_pos);
794 ioRAW(file, (
int*)s, (
sizeof(
ADD_STRUCT) * len /
sizeof(
int)), from_file);
809 ioRAW(file, &(s[i].r_dur), 7, from_file);
810 ioRAW(file, &(s[i].r_gd_prtn_chrg), 2, from_file);
811 ioRAW(file, &(s[i].r_goodfrm), 7, from_file);
812 ioRAW(file, s[i].r_enddate, 20, from_file);
813 ioRAW(file, &(s[i].r_prop), 11, from_file);
824 ioRAW(file, &(s[i].i_chfreq), 3, from_file);
825 ioRAW(file, &(s[i].delay_c1), 14, from_file);
826 ioRAW(file, &(s[i].i_xsect), 2, from_file);
827 ioRAW(file, &(s[i].i_posn), 3, from_file);
828 ioRAW(file, &(s[i].i_l1), 1, from_file);
829 ioRAW(file, &(s[i].i_rfreq), 1, from_file);
830 ioRAW(file, &(s[i].i_renergy), 2, from_file);
831 ioRAW(file, &(s[i].i_rslit), 2, from_file);
832 ioRAW(file, &(s[i].i_xcen), 2, from_file);
833 ioRAW(file, &(s[i].i_bestop), 1, from_file);
834 ioRAW(file, &(s[i].i_radbest), 4, from_file);
835 ioRAW(file, s[i].spare, 29, from_file);
845 ioRAW(file, &(s[i].e_posn), 3, from_file);
846 ioRAW(file, &(s[i].e_thick), 16, from_file);
847 ioRAW(file, s[i].e_name, 40, from_file);
848 ioRAW(file, &(s[i].e_equip), 35, from_file);
858 ioRAW(file, s[i].sep_name, 8, from_file);
859 ioRAW(file, &(s[i].sep_value), 2, from_file);
860 ioRAW(file, s[i].sep_units, 8, from_file);
861 ioRAW(file, &(s[i].sep_low_trip), 7, from_file);
862 ioRAW(file, &(s[i].sep_stable), 2, from_file);
863 ioRAW(file, &(s[i].sep_cam_addr), 17, from_file);
879 ioRAW(file, &(s[i].d_comp), 3, from_file);
880 ioRAW(file, &(s[i].d_crdata), 2, from_file);
881 ioRAW(file, &(s[i].d_exp_filesize), 27, from_file);
891 ioRAW(file, &(s[i].nwords), 2, from_file);
901 ioRAW(file, &(s[i].ver), 2, from_file);
902 ioRAW(file, &(s[i].lines), s[i].nlines, from_file);
910 memset(padding,
' ',
sizeof(padding));
911 int i, nbytes_rounded;
914 ioRAW(file, &(s[i].len), 1, from_file);
915 nbytes_rounded = 4 * (1 + (s[i].
len-1)/4);
916 ioRAW(file, &(s[i].data), s[i].len, from_file);
917 ioRAW(file, padding, nbytes_rounded - s[i].len, from_file);
925 if ( (len <= 0) || (s == 0) )
931 n = fread(s,
sizeof(
char), len, file);
935 n = fwrite(s,
sizeof(
char), len, file);
943 if ( (len <= 0) || (s == 0) )
949 n = fread(s,
sizeof(
int), len, file);
953 n = fwrite(s,
sizeof(
int), len, file);
961 if ( (len <= 0) || (s == 0) )
967 n = fread(s,
sizeof(
isisU32_t), len, file);
971 n = fwrite(s,
sizeof(
isisU32_t), len, file);
980 if ( (len <= 0) || (s == 0) )
986 n = fread(s,
sizeof(
float), len, file);
992 n = fwrite(s,
sizeof(
float), len, file);
1005 ioRAW(file, *s, len, from_file);
1016 ioRAW(file, *s, len, from_file);
1029 ioRAW(file, *s, len, from_file);
1040 ioRAW(file, *s, len, from_file);
1053 ioRAW(file, *s, len, from_file);
1064 ioRAW(file, *s, len, from_file);
1077 *s =
new float[len];
1078 ioRAW(file, *s, len, from_file);
1089 ioRAW(file, *s, len, from_file);
1102 ioRAW(file, *s, len, from_file);
1113 ioRAW(file, *s, len, from_file);
1126 ioRAW(file, *s, len, from_file);
1137 ioRAW(file, *s, len, from_file);
1150 ioRAW(file, *s, len, from_file);
1161 ioRAW(file, *s, len, from_file);
1169 static int size_check_array[] = {
1182 for(i=0; i<
sizeof(size_check_array)/
sizeof(
int); i += 2)
1184 if (size_check_array[i] != size_check_array[i+1])
1186 std::cerr <<
"ISISRAW size check failed for " << i/2 << std::endl;
1198 struct tm *tmstruct;
1199 tmstruct = localtime((time_t*)&time_value);
1200 n = strftime(timbuf, len,
"%d-%b-%Y %H:%M:%S", tmstruct);
1203 timbuf[i] = toupper(timbuf[i]);
1208 static const char*
months[] = {
"JAN",
"FEB",
"MAR",
"APR",
"MAY",
"JUN",
1209 "JUL",
"AUG",
"SEP",
"OCT",
"NOV",
"DEC", NULL };
1216 char* timstr =
new char[len+1];
1217 strncpy(timstr, timbuf, len);
1219 n = sscanf(timstr,
"%d-%3c-%d %d:%d:%d", &(tms.tm_mday), month, &year,
1220 &(tms.tm_hour), &(tms.tm_min), &(tms.tm_sec));
1227 tms.tm_year = year - 1900;
1230 for(i = 0;
months[i] != NULL; i++)
1232 if (!strcmp(
months[i], month))
1235 return mktime(&tms);
1241 FILE* input_file = _fsopen(filename,
"rbN",_SH_DENYWR);
1242 if (input_file != NULL)
1244 ioRAW(input_file,
true);
1257 unsigned char zero_pad[512];
1260 memset(zero_pad, 0,
sizeof(zero_pad));
1262 FILE* output_file = _fsopen(filename,
"w+bcN",_SH_DENYWR);
1263 if (output_file != NULL)
1265 ioRAW(output_file,
false);
1266 fflush(output_file);
1268 fseek(output_file, 0, SEEK_END);
1269 pos = ftell(output_file);
1272 npad = 512 - pos % 512;
1273 fwrite(zero_pad, 1, npad, output_file);
1275 fclose(output_file);
1287 os <<
"INST section at " <<
add.
ad_inst <<
" 0x" << std::hex << 4*
add.
ad_inst << std::dec << std::endl;
1288 os <<
"SE section at " <<
add.
ad_se <<
" 0x" << std::hex << 4*
add.
ad_se << std::dec << std::endl;
1289 os <<
"Dae section at " <<
add.
ad_dae <<
" 0x" << std::hex << 4*
add.
ad_dae << std::dec << std::endl;
1290 os <<
"Tcb section at " <<
add.
ad_tcb <<
" 0x" << std::hex << 4*
add.
ad_tcb << std::dec << std::endl;
1291 os <<
"User section at " <<
add.
ad_user <<
" 0x" << std::hex << 4*
add.
ad_user << std::dec << std::endl;
1292 os <<
"Data section at " <<
add.
ad_data <<
" 0x" << std::hex << 4*
add.
ad_data << std::dec << std::endl;
1293 os <<
"Log section at " <<
add.
ad_log <<
" 0x" << std::hex << 4*
add.
ad_log << std::dec << std::endl;
1294 os <<
"End section at " <<
add.
ad_end <<
" 0x" << std::hex << 4*
add.
ad_end << std::dec << std::endl;
1295 os <<
"User data len " <<
u_len << std::endl;
1296 os <<
"Compression is " << (
dhdr.
d_comp == 0 ?
"NONE" :
"BYTE-RELATIVE") << std::endl;
1297 os <<
"Compression ratio of data = " <<
dhdr.
d_crdata << std::endl;
1298 os <<
"Offsets of spectrum data" << std::endl;
int ioRAW(FILE *file, bool from_file)
int timr_crpt[ISISCRPT_MAX_DETECTOR]
int code[ISISCRPT_MAX_DETECTOR]
int udet[ISISCRPT_MAX_DETECTOR]
char log_data[ISISCRPT_LOG_MAXLINES][ISISCRPT_LOG_LINELEN]
int byte_rel_comp(int *data_in, int n_in, char *data_out, int max_out, int &n_out, DAEstatus &status)
float rtcb[ISISCRPT_MAX_NTRG][ISISCRPT_MAX_TIMECHANB]
int modn[ISISCRPT_MAX_DETECTOR]
static int vmstime(char *timbuf, int len, time_t time_value)
boost::array< float, ISISCRPT_MAX_TCPAR > tcpar
int readFromFile(const char *filename)
#define TCBRANGE_CONST_T
dt=c
int mode
must be a TCBRANGE_* define
int spaceTrimCopy(char *output, int output_size, const char *input, int input_size)
int mpos[ISISCRPT_MAX_DETECTOR]
int printInfo(std::ostream &os)
static time_t from_vmstime(const char *timbuf, int len)
boost::array< int, ISISCRPT_MAX_MONITOR > monp
#define TCBRANGE_FILE
read from file
void local_to_vaxf(float *val, const int *n, int *errcode)
char beamstop_position[16]
int timr_dae[ISISCRPT_MAX_DETECTOR]
float tthe[ISISCRPT_MAX_DETECTOR]
boost::array< VETO, ISISCRPT_NUM_VETOS > vetos
char institute[ISISCRPT_INSTITUTE_NAME_LEN+1]
item_struct< char > m_char_items
int byte_rel_expn(char *data_in, int n_in, int n_from, int *data_out, int n_out, DAEstatus &status)
float delt[ISISCRPT_MAX_DETECTOR]
int dae_type
time CRPT unloaded (may not be set if program crashed)
char long_title[ISISCRPT_TITLE_LEN+1]
boost::array< unsigned, ISISCRPT_MAX_MONITOR > monitor_sum
#define TCBRANGE_INC_T
dt/t=c
int tcb[ISISCRPT_MAX_NTRG][ISISCRPT_MAX_TIMECHANB]
boost::array< int, ISISCRPT_MAX_NTRG > tcb_trdelay
int spec[ISISCRPT_MAX_DETECTOR]
float chopper_opening_angle
boost::array< int, ISISCRPT_MAX_MONITOR > mdet
int writeToFile(const char *filename)
char inst_abrv[ISISCRPT_INST_ABRV_LEN+1]
int crat[ISISCRPT_MAX_DETECTOR]
item_struct< int > m_int_items
int timr_file[ISISCRPT_MAX_DETECTOR]
TCBRANGE tcr[ISISCRPT_MAX_NTRG][ISISCRPT_MAX_TCR]
boost::array< int, ISISCRPT_MAX_NTRG > ntc
number of time channels per CRPT time regime
static const char * months[]
char user_name[ISISCRPT_USER_NAME_LEN+1]
char inst_name[ISISCRPT_INST_LEN+1]
#define VMS_RUN_MASK
need to wrap VMS run numbers to fit into 5 digits
float len2[ISISCRPT_MAX_DETECTOR]
float ut[ISISCRPT_MAX_USER *ISISCRPT_MAX_DETECTOR]
void vaxf_to_local(float *val, const int *n, int *errcode)
item_struct< float > m_real_items
boost::array< int, ISISCRPT_MAX_NTRG > nsp
number of spectra per CRPT time regime
int spacePadCopy(char *output, const char *input, int output_size)
int addItem(const std::string &name, const T *value, bool det_average=false, const int *dim0=NULL, const int *dim1=NULL)