DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
wib.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_wib(py::module& m)
20{
21
22 py::class_<WIBFrame>(m, "WIBFrame", py::buffer_protocol())
23 .def(py::init())
24 .def(py::init([](py::capsule capsule) {
25 auto wfp = *static_cast<WIBFrame*>(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<WIBFrame*>(info.ptr);
31 return wfp;
32 }))
33 .def("get_wib_header", static_cast<const WIBHeader* (WIBFrame::*)() const >(&WIBFrame::get_wib_header), py::return_value_policy::reference_internal)
34 .def("get_coldata_header", &WIBFrame::get_coldata_header, py::return_value_policy::reference_internal)
35 .def("get_block", &WIBFrame::get_block, py::return_value_policy::reference_internal)
36 .def("get_channel", static_cast<uint16_t (WIBFrame::*)(const uint8_t, const uint8_t, const uint8_t) const>(&WIBFrame::get_channel))
37 .def("get_channel", static_cast<uint16_t (WIBFrame::*)(const uint8_t, const uint8_t) const>(&WIBFrame::get_channel))
38 .def("get_channel", static_cast<uint16_t (WIBFrame::*)(const uint8_t) const>(&WIBFrame::get_channel))
39 .def("set_channel", static_cast<void (WIBFrame::*)(const uint8_t, const uint16_t)>(&WIBFrame::set_channel))
40 .def("get_timestamp", &WIBFrame::get_timestamp)
41 .def_static("sizeof", [](){ return sizeof(WIBFrame); })
42 .def("get_bytes",
43 [](WIBFrame* fr) -> py::bytes {
44 return py::bytes(reinterpret_cast<char*>(fr), sizeof(WIBFrame));
45 }
46 )
47 ;
48
49 py::class_<WIBHeader>(m, "WIBHeader")
50 .def_property_readonly("sof", [](WIBHeader& self) -> uint32_t {return self.sof;})
51 .def_property_readonly("version", [](WIBHeader& self) -> uint32_t {return self.version;})
52 .def_property_readonly("fiber_no", [](WIBHeader& self) -> uint32_t {return self.fiber_no;})
53 .def_property_readonly("crate_no", [](WIBHeader& self) -> uint32_t {return self.crate_no;})
54 .def_property_readonly("slot_no", [](WIBHeader& self) -> uint32_t {return self.slot_no;})
55 .def_property_readonly("mm", [](WIBHeader& self) -> uint32_t {return self.mm;})
56 .def_property_readonly("oos", [](WIBHeader& self) -> uint32_t {return self.oos;})
57 .def_property_readonly("mm", [](WIBHeader& self) -> uint32_t {return self.mm;})
58 .def_property_readonly("wib_errors", [](WIBHeader& self) -> uint32_t {return self.wib_errors;})
59 .def("get_timestamp", &WIBHeader::get_timestamp)
60 .def("get_wib_counter", &WIBHeader::get_wib_counter)
61 ;
62 py::class_<ColdataHeader>(m, "ColdataHeader")
63 .def_property_readonly("s1_error", [](ColdataHeader& self) -> uint32_t {return self.s1_error;})
64 .def_property_readonly("s2_error", [](ColdataHeader& self) -> uint32_t {return self.s2_error;})
65 .def_property_readonly("coldata_convert_count", [](ColdataHeader& self) -> uint32_t {return self.coldata_convert_count;})
66 .def_property_readonly("error_register", [](ColdataHeader& self) -> uint32_t {return self.error_register;})
67 .def_property_readonly("hdr_1", [](ColdataHeader& self) -> uint32_t {return self.hdr_1;})
68 .def_property_readonly("hdr_3", [](ColdataHeader& self) -> uint32_t {return self.hdr_3;})
69 .def_property_readonly("hdr_2", [](ColdataHeader& self) -> uint32_t {return self.hdr_2;})
70 .def_property_readonly("hdr_4", [](ColdataHeader& self) -> uint32_t {return self.hdr_4;})
71 .def_property_readonly("hdr_5", [](ColdataHeader& self) -> uint32_t {return self.hdr_5;})
72 .def_property_readonly("hdr_7", [](ColdataHeader& self) -> uint32_t {return self.hdr_7;})
73 .def_property_readonly("hdr_6", [](ColdataHeader& self) -> uint32_t {return self.hdr_6;})
74 .def_property_readonly("hdr_8", [](ColdataHeader& self) -> uint32_t {return self.hdr_8;})
75 .def("get_checksum_a", &ColdataHeader::get_checksum_a)
76 .def("get_checksum_b", &ColdataHeader::get_checksum_b)
77 .def("get_hdr", &ColdataHeader::get_hdr)
78 ;
79
80 py::class_<ColdataSegment>(m, "ColdataSegment")
81 .def("get_channel", &ColdataSegment::get_channel)
82 ;
83 py::class_<ColdataBlock>(m, "ColdataBlock")
84 .def("get_channel", &ColdataBlock::get_channel)
85 ;
86
87}
88
89} // namespace dunedaq::fddetdataformats::python
const WIBHeader * get_wib_header() const
Definition WIBFrame.hpp:360
uint16_t get_channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch) const
Definition WIBFrame.hpp:381
const ColdataBlock & get_block(const uint8_t b) const
Definition WIBFrame.hpp:368
const ColdataHeader * get_coldata_header(const unsigned block_index) const
Definition WIBFrame.hpp:363
void set_channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch, const uint16_t new_val)
Definition WIBFrame.hpp:397
void register_wib(pybind11::module &)
uint16_t get_channel(const uint8_t adc, const uint8_t ch) const
Definition WIBFrame.hpp:305
uint8_t get_hdr(const uint8_t i) const
Definition WIBFrame.hpp:105
uint16_t get_channel(const uint8_t adc, const uint8_t ch) const
Definition WIBFrame.hpp:219