DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::fddetdataformats::DAPHNEStreamFrame Class Reference

#include <DAPHNEStreamFrame.hpp>

Collaboration diagram for dunedaq::fddetdataformats::DAPHNEStreamFrame:
[legend]

Classes

struct  Header
 
struct  Trailer
 

Public Types

typedef uint32_t word_t
 

Public Member Functions

uint64_t get_timestamp () const
 
void set_timestamp (const uint64_t new_timestamp)
 Set the 64-bit timestamp of the frame.
 
uint16_t get_adc (uint i, uint chn) const
 Get the i ADC value of chn in the frame.
 
void set_adc (uint i, uint chn, uint16_t val)
 Set the i ADC value of chn in the frame to val.
 
uint8_t get_channel0 () const
 Get the channel 0 from the DAPHNE Stream frame header

 
uint8_t get_channel1 () const
 Get the channel 1 from the DAPHNE Stream frame header

 
uint8_t get_channel2 () const
 Get the channel 2 from the DAPHNE Stream frame header

 
uint8_t get_channel3 () const
 Get the channel 3 from the DAPHNE Stream frame header

 

Public Attributes

detdataformats::DAQHeader daq_header
 
Header header
 
word_t adc_words [s_num_adc_words]
 
Trailer trailer
 

Static Public Attributes

static constexpr int s_bits_per_adc = 14
 
static constexpr int s_bits_per_word = 8 * sizeof(word_t)
 
static constexpr int s_channels_per_frame = 4
 
static constexpr int s_adcs_per_channel = 64
 
static constexpr int s_daphnes_per_frame = 1
 
static constexpr int s_num_adc_words = s_channels_per_frame * s_adcs_per_channel * s_bits_per_adc / s_bits_per_word
 

Detailed Description

Definition at line 29 of file DAPHNEStreamFrame.hpp.

Member Typedef Documentation

◆ word_t

Member Function Documentation

◆ get_adc()

uint16_t dunedaq::fddetdataformats::DAPHNEStreamFrame::get_adc ( uint i,
uint chn ) const
inline

Get the i ADC value of chn in the frame.

Definition at line 86 of file DAPHNEStreamFrame.hpp.

87 {
88
89 if (i >= s_adcs_per_channel)
90 throw std::out_of_range("ADC index out of range");
91
92 if (chn >= s_channels_per_frame)
93 throw std::out_of_range("ADC index out of range");
94
95 // find absolute index in frame
96 uint j = i*s_channels_per_frame+chn;
97 // The index of the first (and sometimes only) word containing the required ADC value
98 uint word_index = s_bits_per_adc * j / s_bits_per_word;
99 assert(word_index < s_num_adc_words);
100 // Where in the word the lowest bit of our ADC value is located
101 int first_bit_position = (s_bits_per_adc * j) % s_bits_per_word;
102 // How many bits of our desired ADC are located in the `word_index`th word
103 int bits_from_first_word = std::min(s_bits_per_adc, s_bits_per_word - first_bit_position);
104 uint16_t adc = adc_words[word_index] >> first_bit_position; // NOLINT(build/unsigned)
105
106 if (bits_from_first_word < s_bits_per_adc) {
107 assert(word_index + 1 < s_num_adc_words);
108 adc |= adc_words[word_index + 1] << bits_from_first_word;
109 }
110 // Mask out all but the lowest 14 bits;
111 return adc & 0x3FFFu;
112 }

◆ get_channel0()

uint8_t dunedaq::fddetdataformats::DAPHNEStreamFrame::get_channel0 ( ) const
inline

Get the channel 0 from the DAPHNE Stream frame header

Definition at line 151 of file DAPHNEStreamFrame.hpp.

◆ get_channel1()

uint8_t dunedaq::fddetdataformats::DAPHNEStreamFrame::get_channel1 ( ) const
inline

Get the channel 1 from the DAPHNE Stream frame header

Definition at line 155 of file DAPHNEStreamFrame.hpp.

155{ return header.channel_1; } // NOLINT(build/unsigned)

◆ get_channel2()

uint8_t dunedaq::fddetdataformats::DAPHNEStreamFrame::get_channel2 ( ) const
inline

Get the channel 2 from the DAPHNE Stream frame header

Definition at line 159 of file DAPHNEStreamFrame.hpp.

159{ return header.channel_2; } // NOLINT(build/unsigned)

◆ get_channel3()

uint8_t dunedaq::fddetdataformats::DAPHNEStreamFrame::get_channel3 ( ) const
inline

Get the channel 3 from the DAPHNE Stream frame header

Definition at line 163 of file DAPHNEStreamFrame.hpp.

163{ return header.channel_3; } // NOLINT(build/unsigned)

◆ get_timestamp()

