Line data Source code
1 : /**
2 : * @file detid.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 :
9 : #include "detdataformats/DAQEthHeader.hpp"
10 :
11 : #include <pybind11/operators.h>
12 : #include <pybind11/pybind11.h>
13 : #include <pybind11/stl.h>
14 :
15 : #include <sstream>
16 :
17 : namespace py = pybind11;
18 :
19 : namespace dunedaq::detdataformats::python {
20 :
21 : // Quiet the linter about use of unsigned ints in the file
22 : // NOLINTBEGIN(build/unsigned)
23 :
24 : void
25 0 : register_daqethheader(py::module& m)
26 : {
27 :
28 0 : py::class_<DAQEthHeader>(m, "DAQEthHeader", py::buffer_protocol())
29 0 : .def(py::init([](py::capsule capsule) {
30 0 : auto hsfp = *static_cast<DAQEthHeader*>(capsule.get_pointer());
31 0 : return hsfp;
32 : }))
33 0 : .def(py::init([](py::bytes bytes) {
34 0 : py::buffer_info info(py::buffer(bytes).request());
35 0 : auto wfp = *static_cast<DAQEthHeader*>(info.ptr);
36 0 : return wfp;
37 0 : }))
38 0 : .def_property(
39 : "version",
40 0 : [](DAQEthHeader& self) -> uint32_t { return self.version; },
41 0 : [](DAQEthHeader& self, uint32_t version) { self.version = version; })
42 0 : .def_property(
43 : "det_id",
44 0 : [](DAQEthHeader& self) -> uint32_t { return self.det_id; },
45 0 : [](DAQEthHeader& self, uint32_t det_id) { self.det_id = det_id; })
46 0 : .def_property(
47 : "crate_id",
48 0 : [](DAQEthHeader& self) -> uint32_t { return self.crate_id; },
49 0 : [](DAQEthHeader& self, uint32_t crate_id) { self.crate_id = crate_id; })
50 0 : .def_property(
51 : "slot_id",
52 0 : [](DAQEthHeader& self) -> uint32_t { return self.slot_id; },
53 0 : [](DAQEthHeader& self, uint32_t slot_id) { self.slot_id = slot_id; })
54 0 : .def_property(
55 : "stream_id",
56 0 : [](DAQEthHeader& self) -> uint32_t { return self.stream_id; },
57 0 : [](DAQEthHeader& self, uint32_t stream_id) { self.stream_id = stream_id; })
58 0 : .def_property(
59 : "reserved",
60 0 : [](DAQEthHeader& self) -> uint32_t { return self.reserved; },
61 0 : [](DAQEthHeader& self, uint32_t reserved) { self.reserved = reserved; })
62 0 : .def_property(
63 : "seq_id",
64 0 : [](DAQEthHeader& self) -> uint32_t { return self.seq_id; },
65 0 : [](DAQEthHeader& self, uint32_t seq_id) { self.seq_id = seq_id; })
66 0 : .def_property(
67 : "block_length",
68 0 : [](DAQEthHeader& self) -> uint32_t { return self.block_length; },
69 0 : [](DAQEthHeader& self, uint32_t block_length) { self.block_length = block_length; })
70 0 : .def_property(
71 : "timestamp",
72 0 : [](DAQEthHeader& self) -> uint64_t { return self.timestamp; },
73 0 : [](DAQEthHeader& self, uint64_t timestamp) { self.timestamp = timestamp; })
74 0 : .def("get_timestamp", &DAQEthHeader::get_timestamp)
75 0 : .def_static("sizeof", []() { return sizeof(DAQEthHeader); });
76 0 : }
77 :
78 : } // namespace dunedaq::detdataformats::python
79 :
80 : // NOLINTEND(build/unsigned)
|