DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
daphneeth.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_daphneeth(py::module& m)
20{
21
22
23 py::class_<DAPHNEEthFrame::Header>(m, "DAPHNEEthHeader")
24 // .def_property("w0",
25 // [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w0;},
26 // [](DAPHNEEthFrame::Header& self, uint32_t w0) {self.w0 = w0;}
27 // )
28 .def_property("w1",
29 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w1;},
30 [](DAPHNEEthFrame::Header& self, uint32_t w1) {self.w1 = w1;}
31 )
32 .def_property("w2",
33 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w2;},
34 [](DAPHNEEthFrame::Header& self, uint32_t w2) {self.w2 = w2;}
35 )
36 .def_property("w3",
37 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w3;},
38 [](DAPHNEEthFrame::Header& self, uint32_t w3) {self.w3 = w3;}
39 )
40 .def_property("w4",
41 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w4;},
42 [](DAPHNEEthFrame::Header& self, uint32_t w4) {self.w4 = w4;}
43 )
44 .def_property("w5",
45 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w5;},
46 [](DAPHNEEthFrame::Header& self, uint32_t w5) {self.w5 = w5;}
47 )
48 .def_property("w6",
49 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.w6;},
50 [](DAPHNEEthFrame::Header& self, uint32_t w6) {self.w6 = w6;}
51 )
52 .def_property("channel",
53 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.channel;},
54 [](DAPHNEEthFrame::Header& self, uint32_t channel) {self.channel = channel;}
55 )
56 .def_property("version",
57 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.version;},
58 [](DAPHNEEthFrame::Header& self, uint32_t version) {self.version = version;}
59 )
60 .def_property("trigger_sample_value",
61 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.trig_sample;},
62 [](DAPHNEEthFrame::Header& self, uint32_t trig_sample) {self.trig_sample = trig_sample;}
63 )
64 .def_property("threshold",
65 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.threshold;},
66 [](DAPHNEEthFrame::Header& self, uint32_t threshold) {self.threshold = threshold;}
67 )
68 .def_property("baseline",
69 [](DAPHNEEthFrame::Header& self) -> uint32_t {return self.baseline;},
70 [](DAPHNEEthFrame::Header& self, uint32_t baseline) {self.baseline = baseline;}
71 )
72 ;
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("get_daqheader", [](DAPHNEEthFrame& self) -> const detdataformats::DAQEthHeader& {return self.daq_header;}, py::return_value_policy::reference_internal)
86 .def("get_daphneheader", [](DAPHNEEthFrame& self) -> const DAPHNEEthFrame::Header& {return self.header;}, py::return_value_policy::reference_internal)
87 .def("get_header", [](DAPHNEEthFrame& self) -> const DAPHNEEthFrame::Header& {return self.header;}, py::return_value_policy::reference_internal)
88 .def("get_adc", &DAPHNEEthFrame::get_adc)
89 .def("set_adc", &DAPHNEEthFrame::set_adc)
90 .def("get_timestamp", &DAPHNEEthFrame::get_timestamp)
91 .def("set_timestamp", &DAPHNEEthFrame::set_timestamp)
92 .def("get_channel", &DAPHNEEthFrame::get_channel)
93 .def("set_channel", &DAPHNEEthFrame::set_channel)
94 .def_static("sizeof", [](){ return sizeof(DAPHNEEthFrame); })
95 .def("get_bytes",
96 [](DAPHNEEthFrame* fr) -> py::bytes {
97 return py::bytes(reinterpret_cast<char*>(fr), sizeof(DAPHNEEthFrame));
98 })
99 ;
100}
101
102} // 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:19
DAQEthHeader is a versioned and unified structure for every FE electronics.