DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
wibeth.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
19register_wibeth(py::module& m)
20{
21
22
23 py::class_<WIBEthFrame::WIBEthHeader>(m, "WIBEthHeader")
24 .def_property("channel",
25 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.channel;},
26 [](WIBEthFrame::WIBEthHeader& self, uint32_t channel) {self.channel = channel;}
27 )
28 .def_property("version",
29 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.version;},
30 [](WIBEthFrame::WIBEthHeader& self, uint32_t version) {self.version = version;}
31 )
32 // .def_property("reserved",
33 // [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.reserved;},
34 // [](WIBEthFrame::WIBEthHeader& self, uint32_t reserved) {self.reserved = reserved;}
35 // )
36 .def_property("cd",
37 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.cd;},
38 [](WIBEthFrame::WIBEthHeader& self, uint32_t cd) {self.version = cd;}
39 )
40 .def_property("context",
41 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.context;},
42 [](WIBEthFrame::WIBEthHeader& self, uint32_t context) {self.version = context;}
43 )
44 .def_property("ready",
45 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.ready;},
46 [](WIBEthFrame::WIBEthHeader& self, uint32_t ready) {self.ready = ready;}
47 )
48 .def_property("calibration",
49 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.calibration;},
50 [](WIBEthFrame::WIBEthHeader& self, uint32_t calibration) {self.calibration = calibration;}
51 )
52 .def_property("pulser",
53 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.pulser;},
54 [](WIBEthFrame::WIBEthHeader& self, uint32_t pulser) {self.pulser = pulser;}
55 )
56 .def_property("femb_sync",
57 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.femb_sync;},
58 [](WIBEthFrame::WIBEthHeader& self, uint32_t femb_sync) {self.femb_sync = femb_sync;}
59 )
60 .def_property("wib_sync",
61 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.wib_sync;},
62 [](WIBEthFrame::WIBEthHeader& self, uint32_t wib_sync) {self.wib_sync = wib_sync;}
63 )
64 .def_property("lol",
65 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.lol;},
66 [](WIBEthFrame::WIBEthHeader& self, uint32_t lol) {self.lol = lol;}
67 )
68 .def_property("link_valid",
69 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.link_valid;},
70 [](WIBEthFrame::WIBEthHeader& self, uint32_t link_valid) {self.link_valid = link_valid;}
71 )
72 .def_property("crc_err",
73 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.crc_err;},
74 [](WIBEthFrame::WIBEthHeader& self, uint32_t crc_err) {self.crc_err = crc_err;}
75 )
76 .def_property("colddata_timestamp_1",
77 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.colddata_timestamp_1;},
78 [](WIBEthFrame::WIBEthHeader& self, uint32_t colddata_timestamp_1) {self.lol = colddata_timestamp_1;}
79 )
80 .def_property("colddata_timestamp_0",
81 [](WIBEthFrame::WIBEthHeader& self) -> uint32_t {return self.colddata_timestamp_0;},
82 [](WIBEthFrame::WIBEthHeader& self, uint32_t colddata_timestamp_0) {self.colddata_timestamp_0 = colddata_timestamp_0;}
83 )
84 .def_property("extra_data",
85 [](WIBEthFrame::WIBEthHeader& self) -> uint64_t {return self.extra_data;},
86 [](WIBEthFrame::WIBEthHeader& self, uint64_t extra_data) {self.extra_data = extra_data;}
87 )
88 ;
89
90 py::class_<WIBEthFrame>(m, "WIBEthFrame", py::buffer_protocol())
91 .def(py::init())
92 .def(py::init([](py::capsule capsule) {
93 auto wfp = *static_cast<WIBEthFrame*>(capsule.get_pointer());
94 return wfp;
95 } ))
96 .def(py::init([](py::bytes bytes){
97 py::buffer_info info(py::buffer(bytes).request());
98 auto wfp = *static_cast<WIBEthFrame*>(info.ptr);
99 return wfp;
100 }))
101 .def("get_daqheader", [](WIBEthFrame& self) -> const detdataformats::DAQEthHeader& {return self.daq_header;}, py::return_value_policy::reference_internal)
102 .def("get_wibheader", [](WIBEthFrame& self) -> const WIBEthFrame::WIBEthHeader& {return self.header;}, py::return_value_policy::reference_internal)
103 .def("get_adc", &WIBEthFrame::get_adc)
104 .def("set_adc", &WIBEthFrame::set_adc)
105 .def("get_timestamp", &WIBEthFrame::get_timestamp)
106 .def("set_timestamp", &WIBEthFrame::set_timestamp)
107 .def("get_channel", &WIBEthFrame::get_channel)
108 .def("set_channel", &WIBEthFrame::set_channel)
109 .def_static("sizeof", [](){ return sizeof(WIBEthFrame); })
110 .def("get_bytes",
111 [](WIBEthFrame* fr) -> py::bytes {
112 return py::bytes(reinterpret_cast<char*>(fr), sizeof(WIBEthFrame));
113 })
114 ;
115}
116
117} // namespace dunedaq::fddetdataformats::python
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
uint16_t get_adc(int i, int sample=0) const
Get the ith ADC value in the frame.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
void set_channel(const uint8_t new_channel)
Set the channel identifier of the frame.
uint8_t get_channel() const
Get the channel identifier of the frame.
void set_adc(int i, int sample, uint16_t val)
Set the ith ADC value in the frame to val.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
void register_wibeth(pybind11::module &)
DAQEthHeader is a versioned and unified structure for every FE electronics.