7 #include "TTimeStamp.h" 12 using std::istringstream;
13 using std::ostringstream;
22 : m_LogLevel(ps.
get<
int>(
"LogLevel")),
23 m_RunWidth(ps.
get<
Index>(
"RunWidth")),
24 m_SubRunWidth(ps.
get<
Index>(
"SubRunWidth")),
25 m_EventWidth(ps.
get<
Index>(
"EventWidth")),
26 m_ChannelWidth(ps.
get<
Index>(
"ChannelWidth")),
27 m_CountWidth(ps.
get<
Index>(
"CountWidth")),
28 m_FembWidth(ps.
get<
Index>(
"FembWidth")),
29 m_TriggerWidth(ps.
get<
Index>(
"TriggerWidth")),
31 const string myname =
"StandardAdcChannelStringTool::ctor: ";
51 m_bads[1] =
"SubRunNotFound";
52 m_bads[2] =
"EventNotFound";
53 m_bads[3] =
"ChannelNotFound";
54 m_bads[4] =
"CountNotFound";
55 m_bads[5] =
"Channel1NotFound";
56 m_bads[6] =
"Channel2NotFound";
57 m_bads[7] =
"FembNotFound";
58 m_bads[8] =
"TriggerNotFound";
60 cout << myname <<
"Configuration parameters:" <<
endl;
69 cout << myname <<
" TrigNames: [";
74 if ( (icnt/10)*10 == icnt ) cout <<
"\n" << myname <<
" ";
87 const string myname =
"StandardAdcChannelStringTool::build: ";
109 string smat =
m_reps[irep] +
"%";
110 string::size_type ipos = 1;
112 while ( (ipos = sout.find(smat, ipos)) != string::npos ) {
114 string::size_type iposRep = ipos;
115 string::size_type wOld = 0;
116 if ( sout[--iposRep] ==
'%' ) {
117 wOld = smat.size() + 1;
119 }
else if ( iposRep > 0 && sout[--iposRep] ==
'%' ) {
120 istringstream sswid(sout.substr(iposRep+1, 1));
123 if ( wNew == 0 ) wNew =
m_wids[irep];
124 if ( wNew == 999 ) wNew = 0;
125 wOld = smat.size() + 2;
136 Index ival = vals[irep];
140 while ( wNew > sval.size() ) sval =
"0" + sval;
142 sout.replace(iposRep, wOld, sval);
143 ipos = iposRep + sval.size();
150 string sunitSpaced = sunit.size() ?
" " + sunit :
"";
151 string sunitWrapped = sunit.size() ?
"(" + sunit +
")" :
"";
152 string sunitSpWrapped = sunit.size() ?
" " + sunitWrapped :
"";
153 string sunitOptWrapped = sunit.find(
" ") != string::npos ? sunitWrapped :
"";
154 string sunitSpOptWrapped = sunitOptWrapped.size() ?
" " + sunitOptWrapped :
"";
155 string sunitBarred = sunit.size() ?
"[" + sunit +
"]" :
"";
156 string sunitSpBarred = sunit.size() ?
" " + sunitBarred :
"";
157 sman.
replace(
"%SUNIT%", sunit);
158 sman.
replace(
"% SUNIT%", sunitSpaced);
159 sman.
replace(
"%(SUNIT)%", sunitWrapped);
160 sman.
replace(
"% (SUNIT)%", sunitSpWrapped);
161 sman.
replace(
"%((SUNIT))%", sunitOptWrapped);
162 sman.
replace(
"% ((SUNIT))%", sunitSpOptWrapped);
163 sman.
replace(
"%[SUNIT]%", sunitBarred);
164 sman.
replace(
"% [SUNIT]%", sunitSpBarred);
166 string asunit = sunit +
"-tick";
167 string::size_type ipos = sunit.find(
"/tick");
168 if ( ipos != string::npos ) {
169 asunit = sunit.substr(0, ipos) + sunit.substr(ipos + 5);
171 string asunitSpaced = asunit.size() ?
" " + asunit :
"";
172 string asunitWrapped = asunit.size() ?
"(" + asunit +
")" :
"";
173 string asunitSpWrapped = asunit.size() ?
" " + asunitWrapped :
"";
174 string asunitOptWrapped = asunit.find(
" ") != string::npos ? asunitWrapped :
"";
175 string asunitSpOptWrapped = asunitOptWrapped.size() ?
" " + asunitOptWrapped :
"";
176 string asunitBarred = asunit.size() ?
"[" + asunit +
"]" :
"";
177 string asunitSpBarred = asunit.size() ?
" " + asunitBarred :
"";
178 sman.
replace(
"%ASUNIT%", asunit);
179 sman.
replace(
"% ASUNIT%", asunitSpaced);
180 sman.
replace(
"%(ASUNIT)%", asunitWrapped);
181 sman.
replace(
"% (ASUNIT)%", asunitSpWrapped);
182 sman.
replace(
"%((ASUNIT))%", asunitOptWrapped);
183 sman.
replace(
"% ((ASUNIT))%", asunitSpOptWrapped);
184 sman.
replace(
"%[ASUNIT]%", asunitBarred);
185 sman.
replace(
"% [ASUNIT]%", asunitSpBarred);
187 if ( sout.find(
"%TRIGNAME") != string::npos ) {
189 Name strig =
"undefined";
191 Index itrn = itrig < ntrn ? itrig : ntrn - 1;
194 sman.
replace(
"%TRIGNAME%", strig);
195 if ( strig.size() ) strig[0] = std::toupper(strig[0]);
196 sman.
replace(
"%TRIGNAMECAP%", strig);
199 string spatpre =
"%UTCTIME";
200 ipos = sout.find(spatpre);
201 if ( ipos != string::npos ) {
202 time_t tim = acd.
time();
204 int remMax = 1000000000;
205 if (
std::abs(rem) >= remMax ) rem = 0;
211 TTimeStamp ts(tim, rem);
212 string stimpre = ts.AsString(
"s");
213 sman.
replace(spatpre +
"%", stimpre);
215 while ( srem.size() < 9 ) srem =
"0" + srem;
216 for (
Index ndig=0; ndig<10; ++ndig ) {
219 string stim = stimpre;
220 if ( ndig ) stim +=
"." + srem.substr(0, ndig);
224 if (
m_LogLevel >= 2 ) cout << myname << spat <<
" --> " << sout <<
endl;
int replace(std::string substr, const T &xsub)
bool haveInt(Name name) const
static constexpr double ps
Q_EXPORT QTSManip setw(int w)
int getInt(Name name, int def=0) const
static Index badChannel()
auto const & get(AssnsNode< L, R, D > const &r)
std::string to_string(ModuleType const mt)
QTextStream & endl(QTextStream &s)