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 : void
22 0 : register_daqethheader(py::module& m)
23 : {
24 :
25 0 : py::class_<DAQEthHeader>(m, "DAQEthHeader", py::buffer_protocol())
26 0 : .def(py::init([](py::capsule capsule) {
27 0 : auto hsfp = *static_cast<DAQEthHeader*>(capsule.get_pointer());
28 0 : return hsfp;
29 : }))
30 0 : .def(py::init([](py::bytes bytes) {
31 0 : py::buffer_info info(py::buffer(bytes).request());
32 0 : auto wfp = *static_cast<DAQEthHeader*>(info.ptr);
33 0 : return wfp;
34 0 : }))
35 0 : .def_property(
36 : "version",
37 0 : [](DAQEthHeader& self) -> uint32_t { return self.version; },
38 0 : [](DAQEthHeader& self, uint32_t version) { self.version = version; })
39 0 : .def_property(
40 : "det_id",
41 0 : [](DAQEthHeader& self) -> uint32_t { return self.det_id; },
42 0 : [](DAQEthHeader& self, uint32_t det_id) { self.det_id = det_id; })
43 0 : .def_property(
44 : "crate_id",
45 0 : [](DAQEthHeader& self) -> uint32_t { return self.crate_id; },
46 0 : [](DAQEthHeader& self, uint32_t crate_id) { self.crate_id = crate_id; })
47 0 : .def_property(
48 : "slot_id",
49 0 : [](DAQEthHeader& self) -> uint32_t { return self.slot_id; },
50 0 : [](DAQEthHeader& self, uint32_t slot_id) { self.slot_id = slot_id; })
51 0 : .def_property(
52 : "stream_id",
53 0 : [](DAQEthHeader& self) -> uint32_t { return self.stream_id; },
54 0 : [](DAQEthHeader& self, uint32_t stream_id) { self.stream_id = stream_id; })
55 0 : .def_property(
56 : "reserved",
57 0 : [](DAQEthHeader& self) -> uint32_t { return self.reserved; },
58 0 : [](DAQEthHeader& self, uint32_t reserved) { self.reserved = reserved; })
59 0 : .def_property(
60 : "seq_id",
61 0 : [](DAQEthHeader& self) -> uint32_t { return self.seq_id; },
62 0 : [](DAQEthHeader& self, uint32_t seq_id) { self.seq_id = seq_id; })
63 0 : .def_property(
64 : "block_length",
65 0 : [](DAQEthHeader& self) -> uint32_t { return self.block_length; },
66 0 : [](DAQEthHeader& self, uint32_t block_length) { self.block_length = block_length; })
67 0 : .def_property(
68 : "timestamp",
69 0 : [](DAQEthHeader& self) -> uint64_t { return self.timestamp; },
70 0 : [](DAQEthHeader& self, uint64_t timestamp) { self.timestamp = timestamp; })
71 0 : .def("get_timestamp", &DAQEthHeader::get_timestamp)
72 0 : .def_static("sizeof", []() { return sizeof(DAQEthHeader); });
73 0 : }
74 :
75 : } // namespace dunedaq::detdataformats::python
|