FACT++  1.0
DataWriteRaw.h
Go to the documentation of this file.
1 #ifndef FACT_DataWriteRaw
2 #define FACT_DataWriteRaw
3 
4 #include "DataProcessorImp.h"
5 
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 
69 public:
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  {
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
std::ofstream fOut
Definition: DataWriteRaw.h:8
The base implementation of a distributed messaging system.
Definition: MessageImp.h:10
bool Open(const RUN_HEAD &h, const FAD::RunDescription &d)
Definition: DataWriteRaw.cc:21
bool Close(const EVT_CTRL2 &)
Definition: DataWriteRaw.h:85
void WriteBlockHeader(uint32_t type, uint32_t ver, uint32_t cnt, uint32_t len)
Definition: DataWriteRaw.cc:8
off_t fPosTail
Definition: DataWriteRaw.h:10
Definition: FAD.h:92
int type
DataWriteRaw(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp)
Definition: DataWriteRaw.h:70
void WriteValue(const T &t)
Definition: DataWriteRaw.cc:16
bool WriteEvt(const EVT_CTRL2 &)
Definition: DataWriteRaw.cc:81
TT t
Definition: test_client.c:26
uint32_t fCounter
Definition: DataWriteRaw.h:12