DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SIMIONode.cpp
Go to the documentation of this file.
1
10
11#include "logging/Logging.hpp"
12
13#include <string>
14#include <utility>
15#include <vector>
16
17namespace dunedaq {
18namespace timing {
19
20UHAL_REGISTER_DERIVED_NODE(SIMIONode)
21
22//-----------------------------------------------------------------------------
23SIMIONode::SIMIONode(const uhal::Node& node)
24 : IONode(node, "", "", "", {}, {})
25{}
26//-----------------------------------------------------------------------------
27
28//-----------------------------------------------------------------------------
30//-----------------------------------------------------------------------------
31
32//-----------------------------------------------------------------------------
33std::string
35{
36 return "";
37}
38//-----------------------------------------------------------------------------
39
40//-----------------------------------------------------------------------------
41std::string
42SIMIONode::get_status(bool print_out) const
43{
44 std::stringstream status;
45
46 auto subnodes = read_sub_nodes(getNode("csr.stat"));
47 status << format_reg_table(subnodes, "SIM IO state");
48
49 if (print_out)
50 TLOG() << status.str();
51 return status.str();
52}
53//-----------------------------------------------------------------------------
54
55//-----------------------------------------------------------------------------
56uint64_t // NOLINT(build/unsigned)
58{
59 return 0;
60}
61//-----------------------------------------------------------------------------
62
63//-----------------------------------------------------------------------------
66{
67 return kSIMRev1;
68}
69//-----------------------------------------------------------------------------
70
71//-----------------------------------------------------------------------------
72std::string
73SIMIONode::get_hardware_info(bool print_out) const
74{
75 std::stringstream info;
77 const BoardRevision board_revision = get_board_revision();
80
81 std::vector<std::pair<std::string, std::string>> hardware_info;
82
83 try {
84 hardware_info.push_back(std::make_pair("Board type", get_board_type_map().at(board_type)));
85 } catch (const std::out_of_range& e) {
86 throw MissingBoardTypeMapEntry(ERS_HERE, format_reg_value(board_type), e);
87 }
88
89 try {
90 hardware_info.push_back(std::make_pair("Board revision", get_board_revision_map().at(board_revision)));
91 } catch (const std::out_of_range& e) {
92 throw MissingBoardRevisionMapEntry(ERS_HERE, format_reg_value(board_revision), e);
93 }
94
95 try {
96 hardware_info.push_back(std::make_pair("Carrier type", get_carrier_type_map().at(carrier_type)));
97 } catch (const std::out_of_range& e) {
98 throw MissingCarrierTypeMapEntry(ERS_HERE, format_reg_value(carrier_type), e);
99 }
100
101 try {
102 hardware_info.push_back(std::make_pair("Design type", get_design_type_map().at(design_type)));
103 } catch (const std::out_of_range& e) {
104 throw MissingDesignTypeMapEntry(ERS_HERE, format_reg_value(design_type), e);
105 }
106 info << format_reg_table(hardware_info, "Hardware info", { "", "" });
107
108 if (print_out)
109 TLOG() << info.str();
110 return info.str();
111}
112//-----------------------------------------------------------------------------
113
114//-----------------------------------------------------------------------------
115void
116SIMIONode::reset(const std::string& /*clock_config_file*/) const
117{
118
120 TLOG_DEBUG(0) << "Reset done";
121}
122//-----------------------------------------------------------------------------
123
124//-----------------------------------------------------------------------------
125void
126SIMIONode::configure_pll(const std::string& /*clock_config_file*/) const
127{
128 TLOG_DEBUG(0) << "Simulation does not support PLL config";
129}
130//-----------------------------------------------------------------------------
131
132//-----------------------------------------------------------------------------
133std::vector<double>
135{
136 TLOG_DEBUG(0) << "Simulation does not support reading of freq";
137 return {};
138}
139//-----------------------------------------------------------------------------
140
141//-----------------------------------------------------------------------------
142std::string
144{
145 TLOG_DEBUG(0) << "Simulation does not support freq table";
146 return "Simulation does not support freq table";
147}
148//-----------------------------------------------------------------------------
149
150//-----------------------------------------------------------------------------
151std::string
152SIMIONode::get_pll_status(bool /*print_out*/) const
153{
154 TLOG_DEBUG(0) << "Simulation does not support PLL status";
155 return "Simulation does not support PLL status";
156}
157//-----------------------------------------------------------------------------
158
159//-----------------------------------------------------------------------------
160std::string
161SIMIONode::get_sfp_status(uint32_t /*sfp_id*/, bool /*print_out*/) const // NOLINT(build/unsigned)
162{
163 TLOG_DEBUG(0) << "Simulation does not support SFP I2C";
164 return "Simulation does not support SFP I2C";
165}
166//-----------------------------------------------------------------------------
167
168//-----------------------------------------------------------------------------
169void
170SIMIONode::switch_sfp_soft_tx_control_bit(uint32_t /*sfp_id*/, bool /*turn_on*/) const // NOLINT(build/unsigned)
171{
172 TLOG_DEBUG(0) << "Simulation does not support SFP I2C";
173}
174//-----------------------------------------------------------------------------
175
176//-----------------------------------------------------------------------------
177void
178SIMIONode::switch_sfp_tx(uint32_t /*sfp_id*/, bool /*turn_on*/) const // NOLINT(build/unsigned)
179{
180 TLOG_DEBUG(0) << "Simulation does not support SFP control";
181}
182//-----------------------------------------------------------------------------
183
184} // namespace timing
185} // namespace dunedaq
#define ERS_HERE
Base class for timing IO nodes.
Definition IONode.hpp:44
virtual uint32_t read_board_type() const
Read the word identifying the timing board.
Definition IONode.cpp:48
virtual void write_soft_reset_register() const
Write soft reset register.
Definition IONode.cpp:296
virtual uint32_t read_carrier_type() const
Read the word identifying the FPFA carrier board.
Definition IONode.cpp:58
virtual uint32_t read_design_type() const
Read the word identifying the firmware design in the FPGA.
Definition IONode.cpp:68
static const std::map< DesignType, std::string > & get_design_type_map()
Definition IONode.hpp:194
static const std::map< BoardRevision, std::string > & get_board_revision_map()
Definition IONode.hpp:192
static const std::map< BoardType, std::string > & get_board_type_map()
Definition IONode.hpp:188
static const std::map< CarrierType, std::string > & get_carrier_type_map()
Definition IONode.hpp:190
Class for the timing simulation IO.
Definition SIMIONode.hpp:34
BoardRevision get_board_revision() const override
Read the word identifying the timing board.
Definition SIMIONode.cpp:65
std::string get_clock_frequencies_table(bool print_out=false) const override
Print frequencies of on-board clocks.
void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const override
Control tx laser of on-board SFP softly (I2C command)
std::string get_pll_status(bool print_out=false) const override
Print status of on-board PLL.
std::string get_hardware_info(bool print_out=false) const override
Print hardware information.
Definition SIMIONode.cpp:73
void configure_pll(const std::string &clock_config_file="") const override
Configure clock chip.
uint64_t read_board_uid() const override
Read the word containing the timing board UID.
Definition SIMIONode.cpp:57
std::vector< double > read_clock_frequencies() const override
Read frequencies of on-board clocks.
std::string get_uid_address_parameter_name() const override
Get the UID address parameter name.
Definition SIMIONode.cpp:34
void reset(const std::string &clock_config_file) const override
Reset IO.
std::string get_sfp_status(uint32_t sfp_id, bool print_out=false) const override
Print status of on-board SFP.
std::string get_status(bool print_out=false) const override
Get status string, optionally print.
Definition SIMIONode.cpp:42
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override
Control tx laser of on-board SFP softly (I2C command)
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes(const uhal::Node &node, bool dispatch=true) const
Read subnodes.
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TLOG(...)
Definition macro.hpp:22
CarrierType convert_value_to_carrier_type(uint32_t darrier_type)
Definition toolbox.cpp:287
BoardType convert_value_to_board_type(uint32_t Board_type)
Definition toolbox.cpp:274
std::string format_reg_table(T data, std::string title, std::vector< std::string > headers)
Format reg-value table.
Definition toolbox.hxx:166
DesignType convert_value_to_design_type(uint32_t design_type)
Definition toolbox.cpp:300
std::string format_reg_value(T reg_value, uint32_t base)
Definition toolbox.hxx:117
Including Qt Headers.