DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
VLCmdGeneratorNode.cpp
Go to the documentation of this file.
1
10#include "timing/toolbox.hpp"
11
12#include "logging/Logging.hpp"
13
14#include <string>
15
16namespace dunedaq {
17namespace timing {
18
19UHAL_REGISTER_DERIVED_NODE(VLCmdGeneratorNode)
20
21//-----------------------------------------------------------------------------
23 : TimingNode(node)
24{}
25//-----------------------------------------------------------------------------
26
27//-----------------------------------------------------------------------------
29//-----------------------------------------------------------------------------
30
31//-----------------------------------------------------------------------------
32std::string
33VLCmdGeneratorNode::get_status(bool print_out) const
34{
35 std::stringstream status;
36 auto subnodes = read_sub_nodes(getNode("csr.stat"));
37 status << format_reg_table(subnodes, "VL Cmd gen state");
38
39 if (print_out)
40 TLOG() << status.str();
41 return status.str();
42}
43//-----------------------------------------------------------------------------
44
45//-----------------------------------------------------------------------------
46void
47VLCmdGeneratorNode::switch_endpoint_sfp(uint32_t address, bool enable) const // NOLINT(build/unsigned)
48{
49 TLOG_DEBUG(3) << "Switching SFP for endpoint address: " << address << ", to state: " << enable;
50 reset_sub_nodes(getNode("csr.ctrl"));
51 getNode("csr.ctrl.addr").write(address);
52 getNode("csr.ctrl.tx_en").write(enable);
53 getNode("csr.ctrl.go").write(0x1);
54 getNode("csr.ctrl.go").write(0x0);
55 getClient().dispatch();
56}
57//-----------------------------------------------------------------------------
58
59//-----------------------------------------------------------------------------
60void
61VLCmdGeneratorNode::apply_endpoint_delay(uint32_t address, // NOLINT(build/unsigned)
62 uint32_t coarse_delay, // NOLINT(build/unsigned)
63 uint32_t fine_delay, // NOLINT(build/unsigned)
64 uint32_t phase_delay) const // NOLINT(build/unsigned)
65{
66 reset_sub_nodes(getNode("csr.ctrl"), false);
67 getNode("csr.ctrl.tx_en").write(0x0);
68 getNode("csr.ctrl.addr").write(address);
69 getNode("csr.ctrl.cdel").write(coarse_delay);
70 getNode("csr.ctrl.fdel").write(fine_delay);
71 getNode("csr.ctrl.pdel").write(phase_delay);
72 getNode("csr.ctrl.update").write(0x1);
73 getNode("csr.ctrl.go").write(0x1);
74 getNode("csr.ctrl.go").write(0x0);
75 getClient().dispatch();
76
77 TLOG_DEBUG(2) << "Coarse delay " << format_reg_value(coarse_delay) << " applied";
78 TLOG_DEBUG(2) << "Fine delay " << format_reg_value(fine_delay) << " applied";
79 TLOG_DEBUG(2) << "Phase delay " << format_reg_value(phase_delay) << " applied";
80}
81//-----------------------------------------------------------------------------
82
83} // namespace timing
84} // namespace dunedaq
Base class for timing nodes.
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes(const uhal::Node &node, bool dispatch=true) const
Read subnodes.
Class for master global node.
void switch_endpoint_sfp(uint32_t address, bool enable=false) const
Control the endpoint sfp tx laser.
std::string get_status(bool print_out=false) const override
Print the status of the timing node.
void apply_endpoint_delay(uint32_t address, uint32_t coarse_delay, uint32_t fine_delay, uint32_t phase_delay) const
Adjust endpoint delay.
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TLOG(...)
Definition macro.hpp:22
std::string format_reg_table(T data, std::string title, std::vector< std::string > headers)
Format reg-value table.
Definition toolbox.hxx:166
std::string format_reg_value(T reg_value, uint32_t base)
Definition toolbox.hxx:117
Including Qt Headers.