DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
time_slice.cpp
Go to the documentation of this file.
1
11
12#include <pybind11/pybind11.h>
13#include <pybind11/stl.h>
14
15#include <memory>
16#include <vector>
17
18namespace py = pybind11;
19
21
22void
23register_timeslice(py::module& m)
24{
25 py::class_<TimeSliceHeader>(m, "TimeSliceHeader")
26 .def_property_readonly_static("s_timeslice_header_marker",
27 [](const TimeSliceHeader& self) -> uint32_t { // NOLINT(build/unsigned)
28 return self.s_timeslice_header_marker;
29 })
30 .def_property_readonly_static("s_timeslice_header_version",
31 [](const TimeSliceHeader& self) -> uint32_t { // NOLINT(build/unsigned)
33 })
34 .def_property_readonly("timeslice_header_marker",
35 [](const TimeSliceHeader& self) -> uint32_t { // NOLINT(build/unsigned)
36 return self.timeslice_header_marker;
37 })
38 .def_property_readonly(
39 "version", [](const TimeSliceHeader& self) -> uint32_t { return self.version; }) // NOLINT(build/unsigned)
40 .def_property_readonly("timeslice_number",
41 [](const TimeSliceHeader& self) -> timeslice_number_t { return self.timeslice_number; })
42
43 .def_property_readonly("run_number", [](const TimeSliceHeader& self) -> run_number_t { return self.run_number; });
44
45 py::class_<TimeSlice> py_timeslice(m, "TimeSlice", pybind11::buffer_protocol());
46 py_timeslice.def(py::init<TimeSliceHeader const&>())
47 .def(py::init<timeslice_number_t, run_number_t>())
48 .def(
49 "get_header", [](TimeSlice& self) { return self.get_header(); }, py::return_value_policy::reference_internal)
50 // .def("set_header", &TimeSlice::set_header)
51 .def(
52 "get_fragments_ref",
53 [](TimeSlice& self) {
54 auto fragments = py::list();
55 for (auto& fragment : self.get_fragments_ref()) {
56 auto py_fragment = py::cast(*fragment, py::return_value_policy::reference);
57 fragments.append(py_fragment);
58 }
59 return fragments;
60 },
61 py::return_value_policy::reference_internal)
62 .def("get_total_size_bytes", &TimeSlice::get_total_size_bytes)
63 .def("get_sum_of_fragment_payload_sizes", &TimeSlice::get_sum_of_fragment_payload_sizes);
64} // NOLINT
65
66} // namespace dunedaq::daqdataformats::python
C++ Representation of a DUNE TimeSlice, consisting of a TimeSliceHeader object and a vector of pointe...
Definition TimeSlice.hpp:27
size_t get_total_size_bytes() const
Get size of timeslice from underlying TimeSliceHeader and Fragments.
Definition TimeSlice.hpp:85
size_t get_sum_of_fragment_payload_sizes() const
Get the sum of the fragment payload sizes.
Definition TimeSlice.hpp:98
void register_timeslice(py::module &)
uint32_t run_number_t
Type used to represent run number.
Definition Types.hpp:20
uint64_t timeslice_number_t
Type used to represent timeslice number.
Definition Types.hpp:52
Additional data fields associated with a TimeSliceHeader.
static constexpr uint32_t s_timeslice_header_marker
Marker bytes to identify a TimeSliceHeader entry in a raw data stream.
run_number_t run_number
Run Number for the TimeSlice.
uint32_t version
Version of the TimeSliceHeader structure.
uint32_t timeslice_header_marker
Marker bytes used to identify a TimeSliceHeader struct in a raw data stream.
static constexpr uint32_t s_timeslice_header_version
The current version of the TimeSliceHeader.
timeslice_number_t timeslice_number
Slice number of this TimeSlice within the stream.