|
17 | 17 | #include "Cru/Common.h" |
18 | 18 | #include "Cru/Constants.h" |
19 | 19 | #include "Cru/CruBar.h" |
| 20 | +#include "Crorc/Common.h" |
| 21 | +#include "Crorc/CrorcBar.h" |
20 | 22 | #include "ReadoutCard/ChannelFactory.h" |
21 | 23 | #include "CommandLineUtilities/Options.h" |
22 | 24 | #include "CommandLineUtilities/Program.h" |
@@ -62,125 +64,208 @@ class ProgramStatus : public Program |
62 | 64 | }; |
63 | 65 |
|
64 | 66 | std::ostringstream table; |
65 | | - auto formatHeader = " %-9s %-16s %-10s %-14s %-15s %-10s %-14s %-14s %-8s %-19s\n"; |
66 | | - auto formatRow = " %-9s %-16s %-10s %-14s %-15s %-10s %-14.2f %-14.2f %-8s %-19.1f\n"; |
67 | | - auto header = (boost::format(formatHeader) % "Link ID" % "GBT Mode Tx/Rx" % "Loopback" % "GBT MUX" % "Datapath Mode" % "Datapath" % "RX freq(MHz)" % "TX freq(MHz)" % "Status" % "Optical power(uW)").str(); |
68 | | - auto lineFat = std::string(header.length(), '=') + '\n'; |
69 | | - auto lineThin = std::string(header.length(), '-') + '\n'; |
70 | | - |
71 | | - if (mOptions.csvOut) { |
72 | | - auto csvHeader = "Link ID,GBT Mode,Loopback,GBT Mux,Datapath Mode,Datapath,RX Freq(MHz),TX Freq(MHz),Status,Optical Power(uW)\n"; |
73 | | - std::cout << csvHeader; |
74 | | - } else if (!mOptions.jsonOut) { |
75 | | - table << lineFat << header << lineThin; |
76 | | - } |
| 67 | + std::string formatHeader; |
| 68 | + std::string formatRow; |
| 69 | + std::string header; |
| 70 | + std::string lineFat; |
| 71 | + std::string lineThin; |
77 | 72 |
|
78 | 73 | // initialize ptree |
79 | 74 | pt::ptree root; |
80 | 75 |
|
81 | 76 | auto cardId = Options::getOptionCardId(map); |
82 | | - auto params = Parameters::makeParameters(cardId, 2); //status available on BAR2 |
83 | | - // We care for all of the links |
84 | | - //params.setLinkMask(Parameters::linkMaskFromString("0-23")); |
85 | | - auto bar2 = ChannelFactory().getBar(params); |
| 77 | + auto cardType = RocPciDevice(cardId).getCardDescriptor().cardType; |
86 | 78 |
|
87 | | - CardType::type cardType = bar2->getCardType(); |
88 | 79 | if (cardType == CardType::type::Crorc) { |
89 | | - std::cout << "CRORC status report not yet supported" << std::endl; |
90 | | - return; |
91 | | - } else if (cardType != CardType::type::Cru) { |
92 | | - std::cout << "Invalid card type" << std::endl; |
93 | | - return; |
94 | | - } |
| 80 | + formatHeader = " %-9s %-8s %-19s\n"; |
| 81 | + formatRow = " %-9s %-8s %-19.1f\n"; |
| 82 | + header = (boost::format(formatHeader) % "Link ID" % "Status" % "Optical power(uW)").str(); |
| 83 | + lineFat = std::string(header.length(), '=') + '\n'; |
| 84 | + lineThin = std::string(header.length(), '-') + '\n'; |
95 | 85 |
|
96 | | - auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar2); |
| 86 | + if (mOptions.csvOut) { |
| 87 | + auto csvHeader = "Link ID,Status,Optical Power(uW),QSFP Enabled,Offset\n"; |
| 88 | + std::cout << csvHeader; |
| 89 | + } else if (!mOptions.jsonOut) { |
| 90 | + table << lineFat << header << lineThin; |
| 91 | + } |
97 | 92 |
|
98 | | - Cru::ReportInfo reportInfo = cruBar2->report(); |
| 93 | + auto params = Parameters::makeParameters(cardId, 0); //status available on BAR0 |
| 94 | + auto bar0 = ChannelFactory().getBar(params); |
| 95 | + auto crorcBar0 = std::dynamic_pointer_cast<CrorcBar>(bar0); |
99 | 96 |
|
100 | | - std::string clock = (reportInfo.ttcClock == 0 ? "TTC" : "Local"); |
| 97 | + Crorc::ReportInfo reportInfo = crorcBar0->report(); |
101 | 98 |
|
102 | | - if (mOptions.jsonOut) { |
103 | | - root.put("clock", clock); |
104 | | - if (reportInfo.dynamicOffset) { |
105 | | - root.put("offset", "Dynamic"); |
106 | | - } else { |
107 | | - root.put("offset", "Fixed"); |
108 | | - } |
109 | | - } else if (!mOptions.csvOut) { |
110 | | - std::cout << "----------------------------" << std::endl; |
111 | | - std::cout << clock << " clock | "; |
112 | | - if (reportInfo.dynamicOffset) { |
113 | | - std::cout << "Dynamic offset" << std::endl; |
| 99 | + /* GENERAL PARAMETERS */ |
| 100 | + if (mOptions.jsonOut) { |
| 101 | + if (reportInfo.qsfpEnabled) { |
| 102 | + root.put("qsfp", "Enabled"); |
| 103 | + } else { |
| 104 | + root.put("qsfp", "Disabled"); |
| 105 | + } |
| 106 | + |
| 107 | + if (reportInfo.dynamicOffset) { |
| 108 | + root.put("offset", "Dynamic"); |
| 109 | + } else { |
| 110 | + root.put("offset", "Fixed"); |
| 111 | + } |
| 112 | + } else if (mOptions.csvOut) { |
| 113 | + auto csvLine = std::string(",,,") + (reportInfo.qsfpEnabled ? "Enabled" : "Disabled") + "," + (reportInfo.dynamicOffset ? "Dynamic" : "Fixed") + "\n"; |
| 114 | + std::cout << csvLine; |
114 | 115 | } else { |
115 | | - std::cout << "Fixed offset" << std::endl; |
116 | | - } |
117 | | - std::cout << "----------------------------" << std::endl; |
118 | | - } |
| 116 | + std::cout << "----------------------------" << std::endl; |
| 117 | + if (reportInfo.qsfpEnabled) { |
| 118 | + std::cout << "QSFP enabled | "; |
| 119 | + } else { |
| 120 | + std::cout << "QSFP disabled | "; |
| 121 | + } |
119 | 122 |
|
120 | | - for (const auto& el : reportInfo.linkMap) { |
121 | | - auto link = el.second; |
122 | | - int globalId = el.first; //Use the "new" link mapping |
123 | | - std::string gbtTxMode = GbtMode::toString(link.gbtTxMode); |
124 | | - std::string gbtRxMode = GbtMode::toString(link.gbtRxMode); |
125 | | - std::string gbtTxRxMode = gbtTxMode + "/" + gbtRxMode; |
126 | | - std::string loopback = (link.loopback == false ? "None" : "Enabled"); |
127 | | - |
128 | | - std::string downstreamData; |
129 | | - if (reportInfo.downstreamData == Cru::DATA_CTP) { |
130 | | - downstreamData = "CTP"; |
131 | | - } else if (reportInfo.downstreamData == Cru::DATA_PATTERN) { |
132 | | - downstreamData = "PATTERN"; |
133 | | - } else if (reportInfo.downstreamData == Cru::DATA_MIDTRG) { |
134 | | - downstreamData = "MIDTRG"; |
| 123 | + if (reportInfo.dynamicOffset) { |
| 124 | + std::cout << "Dynamic offset" << std::endl; |
| 125 | + } else { |
| 126 | + std::cout << "Fixed offset" << std::endl; |
| 127 | + } |
| 128 | + std::cout << "----------------------------" << std::endl; |
135 | 129 | } |
136 | 130 |
|
137 | | - std::string gbtMux = GbtMux::toString(link.gbtMux); |
138 | | - if (gbtMux == "TTC") { |
139 | | - gbtMux += ":" + downstreamData; |
140 | | - } |
| 131 | + /* PARAMETERS PER LINK */ |
| 132 | + for (const auto& el : reportInfo.linkMap) { |
| 133 | + auto link = el.second; |
| 134 | + int id = el.first; |
141 | 135 |
|
142 | | - std::string datapathMode = DatapathMode::toString(link.datapathMode); |
| 136 | + std::string linkStatus = link.status == Crorc::LinkStatus::Up ? "UP" : "DOWN"; |
| 137 | + float opticalPower = link.opticalPower; |
143 | 138 |
|
144 | | - std::string enabled = (link.enabled) ? "Enabled" : "Disabled"; |
| 139 | + if (mOptions.jsonOut) { |
| 140 | + pt::ptree linkNode; |
145 | 141 |
|
146 | | - float rxFreq = link.rxFreq; |
147 | | - float txFreq = link.txFreq; |
| 142 | + // add kv pairs for this card |
| 143 | + linkNode.put("status", linkStatus); |
| 144 | + linkNode.put("opticalPower", enforcePrecision(opticalPower)); |
148 | 145 |
|
149 | | - std::string linkStatus; |
150 | | - if (link.stickyBit == Cru::LinkStatus::Up) { |
151 | | - linkStatus = "UP"; |
152 | | - } else if (link.stickyBit == Cru::LinkStatus::UpWasDown) { |
153 | | - linkStatus = "UP (was DOWN)"; |
154 | | - } else if (link.stickyBit == Cru::LinkStatus::Down) { |
155 | | - linkStatus = "DOWN"; |
| 146 | + // add the link node to the tree |
| 147 | + root.add_child(std::to_string(id), linkNode); |
| 148 | + } else if (mOptions.csvOut) { |
| 149 | + auto csvLine = std::to_string(id) + "," + linkStatus + "," + std::to_string(opticalPower) + "\n"; |
| 150 | + std::cout << csvLine; |
| 151 | + } else { |
| 152 | + auto format = boost::format(formatRow) % id % linkStatus % opticalPower; |
| 153 | + table << format; |
| 154 | + } |
156 | 155 | } |
| 156 | + } else if (cardType == CardType::type::Cru) { |
| 157 | + formatHeader = " %-9s %-16s %-10s %-14s %-15s %-10s %-14s %-14s %-8s %-19s\n"; |
| 158 | + formatRow = " %-9s %-16s %-10s %-14s %-15s %-10s %-14.2f %-14.2f %-8s %-19.1f\n"; |
| 159 | + header = (boost::format(formatHeader) % "Link ID" % "GBT Mode Tx/Rx" % "Loopback" % "GBT MUX" % "Datapath Mode" % "Datapath" % "RX freq(MHz)" % "TX freq(MHz)" % "Status" % "Optical power(uW)").str(); |
| 160 | + lineFat = std::string(header.length(), '=') + '\n'; |
| 161 | + lineThin = std::string(header.length(), '-') + '\n'; |
157 | 162 |
|
158 | | - float opticalPower = link.opticalPower; |
| 163 | + auto params = Parameters::makeParameters(cardId, 2); //status available on BAR2 |
| 164 | + auto bar2 = ChannelFactory().getBar(params); |
| 165 | + auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar2); |
159 | 166 |
|
| 167 | + if (mOptions.csvOut) { |
| 168 | + auto csvHeader = "Link ID,GBT Mode,Loopback,GBT Mux,Datapath Mode,Datapath,RX Freq(MHz),TX Freq(MHz),Status,Optical Power(uW),Clock,Offset\n"; |
| 169 | + std::cout << csvHeader; |
| 170 | + } else if (!mOptions.jsonOut) { |
| 171 | + table << lineFat << header << lineThin; |
| 172 | + } |
| 173 | + |
| 174 | + Cru::ReportInfo reportInfo = cruBar2->report(); |
| 175 | + |
| 176 | + std::string clock = (reportInfo.ttcClock == 0 ? "TTC" : "Local"); |
| 177 | + |
| 178 | + /* GENERAL PARAMETERS */ |
160 | 179 | if (mOptions.jsonOut) { |
161 | | - pt::ptree linkNode; |
162 | | - |
163 | | - // add kv pairs for this card |
164 | | - linkNode.put("gbtMode", gbtTxRxMode); |
165 | | - linkNode.put("loopback", loopback); |
166 | | - linkNode.put("gbtMux", gbtMux); |
167 | | - linkNode.put("datapathMode", datapathMode); |
168 | | - linkNode.put("datapath", enabled); |
169 | | - linkNode.put("rxFreq", enforcePrecision(rxFreq)); |
170 | | - linkNode.put("txFreq", enforcePrecision(txFreq)); |
171 | | - linkNode.put("status", linkStatus); |
172 | | - linkNode.put("opticalPower", enforcePrecision(opticalPower)); |
173 | | - |
174 | | - // add the link node to the tree |
175 | | - root.add_child(std::to_string(globalId), linkNode); |
| 180 | + root.put("clock", clock); |
| 181 | + if (reportInfo.dynamicOffset) { |
| 182 | + root.put("offset", "Dynamic"); |
| 183 | + } else { |
| 184 | + root.put("offset", "Fixed"); |
| 185 | + } |
176 | 186 | } else if (mOptions.csvOut) { |
177 | | - auto csvLine = std::to_string(globalId) + "," + gbtTxRxMode + "," + loopback + "," + gbtMux + "," + datapathMode + "," + enabled + "," + |
178 | | - std::to_string(rxFreq) + "," + std::to_string(txFreq) + "," + linkStatus + "," + std::to_string(opticalPower) + "\n"; |
| 187 | + auto csvLine = ",,,,,,,,,," + clock + "," + (reportInfo.dynamicOffset ? "Dynamic" : "Fixed") + "\n"; |
179 | 188 | std::cout << csvLine; |
180 | 189 | } else { |
181 | | - auto format = boost::format(formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower; |
182 | | - table << format; |
| 190 | + std::cout << "----------------------------" << std::endl; |
| 191 | + std::cout << clock << " clock | "; |
| 192 | + if (reportInfo.dynamicOffset) { |
| 193 | + std::cout << "Dynamic offset" << std::endl; |
| 194 | + } else { |
| 195 | + std::cout << "Fixed offset" << std::endl; |
| 196 | + } |
| 197 | + std::cout << "----------------------------" << std::endl; |
183 | 198 | } |
| 199 | + |
| 200 | + /* PARAMETERS PER LINK */ |
| 201 | + for (const auto& el : reportInfo.linkMap) { |
| 202 | + auto link = el.second; |
| 203 | + int globalId = el.first; //Use the "new" link mapping |
| 204 | + std::string gbtTxMode = GbtMode::toString(link.gbtTxMode); |
| 205 | + std::string gbtRxMode = GbtMode::toString(link.gbtRxMode); |
| 206 | + std::string gbtTxRxMode = gbtTxMode + "/" + gbtRxMode; |
| 207 | + std::string loopback = (link.loopback == false ? "None" : "Enabled"); |
| 208 | + |
| 209 | + std::string downstreamData; |
| 210 | + if (reportInfo.downstreamData == Cru::DATA_CTP) { |
| 211 | + downstreamData = "CTP"; |
| 212 | + } else if (reportInfo.downstreamData == Cru::DATA_PATTERN) { |
| 213 | + downstreamData = "PATTERN"; |
| 214 | + } else if (reportInfo.downstreamData == Cru::DATA_MIDTRG) { |
| 215 | + downstreamData = "MIDTRG"; |
| 216 | + } |
| 217 | + |
| 218 | + std::string gbtMux = GbtMux::toString(link.gbtMux); |
| 219 | + if (gbtMux == "TTC") { |
| 220 | + gbtMux += ":" + downstreamData; |
| 221 | + } |
| 222 | + |
| 223 | + std::string datapathMode = DatapathMode::toString(link.datapathMode); |
| 224 | + |
| 225 | + std::string enabled = (link.enabled) ? "Enabled" : "Disabled"; |
| 226 | + |
| 227 | + float rxFreq = link.rxFreq; |
| 228 | + float txFreq = link.txFreq; |
| 229 | + |
| 230 | + std::string linkStatus; |
| 231 | + if (link.stickyBit == Cru::LinkStatus::Up) { |
| 232 | + linkStatus = "UP"; |
| 233 | + } else if (link.stickyBit == Cru::LinkStatus::UpWasDown) { |
| 234 | + linkStatus = "UP (was DOWN)"; |
| 235 | + } else if (link.stickyBit == Cru::LinkStatus::Down) { |
| 236 | + linkStatus = "DOWN"; |
| 237 | + } |
| 238 | + |
| 239 | + float opticalPower = link.opticalPower; |
| 240 | + |
| 241 | + if (mOptions.jsonOut) { |
| 242 | + pt::ptree linkNode; |
| 243 | + |
| 244 | + // add kv pairs for this card |
| 245 | + linkNode.put("gbtMode", gbtTxRxMode); |
| 246 | + linkNode.put("loopback", loopback); |
| 247 | + linkNode.put("gbtMux", gbtMux); |
| 248 | + linkNode.put("datapathMode", datapathMode); |
| 249 | + linkNode.put("datapath", enabled); |
| 250 | + linkNode.put("rxFreq", enforcePrecision(rxFreq)); |
| 251 | + linkNode.put("txFreq", enforcePrecision(txFreq)); |
| 252 | + linkNode.put("status", linkStatus); |
| 253 | + linkNode.put("opticalPower", enforcePrecision(opticalPower)); |
| 254 | + |
| 255 | + // add the link node to the tree |
| 256 | + root.add_child(std::to_string(globalId), linkNode); |
| 257 | + } else if (mOptions.csvOut) { |
| 258 | + auto csvLine = std::to_string(globalId) + "," + gbtTxRxMode + "," + loopback + "," + gbtMux + "," + datapathMode + "," + enabled + "," + |
| 259 | + std::to_string(rxFreq) + "," + std::to_string(txFreq) + "," + linkStatus + "," + std::to_string(opticalPower) + "\n"; |
| 260 | + std::cout << csvLine; |
| 261 | + } else { |
| 262 | + auto format = boost::format(formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower; |
| 263 | + table << format; |
| 264 | + } |
| 265 | + } |
| 266 | + } else { |
| 267 | + std::cout << "Invalid card type" << std::endl; |
| 268 | + return; |
184 | 269 | } |
185 | 270 |
|
186 | 271 | if (mOptions.jsonOut) { |
|
0 commit comments