ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcdcsFINFO.hpp
Go to the documentation of this file.
1
8#ifndef ngcdcsFINFO_H
9#define ngcdcsFINFO_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16#include <ngc/core/ngcb.h>
18#include <ngc/core/ngcbFITS.hpp>
19#include <ngc/core/ngcppInt.h>
21
25#define ngcdcsMAX_FRAME_TYPES ngcppMAX_FRAME_TYPES
26
30#define ngcdcsMAX_DET 32
31
37 int posX;
38
40 int posY;
41
43 int nx;
44
46 int ny;
47
50
53
56
58 int index;
59
62
64 int live;
65
68
71
73 int acqIdx;
74
76 double pixSpace;
77
79 double gain;
80
82 double outGain[64];
83
85 double ron;
86
88 double pszx;
89
91 double pszy;
92
94 double xgap;
95
97 double ygap;
98
100 double rgap;
101
103 char type[32];
104
106 char name[32];
107
109 char id[32];
110
112 char date[16];
113
115 explicit ngcdcs_chip_t(int n=0) {
116 int i;
117
118 index = n;
119 strcpy(type, "CHIP-TYPE");
120 strcpy(name, "CHIP-NAME");
121 strcpy(id, "CHIP-ID");
122 strcpy(date, "YYYY-MM-DD");
123 pixSpace = 1.0e-6;
124 gain = 1.0;
125 for (i=0;i<64;i++) outGain[i] = 0.0; // use global gain
126 ron = 0.0;
127 pszx = 1.0;
128 pszy = 1.0;
129 numOutput = 4;
130 pixPerChan = 0; // not set
131 xgap = 0.0;
132 ygap = 0.0;
133 rgap = 0.0;
134 rotAngle = 0;
135 live = 1;
136 posX = 1;
137 posY = 1;
138 nx = 256;
139 ny = 256;
140 adjustMode = 0;
141 adjustX = 1;
142 adjustY = 1;
143 acqIdx = 0; // auto-mapping
144 }
145};
146
152 int desc[4];
153
156
159 next = NULL;
160 memset(desc, 0, sizeof(desc));
161 }
162
165 if (next != NULL)
166 {
167 delete next; next = NULL;
168 }
169 }
170};
171
176public:
178 int size;
179
181 int ftype;
182
185
189 Init_();
190 }
191
193 explicit ngcdcs_cfile_list(int f) {
194 ftype = f;
195 Init_();
196 }
197
200 delete first_;
201 size = 0;
202 }
203
205 void Add(int pid, int id, int fcnt, int hcnt) {
206 int *e = entry->desc;
207 e[0] = pid; e[1] = id; e[2] = fcnt; e[3] = hcnt;
208 entry->next = new ngcdcs_cfile_t();
209 entry = entry->next;
210 size++;
211 }
212
214 void Add(const char *ref) {
215 int pid, id, fcnt, hcnt;
216 if (sscanf(ref, "%10d_%10d_%*d_%10d_%10d", &pid, &id, &fcnt, &hcnt) == 4)
217 {
218 Add(pid, id, fcnt, hcnt);
219 }
220 else if (sscanf(ref, "%10d_%10d_%*d_*_%10d", &pid, &id, &hcnt) == 3)
221 {
222 Add(pid, id, -1, hcnt);
223 }
224 }
225
227 const int *Entry(int n) {
228 if ((n < 0) || (n >= size))
229 {
230 return (NULL);
231 }
232 else
233 {
234 int i;
235 ngcdcs_cfile_t *e = first_;
236 for (i=0;i<n;i++) e = e->next;
237 return (e->desc);
238 }
239 }
240
242 void Entry2File(char *fileName, const int *e) {
243 if ((e[2] == -1) && (e[3] == -1))
244 {
245 sprintf(fileName, "%d_%d_%d_*_*.frm", e[0], e[1], ftype);
246 }
247 else
248 {
249 if (e[2] == -1)
250 {
251 sprintf(fileName, "%d_%d_%d_*_%d.frm", e[0], e[1], ftype, e[3]);
252 }
253 else if (e[3] == -1)
254 {
255 sprintf(fileName, "%d_%d_%d_%d_*.frm", e[0], e[1], ftype, e[2]);
256 }
257 else
258 {
259 sprintf(fileName, "%d_%d_%d_%d_%d.frm", e[0], e[1], ftype, e[2], e[3]);
260 }
261 }
262 }
263
265 void FileName(char *fileName, int n) {
266 const int *e = Entry(n);
267 if (e == NULL) fileName[0] = '\0';
268 else Entry2File(fileName, e);
269 }
270
271protected:
272private:
274 ngcdcs_cfile_t *first_;
275
277 void Init_() {
278 size = 0;
279 entry = new ngcdcs_cfile_t();
280 first_ = entry;
281 }
282};
283
288public:
290 FILE *fd;
291
294
296 int naxis2;
297
300
302 int bitPix;
303
306
308 double bscale;
309
311 double bzero;
312
314 int ndit;
315
317 int sx;
318
320 int sy;
321
323 double expFactor;
324
326 double timeStamp;
327
329 char fileName[512];
330
332 char frameName[64];
333
335 unsigned int cnt;
336
338 int fcnt;
339
341 int fcnt0;
342
345
347 char reference[64];
348
351
354
357
360 fd = NULL;
361 naxis1 = 0;
362 naxis2 = 0;
363 naxis3 = 0;
364 bitPix = 16;
365 divisor = 1;
366 bscale = 1.0;
367 bzero = 0.0;
368 ndit = 1;
369 sx = 1;
370 sy = 1;
371 expFactor = 1.0;
372 timeStamp = 0.0;
373 fileName[0] = '\0';
374 frameName[0] = '\0';
375 cnt = 0;
376 fcnt = 0;
377 fcnt0 = 0;
378 // cppcheck-suppress useInitializationList
379 truncate = -1;
380 reference[0] = '\0';
381 fileList = NULL;
382 stream = NULL;
383 }
384
387 Close();
388 }
389
392 return ((ngcb_off_t)naxis1 * (ngcb_off_t)naxis2 * (ngcb_off_t)(naxis3 * abs(bitPix/8)));
393 }
394
396 int Open(const char *path, const char *name) {
397 naxis3 = 0;
398 timeStamp = 0.0;
399 truncate = -1;
400 timestamps.Clear();
401 fd = ngcb_fopen(path, "w");
402 if (fd == NULL)
403 {
404 return (ngcbFAILURE);
405 }
406 else
407 {
408 char tmp[512];
409 strcpy(tmp, path);
410 strcpy(fileName, tmp);
411 strcpy(tmp, name);
412 strcpy(frameName, tmp);
413 return (ngcbSUCCESS);
414 }
415 }
416
418 void Close(int sync=0) {
419 if (stream != NULL)
420 {
421 delete stream; stream = NULL;
422 }
423 if (fd != NULL)
424 {
425 if (truncate >= 0)
426 {
427 int fno = fileno(fd);
428 if (fno >= 0) {fflush(fd); if (ngcb_ftruncate(fno, truncate) != 0);}
429 }
430
431 if (sync)
432 {
433 /*
434 * Flush to disk
435 */
436 if (fflush(fd) == 0)
437 {
438 int fno = fileno(fd);
439 if (fno >= 0) fsync(fno);
440 }
441 }
442
443 /*
444 * Close file
445 */
446 fclose(fd); fd = NULL;
447
448 if ((naxis3 <= 0) || (truncate == 0))
449 {
450 if (strlen(fileName) > 0)
451 {
452 /*
453 * Remove the file
454 */
455 remove(fileName); fileName[0] = '\0';
456 }
457 }
458 }
459 }
460
461protected:
462private:
463};
464
470 int type;
471
473 char name[64];
474
476 int fcnt;
477
479 double expFactor;
480
482 int bitPix;
483
486
488 double bscale;
489
491 double bzero;
492
494 int sx;
495
497 int sy;
498
500 int nx;
501
503 int ny;
504
506 double crpix1;
507
509 double crpix2;
510
512 int detIdx;
513
515 int expCnt;
516
518 int fcnt0;
519
521 int ndit;
522
524 int acq;
525
528
530 char utc[64];
531
533 char reference[64];
534
536 char where[512];
537
540
543
546
548 double timeStamp;
549
552
555
558 type = 0;
559 name[0] = '\0';
560 fcnt = 0;
561 fcnt0 = 0;
562 expFactor = 1.0;
563 bitPix = 16;
564 divisor = 1;
565 bscale = 1.0;
566 bzero = 0.0;
567 ndit = 1;
568 sx = 1;
569 sy = 1;
570 nx = 0;
571 ny = 0;
572 crpix1 = 0.0;
573 crpix2 = 0.0;
574 detIdx = 0;
575 expCnt = 0;
576 acq = 0;
577 utc[0] = '\0';
578 reference[0] = '\0';
579 where[0] = '\0';
580 appDataSize = 0;
581 appDataInline = 1;
582 memset(appData, 0, sizeof(appData));
583 recording = 0;
584 timeStamp = 0.0;
585 cube = NULL;
586 ehdr = NULL;
587 }
588};
589
590#endif
Timestamp binary table container class.
Definition ngcdcsTsTable.hpp:25
Definition ngcbFITS.hpp:25
Definition ngcbSTREAM.hpp:43
Definition ngcdcsFINFO.hpp:287
int bitPix
Bits per pixel as defined in the FITS-standard.
Definition ngcdcsFINFO.hpp:302
int naxis1
Dimension in x-direction.
Definition ngcdcsFINFO.hpp:293
~ngcdcsCUBE()
Destructor.
Definition ngcdcsFINFO.hpp:386
int sx
Lower left corner (x-direction)
Definition ngcdcsFINFO.hpp:317
unsigned int cnt
Cube counter.
Definition ngcdcsFINFO.hpp:335
FILE * fd
File descriptor.
Definition ngcdcsFINFO.hpp:290
int naxis2
Dimension in y-direction.
Definition ngcdcsFINFO.hpp:296
int fcnt0
Initial frame counter.
Definition ngcdcsFINFO.hpp:341
ngc::core::ngcdcs::TsTable timestamps
Timestamp container.
Definition ngcdcsFINFO.hpp:356
double bzero
Offset value to be added.
Definition ngcdcsFINFO.hpp:311
ngcb_off_t truncate
Truncate file.
Definition ngcdcsFINFO.hpp:344
void Close(int sync=0)
Close data cube.
Definition ngcdcsFINFO.hpp:418
int ndit
Number of integrations in pixel data.
Definition ngcdcsFINFO.hpp:314
int Open(const char *path, const char *name)
Open data cube.
Definition ngcdcsFINFO.hpp:396
double bscale
Scaling factor to be applied.
Definition ngcdcsFINFO.hpp:308
int divisor
Pixel divisor.
Definition ngcdcsFINFO.hpp:305
ngcb_off_t Size()
Cube data size.
Definition ngcdcsFINFO.hpp:391
int fcnt
Frame counter.
Definition ngcdcsFINFO.hpp:338
char frameName[64]
Frame type name for all images in the cube.
Definition ngcdcsFINFO.hpp:332
char reference[64]
Reference file.
Definition ngcdcsFINFO.hpp:347
ngcdcs_cfile_list * fileList
Cube file list on local storage media.
Definition ngcdcsFINFO.hpp:350
int sy
Lower left corner (y-direction)
Definition ngcdcsFINFO.hpp:320
int naxis3
Number of images.
Definition ngcdcsFINFO.hpp:299
double expFactor
Exposure time factor.
Definition ngcdcsFINFO.hpp:323
double timeStamp
MUDPI/RTMS timestamp of first frame.
Definition ngcdcsFINFO.hpp:326
char fileName[512]
Actual filename (full path)
Definition ngcdcsFINFO.hpp:329
ngcdcsCUBE()
Constructor.
Definition ngcdcsFINFO.hpp:359
ngcbSTREAM * stream
Streaming buffer.
Definition ngcdcsFINFO.hpp:353
Definition ngcdcsFINFO.hpp:175
int size
Number of entries.
Definition ngcdcsFINFO.hpp:178
int ftype
Frame type.
Definition ngcdcsFINFO.hpp:181
void Add(const char *ref)
Add file descriptor given by reference string.
Definition ngcdcsFINFO.hpp:214
const int * Entry(int n)
Return n'th entry.
Definition ngcdcsFINFO.hpp:227
~ngcdcs_cfile_list()
Destructor.
Definition ngcdcsFINFO.hpp:199
ngcdcs_cfile_list()
Constructor.
Definition ngcdcsFINFO.hpp:187
void FileName(char *fileName, int n)
Retrieve n'th file-name.
Definition ngcdcsFINFO.hpp:265
ngcdcs_cfile_t * entry
Entry.
Definition ngcdcsFINFO.hpp:184
void Add(int pid, int id, int fcnt, int hcnt)
Add file descriptor to list.
Definition ngcdcsFINFO.hpp:205
ngcdcs_cfile_list(int f)
Constructor with frame type.
Definition ngcdcsFINFO.hpp:193
void Entry2File(char *fileName, const int *e)
Convert list entry to file-name.
Definition ngcdcsFINFO.hpp:242
#define ngcb_fopen(p, m)
Definition ngcb.h:51
off_t ngcb_off_t
Definition ngcb.h:46
#define ngcb_ftruncate(s, o)
Definition ngcb.h:54
#define ngcbSUCCESS
Definition ngcb.h:138
#define ngcbFAILURE
Definition ngcb.h:140
Timestamp binary table container.
#define ngcppFRAME_NO_FRAME
Definition ngcppInt.h:232
#define ngcppAPP_HDR_SIZE
Definition ngcppInt.h:513
Definition ngcdcsFINFO.hpp:150
ngcdcs_cfile_t()
Constructor.
Definition ngcdcsFINFO.hpp:158
ngcdcs_cfile_t * next
Next entry.
Definition ngcdcsFINFO.hpp:155
~ngcdcs_cfile_t()
Destructor.
Definition ngcdcsFINFO.hpp:164
int desc[4]
File descriptor.
Definition ngcdcsFINFO.hpp:152
int adjustMode
Window adjustment mode (0=free, 1=center, ...)
Definition ngcdcsFINFO.hpp:49
double pixSpace
Pixel to pixel space (meter)
Definition ngcdcsFINFO.hpp:76
char type[32]
Detector type.
Definition ngcdcsFINFO.hpp:103
int live
Detector live (=1) or broken (=0)
Definition ngcdcsFINFO.hpp:64
int index
Unique index.
Definition ngcdcsFINFO.hpp:58
char date[16]
Installation date [YYYY-MM-DD].
Definition ngcdcsFINFO.hpp:112
int adjustY
Window adjustment step in y-direction.
Definition ngcdcsFINFO.hpp:55
double pszy
Size of pixel in y (um)
Definition ngcdcsFINFO.hpp:91
int nx
X-Dimension (in pixels)
Definition ngcdcsFINFO.hpp:43
int posY
Y-Position in mosaic.
Definition ngcdcsFINFO.hpp:40
int numOutput
Number of output channels.
Definition ngcdcsFINFO.hpp:67
double ygap
Gap between chips along y (um)
Definition ngcdcsFINFO.hpp:97
double pszx
Size of pixel in x (um)
Definition ngcdcsFINFO.hpp:88
int adjustX
Window adjustment step in x-direction.
Definition ngcdcsFINFO.hpp:52
int acqIdx
Acquisition module index.
Definition ngcdcsFINFO.hpp:73
int ny
Y-Dimension (in pixels)
Definition ngcdcsFINFO.hpp:46
char name[32]
Detector name.
Definition ngcdcsFINFO.hpp:106
int pixPerChan
Pixel per channel.
Definition ngcdcsFINFO.hpp:70
double outGain[64]
Gain per output (e-/ADU)
Definition ngcdcsFINFO.hpp:82
int rotAngle
Rotation angle of chip in mosaic (0, 90, 180, 270)
Definition ngcdcsFINFO.hpp:61
int posX
X-Position in mosaic.
Definition ngcdcsFINFO.hpp:37
ngcdcs_chip_t(int n=0)
Constructor.
Definition ngcdcsFINFO.hpp:115
double rgap
Angle of gap between chips (deg)
Definition ngcdcsFINFO.hpp:100
double gain
Gain (e-/ADU)
Definition ngcdcsFINFO.hpp:79
double ron
Read-out noise (e-)
Definition ngcdcsFINFO.hpp:85
double xgap
Gap between chips along x (um)
Definition ngcdcsFINFO.hpp:94
int fcnt0
Initial frame counter.
Definition ngcdcsFINFO.hpp:518
int divisor
Pixel divisor.
Definition ngcdcsFINFO.hpp:485
int sx
Lower left corner (x-direction)
Definition ngcdcsFINFO.hpp:494
double expFactor
Factor for EXPTIME.
Definition ngcdcsFINFO.hpp:479
int sy
Lower left corner (y-direction)
Definition ngcdcsFINFO.hpp:497
int appDataInline
Application data inline flag.
Definition ngcdcsFINFO.hpp:542
char reference[64]
Reference file.
Definition ngcdcsFINFO.hpp:533
int nx
Dimension in x-direction.
Definition ngcdcsFINFO.hpp:500
int fcnt
Frame counter.
Definition ngcdcsFINFO.hpp:476
char name[64]
Unique frame name.
Definition ngcdcsFINFO.hpp:473
int recording
Frame belongs to recording sequence.
Definition ngcdcsFINFO.hpp:527
double bscale
Scaling factor to be applied.
Definition ngcdcsFINFO.hpp:488
int type
Unique frame type.
Definition ngcdcsFINFO.hpp:470
int ndit
Number of integrations in pixel-data.
Definition ngcdcsFINFO.hpp:521
char appData[ngcppAPP_HDR_SIZE]
Application data.
Definition ngcdcsFINFO.hpp:545
char utc[64]
Time when frame was ready in the pre-processor.
Definition ngcdcsFINFO.hpp:530
int detIdx
Detector index (for mosaics)
Definition ngcdcsFINFO.hpp:512
double timeStamp
MUDPI/RTMS timestamp (seconds since UNIX epoch)
Definition ngcdcsFINFO.hpp:548
double crpix1
Reference pixel in x-direction.
Definition ngcdcsFINFO.hpp:506
int acq
Acquisition module instance number.
Definition ngcdcsFINFO.hpp:524
ngcbFITS * ehdr
Extension FITS header.
Definition ngcdcsFINFO.hpp:554
ngcdcsCUBE * cube
Data cube object to be used for storing to a cube.
Definition ngcdcsFINFO.hpp:551
int ny
Dimension in y-direction.
Definition ngcdcsFINFO.hpp:503
int bitPix
Bits per pixel as defined in the FITS-standard.
Definition ngcdcsFINFO.hpp:482
double bzero
Offset value to be added.
Definition ngcdcsFINFO.hpp:491
int appDataSize
Application data size.
Definition ngcdcsFINFO.hpp:539
char where[512]
Location where file has been stored.
Definition ngcdcsFINFO.hpp:536
int expCnt
Exposure counter for this type.
Definition ngcdcsFINFO.hpp:515
double crpix2
Reference pixel in y-direction.
Definition ngcdcsFINFO.hpp:509
ngcdcs_finfo_t()
Constructor.
Definition ngcdcsFINFO.hpp:557