-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSTFBuilder.h
106 lines (89 loc) · 2.95 KB
/
STFBuilder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef STFBuilder_H
#define STFBuilder_H
#include <string>
#include <string_view>
#include <cstdint>
#include <deque>
#include <memory>
#include <queue>
#include <fairmq/Device.h>
#include "AmQStrTdcData.h"
/* HBFRAME */
//constexpr uint64_t HBFMagic = 0x00454d4152464248;
// HRTBEAT
constexpr uint64_t HBFMagic = 0x0054414542545248;
#pragma pack(4)
struct HBFHeader {
uint64_t magic {HBFMagic};
uint32_t length {0};
uint16_t hLength {0};
uint16_t reserve {0};
};
#pragma pack()
struct FEMInfo {
uint64_t magic {0};
uint32_t femType {0};
uint32_t femId {0};
uint64_t reserved {0};
};
enum class TimeFrameIdType : int {
FirstHeartbeatDelimiter = 0,
LastHeartbeatDelimiter,
SequenceNumberOfTimeFrames
};
class AmQStrTdcSTFBuilder : public fair::mq::Device
{
public:
using WorkBuffer = std::unique_ptr<std::vector<FairMQMessagePtr>>;
using RecvBuffer = std::vector<AmQStrTdc::Data::Word>; //64 bits
using SendBuffer = std::queue<WorkBuffer>;
struct OptionKey {
static constexpr std::string_view FEMId {"fem-id"};
static constexpr std::string_view InputChannelName {"in-chan-name"};
static constexpr std::string_view OutputChannelName {"out-chan-name"};
static constexpr std::string_view DQMChannelName {"dqm-chan-name"};
static constexpr std::string_view StripHBF {"strip-hbf"};
static constexpr std::string_view MaxHBF {"max-hbf"};
static constexpr std::string_view SplitMethod {"split"};
static constexpr std::string_view TimeFrameIdType {"time-frame-id-type"};
};
AmQStrTdcSTFBuilder();
AmQStrTdcSTFBuilder(const AmQStrTdcSTFBuilder&) = delete;
AmQStrTdcSTFBuilder& operator=(const AmQStrTdcSTFBuilder&) = delete;
~AmQStrTdcSTFBuilder() = default;
private:
void BuildFrame(FairMQMessagePtr& msg, int index);
void FillData(AmQStrTdc::Data::Word* first,
AmQStrTdc::Data::Word* last);
void FinalizeSTF();
bool HandleData(FairMQMessagePtr&, int index);
void Init() override;
void InitTask() override;
void NewData();
void PostRun() override;
void PreRun() override;
uint64_t fFEMId {0};
uint64_t fFEMType {0};
int fNumDestination {0};
std::string fInputChannelName;
std::string fOutputChannelName;
std::string fDQMChannelName;
int fMaxHBF {1};
int fHBFCounter {0};
int hbf_flag {0};
int32_t fdelimiterFrameId {0};
uint32_t fSTFSequenceNumber {0};
int fSplitMethod {0};
uint8_t fLastHeader {0};
int fH_flag {0};
uint16_t fThrottlingIn {0};
uint16_t fThrottlingOut {0};
TimeFrameIdType fTimeFrameIdType;
int32_t fSTFId{-1}; // 8-bit spill counter and 16-bit HB frame from heartbeat delimiter
bool mdebug;
RecvBuffer fInputPayloads;
RecvBuffer fInputDataloads;
WorkBuffer fWorkingPayloads;
SendBuffer fOutputPayloads;
};
#endif