DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
FrequencyCounterNode.cpp
Go to the documentation of this file.
1
10
11#include "timing/toolbox.hpp"
12#include "logging/Logging.hpp"
13
14#include <string>
15#include <vector>
16
17namespace dunedaq {
18namespace timing {
19
20UHAL_REGISTER_DERIVED_NODE(FrequencyCounterNode)
21
22//-----------------------------------------------------------------------------
24 : TimingNode(node)
25{}
26//-----------------------------------------------------------------------------
27
28//-----------------------------------------------------------------------------
30//-----------------------------------------------------------------------------
31
32//-----------------------------------------------------------------------------
33std::string
35{
36 std::stringstream status;
37 auto subnodes = read_sub_nodes(getNode("csr.ctrl"));
38 status << format_reg_table(subnodes, "Freq counter state");
39 if (print_out)
40 TLOG() << status.str();
41 return status.str();
42}
43//-----------------------------------------------------------------------------
44
45//-----------------------------------------------------------------------------
46std::vector<double>
47FrequencyCounterNode::measure_frequencies(uint8_t number_of_clocks) const // NOLINT(build/unsigned)
48{
49 std::vector<double> frequencies;
50
51 for (uint8_t i = 0; i < number_of_clocks; ++i) { // NOLINT(build/unsigned)
52 getNode("ctrl.chan_sel").write(i);
53 getNode("ctrl.en_crap_mode").write(0);
54 getClient().dispatch();
55
56 millisleep(2000);
57
58 uhal::ValWord<uint32_t> frequency = getNode("freq.count").read(); // NOLINT(build/unsigned)
59 uhal::ValWord<uint32_t> frequency_valid = getNode("freq.valid").read(); // NOLINT(build/unsigned)
60 getClient().dispatch();
61
62 if (frequency_valid.value()) {
63 double freq = frequency.value() * 119.20928 / 1000000;
64 frequencies.push_back(freq);
65 } else {
66 frequencies.push_back(-1);
67 }
68 }
69 return frequencies;
70}
71//-----------------------------------------------------------------------------
72
73} // namespace timing
74} // namespace dunedaq
std::string get_status(bool print_out=false) const override
Get status string, optionally print.
std::vector< double > measure_frequencies(uint8_t number_of_clocks) const
Measure clock frequencies.
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.
#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
void millisleep(const double &time_in_milliseconds)
Definition toolbox.cpp:83
Including Qt Headers.