1 | #ifndef FACT_EventBuilderWrapper
|
---|
2 | #define FACT_EventBuilderWrapper
|
---|
3 |
|
---|
4 | /*
|
---|
5 | #if BOOST_VERSION < 104400
|
---|
6 | #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))
|
---|
7 | #undef BOOST_HAS_RVALUE_REFS
|
---|
8 | #endif
|
---|
9 | #endif
|
---|
10 | #include <boost/thread.hpp>
|
---|
11 |
|
---|
12 | using namespace std;
|
---|
13 | */
|
---|
14 |
|
---|
15 | #include <boost/date_time/posix_time/posix_time_types.hpp>
|
---|
16 |
|
---|
17 | #include <CCfits/CCfits>
|
---|
18 |
|
---|
19 | #include "EventBuilder.h"
|
---|
20 |
|
---|
21 | extern "C" {
|
---|
22 | extern void StartEvtBuild();
|
---|
23 | extern int CloseRunFile(uint32_t runId, uint32_t closeTime);
|
---|
24 | }
|
---|
25 |
|
---|
26 | class DataFileImp
|
---|
27 | {
|
---|
28 | uint32_t fRunId;
|
---|
29 |
|
---|
30 | public:
|
---|
31 | DataFileImp(uint32_t id) : fRunId(id) { }
|
---|
32 |
|
---|
33 | virtual bool OpenFile(RUN_HEAD* h) = 0;
|
---|
34 | virtual bool Write(EVENT *) = 0;
|
---|
35 | virtual bool Close(RUN_TAIL * = 0) = 0;
|
---|
36 |
|
---|
37 | uint32_t GetRunId() const { return fRunId; }
|
---|
38 |
|
---|
39 | // --------------------------------------------------------------------------
|
---|
40 | //
|
---|
41 | //! This creates an appropriate file name for a particular run number and type
|
---|
42 | //! @param runNumber the run number for which a filename is to be created
|
---|
43 | //! @param runType an int describing the kind of run. 0=Data, 1=Pedestal, 2=Calibration, 3=Calibrated data
|
---|
44 | //! @param extension a string containing the extension to be appened to the file name
|
---|
45 | //
|
---|
46 | string FormFileName(uint32_t runType, string extension)
|
---|
47 | {
|
---|
48 | //TODO where am I supposed to get the base directory from ?
|
---|
49 | //TODO also, for creating subsequent directories, should I use the functions from the dataLogger ?
|
---|
50 | string baseDirectory = "./Run";
|
---|
51 |
|
---|
52 | ostringstream result;
|
---|
53 | // result << baseDirectory;
|
---|
54 | // result << Time::fmt("/%Y/%m/%d/") << (Time() - boost::posix_time::time_duration(12,0,0));
|
---|
55 | result << setfill('0') << setw(8) << fRunId;
|
---|
56 | result << ".001_";
|
---|
57 | switch (runType)
|
---|
58 | {
|
---|
59 | case -1:
|
---|
60 | result << 'T';
|
---|
61 | break;
|
---|
62 | case 0:
|
---|
63 | result << 'D';
|
---|
64 | break;
|
---|
65 | case 1:
|
---|
66 | result << 'P';
|
---|
67 | break;
|
---|
68 | case 2:
|
---|
69 | result << 'C';
|
---|
70 | break;
|
---|
71 | case 3:
|
---|
72 | result << 'N';
|
---|
73 | break;
|
---|
74 | default:
|
---|
75 | result << runType;
|
---|
76 | };
|
---|
77 | result << "." << extension;
|
---|
78 |
|
---|
79 | return result.str();
|
---|
80 | }
|
---|
81 | };
|
---|
82 |
|
---|
83 | class DataFileNone : public DataFileImp
|
---|
84 | {
|
---|
85 | public:
|
---|
86 | DataFileNone(uint32_t id) : DataFileImp(id) { }
|
---|
87 |
|
---|
88 | bool OpenFile(RUN_HEAD* h)
|
---|
89 | {
|
---|
90 | cout << "OPEN_FILE #" << GetRunId() << " (" << this << ")" << endl;
|
---|
91 | cout << " Ver= " << h->Version << endl;
|
---|
92 | cout << " Typ= " << h->RunType << endl;
|
---|
93 | cout << " Nb = " << h->NBoard << endl;
|
---|
94 | cout << " Np = " << h->NPix << endl;
|
---|
95 | cout << " NTm= " << h->NTm << endl;
|
---|
96 | cout << " roi= " << h->Nroi << endl;
|
---|
97 |
|
---|
98 | return true;
|
---|
99 | }
|
---|
100 | bool Write(EVENT *)
|
---|
101 | {
|
---|
102 | return true;
|
---|
103 | }
|
---|
104 | bool Close(RUN_TAIL * = 0)
|
---|
105 | {
|
---|
106 | cout << "CLOSE FILE #" << GetRunId() << " (" << this << ")" << endl;
|
---|
107 | return true;
|
---|
108 | }
|
---|
109 | };
|
---|
110 |
|
---|
111 | class DataFileDebug : public DataFileNone
|
---|
112 | {
|
---|
113 | public:
|
---|
114 | DataFileDebug(uint32_t id) : DataFileNone(id) { }
|
---|
115 |
|
---|
116 | bool Write(EVENT *e)
|
---|
117 | {
|
---|
118 | cout << "WRITE_EVENT #" << GetRunId() << " (" << e->EventNum << ")" << endl;
|
---|
119 | cout << " Typ=" << e->TriggerType << endl;
|
---|
120 | cout << " roi=" << e->Roi << endl;
|
---|
121 | cout << " trg=" << e->SoftTrig << endl;
|
---|
122 | cout << " tim=" << e->PCTime << endl;
|
---|
123 |
|
---|
124 | return true;
|
---|
125 | }
|
---|
126 | };
|
---|
127 |
|
---|
128 | #include "FAD.h"
|
---|
129 |
|
---|
130 | class DataFileRaw : public DataFileImp
|
---|
131 | {
|
---|
132 | ofstream fOut;
|
---|
133 |
|
---|
134 | off_t fPosTail;
|
---|
135 |
|
---|
136 | uint32_t fCounter;
|
---|
137 |
|
---|
138 |
|
---|
139 | // WRITE uint32_t 0xFAC77e1e (FACT Tele)
|
---|
140 | // ===
|
---|
141 | // WRITE uint32_t TYPE(>0) == 1
|
---|
142 | // WRITE uint32_t ID(>0) == 0
|
---|
143 | // WRITE uint32_t VERSION(>0) == 1
|
---|
144 | // WRITE uint32_t LENGTH
|
---|
145 | // -
|
---|
146 | // WRITE uint32_t TELESCOPE ID
|
---|
147 | // WRITE uint32_t RUNID
|
---|
148 | // ===
|
---|
149 | // WRITE uint32_t TYPE(>0) == 2
|
---|
150 | // WRITE uint32_t ID(>0) == 0
|
---|
151 | // WRITE uint32_t VERSION(>0) == 1
|
---|
152 | // WRITE uint32_t LENGTH
|
---|
153 | // -
|
---|
154 | // WRITE HEADER
|
---|
155 | // ===
|
---|
156 | // [ 40 TIMES
|
---|
157 | // WRITE uint32_t TYPE(>0) == 3
|
---|
158 | // WRITE uint32_t ID(>0) == 0..39
|
---|
159 | // WRITE uint32_t VERSION(>0) == 1
|
---|
160 | // WRITE uint32_t LENGTH
|
---|
161 | // -
|
---|
162 | // WRITE BOARD-HEADER
|
---|
163 | // ]
|
---|
164 | // ===
|
---|
165 | // WRITE uint32_t TYPE(>0) == 4
|
---|
166 | // WRITE uint32_t ID(>0) == 0
|
---|
167 | // WRITE uint32_t VERSION(>0) == 1
|
---|
168 | // WRITE uint32_t LENGTH
|
---|
169 | // -
|
---|
170 | // WRITE FOOTER (empty)
|
---|
171 | // ===
|
---|
172 | // [ N times
|
---|
173 | // WRITE uint32_t TYPE(>0) == 10
|
---|
174 | // WRITE uint32_t ID(>0) == counter
|
---|
175 | // WRITE uint32_t VERSION(>0) == 1
|
---|
176 | // WRITE uint32_t LENGTH HEADER
|
---|
177 | // -
|
---|
178 | // WRITE HEADER+DATA
|
---|
179 | // ]
|
---|
180 | // ===
|
---|
181 | // WRITE uint32_t TYPE ==0
|
---|
182 | // WRITE uint32_t VERSION==0
|
---|
183 | // WRITE uint32_t LENGTH ==0
|
---|
184 | // ===
|
---|
185 | // Go back and write footer
|
---|
186 |
|
---|
187 | public:
|
---|
188 | DataFileRaw(uint32_t id) : DataFileImp(id) { }
|
---|
189 | ~DataFileRaw() { Close(); }
|
---|
190 |
|
---|
191 | void WriteBlockHeader(uint32_t type, uint32_t ver, uint32_t cnt, uint32_t len)
|
---|
192 | {
|
---|
193 | const uint32_t val[4] = { type, ver, cnt, len };
|
---|
194 |
|
---|
195 | fOut.write(reinterpret_cast<const char*>(val), sizeof(val));
|
---|
196 | }
|
---|
197 |
|
---|
198 | template<typename T>
|
---|
199 | void WriteValue(const T &t)
|
---|
200 | {
|
---|
201 | fOut.write(reinterpret_cast<const char*>(&t), sizeof(T));
|
---|
202 | }
|
---|
203 |
|
---|
204 | enum
|
---|
205 | {
|
---|
206 | kEndOfFile = 0,
|
---|
207 | kIdentifier = 1,
|
---|
208 | kRunHeader,
|
---|
209 | kBoardHeader,
|
---|
210 | kRunSummary,
|
---|
211 | kEvent,
|
---|
212 | };
|
---|
213 |
|
---|
214 | virtual bool OpenFile(RUN_HEAD *h)
|
---|
215 | {
|
---|
216 | const string name = FormFileName(h->RunType, "bin");
|
---|
217 |
|
---|
218 | errno = 0;
|
---|
219 | fOut.open(name.c_str(), ios_base::out);
|
---|
220 | if (!fOut)
|
---|
221 | {
|
---|
222 | //ostringstream str;
|
---|
223 | //str << "Open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")";
|
---|
224 | //Error(str);
|
---|
225 |
|
---|
226 | return false;
|
---|
227 | }
|
---|
228 |
|
---|
229 | fCounter = 0;
|
---|
230 |
|
---|
231 | static uint32_t FACT = 0xFAC77e1e;
|
---|
232 |
|
---|
233 | fOut.write(reinterpret_cast<char*>(&FACT), 4);
|
---|
234 |
|
---|
235 | WriteBlockHeader(kIdentifier, 1, 0, 8);
|
---|
236 | WriteValue(uint32_t(0));
|
---|
237 | WriteValue(GetRunId());
|
---|
238 |
|
---|
239 | WriteBlockHeader(kRunHeader, 1, 0, sizeof(RUN_HEAD)-sizeof(PEVNT_HEADER*));
|
---|
240 | fOut.write(reinterpret_cast<char*>(h), sizeof(RUN_HEAD)-sizeof(PEVNT_HEADER*));
|
---|
241 |
|
---|
242 | for (int i=0; i<40; i++)
|
---|
243 | {
|
---|
244 | WriteBlockHeader(kBoardHeader, 1, i, sizeof(PEVNT_HEADER));
|
---|
245 | fOut.write(reinterpret_cast<char*>(h->FADhead+i), sizeof(PEVNT_HEADER));
|
---|
246 | }
|
---|
247 |
|
---|
248 | // FIXME: Split this
|
---|
249 | const vector<char> block(sizeof(uint32_t)+sizeof(RUN_TAIL));
|
---|
250 | WriteBlockHeader(kRunSummary, 1, 0, block.size());
|
---|
251 |
|
---|
252 | fPosTail = fOut.tellp();
|
---|
253 | fOut.write(block.data(), block.size());
|
---|
254 |
|
---|
255 | if (!fOut)
|
---|
256 | {
|
---|
257 | //ostringstream str;
|
---|
258 | //str << "Open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")";
|
---|
259 | //Error(str);
|
---|
260 |
|
---|
261 | return false;
|
---|
262 | }
|
---|
263 |
|
---|
264 | return true;
|
---|
265 | }
|
---|
266 | virtual bool Write(EVENT *evt)
|
---|
267 | {
|
---|
268 | const int sh = sizeof(EVENT)-2 + NPIX*evt->Roi*2;
|
---|
269 |
|
---|
270 | WriteBlockHeader(kEvent, 1, fCounter++, sh);
|
---|
271 | fOut.write(reinterpret_cast<char*>(evt)+2, sh);
|
---|
272 | return true;
|
---|
273 | }
|
---|
274 | virtual bool Close(RUN_TAIL *tail= 0)
|
---|
275 | {
|
---|
276 | WriteBlockHeader(kEndOfFile, 0, 0, 0);
|
---|
277 |
|
---|
278 | if (tail)
|
---|
279 | {
|
---|
280 | fOut.seekp(fPosTail);
|
---|
281 |
|
---|
282 | WriteValue(uint32_t(1));
|
---|
283 | fOut.write(reinterpret_cast<char*>(tail), sizeof(RUN_TAIL));
|
---|
284 | }
|
---|
285 |
|
---|
286 | if (!fOut)
|
---|
287 | {
|
---|
288 | //ostringstream str;
|
---|
289 | //str << "Open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")";
|
---|
290 | //Error(str);
|
---|
291 |
|
---|
292 | return false;
|
---|
293 | }
|
---|
294 |
|
---|
295 | fOut.close();
|
---|
296 |
|
---|
297 | if (!fOut)
|
---|
298 | {
|
---|
299 | //ostringstream str;
|
---|
300 | //str << "Open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")";
|
---|
301 | //Error(str);
|
---|
302 |
|
---|
303 | return false;
|
---|
304 | }
|
---|
305 |
|
---|
306 | return true;
|
---|
307 | }
|
---|
308 | };
|
---|
309 |
|
---|
310 | #ifdef HAS_FITS
|
---|
311 | class DataFileFits : public DataFileImp
|
---|
312 | {
|
---|
313 | CCfits::FITS* fFile; /// The pointer to the CCfits FITS file
|
---|
314 | CCfits::Table* fTable; /// The pointer to the CCfits binary table
|
---|
315 |
|
---|
316 | uint64_t fNumRows; ///the number of rows that have been written already to the FITS file.
|
---|
317 |
|
---|
318 | public:
|
---|
319 | DataFileFits(uint32_t runid) : DataFileImp(runid), fFile(0)
|
---|
320 | {
|
---|
321 | }
|
---|
322 |
|
---|
323 | // --------------------------------------------------------------------------
|
---|
324 | //
|
---|
325 | //! Default destructor
|
---|
326 | //! The Fits file SHOULD have been closed already, otherwise the informations
|
---|
327 | //! related to the RUN_TAIL will NOT be written to the file.
|
---|
328 | //
|
---|
329 | ~DataFileFits() { Close(); }
|
---|
330 |
|
---|
331 | // --------------------------------------------------------------------------
|
---|
332 | //
|
---|
333 | //! Add a new column to the vectors storing the column data.
|
---|
334 | //! @param names the vector of string storing the columns names
|
---|
335 | //! @param types the vector of string storing the FITS data format
|
---|
336 | //! @param numElems the number of elements in this column
|
---|
337 | //! @param type the char describing the FITS data format
|
---|
338 | //! @param name the name of the particular column to be added.
|
---|
339 | //
|
---|
340 | inline void AddColumnEntry(vector<string>& names, vector<string>& types, int numElems, char type, string name)
|
---|
341 | {
|
---|
342 | names.push_back(name);
|
---|
343 |
|
---|
344 | ostringstream str;
|
---|
345 | if (numElems != 1)
|
---|
346 | str << numElems;
|
---|
347 | str << type;
|
---|
348 | types.push_back(str.str());
|
---|
349 | }
|
---|
350 |
|
---|
351 | // --------------------------------------------------------------------------
|
---|
352 | //
|
---|
353 | //! Writes a single header key entry
|
---|
354 | //! @param name the name of the key
|
---|
355 | //! @param value its value
|
---|
356 | //! @param comment the comment associated to that key
|
---|
357 | //
|
---|
358 | //FIXME this function is a duplicate from the class Fits. should we try to merge it ?
|
---|
359 | template <typename T>
|
---|
360 | void WriteKey(const string &name, const T &value, const string &comment)
|
---|
361 | {
|
---|
362 | try
|
---|
363 | {
|
---|
364 | fTable->addKey(name, value, comment);
|
---|
365 | }
|
---|
366 | catch (CCfits::FitsException e)
|
---|
367 | {
|
---|
368 | ostringstream str;
|
---|
369 | str << "Could not add header key ";
|
---|
370 | //TODO pipe the error message somewhere
|
---|
371 | }
|
---|
372 | }
|
---|
373 |
|
---|
374 | template <typename T>
|
---|
375 | void WriteKey(const string &name, const int idx, const T &value, const string &comment)
|
---|
376 | {
|
---|
377 | ostringstream str;
|
---|
378 | str << name << idx;
|
---|
379 |
|
---|
380 | WriteKey(str.str(), value, comment);
|
---|
381 | }
|
---|
382 |
|
---|
383 | // --------------------------------------------------------------------------
|
---|
384 | //
|
---|
385 | //! DataFileFits constructor. This is the one that should be used, not the default one (parameter-less)
|
---|
386 | //! @param runid This parameter should probably be removed. I first thought it was the run number, but apparently it is not
|
---|
387 | //! @param h a pointer to the RUN_HEAD structure that contains the informations relative to this run
|
---|
388 | //
|
---|
389 | bool OpenFile(RUN_HEAD* h)
|
---|
390 | {
|
---|
391 | //Form filename, based on runid and run-type
|
---|
392 | const string fileName = FormFileName(h->RunType, "fits");
|
---|
393 |
|
---|
394 | //create the FITS object
|
---|
395 | try
|
---|
396 | {
|
---|
397 | fFile = new CCfits::FITS(fileName, CCfits::RWmode::Write);
|
---|
398 | }
|
---|
399 | catch (CCfits::FitsException e)
|
---|
400 | {
|
---|
401 | ostringstream str;
|
---|
402 | str << "Could not open FITS file " << fileName << " reason: " << e.message();
|
---|
403 | //TODO display the message somewhere
|
---|
404 |
|
---|
405 | return false;
|
---|
406 | }
|
---|
407 |
|
---|
408 | //create columns according to header
|
---|
409 | ostringstream arrayTypes;
|
---|
410 |
|
---|
411 | // uint32_t EventNum ; // EventNumber as from FTM
|
---|
412 | // uint16_t TriggerType ; // Trigger Type from FTM
|
---|
413 | // uint32_t SoftTrig ; // SoftTrigger Info (TBD)
|
---|
414 | // uint32_t PCTime ; // when did event start to arrive at PC
|
---|
415 | // uint32_t BoardTime[NBOARDS];//
|
---|
416 | // int16_t StartPix[NPIX]; // First Channel per Pixel (Pixels sorted according Software ID) ; -1 if not filled
|
---|
417 | // int16_t StartTM[NTMARK]; // First Channel for TimeMark (sorted Hardware ID) ; -1 if not filled
|
---|
418 | // uint16_t Adc_Data[]; // final length defined by malloc ....
|
---|
419 |
|
---|
420 | vector<string> colNames;
|
---|
421 | vector<string> dataTypes;
|
---|
422 | AddColumnEntry(colNames, dataTypes, 1, 'V', "EventNum");
|
---|
423 | AddColumnEntry(colNames, dataTypes, 1, 'U', "TriggerType");
|
---|
424 | AddColumnEntry(colNames, dataTypes, 1, 'V', "SoftTrig");
|
---|
425 | AddColumnEntry(colNames, dataTypes, 1, 'V', "PCTime");
|
---|
426 | AddColumnEntry(colNames, dataTypes, NBOARDS, 'V', "BoardTime");
|
---|
427 | AddColumnEntry(colNames, dataTypes, NPIX, 'I', "StartPix");
|
---|
428 | AddColumnEntry(colNames, dataTypes, NTMARK, 'I', "StartTM");
|
---|
429 | AddColumnEntry(colNames, dataTypes, NPIX*h->Nroi, 'U', "Data");
|
---|
430 |
|
---|
431 | //actually create the table
|
---|
432 | try
|
---|
433 | {
|
---|
434 | fTable = fFile->addTable("Events", 0, colNames, dataTypes);
|
---|
435 | if (fTable->rows() != 0)
|
---|
436 | {
|
---|
437 | ostringstream str;
|
---|
438 | str << "Error: table created on the fly looks non-empty.";
|
---|
439 | //TODO giev the error text to some error handler
|
---|
440 | //FIXME I guess that this error checking is useless. remove it for performances.
|
---|
441 | }
|
---|
442 | }
|
---|
443 | catch (const CCfits::FitsException &e)
|
---|
444 | {
|
---|
445 | ostringstream str;
|
---|
446 | str << "Could not create FITS table " << "Events" << " in file " << fileName << " reason: " << e.message();
|
---|
447 | //TODO give the error text to some error handler
|
---|
448 |
|
---|
449 | Close();
|
---|
450 | return false;
|
---|
451 | }
|
---|
452 |
|
---|
453 | //write header data
|
---|
454 | //first the "standard" keys
|
---|
455 | string stringValue;
|
---|
456 | WriteKey("EXTREL", 1.0f, "Release Number");
|
---|
457 | WriteKey("TELESCOP", "FACT", "Telescope that acquired this data");
|
---|
458 | WriteKey("ORIGIN", "ISDC", "Institution that wrote the file");
|
---|
459 | WriteKey("CREATOR", "FACT++ Event Builder", "Program that wrote this file");
|
---|
460 |
|
---|
461 | stringValue = Time().GetAsStr();
|
---|
462 | stringValue[10]= 'T';
|
---|
463 | WriteKey("DATE", stringValue, "File creation data");
|
---|
464 | WriteKey("TIMESYS", "TT", "Time frame system");
|
---|
465 | WriteKey("TIMEUNIT", "d", "Time unit");
|
---|
466 | WriteKey("TIMEREF", "UTC", "Time reference frame");
|
---|
467 | //FIXME should we also put the start and stop time of the received data ?
|
---|
468 | //now the events header related variables
|
---|
469 | WriteKey("VERSION", h->Version, "Builder version");
|
---|
470 | WriteKey("RUNTYPE", h->RunType, "Type of run");
|
---|
471 | WriteKey("NBOARD", h->NBoard, "Number of acquisition boards");
|
---|
472 | WriteKey("NPIX", h->NPix, "Number of pixels");
|
---|
473 | WriteKey("NTM", h->NTm, "Number of Time marks");
|
---|
474 | WriteKey("NROI", h->Nroi, "Number of slices per pixels");
|
---|
475 |
|
---|
476 | //now the boards related keywords
|
---|
477 | for (int i=0; i<h->NBoard; i++)
|
---|
478 | {
|
---|
479 | const PEVNT_HEADER &hh = h->FADhead[i];
|
---|
480 |
|
---|
481 | WriteKey("STPKGFG", i, hh.start_package_flag,
|
---|
482 | "Start package flag");
|
---|
483 |
|
---|
484 | WriteKey("PKGLEN", i, hh.package_length,
|
---|
485 | "Package length");
|
---|
486 |
|
---|
487 | WriteKey("VERNO", i, hh.version_no,
|
---|
488 | "Version number");
|
---|
489 |
|
---|
490 | WriteKey("PLLLCK", i, hh.PLLLCK,
|
---|
491 | "");
|
---|
492 | /*
|
---|
493 | WriteKey("TRIGCRC", i, hh.trigger_crc,
|
---|
494 | "Trigger CRC");
|
---|
495 |
|
---|
496 | WriteKey("TRIGTYP", i, hh.trigger_type,
|
---|
497 | "Trigger type");
|
---|
498 |
|
---|
499 | WriteKey("TRIGID", i, hh.trigger_id,
|
---|
500 | "Trigger ID");
|
---|
501 |
|
---|
502 | WriteKey("EVTCNTR", i, hh.fad_evt_counter,
|
---|
503 | "FAD Event Counter");
|
---|
504 | */
|
---|
505 | WriteKey("REFCLK", i, hh.REFCLK_frequency,
|
---|
506 | "Reference Clock Frequency");
|
---|
507 |
|
---|
508 | WriteKey("BOARDID", i, hh.board_id,
|
---|
509 | "Board ID");
|
---|
510 |
|
---|
511 | WriteKey("PHASESH", i, hh.adc_clock_phase_shift,
|
---|
512 | "ADC clock phase shift");
|
---|
513 |
|
---|
514 | //WriteKey("TRGGEN", i, hh.number_of_triggers_to_generate,
|
---|
515 | // "Number of triggers to generate");
|
---|
516 |
|
---|
517 | WriteKey("PRESC", i, hh.trigger_generator_prescaler,
|
---|
518 | "Trigger generator prescaler");
|
---|
519 |
|
---|
520 | WriteKey("DNA", i, hh.DNA, "DNA");
|
---|
521 | WriteKey("TIME", i, hh.time, "Time");
|
---|
522 | WriteKey("RUNNB", i, hh.runnumber, "Run number");
|
---|
523 | /*
|
---|
524 | for (int j=0;j<NTemp;j++)
|
---|
525 | {
|
---|
526 | str.str(""); str2.str("");
|
---|
527 | str << "DRS_T" << i << j;
|
---|
528 | str2 << "DRS temperature #" << i << " " << j;
|
---|
529 | WriteKey(str.str(), h->FADhead[i].drs_temperature[j], str2.str());
|
---|
530 | }
|
---|
531 | */
|
---|
532 | for (int j=0;j<NDAC;j++)
|
---|
533 | WriteKey("DAC", i*NDAC+j, hh.dac[j], "DAC");
|
---|
534 |
|
---|
535 | //Last but not least, add header keys that will be updated when closing the file
|
---|
536 | WriteFooter(NULL);
|
---|
537 | }
|
---|
538 |
|
---|
539 | return true;
|
---|
540 | }
|
---|
541 |
|
---|
542 |
|
---|
543 | int WriteColumns(size_t &start, size_t size, void *e)
|
---|
544 | {
|
---|
545 | int status = 0;
|
---|
546 | fits_write_tblbytes(fFile->fitsPointer(), fNumRows, start, size, reinterpret_cast<unsigned char*>(e), &status);
|
---|
547 | if (status)
|
---|
548 | {
|
---|
549 | char text[30];//max length of cfitsio error strings (from doc)
|
---|
550 | fits_get_errstatus(status, text);
|
---|
551 | //ostringstream str;
|
---|
552 | //str << "Writing FITS row " << i << " in " << groupName << ": " << text << " (file_write_tblbytes, rc=" << status << ")";
|
---|
553 | //Error(str);
|
---|
554 | }
|
---|
555 |
|
---|
556 | start += size;
|
---|
557 | return status;
|
---|
558 | }
|
---|
559 |
|
---|
560 | // --------------------------------------------------------------------------
|
---|
561 | //
|
---|
562 | //! This writes one event to the file
|
---|
563 | //! @param e the pointer to the EVENT
|
---|
564 | //
|
---|
565 | virtual bool Write(EVENT *e)
|
---|
566 | {
|
---|
567 | //FIXME As discussed earlier, we do not swap the bytes yet.
|
---|
568 | fTable->makeThisCurrent();
|
---|
569 |
|
---|
570 | //insert a new row
|
---|
571 | int status(0);
|
---|
572 | if (fits_insert_rows(fTable->fitsPointer(), fNumRows, 1, &status))
|
---|
573 | {
|
---|
574 | //ostringstream str;
|
---|
575 | //str << "Inserting row into " << fFileName << " failed (fits_insert_rows, rc=" << status << ")";
|
---|
576 | //fMess->Error(str);
|
---|
577 | //TODO pipe this error message to the appropriate error stream
|
---|
578 | }
|
---|
579 | fNumRows++;
|
---|
580 |
|
---|
581 | const int sh = sizeof(EVENT)+NPIX*e->Roi*2;
|
---|
582 |
|
---|
583 | // column size pointer
|
---|
584 | size_t col = 1;
|
---|
585 | if (!WriteColumns(col, sh, e))
|
---|
586 | return true;
|
---|
587 |
|
---|
588 | //TODO output an error
|
---|
589 | return false;
|
---|
590 |
|
---|
591 | /*
|
---|
592 | //write the data, chunk by chunk
|
---|
593 | //FIXME hard-coded size corresponds to current variables of the event, in bytes.
|
---|
594 | //FIXME no padding was taken into account. Because smallest member is 2 bytes, I don't think that this should be a problem.
|
---|
595 | const long sizeInBytesOfEventBeforePointers = 16;
|
---|
596 |
|
---|
597 | long col = 1;
|
---|
598 | if (FitsWriteTblBytes(col, sizeInBytesOfEventBeforePointers, e))
|
---|
599 | {
|
---|
600 | //TODO output an error
|
---|
601 | return false;
|
---|
602 | }
|
---|
603 | if (FitsWriteTblBytes(col, NBOARDS*2, e->BoardTime))
|
---|
604 | {
|
---|
605 | //TODO output an error
|
---|
606 | return false;
|
---|
607 | }
|
---|
608 | if (FitsWriteTblBytes(col, NPIX*2, e->StartPix))
|
---|
609 | {
|
---|
610 | //TODO output an error
|
---|
611 | return false;
|
---|
612 | }
|
---|
613 | if (FitsWriteTblBytes(col, NTMARK*2, e->StartTM))
|
---|
614 | {
|
---|
615 | //TODO output an error
|
---|
616 | return false;
|
---|
617 | }
|
---|
618 | if (FitsWriteTblBytes(col, NPIX*fRoi*2, e->Adc_Data))
|
---|
619 | {
|
---|
620 | //TODO output an error
|
---|
621 | return false;
|
---|
622 | }
|
---|
623 | return true;*/
|
---|
624 | }
|
---|
625 |
|
---|
626 | void WriteFooter(RUN_TAIL *rt)
|
---|
627 | {
|
---|
628 | //write final header keys
|
---|
629 | fTable->makeThisCurrent();
|
---|
630 |
|
---|
631 | WriteKey("NBEVTOK", rt ? rt->nEventsOk : uint32_t(0),
|
---|
632 | "How many events were written");
|
---|
633 |
|
---|
634 | WriteKey("NBEVTREJ", rt ? rt->nEventsRej : uint32_t(0),
|
---|
635 | "How many events were rejected by SW-trig");
|
---|
636 |
|
---|
637 | WriteKey("NBEVTBAD", rt ? rt->nEventsBad : uint32_t(0),
|
---|
638 | "How many events were rejected by Error");
|
---|
639 |
|
---|
640 | //FIXME shouldn't we convert start and stop time to MjD first ?
|
---|
641 | //FIXME shouldn't we also add an MjD reference ?
|
---|
642 |
|
---|
643 | WriteKey("TSTART", rt ? rt->PCtime0 : uint32_t(0),
|
---|
644 | "Time when first event received");
|
---|
645 |
|
---|
646 | WriteKey("TSTOP", rt ? rt->PCtimeX : uint32_t(0),
|
---|
647 | "Time when last event received");
|
---|
648 | }
|
---|
649 |
|
---|
650 | // --------------------------------------------------------------------------
|
---|
651 | //
|
---|
652 | //! Closes the file, and before this it write the TAIL data
|
---|
653 | //! @param rt the pointer to the RUN_TAIL data structure
|
---|
654 | //
|
---|
655 | virtual bool Close(RUN_TAIL *rt = 0)
|
---|
656 | {
|
---|
657 | if (!fFile)
|
---|
658 | return false;
|
---|
659 |
|
---|
660 | WriteFooter(rt);
|
---|
661 |
|
---|
662 | delete fFile;
|
---|
663 | fFile = NULL;
|
---|
664 |
|
---|
665 | return true;
|
---|
666 | }
|
---|
667 |
|
---|
668 | };
|
---|
669 | #else
|
---|
670 | #define DataFileFits DataFileRaw
|
---|
671 | #endif
|
---|
672 |
|
---|
673 | class EventBuilderWrapper
|
---|
674 | {
|
---|
675 | public:
|
---|
676 | // FIXME
|
---|
677 | static EventBuilderWrapper *This;
|
---|
678 |
|
---|
679 | MessageImp &fMsg;
|
---|
680 |
|
---|
681 | private:
|
---|
682 | boost::thread fThread;
|
---|
683 |
|
---|
684 | enum CommandStates_t // g_runStat
|
---|
685 | {
|
---|
686 | kAbort = -2, // quit as soon as possible ('abort')
|
---|
687 | kExit = -1, // stop reading, quit when buffered events done ('exit')
|
---|
688 | kInitialize = 0, // 'initialize' (e.g. dim not yet started)
|
---|
689 | kHybernate = 1, // do nothing for long time ('hybernate') [wakeup within ~1sec]
|
---|
690 | kSleep = 2, // do nothing ('sleep') [wakeup within ~10msec]
|
---|
691 | kModeFlush = 10, // read data from camera, but skip them ('flush')
|
---|
692 | kModeTest = 20, // read data and process them, but do not write to disk ('test')
|
---|
693 | kModeFlag = 30, // read data, process and write all to disk ('flag')
|
---|
694 | kModeRun = 40, // read data, process and write selected to disk ('run')
|
---|
695 | };
|
---|
696 |
|
---|
697 | enum
|
---|
698 | {
|
---|
699 | kCurrent = 0,
|
---|
700 | kTotal = 1
|
---|
701 | };
|
---|
702 |
|
---|
703 | enum FileFormat_t
|
---|
704 | {
|
---|
705 | kNone,
|
---|
706 | kDebug,
|
---|
707 | kFits,
|
---|
708 | kRaw
|
---|
709 | };
|
---|
710 |
|
---|
711 | FileFormat_t fFileFormat;
|
---|
712 |
|
---|
713 |
|
---|
714 | uint32_t fMaxRun;
|
---|
715 | uint32_t fNumEvts[2];
|
---|
716 |
|
---|
717 | DimDescribedService fDimFiles;
|
---|
718 | DimDescribedService fDimRuns;
|
---|
719 | DimDescribedService fDimEvents;
|
---|
720 | DimDescribedService fDimCurrentEvent;
|
---|
721 | DimDescribedService fDimEventData;
|
---|
722 | DimDescribedService fDimFwVersion;
|
---|
723 | DimDescribedService fDimStatus;
|
---|
724 | DimDescribedService fDimDNA;
|
---|
725 | DimDescribedService fDimStatistics;
|
---|
726 |
|
---|
727 | bool fDebugStream;
|
---|
728 | bool fDebugRead;
|
---|
729 |
|
---|
730 | int Write(const Time &time, const std::string &txt, int qos)
|
---|
731 | {
|
---|
732 | return fMsg.Write(time, txt, qos);
|
---|
733 | }
|
---|
734 |
|
---|
735 | public:
|
---|
736 | EventBuilderWrapper(MessageImp &imp) : fMsg(imp),
|
---|
737 | fFileFormat(kRaw), fMaxRun(0),
|
---|
738 | fDimFiles ("FAD_CONTROL/FILES", "X:1", ""),
|
---|
739 | fDimRuns ("FAD_CONTROL/RUNS", "I:1", ""),
|
---|
740 | fDimEvents ("FAD_CONTROL/EVENTS", "I:2", ""),
|
---|
741 | fDimCurrentEvent("FAD_CONTROL/CURRENT_EVENT", "I:1", ""),
|
---|
742 | fDimEventData ("FAD_CONTROL/EVENT_DATA", "S:1;I:1;S:1;I:2;S:1;S", ""),
|
---|
743 | fDimFwVersion ("FAD_CONTROL/FIRMWARE_VERSION", "F:43", ""),
|
---|
744 | fDimStatus ("FAD_CONTROL/STATUS", "S:42", ""),
|
---|
745 | fDimDNA ("FAD_CONTROL/DNA", "X:40", ""),
|
---|
746 | fDimStatistics ("FAD_CONTROL/STATISTICS", "X:8", ""),
|
---|
747 | fDebugStream(false), fDebugRead(false)
|
---|
748 | {
|
---|
749 | if (This)
|
---|
750 | throw logic_error("EventBuilderWrapper cannot be instantiated twice.");
|
---|
751 |
|
---|
752 | This = this;
|
---|
753 |
|
---|
754 | memset(fNumEvts, 0, sizeof(fNumEvts));
|
---|
755 |
|
---|
756 | fDimRuns.Update(uint32_t(0));
|
---|
757 | fDimCurrentEvent.Update(uint32_t(0));
|
---|
758 | fDimEvents.Update(fNumEvts);
|
---|
759 |
|
---|
760 | for (size_t i=0; i<40; i++)
|
---|
761 | ConnectSlot(i, tcp::endpoint());
|
---|
762 | }
|
---|
763 | ~EventBuilderWrapper()
|
---|
764 | {
|
---|
765 | Abort();
|
---|
766 |
|
---|
767 | // FIXME: Used timed_join and abort afterwards
|
---|
768 | // What's the maximum time the eb need to abort?
|
---|
769 | fThread.join();
|
---|
770 | //ffMsg.Info("EventBuilder stopped.");
|
---|
771 |
|
---|
772 | for (vector<DataFileImp*>::iterator it=fFiles.begin(); it!=fFiles.end(); it++)
|
---|
773 | delete *it;
|
---|
774 | }
|
---|
775 |
|
---|
776 | bool IsThreadRunning()
|
---|
777 | {
|
---|
778 | return !fThread.timed_join(boost::posix_time::microseconds(0));
|
---|
779 | }
|
---|
780 |
|
---|
781 | void SetMaxMemory(unsigned int mb) const
|
---|
782 | {
|
---|
783 | if (mb*1000000<GetUsedMemory())
|
---|
784 | {
|
---|
785 | // ffMsg.Warn("...");
|
---|
786 | return;
|
---|
787 | }
|
---|
788 |
|
---|
789 | g_maxMem = mb*1000000;
|
---|
790 | }
|
---|
791 |
|
---|
792 | void StartThread(const vector<tcp::endpoint> &addr)
|
---|
793 | {
|
---|
794 | if (IsThreadRunning())
|
---|
795 | {
|
---|
796 | fMsg.Warn("Start - EventBuilder still running");
|
---|
797 | return;
|
---|
798 | }
|
---|
799 |
|
---|
800 | for (size_t i=0; i<40; i++)
|
---|
801 | ConnectSlot(i, addr[i]);
|
---|
802 |
|
---|
803 | g_runStat = kModeRun;
|
---|
804 |
|
---|
805 | fMsg.Message("Starting EventBuilder thread");
|
---|
806 |
|
---|
807 | fThread = boost::thread(StartEvtBuild);
|
---|
808 | }
|
---|
809 | void ConnectSlot(unsigned int i, const tcp::endpoint &addr)
|
---|
810 | {
|
---|
811 | if (i>39)
|
---|
812 | return;
|
---|
813 |
|
---|
814 | if (addr==tcp::endpoint())
|
---|
815 | {
|
---|
816 | DisconnectSlot(i);
|
---|
817 | return;
|
---|
818 | }
|
---|
819 |
|
---|
820 | g_port[i].sockAddr.sin_family = AF_INET;
|
---|
821 | g_port[i].sockAddr.sin_addr.s_addr = htonl(addr.address().to_v4().to_ulong());
|
---|
822 | g_port[i].sockAddr.sin_port = htons(addr.port());
|
---|
823 | // In this order
|
---|
824 | g_port[i].sockDef = 1;
|
---|
825 | }
|
---|
826 | void DisconnectSlot(unsigned int i)
|
---|
827 | {
|
---|
828 | if (i>39)
|
---|
829 | return;
|
---|
830 |
|
---|
831 | g_port[i].sockDef = 0;
|
---|
832 | // In this order
|
---|
833 | g_port[i].sockAddr.sin_family = AF_INET;
|
---|
834 | g_port[i].sockAddr.sin_addr.s_addr = 0;
|
---|
835 | g_port[i].sockAddr.sin_port = 0;
|
---|
836 | }
|
---|
837 | void IgnoreSlot(unsigned int i)
|
---|
838 | {
|
---|
839 | if (i>39)
|
---|
840 | return;
|
---|
841 | if (g_port[i].sockAddr.sin_port==0)
|
---|
842 | return;
|
---|
843 |
|
---|
844 | g_port[i].sockDef = -1;
|
---|
845 | }
|
---|
846 |
|
---|
847 |
|
---|
848 | void Abort()
|
---|
849 | {
|
---|
850 | fMsg.Message("Signal abort to EventBuilder thread...");
|
---|
851 | g_runStat = kAbort;
|
---|
852 | }
|
---|
853 |
|
---|
854 | void Exit()
|
---|
855 | {
|
---|
856 | fMsg.Message("Signal exit to EventBuilder thread...");
|
---|
857 | g_runStat = kExit;
|
---|
858 | }
|
---|
859 |
|
---|
860 | /*
|
---|
861 | void Wait()
|
---|
862 | {
|
---|
863 | fThread.join();
|
---|
864 | ffMsg.Message("EventBuilder stopped.");
|
---|
865 | }*/
|
---|
866 |
|
---|
867 | void Hybernate() const { g_runStat = kHybernate; }
|
---|
868 | void Sleep() const { g_runStat = kSleep; }
|
---|
869 | void FlushMode() const { g_runStat = kModeFlush; }
|
---|
870 | void TestMode() const { g_runStat = kModeTest; }
|
---|
871 | void FlagMode() const { g_runStat = kModeFlag; }
|
---|
872 | void RunMode() const { g_runStat = kModeRun; }
|
---|
873 |
|
---|
874 | // FIXME: To be removed
|
---|
875 | void SetMode(int mode) const { g_runStat = mode; }
|
---|
876 |
|
---|
877 | bool IsConnected(int i) const { return gi_NumConnect[i]==7; }
|
---|
878 | bool IsDisconnected(int i) const { return gi_NumConnect[i]<=0; }
|
---|
879 | int GetNumConnected(int i) const { return gi_NumConnect[i]; }
|
---|
880 |
|
---|
881 | void SetIgnore(int i, bool b) const { if (g_port[i].sockDef!=0) g_port[i].sockDef=b?-1:1; }
|
---|
882 | bool IsIgnored(int i) const { return g_port[i].sockDef==-1; }
|
---|
883 |
|
---|
884 | void SetDebugStream(bool b)
|
---|
885 | {
|
---|
886 | fDebugStream = b;
|
---|
887 | if (b)
|
---|
888 | return;
|
---|
889 |
|
---|
890 | for (int i=0; i<40; i++)
|
---|
891 | {
|
---|
892 | if (!fDumpStream[i].is_open())
|
---|
893 | continue;
|
---|
894 |
|
---|
895 | fDumpStream[i].close();
|
---|
896 |
|
---|
897 | ostringstream name;
|
---|
898 | name << "socket_dump-" << setfill('0') << setw(2) << i << ".bin";
|
---|
899 | fMsg.Message("Closed file '"+name.str()+"'");
|
---|
900 | }
|
---|
901 | }
|
---|
902 |
|
---|
903 | void SetDebugRead(bool b)
|
---|
904 | {
|
---|
905 | fDebugRead = b;
|
---|
906 | if (b || !fDumpRead.is_open())
|
---|
907 | return;
|
---|
908 |
|
---|
909 | fDumpRead.close();
|
---|
910 | fMsg.Message("Closed file 'socket_events.txt'");
|
---|
911 | }
|
---|
912 |
|
---|
913 | size_t GetUsedMemory() const { return gi_usedMem; }
|
---|
914 |
|
---|
915 | virtual int CloseOpenFiles() { CloseRunFile(0, 0); return 0; }
|
---|
916 |
|
---|
917 |
|
---|
918 | /*
|
---|
919 | struct OpenFileToDim
|
---|
920 | {
|
---|
921 | int code;
|
---|
922 | char fileName[FILENAME_MAX];
|
---|
923 | };
|
---|
924 |
|
---|
925 | SignalRunOpened(runid, filename);
|
---|
926 | // Send num open files
|
---|
927 | // Send runid, (more info about the run?), filename via dim
|
---|
928 |
|
---|
929 | SignalEvtWritten(runid);
|
---|
930 | // Send num events written of newest file
|
---|
931 |
|
---|
932 | SignalRunClose(runid);
|
---|
933 | // Send new num open files
|
---|
934 | // Send empty file-name if no file is open
|
---|
935 |
|
---|
936 | */
|
---|
937 |
|
---|
938 | // -------------- Mapped event builder callbacks ------------------
|
---|
939 |
|
---|
940 | vector<DataFileImp*> fFiles;
|
---|
941 |
|
---|
942 | FileHandle_t runOpen(uint32_t runid, RUN_HEAD *h, size_t)
|
---|
943 | {
|
---|
944 | // Check if file already exists...
|
---|
945 | DataFileImp *file = 0;
|
---|
946 | switch (fFileFormat)
|
---|
947 | {
|
---|
948 | case kNone: file = new DataFileNone(runid); break;
|
---|
949 | case kDebug: file = new DataFileDebug(runid); break;
|
---|
950 | case kFits: file = new DataFileFits(runid); break;
|
---|
951 | case kRaw: file = new DataFileRaw(runid); break;
|
---|
952 | }
|
---|
953 |
|
---|
954 | try
|
---|
955 | {
|
---|
956 | if (!file->OpenFile(h))
|
---|
957 | return 0;
|
---|
958 | }
|
---|
959 | catch (const exception &e)
|
---|
960 | {
|
---|
961 | return 0;
|
---|
962 | }
|
---|
963 |
|
---|
964 | fFiles.push_back(file);
|
---|
965 |
|
---|
966 | if (runid>fMaxRun)
|
---|
967 | {
|
---|
968 | fMaxRun = runid;
|
---|
969 | fNumEvts[kCurrent] = 0;
|
---|
970 |
|
---|
971 | fDimRuns.Update(fMaxRun);
|
---|
972 | fDimEvents.Update(fNumEvts);
|
---|
973 | fDimCurrentEvent.Update(uint32_t(0));
|
---|
974 | }
|
---|
975 |
|
---|
976 | fDimFiles.Update(fFiles.size());
|
---|
977 |
|
---|
978 | return reinterpret_cast<FileHandle_t>(file);
|
---|
979 | }
|
---|
980 |
|
---|
981 | int runWrite(FileHandle_t handler, EVENT *e, size_t)
|
---|
982 | {
|
---|
983 | DataFileImp *file = reinterpret_cast<DataFileImp*>(handler);
|
---|
984 |
|
---|
985 | if (!file->Write(e))
|
---|
986 | return -1;
|
---|
987 |
|
---|
988 | if (file->GetRunId()==fMaxRun)
|
---|
989 | {
|
---|
990 | fDimCurrentEvent.Update(e->EventNum);
|
---|
991 | fNumEvts[kCurrent]++;
|
---|
992 | }
|
---|
993 |
|
---|
994 | fNumEvts[kTotal]++;
|
---|
995 | fDimEvents.Update(fNumEvts);
|
---|
996 |
|
---|
997 | // ===> SignalEvtWritten(runid);
|
---|
998 | // Send num events written of newest file
|
---|
999 |
|
---|
1000 | /* close run runId (all all runs if runId=0) */
|
---|
1001 | /* return: 0=close scheduled / >0 already closed / <0 does not exist */
|
---|
1002 | //CloseRunFile(file->GetRunId(), time(NULL)+2) ;
|
---|
1003 |
|
---|
1004 | return 0;
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | int runClose(FileHandle_t handler, RUN_TAIL *tail, size_t)
|
---|
1008 | {
|
---|
1009 | DataFileImp *file = reinterpret_cast<DataFileImp*>(handler);
|
---|
1010 |
|
---|
1011 | const vector<DataFileImp*>::iterator it = find(fFiles.begin(), fFiles.end(), file);
|
---|
1012 | if (it==fFiles.end())
|
---|
1013 | {
|
---|
1014 | ostringstream str;
|
---|
1015 | str << "File handler (" << handler << ") requested to close by event builder doesn't exist.";
|
---|
1016 | fMsg.Fatal(str);
|
---|
1017 | return -1;
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | ostringstream str;
|
---|
1021 | str << "Closing file for run " << file->GetRunId() << " (" << file << ")" << endl;
|
---|
1022 | fMsg.Info(str);
|
---|
1023 |
|
---|
1024 | fFiles.erase(it);
|
---|
1025 |
|
---|
1026 | fDimFiles.Update(fFiles.size());
|
---|
1027 |
|
---|
1028 | const bool rc = file->Close(tail);
|
---|
1029 | if (!rc)
|
---|
1030 | {
|
---|
1031 | // Error message
|
---|
1032 | }
|
---|
1033 |
|
---|
1034 | delete file;
|
---|
1035 |
|
---|
1036 | // ==> SignalRunClose(runid);
|
---|
1037 | // Send new num open files
|
---|
1038 | // Send empty file-name if no file is open
|
---|
1039 |
|
---|
1040 | return rc ? 0 : -1;
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 | ofstream fDumpStream[40];
|
---|
1044 |
|
---|
1045 | void debugStream(int isock, void *buf, int len)
|
---|
1046 | {
|
---|
1047 | if (!fDebugStream)
|
---|
1048 | return;
|
---|
1049 |
|
---|
1050 | const int slot = isock/7;
|
---|
1051 | if (slot<0 || slot>39)
|
---|
1052 | return;
|
---|
1053 |
|
---|
1054 | if (!fDumpStream[slot].is_open())
|
---|
1055 | {
|
---|
1056 | ostringstream name;
|
---|
1057 | name << "socket_dump-" << setfill('0') << setw(2) << slot << ".bin";
|
---|
1058 |
|
---|
1059 | fDumpStream[slot].open(name.str().c_str(), ios::app);
|
---|
1060 | if (!fDumpStream[slot])
|
---|
1061 | {
|
---|
1062 | ostringstream str;
|
---|
1063 | str << "Open file '" << name << "': " << strerror(errno) << " (errno=" << errno << ")";
|
---|
1064 | fMsg.Error(str);
|
---|
1065 |
|
---|
1066 | return;
|
---|
1067 | }
|
---|
1068 |
|
---|
1069 | fMsg.Message("Opened file '"+name.str()+"' for writing.");
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | fDumpStream[slot].write(reinterpret_cast<const char*>(buf), len);
|
---|
1073 | }
|
---|
1074 |
|
---|
1075 | ofstream fDumpRead; // Stream to possibly dump docket events
|
---|
1076 |
|
---|
1077 | void debugRead(int isock, int ibyte, uint32_t event, uint32_t ftmevt, uint32_t runno, int state, uint32_t tsec, uint32_t tusec)
|
---|
1078 | {
|
---|
1079 | // isock = socketID (0-279)
|
---|
1080 | // ibyte = #bytes gelesen
|
---|
1081 | // event = eventId (oder 0 wenn noch nicht bekannt)
|
---|
1082 | // state : 1=finished reading data
|
---|
1083 | // 0=reading data
|
---|
1084 | // -1=start reading data (header)
|
---|
1085 | // -2=start reading data,
|
---|
1086 | // eventId not known yet (too little data)
|
---|
1087 | // tsec, tusec = time when reading seconds, microseconds
|
---|
1088 | //
|
---|
1089 | if (!fDebugRead || ibyte==0)
|
---|
1090 | return;
|
---|
1091 |
|
---|
1092 | if (!fDumpRead.is_open())
|
---|
1093 | {
|
---|
1094 | fDumpRead.open("socket_events.txt", ios::app);
|
---|
1095 | if (!fDumpRead)
|
---|
1096 | {
|
---|
1097 | ostringstream str;
|
---|
1098 | str << "Open file 'socket_events.txt': " << strerror(errno) << " (errno=" << errno << ")";
|
---|
1099 | fMsg.Error(str);
|
---|
1100 |
|
---|
1101 | return;
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 | fMsg.Message("Opened file 'socket_events.txt' for writing.");
|
---|
1105 |
|
---|
1106 | fDumpRead << "# START: " << Time().GetAsStr() << endl;
|
---|
1107 | fDumpRead << "# state time_sec time_usec socket slot runno event_id trigger_id bytes_received" << endl;
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | fDumpRead
|
---|
1111 | << setw(2) << state << " "
|
---|
1112 | << setw(8) << tsec << " "
|
---|
1113 | << setw(9) << tusec << " "
|
---|
1114 | << setw(3) << isock << " "
|
---|
1115 | << setw(2) << isock/7 << " "
|
---|
1116 | << runno << " "
|
---|
1117 | << event << " "
|
---|
1118 | << ftmevt << " "
|
---|
1119 | << ibyte << endl;
|
---|
1120 | }
|
---|
1121 |
|
---|
1122 | struct DimEventData
|
---|
1123 | {
|
---|
1124 | uint16_t Roi ; // #slices per pixel (same for all pixels and tmarks)
|
---|
1125 | uint32_t EventNum ; // EventNumber as from FTM
|
---|
1126 | uint16_t TriggerType ; // Trigger Type from FTM
|
---|
1127 |
|
---|
1128 | uint32_t PCTime ; // when did event start to arrive at PC
|
---|
1129 | uint32_t BoardTime; //
|
---|
1130 |
|
---|
1131 | int16_t StartPix; // First Channel per Pixel (Pixels sorted according Software ID) ; -1 if not filled
|
---|
1132 | int16_t StartTM; // First Channel for TimeMark (sorted Hardware ID) ; -1 if not filled
|
---|
1133 |
|
---|
1134 | uint16_t Adc_Data[]; // final length defined by malloc ....
|
---|
1135 |
|
---|
1136 | } __attribute__((__packed__));;
|
---|
1137 |
|
---|
1138 | template<typename T>
|
---|
1139 | vector<T> CheckVals(const PEVNT_HEADER *fadhd, const T *val, bool &rc)
|
---|
1140 | {
|
---|
1141 | const size_t offset = reinterpret_cast<const char*>(val)-reinterpret_cast<const char*>(fadhd);
|
---|
1142 |
|
---|
1143 | vector<T> vec(40);
|
---|
1144 |
|
---|
1145 | vec[0] = *val;
|
---|
1146 |
|
---|
1147 | rc = true;
|
---|
1148 | for (int i=1; i<40; i++)
|
---|
1149 | {
|
---|
1150 |
|
---|
1151 | const T &t = *reinterpret_cast<const T*>(reinterpret_cast<const char*>(fadhd+i)+offset);
|
---|
1152 | if (t!=*val)
|
---|
1153 | rc = false;
|
---|
1154 |
|
---|
1155 | vec[i] = t;
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | return vec;
|
---|
1159 | }
|
---|
1160 | /*
|
---|
1161 | template<typename T>
|
---|
1162 | vector<uint8_t> CheckBits(const PEVNT_HEADER *fadhd, const T &val, T &rc)
|
---|
1163 | {
|
---|
1164 | const size_t offset = reinterpret_cast<const char*>(&val)-reinterpret_cast<const char*>(fadhd);
|
---|
1165 |
|
---|
1166 | vector<uint8_t> vec(40);
|
---|
1167 |
|
---|
1168 | rc = 0;
|
---|
1169 | for (int i=0; i<40; i++)
|
---|
1170 | {
|
---|
1171 | const T &t = *reinterpret_cast<const T*>(reinterpret_cast<const char*>(fadhd+i)+offset);
|
---|
1172 |
|
---|
1173 | rc |= val^t;
|
---|
1174 |
|
---|
1175 | vec[i] = t;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | // Return 1 for all bits which are identical
|
---|
1179 | // 0 for all other bits
|
---|
1180 | rc = ~rc;
|
---|
1181 | return vec;
|
---|
1182 | }*/
|
---|
1183 |
|
---|
1184 |
|
---|
1185 | int eventCheck(PEVNT_HEADER *fadhd, EVENT *event)
|
---|
1186 | {
|
---|
1187 | /*
|
---|
1188 | fadhd[i] ist ein array mit den 40 fad-headers
|
---|
1189 | (falls ein board nicht gelesen wurde, ist start_package_flag =0 )
|
---|
1190 |
|
---|
1191 | event ist die Struktur, die auch die write routine erhaelt;
|
---|
1192 | darin sind im header die 'soll-werte' fuer z.B. eventID
|
---|
1193 | als auch die ADC-Werte (falls Du die brauchst)
|
---|
1194 |
|
---|
1195 | Wenn die routine einen negativen Wert liefert, wird das event
|
---|
1196 | geloescht (nicht an die write-routine weitergeleitet [mind. im Prinzip]
|
---|
1197 | */
|
---|
1198 |
|
---|
1199 | bool ok_verno;
|
---|
1200 | bool ok_runno;
|
---|
1201 | // uint16_t ok_bitmask;
|
---|
1202 | /*
|
---|
1203 | const vector<uint16_t> verno = CheckVals(fadhd, &fadhd->version_no, ok_verno);
|
---|
1204 | const vector<uint32_t> runno = CheckVals(fadhd, &fadhd->runnumber, ok_runno);
|
---|
1205 | // const vector<uint8_t> bitmask = CheckBits(fadhd, &fadhd->PLLLCK, ok_bitmask);
|
---|
1206 |
|
---|
1207 | static vector<uint16_t> fStoreVersion;
|
---|
1208 |
|
---|
1209 | if (verno!=fStoreVersion)
|
---|
1210 | {
|
---|
1211 | vector<float> data(40);
|
---|
1212 | for (int i=0; i<40; i++)
|
---|
1213 | {
|
---|
1214 | ostringstream ver;
|
---|
1215 | ver << (verno[i]&0xff) << '.' << (verno[i]>>8); // WARNING: No byte-swap yet!
|
---|
1216 | data[i] = atof(ver.str().c_str());
|
---|
1217 | }
|
---|
1218 | fDimFwVersion.Update(data);
|
---|
1219 | fStoreVersion=verno;
|
---|
1220 | }
|
---|
1221 | */
|
---|
1222 | /*
|
---|
1223 | uint16_t start_package_flag;
|
---|
1224 | uint16_t package_length;
|
---|
1225 | uint16_t version_no;
|
---|
1226 | uint16_t PLLLCK;
|
---|
1227 |
|
---|
1228 | uint16_t trigger_crc;
|
---|
1229 | uint16_t trigger_type;
|
---|
1230 | uint32_t trigger_id;
|
---|
1231 |
|
---|
1232 | uint32_t fad_evt_counter;
|
---|
1233 | uint32_t REFCLK_frequency;
|
---|
1234 |
|
---|
1235 | uint16_t board_id;
|
---|
1236 | uint8_t zeroes;
|
---|
1237 | int8_t adc_clock_phase_shift;
|
---|
1238 | uint16_t number_of_triggers_to_generate;
|
---|
1239 | uint16_t trigger_generator_prescaler;
|
---|
1240 |
|
---|
1241 | uint64_t DNA;
|
---|
1242 |
|
---|
1243 | uint32_t time;
|
---|
1244 | uint32_t runnumber;
|
---|
1245 |
|
---|
1246 | int16_t drs_temperature[NTemp];
|
---|
1247 |
|
---|
1248 | uint16_t dac[NDAC];
|
---|
1249 | */
|
---|
1250 |
|
---|
1251 | static DimEventData *data = 0;
|
---|
1252 |
|
---|
1253 | const size_t sz = sizeof(DimEventData)+event->Roi*2;
|
---|
1254 |
|
---|
1255 | if (data && data->Roi != event->Roi)
|
---|
1256 | {
|
---|
1257 | delete data;
|
---|
1258 | data = 0;
|
---|
1259 | }
|
---|
1260 |
|
---|
1261 | if (!data)
|
---|
1262 | data = reinterpret_cast<DimEventData*>(new char[sz]);
|
---|
1263 |
|
---|
1264 | // cout << sizeof(DimEventData) << " " << event->Roi << " " << sz << " " << sizeof(*data) << endl;
|
---|
1265 |
|
---|
1266 | data->Roi = event->Roi;
|
---|
1267 | data->EventNum = event->EventNum;
|
---|
1268 | data->TriggerType = event->TriggerType;
|
---|
1269 | data->PCTime = event->PCTime;
|
---|
1270 | data->BoardTime = event->BoardTime[0];
|
---|
1271 | data->StartPix = event->StartPix[0];
|
---|
1272 | data->StartTM = event->StartTM[0];
|
---|
1273 |
|
---|
1274 | memcpy(data->Adc_Data, event->Adc_Data, event->Roi*2);
|
---|
1275 |
|
---|
1276 | fDimEventData.setData(data, sz);
|
---|
1277 | fDimEventData.updateService();
|
---|
1278 |
|
---|
1279 | //delete data;
|
---|
1280 |
|
---|
1281 | return 0;
|
---|
1282 | }
|
---|
1283 |
|
---|
1284 | void factOut(int severity, int err, const char *message)
|
---|
1285 | {
|
---|
1286 | // FIXME: Make the output to the console stream thread-safe
|
---|
1287 | ostringstream str;
|
---|
1288 | str << "EventBuilder(";
|
---|
1289 | if (err<0)
|
---|
1290 | str << "---";
|
---|
1291 | else
|
---|
1292 | str << err;
|
---|
1293 | str << "): " << message;
|
---|
1294 |
|
---|
1295 | fMsg.Update(str, severity);
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | void factStat(int64_t *stat, int len)
|
---|
1299 | {
|
---|
1300 | if (len!=7)
|
---|
1301 | {
|
---|
1302 | fMsg.Warn("factStat received unknown number of values.");
|
---|
1303 | return;
|
---|
1304 | }
|
---|
1305 |
|
---|
1306 | vector<int64_t> data(1, g_maxMem);
|
---|
1307 | data.insert(data.end(), stat, stat+len);
|
---|
1308 |
|
---|
1309 | static vector<int64_t> last(8);
|
---|
1310 | if (data==last)
|
---|
1311 | return;
|
---|
1312 | last = data;
|
---|
1313 |
|
---|
1314 | fDimStatistics.Update(data);
|
---|
1315 |
|
---|
1316 | // len ist die Laenge des arrays.
|
---|
1317 | // array[4] enthaelt wieviele bytes im Buffer aktuell belegt sind; daran
|
---|
1318 | // kannst Du pruefen, ob die 100MB voll sind ....
|
---|
1319 |
|
---|
1320 | /*
|
---|
1321 | stat[0]= qwait;
|
---|
1322 | stat[1]= qskip;
|
---|
1323 | stat[2]= qdel ;
|
---|
1324 | stat[3]= qtot ;
|
---|
1325 | stat[4]= gi_usedMem ;
|
---|
1326 | stat[5]= qread;
|
---|
1327 | stat[6]= qconn;
|
---|
1328 | */
|
---|
1329 |
|
---|
1330 | ostringstream str;
|
---|
1331 | str
|
---|
1332 | << "Wait=" << stat[0] << " "
|
---|
1333 | << "Skip=" << stat[1] << " "
|
---|
1334 | << "Del=" << stat[2] << " "
|
---|
1335 | << "Tot=" << stat[3] << " "
|
---|
1336 | << "Mem=" << stat[4] << "/" << g_maxMem << " "
|
---|
1337 | << "Read=" << stat[5] << " "
|
---|
1338 | << "Conn=" << stat[6];
|
---|
1339 |
|
---|
1340 | fMsg.Info(str);
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | boost::array<FAD::EventHeader, 40> fVecHeader;
|
---|
1344 |
|
---|
1345 | template<typename T>
|
---|
1346 | pair<bool,boost::array<T, 43>> Compare(const FAD::EventHeader *h, const T *t, const uint64_t mask=~0, const uint8_t shift=0)
|
---|
1347 | {
|
---|
1348 | const int offset = reinterpret_cast<const char *>(t) - reinterpret_cast<const char *>(h);
|
---|
1349 |
|
---|
1350 | const T *min = NULL;
|
---|
1351 | const T *val = NULL;
|
---|
1352 | const T *max = NULL;
|
---|
1353 |
|
---|
1354 | boost::array<T, 43> vec;
|
---|
1355 |
|
---|
1356 | bool rc = true;
|
---|
1357 | for (int i=0; i<40; i++)
|
---|
1358 | {
|
---|
1359 | const char *base = reinterpret_cast<const char*>(&fVecHeader[i]);
|
---|
1360 | const T *ref = reinterpret_cast<const T*>(base+offset);
|
---|
1361 |
|
---|
1362 | vec[i+3] = (*ref&mask)>>shift;
|
---|
1363 |
|
---|
1364 | if (gi_NumConnect[i]!=7)
|
---|
1365 | {
|
---|
1366 | vec[i+3] = -1;
|
---|
1367 | continue;
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 | if (!val)
|
---|
1371 | {
|
---|
1372 | min = ref;
|
---|
1373 | val = ref;
|
---|
1374 | max = ref;
|
---|
1375 | }
|
---|
1376 |
|
---|
1377 | if (*val<*min)
|
---|
1378 | min = val;
|
---|
1379 |
|
---|
1380 | if (*val>*max)
|
---|
1381 | max = val;
|
---|
1382 |
|
---|
1383 | if ((*val&mask)!=(*ref&mask))
|
---|
1384 | rc = false;
|
---|
1385 | }
|
---|
1386 |
|
---|
1387 | if (!val)
|
---|
1388 | return make_pair(false, vec);
|
---|
1389 |
|
---|
1390 | vec[0] = (*min&mask)>>shift;
|
---|
1391 | vec[1] = (*val&mask)>>shift;
|
---|
1392 | vec[2] = (*max&mask)>>shift;
|
---|
1393 |
|
---|
1394 | return make_pair(rc, vec);
|
---|
1395 | }
|
---|
1396 |
|
---|
1397 | template<typename T>
|
---|
1398 | boost::array<T, 42> CompareBits(const FAD::EventHeader *h, const T *t)
|
---|
1399 | {
|
---|
1400 | const int offset = reinterpret_cast<const char *>(t) - reinterpret_cast<const char *>(h);
|
---|
1401 |
|
---|
1402 | T val = T(); // All bits 0
|
---|
1403 | T rc = T();
|
---|
1404 |
|
---|
1405 | boost::array<T, 42> vec;
|
---|
1406 |
|
---|
1407 | bool first = true;
|
---|
1408 |
|
---|
1409 | for (int i=0; i<40; i++)
|
---|
1410 | {
|
---|
1411 | const char *base = reinterpret_cast<const char*>(&fVecHeader[i]);
|
---|
1412 | const T *ref = reinterpret_cast<const T*>(base+offset);
|
---|
1413 |
|
---|
1414 | vec[i+2] = *ref;
|
---|
1415 |
|
---|
1416 | if (gi_NumConnect[i]!=7)
|
---|
1417 | {
|
---|
1418 | vec[i+2] = 0;
|
---|
1419 | continue;
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | if (first)
|
---|
1423 | {
|
---|
1424 | first = false;
|
---|
1425 | val = *ref;
|
---|
1426 | rc = 0;
|
---|
1427 | }
|
---|
1428 |
|
---|
1429 | rc |= val^*ref;
|
---|
1430 | }
|
---|
1431 |
|
---|
1432 | vec[0] = ~rc;
|
---|
1433 | vec[1] = val;
|
---|
1434 |
|
---|
1435 | return vec;
|
---|
1436 | }
|
---|
1437 |
|
---|
1438 | template<typename T, size_t N>
|
---|
1439 | void Update(DimDescribedService &svc, const pair<bool,boost::array<T, N>> &data)
|
---|
1440 | {
|
---|
1441 | svc.setQuality(data.first);
|
---|
1442 | svc.setData(const_cast<T*>(data.second.data()), sizeof(T)*N);
|
---|
1443 | svc.updateService();
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | template<typename T>
|
---|
1447 | void Print(const char *name, const pair<bool,boost::array<T, 43>> &data)
|
---|
1448 | {
|
---|
1449 | cout << name << "|" << data.first << "|" << data.second[1] << "|" << data.second[0] << "<x<" << data.second[1] << ":";
|
---|
1450 | for (int i=0; i<40;i++)
|
---|
1451 | cout << " " << data.second[i+3];
|
---|
1452 | cout << endl;
|
---|
1453 | }
|
---|
1454 |
|
---|
1455 | void debugHead(int socket, const FAD::EventHeader &h)
|
---|
1456 | {
|
---|
1457 | const uint16_t id = h.Id();
|
---|
1458 | if (id>39)
|
---|
1459 | return;
|
---|
1460 |
|
---|
1461 | const FAD::EventHeader old = fVecHeader[id];
|
---|
1462 |
|
---|
1463 | fVecHeader[id] = h;
|
---|
1464 |
|
---|
1465 | if (old.fVersion != h.fVersion)
|
---|
1466 | {
|
---|
1467 | const pair<bool, boost::array<uint16_t,43>> ver = Compare(&h, &h.fVersion);
|
---|
1468 |
|
---|
1469 | pair<bool, boost::array<float,43>> data;
|
---|
1470 | data.first = ver.first;
|
---|
1471 |
|
---|
1472 | for (int i=0; i<43; i++)
|
---|
1473 | {
|
---|
1474 | ostringstream str;
|
---|
1475 | str << (ver.second[i]>>8) << '.' << (ver.second[i]&0xff);
|
---|
1476 | data.second[i] = atof(str.str().c_str());
|
---|
1477 | }
|
---|
1478 | Update(fDimFwVersion, data);
|
---|
1479 | }
|
---|
1480 |
|
---|
1481 | /*
|
---|
1482 | uint16_t fTriggerType;
|
---|
1483 | uint32_t fTriggerId;
|
---|
1484 | uint32_t fEventCounter;
|
---|
1485 | uint32_t fFreqRefClock;
|
---|
1486 | uint16_t fAdcClockPhaseShift;
|
---|
1487 | uint16_t fNumTriggersToGenerate;
|
---|
1488 | uint16_t fTriggerGeneratorPrescaler;
|
---|
1489 | uint64_t fDNA; // Xilinx DNA
|
---|
1490 | uint32_t fTimeStamp;
|
---|
1491 | uint32_t fRunNumber;
|
---|
1492 | int16_t fTempDrs[kNumTemp]; // In units of 1/16 deg(?)
|
---|
1493 | uint16_t fDac[kNumDac];
|
---|
1494 | */
|
---|
1495 |
|
---|
1496 | if (old.fTriggerType != h.fTriggerType)
|
---|
1497 | {
|
---|
1498 | const pair<bool, boost::array<uint16_t,43>> typ = Compare(&h, &h.fTriggerType);
|
---|
1499 | Print("Typ", typ);
|
---|
1500 | }
|
---|
1501 |
|
---|
1502 | if (old.fRunNumber != h.fRunNumber)
|
---|
1503 | {
|
---|
1504 | const pair<bool, boost::array<uint32_t,43>> run = Compare(&h, &h.fRunNumber);
|
---|
1505 | Print("Run", run);
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 | if (old.fDNA != h.fDNA)
|
---|
1509 | {
|
---|
1510 | const pair<bool, boost::array<uint64_t,43>> dna = Compare(&h, &h.fDNA);
|
---|
1511 | fDimDNA.setData(const_cast<uint64_t*>(dna.second.data())+3, 40*sizeof(uint64_t));
|
---|
1512 | fDimDNA.updateService();
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 | if (old.fStatus != h.fStatus)
|
---|
1516 | {
|
---|
1517 | const boost::array<uint16_t,42> sts = CompareBits(&h, &h.fStatus);
|
---|
1518 | fDimStatus.setData(const_cast<uint16_t*>(sts.data()), 42*sizeof(uint16_t));
|
---|
1519 | fDimStatus.updateService();
|
---|
1520 | }
|
---|
1521 | }
|
---|
1522 | };
|
---|
1523 |
|
---|
1524 | EventBuilderWrapper *EventBuilderWrapper::This = 0;
|
---|
1525 |
|
---|
1526 | // ----------- Event builder callbacks implementation ---------------
|
---|
1527 | extern "C"
|
---|
1528 | {
|
---|
1529 | FileHandle_t runOpen(uint32_t irun, RUN_HEAD *runhd, size_t len)
|
---|
1530 | {
|
---|
1531 | return EventBuilderWrapper::This->runOpen(irun, runhd, len);
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | int runWrite(FileHandle_t fileId, EVENT *event, size_t len)
|
---|
1535 | {
|
---|
1536 | return EventBuilderWrapper::This->runWrite(fileId, event, len);
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 | int runClose(FileHandle_t fileId, RUN_TAIL *runth, size_t len)
|
---|
1540 | {
|
---|
1541 | return EventBuilderWrapper::This->runClose(fileId, runth, len);
|
---|
1542 | }
|
---|
1543 |
|
---|
1544 | void factOut(int severity, int err, const char *message)
|
---|
1545 | {
|
---|
1546 | EventBuilderWrapper::This->factOut(severity, err, message);
|
---|
1547 | }
|
---|
1548 |
|
---|
1549 | void factStat(int64_t *array, int len)
|
---|
1550 | {
|
---|
1551 | EventBuilderWrapper::This->factStat(array, len);
|
---|
1552 | }
|
---|
1553 |
|
---|
1554 | void debugHead(int socket, void *buf)
|
---|
1555 | {
|
---|
1556 | EventBuilderWrapper::This->debugHead(socket, FAD::EventHeader(vector<uint16_t>(reinterpret_cast<uint16_t*>(buf),
|
---|
1557 | reinterpret_cast<uint16_t*>(buf)+sizeof(FAD::EventHeader)/2)));
|
---|
1558 | }
|
---|
1559 |
|
---|
1560 | void debugStream(int isock, void *buf, int len)
|
---|
1561 | {
|
---|
1562 | return EventBuilderWrapper::This->debugStream(isock, buf, len);
|
---|
1563 | }
|
---|
1564 |
|
---|
1565 | void debugRead(int isock, int ibyte, int32_t event, int32_t ftmevt, int32_t runno, int state, uint32_t tsec, uint32_t tusec)
|
---|
1566 | {
|
---|
1567 | return EventBuilderWrapper::This->debugRead(isock, ibyte, event, ftmevt, runno, state, tsec, tusec);
|
---|
1568 | }
|
---|
1569 |
|
---|
1570 | int eventCheck(PEVNT_HEADER *fadhd, EVENT *event)
|
---|
1571 | {
|
---|
1572 | return EventBuilderWrapper::This->eventCheck(fadhd, event);
|
---|
1573 | }
|
---|
1574 | }
|
---|
1575 |
|
---|
1576 | #endif
|
---|