Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDatalogString.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <sstream>
4#include <fstream>
5#include <iomanip>
6#include <vector>
7#include <set>
8#include <algorithm>
9
10#include "JLang/JPredicate.hh"
11#include "JLang/JComparator.hh"
12#include "JLang/JComparison.hh"
13
15
16#include "JDAQ/JDAQTags.hh"
17
18#include "JTools/JRange.hh"
19
20#include "JDB/JDatalogString.hh"
21#include "JDB/JLoggerMessage.hh"
22#include "JDB/JReplyMessage.hh"
23
24#include "Jeep/JeepToolkit.hh"
25#include "Jeep/JProperties.hh"
26#include "Jeep/JParser.hh"
27#include "Jeep/JMessage.hh"
28
29
30namespace {
31
32 using namespace JPP;
33
34 /**
35 * Print.
36 *
37 * \param out output stream
38 * \param object object
39 */
40 inline void print(std::ostream& out, const JDatalogString& object)
41 {
42 using namespace std;
43 using namespace JPP;
44
45 static int row = 0;
46
47 out << FILL(6,'0') << ++row << FILL() << ' ' << object << endl;
48 }
49}
50
51
52/**
53 * \file
54 * Auxiliary application to examine datalog file.
55 *
56 * \author mdejong
57 */
58int main(int argc, char **argv)
59{
60 using namespace std;
61 using namespace JPP;
62 using namespace KM3NETDAQ;
63
65
66 vector<string> datalogstringFile;
67 string egrep;
68 JLoggerMessage message;
69 JReplyMessage reply;
70 JDatalogString datalog;
71 JRange_t UTC;
72 int debug;
73
74 try {
75
76 JProperties fMessage;
77 JProperties fDatalog;
78 JProperties fReply;
79
80 fMessage.insert(gmake_property(message.tag));
81 fMessage.insert(gmake_property(message.process));
82 fMessage.insert(gmake_property(message.nickname));
83 fMessage.insert(gmake_property(message.ip));
84 fMessage.insert(gmake_property(message.fullname));
85 fMessage.insert(gmake_property(message.level));
86 fMessage.insert(gmake_property(message.data));
87
88 fDatalog.insert(gmake_property(datalog.source));
89 fDatalog.insert(gmake_property(datalog.parameter));
90 fDatalog.insert(gmake_property(datalog.data));
91
92 fReply .insert(gmake_property(reply.nickname));
93 fReply .insert(gmake_property(reply.ip));
94 fReply .insert(gmake_property(reply.event));
95 fReply .insert(gmake_property(reply.state));
96
97 JParser<> zap("Auxiliary application to examine datalog file.");
98
99 zap['f'] = make_field(datalogstringFile, "datalog file");
100 zap['e'] = make_field(egrep, "filter, precede with '!' to invert") = "";
101 zap['M'] = make_field(fMessage, "filter for logger message") = JPARSER::initialised();
102 zap['D'] = make_field(fDatalog, "filter for datalog string") = JPARSER::initialised();
103 zap['R'] = make_field(fReply, "filter for reply message") = JPARSER::initialised();
104 zap['T'] = make_field(UTC, "UTC time range [s]") = JRange_t();
105 zap['d'] = make_field(debug) = 2;
106
107 zap(argc, argv);
108 }
109 catch(const exception& error) {
110 FATAL(error.what() << endl);
111 }
112
113
114 JDatalogs_t datalogs;
115
116 try {
117 for (const auto& filename : datalogstringFile) {
118 datalogs.load(filename);
119 }
120 }
121 catch(const exception& error) {
122 FATAL(error.what() << endl);
123 }
124
125 {
126 JDatalogs_t::iterator __end = datalogs.end();
127
128 for (JDatalogs_t::iterator i = datalogs.begin(); i != __end; ) {
129
130 bool status = UTC(i->utc);
131
132 if (!egrep.empty()) {
133
134 if (egrep[0] != '!' && !regex_match(i->data, regex(".*" + egrep.substr(0) + ".*"))) { status = false; }
135 if (egrep[0] == '!' && regex_match(i->data, regex(".*" + egrep.substr(1) + ".*"))) { status = false; }
136 }
137
138 if (status) {
139
140 if (i->source == MESSAGE_TAG)
141
142 status = JLoggerMessage(*i).match(message);
143
144 else if (i->source == RC_REPLY.toString())
145
146 status = JReplyMessage (*i).match(reply);
147
148 else
149
150 status = i->match(datalog);
151 }
152
153 if (status)
154 ++i;
155 else
156 iter_swap(i, --__end);
157 }
158
159 datalogs.erase(__end, datalogs.end());
160 }
161
162 sort(datalogs.begin(), datalogs.end(), make_comparator(&JDatalogString::utc, JComparison::lt()));
163
164 for (const auto& datalog : datalogs) {
165 print(cout, datalog);
166 }
167}
Fixed parameters and ControlHost tags for KM3NeT DAQ.
int main(int argc, char **argv)
General purpose message reporting.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Auxiliary class to define a range between two values.
Auxiliary methods for handling file names, type names and environment.
Utility class to parse parameter values.
Utility class to parse command line options.
Definition JParser.hh:1698
Range of values.
Definition JRange.hh:42
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
static const std::string MESSAGE_TAG
Message logging tag.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Type definition of range.
Definition JHead.hh:43
Auxiliary data structure for datalog strings.
Container for datalog strings.
void load(const std::string &file_name)
Load message from input file.
Auxiliary data structure for logger message.
bool match(const JLoggerMessage &message) const
Get match.
Auxiliary data structure for reply message.
bool match(const JReplyMessage &message) const
Get match.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68