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