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

Last change on this file since 10860 was 10773, checked in by tbretz, 14 years ago
File size: 5.8 KB
Line 
1#ifndef FACT_FAD_H
2#define FACT_FAD_H
3
4//---------------------------------------------------------------
5//
6// FAD internal structures
7//
8//---------------------------------------------------------------
9
10 //
11// Other definitions
12//
13#define MAX_ADDR 0xFF // highest address in Config-RAM
14#define BADDR_ROI 0x00 // Baseaddress ROI-Values
15#define BADDR_DAC 0x24 // Baseaddress DAC-Values
16#define BADDR_CONT_TRIGGER_TIME 0x2C // Baseaddress for the continouus trigger timing.
17#define ADDR_RUNNUMBER 0x2D //
18#define MAX_VAL 65535
19#define MAX_ROIVAL 1024
20#define MAX_DACVAL 65535
21
22#define NChannels 9
23#define NBins 1024
24#define NChips 4
25#define NTemp 4
26#define NDAC 8
27
28//
29// Data structures
30//
31typedef struct {
32
33 uint16_t start_package_flag;
34 uint16_t package_length;
35 uint16_t version_no;
36 uint16_t PLLLCK;
37
38 uint16_t trigger_crc;
39 uint16_t trigger_type;
40 uint32_t trigger_id;
41
42 uint32_t fad_evt_counter;
43 uint32_t REFCLK_frequency;
44
45 uint16_t board_id;
46 uint8_t zeroes;
47 int8_t adc_clock_phase_shift;
48 uint16_t number_of_triggers_to_generate;
49 uint16_t trigger_generator_prescaler;
50
51 uint64_t DNA;
52
53 uint32_t time;
54 uint32_t runnumber;
55
56 int16_t drs_temperature[NTemp];
57
58 uint16_t dac[NDAC];
59
60} __attribute__((__packed__)) PEVNT_HEADER;
61
62typedef struct {
63uint16_t id;
64uint16_t start_cell;
65uint16_t roi;
66uint16_t filling;
67uint16_t adc_data[];
68} __attribute__((__packed__)) PCHANNEL;
69
70
71typedef struct {
72uint16_t package_crc;
73uint16_t end_package_flag;
74} __attribute__((__packed__)) PEVNT_FOOTER;
75
76#define NBOARDS 40 // max. number of boards
77#define NPIX 1440 // max. number of pixels
78#define NTMARK 180 // max. number of timeMarker signals
79#define MAX_SOCK 280 // NBOARDS * 7
80
81
82typedef union {
83 uint8_t B[8] ; //8 bytes
84 uint16_t S[4] ; //4 short
85 uint32_t I[2] ; //2 int
86 uint64_t L ; //1 long
87} L_WORD ;
88
89typedef union {
90 uint8_t B[4] ; //4 bytes
91 uint16_t S[2] ; //2 short
92 uint32_t I ; //1 int
93} I_WORD ;
94
95
96//---------------------------------------------------------------
97//
98// Data structures
99//
100//---------------------------------------------------------------
101
102typedef struct {
103 uint32_t EventNum ; // EventNumber as from FTM
104 uint16_t TriggerType ; // Trigger Type from FTM
105 uint16_t Roi ; // #slices per pixel (same for all pixels and tmarks)
106
107 uint32_t SoftTrig ; // SoftTrigger Info (TBD)
108 uint32_t PCTime ; // when did event start to arrive at PC
109
110 int16_t *StartPix ; //First Channel per Pixel (Pixels sorted according Software ID) ; -1 if not filled
111
112 int16_t *StartTM ; //First Channel for TimeMark (sorted Hardware ID) ; -1 if not filled
113
114 uint16_t *Adc_Data ; // [ NPixels ] [ ROI ] sorted softID
115
116 uint16_t *Adc_Tmark ; // [ NTmark ] [ ROI ] sorted hardID
117
118//this is highly redundant and should be reduced to usefull info [if any]
119 PEVNT_HEADER *FADhead; // [ NBoards ] sorted Board Headers (according Hardware ID)
120
121} EVENT ;
122
123
124
125//---------------------------------------------------------------
126
127
128
129
130typedef struct {
131 uint32_t Version ;
132 uint32_t RunType ;
133 uint16_t NBoard ;
134 uint16_t NPix ;
135 uint16_t NTm ;
136 uint16_t Nroi ;
137
138//headers of all FAD-boards for first event ==> all FAD configs
139 PEVNT_HEADER *FADhead; // [ NBoards ] sorted Board Headers (according Hardware ID)
140
141//do we also have info about FTM config we want to add here ???
142} RUN_HEAD ;
143
144
145//---------------------------------------------------------------
146
147
148typedef struct {
149 uint32_t nEventsOk ; //how many events were written
150 uint32_t nEventsRej; //how many events were rejected by SW-trig
151 uint32_t nEventsBad; //how many events were rejected by Error
152
153 uint32_t PCtime0 ; //time when first event received
154 uint32_t PCtimeX ; //time when last event received
155
156
157//probably more to come ...
158} RUN_TAIL ;
159
160
161
162//---------------------------------------------------------------
163
164#define MAX_RUN 64
165#define MAX_EVT 131072
166
167typedef struct {
168 uint32_t runId ; //run number
169 uint32_t lastTime ; //time when last event written so far
170 uint32_t nextEvt ; //next event number to be written
171 uint32_t waitEvt ; //event that would be ready to be written
172 int32_t fileId ; //id of open file
173 int16_t ctrlId[MAX_EVT] ; //index to buffId (sorted list; -1 =end)
174 uint16_t buffId[MAX_EVT] ; //index to mBuffer(buffered raw data)
175} RUN_CTRL ;
176
177
178
179//---------------------------------------------------------------
180
181
182typedef struct {
183 int32_t evNum ;
184 int32_t runNum ;
185 int32_t fadLen ;
186 int32_t nBoard ;
187 int16_t board[ NBOARDS ];
188 int32_t nRoi ;
189 int32_t pcTime ;
190 EVENT *fEvent ;
191
192} WRK_DATA ; //internal to eventbuilder
193
194
195//---------------------------------------------------------------
196
197
198typedef struct {
199 int readPtr ; //index of reading
200 int writePtr ; //index of writing
201 int evtBuf[MAX_EVT*MAX_RUN] ; //index of event in mBuffer
202 int evtStat[MAX_EVT*MAX_RUN] ; //status of event:
203 // -1=empty
204 // 1..NBoards reading #Boards
205 // 90-99 : end reading
206 //128-255: processing
207 //256-
208 //201=start processing
209 //299=end processing
210 //901=start writing
211 //999=finished writing
212 //(TO BE REVISED)
213
214 int pcTime[MAX_EVT*MAX_RUN] ; //time when last action happened
215} EVT_CTRL ;
216
217
218
219#endif
Note: See TracBrowser for help on using the repository browser.