DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
wib2.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
18void
19register_wib2(py::module& m)
20{
21
22 py::class_<WIB2Frame>(m, "WIB2Frame", py::buffer_protocol())
23 .def(py::init())
24 .def(py::init([](py::capsule capsule) {
25 auto wfp = *static_cast<WIB2Frame*>(capsule.get_pointer());
26 return wfp;
27 }))
28 .def(py::init([](py::bytes bytes) {
29 py::buffer_info info(py::buffer(bytes).request());
30 auto wfp = *static_cast<WIB2Frame*>(info.ptr);
31 return wfp;
32 }))
33 .def("get_adc", static_cast<uint16_t (WIB2Frame::*)(const int) const>(&WIB2Frame::get_adc))
34 .def("set_adc", static_cast<void (WIB2Frame::*)(int, uint16_t)>(&WIB2Frame::set_adc))
35 .def("get_timestamp", &WIB2Frame::get_timestamp)
36 .def("get_header", [](WIB2Frame& self) -> const WIB2Frame::Header& { return self.header; })
37 .def("get_trailer", [](WIB2Frame& self) -> const WIB2Frame::Trailer& { return self.trailer; })
38 .def_static("sizeof", []() { return sizeof(WIB2Frame); })
39 .def("get_bytes",
40 [](WIB2Frame* fr) -> py::bytes { return py::bytes(reinterpret_cast<char*>(fr), sizeof(WIB2Frame)); });
41
42 py::class_<WIB2Frame::Header>(m, "WIB2Header")
43 .def_property_readonly("version", [](WIB2Frame::Header& self) -> uint32_t { return self.version; })
44 .def_property_readonly("detector_id", [](WIB2Frame::Header& self) -> uint32_t { return self.detector_id; })
45 .def_property_readonly("crate", [](WIB2Frame::Header& self) -> uint32_t { return self.crate; })
46 .def_property_readonly("slot", [](WIB2Frame::Header& self) -> uint32_t { return self.slot; })
47 .def_property_readonly("link", [](WIB2Frame::Header& self) -> uint32_t { return self.link; })
48 .def_property_readonly("timestamp_1", [](WIB2Frame::Header& self) -> uint32_t { return self.timestamp_1; })
49 .def_property_readonly("timestamp_2", [](WIB2Frame::Header& self) -> uint32_t { return self.timestamp_2; })
50 .def_property_readonly("colddata_timestamp_id",
51 [](WIB2Frame::Header& self) -> uint32_t { return self.colddata_timestamp_id; })
52 .def_property_readonly("femb_valid", [](WIB2Frame::Header& self) -> uint32_t { return self.femb_valid; })
53 .def_property_readonly("link_mask", [](WIB2Frame::Header& self) -> uint32_t { return self.link_mask; })
54 .def_property_readonly("lock_output_status",
55 [](WIB2Frame::Header& self) -> uint32_t { return self.lock_output_status; })
56 .def_property_readonly("femb_pulser_frame_bits",
57 [](WIB2Frame::Header& self) -> uint32_t { return self.femb_pulser_frame_bits; })
58 .def_property_readonly("femb_sync_flags", [](WIB2Frame::Header& self) -> uint32_t { return self.femb_sync_flags; })
59 .def_property_readonly("colddata_timestamp",
60 [](WIB2Frame::Header& self) -> uint32_t { return self.colddata_timestamp; });
61
62 py::class_<WIB2Frame::Trailer>(m, "WIB2Trailer")
63 .def_property_readonly("flex_bits", [](WIB2Frame::Trailer& self) -> uint32_t { return self.flex_bits; })
64 .def_property_readonly("ws", [](WIB2Frame::Trailer& self) -> uint32_t { return self.ws; })
65 .def_property_readonly("psr_cal", [](WIB2Frame::Trailer& self) -> uint32_t { return self.psr_cal; })
66 .def_property_readonly("ready", [](WIB2Frame::Trailer& self) -> uint32_t { return self.ready; })
67 .def_property_readonly("context_code", [](WIB2Frame::Trailer& self) -> uint32_t { return self.context_code; });
68}
69
70} // namespace dunedaq::fddetdataformats::python
Class for accessing raw WIB v2 frames, as used in ProtoDUNE-SP-II.
Definition WIB2Frame.hpp:31
uint16_t get_adc(int i) const
Get the ith ADC value in the frame.
Definition WIB2Frame.hpp:88
uint64_t get_timestamp() const
Get the 64-bit timestamp of the frame.
void set_adc(int i, uint16_t val)
Set the ith ADC value in the frame to val.
void register_wib2(pybind11::module &)