source: trunk/FACT++/src/FAD.h@ 18530

Last change on this file since 18530 was 16617, checked in by tbretz, 11 years ago
Removed the total number of bytes, replaced by a relative one.
File size: 4.7 KB
Line 
1#ifndef FACT_FAD_H
2#define FACT_FAD_H
3
4//---------------------------------------------------------------
5//
6// FAD internal structures
7//
8//---------------------------------------------------------------
9
10#define NTemp 4
11#define NDAC 8
12
13typedef struct {
14
15 uint16_t start_package_flag;
16 uint16_t package_length;
17 uint16_t version_no;
18 uint16_t PLLLCK;
19
20 uint16_t trigger_crc;
21 uint16_t trigger_type;
22 uint32_t trigger_id;
23
24 uint32_t fad_evt_counter;
25 uint32_t REFCLK_frequency;
26
27 uint16_t board_id;
28 uint8_t zeroes;
29 int8_t adc_clock_phase_shift;
30 uint16_t number_of_triggers_to_generate;
31 uint16_t trigger_generator_prescaler;
32
33 uint64_t DNA;
34
35 uint32_t time;
36 uint32_t runnumber;
37
38 int16_t drs_temperature[NTemp];
39
40 uint16_t dac[NDAC];
41
42} __attribute__((__packed__)) PEVNT_HEADER;
43
44typedef struct {
45uint16_t id;
46uint16_t start_cell;
47uint16_t roi;
48uint16_t filling;
49 int16_t adc_data[];
50} __attribute__((__packed__)) PCHANNEL;
51
52
53typedef struct {
54uint16_t package_crc;
55uint16_t end_package_flag;
56} __attribute__((__packed__)) PEVNT_FOOTER;
57
58#define NBOARDS 40 // max. number of boards
59#define NPIX 1440 // max. number of pixels
60#define NTMARK 160 // max. number of timeMarker signals
61
62//---------------------------------------------------------------
63//
64// Data structures
65//
66//---------------------------------------------------------------
67
68typedef struct _EVENT {
69 uint16_t Roi ; // #slices per pixel (same for all pixels)
70 uint16_t RoiTM ; // #slices per pixel (same for all tmarks) [ 0 or Roi ]
71 uint32_t EventNum ; // EventNumber as from FADs
72 uint32_t TriggerNum ; // EventNumber as from FTM
73 uint16_t TriggerType ; // Trigger Type from FTM
74
75 uint32_t NumBoards ; // number of active boards included
76
77 uint32_t PCTime ; // epoch
78 uint32_t PCUsec ; // micro-seconds
79
80 uint32_t BoardTime[NBOARDS];//
81
82 int16_t StartPix[NPIX]; // First Channel per Pixel (Pixels sorted according Software ID) ; -1 if not filled
83
84 int16_t StartTM[NTMARK]; // First Channel for TimeMark (sorted Hardware ID) ; -1 if not filled
85
86 int16_t Adc_Data[]; // final length defined by malloc ....
87
88} __attribute__((__packed__)) EVENT ;
89
90//---------------------------------------------------------------
91
92struct RUN_HEAD
93{
94 uint32_t Version ;
95 uint32_t RunType ;
96 uint32_t RunTime ; //unix epoch for first event
97 uint32_t RunUsec ; //microseconds
98 uint16_t NBoard ; //#boards (always 40)
99 uint16_t NPix ; //#pixels (always 1440)
100 uint16_t NTm ; //#TM (always 160)
101 uint16_t Nroi ; //roi for pixels
102 uint16_t NroiTM ; //roi for TM <=0 if TM is empty
103
104//headers of all FAD-boards for first event ==> all FAD configs
105 PEVNT_HEADER FADhead[NBOARDS]; // [ NBoards ] sorted Board Headers (according Hardware ID)
106
107 RUN_HEAD() : Version(1), RunType(-1), NBoard(NBOARDS), NPix(NPIX), NTm(NTMARK)
108 {
109 }
110
111
112//do we also have info about FTM config we want to add here ???
113} __attribute__((__packed__));
114
115
116//---------------------------------------------------------------
117
118// FIXME: This doesn't neet to be here... it is inlcuded in all
119// data processors
120
121#include <netinet/in.h>
122
123typedef struct {
124 struct sockaddr_in sockAddr ;
125 int sockDef ; //<0 not defined/ ==0 not to be used/ >0 used
126} FACT_SOCK ; //internal to eventbuilder
127
128
129//---------------------------------------------------------------
130
131typedef struct {
132 //info about (current state of) the buffer
133 uint32_t bufNew ; //# incomplete events in buffer (evtCtrl)
134 uint32_t bufEvt ; //# complete events in buffer (primaryQueue)
135 uint32_t bufWrite ; //# events in write queue (secondaryQueue)
136 uint32_t bufProc ; //# events in processing queue (processingQueue1)
137 uint32_t bufTot ; //# total events currently in buffer (this corresponds to totMem)
138
139 uint64_t totMem; //# Bytes available in Buffer
140 uint64_t usdMem; //# Bytes currently used
141 uint64_t maxMem; //max # Bytes used during past cycle
142
143 //rates
144 int32_t deltaT ; //time in milli-seconds for rates
145 int32_t rateNew ; //#New start events recieved
146 int32_t rateWrite ; //#Complete events written (or flushed)
147
148 //connections
149 int8_t numConn[NBOARDS] ; //#connections per board (at the moment)
150 uint32_t rateBytes[NBOARDS]; //#Bytes read (counter)
151 int32_t relBytes[NBOARDS]; //#Bytes read this cycle **
152
153 // ** // if counter and rates exist, do only update the rates in
154 // ** // real time;
155 // ** // counters will be updated only once per cycle based on rates
156
157} __attribute__((__packed__)) GUI_STAT ; //EventBuilder Status
158
159#endif
Note: See TracBrowser for help on using the repository browser.