26{
29
31 string usr;
32 string pwd;
33 string cookie;
34 string id;
35 int run;
37
38 try {
39
40 JParser<> zap(
"Auxiliary program to print firmware vesion.");
41
46 zap[
'D'] =
make_field(
id,
"detector identifier") =
"";
49
50 zap(argc, argv);
51 }
52 catch(const exception &error) {
53 FATAL(error.what() << endl);
54 }
55
56
57 try {
58 JDB::reset(usr, pwd, cookie);
59 }
60 catch(const exception& error) {
61 FATAL(error.what() << endl);
62 }
63
64 const string detid = getDetector<string>(id);
65
67
68 try {
69
71
72 if (! (rs >> clbmap)) {
74 }
75
76 rs.Close();
77 }
78 catch(const exception& error) {
79 FATAL(
"Detector " << detid <<
" - " << error.what() << endl);
80 }
81
82 if (clbmap.empty()) {
83 FATAL(
"Detector " << detid <<
" - " <<
" no data." << endl);
84 }
85
86
87 struct {
89 {
92 else
94 }
95 } compare;
96
97 sort(clbmap.begin(), clbmap.end(), compare);
98
99
100 for (const auto& i : clbmap) {
101
102 string version = "?";
103
104 try {
105
106 JSelector selection(&JDatalogNumbers::SOURCE_NAME, i.UPI.toString());
107
109
110 ResultSet& rs =
getResultSet(getTable<JDatalogNumbers>(), selection);
111
113
114 const int value = (int) parameters.DATA_VALUE;
115
116 if (value != 0) {
117
118 const size_t pos = parameters.PARAMETER_NAME.find("BUILD");
119
120 if (pos != string::npos) {
121
122 const size_t ls[] = {
123 parameters.PARAMETER_NAME.find('['),
124 parameters.PARAMETER_NAME.find(']')
125 };
126
128
129 size_t index;
130
131 istringstream(parameters.PARAMETER_NAME.substr(
ls[0] + 1,
ls[1] -
ls[0] + 1)) >> index;
132
133 if (version.size() <= index) {
134 version.append(index - version.size() + 1, ' ');
135 }
136
137 DEBUG(parameters.PARAMETER_NAME <<
' ' <<
ls[0] <<
' ' <<
ls[1] <<
' ' << index <<
' ' << value << endl);
138
139 version[index] = (char) value;
140 }
141 }
142 }
143 }
144
145 rs.Close();
146 }
147 catch(const exception& error) {
148 FATAL(error.what() << endl);
149 }
150
151 cout <<
"Firmware: " <<
FILL(4,
'0') << i.DUID <<
'.' <<
FILL(2,
'0') << i.FLOORID <<
" " << setw(24) << left << i.UPI <<
" \"" << version <<
"\"" << right << endl;
152 }
153
154 return 0;
155}
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
ResultSet & getResultSet(const std::string &query)
Get result set.
std::vector< JServer > getServernames()
Get list of names of available database servers.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Wrapper class for server name.
Template definition for getting table specific selector.
Auxiliary data structure to list files in directory.