Mantid
Loading...
Searching...
No Matches
isisraw.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include "isisraw.h"
9#include "byte_rel_comp.h"
10#include "vms_convert.h"
11
12#include <algorithm>
13#include <cstdio>
14#include <ostream>
15
16#define SUCCESS 0
17#define FAILURE 1
18
19namespace {
20Mantid::Kernel::Logger logger("isisraw");
21}
23ISISRAW::ISISRAW() : m_crpt(nullptr), dat1(nullptr) {
24 int i, j;
25 // section 1
26 frmt_ver_no = 2; // format version number VER1 (=2)
27 data_format = 0; // data section format (0 = by TC, 1 = by spectrum)
28 // section 2
29 ver2 = 1; // run section version number VER2 (=1)
30 r_number = 0; // run number
31 memset(r_title, ' ', sizeof(r_title)); // run title
32 // section 3
33 ver3 = 2; // instrument section version number (=2)
34 memset(i_inst, ' ', sizeof(i_inst)); // instrument name
35 i_det = 1; // number of detectors NDET
36 i_mon = 1; // number of monitors NMON
37 i_use = 1; // number of user defined UTn tables NUSE
38 // I_TABLES is address of MDET
39 mdet = new int[i_mon]; // detector number for monitors (size NMON)
40 monp = new int[i_mon]; // prescale value for each monitor (size NMON)
41 for (i = 0; i < i_mon; i++) {
42 mdet[i] = i + 1;
43 monp[i] = 1;
44 }
45 spec = new int[i_det]; // spectrum number table (size NDET)
46 delt = new float[i_det]; // hold off table (size NDET)
47 len2 = new float[i_det]; // L2 table (size NDET)
48 code = new int[i_det]; // code for UTn tables (size NDET)
49 tthe = new float[i_det]; // 2theta scattering angle (size NDET)
50 ut = new float[i_use * i_det]; // nuse UT* user tables (total size NUSE*NDET) ut01=phi
51 for (i = 0; i < i_det; i++) {
52 spec[i] = i + 1; // we have t_nsp1 = i_det
53 delt[i] = static_cast<float>(i);
54 len2[i] = static_cast<float>(i);
55 code[i] = i + 1;
56 tthe[i] = static_cast<float>(i);
57 }
58 for (i = 0; i < i_use; i++) {
59 for (j = 0; j < i_det; j++) {
60 ut[i * i_det + j] = static_cast<float>(j);
61 }
62 }
63 // section 4
64 ver4 = 2; // SE section version number (=2)
65 e_nse = 1; // number of controlled SEPs NSEP
66 e_seblock = new SE_STRUCT[e_nse]; // NSEP SE parameter blocks (total size
67 // NSEP*32*4 bytes)
68 // section 5
69 ver5 = 2; // DAE section version number (=2)
70 crat = new int[i_det]; // crate number for each detector (size NDET)
71 modn = new int[i_det]; // module number for each detector (size NDET)
72 mpos = new int[i_det]; // module position for each detector (size NDET)
73 timr = new int[i_det]; // time regime for each detector (size NDET)
74 udet = new int[i_det]; // user detector number for each detector (size NDET)
75 for (i = 0; i < i_det; i++) {
76 crat[i] = 1;
77 modn[i] = 1;
78 mpos[i] = i;
79 timr[i] = 1;
80 udet[i] = i;
81 }
82 // section 6
83 ver6 = 1; // TCB section version number (=1)
84 t_ntrg = 1; // number of time regimes (=1)
85 t_nfpp = 1; // number of frames per period
86 t_nper = 1; // number of periods
87 for (i = 0; i < 256; i++) {
88 t_pmap[i] = 1; // period number for each basic period
89 }
90 t_nsp1 = i_det; // number of spectra in time regime 1
91 t_ntc1 = 10; // number of time channels in time regime 1
92 memset(t_tcm1, 0, sizeof(t_tcm1)); // time channel mode
93 memset(t_tcp1, 0, sizeof(t_tcp1)); // time channel parameters
94 t_pre1 = 1; // prescale for 32MHz clock
95 t_tcb1 = new int[t_ntc1 + 1]; // time channel boundaries in clock pulses (size NTC1+1)
96 for (i = 0; i < t_ntc1 + 1; i++) {
97 t_tcb1[i] = i;
98 }
99 // section 7
100 // write NCHAN = NTC1+1 time channel boundaries
101 ver7 = 1; // user version number (=1)
102 u_len = 1;
103 u_dat = new float[u_len]; // user defined data (ULEN, max size 400 words)
104 for (i = 0; i < u_len; i++) {
105 u_dat[i] = static_cast<float>(i);
106 }
107 // section 8
108 ver8 = 2; // data version number (=2)
109 // D_DATA points at ddes
110 ddes = new DDES_STRUCT[(t_nsp1 + 1) * t_nper]; // (NSP1+1)*NPER items, totoal
111 // size (NSP1+1)*NPER*2*4 bytes
112 dat1 = new uint32_t[(t_ntc1 + 1) * (t_nsp1 + 1) * t_nper]; // compressed data for (NTC1+1)*(NSP1+1)*NPER values
113 for (i = 0; i < (t_ntc1 + 1) * (t_nsp1 + 1) * t_nper; i++) {
114 dat1[i] = i;
115 }
116#if defined(_WIN32)
117// disable warning about strcpy
118#pragma warning(disable : 4996)
119#endif
120 logsect.nlines = 1;
122 for (i = 0; i < logsect.nlines; i++) {
123 logsect.lines[i].data = reinterpret_cast<char *>(malloc(16));
124 strcpy(logsect.lines[i].data, "test log line");
125 logsect.lines[i].len = static_cast<int>(strlen(logsect.lines[i].data));
126 }
127 addItems();
128}
129
132 static const int hdr_size = sizeof(hdr) / sizeof(char);
133 static const int rrpb_size = sizeof(rpb) / sizeof(float);
134 static const int irpb_size = sizeof(rpb) / sizeof(int);
135 m_char_items.addItem("HDR", reinterpret_cast<const char *>(&hdr), false, &hdr_size);
136 m_real_items.addItem("RRPB", reinterpret_cast<float *>(&rpb), false, &rrpb_size);
137 m_int_items.addItem("IRPB", reinterpret_cast<int *>(&rpb), false, &irpb_size);
138 return 0;
139}
140
141// create one bound to a CRPT
143ISISRAW::ISISRAW(ISISCRPT_STRUCT *crpt)
144 : m_crpt(crpt), frmt_ver_no(0), data_format(0), ver2(0), r_number(0), ver3(0), i_det(0), i_mon(0), i_use(0),
145 mdet(nullptr), monp(nullptr), spec(nullptr), delt(nullptr), len2(nullptr), code(nullptr), tthe(nullptr),
146 ut(nullptr), ver4(0), ver5(0), crat(nullptr), modn(nullptr), mpos(nullptr), timr(nullptr), udet(nullptr), ver6(0),
147 t_ntrg(0), t_nfpp(0), t_nper(0), t_nsp1(0), t_ntc1(0), t_pre1(0), t_tcb1(nullptr), ver7(0), u_dat(nullptr),
148 ver8(0), ddes(nullptr), dat1(nullptr) {
149 memset(r_title, ' ', sizeof(r_title));
150 memset(i_inst, ' ', sizeof(i_inst));
151 std::fill(std::begin(t_pmap), std::end(t_pmap), 1); // period number for each basic period
152 memset(t_tcm1, 0, sizeof(t_tcm1)); // time channel mode
153 memset(t_tcp1, 0, sizeof(t_tcp1)); // time channel parameters
154 e_nse = 0;
155 e_seblock = nullptr;
156 u_len = 0;
157 logsect.nlines = 0;
158 logsect.lines = nullptr;
159 addItems();
161}
162
163// create one bound to a CRPT
165ISISRAW::ISISRAW(ISISCRPT_STRUCT *crpt, bool doUpdateFromCRPT)
166 : m_crpt(crpt), frmt_ver_no(0), data_format(0), ver2(0), r_number(0), ver3(0), i_det(0), i_mon(0), i_use(0),
167 mdet(nullptr), monp(nullptr), spec(nullptr), delt(nullptr), len2(nullptr), code(nullptr), tthe(nullptr),
168 ut(nullptr), ver4(0), ver5(0), crat(nullptr), modn(nullptr), mpos(nullptr), timr(nullptr), udet(nullptr), ver6(0),
169 t_ntrg(0), t_nfpp(0), t_nper(0), t_nsp1(0), t_ntc1(0), t_pre1(0), t_tcb1(nullptr), ver7(0), u_dat(nullptr),
170 ver8(0), ddes(nullptr), dat1(nullptr) {
171 memset(r_title, ' ', sizeof(r_title));
172 memset(i_inst, ' ', sizeof(i_inst));
173 std::fill(std::begin(t_pmap), std::end(t_pmap), 1); // period number for each basic period
174 memset(t_tcm1, 0, sizeof(t_tcm1)); // time channel mode
175 memset(t_tcp1, 0, sizeof(t_tcp1)); // time channel parameters
176 e_nse = 0;
177 e_seblock = nullptr;
178 u_len = 0;
179 logsect.nlines = 0;
180 logsect.lines = nullptr;
181 addItems();
182 if (doUpdateFromCRPT) {
184 }
185}
186
187// update from bound CRPT
190 if (m_crpt == nullptr) {
191 return 0;
192 }
193#ifndef REAL_CRPT
194 return 0;
195#else
196 int i;
197 char buffer[256];
198 spacePadCopy(hdr.inst_abrv, m_crpt->inst_abrv, sizeof(hdr.inst_abrv));
199 sprintf(buffer, "%05d", m_crpt->run_number);
200 spacePadCopy(hdr.hd_run, buffer, sizeof(hdr.hd_run));
201 spacePadCopy(hdr.hd_user, m_crpt->user_name, sizeof(hdr.hd_user));
202 // spacePadCopy(hdr.hd_title, m_crpt->short_title, sizeof(hdr.hd_title));
203 spacePadCopy(hdr.hd_title, m_crpt->long_title, sizeof(hdr.hd_title));
204 vmstime(buffer, sizeof(buffer), m_crpt->start_time);
205 spacePadCopy(hdr.hd_date, buffer, sizeof(hdr.hd_date) + sizeof(hdr.hd_time));
206 sprintf(buffer, "%8.2f", m_crpt->good_uamph);
207 spacePadCopy(hdr.hd_dur, buffer, sizeof(hdr.hd_dur));
208
209 // section 1
210 frmt_ver_no = 2; // format version number VER1 (=2)
211 data_format = 0; // data section format (0 = by TC, 1 = by spectrum)
212 // section 2
213 ver2 = 1; // run section version number VER2 (=1)
214 r_number = m_crpt->run_number; // run number
215 spacePadCopy(r_title, m_crpt->long_title, sizeof(r_title)); // run title
216 spacePadCopy(user.r_user, m_crpt->user_name, sizeof(user.r_user));
217 spacePadCopy(user.r_instit, m_crpt->institute, sizeof(user.r_instit));
218 // rpb
219 rpb.r_dur = m_crpt->duration;
220 rpb.r_durunits = 1; // seconds
221 rpb.r_freq = 1; // 50Hz
222 rpb.r_gd_prtn_chrg = m_crpt->good_uamph;
223 rpb.r_tot_prtn_chrg = m_crpt->total_uamph;
224 rpb.r_goodfrm = m_crpt->good_frames;
225 rpb.r_rawfrm = m_crpt->total_frames;
226 rpb.r_dur_secs = m_crpt->duration;
227 // TODO
228 rpb.r_mon_sum1 = 0; // m_crpt->monitor_sum[0];
229 rpb.r_mon_sum2 = 0;
230 rpb.r_mon_sum3 = 0;
231 vmstime(buffer, sizeof(buffer), m_crpt->stop_time);
232 spacePadCopy(rpb.r_enddate, buffer, sizeof(rpb.r_enddate) + sizeof(rpb.r_endtime));
233 rpb.r_prop = m_crpt->rb_number;
234
235 // section 3
236 ver3 = 2; // instrument section version number (=2)
237 spacePadCopy(i_inst, m_crpt->inst_name, sizeof(i_inst)); // instrument name
238 ivpb.i_l1 = m_crpt->i_l1;
239 if (!strcmp(m_crpt->beamstop_position, "IN")) {
240 ivpb.i_bestop = 0;
241 } else {
242 ivpb.i_bestop = 1;
243 }
244 ivpb.i_xsect = m_crpt->aperture1;
245 ivpb.i_ysect = m_crpt->aperture2;
246 ivpb.i_sddist = m_crpt->sdd;
247
248 ivpb.i_foeang = m_crpt->foe_mirror_angle;
249 ivpb.i_xcen = m_crpt->beam_centre_x;
250 ivpb.i_ycen = m_crpt->beam_centre_y;
251 ivpb.i_chopsiz = m_crpt->chopper_opening_angle;
252 ivpb.i_aofi = m_crpt->angle_of_incidence;
253
254 spb.e_phi = m_crpt->sample_phi_angle;
255 spb.e_height = m_crpt->sample_height;
256 spb.e_width = m_crpt->sample_width;
257 spb.e_thick = m_crpt->sample_thickness;
258 if (!stricmp(m_crpt->sample_type, "sample+can")) {
259 spb.e_type = 1;
260 } else if (!stricmp(m_crpt->sample_type, "empty can")) {
261 spb.e_type = 2;
262 } else if (!stricmp(m_crpt->sample_type, "vanadium")) {
263 spb.e_type = 3;
264 } else if (!stricmp(m_crpt->sample_type, "absorber")) {
265 spb.e_type = 4;
266 } else if (!stricmp(m_crpt->sample_type, "nothing")) {
267 spb.e_type = 5;
268 } else if (!stricmp(m_crpt->sample_type, "sample, no can")) {
269 spb.e_type = 6;
270 } else {
271 spb.e_type = 1;
272 }
273
274 if (!stricmp(m_crpt->sample_geometry, "cylinder") || !stricmp(m_crpt->sample_geometry, "cylindrical")) {
275 spb.e_geom = 1;
276 } else if (!stricmp(m_crpt->sample_geometry, "flat plate")) {
277 spb.e_geom = 2;
278 } else if (!stricmp(m_crpt->sample_geometry, "disc")) {
279 spb.e_geom = 3;
280 } else if (!stricmp(m_crpt->sample_geometry, "single crystal")) {
281 spb.e_geom = 4;
282 } else {
283 spb.e_geom = 1;
284 }
285
286 i_det = m_crpt->ndet; // number of detectors NDET
287 i_mon = m_crpt->nmon; // number of monitors NMON
288 i_use = m_crpt->nuse; // number of user defined UTn tables NUSE
289 // I_TABLES is address of MDET
290 mdet = m_crpt->mdet; // detector number for monitors (size NMON)
291 monp = m_crpt->monp; // prescale value for each monitor (size NMON)
292 spec = m_crpt->spec; // spectrum number table (size NDET)
293 delt = m_crpt->delt; // hold off table (size NDET)
294 len2 = m_crpt->len2; // L2 table (size NDET)
295 code = m_crpt->code; // code for UTn tables (size NDET)
296 tthe = m_crpt->tthe; // 2theta scattering angle (size NDET)
297 ut = (float *)m_crpt->ut; // nuse UT* user tables (total size NUSE*NDET) ut01=phi
298
299 // section 4
300 ver4 = 2; // SE section version number (=2)
301 e_nse = 1; // number of controlled SEPs NSEP
302 delete[] e_seblock;
303 e_seblock = new SE_STRUCT[e_nse]; // NSEP SE parameter blocks (total size
304 // NSEP*32*4 bytes)
305 // section 5
306 ver5 = 2; // DAE section version number (=2)
307 daep.a_pars = 4; // 32bit dae memory
308 daep.mem_size = daep.a_pars * (m_crpt->nsp1 + 1) * (m_crpt->ntc1 + 1) * m_crpt->nper_daq;
309
310 daep.ppp_good_high = m_crpt->good_ppp_high;
311 daep.ppp_good_low = m_crpt->good_ppp_low;
312 daep.ppp_raw_high = m_crpt->total_ppp_high;
313 daep.ppp_raw_low = m_crpt->total_ppp_low;
314 daep.mon1_detector = 0; // m_crpt->udet[m_crpt->mdet[0] - 1];
315 daep.mon1_module = 0;
316 daep.mon1_crate = 0;
317 daep.mon1_mask = 0;
319 daep.mon2_module = 0;
320 daep.mon2_crate = 0;
321 daep.mon2_mask = 0;
322 daep.a_smp = (m_crpt->vetos[SMPVeto].enabled != 0);
323 daep.ext_vetos[0] = (m_crpt->vetos[Ext0Veto].enabled != 0);
324 daep.ext_vetos[1] = (m_crpt->vetos[Ext1Veto].enabled != 0);
325 daep.ext_vetos[2] = (m_crpt->vetos[Ext2Veto].enabled != 0);
326 daep.a_delay = m_crpt->tcb_delay / 4;
327 if (m_crpt->tcb_sync == FrameSyncInternalTest) {
328 daep.a_sync = 1;
329 } else {
330 daep.a_sync = 0; // external
331 }
332 // two time regime mods
333 if (m_crpt->ntrg > 1) {
334 daep.n_tr_shift = m_crpt->ntrg;
335 for (i = 0; i < m_crpt->ntrg; i++) {
336 daep.tr_shift[i] = m_crpt->tcb_trdelay[i];
337 }
338 } else {
339 daep.n_tr_shift = 0;
340 }
341 crat = m_crpt->crat; // crate number for each detector (size NDET)
342 modn = m_crpt->modn; // module number for each detector (size NDET)
343 mpos = m_crpt->mpos; // module position for each detector (size NDET)
344 timr = m_crpt->timr; // time regime for each detector (size NDET)
345 udet = m_crpt->udet; // user detector number for each detector (size NDET)
346 // section 6
347 ver6 = 1; // TCB section version number (=1)
348 t_ntrg = 1; // number of time regimes (=1)
349 t_nfpp = 1; // number of frames per period
350 t_nper = m_crpt->nper_daq; // number of periods
351 for (i = 0; i < 256; i++) {
352 t_pmap[i] = 1; // period number for each basic period
353 }
354 t_nsp1 = m_crpt->nsp1; // number of spectra in time regime 1
355 t_ntc1 = m_crpt->ntc1; // number of time channels in time regime 1
356 // TODO
357 memset(t_tcm1, 0, sizeof(t_tcm1)); // time channel mode
358 memset(t_tcp1, 0, sizeof(t_tcp1)); // time channel parameters
359 t_pre1 = 1; // prescale for 32MHz clock
360 t_tcb1 = m_crpt->tcb1; // time channel boundaries in clock pulses (size NTC1+1)
361 // section 7
362 // write NCHAN = NTC1+1 time channel boundaries
363 ver7 = 1; // user version number (=1)
364 u_len = 1;
365 delete[] u_dat;
366 u_dat = new float[u_len]; // user defined data (ULEN, max size 400 words)
367 for (i = 0; i < u_len; i++) {
368 u_dat[i] = (float)i;
369 }
370 // section 8
371 ver8 = 2; // data version number (=2)
372 // D_DATA points at ddes
373 if ((t_nsp1 != m_nsp1) || (t_nper != m_nper)) {
374 delete[] ddes;
375 ddes = new DDES_STRUCT[(t_nsp1 + 1) * t_nper]; // (NSP1+1)*NPER items,
376 // totoal size
377 // (NSP1+1)*NPER*2*4 bytes
378 }
379 dat1 = (uint32_t *)m_crpt->raw_data;
380 if (m_crpt->log_nlines > 0) {
381 logsect.nlines = m_crpt->log_nlines;
382 delete[] logsect.lines;
384 for (i = 0; i < logsect.nlines; i++) {
385 logsect.lines[i].data = &(m_crpt->log_data[i][0]);
386 logsect.lines[i].len = strlen(logsect.lines[i].data);
387 }
388 } else {
389 logsect.nlines = 0;
390 logsect.lines = NULL;
391 }
392 // for caching on updates
393 m_ntc1 = t_ntc1;
394 m_nsp1 = t_nsp1;
395 m_nper = t_nper;
396 return 0;
397#endif /* REAL_CRPT */
398}
399
401int ISISRAW::ioRAW(FILE *file, bool from_file, bool read_data) {
402 int ndata, len_log, i;
403 fpos_t add_pos, dhdr_pos, keep_pos;
404 if (!from_file) {
405 add.ad_run = 32;
406 add.ad_inst = add.ad_run + 94;
407 add.ad_se = add.ad_inst + 70 + 2 * i_mon + (5 + i_use) * i_det;
408 add.ad_dae = add.ad_se + 66 + e_nse * 32;
409 add.ad_tcb = add.ad_dae + 65 + 5 * i_det;
410 add.ad_user = add.ad_tcb + 288 + (t_ntc1 + 1);
411 add.ad_data = add.ad_user + 2 + u_len;
412 add.ad_log = 0; // we don't know it yet
413 add.ad_end = 0;
414 }
415 ioRAW(file, &hdr, 1, from_file);
416 ioRAW(file, &frmt_ver_no, 1, from_file);
417 fgetpos(file, &add_pos);
418 ioRAW(file, &add, 1, from_file);
419 ioRAW(file, &data_format, 3, from_file);
420 ioRAW(file, r_title, 80, from_file);
421 ioRAW(file, &user, 1, from_file);
422 ioRAW(file, &rpb, 1, from_file);
423 ioRAW(file, &ver3, 1, from_file);
424 ioRAW(file, i_inst, 8, from_file);
425 ioRAW(file, &ivpb, 1, from_file);
426 ioRAW(file, &i_det, 3, from_file);
427 ioRAW(file, &mdet, i_mon, from_file);
428 ioRAW(file, &monp, i_mon, from_file);
429 ioRAW(file, &spec, i_det, from_file);
430 ioRAW(file, &delt, i_det, from_file);
431 ioRAW(file, &len2, i_det, from_file);
432 ioRAW(file, &code, i_det, from_file);
433 ioRAW(file, &tthe, i_det, from_file);
434 ioRAW(file, &ut, i_use * i_det, from_file);
435 ioRAW(file, &ver4, 1, from_file);
436 ioRAW(file, &spb, 1, from_file);
437 ioRAW(file, &e_nse, 1, from_file);
438 ioRAW(file, &e_seblock, e_nse, from_file);
439 ioRAW(file, &ver5, 1, from_file);
440 ioRAW(file, &daep, 1, from_file);
441 ioRAW(file, &crat, i_det, from_file);
442 ioRAW(file, &modn, i_det, from_file);
443 ioRAW(file, &mpos, i_det, from_file);
444 ioRAW(file, &timr, i_det, from_file);
445 ioRAW(file, &udet, i_det, from_file);
446 ioRAW(file, &ver6, 267, from_file);
447 ioRAW(file, &(t_tcp1[0][0]), 20, from_file);
448 ioRAW(file, &t_pre1, 1, from_file);
449 ioRAW(file, &t_tcb1, t_ntc1 + 1, from_file);
450 ioRAW(file, &ver7, 1, from_file);
451 // it appear that the VMS ICP traditionally sets u_len to 1 regardless
452 // of its real size; thus we cannot rely on it for reading and must instead
453 // use section offsets
454 i = 0;
455 ioRAW(file, &i, 1, from_file);
456 // ioRAW(file, &u_len, 1, from_file);
457 if (from_file) {
458 u_len = add.ad_data - add.ad_user - 2;
459
460 if (u_len < 0 || (add.ad_data < add.ad_user + 2)) {
461 // this will/would be used for memory allocation
462 logger.error() << "Error in u_len value read from file, it would be " << u_len
463 << "; where it is calculated as "
464 "u_len = ad_data - ad_user - 2, where ad_data: "
465 << add.ad_data << ", ad_user: " << add.ad_user << '\n';
466 return 0;
467 }
468 }
469
470 ioRAW(file, &u_dat, u_len, from_file);
471 ioRAW(file, &ver8, 1, from_file);
472 fgetpos(file, &dhdr_pos);
473 ioRAW(file, &dhdr, 1, from_file);
474 int ndes, nout, nwords, outbuff_size = 100000, offset;
475 auto outbuff = new char[outbuff_size];
476 if (!read_data) {
477 ndes = ndata = 0;
478 dat1 = nullptr;
479 // seek to position right after the data if we want to read the log
480 if (from_file) {
481 ndes = t_nper * (t_nsp1 + 1);
482 ioRAW(file, &ddes, ndes, from_file);
483 for (i = 0; i < ndes; i++) {
484 int zero = fseek(file, 4 * ddes[i].nwords, SEEK_CUR);
485 if (0 != zero)
486 logger.error() << "Failed to seek position in file for index: " << i << "\n";
487 }
488 }
489 } else if (dhdr.d_comp == 0) {
490 ndata = t_nper * (t_nsp1 + 1) * (t_ntc1 + 1);
491 ndes = 0;
492 ioRAW(file, &dat1, ndata, from_file);
493 } else {
494 ndata = 0;
495 ndes = t_nper * (t_nsp1 + 1);
496 ioRAW(file, &ddes, ndes, from_file);
497 if (from_file) {
498 dat1 = new uint32_t[ndes * (t_ntc1 + 1)];
499 }
500 offset = 33 + ndes * 2;
501 memset(outbuff, 0,
502 outbuff_size); // so when we round up words we get a zero written
503 for (i = 0; i < ndes; i++) {
504 if (from_file) {
505 nwords = ddes[i].nwords;
506 ioRAW(file, outbuff, 4 * nwords, from_file);
507 byte_rel_expn(outbuff, 4 * nwords, 0, reinterpret_cast<int *>(&dat1[i * (t_ntc1 + 1)]), t_ntc1 + 1);
508 } else {
509 byte_rel_comp(reinterpret_cast<int *>(&dat1[i * (t_ntc1 + 1)]), t_ntc1 + 1, outbuff, outbuff_size, nout);
510 nwords = (3 + nout) / 4; // round up to words
511 ddes[i].nwords = nwords;
512 ddes[i].offset = offset + ndata;
513 ndata += nwords;
514 ioRAW(file, outbuff, 4 * nwords, from_file);
515 }
516 }
517 }
518 delete[] outbuff;
519 // log section
520 ioRAW(file, &logsect, 1, from_file);
521 len_log = 2 + logsect.nlines;
522 for (i = 0; i < logsect.nlines; i++) {
523 len_log += (1 + (logsect.lines[i].len - 1) / 4);
524 }
525 if (!from_file) {
526 add.ad_log = add.ad_data + 33 + 2 * ndes + ndata;
527 add.ad_end = add.ad_log + len_log;
528 int curr_data_size = add.ad_log - add.ad_data;
529 int uncomp_data_size = 33 + t_nper * (t_nsp1 + 1) * (t_ntc1 + 1);
530 int curr_filesize = add.ad_end - 1;
531 int uncomp_filesize = add.ad_data - 1 + uncomp_data_size + len_log;
532 dhdr.d_crdata = static_cast<float>(uncomp_data_size) / static_cast<float>(curr_data_size);
533 dhdr.d_crfile = static_cast<float>(uncomp_filesize) / static_cast<float>(curr_filesize);
534 dhdr.d_exp_filesize = uncomp_filesize / 128; // in 512 byte blocks (vms default allocation unit)
535 int zero = fgetpos(file, &keep_pos);
536 if (!zero) {
537 logger.error() << "Error when getting file position: " << strerror(errno) << '\n';
538 return -1;
539 }
540
541 // update section addresses
542 zero = fsetpos(file, &add_pos);
543 if (!zero) {
544 logger.error() << "Error when setting file position: " << strerror(errno) << '\n';
545 return -1;
546 }
547
548 ioRAW(file, &add, 1, from_file);
549 // update data header and descriptors etc.
550 zero = fsetpos(file, &dhdr_pos);
551 if (!zero) {
552 logger.error() << "Error when setting file position to header: " << strerror(errno) << '\n';
553 return -1;
554 }
555
556 ioRAW(file, &dhdr, 1, from_file);
557 ioRAW(file, &ddes, ndes, from_file);
558 zero = fsetpos(file, &keep_pos);
559 if (!zero) {
560 logger.error() << "Error when restoring file position: " << strerror(errno) << '\n';
561 return -1;
562 }
563 }
564 return 0;
565}
566
568int ISISRAW::ioRAW(FILE *file, HDR_STRUCT *s, int len, bool from_file) {
569 ioRAW(file, reinterpret_cast<char *>(s), sizeof(HDR_STRUCT) * len, from_file);
570 return 0;
571}
572
574int ISISRAW::ioRAW(FILE *file, ADD_STRUCT *s, int len, bool from_file) {
575 ioRAW(file, reinterpret_cast<int *>(s), (sizeof(ADD_STRUCT) * len / sizeof(int)), from_file);
576 return 0;
577}
578
580int ISISRAW::ioRAW(FILE *file, USER_STRUCT *s, int len, bool from_file) {
581 ioRAW(file, reinterpret_cast<char *>(s), sizeof(USER_STRUCT) * len, from_file);
582 return 0;
583}
584
586int ISISRAW::ioRAW(FILE *file, RPB_STRUCT *s, int len, bool from_file) {
587 int i;
588 for (i = 0; i < len; i++) {
589 ioRAW(file, &(s[i].r_dur), 7, from_file);
590 ioRAW(file, &(s[i].r_gd_prtn_chrg), 2, from_file);
591 ioRAW(file, &(s[i].r_goodfrm), 7, from_file);
592 ioRAW(file, s[i].r_enddate, 20, from_file);
593 ioRAW(file, &(s[i].r_prop), 11, from_file);
594 }
595 return 0;
596}
597
599int ISISRAW::ioRAW(FILE *file, IVPB_STRUCT *s, int len, bool from_file) {
600 int i;
601 for (i = 0; i < len; i++) {
602 ioRAW(file, &(s[i].i_chfreq), 3, from_file);
603 ioRAW(file, &(s[i].delay_c1), 14, from_file);
604 ioRAW(file, &(s[i].i_xsect), 2, from_file);
605 ioRAW(file, &(s[i].i_posn), 3, from_file);
606 ioRAW(file, &(s[i].i_l1), 1, from_file);
607 ioRAW(file, &(s[i].i_rfreq), 1, from_file);
608 ioRAW(file, &(s[i].i_renergy), 2, from_file);
609 ioRAW(file, &(s[i].i_rslit), 2, from_file);
610 ioRAW(file, &(s[i].i_xcen), 2, from_file);
611 ioRAW(file, &(s[i].i_bestop), 1, from_file);
612 ioRAW(file, &(s[i].i_radbest), 4, from_file);
613 ioRAW(file, s[i].spare, 29, from_file);
614 }
615 return 0;
616}
617
619int ISISRAW::ioRAW(FILE *file, SPB_STRUCT *s, int len, bool from_file) {
620 int i;
621 for (i = 0; i < len; i++) {
622 ioRAW(file, &(s[i].e_posn), 3, from_file);
623 ioRAW(file, &(s[i].e_thick), 16, from_file);
624 ioRAW(file, s[i].e_name, 40, from_file);
625 ioRAW(file, &(s[i].e_equip), 35, from_file);
626 }
627 return 0;
628}
629
631int ISISRAW::ioRAW(FILE *file, SE_STRUCT *s, int len, bool from_file) {
632 int i;
633 for (i = 0; i < len; i++) {
634 ioRAW(file, s[i].sep_name, 8, from_file);
635 ioRAW(file, &(s[i].sep_value), 2, from_file);
636 ioRAW(file, s[i].sep_units, 8, from_file);
637 ioRAW(file, &(s[i].sep_low_trip), 7, from_file);
638 ioRAW(file, &(s[i].sep_stable), 2, from_file);
639 ioRAW(file, &(s[i].sep_cam_addr), 17, from_file);
640 }
641 return 0;
642}
643
645int ISISRAW::ioRAW(FILE *file, DAEP_STRUCT *s, int len, bool from_file) {
646 ioRAW(file, reinterpret_cast<int *>(s), sizeof(DAEP_STRUCT) * len / sizeof(int), from_file);
647 return 0;
648}
649
651int ISISRAW::ioRAW(FILE *file, DHDR_STRUCT *s, int len, bool from_file) {
652 int i;
653 for (i = 0; i < len; i++) {
654 ioRAW(file, &(s[i].d_comp), 3, from_file);
655 ioRAW(file, &(s[i].d_crdata), 2, from_file);
656 ioRAW(file, &(s[i].d_exp_filesize), 27, from_file);
657 }
658 return 0;
659}
660
662int ISISRAW::ioRAW(FILE *file, DDES_STRUCT *s, int len, bool from_file) {
663 int i;
664 for (i = 0; i < len; i++) {
665 ioRAW(file, &(s[i].nwords), 2, from_file);
666 }
667 return 0;
668}
669
671int ISISRAW::ioRAW(FILE *file, LOG_STRUCT *s, int len, bool from_file) {
672 int i;
673 for (i = 0; i < len; i++) {
674 ioRAW(file, &(s[i].ver), 2, from_file);
675 ioRAW(file, &(s[i].lines), s[i].nlines, from_file);
676 }
677 return 0;
678}
679
681int ISISRAW::ioRAW(FILE *file, LOG_LINE *s, int len, bool from_file) {
682 char padding[5];
683 memset(padding, ' ', sizeof(padding));
684 int i;
685 for (i = 0; i < len; i++) {
686 ioRAW(file, &(s[i].len), 1, from_file);
687 int nbytes_rounded = 4 * (1 + (s[i].len - 1) / 4);
688 ioRAW(file, &(s[i].data), s[i].len, from_file);
689 ioRAW(file, padding, nbytes_rounded - s[i].len, from_file);
690 }
691 return 0;
692}
693
695int ISISRAW::ioRAW(FILE *file, char *s, int len, bool from_file) {
696 if ((len <= 0) || (s == nullptr)) {
697 return 0;
698 }
699
700 if (from_file) {
701 size_t n = fread(s, sizeof(char), len, file);
702 return static_cast<int>(n - len);
703 } else {
704 fwrite(s, sizeof(char), len, file);
705 }
706
707 return 0;
708}
709
711int ISISRAW::ioRAW(FILE *file, int *s, int len, bool from_file) {
712 if ((len <= 0) || (s == nullptr)) {
713 return 0;
714 }
715
716 if (from_file) {
717 size_t n = fread(s, sizeof(int), len, file);
718 return static_cast<int>(n - len);
719 } else {
720 fwrite(s, sizeof(int), len, file);
721 }
722
723 return 0;
724}
725
727int ISISRAW::ioRAW(FILE *file, uint32_t *s, int len, bool from_file) {
728 if ((len <= 0) || (s == nullptr)) {
729 return 0;
730 }
731
732 if (from_file) {
733 size_t n = fread(s, sizeof(uint32_t), len, file);
734 return static_cast<int>(n - len);
735 } else {
736 fwrite(s, sizeof(uint32_t), len, file);
737 }
738 return 0;
739}
740
742int ISISRAW::ioRAW(FILE *file, float *s, int len, bool from_file) {
743 int errcode = 0;
744 if ((len <= 0) || (s == nullptr)) {
745 return 0;
746 }
747
748 if (from_file) {
749 size_t n = fread(s, sizeof(float), len, file);
750 vaxf_to_local(s, &len, &errcode);
751 return static_cast<int>(n - len);
752 } else {
753 local_to_vaxf(s, &len, &errcode);
754 fwrite(s, sizeof(float), len, file);
755 vaxf_to_local(s, &len, &errcode);
756 }
757 return 0;
758}
759
761int ISISRAW::ioRAW(FILE *file, char **s, int len, bool from_file) {
762 if (from_file) {
763 if (len > 0) {
764 delete[] * s;
765 *s = new char[len];
766 ioRAW(file, *s, len, from_file);
767 } else {
768 *s = nullptr;
769 }
770 } else {
771 if (*s != nullptr) {
772 ioRAW(file, *s, len, from_file);
773 }
774 }
775 return 0;
776}
777
779int ISISRAW::ioRAW(FILE *file, int **s, int len, bool from_file) {
780 if (from_file) {
781 if (len > 0) {
782 delete[] * s;
783 *s = new int[len];
784 ioRAW(file, *s, len, from_file);
785 } else {
786 *s = nullptr;
787 }
788 } else {
789 if (*s != nullptr) {
790 ioRAW(file, *s, len, from_file);
791 }
792 }
793 return 0;
794}
795
797int ISISRAW::ioRAW(FILE *file, uint32_t **s, int len, bool from_file) {
798 if (from_file) {
799 if (len > 0) {
800 delete[] * s;
801 *s = new uint32_t[len];
802 ioRAW(file, *s, len, from_file);
803 } else {
804 *s = nullptr;
805 }
806 } else {
807 if (*s != nullptr) {
808 ioRAW(file, *s, len, from_file);
809 }
810 }
811 return 0;
812}
813
815int ISISRAW::ioRAW(FILE *file, float **s, int len, bool from_file) {
816 if (from_file) {
817 if (len > 0) {
818 delete[] * s;
819 *s = new float[len];
820 ioRAW(file, *s, len, from_file);
821 } else {
822 *s = nullptr;
823 }
824 } else {
825 if (*s != nullptr) {
826 ioRAW(file, *s, len, from_file);
827 }
828 }
829 return 0;
830}
831
833int ISISRAW::ioRAW(FILE *file, SE_STRUCT **s, int len, bool from_file) {
834 if (from_file) {
835 if (len > 0) {
836 delete[] * s;
837 *s = new SE_STRUCT[len];
838 ioRAW(file, *s, len, from_file);
839 } else {
840 *s = nullptr;
841 }
842 } else {
843 if (*s != nullptr) {
844 ioRAW(file, *s, len, from_file);
845 }
846 }
847 return 0;
848}
849
851int ISISRAW::ioRAW(FILE *file, DDES_STRUCT **s, int len, bool from_file) {
852 if (from_file) {
853 if (len > 0) {
854 delete[] * s;
855 *s = new DDES_STRUCT[len];
856 ioRAW(file, *s, len, from_file);
857 } else {
858 *s = nullptr;
859 }
860 } else {
861 if (*s != nullptr) {
862 ioRAW(file, *s, len, from_file);
863 }
864 }
865 return 0;
866}
867
869int ISISRAW::ioRAW(FILE *file, LOG_LINE **s, int len, bool from_file) {
870 if (from_file) {
871 if (len > 0) {
872 delete[] * s;
873 *s = new LOG_LINE[len];
874 ioRAW(file, *s, len, from_file);
875 } else {
876 *s = nullptr;
877 }
878 } else {
879 if (*s != nullptr) {
880 ioRAW(file, *s, len, from_file);
881 }
882 }
883 return 0;
884}
885
888 static int size_check_array[] = {sizeof(HDR_STRUCT), 80, sizeof(ADD_STRUCT), 9 * 4,
889 sizeof(USER_STRUCT), 8 * 20, sizeof(RPB_STRUCT), 32 * 4,
890 sizeof(IVPB_STRUCT), 64 * 4, sizeof(SPB_STRUCT), 64 * 4,
891 sizeof(SE_STRUCT), 32 * 4, sizeof(DAEP_STRUCT), 64 * 4,
892 sizeof(DHDR_STRUCT), 32 * 4, sizeof(DDES_STRUCT), 2 * 4};
893 for (unsigned i = 0; i < sizeof(size_check_array) / sizeof(int); i += 2) {
894 if (size_check_array[i] != size_check_array[i + 1]) {
895 logger.error() << "size check failed\n";
896 }
897 }
898 return 0;
899}
901int ISISRAW::vmstime(char *timbuf, int len, time_t time_value) {
902 /*
903 * get time in VMS format 01-JAN-1970 00:00:00
904 */
905 size_t i, n;
906 struct tm *tmstruct = nullptr;
907#ifdef MS_VISUAL_STUDIO
908 errno_t err = localtime_s(tmstruct, &time_value);
909 if (err) {
910 return FAILURE;
911 }
912#else //_WIN32
913 tmstruct = localtime(&time_value);
914#endif //_WIN32
915 n = strftime(timbuf, len, "%d-%b-%Y %H:%M:%S", tmstruct);
916 for (i = 0; i < n; i++) {
917 timbuf[i] = toupper(timbuf[i]);
918 }
919 return SUCCESS;
920}
921
923int ISISRAW::readFromFile(const char *filename, bool read_data) {
924#ifdef MS_VISUAL_STUDIO
925 FILE *input_file = NULL;
926 if (fopen_s(&input_file, filename, "rb") != 0) {
927 return -1;
928 }
929#else //_WIN32
930 FILE *input_file = fopen(filename, "rb");
931#endif //_WIN32
932 if (input_file != nullptr) {
933 ioRAW(input_file, true, read_data);
934 fclose(input_file);
935 return 0;
936 } else {
937 return -1;
938 }
939}
940
942int ISISRAW::printInfo(std::ostream &os) {
943 int i;
944 os << "INST section at " << add.ad_inst << " 0x" << std::hex << 4 * add.ad_inst << std::dec << '\n';
945 os << "SE section at " << add.ad_se << " 0x" << std::hex << 4 * add.ad_se << std::dec << '\n';
946 os << "Dae section at " << add.ad_dae << " 0x" << std::hex << 4 * add.ad_dae << std::dec << '\n';
947 os << "Tcb section at " << add.ad_tcb << " 0x" << std::hex << 4 * add.ad_tcb << std::dec << '\n';
948 os << "User section at " << add.ad_user << " 0x" << std::hex << 4 * add.ad_user << std::dec << '\n';
949 os << "Data section at " << add.ad_data << " 0x" << std::hex << 4 * add.ad_data << std::dec << '\n';
950 os << "Log section at " << add.ad_log << " 0x" << std::hex << 4 * add.ad_log << std::dec << '\n';
951 os << "End section at " << add.ad_end << " 0x" << std::hex << 4 * add.ad_end << std::dec << '\n';
952 os << "User data len " << u_len << '\n';
953 os << "Compression is " << (dhdr.d_comp == 0 ? "NONE" : "BYTE-RELATIVE") << '\n';
954 os << "Compression ratio of data = " << dhdr.d_crdata << '\n';
955 os << "Offsets of spectrum data\n";
956 for (i = 0; i < ((t_nsp1 + 1) * t_nper); i++) {
957 os << i << " " << ddes[i].nwords << " words at offset " << ddes[i].offset << '\n';
958 }
959 return 0;
960}
961
964 delete[] dat1;
965 delete[] ut;
966 delete[] mdet;
967 delete[] monp;
968 delete[] spec;
969 delete[] delt;
970 delete[] len2;
971 delete[] code;
972 delete[] tthe;
973 delete[] e_seblock;
974 delete[] crat;
975 delete[] modn;
976 delete[] mpos;
977 delete[] timr;
978 delete[] udet;
979 delete[] t_tcb1;
980 delete[] u_dat;
981 delete[] ddes;
982 for (int i = 0; i < logsect.nlines; i++) {
983 delete[] logsect.lines[i].data;
984 }
985 delete[] logsect.lines;
986}
987
989int ISISRAW::getTimeChannels(float *rtcb1, int n) {
990 if (n != t_ntc1 + 1) {
991 return -1;
992 }
993 float extra;
994 if (frmt_ver_no > 1) {
995 extra = float(4.0) * daep.a_delay; // add on frame sync delay
996 } else {
997 extra = 0.0; // old files did not have this
998 }
999 int i;
1000 for (i = 0; i < t_ntc1 + 1; i++) {
1001 rtcb1[i] = t_tcb1[i] * t_pre1 / float(32.0) + extra;
1002 }
1003 return 0;
1004}
int byte_rel_expn(const char *data_in, int n_in, int n_from, int *data_out, int n_out)
#define FAILURE
#define SUCCESS
int byte_rel_comp(const int *data_in, int n_in, char *data_out, int max_out, int &n_out)
HDR_STRUCT hdr
header block (80 bytes)
Definition: isisraw.h:282
float * ut
nuse UT* user tables (total size NUSE*NDET) ut01=phi
Definition: isisraw.h:307
LOG_STRUCT logsect
log section
Definition: isisraw.h:347
ISISCRPT_STRUCT * m_crpt
CRPT from ICP.
Definition: isisraw.h:274
int t_tcm1[5]
time channel mode
Definition: isisraw.h:331
int i_use
number of user defined UTn tables NUSE
Definition: isisraw.h:298
SPB_STRUCT spb
sample parameter block (64*4 bytes)
Definition: isisraw.h:310
float * delt
hold off table (size NDET)
Definition: isisraw.h:303
int * modn
module number for each detector (size NDET)
Definition: isisraw.h:319
float t_tcp1[5][4]
time channel parameters
Definition: isisraw.h:332
int e_nse
number of controlled SEPs NSEP
Definition: isisraw.h:311
int getTimeChannels(float *rtcb1, int n)
rtcb1 is of size t_ntc1+1
Definition: isisraw.cpp:989
char i_inst[8]
instrument name
Definition: isisraw.h:294
uint32_t * dat1
compressed data for (NTC1+1)*(NSP1+1)*NPER values
Definition: isisraw.h:346
int ver2
run section version number VER2 (=1)
Definition: isisraw.h:287
ISISRAW()
stuff
Definition: isisraw.cpp:23
int t_ntrg
number of time regimes (=1)
Definition: isisraw.h:325
int i_det
number of detectors NDET
Definition: isisraw.h:296
DAEP_STRUCT daep
DAE parameter block (size 64*4 bytes)
Definition: isisraw.h:316
DDES_STRUCT * ddes
(NSP1+1)*NPER items, totoal size (NSP1+1)*NPER*2*4 bytes
Definition: isisraw.h:345
int * code
code for UTn tables (size NDET)
Definition: isisraw.h:305
int t_nper
number of periods
Definition: isisraw.h:327
DHDR_STRUCT dhdr
size 32*4 bytes
Definition: isisraw.h:342
int printInfo(std::ostream &os)
stuff
Definition: isisraw.cpp:942
int * t_tcb1
time channel boundaries in clock pulses (size NTC1+1)
Definition: isisraw.h:334
int t_nsp1
number of spectra in time regime 1
Definition: isisraw.h:329
int * mdet
detector number for monitors (size NMON)
Definition: isisraw.h:300
int ver3
instrument section version number (=2)
Definition: isisraw.h:293
static int vmstime(char *timbuf, int len, time_t time_value)
stuff
Definition: isisraw.cpp:901
item_struct< char > m_char_items
dunno
Definition: isisraw.h:275
int readFromFile(const char *filename, bool read_data=true)
stuff
Definition: isisraw.cpp:923
item_struct< float > m_real_items
dunno
Definition: isisraw.h:276
int ver5
DAE section version number (=2)
Definition: isisraw.h:315
int ver7
user version number (=1)
Definition: isisraw.h:337
int * timr
time regime for each detector (size NDET)
Definition: isisraw.h:321
USER_STRUCT user
user information (8*20 bytes)
Definition: isisraw.h:290
int addItems()
stuff
Definition: isisraw.cpp:131
int updateFromCRPT()
stuff
Definition: isisraw.cpp:189
int i_mon
number of monitors NMON
Definition: isisraw.h:297
int * crat
crate number for each detector (size NDET)
Definition: isisraw.h:318
int size_check()
stuff
Definition: isisraw.cpp:887
virtual int ioRAW(FILE *file, bool from_file, bool read_data=true)
stuff
Definition: isisraw.cpp:401
int ver4
SE section version number (=2)
Definition: isisraw.h:309
int ver8
data version number (=2)
Definition: isisraw.h:341
float * u_dat
user defined data (ULEN, max size 400 words)
Definition: isisraw.h:339
int data_format
data section format (0 = by TC, 1 = by spectrum)
Definition: isisraw.h:285
char r_title[80]
run title
Definition: isisraw.h:289
int r_number
run number
Definition: isisraw.h:288
int * mpos
module position for each detector (size NDET)
Definition: isisraw.h:320
int t_nfpp
number of frames per period
Definition: isisraw.h:326
int ver6
TCB section version number (=1)
Definition: isisraw.h:324
IVPB_STRUCT ivpb
instrument parameter block (64*4 bytes)
Definition: isisraw.h:295
int * udet
user detector number for each detector (size NDET)
Definition: isisraw.h:322
int * monp
prescale value for each monitor (size NMON)
Definition: isisraw.h:301
int u_len
length of user data section
Definition: isisraw.h:338
RPB_STRUCT rpb
run parameter block (32*4 bytes)
Definition: isisraw.h:291
int * spec
spectrum number table (size NDET)
Definition: isisraw.h:302
SE_STRUCT * e_seblock
NSEP SE parameter blocks (total size NSEP*32*4 bytes)
Definition: isisraw.h:313
struct ADD_STRUCT add
9*4 bytes
Definition: isisraw.h:284
virtual ~ISISRAW()
stuff
Definition: isisraw.cpp:963
int t_ntc1
number of time channels in time regime 1
Definition: isisraw.h:330
float * tthe
2theta scattering angle (size NDET)
Definition: isisraw.h:306
float * len2
L2 table (size NDET)
Definition: isisraw.h:304
item_struct< int > m_int_items
dunno
Definition: isisraw.h:277
int t_pre1
prescale for 32MHz clock
Definition: isisraw.h:333
int t_pmap[256]
period number for each basic period
Definition: isisraw.h:328
int frmt_ver_no
format version number VER1 (=2)
Definition: isisraw.h:283
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
int addItem(const std::string &name, const T *value, bool det_average=false, const int *dim0=nullptr, const int *dim1=nullptr)
Adds an item.
Definition: item_struct.h:45
ISIS VMS raw file definitions.
address offsets to various sections (9*4 bytes)
Definition: isisraw.h:35
int ad_dae
ad_se + 66 + nse*32
Definition: isisraw.h:39
int ad_user
ad_tcb + 288 + (ntc1 + 1)
Definition: isisraw.h:41
int ad_data
ad_user + 2 + ulen
Definition: isisraw.h:42
int ad_tcb
ad_dae + 65 + 5*ndet
Definition: isisraw.h:40
int ad_run
32 (1+offset_of(ver2))
Definition: isisraw.h:36
int ad_end
1+end of file
Definition: isisraw.h:44
int ad_inst
ad_run + 94
Definition: isisraw.h:37
int ad_log
ad_data + 33 +
Definition: isisraw.h:43
int ad_se
ad_inst + 70 + 2*nmon+(5+nuse)*ndet
Definition: isisraw.h:38
DAE parameters block (64*4 bytes)
Definition: isisraw.h:189
int mon1_module
module for MON 1 ( 4 bits) ***B
Definition: isisraw.h:204
int a_pars
Word length in bulk store memory.
Definition: isisraw.h:190
int mon1_mask
mask for MON 1 (c4:m4:d12) ***B
Definition: isisraw.h:206
int tr_shift[3]
set to shift value (us) of each TR if (using_tr_shift >
Definition: isisraw.h:220
int ppp_raw_low
raw PPP total (low 32 bits) ***B
Definition: isisraw.h:196
int ext_vetos[3]
External vetoes 0,1,2 (0 dis,1.
Definition: isisraw.h:216
int a_delay
frame synch delay (4�s steps) ***B
Definition: isisraw.h:213
int mon2_crate
crate for MON 2 ( 4 bits) ***B
Definition: isisraw.h:209
int ppp_good_high
good PPP total (high 32 bits) ***B
Definition: isisraw.h:193
int mon1_crate
crate for MON 1 ( 4 bits) ***B
Definition: isisraw.h:205
int ppp_good_low
good PPP total (low 32 bits) ***B
Definition: isisraw.h:194
int a_sync
frm snch origin(0:none/1:ext/2:int)***B
Definition: isisraw.h:214
int mem_size
Length of bulk store memory (bytes)**A.
Definition: isisraw.h:191
int ppp_raw_high
raw PPP total (high 32 bits) ***B
Definition: isisraw.h:195
int mon2_mask
mask for MON 2 (c4:m4:d12) ***B
Definition: isisraw.h:210
int n_tr_shift
en)
Definition: isisraw.h:219
int mon2_detector
detector for MON 2 (12 bits) ***B
Definition: isisraw.h:207
int mon2_module
module for MON 2 ( 4 bits) ***B
Definition: isisraw.h:208
int a_smp
Secondary Master Pulse (0:en,1:dis)
Definition: isisraw.h:215
int mon1_detector
detector for MON 1 (12 bits) ***B
Definition: isisraw.h:203
2*4 bytes
Definition: isisraw.h:246
int nwords
number of compressed words in spectrum
Definition: isisraw.h:247
int offset
offset to compressed spectrum
Definition: isisraw.h:248
data section header (32*4 bytes)
Definition: isisraw.h:228
int d_comp
compression type (0=none, 1 = byte relative)
Definition: isisraw.h:229
float d_crfile
compression ratio for whole file
Definition: isisraw.h:233
float d_crdata
compression ratio for data
Definition: isisraw.h:232
int d_exp_filesize
equivalent version 1 filesize
Definition: isisraw.h:234
Run header (80 bytes)
Definition: isisraw.h:22
char hd_date[12]
start date
Definition: isisraw.h:27
char hd_time[8]
start time
Definition: isisraw.h:28
char inst_abrv[3]
instrument abbreviated name
Definition: isisraw.h:23
char hd_dur[8]
run duration (uA.hour) constructor
Definition: isisraw.h:29
char hd_run[5]
run number
Definition: isisraw.h:24
char hd_user[20]
user name
Definition: isisraw.h:25
char hd_title[24]
short title
Definition: isisraw.h:26
instrument parameter block (64*4 bytes)
Definition: isisraw.h:90
float i_ycen
LOQ y centre.
Definition: isisraw.h:120
float i_xsect
beam aperture horizontal (mm)
Definition: isisraw.h:108
float i_chopsiz
dunno
Definition: isisraw.h:100
float i_aofi
angle of incidence (CRISP)
Definition: isisraw.h:125
float i_sddist
source to detector distance (LOQ)
Definition: isisraw.h:123
float i_l1
L1 scattering length.
Definition: isisraw.h:113
float i_xcen
LOQ x centre.
Definition: isisraw.h:119
float i_ysect
beam aperture vertical (mm)
Definition: isisraw.h:109
int i_bestop
beam_stop LOQ
Definition: isisraw.h:121
float i_foeang
foe angle LOQ
Definition: isisraw.h:124
log line entry
Definition: isisraw.h:254
int len
real length of data
Definition: isisraw.h:255
char * data
padded to multiple of 4 bytes
Definition: isisraw.h:256
log line entry
Definition: isisraw.h:262
LOG_LINE * lines
size nlines
Definition: isisraw.h:265
int nlines
number of lines
Definition: isisraw.h:264
Run parameter block (32*4 bytes)
Definition: isisraw.h:62
int r_dur_secs
actual run duration in seconds
Definition: isisraw.h:75
int r_freq
2**k where source frequency = 50 / 2**k
Definition: isisraw.h:69
int r_mon_sum2
monitor sum 2
Definition: isisraw.h:77
char r_endtime[8]
format HH-MM-SS
Definition: isisraw.h:80
char r_enddate[12]
format DD-MMM-YYYY
Definition: isisraw.h:79
int r_goodfrm
good frames
Definition: isisraw.h:72
int r_rawfrm
raw frames
Definition: isisraw.h:73
float r_gd_prtn_chrg
good proton charge (uA.hour)
Definition: isisraw.h:70
int r_durunits
scaler for above (1=seconds)
Definition: isisraw.h:64
int r_mon_sum1
monitor sum 1
Definition: isisraw.h:76
int r_mon_sum3
monitor sum 3
Definition: isisraw.h:78
int r_dur
actual run duration
Definition: isisraw.h:63
int r_prop
RB (proposal) number.
Definition: isisraw.h:81
float r_tot_prtn_chrg
total proton charge (uA.hour)
Definition: isisraw.h:71
sample environment block (32*4 bytes)
Definition: isisraw.h:163
sample parameter block (64*4 bytes)
Definition: isisraw.h:133
int e_type
sample type (1=sample+can,2=empty can)
Definition: isisraw.h:135
float e_width
sample width (mm)
Definition: isisraw.h:139
float e_phi
phi sample angle (degrees)
Definition: isisraw.h:142
int e_geom
sample geometry
Definition: isisraw.h:136
float e_height
sample height (mm)
Definition: isisraw.h:138
float e_thick
sample thickness normal to sample (mm)
Definition: isisraw.h:137
user information (8*20 bytes)
Definition: isisraw.h:50
char r_instit[20]
institute
Definition: isisraw.h:55
char r_user[20]
name
Definition: isisraw.h:51
void vaxf_to_local(float *val, const int *n, int *errcode)
void local_to_vaxf(float *val, const int *n, int *errcode)