DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
daphneethstream.cpp
Go to the documentation of this file.
1
10
11#include <pybind11/pybind11.h>
12#include <pybind11/stl.h>
13
14namespace py = pybind11;
15
17
18void
20{
21
22
23 py::class_<DAPHNEEthStreamFrame::ChannelWord>(m, "DAPHNEEthStreamChannelWord")
24 .def_property("tbd",
25 [](DAPHNEEthStreamFrame::ChannelWord& self) -> uint64_t {return self.tbd;},
26 [](DAPHNEEthStreamFrame::ChannelWord& self, uint64_t tbd) {self.tbd = tbd;}
27 )
28 .def_property("version",
29 [](DAPHNEEthStreamFrame::ChannelWord& self) -> uint64_t {return self.version;},
30 [](DAPHNEEthStreamFrame::ChannelWord& self, uint64_t version) {self.version = version;}
31 )
32 .def_property("channel",
33 [](DAPHNEEthStreamFrame::ChannelWord& self) -> uint64_t {return self.channel;},
34 [](DAPHNEEthStreamFrame::ChannelWord& self, uint64_t channel) {self.channel = channel;}
35 )
36 ;
37
38 py::class_<DAPHNEEthStreamFrame::Header>(m, "DAPHNEEthStreamHeader")
39 .def_property("channel_words",
40 [](DAPHNEEthStreamFrame::Header& self) -> py::list {
41 py::list result;
42 for (int i = 0; i < 4; i++) {
43 result.append(self.channel_words[i]);
44 }
45 return result;
46 },
47 [](DAPHNEEthStreamFrame::Header& self, py::list channel_words) {
48 for (int i = 0; i < 4 && i < len(channel_words); i++) {
49 self.channel_words[i] = channel_words[i].cast<DAPHNEEthStreamFrame::ChannelWord>();
50 }
51 }
52 )
53 ;
54
55 py::class_<DAPHNEEthStreamFrame>(m, "DAPHNEEthStreamFrame", py::buffer_protocol())
56 .def(py::init())
57 .def(py::init([](py::capsule capsule) {
58 auto wfp = *static_cast<DAPHNEEthStreamFrame*>(capsule.get_pointer());
59 return wfp;
60 } ))
61 .def(py::init([](py::bytes bytes){
62 py::buffer_info info(py::buffer(bytes).request());
63 auto wfp = *static_cast<DAPHNEEthStreamFrame*>(info.ptr);
64 return wfp;
65 }))
66 .def("get_daqheader", [](DAPHNEEthStreamFrame& self) -> const detdataformats::DAQEthHeader& {return self.daq_header;}, py::return_value_policy::reference_internal)
67 .def("get_daphneheader", [](DAPHNEEthStreamFrame& self) -> const DAPHNEEthStreamFrame::Header& {return self.header;}, py::return_value_policy::reference_internal)
68 .def("get_adc", &DAPHNEEthStreamFrame::get_adc)
69 .def("set_adc", &DAPHNEEthStreamFrame::set_adc)
70 .def("get_timestamp", &DAPHNEEthStreamFrame::get_timestamp)
71 .def("set_timestamp", &DAPHNEEthStreamFrame::set_timestamp)
72 .def("get_channel", &DAPHNEEthStreamFrame::get_channel)
73 .def("set_channel", &DAPHNEEthStreamFrame::set_channel)
74 .def("get_channel0", &DAPHNEEthStreamFrame::get_channel0)
75 .def("get_channel1", &DAPHNEEthStreamFrame::get_channel1)
76 .def("get_channel2", &DAPHNEEthStreamFrame::get_channel2)
77 .def("get_channel3", &DAPHNEEthStreamFrame::get_channel3)
78 .def_static("sizeof", [](){ return sizeof(DAPHNEEthStreamFrame); })
79 .def("get_bytes",
80 [](DAPHNEEthStreamFrame* fr) -> py::bytes {
81 return py::bytes(reinterpret_cast<char*>(fr), sizeof(DAPHNEEthStreamFrame));
82 })
83 ;
84}
85
86} // namespace dunedaq::fddetdataformats::python
Class for accessing raw DAPHNE eth stream frames, as used in ProtoDUNE-II.
void set_channel(uint channel_index, const uint8_t new_channel_val)
Set the channel identifier of the frame.
uint8_t get_channel1() const
Get the channel 1 from the DAPHNE Stream frame header
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
void set_adc(uint chn, uint i, 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
uint16_t get_adc(uint i, uint chn) const
Get the i ADC value of chn in the frame.
uint8_t get_channel3() const
Get the channel 3 from the DAPHNE Stream frame header
uint8_t get_channel2() const
Get the channel 2 from the DAPHNE Stream frame header
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
uint8_t get_channel(uint ch) const
Get the channel identifier of the frame.
void register_daphneethstream(py::module &m)
DAQEthHeader is a versioned and unified structure for every FE electronics.