6 #include <pdbcalbase/PdbBankID.h>
7 #include <pdbcalbase/PdbBankManagerFactory.h>
8 #include <pdbcalbase/PdbCalBank.h>
9 #include <pdbcalbase/PdbClassMap.h>
10 #include <pdbcalbase/PHGenericFactoryT.h>
11 #include <pdbcalbase/RunToTime.h>
12 #include <pdbcalbase/PdbBankManager.h>
46 const bool registered =
54 return mySpecificCopy;
59 if (__instance)
return -1;
61 __instance = mySpecificCopy;
67 tMaxInsertTime.setToFarFuture();
90 if (beginRunTime != 0)
100 if (startTime >= endTime)
102 cout <<
PHWHERE <<
"Bad Start/EndRun Time: Start Time: "
103 << startTime <<
" >= End Time: "
107 return createBank(className, bankID, description, startTime, endTime, bankName);
112 cout <<
PHWHERE <<
"endTime = 0" << endl;
119 cout <<
PHWHERE <<
"beginTime = 0" << endl;
130 if (runBeginTime != 0)
145 return createBank(className, bankID, description, startTime, endTime, bankName);
153 string realName = getRealName(className);
154 const char *rName = realName.c_str();
156 if (classMap->
find(rName) != classMap->
end())
173 std::cerr <<
PHWHERE <<
"\t NO BANK " << rName
174 <<
" IN THE MAP" << std::endl;
185 if (runBeginTime != 0)
189 return fetchBank(className, bankID, bankName, searchTime);
200 if (runBeginTime != 0)
204 return fetchClosestBank(className, bankID, bankName, searchTime);
240 cout <<
"Fetching " << className <<
" from " << bankName << endl;
246 cout <<
PHWHERE <<
" PgPostApplication instance is nullptr, exiting" << endl;
253 cout <<
PHWHERE <<
" Cannot get TSQLConnection, exiting" << endl;
258 time_t sT = searchTime.
getTics();
259 std::ostringstream tem;
260 std::ostringstream
t2;
263 t2 <<
"select * from " << bankName
265 <<
" and startvaltime <= " << sT
266 <<
" and endvaltime > " << sT;
268 tem <<
"select * from ("
270 <<
") as foo where inserttime = "
271 <<
"(select max(inserttime) from ("
273 <<
" and inserttime <= "
274 << tMaxInsertTime.getTics()
276 <<
" order by rid desc";
279 cout <<
"exe : " << tem.str() << endl;
282 std::unique_ptr<TSQLResultSet> rs(stmt->
ExecuteQuery(tem.str().c_str()));
283 if ((rs) && rs->
Next())
297 int rid = rs->
GetInt(
"rid");
304 BankRid[bankName].insert(rid);
309 std::cerr <<
PHWHERE <<
"NO Bank found : " << tem.str() << std::endl;
318 cout <<
PHWHERE <<
" PdbBankManager::fetchClosestBank: This method is not implemented" << endl;
427 string realName = searchName;
428 string pdbsubstring =
"Pdb";
429 realName.replace(realName.find(pdbsubstring), realName.find(pdbsubstring) + pdbsubstring.size(),
"PgPost");
451 cout <<
"Setting latest inserttime for calibrations to " << tMax
452 <<
" (" << tMax.
getTics() <<
")" << endl;
453 tMaxInsertTime = tMax;