DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TopDesign.hpp
Go to the documentation of this file.
1
12#ifndef TIMING_INCLUDE_TIMING_TOPDESIGN_HPP_
13#define TIMING_INCLUDE_TIMING_TOPDESIGN_HPP_
14
15// PDT Headers
16#include "TimingIssues.hpp"
18
21
22// uHal Headers
23#include "uhal/DerivedNode.hpp"
24
25#include <nlohmann/json.hpp>
26
27// C++ Headers
28#include <chrono>
29#include <sstream>
30#include <string>
31
32namespace dunedaq {
33namespace timing {
34
38class TopDesign : virtual public TopDesignInterface
39{
40public:
41 explicit TopDesign(const uhal::Node& node)
42 : TopDesignInterface(node) {}
43 virtual ~TopDesign() {}
44
48 const IONode* get_io_node_plain() const override
49 {
50 return dynamic_cast<const IONode*>(&uhal::Node::getNode("io"));
51 }
52
56 void soft_reset_io() const override
57 {
59 }
60
64 void reset_io(const std::string& clock_config_file) const override
65 {
66 get_io_node_plain()->reset(clock_config_file);
67 }
68
72 void reset_io(const ClockSource& clock_source) const override
73 {
74 get_io_node_plain()->reset(clock_source);
75 }
76
81 void configure(ClockSource clock_source) const override
82 {
83 // Hard resets
84 this->reset_io(clock_source);
85
86 auto start = std::chrono::high_resolution_clock::now();
87
88 // Wait for clocks to be happy
89 while (true)
90 {
91 if (get_io_node_plain()->clocks_ok())
92 {
93 TLOG() << "Clocks ready!";
94 break;
95 }
96
97 auto now = std::chrono::high_resolution_clock::now();
98 auto ms_since_start = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
99
100 if (ms_since_start.count() > 500)
101 throw ClocksNotReady(ERS_HERE, "IO");
102
103 std::this_thread::sleep_for(std::chrono::microseconds(10));
104 }
105 }
106
110 std::string get_hardware_info(bool print_out = false) const override
111 {
112 auto info = get_io_node_plain()->get_hardware_info();
113 if (print_out)
114 TLOG() << info;
115 return info;
116 }
117
121 void get_info(timingfirmwareinfo::TimingDeviceInfo& mon_data) const override
122 {
124 }
125};
126
127} // namespace timing
128} // namespace dunedaq
129
130#endif // TIMING_INCLUDE_TIMING_TOPDESIGN_HPP_
#define ERS_HERE
Base class for timing IO nodes.
Definition IONode.hpp:44
virtual void reset(const std::string &clock_config_file) const =0
Reset timing node.
virtual std::string get_hardware_info(bool print_out=false) const
Print hardware information.
Definition IONode.cpp:118
virtual void soft_reset() const
Reset timing node.
Definition IONode.cpp:305
virtual void get_info(timinghardwareinfo::TimingPLLMonitorData &mon_data) const
Definition IONode.hpp:186
Base class for timing top design nodes.
Base class for timing top design nodes with IO class.
Definition TopDesign.hpp:39
void configure(ClockSource clock_source) const override
Prepare the timing device for data taking.
Definition TopDesign.hpp:81
void get_info(timingfirmwareinfo::TimingDeviceInfo &mon_data) const override
Give info to collector.
void soft_reset_io() const override
Reset timing node.
Definition TopDesign.hpp:56
void reset_io(const ClockSource &clock_source) const override
Reset timing node.
Definition TopDesign.hpp:72
const IONode * get_io_node_plain() const override
Get io node pointer.
Definition TopDesign.hpp:48
std::string get_hardware_info(bool print_out=false) const override
Print hardware information.
void reset_io(const std::string &clock_config_file) const override
Reset timing node.
Definition TopDesign.hpp:64
TopDesign(const uhal::Node &node)
Definition TopDesign.hpp:41
static int64_t now()
#define TLOG(...)
Definition macro.hpp:22
Including Qt Headers.
timinghardwareinfo::TimingPLLMonitorData pll_info
Definition Structs.hpp:111