DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
wib2.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_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 {
41 return py::bytes(reinterpret_cast<char*>(fr), sizeof(WIB2Frame));
42 }
43 )
44 ;
45
46 py::class_<WIB2Frame::Header>(m, "WIB2Header")
47 .def_property_readonly("version", [](WIB2Frame::Header& self) -> uint32_t {return self.version;})
48 .def_property_readonly("detector_id", [](WIB2Frame::Header& self) -> uint32_t {return self.detector_id;})
49 .def_property_readonly("crate", [](WIB2Frame::Header& self) -> uint32_t {return self.crate;})
50 .def_property_readonly("slot", [](WIB2Frame::Header& self) -> uint32_t {return self.slot;})
51 .def_property_readonly("link", [](WIB2Frame::Header& self) -> uint32_t {return self.link;})
52 .def_property_readonly("timestamp_1", [](WIB2Frame::Header& self) -> uint32_t {return self.timestamp_1;})
53 .def_property_readonly("timestamp_2", [](WIB2Frame::Header& self) -> uint32_t {return self.timestamp_2;})
54 .def_property_readonly("colddata_timestamp_id", [](WIB2Frame::Header& self) -> uint32_t {return self.colddata_timestamp_id;})
55 .def_property_readonly("femb_valid", [](WIB2Frame::Header& self) -> uint32_t {return self.femb_valid;})
56 .def_property_readonly("link_mask", [](WIB2Frame::Header& self) -> uint32_t {return self.link_mask;})
57 .def_property_readonly("lock_output_status", [](WIB2Frame::Header& self) -> uint32_t {return self.lock_output_status;})
58 .def_property_readonly("femb_pulser_frame_bits", [](WIB2Frame::Header& self) -> uint32_t {return self.femb_pulser_frame_bits;})
59 .def_property_readonly("femb_sync_flags", [](WIB2Frame::Header& self) -> uint32_t {return self.femb_sync_flags;})
60 .def_property_readonly("colddata_timestamp", [](WIB2Frame::Header& self) -> uint32_t {return self.colddata_timestamp;})
61 ;
62
63 py::class_<WIB2Frame::Trailer>(m, "WIB2Trailer")
64 .def_property_readonly("flex_bits", [](WIB2Frame::Trailer& self) -> uint32_t {return self.flex_bits;})
65 .def_property_readonly("ws", [](WIB2Frame::Trailer& self) -> uint32_t {return self.ws;})
66 .def_property_readonly("psr_cal", [](WIB2Frame::Trailer& self) -> uint32_t {return self.psr_cal;})
67 .def_property_readonly("ready", [](WIB2Frame::Trailer& self) -> uint32_t {return self.ready;})
68 .def_property_readonly("context_code", [](WIB2Frame::Trailer& self) -> uint32_t {return self.context_code;})
69 ;
70
71}
72
73} // 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:89
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 &)