DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
IRIGTimestampNode.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
16namespace dunedaq {
17namespace timing {
18
19UHAL_REGISTER_DERIVED_NODE(IRIGTimestampNode)
20
21//-----------------------------------------------------------------------------
23 : TimingNode(node)
24{}
25//-----------------------------------------------------------------------------
26
27//-----------------------------------------------------------------------------
29//-----------------------------------------------------------------------------
30
31//-----------------------------------------------------------------------------
32std::string
33IRIGTimestampNode::get_status(bool print_out) const
34{
35 std::stringstream status;
36 status << "Timestamp: 0x" << std::hex << read_timestamp() << std::endl;
37
38 auto ctrl_subnodes = read_sub_nodes(getNode("csr.ctrl"));
39 status << format_reg_table(ctrl_subnodes, "IRIG ts ctrl");
40
41 auto stat_subnodes = read_sub_nodes(getNode("csr.stat"));
42 status << format_reg_table(stat_subnodes, "IRIG ts state");
43
44 auto date_subnodes = read_sub_nodes(getNode("csr.irig_date"));
45 status << format_reg_table(date_subnodes, "IRIG date");
46
47 auto time_subnodes = read_sub_nodes(getNode("csr.irig_time"));
48 status << format_reg_table(time_subnodes, "IRIG time");
49
50 status << "PPS counter: 0x" << std::hex << read_pps_counter() << std::endl;
51
52 status << "Seconds since epoch: 0x" << std::hex << read_seconds_since_epoch() << std::endl;
53
54 if (print_out)
55 TLOG() << status.str();
56 return status.str();
57}
58//-----------------------------------------------------------------------------
59
60//-----------------------------------------------------------------------------
61uhal::ValVector<uint32_t> // NOLINT(build/unsigned)
63{
64 auto timestamp = getNode("tstamp").readBlock(2);
65 if (dispatch)
66 getClient().dispatch();
67 return timestamp;
68}
69//-----------------------------------------------------------------------------
70
71//-----------------------------------------------------------------------------
72uint64_t // NOLINT(build/unsigned)
77//-----------------------------------------------------------------------------
78
79//-----------------------------------------------------------------------------
80void
81IRIGTimestampNode::set_irig_epoch(IRIGEpoch irig_epoch) const // NOLINT(build/unsigned)
82{
83 getNode("csr.ctrl.rst").write(0x1);
84 getNode("csr.ctrl.irig_epoch").write(irig_epoch);
85 getNode("csr.ctrl.rst").write(0x0);
86 getClient().dispatch();
87}
88//-----------------------------------------------------------------------------
89
90//-----------------------------------------------------------------------------
91uint32_t // NOLINT(build/unsigned)
93{
94 auto counter = getNode("pps_ctr").read();
95 getClient().dispatch();
96 return counter.value();
97}
98//-----------------------------------------------------------------------------
99
100//-----------------------------------------------------------------------------
101uint64_t // NOLINT(build/unsigned)
103{
104 auto seconds_since_epoch = getNode("seconds_since_epoch").readBlock(2);
105 getClient().dispatch();
106 return tstamp2int(seconds_since_epoch);
107}
108//-----------------------------------------------------------------------------
109} // namespace timing
110} // namespace dunedaq
Class for timestamp generator node.
std::string get_status(bool print_out=false) const override
Print the status of the timing node.
uint64_t read_timestamp() const
Read the current timestamp words.
uint64_t read_seconds_since_epoch() const
Read the current seconds since epoch words.
void set_irig_epoch(IRIGEpoch irig_epoch) const
Set IRIG epoch: TAI/UNIX.
uhal::ValVector< uint32_t > read_raw_timestamp(bool dispatch=true) const
Read the current timestamp words.
uint32_t read_pps_counter() const
Read the current pps ctr word.
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
uint64_t tstamp2int(uhal::ValVector< uint32_t > raw_timestamp)
Definition toolbox.cpp:175
Including Qt Headers.