Line data Source code
1 : /**
2 : * @file hsi.cpp
3 : *
4 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 : #include "detdataformats/HSIFrame.hpp"
9 :
10 : #include <pybind11/pybind11.h>
11 : #include <pybind11/stl.h>
12 :
13 : namespace py = pybind11;
14 :
15 : namespace dunedaq::detdataformats::python {
16 :
17 : void
18 0 : register_hsi(py::module& m)
19 : {
20 :
21 0 : py::class_<HSIFrame> (m, "HSIFrame", py::buffer_protocol())
22 0 : .def(py::init())
23 0 : .def(py::init([](py::capsule capsule) {
24 0 : auto hsfp = *static_cast<HSIFrame*>(capsule.get_pointer());
25 0 : return hsfp;
26 : } ))
27 0 : .def(py::init([](py::bytes bytes){
28 0 : py::buffer_info info(py::buffer(bytes).request());
29 0 : auto wfp = *static_cast<HSIFrame*>(info.ptr);
30 0 : return wfp;
31 0 : }))
32 0 : .def("get_timestamp", &HSIFrame::get_timestamp)
33 0 : .def_property_readonly("version", [](const HSIFrame& self) -> uint64_t {return self.version;})
34 0 : .def_property_readonly("detector_id", [](const HSIFrame& self) -> uint64_t {return self.detector_id;})
35 0 : .def_property_readonly("crate", [](const HSIFrame& self) -> uint64_t {return self.crate;})
36 0 : .def_property_readonly("slot", [](const HSIFrame& self) -> uint64_t {return self.slot;})
37 0 : .def_property_readonly("link", [](const HSIFrame& self) -> uint64_t {return self.link;})
38 0 : .def_property_readonly("input_low", [](const HSIFrame& self) -> uint64_t {return self.input_low;})
39 0 : .def_property_readonly("input_high", [](const HSIFrame& self) -> uint64_t {return self.input_high;})
40 0 : .def_property_readonly("trigger", [](const HSIFrame& self) -> uint64_t {return self.trigger;})
41 0 : .def_property_readonly("sequence", [](const HSIFrame& self) -> uint64_t {return self.sequence;})
42 0 : .def_static("sizeof", [](){ return sizeof(HSIFrame); })
43 : ;
44 0 : }
45 :
46 : } // namespace dunedaq::detdataformats::python
|