uint64_t dunedaq::fddetdataformats::DAPHNEStreamFrame::get_timestamp ( ) const
inline

Definition at line 69 of file DAPHNEStreamFrame.hpp.

70 {
72 }

◆ set_adc()

void dunedaq::fddetdataformats::DAPHNEStreamFrame::set_adc ( uint i,
uint chn,
uint16_t val )
inline

Set the i ADC value of chn in the frame to val.

Definition at line 117 of file DAPHNEStreamFrame.hpp.

118 {
119
120 if (i >= s_adcs_per_channel)
121 throw std::out_of_range("ADC index out of range");
122
123 if (chn >= s_channels_per_frame)
124 throw std::out_of_range("ADC index out of range");
125
126 if (val >= (1 << s_bits_per_adc))
127 throw std::out_of_range("ADC value out of range");
128
129
130 // find absolute index in frame
131 uint j = i*s_channels_per_frame+chn;
132 // The index of the first (and sometimes only) word containing the required ADC value
133 int word_index = s_bits_per_adc * j / s_bits_per_word;
134 assert(word_index < s_num_adc_words);
135 // Where in the word the lowest bit of our ADC value is located
136 int first_bit_position = (s_bits_per_adc * j) % s_bits_per_word;
137 // How many bits of our desired ADC are located in the `word_index`th word
138 int bits_in_first_word = std::min(s_bits_per_adc, s_bits_per_word - first_bit_position);
139 uint32_t mask = (1 << (first_bit_position)) - 1;
140 adc_words[word_index] = ((val << first_bit_position) & ~mask) | (adc_words[word_index] & mask);
141 // If we didn't put the full 14 bits in this word, we need to put the rest in the next word
142 if (bits_in_first_word < s_bits_per_adc) {
143 assert(word_index + 1 < s_num_adc_words);
144 mask = (1 << (s_bits_per_adc - bits_in_first_word)) - 1;
145 adc_words[word_index + 1] = ((val >> bits_in_first_word) & mask) | (adc_words[word_index + 1] & ~mask);
146 }
147
148 }

◆ set_timestamp()

void dunedaq::fddetdataformats::DAPHNEStreamFrame::set_timestamp ( const uint64_t new_timestamp)
inline

Set the 64-bit timestamp of the frame.

Definition at line 76 of file DAPHNEStreamFrame.hpp.

77 {
78 daq_header.timestamp_1 = new_timestamp;
79 daq_header.timestamp_2 = new_timestamp >> 32;
80 }

Member Data Documentation

◆ adc_words

word_t dunedaq::fddetdataformats::DAPHNEStreamFrame::adc_words[s_num_adc_words]

Definition at line 62 of file DAPHNEStreamFrame.hpp.

◆ daq_header

detdataformats::DAQHeader dunedaq::fddetdataformats::DAPHNEStreamFrame::daq_header

Definition at line 60 of file DAPHNEStreamFrame.hpp.

◆ header

Header dunedaq::fddetdataformats::DAPHNEStreamFrame::header

Definition at line 61 of file DAPHNEStreamFrame.hpp.

◆ s_adcs_per_channel

int dunedaq::fddetdataformats::DAPHNEStreamFrame::s_adcs_per_channel = 64
staticconstexpr

Definition at line 42 of file DAPHNEStreamFrame.hpp.

◆ s_bits_per_adc

int dunedaq::fddetdataformats::DAPHNEStreamFrame::s_bits_per_adc = 14
staticconstexpr

Definition at line 39 of file DAPHNEStreamFrame.hpp.

◆ s_bits_per_word

int dunedaq::fddetdataformats::DAPHNEStreamFrame::s_bits_per_word = 8 * sizeof(word_t)
staticconstexpr

Definition at line 40 of file DAPHNEStreamFrame.hpp.

◆ s_channels_per_frame

int dunedaq::fddetdataformats::DAPHNEStreamFrame::s_channels_per_frame = 4
staticconstexpr

Definition at line 41 of file DAPHNEStreamFrame.hpp.

◆ s_daphnes_per_frame

int dunedaq::fddetdataformats::DAPHNEStreamFrame::s_daphnes_per_frame = 1
staticconstexpr

Definition at line 43 of file DAPHNEStreamFrame.hpp.

◆ s_num_adc_words

int dunedaq::fddetdataformats::DAPHNEStreamFrame::s_num_adc_words = s_channels_per_frame * s_adcs_per_channel * s_bits_per_adc / s_bits_per_word
staticconstexpr

Definition at line 44 of file DAPHNEStreamFrame.hpp.

◆ trailer

Trailer dunedaq::fddetdataformats::DAPHNEStreamFrame::trailer

Definition at line 63 of file DAPHNEStreamFrame.hpp.


The documentation for this class was generated from the following file: