DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::timing::EndpointNode Class Reference

Base class for timing IO nodes. More...

#include <EndpointNode.hpp>

Inheritance diagram for dunedaq::timing::EndpointNode:
[legend]
Collaboration diagram for dunedaq::timing::EndpointNode:
[legend]

Public Member Functions

 EndpointNode (const uhal::Node &node)
 
virtual ~EndpointNode ()
 
std::string get_status (bool print_out=false) const override
 Print the status of the timing node.
 
void enable (uint32_t address=0, uint32_t partition=0) const override
 Enable the endpoint.
 
void disable () const override
 Disable the endpoint.
 
void reset (uint32_t address=0, uint32_t partition=0) const override
 Reset the endpoint.
 
virtual uint64_t read_timestamp () const
 Read the current timestamp word.
 
void get_info (timingendpointinfo::TimingEndpointInfo &mon_data) const override
 Read the endpoint clock frequency.
 
- Public Member Functions inherited from dunedaq::timing::EndpointNodeInterface
 EndpointNodeInterface (const uhal::Node &node)
 
virtual ~EndpointNodeInterface ()
 
virtual bool endpoint_ready () const
 Get endpoint ready flag.
 
virtual uint32_t read_endpoint_state () const
 Get endpoint state.
 
- Public Member Functions inherited from dunedaq::timing::TimingNode
 TimingNode (const uhal::Node &node)
 
virtual ~TimingNode ()
 
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes (const uhal::Node &node, bool dispatch=true) const
 Read subnodes.
 
void reset_sub_nodes (const uhal::Node &node, uint32_t aValue=0x0, bool dispatch=true) const
 Reset subnodes.
 

Static Public Member Functions

static std::map< uint8_t, std::string > get_endpoint_state_map ()
 Get the states map.
 

Static Protected Attributes

static const std::map< uint8_t, std::string > endpoint_state_map
 

Detailed Description

Base class for timing IO nodes.

Definition at line 35 of file EndpointNode.hpp.

Constructor & Destructor Documentation

◆ EndpointNode()

dunedaq::timing::EndpointNode::EndpointNode ( const uhal::Node & node)
explicit

Definition at line 24 of file EndpointNode.cpp.

26{}

◆ ~EndpointNode()

dunedaq::timing::EndpointNode::~EndpointNode ( )
virtual

Definition at line 30 of file EndpointNode.cpp.

30{}

Member Function Documentation

◆ disable()

void dunedaq::timing::EndpointNode::disable ( ) const
overridevirtual

Disable the endpoint.

Returns
{ description_of_the_return_value }

Implements dunedaq::timing::EndpointNodeInterface.

Definition at line 73 of file EndpointNode.cpp.

74{
75 getNode("csr.ctrl.ep_en").write(0x0);
76// getNode("csr.ctrl.buf_en").write(0x0);
77 getClient().dispatch();
78}

◆ enable()

void dunedaq::timing::EndpointNode::enable ( uint32_t address = 0,
uint32_t partition = 0 ) const
overridevirtual

Enable the endpoint.

Returns
{ description_of_the_return_value }

Implements dunedaq::timing::EndpointNodeInterface.

Definition at line 35 of file EndpointNode.cpp.

36{
37 getNode("csr.ctrl.addr").write(address);
38
39 getNode("csr.ctrl.ep_en").write(0x1);
40 getClient().dispatch();
41
42 auto start = std::chrono::high_resolution_clock::now();
43
44 std::chrono::milliseconds ms_since_start(0);
45
46 uhal::ValWord<uint32_t> counters_ready;
47
48 // Wait for the endpoint to be happy
49 while (ms_since_start.count() < 500) {
50 auto now = std::chrono::high_resolution_clock::now();
51 ms_since_start = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
52
53 millisleep(10);
54
55 counters_ready = getNode("csr.stat.ctrs_rdy").read();
56 getClient().dispatch();
57 TLOG_DEBUG(1) << "counters_ready: 0x" << std::hex << counters_ready.value();
58
59 if (counters_ready) {
60 TLOG_DEBUG(1) << "counters ready";
61 break;
62 }
63 }
64
65 if (!counters_ready) {
66 ers::warning(EndpointBroadcastMessageCountersNotReady(ERS_HERE));
67 }
68}
#define ERS_HERE
static int64_t now()
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
void millisleep(const double &time_in_milliseconds)
Definition toolbox.cpp:83
void warning(const Issue &issue)
Definition ers.hpp:115

