DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
unpack.cpp
Go to the documentation of this file.
1
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
28 uint64_t* data = static_cast<uint64_t*>(frag.get_data());
29 size_t data_size = (frag.get_size() - sizeof(daqdataformats::FragmentHeader))/8;
30
31 for ( size_t i(0); i<data_size; ++i) {
32 fmt::print("{:06d} 0x{:016x}\n", i, data[i]);
33 }
34
35}
36
37
38namespace wib {
39 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment& frag);
40 extern py::array_t<uint16_t> np_array_adc_data(void* data, int nframes);
41 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment& frag);
42 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes);
43}
44
45namespace wib2 {
46 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
47 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag);
48 extern py::array_t<uint16_t> np_array_adc_data(void* data, int nframes);
49 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment const& frag);
50 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes);
51}
52
53namespace wibeth {
54 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
55 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag);
56 extern py::array_t<uint16_t> np_array_adc_data(void* data, uint32_t n_frames);
57 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment const& frag);
58 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, uint32_t n_frames);
59}
60
61
62namespace daphne {
63 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
64 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment& frag);
65 extern py::array_t<uint8_t> np_array_channels(daqdataformats::Fragment& frag);
66 extern py::array_t<uint16_t> np_array_adc_data(void* data, int nframes);
67 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment& frag);
68 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes);
69 extern py::array_t<uint8_t> np_array_channels_data(void* data, int nframes);
70
71 extern uint32_t get_n_frames_stream(daqdataformats::Fragment const& frag);
72 extern py::array_t<uint16_t> np_array_adc_stream(daqdataformats::Fragment& frag);
73 extern py::array_t<uint8_t> np_array_channels_stream(daqdataformats::Fragment& frag);
74 extern py::array_t<uint16_t> np_array_adc_stream_data(void* data, int nframes);
75 extern py::array_t<uint64_t> np_array_timestamp_stream(daqdataformats::Fragment& frag);
76 extern py::array_t<uint64_t> np_array_timestamp_stream_data(void* data, int nframes);
77 extern py::array_t<uint8_t> np_array_channels_stream_data(void* data, int nframes);
78
79}
80
81
82namespace tde {
83 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
84 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag);
85 extern py::array_t<uint16_t> np_array_adc_data(void* data, uint32_t n_frames);
86 extern py::array_t<long double> np_array_timestamp(daqdataformats::Fragment const& frag);
87 extern py::array_t<long double> np_array_timestamp_data(void* data, uint32_t n_frames);
88
89}
90
91namespace unpack {
92namespace python {
93
94void
95register_unpack(py::module& m) {
96
97 m.def("print_hex_fragment", &print_hex_fragment);
98
99 py::module_ wib_module = m.def_submodule("wib");
100 wib_module.def("np_array_adc", &wib::np_array_adc);
101 wib_module.def("np_array_timestamp", &wib::np_array_timestamp);
102 wib_module.def("np_array_adc_data", &wib::np_array_adc_data);
103 wib_module.def("np_array_timestamp_data", &wib::np_array_timestamp_data);
104
105 py::module_ wib2_module = m.def_submodule("wib2");
106 wib2_module.def("get_n_frames", &wib2::get_n_frames);
107 wib2_module.def("np_array_adc", &wib2::np_array_adc);
108 wib2_module.def("np_array_timestamp", &wib2::np_array_timestamp);
109 wib2_module.def("np_array_adc_data", &wib2::np_array_adc_data);
110 wib2_module.def("np_array_timestamp_data", &wib2::np_array_timestamp_data);
111
112 py::module_ wibeth_module = m.def_submodule("wibeth");
113 wibeth_module.def("get_n_frames", &wibeth::get_n_frames);
114 wibeth_module.def("np_array_adc", &wibeth::np_array_adc);
115 wibeth_module.def("np_array_timestamp", &wibeth::np_array_timestamp);
116 wibeth_module.def("np_array_adc_data", &wibeth::np_array_adc_data);
117 wibeth_module.def("np_array_timestamp_data", &wibeth::np_array_timestamp_data);
118
119 py::module_ daphne_module = m.def_submodule("daphne");
120 daphne_module.def("get_n_frames", &daphne::get_n_frames);
121 daphne_module.def("np_array_adc", &daphne::np_array_adc);
122 daphne_module.def("np_array_timestamp", &daphne::np_array_timestamp);
123 daphne_module.def("np_array_adc_data", &daphne::np_array_adc_data);
124 daphne_module.def("np_array_timestamp_data", &daphne::np_array_timestamp_data);
125 daphne_module.def("np_array_channels_data", &daphne::np_array_channels_data);
126 daphne_module.def("np_array_channels", &daphne::np_array_channels);
127
128 daphne_module.def("get_n_frames_stream", &daphne::get_n_frames_stream);
129 daphne_module.def("np_array_adc_stream", &daphne::np_array_adc_stream);
130 daphne_module.def("np_array_timestamp_stream", &daphne::np_array_timestamp_stream);
131 daphne_module.def("np_array_adc_stream_data", &daphne::np_array_adc_stream_data);
132 daphne_module.def("np_array_timestamp_stream_data", &daphne::np_array_timestamp_stream_data);
133 daphne_module.def("np_array_channels_stream_data", &daphne::np_array_channels_stream_data);
134 daphne_module.def("np_array_channels_stream", &daphne::np_array_channels_stream);
135
136 py::module_ tde_module = m.def_submodule("tde");
137 tde_module.def("get_n_frames", &tde::get_n_frames);
138 tde_module.def("np_array_adc", &tde::np_array_adc);
139 tde_module.def("np_array_timestamp", &tde::np_array_timestamp);
140 tde_module.def("np_array_adc_data", &tde::np_array_adc_data);
141 tde_module.def("np_array_timestamp_data", &tde::np_array_timestamp_data);
142
143}
144
145} // namespace python
146} // namespace rawdatautils
147} // namespace dunedaq
148}
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:254
fragment_size_t get_size() const
Get the total size of the Fragment.
Definition Fragment.hpp:242
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 dimensi...
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 (n...
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 (nu...
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 dimensio...
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(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 ...
void register_unpack(py::module &)
Definition unpack.cpp:95
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing WIB2Frames into a numpy array with the ADC values and dimension (number of WI...
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 WIB2Frames into a numpy array with the ADC values and dimension (number...
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing WIB2Frames into a numpy array with the timestamps with dimension (number of W...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of WIB2Frames 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< uint16_t > np_array_adc(daqdataformats::Fragment &frag)
Unpacks a Fragment containing WIBFrames into a numpy array with the ADC values and dimension (number ...
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing WIBFrames into a numpy array with the timestamps with dimension (number of WI...
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing WIBFrames into a numpy array with the ADC values and dimension (number of WIB...
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:27
Including Qt Headers.
Definition wib.pb.cc:23
The header for a DUNE Fragment.