DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
MasterMuxDesign.cpp
Go to the documentation of this file.
2
3#include <sstream>
4#include <string>
5
6namespace dunedaq::timing {
7
8UHAL_REGISTER_DERIVED_NODE(MasterMuxDesign)
9
10//-----------------------------------------------------------------------------
12 : TopDesignInterface(node)
13 , MuxDesignInterface(node)
16 , MasterDesign(node)
17{}
18//-----------------------------------------------------------------------------
19
20//-----------------------------------------------------------------------------
23//-----------------------------------------------------------------------------
24
25//-----------------------------------------------------------------------------
26std::string
27MasterMuxDesign::get_status(bool print_out) const
28{
29 std::stringstream status;
30 status << get_io_node_plain()->get_pll_status();
31 status << get_master_node_plain()->get_status();
32 // TODO mux specific status
33 if (print_out)
34 TLOG() << status.str();
35 return status.str();
36}
37//-----------------------------------------------------------------------------
38
39//-----------------------------------------------------------------------------
40uint32_t
41MasterMuxDesign::measure_endpoint_rtt(uint32_t address, bool control_sfp, int sfp_mux) const
42{
43
44 if (sfp_mux > -1) {
45 if (control_sfp)
46 {
47 // set fanout rtt mux channel, and do not wait for fanout rtt ept to be in a good state
48 switch_mux(sfp_mux);
49 }
50 // gets master rtt ept in a good state, and sends echo command
51 uint32_t rtt = get_master_node_plain()->measure_endpoint_rtt(address, control_sfp);
52 return rtt;
53 } else {
55 }
56}
57//-----------------------------------------------------------------------------
58
59//-----------------------------------------------------------------------------
60void
62 uint32_t coarse_delay,
63 uint32_t fine_delay,
64 uint32_t phase_delay,
65 bool measure_rtt,
66 bool control_sfp,
67 int sfp_mux) const
68{
69 if (sfp_mux > -1)
70 {
71 if (control_sfp && measure_rtt)
72 {
73 // set fanout rtt mux channel, and do not wait for fanout rtt ept to be in a good state
74 switch_mux(sfp_mux);
75 }
76 // gets master rtt ept in a good state, and sends echo command
77 get_master_node_plain()->apply_endpoint_delay(address, coarse_delay, fine_delay, phase_delay, measure_rtt, control_sfp);
78 }
79 else
80 {
81 get_master_node_plain()->apply_endpoint_delay(address, coarse_delay, fine_delay, phase_delay, measure_rtt, control_sfp);
82 }
83}
84//-----------------------------------------------------------------------------
85
86//-----------------------------------------------------------------------------
87std::vector<uint32_t>
89{
90 std::vector<uint32_t> locked_channels;
91
92 // TODO will this be right for every fanout board, need to check the IO board
93 uint32_t number_of_mux_channels = 8;
94 for (uint32_t i = 0; i < number_of_mux_channels; ++i)
95 {
96 TLOG_DEBUG(0) << "Scanning slot " << i;
97
98 try
99 {
100 switch_mux(i);
102 } catch (...) {
103 TLOG_DEBUG(0) << "Slot " << i << " not locked";
104 }
105 // TODO catch right except
106
107 TLOG_DEBUG(0) << "Slot " << i << " locked";
108 locked_channels.push_back(i);
109 }
110
111 if (locked_channels.size()) {
112 TLOG() << "Slots locked: " << vec_fmt(locked_channels);
113 } else {
114 TLOG() << "No slots locked";
115 }
116 return locked_channels;
117}
118//-----------------------------------------------------------------------------
119
120//-----------------------------------------------------------------------------
121void
126//-----------------------------------------------------------------------------
127}
virtual std::string get_pll_status(bool print_out=false) const
Print status of on-board PLL.
Definition IONode.cpp:288
Base class for timing master designs.
Base class for timing master designs.
const MasterNodeInterface * get_master_node_plain() const override
Get master node pointer.
Class for PDI timing master design on mux board.
void resync_active_cdr() const override
Resync active cdr.
std::string get_status(bool print_out=false) const override
Get status string, optionally print.
std::vector< uint32_t > scan_sfp_mux() const override
Scan SFP for alive timing transmitters.
uint32_t measure_endpoint_rtt(uint32_t address, bool control_sfp=true, int sfp_mux=-1) const override
Measure the endpoint round trip time.
void apply_endpoint_delay(uint32_t address, uint32_t coarse_delay, uint32_t fine_delay, uint32_t phase_delay, bool measure_rtt=false, bool control_sfp=true, int sfp_mux=-1) const override
Apply delay to endpoint.
virtual void apply_endpoint_delay(uint32_t address, uint32_t coarse_delay, uint32_t fine_delay, uint32_t phase_delay, bool measure_rtt=false, bool control_sfp=true) const =0
Apply delay to endpoint.
virtual uint32_t measure_endpoint_rtt(uint32_t address, bool control_sfp=true) const =0
Measure the endpoint round trip time.
virtual void enable_upstream_endpoint() const =0
Enable RTT endpoint.
Base class for timing endpoint design nodes.
void switch_mux(uint8_t mux_channel, bool resync_cdr=false) const override
Switch the SFP mux channel.
virtual std::string get_status(bool print_out=false) const =0
Get the status string of the timing node. Optionally print it.
Base class for timing top design nodes.
const IONode * get_io_node_plain() const override
Get io node pointer.
Definition TopDesign.hpp:48
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TLOG(...)
Definition macro.hpp:22
< Message parameters
std::string vec_fmt(const std::vector< T > &vec)
Definition toolbox.hxx:382