DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
daphneeth.cpp
Go to the documentation of this file.
1
8
10
11#include <pybind11/pybind11.h>
12#include <pybind11/stl.h>
13
14namespace py = pybind11;
15
17
18// NOLINTBEGIN(build/unsigned)
19
20void
21register_daphneeth(py::module& m)
22{
23
24 py::class_<DAPHNEEthFrame::Header>(m, "DAPHNEEthHeader")
25 // .def_property("w0",
26 // [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w0;},
27 // [](DAPHNEEthFrame::Header& self, uint32_t w0) {self.w0 = w0;}
28 // )
29 .def_property(
30 "w1",
31 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.w1; },
32 [](DAPHNEEthFrame::Header& self, uint32_t w1) { self.w1 = w1; })
33 .def_property(
34 "w2",
35 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.w2; },
36 [](DAPHNEEthFrame::Header& self, uint32_t w2) { self.w2 = w2; })
37 .def_property(
38 "w3",
39 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.w3; },
40 [](DAPHNEEthFrame::Header& self, uint32_t w3) { self.w3 = w3; })
41 .def_property(
42 "w4",
43 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.w4; },
44 [](DAPHNEEthFrame::Header& self, uint32_t w4) { self.w4 = w4; })
45 .def_property(
46 "w5",
47 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.w5; },
48 [](DAPHNEEthFrame::Header& self, uint32_t w5) { self.w5 = w5; })
49 .def_property(
50 "w6",
51 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.w6; },
52 [](DAPHNEEthFrame::Header& self, uint32_t w6) { self.w6 = w6; })
53 .def_property(
54 "channel",
55 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.channel; },
56 [](DAPHNEEthFrame::Header& self, uint32_t channel) { self.channel = channel; })
57 .def_property(
58 "version",
59 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.version; },
60 [](DAPHNEEthFrame::Header& self, uint32_t version) { self.version = version; })
61 .def_property(
62 "trigger_sample_value",
63 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.trig_sample; },
64 [](DAPHNEEthFrame::Header& self, uint32_t trig_sample) { self.trig_sample = trig_sample; })
65 .def_property(
66 "threshold",
67 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.threshold; },
68 [](DAPHNEEthFrame::Header& self, uint32_t threshold) { self.threshold = threshold; })
69 .def_property(
70 "baseline",
71 [](DAPHNEEthFrame::Header& self) -> uint32_t { return self.baseline; },
72 [](DAPHNEEthFrame::Header& self, uint32_t baseline) { self.baseline = baseline; });
73
74 py::class_<DAPHNEEthFrame>(m, "DAPHNEEthFrame", py::buffer_protocol())
75 .def(py::init())
76 .def(py::init([](py::capsule capsule) {
77 auto wfp = *static_cast<DAPHNEEthFrame*>(capsule.get_pointer());
78 return wfp;
79 }))
80 .def(py::init([](py::bytes bytes) {
81 py::buffer_info info(py::buffer(bytes).request());
82 auto wfp = *static_cast<DAPHNEEthFrame*>(info.ptr);
83 return wfp;
84 }))
85 .def(
86 "get_daqheader",
87 [](DAPHNEEthFrame& self) -> const detdataformats::DAQEthHeader& { return self.daq_header; },
88 py::return_value_policy::reference_internal)
89 .def(
90 "get_daphneheader",
91 [](DAPHNEEthFrame& self) -> const DAPHNEEthFrame::Header& { return self.header; },
92 py::return_value_policy::reference_internal)
93 .def(
94 "get_header",
95 [](DAPHNEEthFrame& self) -> const DAPHNEEthFrame::Header& { return self.header; },
96 py::return_value_policy::reference_internal)
97 .def("get_adc", &DAPHNEEthFrame::get_adc)
98 .def("set_adc", &DAPHNEEthFrame::set_adc)
99 .def("get_timestamp", &DAPHNEEthFrame::get_timestamp)
100 .def("set_timestamp", &DAPHNEEthFrame::set_timestamp)
101 .def("get_channel", &DAPHNEEthFrame::get_channel)
102 .def("set_channel", &DAPHNEEthFrame::set_channel)
103 .def_static("sizeof", []() { return sizeof(DAPHNEEthFrame); })
104 .def("get_bytes", [](DAPHNEEthFrame* fr) -> py::bytes {
105 return py::bytes(reinterpret_cast<char*>(fr), sizeof(DAPHNEEthFrame)); // NOLINT reinterpret_cast
106 });
107}
108
109// NOLINTEND(build/unsigned)
110
111} // namespace dunedaq::fddetdataformats::python
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
void set_adc(int i, 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.
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.
uint16_t get_adc(int i) const
Get the ith ADC value in the frame.
void register_daphneeth(py::module &m)
Definition daphneeth.cpp:21
DAQEthHeader is a versioned and unified structure for every FE electronics.