DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
unpack.cpp
Go to the documentation of this file.
1
8
15
16#include <pybind11/numpy.h>
17#include <pybind11/pybind11.h>
18#include <pybind11/stl.h>
19
20#include <fmt/core.h>
21
22namespace py = pybind11;
23
24namespace dunedaq {
25namespace rawdatautils {
26
27void
29{
30 uint64_t* data = static_cast<uint64_t*>(frag.get_data());
31 size_t data_size = (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) / 8;
32
33 for (size_t i(0); i < data_size; ++i) {
34 fmt::print("{:06d} 0x{:016x}\n", i, data[i]);
35 }
36}
37
38namespace wibeth {
39extern uint32_t
41extern py::array_t<uint16_t>
43extern py::array_t<uint16_t>
44np_array_adc_data(void* data, uint32_t n_frames);
45extern py::array_t<uint64_t>
47extern py::array_t<uint64_t>
48np_array_timestamp_data(void* data, uint32_t n_frames);
49}
50
51namespace daphne {
52extern uint32_t
54extern py::array_t<uint16_t>
56extern py::array_t<uint8_t>
58extern py::array_t<uint16_t>
59np_array_adc_data(void* data, int nframes);
60extern py::array_t<uint64_t>
62extern py::array_t<uint64_t>
63np_array_timestamp_data(void* data, int nframes);
64extern py::array_t<uint8_t>
65np_array_channels_data(void* data, int nframes);
66
67extern uint32_t
69extern py::array_t<uint16_t>
71extern py::array_t<uint8_t>
73extern py::array_t<uint16_t>
74np_array_adc_stream_data(void* data, int nframes);
75extern py::array_t<uint64_t>
77extern py::array_t<uint64_t>
78np_array_timestamp_stream_data(void* data, int nframes);
79extern py::array_t<uint8_t>
80np_array_channels_stream_data(void* data, int nframes);
81
82}
83
84namespace daphneeth {
85extern uint32_t
87extern py::array_t<uint16_t>
89extern py::array_t<uint8_t>
91extern py::array_t<uint16_t>
92np_array_adc_data(void* data, int nframes);
93extern py::array_t<uint64_t>
95extern py::array_t<uint64_t>
96np_array_timestamp_data(void* data, int nframes);
97extern py::array_t<uint8_t>
98np_array_channels_data(void* data, int nframes);
99
100extern uint32_t
102extern py::array_t<uint16_t>
104extern py::array_t<uint8_t>
106extern py::array_t<uint16_t>
107np_array_adc_stream_data(void* data, int nframes);
108extern py::array_t<uint64_t>
110extern py::array_t<uint64_t>
111np_array_timestamp_stream_data(void* data, int nframes);
112extern py::array_t<uint8_t>
113np_array_channels_stream_data(void* data, int nframes);
114
115}
116
117namespace tde {
118extern uint32_t
119get_n_frames(daqdataformats::Fragment const& frag);
120extern py::array_t<uint16_t>
121np_array_adc(daqdataformats::Fragment const& frag);
122extern py::array_t<uint16_t>
123np_array_adc_data(void* data, uint32_t n_frames);
124extern py::array_t<long double>
125np_array_timestamp(daqdataformats::Fragment const& frag);
126extern py::array_t<long double>
127np_array_timestamp_data(void* data, uint32_t n_frames);
128
129}
130
131namespace unpack {
132namespace python {
133
134void
135register_unpack(py::module& m)
136{
137
138 m.def("print_hex_fragment", &print_hex_fragment);
139
140 py::module_ wibeth_module = m.def_submodule("wibeth");
141 wibeth_module.def("get_n_frames", &wibeth::get_n_frames);
142 wibeth_module.def("np_array_adc", &wibeth::np_array_adc);
143 wibeth_module.def("np_array_timestamp", &wibeth::np_array_timestamp);
144 wibeth_module.def("np_array_adc_data", &wibeth::np_array_adc_data);
145 wibeth_module.def("np_array_timestamp_data", &wibeth::np_array_timestamp_data);
146
147 py::module_ daphne_module = m.def_submodule("daphne");
148 daphne_module.def("get_n_frames", &daphne::get_n_frames);
149 daphne_module.def("np_array_adc", &daphne::np_array_adc);
150 daphne_module.def("np_array_timestamp", &daphne::np_array_timestamp);
151 daphne_module.def("np_array_adc_data", &daphne::np_array_adc_data);
152 daphne_module.def("np_array_timestamp_data", &daphne::np_array_timestamp_data);
153 daphne_module.def("np_array_channels_data", &daphne::np_array_channels_data);
154 daphne_module.def("np_array_channels", &daphne::np_array_channels);
155
156 daphne_module.def("get_n_frames_stream", &daphne::get_n_frames_stream);
157 daphne_module.def("np_array_adc_stream", &daphne::np_array_adc_stream);
158 daphne_module.def("np_array_timestamp_stream", &daphne::np_array_timestamp_stream);
159 daphne_module.def("np_array_adc_stream_data", &daphne::np_array_adc_stream_data);
160 daphne_module.def("np_array_timestamp_stream_data", &daphne::np_array_timestamp_stream_data);
161 daphne_module.def("np_array_channels_stream_data", &daphne::np_array_channels_stream_data);
162 daphne_module.def("np_array_channels_stream", &daphne::np_array_channels_stream);
163
164 py::module_ daphneeth_module = m.def_submodule("daphneeth");
165 daphneeth_module.def("get_n_frames", &daphneeth::get_n_frames);
166 daphneeth_module.def("np_array_adc", &daphneeth::np_array_adc);
167 daphneeth_module.def("np_array_timestamp", &daphneeth::np_array_timestamp);
168 daphneeth_module.def("np_array_adc_data", &daphneeth::np_array_adc_data);
169 daphneeth_module.def("np_array_timestamp_data", &daphneeth::np_array_timestamp_data);
170 daphneeth_module.def("np_array_channels_data", &daphneeth::np_array_channels_data);
171 daphneeth_module.def("np_array_channels", &daphneeth::np_array_channels);
172
173 daphneeth_module.def("get_n_frames_stream", &daphneeth::get_n_frames_stream);
174 daphneeth_module.def("np_array_adc_stream", &daphneeth::np_array_adc_stream);
175 daphneeth_module.def("np_array_timestamp_stream", &daphneeth::np_array_timestamp_stream);
176 daphneeth_module.def("np_array_adc_stream_data", &daphneeth::np_array_adc_stream_data);
177 daphneeth_module.def("np_array_timestamp_stream_data", &daphneeth::np_array_timestamp_stream_data);
178 daphneeth_module.def("np_array_channels_stream_data", &daphneeth::np_array_channels_stream_data);
179 daphneeth_module.def("np_array_channels_stream", &daphneeth::np_array_channels_stream);
180
181 py::module_ tde_module = m.def_submodule("tde");
182 tde_module.def("get_n_frames", &tde::get_n_frames);
183 tde_module.def("np_array_adc", &tde::np_array_adc);
184 tde_module.def("np_array_timestamp", &tde::np_array_timestamp);
185 tde_module.def("np_array_adc_data", &tde::np_array_adc_data);
186 tde_module.def("np_array_timestamp_data", &tde::np_array_timestamp_data);
187}
188
189} // namespace python
190} // namespace rawdatautils
191} // namespace dunedaq
192}
C++ Representation of a DUNE Fragment, wrapping the flat byte array that is the Fragment's "actual" f...
Definition Fragment.hpp:38
void * get_data() const
Get a pointer to the data payload in the Fragmnet.
Definition Fragment.hpp:153
fragment_size_t get_size() const
Get the total size of the Fragment in bytes, including header and all payload pieces.
Definition Fragment.hpp:147
py::array_t< uint16_t > np_array_adc_stream(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension...
py::array_t< uint8_t > np_array_channels_stream(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEStreamFrames into a numpy array with dimensi...
py::array_t< uint64_t > np_array_timestamp_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (num...
py::array_t< uint16_t > np_array_adc_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint64_t > np_array_timestamp_stream(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing DAPHNEStreamFrames into a numpy array with dimension ...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of DAPHNEFrames in a fragment.
py::array_t< uint8_t > np_array_channels_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes).
uint32_t get_n_frames_stream(daqdataformats::Fragment const &frag)
Gets number of DAPHNEStreamFrames in a fragment.
py::array_t< uint8_t > np_array_channels_stream_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEStreamFrames into a numpy array with dimensions (nframes,...
py::array_t< uint8_t > np_array_channels(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEFrames into a numpy array with dimensions.
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of...
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number o...
py::array_t< uint16_t > np_array_adc(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint16_t > np_array_adc_stream(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of DAPHNEFrames in a fragment.
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number o...
py::array_t< uint8_t > np_array_channels_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes).
py::array_t< uint8_t > np_array_channels(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEFrames into a numpy array with dimensions.
uint32_t get_n_frames_stream(daqdataformats::Fragment const &frag)
Gets number of DAPHNEStreamFrames in a fragment.
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of...
py::array_t< uint16_t > np_array_adc_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint8_t > np_array_channels_stream(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEStreamFrames into a numpy array with dimensi...
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint16_t > np_array_adc(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint8_t > np_array_channels_stream_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEEthStreamFrames into a numpy array with dimensions (nframes,...
py::array_t< uint64_t > np_array_timestamp_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (num...
py::array_t< uint64_t > np_array_timestamp_stream(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing DAPHNEStreamFrames into a numpy array with dimension ...
py::array_t< uint16_t > np_array_adc(daqdataformats::Fragment const &frag)
Unpacks a Fragment containing TDEEthFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< long double > np_array_timestamp(daqdataformats::Fragment const &frag)
Unpacks the timestamps in a Fragment containing TDEEthFrames into a numpy array with dimension (numbe...
py::array_t< long double > np_array_timestamp_data(void *data, uint32_t n_frames)
Unpacks data containing TDEEthFrames into a numpy array with the timestamps with dimension (number of...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of TDEEthFrames in a fragment.
py::array_t< uint16_t > np_array_adc_data(void *data, uint32_t n_frames)
Unpacks data containing TDEEthFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment const &frag)
Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number o...
py::array_t< uint16_t > np_array_adc(daqdataformats::Fragment const &frag)
Unpacks a Fragment containing WIBEthFrames into a numpy array with the ADC values and dimension (numb...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of WIBEthFrames in a fragment.
py::array_t< uint16_t > np_array_adc_data(void *data, uint32_t n_frames)
Unpacks data containing WIBEthFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint64_t > np_array_timestamp_data(void *data, uint32_t n_frames)
Unpacks data containing WIBEthFrames into a numpy array with the timestamps with dimension (number of...
void print_hex_fragment(daqdataformats::Fragment const &frag)
Definition unpack.cpp:28
The DUNE-DAQ namespace.
The header for a DUNE Fragment.