11 #include "StEmcDbHandler.h"
12 #include "TUnixTime.h"
13 #include "StMessMgr.h"
45 table = node ? node->addDbTable(
mTableName.c_str()) : 0;
51 table->setFlavor(
mFlavor.c_str());
56 UInt_t unixEntryTime = dbi->getUnixTime(
mMaxTime.c_str());
57 table->setProdTime(unixEntryTime);
59 dbMngr->fetchDbTable(table);
61 mTimeStamp = timeToSqlTime(table->getBeginDateTime());
78 dbMngr->setStoreTime(
mMaxTime.c_str());
79 unsigned int unixStoreTime = dbMngr->getUnixStoreTime();
82 char whereClause[256];
83 sprintf(whereClause,
" where flavor='%s' and beginTime>='%s' and beginTime<='%s' and entryTime<='%s' and (deactive=0 or deactive>=%d) order by beginTime",
85 LOG_INFO <<
"::getTimeStampList() using query = "<<whereClause<<endm;
87 UInt_t* timeStampList = db->QueryDbTimes(table,whereClause,1);
89 int nRows=table->GetNRows();
91 table->getElementID(nRows2);
92 if (nRows != nRows2) {
93 LOG_WARN<<
"problem: nRows!=nRows2"<<endm;
96 for (
int i = 0; i < nRows ; i++) {
97 dbMngr->setRequestTime(timeStampList[i]);
98 mTimeStampList.push_back( timeToSqlTime(dbMngr->getDateRequestTime()) );
100 delete [] timeStampList;
110 std::string StEmcDbHandler::timeToSqlTime(
const char* apiTime) {
111 TString
string=apiTime;
112 TString dateString=string(0,4)+
"-" +string(4,2)+
"-" + string(6,2);
113 TString timeString=string(8,2)+
":" +string(10,2)+
":" + string(12,2);
114 TString datetime = dateString+
" " +timeString;
116 return std::string(datetime.Data());
119 void StEmcDbHandler::writeToDb(
char*
data) {
125 table->setFlavor(
mFlavor.c_str());
128 dbMngr->storeDbTable(table);
std::string mMaxTime
EMC database max entry time.
std::string mFlavor
flavor for BEMC tables
std::string mTableName
EMC database table name, according to input.
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc'd version of data for StRoot
std::string mTimeStamp
EMC database table time stamp.
static StDbManager * Instance()
strdup(..) is not ANSI
std::string mTableNode
Database node for EMC tables.
std::vector< std::string > mTimeStampList
Time stamp list of specified EMC database table.
std::vector< std::string > getTimeStampList(const char *beginTime, const char *endTime)
virtual ~StEmcDbHandler()
Class dtor.