@@ -36,7 +36,8 @@ class ProgramStatus : public Program
3636 {
3737 return { " Status" , " Return current RoC configuration status" ,
3838 " roc-status --id 42:00.0\n "
39- " roc-status --id 42:00.0 --json" };
39+ " roc-status --id 42:00.0 --json"
40+ " roc-status --id 42:00.0 --csv" };
4041 }
4142
4243 virtual void addOptions (boost::program_options::options_description& options)
@@ -45,6 +46,9 @@ class ProgramStatus : public Program
4546 options.add_options ()(" json-out" ,
4647 po::bool_switch (&mOptions .jsonOut ),
4748 " Toggle json-formatted output" );
49+ options.add_options ()(" csv-out" ,
50+ po::bool_switch (&mOptions .csvOut ),
51+ " Toggle csv-formatted output" );
4852 }
4953
5054 virtual void run (const boost::program_options::variables_map& map)
@@ -64,7 +68,10 @@ class ProgramStatus : public Program
6468 auto lineFat = std::string (header.length (), ' =' ) + ' \n ' ;
6569 auto lineThin = std::string (header.length (), ' -' ) + ' \n ' ;
6670
67- if (!mOptions .jsonOut ) {
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 ) {
6875 table << lineFat << header << lineThin;
6976 }
7077
@@ -92,7 +99,14 @@ class ProgramStatus : public Program
9299
93100 std::string clock = (reportInfo.ttcClock == 0 ? " TTC" : " Local" );
94101
95- if (!mOptions .jsonOut ) {
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 ) {
96110 std::cout << " ----------------------------" << std::endl;
97111 std::cout << clock << " clock | " ;
98112 if (reportInfo.dynamicOffset ) {
@@ -101,13 +115,6 @@ class ProgramStatus : public Program
101115 std::cout << " Fixed offset" << std::endl;
102116 }
103117 std::cout << " ----------------------------" << std::endl;
104- } else {
105- root.put (" clock" , clock);
106- if (reportInfo.dynamicOffset ) {
107- root.put (" offset" , " Dynamic" );
108- } else {
109- root.put (" offset" , " Fixed" );
110- }
111118 }
112119
113120 for (const auto & el : reportInfo.linkMap ) {
@@ -150,10 +157,7 @@ class ProgramStatus : public Program
150157
151158 float opticalPower = link.opticalPower ;
152159
153- if (!mOptions .jsonOut ) {
154- auto format = boost::format (formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower;
155- table << format;
156- } else {
160+ if (mOptions .jsonOut ) {
157161 pt::ptree linkNode;
158162
159163 // add kv pairs for this card
@@ -169,21 +173,29 @@ class ProgramStatus : public Program
169173
170174 // add the link node to the tree
171175 root.add_child (std::to_string (globalId), linkNode);
176+ } 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 " ;
179+ std::cout << csvLine;
180+ } else {
181+ auto format = boost::format (formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower;
182+ table << format;
172183 }
173184 }
174185
175- if (!mOptions .jsonOut ) {
186+ if (mOptions .jsonOut ) {
187+ pt::write_json (std::cout, root);
188+ } else if (!mOptions .jsonOut ) {
176189 auto lineFat = std::string (header.length (), ' =' ) + ' \n ' ;
177190 table << lineFat;
178191 std::cout << table.str ();
179- } else {
180- pt::write_json (std::cout, root);
181192 }
182193 }
183194
184195 private:
185196 struct OptionsStruct {
186197 bool jsonOut = false ;
198+ bool csvOut = false ;
187199 } mOptions ;
188200};
189201
0 commit comments