LCOV - code coverage report
Current view: top level - fddetdataformats/pybindsrc - wibeth.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 93 0
Test Date: 2026-07-12 15:23:06 Functions: 0.0 % 39 0

            Line data    Source code
       1              : /**
       2              :  * @file wibeth.cpp Python bindings for the WIBEthFrame format
       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 "fddetdataformats/WIBEthFrame.hpp"
      10              : 
      11              : #include <pybind11/pybind11.h>
      12              : #include <pybind11/stl.h>
      13              : 
      14              : namespace py = pybind11;
      15              : 
      16              : namespace dunedaq::fddetdataformats::python {
      17              : 
      18              : void
      19            0 : register_wibeth(py::module& m)
      20              : {
      21              : 
      22              :   // NOLINTBEGIN(build/unsigned)
      23              : 
      24            0 :   py::class_<WIBEthFrame::WIBEthHeader>(m, "WIBEthHeader")
      25            0 :     .def_property(
      26              :       "channel",
      27            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.channel; },
      28            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t channel) { self.channel = channel; })
      29            0 :     .def_property(
      30              :       "version",
      31            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.version; },
      32            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t version) { self.version = version; })
      33            0 :     .def_property(
      34              :       "cd",
      35            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.cd; },
      36            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t cd) { self.cd = cd; })
      37            0 :     .def_property(
      38              :       "context",
      39            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.context; },
      40            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t context) { self.context = context; })
      41            0 :     .def_property(
      42              :       "ready",
      43            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.ready; },
      44            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t ready) { self.ready = ready; })
      45            0 :     .def_property(
      46              :       "calibration",
      47            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.calibration; },
      48            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t calibration) { self.calibration = calibration; })
      49            0 :     .def_property(
      50              :       "pulser",
      51            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.pulser; },
      52            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t pulser) { self.pulser = pulser; })
      53            0 :     .def_property(
      54              :       "femb_sync",
      55            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.femb_sync; },
      56            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t femb_sync) { self.femb_sync = femb_sync; })
      57            0 :     .def_property(
      58              :       "wib_sync",
      59            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.wib_sync; },
      60            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t wib_sync) { self.wib_sync = wib_sync; })
      61            0 :     .def_property(
      62              :       "lol",
      63            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.lol; },
      64            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t lol) { self.lol = lol; })
      65            0 :     .def_property(
      66              :       "link_valid",
      67            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.link_valid; },
      68            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t link_valid) { self.link_valid = link_valid; })
      69            0 :     .def_property(
      70              :       "crc_err",
      71            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.crc_err; },
      72            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t crc_err) { self.crc_err = crc_err; })
      73            0 :     .def_property(
      74              :       "colddata_timestamp_1",
      75            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.colddata_timestamp_1; },
      76            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t colddata_timestamp_1) {
      77            0 :         self.colddata_timestamp_1 = colddata_timestamp_1;
      78            0 :       })
      79            0 :     .def_property(
      80              :       "colddata_timestamp_0",
      81            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint32_t { return self.colddata_timestamp_0; },
      82            0 :       [](WIBEthFrame::WIBEthHeader& self, uint32_t colddata_timestamp_0) {
      83            0 :         self.colddata_timestamp_0 = colddata_timestamp_0;
      84            0 :       })
      85            0 :     .def_property(
      86              :       "extra_data",
      87            0 :       [](WIBEthFrame::WIBEthHeader& self) -> uint64_t { return self.extra_data; },
      88            0 :       [](WIBEthFrame::WIBEthHeader& self, uint64_t extra_data) { self.extra_data = extra_data; })
      89            0 :     .def_property_readonly_static("s_expected_bytes", [](py::object /*self*/) {
      90              :       return WIBEthFrame::WIBEthHeader::s_expected_bytes;
      91              :     });
      92              : 
      93            0 :   py::class_<WIBEthFrame>(m, "WIBEthFrame", py::buffer_protocol())
      94            0 :     .def(py::init())
      95            0 :     .def(py::init([](py::capsule capsule) {
      96            0 :       auto wfp = *static_cast<WIBEthFrame*>(capsule.get_pointer());
      97            0 :       return wfp;
      98              :     }))
      99            0 :     .def(py::init([](py::bytes bytes) {
     100            0 :       py::buffer_info info(py::buffer(bytes).request());
     101            0 :       auto wfp = *static_cast<WIBEthFrame*>(info.ptr);
     102            0 :       return wfp;
     103            0 :     }))
     104            0 :     .def(
     105              :       "get_daqheader",
     106            0 :       [](WIBEthFrame& self) -> const detdataformats::DAQEthHeader& { return self.daq_header; },
     107            0 :       py::return_value_policy::reference_internal)
     108            0 :     .def(
     109              :       "get_wibheader",
     110            0 :       [](WIBEthFrame& self) -> const WIBEthFrame::WIBEthHeader& { return self.header; },
     111            0 :       py::return_value_policy::reference_internal)
     112            0 :     .def_property_readonly(
     113              :       "daq_header",
     114            0 :       [](WIBEthFrame& self) -> detdataformats::DAQEthHeader& { return self.daq_header; },
     115            0 :       py::return_value_policy::reference_internal)
     116            0 :     .def_property_readonly(
     117              :       "header",
     118            0 :       [](WIBEthFrame& self) -> WIBEthFrame::WIBEthHeader& { return self.header; },
     119            0 :       py::return_value_policy::reference_internal)
     120            0 :     .def("get_adc", &WIBEthFrame::get_adc)
     121            0 :     .def("set_adc", &WIBEthFrame::set_adc)
     122            0 :     .def("get_timestamp", &WIBEthFrame::get_timestamp)
     123            0 :     .def("set_timestamp", &WIBEthFrame::set_timestamp)
     124            0 :     .def("get_channel", &WIBEthFrame::get_channel)
     125            0 :     .def("set_channel", &WIBEthFrame::set_channel)
     126            0 :     .def("__lt__", [](const WIBEthFrame& lhs, const WIBEthFrame& rhs) { return lhs < rhs; })
     127            0 :     .def_property_readonly_static("s_bits_per_adc", [](py::object /*self*/) {
     128              :       return WIBEthFrame::s_bits_per_adc;
     129              :     })
     130            0 :     .def_property_readonly_static("s_bits_per_word", [](py::object /*self*/) {
     131              :       return WIBEthFrame::s_bits_per_word;
     132              :     })
     133            0 :     .def_property_readonly_static("s_time_samples_per_frame", [](py::object /*self*/) {
     134              :       return WIBEthFrame::s_time_samples_per_frame;
     135              :     })
     136            0 :     .def_property_readonly_static("s_channels_per_half_femb", [](py::object /*self*/) {
     137              :       return WIBEthFrame::s_channels_per_half_femb;
     138              :     })
     139            0 :     .def_property_readonly_static("s_half_fembs_per_frame", [](py::object /*self*/) {
     140              :       return WIBEthFrame::s_half_fembs_per_frame;
     141              :     })
     142            0 :     .def_property_readonly_static("s_num_channels", [](py::object /*self*/) {
     143              :       return WIBEthFrame::s_num_channels;
     144              :     })
     145            0 :     .def_property_readonly_static("s_num_adc_words_per_ts", [](py::object /*self*/) {
     146              :       return WIBEthFrame::s_num_adc_words_per_ts;
     147              :     })
     148            0 :     .def_property_readonly_static("s_expected_bytes", [](py::object /*self*/) {
     149              :       return WIBEthFrame::s_expected_bytes;
     150              :     })
     151            0 :     .def_static("sizeof", []() { return sizeof(WIBEthFrame); })
     152            0 :     .def("get_bytes", [](WIBEthFrame* fr) -> py::bytes {
     153            0 :       return py::bytes(reinterpret_cast<char*>(fr), sizeof(WIBEthFrame)); // NOLINT reinterpret_cast
     154              :     });
     155            0 : } // NOLINT function length
     156              : 
     157              : // NOLINTEND(build/unsigned)
     158              : 
     159              : } // namespace dunedaq::fddetdataformats::python
        

Generated by: LCOV version 2.0-1