DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
master.cpp
Go to the documentation of this file.
1
12
13#include <pybind11/pybind11.h>
14#include <pybind11/stl.h>
15
16namespace py = pybind11;
17
18namespace dunedaq {
19namespace timing {
20namespace python {
21
22void
23register_master(py::module& m)
24{
25 py::class_<timing::MasterNode, uhal::Node>(m, "MasterNode")
26 .def(py::init<const uhal::Node&>())
27 .def("switch_endpoint_sfp", &timing::MasterNode::switch_endpoint_sfp)
28 .def("enable_upstream_endpoint", &timing::MasterNode::enable_upstream_endpoint)
29 .def("reset_command_counters", &timing::MasterNode::reset_command_counters)
30 .def("transmit_async_packet", &timing::MasterNode::transmit_async_packet, py::arg("packet"), py::arg("timeout") = 500) //timeout [us]
31 .def("write_endpoint_data", &timing::MasterNode::write_endpoint_data)
32 .def("read_endpoint_data", &timing::MasterNode::read_endpoint_data)
33 .def("send_fl_cmd",
35 py::arg("command"),
36 py::arg("channel"),
37 py::arg("number_of_commands") = 1)
38 .def<void (timing::MasterNode::*)(uint32_t, uint32_t, double, bool, uint32_t) const>("enable_periodic_fl_cmd",
40 py::arg("command"),
41 py::arg("channel"),
42 py::arg("rate"),
43 py::arg("poisson"),
44 py::arg("clock_frequency_hz"))
45 .def("disable_periodic_fl_cmd", &timing::MasterNode::disable_periodic_fl_cmd)
46 .def("get_status", &timing::MasterNode::get_status, py::arg("print_out") = false)
47 .def("get_status_with_date", &timing::MasterNode::get_status_with_date, py::arg("clock_frequency_hz"), py::arg("print_out") = false)
48 .def("sync_timestamp", &timing::MasterNode::sync_timestamp, py::arg("source"))
49 .def("read_timestamp", &timing::MasterNode::read_timestamp)
50 .def("disable_timestamp_broadcast", &timing::MasterNode::disable_timestamp_broadcast)
51 .def("enable_timestamp_broadcast", &timing::MasterNode::enable_timestamp_broadcast)
52 .def("configure_endpoint_command_decoder", &timing::MasterNode::configure_endpoint_command_decoder,
53 py::arg("endpoint_address"),
54 py::arg("slot"),
55 py::arg("command"));
56
57 py::class_<timing::UpstreamCDRNode, uhal::Node>(m, "UpstreamCDRNode")
58 .def(py::init<const uhal::Node&>())
59 .def("get_status", &timing::UpstreamCDRNode::get_status, py::arg("print_out") = false)
60 .def("resync", &timing::UpstreamCDRNode::resync);
61
62 py::class_<timing::IRIGTimestampNode, uhal::Node>(m, "IRIGTimestampNode")
63 .def(py::init<const uhal::Node&>())
64 .def("get_status", &timing::IRIGTimestampNode::get_status, py::arg("print_out") = false)
65 .def("set_ts_timebase", &timing::IRIGTimestampNode::set_ts_timebase, py::arg("ts_timebase"))
66 .def("set_ts_epoch", &timing::IRIGTimestampNode::set_ts_epoch, py::arg("ts_epoch"))
67 .def("set_ts_epoch_value", &timing::IRIGTimestampNode::set_ts_epoch_value, py::arg("epoch_to_2000_seconds_tai"), py::arg("epoch_to_2000_leap_seconds"))
68 .def("set_ts_seconds_offset", &timing::IRIGTimestampNode::set_ts_seconds_offset, py::arg("seconds_offset"))
69 .def("set_ts_ticks_offset", &timing::IRIGTimestampNode::set_ts_ticks_offset, py::arg("ticks_offset"))
70 ;
71
72}
73
74} // namespace python
75} // namespace timing
76} // namespace dunedaq
std::string get_status(bool print_out=false) const override
Print the status of the timing node.
void set_ts_ticks_offset(int16_t ticks_offset) const
Set ticks offset.
void set_ts_epoch_value(uint64_t epoch_to_2000_seconds_tai, uint8_t epoch_to_2000_leap_seconds) const
Set custom epoch value.
void set_ts_seconds_offset(int8_t seconds_offset) const
Set seconds offset.
void set_ts_timebase(TimestampTimebase ts_timebase) const
Set custom epoch date.
void set_ts_epoch(TimestampEpoch ts_epoch) const
Set epoch: UNIX/custom.
virtual void enable_periodic_fl_cmd(uint32_t channel, double rate, bool poisson, uint32_t clock_frequency_hz) const
Configure fake trigger generator.
virtual void disable_periodic_fl_cmd(uint32_t channel) const
Clear fake trigger configuration.
Class for PD-II/DUNE master timing nodes.
std::string get_status(bool print_out=false) const override
Print the status of the timing node.
std::string get_status_with_date(uint32_t clock_frequency_hz, bool print_out=false) const
Print the status of the timing node.
std::vector< uint32_t > transmit_async_packet(const std::vector< uint32_t > &packet, int timeout=500) const
Send an async packet.
void enable_timestamp_broadcast() const
Enable timestamp sending.
uint64_t read_timestamp() const override
Read the current timestamp word.
std::vector< uint32_t > read_endpoint_data(uint16_t endpoint_address, uint8_t reg_address, uint8_t data_length, bool address_mode) const
Read some data from endpoint registers.
void switch_endpoint_sfp(uint32_t address, bool turn_on) const override
Control the tx line of endpoint sfp.
void disable_timestamp_broadcast() const
Disable timestamp sending.
void enable_upstream_endpoint() const override
Enable RTT endpoint.
void sync_timestamp(TimestampSource source) const override
Set timestamp to current machine time.
void configure_endpoint_command_decoder(uint16_t endpoint_address, uint8_t slot, uint8_t command) const
Configure endpoint command decoder.
void reset_command_counters() const
Read some data from endpoint registers.
void write_endpoint_data(uint16_t endpoint_address, uint8_t reg_address, std::vector< uint8_t > data, bool address_mode) const
Write some data to endpoint registers.
void send_fl_cmd(uint32_t command, uint32_t channel, uint32_t number_of_commands=1) const override
Send a fixed length command.
std::string get_status(bool print_out=false) const override
Get status string, optionally print.
void register_master(py::module &m)
Definition master.cpp:23
The DUNE-DAQ namespace.
Definition DataStore.hpp:57
Unknown serialization type<< t,((char) t)) template< typename T > inline std::string datatype_to_string() { return "Unknown";} namespace serialization { template< typename T > struct is_serializable :std::false_type {};enum SerializationType { kMsgPack };inline SerializationType from_string(const std::string s) { if(s=="msgpack") return kMsgPack;throw UnknownSerializationTypeString(ERS_HERE, s);} constexpr uint8_t serialization_type_byte(SerializationType stype) { switch(stype) { case kMsgPack:return 'M';default:throw UnknownSerializationTypeEnum(ERS_HERE);} } constexpr SerializationType DEFAULT_SERIALIZATION_TYPE=kMsgPack;template< class T > std::vector< uint8_t > serialize(const T &obj, SerializationType stype=DEFAULT_SERIALIZATION_TYPE) { switch(stype) { case kMsgPack:{ msgpack::sbuffer buf;msgpack::pack(buf, obj);std::vector< uint8_t > ret(buf.size()+1);ret[0]=serialization_type_byte(stype);std::copy(buf.data(), buf.data()+buf.size(), ret.begin()+1);return ret;} default:throw UnknownSerializationTypeEnum(ERS_HERE);} } template< class T, typename CharType=unsigned char > T deserialize(const std::vector< CharType > &v) { switch(v[0]) { case serialization_type_byte(kMsgPack):{ try { msgpack::object_handle oh=msgpack::unpack(const_cast< char * >(reinterpret_cast< const char * >(v.data()+1)), v.size() - 1,[](msgpack::type::object_type, std::size_t, void *) -> bool