source: trunk/FACT++/src/DataWriteRaw.h@ 19672

Last change on this file since 19672 was 17330, checked in by tbretz, 11 years ago
Give access to the full information in Open/Write/Close
File size: 2.2 KB
Line 
1#ifndef FACT_DataWriteRaw
2#define FACT_DataWriteRaw
3
4#include "DataProcessorImp.h"
5
6class DataWriteRaw : public DataProcessorImp
7{
8 std::ofstream fOut;
9
10 off_t fPosTail;
11
12 uint32_t fCounter;
13
14
15 // WRITE uint32_t 0xFAC77e1e (FACT Tele)
16 // ===
17 // WRITE uint32_t TYPE(>0) == 1
18 // WRITE uint32_t ID(>0) == 0
19 // WRITE uint32_t VERSION(>0) == 1
20 // WRITE uint32_t LENGTH
21 // -
22 // WRITE uint32_t TELESCOPE ID
23 // WRITE uint32_t RUNID
24 // ===
25 // WRITE uint32_t TYPE(>0) == 2
26 // WRITE uint32_t ID(>0) == 0
27 // WRITE uint32_t VERSION(>0) == 1
28 // WRITE uint32_t LENGTH
29 // -
30 // WRITE HEADER
31 // ===
32 // [ 40 TIMES
33 // WRITE uint32_t TYPE(>0) == 3
34 // WRITE uint32_t ID(>0) == 0..39
35 // WRITE uint32_t VERSION(>0) == 1
36 // WRITE uint32_t LENGTH
37 // -
38 // WRITE BOARD-HEADER
39 // ]
40 // ===
41 // WRITE uint32_t TYPE(>0) == 4
42 // WRITE uint32_t ID(>0) == 0
43 // WRITE uint32_t VERSION(>0) == 1
44 // WRITE uint32_t LENGTH
45 // -
46 // WRITE FOOTER (empty)
47 // ===
48 // [ N times
49 // WRITE uint32_t TYPE(>0) == 10
50 // WRITE uint32_t ID(>0) == counter
51 // WRITE uint32_t VERSION(>0) == 1
52 // WRITE uint32_t LENGTH HEADER
53 // -
54 // WRITE HEADER+DATA
55 // ]
56 // ===
57 // WRITE uint32_t TYPE ==0
58 // WRITE uint32_t VERSION==0
59 // WRITE uint32_t LENGTH ==0
60 // ===
61 // Go back and write footer
62
63 void WriteBlockHeader(uint32_t type, uint32_t ver, uint32_t cnt, uint32_t len);
64
65 template<typename T>
66 void WriteValue(const T &t);
67
68
69public:
70 DataWriteRaw(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp) : DataProcessorImp(path, night, id, imp), fPosTail(0) { }
71 ~DataWriteRaw() { if (fOut.is_open()) Close(); }
72
73 enum
74 {
75 kEndOfFile = 0,
76 kIdentifier = 1,
77 kRunHeader,
78 kBoardHeader,
79 kRunSummary,
80 kEvent,
81 };
82
83 bool Open(const RUN_HEAD &h, const FAD::RunDescription &d);
84 bool WriteEvt(const EVT_CTRL2 &);
85 bool Close(const EVT_CTRL2 &) { return Close(); }
86 bool Close();
87};
88
89#endif
Note: See TracBrowser for help on using the repository browser.