◆ get_endpoint_state_map()

static std::map< uint8_t, std::string > dunedaq::timing::EndpointNode::get_endpoint_state_map ( )
inlinestatic

Get the states map.

Definition at line 91 of file EndpointNode.hpp.

91{ return endpoint_state_map; }
static const std::map< uint8_t, std::string > endpoint_state_map

◆ get_info()

void dunedaq::timing::EndpointNode::get_info ( timingendpointinfo::TimingEndpointInfo & mon_data) const
overridevirtual

Read the endpoint clock frequency.

Returns
{ description_of_the_return_value }

Collect monitoring information for timing endpoint

Reimplemented from dunedaq::timing::EndpointNodeInterface.

Definition at line 158 of file EndpointNode.cpp.

159{
160 auto timestamp = getNode("tstamp").readBlock(2);
161 auto endpoint_control = read_sub_nodes(getNode("csr.ctrl"), false);
162 auto endpoint_state = read_sub_nodes(getNode("csr.stat"), false);
163 getClient().dispatch();
164
165 mon_data.state = endpoint_state.at("ep_stat").value();
166 mon_data.ready = endpoint_state.at("ep_rdy").value();
167 mon_data.address = endpoint_control.at("addr").value();
168 mon_data.timestamp = tstamp2int(timestamp);
169 mon_data.sfp_tx_disable = !endpoint_state.at("ep_txen").value();
170}
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes(const uhal::Node &node, bool dispatch=true) const
Read subnodes.
uint64_t tstamp2int(uhal::ValVector< uint32_t > raw_timestamp)
Definition toolbox.cpp:175

◆ get_status()

std::string dunedaq::timing::EndpointNode::get_status ( bool print_out = false) const
overridevirtual

Print the status of the timing node.

Implements dunedaq::timing::TimingNode.

Definition at line 99 of file EndpointNode.cpp.

100{
101
102 std::stringstream status;
103
104 std::vector<std::pair<std::string, std::string>> ept_summary;
105
106 auto ept_timestamp = getNode("tstamp").readBlock(2);
107 auto ept_control = read_sub_nodes(getNode("csr.ctrl"), false);
108 auto ept_state = read_sub_nodes(getNode("csr.stat"), false);
109 getNode("cmd_ctrs.addr").write(0x0);
110 auto counters = getNode("cmd_ctrs.data").readBlock(0xff);
111 getClient().dispatch();
112
113 ept_summary.push_back(std::make_pair("Enabled", std::to_string(ept_control.find("ep_en")->second.value())));
114 ept_summary.push_back(std::make_pair("Address", std::to_string(ept_control.find("addr")->second.value())));
115 ept_summary.push_back(std::make_pair("State", get_endpoint_state_map().at(ept_state.find("ep_stat")->second.value())));
116 ept_summary.push_back(std::make_pair("Timestamp (hex)", format_reg_value(tstamp2int(ept_timestamp))));
117 ept_summary.push_back(std::make_pair("Timestamp", format_timestamp(ept_timestamp,62500000)));
118
119 status << std::endl << format_reg_table(ept_summary, "Endpoint summary", { "", "" }) << std::endl;
120// status << "Endpoint frequency: " << ept_clock_frequency << " MHz" << std::endl;
121 status << format_reg_table(ept_state, "Endpoint state") << std::endl;
122
123 std::vector<uint32_t> non_zero_counters;
124 std::vector<std::string> counter_labels;
125
126 for (uint i=0; i < counters.size(); ++i)
127 {
128 auto counter = counters.at(i);
129 if (counter > 0)
130 {
131 counter_labels.push_back(format_reg_value(i));
132 non_zero_counters.push_back(counter);
133 }
134 }
135 std::vector<std::vector<uint32_t>> counters_container = { non_zero_counters }; // NOLINT(build/unsigned)
136
137 status << format_counters_table(counters_container, { "Received cmd counters" }, "Endpoint cmd counters (>0)", counter_labels);
138 status << std::endl;
139
140 if (print_out)
141 TLOG() << status.str();
142 return status.str();
143}
static std::map< uint8_t, std::string > get_endpoint_state_map()
Get the states map.
#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_timestamp(uhal::ValVector< uint32_t > raw_timestamp, uint32_t clock_frequency_hz)
Definition toolbox.cpp:233
std::string format_counters_table(std::vector< T > counter_nodes, std::vector< std::string > counter_node_titles, std::string table_title, std::vector< std::string > counter_labels, std::string counter_labels_header)
Format reg-value table.
Definition toolbox.hxx:216
std::string format_reg_value(T reg_value, uint32_t base)
Definition toolbox.hxx:117

