DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
CTBPacketContent.hpp
Go to the documentation of this file.
1/*
2 * CTBPacketContent.hpp
3 *
4 * Ported from https://cdcvs.fnal.gov/redmine/projects/dune-raw-data/repository/revisions/develop/entry/dune-raw-data/Overlays/CTB_content.h
5 *
6 * Developer: willpvazquez (27 July 2022)
7 *
8 * Originally Created on: Oct 8, 2017
9 * Author: nbarros
10 */
11
12#ifndef CTBMODULES_SRC_CTBPACKETCONTENT_HPP_
13#define CTBMODULES_SRC_CTBPACKETCONTENT_HPP_
14
15#include <cstdint>
16
17namespace dunedaq {
18 namespace ctbmodules{
19 namespace content {
20
21 // NFB: Note that order denotes bit order in the word:
22 // Upper fields are in the lsb and lower field is in the msb
25 //static uint8_t format_version = 0x2;
26
27 typedef struct buffer_t {
28 int handle;
29 size_t len;
31
35
36 typedef struct tcp_header_t {
37 typedef uint16_t pkt_size_t;
38 typedef uint8_t seq_size_t;
39 typedef uint8_t ver_size_t;
40 uint16_t packet_size : 16; // Size of the data content in bytes
41 uint8_t sequence_id : 8; // packet order...rotates every 256
42 uint8_t format_version : 8;
43 static size_t const size_bytes = sizeof(uint32_t);
44 static size_t const n_bits_size = 16;
45 static size_t const n_bits_sequence_id = 8;
46 static size_t const n_bits_version = 8;
48
49 // NFB: Careful with unions. Setting one member and then accessing another
50 // is undefined behavior in C++.
51 // However, I have tested that they work on gcc on the PTB
52
53 typedef union tcp_header {
55 uint32_t value;
57
58 namespace word {
59 enum word_type {t_fback=0x0,t_lt=0x1,t_gt=0x2, t_ch=0x3,t_chksum=0x4,t_ts=0x7};
63 // -- The body of a word is composed of 12 bytes
64 typedef uint16_t trigger_code_t;
75
76 typedef struct word_t {
77 typedef uint64_t ts_size_t;
78 typedef uint64_t pad_size_t;
79 typedef uint64_t word_type_t;
83 static size_t const size_bytes = 4*sizeof(uint32_t);
84 static size_t const size_u32 = 4*sizeof(uint32_t)/sizeof(uint32_t);
85 static size_t const n_bits_timestamp = 64;
86 static size_t const n_bits_payload = 61;
87 static size_t const n_bits_type = 3;
89
90 typedef union word{
92 uint8_t *get_bytes() {return reinterpret_cast<uint8_t*>(&frame);}
94
98
99 typedef struct feedback_t {
100 typedef uint64_t ts_size_t;
101 typedef uint16_t code_size_t;
102 typedef uint16_t source_size_t;
103 typedef uint32_t wtype_size_t;
104 typedef uint32_t pad_size_t;
110 static size_t const size_bytes = 2*sizeof(uint64_t);
111 static size_t const size_u32 = size_bytes/sizeof(uint32_t);
112 static size_t const n_bits_timestamp = 64;
113 static size_t const n_bits_payload = 32;
114 static size_t const n_bits_type = 3;
116
117 typedef struct ch_status_t {
118 typedef uint64_t ts_size_t;
119 typedef uint64_t pds_size_t;
120 typedef uint64_t crt_size_t;
121 typedef uint64_t beam_size_t;
122 typedef uint64_t wtype_size_t;
129 static size_t const size_bytes = 2*sizeof(uint64_t);
130 static size_t const size_u32 = size_bytes/sizeof(uint32_t);
131 static size_t const n_bits_timestamp = 60;
132 static size_t const n_bits_payload = 32;
133 static size_t const n_bits_type = 3;
134
135 // aux_functions
136 beam_size_t get_beam() const {return (beam_hi << 4 | beam_lo);}
137 crt_size_t get_crt() const {return (crt & 0xFFFFFFFF);}
138 pds_size_t get_pds() const {return (pds & 0x1FFFF);}
139
140 bool get_state_crt(const uint16_t channel) {
141 return ((crt & (0x1 << channel)) != 0x0);
142 }
143
144 bool get_state_pds(const uint16_t channel) {
145 return ((pds & (0x1 << channel)) != 0x0);
146 }
147
148 bool get_state_beam(const uint16_t channel) {
149 return (((beam_hi << 4 | beam_lo) & (0x1 << channel)) != 0x0);
150 }
152
153 typedef struct timestamp_t {
154 typedef uint64_t ts_size_t;
155 typedef uint64_t pad_size_t;
156 typedef uint64_t wtype_size_t;
160 static size_t const size_bytes = 2*sizeof(uint64_t);
161 static size_t const size_u32 = size_bytes/sizeof(uint32_t);
162 static size_t const n_bits_timestamp = 64;
163 static size_t const n_bits_unused = 61;
164 static size_t const n_bits_type = 3;
166
167 typedef struct trigger_t {
168 typedef uint64_t ts_size_t;
169 typedef uint64_t mask_size_t;
170 typedef uint64_t wtype_size_t;
174 static size_t const size_bytes = 2*sizeof(uint64_t);
175 static size_t const size_u32 = size_bytes/sizeof(uint32_t);
176 static size_t const n_bits_timestamp = 64;
177 static size_t const n_bits_tmask = 61;
178 static size_t const n_bits_type = 3;
179
180 bool IsHLT() const { return word_type == word_type::t_gt ; }
181 bool IsLLT() const { return word_type == word_type::t_lt ; }
182 bool IsTrigger( const unsigned int i ) const {
183 if ( IsHLT() ) return trigger_word & ( 0x1 << i ) ;
184 if ( IsLLT() ) return i == 0 ? false : trigger_word & ( 0x1 << (i-1) ) ;
185 return false ;
186 }
188
189 } // -- namespace word
190 } // -- namespace content
191 } // -- namespace ctbmodules
192} // -- namespace dunedaq
193
194#endif /* CTBMODULES_SRC_CTBPACKETCONTENT_HPP_ */
struct dunedaq::ctbmodules::content::word::timestamp_t timestamp_t
struct dunedaq::ctbmodules::content::word::feedback_t feedback_t
struct dunedaq::ctbmodules::content::word::ch_status_t ch_status_t
struct dunedaq::ctbmodules::content::word::trigger_t trigger_t
struct dunedaq::ctbmodules::content::word::word_t word_t
union dunedaq::ctbmodules::content::word::word word
union dunedaq::ctbmodules::content::tcp_header tcp_header
struct dunedaq::ctbmodules::content::tcp_header_t tcp_header_t
struct dunedaq::ctbmodules::content::buffer_t buffer_t
Including Qt Headers.