DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
src
GIBV3IONode.cpp
Go to the documentation of this file.
1
8
9
#include "
timing/GIBV3IONode.hpp
"
10
11
#include <string>
12
#include <math.h>
13
14
namespace
dunedaq
{
15
namespace
timing
{
16
17
UHAL_REGISTER_DERIVED_NODE(
GIBV3IONode
)
18
19
//-----------------------------------------------------------------------------
20
GIBV3IONode
::
GIBV3IONode
(const
uhal
::Node& node)
21
:
GIBV2IONode
(node)
22
{
23
}
24
//-----------------------------------------------------------------------------
25
26
//-----------------------------------------------------------------------------
27
GIBV3IONode::~GIBV3IONode
() {}
28
//-----------------------------------------------------------------------------
29
30
//-----------------------------------------------------------------------------
31
std::string
32
GIBV3IONode::get_status
(
bool
print_out)
const
33
{
34
std::stringstream status;
35
36
auto
subnodes =
read_sub_nodes
(getNode(
"csr.stat"
));
37
status <<
format_reg_table
(subnodes,
"GIB IO state"
);
38
39
auto
subnodes_2 =
read_sub_nodes
(getNode(
"csr.ctrl"
));
40
status <<
format_reg_table
(subnodes_2,
"GIB IO control"
);
41
42
uint8_t sfp_los =
read_sfps_los
();
43
uint8_t sfp_fault =
read_sfps_fault
();
44
45
std::vector<std::string> sfp_vec;
46
std::vector<uint8_t> los_vec;
47
std::vector<uint8_t> fault_vec;
48
49
for
(
int
i=0; i<
get_num_sfps
(); i++) {
50
sfp_vec.push_back(
to_string
(i));
51
// L is 0x4C, H is L - 4
52
los_vec.push_back(0x4C - 4*((sfp_los >> i) & 1));
53
fault_vec.push_back(0x4C - 4*((sfp_fault >> i) & 1));
54
}
55
56
status <<
"-----IO expander------"
<< std::endl;
57
status <<
"SFP: "
<<
vec_fmt
(sfp_vec) << std::endl;
58
status <<
"LOS: "
<<
vec_fmt
(los_vec) << std::endl;
59
status <<
"Fault: "
<<
vec_fmt
(fault_vec) << std::endl;
60
61
// removed temperature readout
62
63
if
(print_out)
64
TLOG
() << std::endl << status.str();
65
return
status.str();
66
}
67
//-----------------------------------------------------------------------------
68
69
//-----------------------------------------------------------------------------
70
uint32_t
71
GIBV3IONode::read_io_expanders
()
const
{
// NOLINT(build/unsigned)
72
auto
sfp_expander_0 =
get_i2c_device<I2CExpanderSlave>
(
m_uid_i2c_bus
,
"SFPExpander0"
);
73
74
uint32_t expander_bits = sfp_expander_0->read_inputs(1);
75
expander_bits = (expander_bits << 8) + sfp_expander_0->read_inputs(0);
76
77
return
expander_bits;
78
}
79
//-----------------------------------------------------------------------------
80
81
//-----------------------------------------------------------------------------
82
uint8_t
83
GIBV3IONode::read_sfps_los
()
const
{
// NOLINT(build/unsigned)
84
uint32_t expander_bits =
read_io_expanders
();
85
86
// A-CLK LOS is 1st bit
87
uint8_t los_bits =
static_cast<
uint8_t
>
(expander_bits & 1);
88
89
uint32_t los_bitmask = 0x003f;
90
91
uhal::ValWord<uint32_t> los_reg_data = getNode(
"csr.stat.sfp_los"
).read();
92
getClient().dispatch();
93
94
los_bits = (los_bits << 6) + static_cast<uint8_t>(los_reg_data & los_bitmask);
95
96
return
los_bits;
97
}
98
//-----------------------------------------------------------------------------
99
100
//-----------------------------------------------------------------------------
101
uint8_t
102
GIBV3IONode::read_sfps_fault
()
const
{
// NOLINT(build/unsigned)
103
uint32_t expander_bits =
read_io_expanders
();
104
105
// A-CLK fault is 2nd bit
106
uint8_t fault_bits =
static_cast<
uint8_t
>
((expander_bits >> 1) & 1);
107
108
for
(uint8_t sfp = 0; sfp<6; sfp++) {
109
// SFP faults are 0-5 on second bus of first expander
110
// Adds the SFPs in reverse order
111
fault_bits = (fault_bits << 1) + ((expander_bits >> (8 + 5 - sfp)) & 1);
112
}
113
114
return
fault_bits;
115
}
116
//-----------------------------------------------------------------------------
117
118
}
// namespace timing
119
}
// namespace dunedaq
GIBV3IONode.hpp
dunedaq::timing::GIBV2IONode::get_num_sfps
uint8_t get_num_sfps() const override
Definition
GIBV2IONode.cpp:122
dunedaq::timing::GIBV2IONode::GIBV2IONode
GIBV2IONode(const uhal::Node &node)
Definition
GIBV2IONode.cpp:20
dunedaq::timing::GIBV3IONode
Class for the timing FMC board.
Definition
GIBV3IONode.hpp:33
dunedaq::timing::GIBV3IONode::read_io_expanders
uint32_t read_io_expanders() const override
Read the contents of the IO expanders.
Definition
GIBV3IONode.cpp:71
dunedaq::timing::GIBV3IONode::~GIBV3IONode
virtual ~GIBV3IONode()
Definition
GIBV3IONode.cpp:27
dunedaq::timing::GIBV3IONode::read_sfps_los
uint8_t read_sfps_los() const override
Retrive SFP LOS status for all SFPs.
Definition
GIBV3IONode.cpp:83
dunedaq::timing::GIBV3IONode::GIBV3IONode
GIBV3IONode(const uhal::Node &node)
Definition
GIBV3IONode.cpp:20
dunedaq::timing::GIBV3IONode::read_sfps_fault
uint8_t read_sfps_fault() const override
Retrive SFP fault status for all SFPs.
Definition
GIBV3IONode.cpp:102
dunedaq::timing::GIBV3IONode::get_status
std::string get_status(bool print_out=false) const override
Get status string, optionally print.
Definition
GIBV3IONode.cpp:32
dunedaq::timing::IONode::m_uid_i2c_bus
const std::string m_uid_i2c_bus
Definition
IONode.hpp:215
dunedaq::timing::IONode::get_i2c_device
std::unique_ptr< const T > get_i2c_device(const std::string &i2c_bus_name, const std::string &i2c_device_name) const
Get the an I2C chip.
Definition
IONode.hxx:6
dunedaq::timing::TimingNode::read_sub_nodes
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes(const uhal::Node &node, bool dispatch=true) const
Read subnodes.
Definition
TimingNode.cpp:29
TLOG
#define TLOG(...)
Definition
macro.hpp:22
dunedaq::timing
< Message parameters
Definition
BoreasDesign.hpp:29
dunedaq::timing::format_reg_table
std::string format_reg_table(T data, std::string title, std::vector< std::string > headers)
Format reg-value table.
Definition
toolbox.hxx:166
dunedaq::timing::vec_fmt
std::string vec_fmt(const std::vector< T > &vec)
Definition
toolbox.hxx:382
dunedaq::timing::to_string
std::string to_string(const T &v)
Definition
toolbox.hxx:49
dunedaq
Including Qt Headers.
Definition
module.cpp:16
uhal
Definition
ProtocolAxi4Lite.hpp:63
Generated on
for DUNE-DAQ by
1.17.0