◆ read_timestamp()

uint64_t dunedaq::timing::EndpointNode::read_timestamp ( ) const
virtual

Read the current timestamp word.

Returns
{ description_of_the_return_value }

Definition at line 148 of file EndpointNode.cpp.

149{
150 auto timestamp = getNode("tstamp").readBlock(2);
151 getClient().dispatch();
152 return tstamp2int(timestamp);
153}

◆ reset()

void dunedaq::timing::EndpointNode::reset ( uint32_t address = 0,
uint32_t partition = 0 ) const
overridevirtual

Reset the endpoint.

Returns
{ description_of_the_return_value }

Implements dunedaq::timing::EndpointNodeInterface.

Definition at line 83 of file EndpointNode.cpp.

84{
85
86 getNode("csr.ctrl.ep_en").write(0x0);
87 getNode("csr.ctrl.ctr_rst").write(0x1);
88 getNode("csr.ctrl.ctr_rst").write(0x0);
89 getClient().dispatch();
90
91 //getNode("csr.ctrl.buf_en").write(0x0);
92
94}

Member Data Documentation

◆ endpoint_state_map

const std::map<uint8_t, std::string> dunedaq::timing::EndpointNode::endpoint_state_map
inlinestaticprotected
Initial value:
{
{ 0x0, "Standing by (0x0)" },
{ 0x1, "Waiting for input clock (0x1)" },
{ 0x2, "Waiting for good frequency check (0x2)" },
{ 0x3, "Waiting for internal CDR to lock (0x3)" },
{ 0x4, "Waiting for rx block to lock (0x4)" },
{ 0x5, "Waiting for address to be set (0x5)" },
{ 0x6, "Waiting for deskew to be set (0x6)" },
{ 0x7, "Waiting for timestamp initialisation (0x7)" },
{ 0x8, "Ready (0x8)" },
{ 0xc, "Error in physical layer (0xc)" },
{ 0xd, "Receive error (0xd)" },
{ 0xe, "Time check error (0xe)" },
{ 0xf, "Protocol error (0xf)" },
}

Definition at line 94 of file EndpointNode.hpp.

95 {
96 { 0x0, "Standing by (0x0)" }, // 0b0000 when ST_RESET, -- Endpoint in in reset
97 { 0x1, "Waiting for input clock (0x1)" }, // 0b0001 when ST_W_CLK, -- Waiting for input clock
98 { 0x2, "Waiting for good frequency check (0x2)" }, // 0b0010 when ST_W_FREQ, -- Waiting for frequency check
99 { 0x3, "Waiting for internal CDR to lock (0x3)" }, // 0b0011 when ST_W_CDR, -- Waiting for internal CDR to lock
100 { 0x4, "Waiting for rx block to lock (0x4)" }, // 0b0100 when ST_W_RX, -- Waiting for rx block to lock
101 { 0x5, "Waiting for address to be set (0x5)" }, // 0b0101 when ST_W_ADDR, -- Waiting for address to be set
102 { 0x6, "Waiting for deskew to be set (0x6)" }, // 0b0110 when ST_W_DESKEW, -- Waiting for deskew to be set
103 { 0x7, "Waiting for timestamp initialisation (0x7)" }, // 0b0111 when ST_W_TS, -- Waiting for timestamp initialisation
104 { 0x8, "Ready (0x8)" }, // 0b1000 when ST_READY, -- Good to go
105 { 0xc, "Error in physical layer (0xc)" }, // 0b1100 when ST_ERR_P, -- Error in physical layer
106 { 0xd, "Receive error (0xd)" }, // 0b1101 when ST_ERR_R, -- Receive error
107 { 0xe, "Time check error (0xe)" }, // 0b1110 when ST_ERR_T, -- Time check error
108 { 0xf, "Protocol error (0xf)" }, // 0b1111 when ST_ERR_X; -- Protocol error
109 };

The documentation for this class was generated from the following files: