00001
00002
00003
00004
00005
00006
00007
00008 #include "CondTools/RPC/interface/RPCFw.h"
00009 #include "RelationalAccess/ISession.h"
00010 #include "RelationalAccess/ITransaction.h"
00011 #include "RelationalAccess/ISchema.h"
00012 #include "RelationalAccess/ITable.h"
00013 #include "RelationalAccess/ITableDataEditor.h"
00014 #include "RelationalAccess/TableDescription.h"
00015 #include "RelationalAccess/IQuery.h"
00016 #include "RelationalAccess/ICursor.h"
00017
00018 #include "CoralBase/AttributeList.h"
00019 #include "CoralBase/Attribute.h"
00020 #include "CoralBase/AttributeSpecification.h"
00021 #include <iostream>
00022 #include <stdexcept>
00023 #include <vector>
00024 #include <math.h>
00025 #include <iostream>
00026 #include <sstream>
00027 #include <time.h>
00028 #include "CondFormats/RPCObjects/interface/RPCObFebmap.h"
00029
00030 RPCFw::RPCFw( const std::string& connectionString,
00031 const std::string& userName,
00032 const std::string& password):
00033 RPCDBCom(),
00034 m_connectionString( connectionString ),
00035 m_userName( userName ),
00036 m_password( password )
00037 {}
00038
00039
00040 RPCFw::~RPCFw()
00041 {}
00042
00043 void
00044 RPCFw::run()
00045 {
00046 }
00047
00048
00049
00050 std::vector<RPCObImon::I_Item> RPCFw::createIMON(long long since, long long till)
00051 {
00052 tMIN = UTtoT(since);
00053 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
00054
00055 coral::ISession* session = this->connect( m_connectionString,
00056 m_userName, m_password );
00057 session->transaction().start( true );
00058 coral::ISchema& schema = session->nominalSchema();
00059 int nRows = 0;
00060 coral::IQuery* queryI = schema.newQuery();
00061 queryI->addToTableList( "FWCAENCHANNEL" );
00062 queryI->addToOutputList( "FWCAENCHANNEL.DPID", "DPID" );
00063 queryI->addToOutputList( "FWCAENCHANNEL.CHANGE_DATE", "TSTAMP" );
00064 queryI->addToOutputList( "FWCAENCHANNEL.ACTUAL_IMON", "IMON" );
00065
00066 RPCObImon::I_Item Itemp;
00067 std::vector<RPCObImon::I_Item> imonarray;
00068 coral::TimeStamp tlast = tMIN;
00069 if (till > since) {
00070 tMAX = UTtoT(till);
00071 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
00072 std::cout << ">> creating IMON object..." << std::endl;
00073 coral::AttributeList conditionData;
00074 conditionData.extend<coral::TimeStamp>( "tmin" );
00075 conditionData.extend<coral::TimeStamp>( "tmax" );
00076 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00077 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00078 std::string condition = "FWCAENCHANNEL.ACTUAL_IMON IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
00079 queryI->setCondition( condition , conditionData );
00080 coral::ICursor& cursorI = queryI->execute();
00081 while ( cursorI.next() ) {
00082 const coral::AttributeList& row = cursorI.currentRow();
00083 float idoub = row["DPID"].data<float>();
00084 int id = static_cast<int>(idoub);
00085 float val = row["IMON"].data<float>();
00086 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00087 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00088 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00089 Itemp.dpid = id;
00090 Itemp.value = val;
00091 Itemp.day = ndate;
00092 Itemp.time = ntime;
00093 imonarray.push_back(Itemp);
00094 ++nRows;
00095 }
00096 } else {
00097 std::cout << ">> creating IMON object..." << std::endl;
00098 coral::AttributeList conditionData;
00099 conditionData.extend<coral::TimeStamp>( "tmin" );
00100 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00101 std::string condition = "FWCAENCHANNEL.ACTUAL_IMON IS NOT NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin";
00102 queryI->setCondition( condition , conditionData );
00103 coral::ICursor& cursorI = queryI->execute();
00104 while ( cursorI.next() ) {
00105 const coral::AttributeList& row = cursorI.currentRow();
00106 float idoub = row["DPID"].data<float>();
00107 int id = static_cast<int>(idoub);
00108 float val = row["IMON"].data<float>();
00109 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00110 if (isMajor(ts, tlast)) tlast = ts;
00111 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00112 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00113 Itemp.dpid = id;
00114 Itemp.value = val;
00115 Itemp.day = ndate;
00116 Itemp.time = ntime;
00117 imonarray.push_back(Itemp);
00118 ++nRows;
00119 }
00120 }
00121 N_IOV = TtoUT(tlast);
00122 if (till > since) N_IOV = till;
00123 std::cout << ">> Imon array --> size: " << imonarray.size() << " >> done." << std::endl;
00124 delete queryI;
00125 session->transaction().commit();
00126 delete session;
00127 return imonarray;
00128 }
00129
00130
00131
00132
00133 std::vector<RPCObVmon::V_Item> RPCFw::createVMON(long long since, long long till)
00134 {
00135 tMIN = UTtoT(since);
00136 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
00137
00138 coral::ISession* session = this->connect( m_connectionString,
00139 m_userName, m_password );
00140 session->transaction().start( true );
00141 coral::ISchema& schema = session->nominalSchema();
00142 int nRows = 0;
00143 coral::IQuery* queryV = schema.newQuery();
00144 queryV->addToTableList( "FWCAENCHANNEL" );
00145 queryV->addToOutputList( "FWCAENCHANNEL.DPID", "DPID" );
00146 queryV->addToOutputList( "FWCAENCHANNEL.CHANGE_DATE", "TSTAMP" );
00147 queryV->addToOutputList( "FWCAENCHANNEL.ACTUAL_VMON", "VMON" );
00148 RPCObVmon::V_Item Vtemp;
00149 std::vector<RPCObVmon::V_Item> vmonarray;
00150 coral::TimeStamp tlast = tMIN;
00151 if (till > since) {
00152 tMAX = UTtoT(till);
00153 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
00154 std::cout << ">> creating VMON object..." << std::endl;
00155 coral::AttributeList conditionData;
00156 conditionData.extend<coral::TimeStamp>( "tmin" );
00157 conditionData.extend<coral::TimeStamp>( "tmax" );
00158 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00159 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00160 std::string condition = " NOT FWCAENCHANNEL.ACTUAL_VMON IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin AND FWCAENCHANNEL.CHANGE_DATE <:tmax";
00161 queryV->setCondition( condition , conditionData );
00162 coral::ICursor& cursorV = queryV->execute();
00163 while ( cursorV.next() ) {
00164 const coral::AttributeList& row = cursorV.currentRow();
00165 float idoub = row["DPID"].data<float>();
00166 int id = static_cast<int>(idoub);
00167 float val = row["VMON"].data<float>();
00168 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00169 if (isMajor(ts, tlast)) tlast = ts;
00170 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00171 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00172 Vtemp.dpid = id;
00173 Vtemp.value = val;
00174 Vtemp.day = ndate;
00175 Vtemp.time = ntime;
00176 vmonarray.push_back(Vtemp);
00177 ++nRows;
00178 }
00179 } else {
00180 std::cout << ">> creating VMON object..." << std::endl;
00181 coral::AttributeList conditionData;
00182 conditionData.extend<coral::TimeStamp>( "tmin" );
00183 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00184 std::string condition = " NOT FWCAENCHANNEL.ACTUAL_VMON IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin";
00185 queryV->setCondition( condition , conditionData );
00186 coral::ICursor& cursorV = queryV->execute();
00187 while ( cursorV.next() ) {
00188 const coral::AttributeList& row = cursorV.currentRow();
00189 float idoub = row["DPID"].data<float>();
00190 int id = static_cast<int>(idoub);
00191 float val = row["VMON"].data<float>();
00192 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00193 if (isMajor(ts, tlast)) tlast = ts;
00194 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00195 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00196 Vtemp.dpid = id;
00197 Vtemp.value = val;
00198 Vtemp.day = ndate;
00199 Vtemp.time = ntime;
00200 vmonarray.push_back(Vtemp);
00201 ++nRows;
00202 }
00203 }
00204
00205 std::cout << ">> Vmon array --> size: " << vmonarray.size() << " >> done." << std::endl;
00206 delete queryV;
00207 session->transaction().commit();
00208 delete session;
00209 return vmonarray;
00210 }
00211
00212
00213
00214 std::vector<RPCObStatus::S_Item> RPCFw::createSTATUS(long long since, long long till)
00215 {
00216 tMIN = UTtoT(since);
00217 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
00218
00219 coral::ISession* session = this->connect( m_connectionString,
00220 m_userName, m_password );
00221 session->transaction().start( true );
00222 coral::ISchema& schema = session->nominalSchema();
00223 int nRows = 0;
00224 std::cout << ">> creating STATUS object..." << std::endl;
00225 coral::IQuery* queryS = schema.newQuery();
00226 queryS->addToTableList( "FWCAENCHANNEL" );
00227 queryS->addToOutputList( "FWCAENCHANNEL.DPID", "DPID" );
00228 queryS->addToOutputList( "FWCAENCHANNEL.CHANGE_DATE", "TSTAMP" );
00229 queryS->addToOutputList( "FWCAENCHANNEL.ACTUAL_STATUS", "STATUS" );
00230 RPCObStatus::S_Item Stemp;
00231 std::vector<RPCObStatus::S_Item> statusarray;
00232 coral::TimeStamp tlast = tMIN;
00233 if (till > since) {
00234 tMAX = UTtoT(till);
00235 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
00236 std::cout << ">> creating STATUS object..." << std::endl;
00237 coral::AttributeList conditionData;
00238 conditionData.extend<coral::TimeStamp>( "tmin" );
00239 conditionData.extend<coral::TimeStamp>( "tmax" );
00240 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00241 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00242 std::string condition = " NOT FWCAENCHANNEL.ACTUAL_STATUS IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin AND FWCAENCHANNEL.CHANGE_DATE <:tmax";
00243 queryS->setCondition( condition , conditionData );
00244 coral::ICursor& cursorS = queryS->execute();
00245 while ( cursorS.next() ) {
00246 const coral::AttributeList& row = cursorS.currentRow();
00247 float idoub = row["DPID"].data<float>();
00248 int id = static_cast<int>(idoub);
00249 float val = row["STATUS"].data<float>();
00250 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00251 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00252 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00253 Stemp.dpid = id;
00254 Stemp.value = val;
00255 Stemp.day = ndate;
00256 Stemp.time = ntime;
00257 statusarray.push_back(Stemp);
00258 ++nRows;
00259 }
00260 }else {
00261 std::cout << ">> creating STATUS object..." << std::endl;
00262 coral::AttributeList conditionData;
00263 conditionData.extend<coral::TimeStamp>( "tmin" );
00264 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00265 std::string condition = " NOT FWCAENCHANNEL.ACTUAL_STATUS IS NULL AND FWCAENCHANNEL.CHANGE_DATE >:tmin";
00266 queryS->setCondition( condition , conditionData );
00267 coral::ICursor& cursorS = queryS->execute();
00268 while ( cursorS.next() ) {
00269 const coral::AttributeList& row = cursorS.currentRow();
00270 float idoub = row["DPID"].data<float>();
00271 int id = static_cast<int>(idoub);
00272 float val = row["STATUS"].data<float>();
00273 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00274 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00275 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00276 Stemp.dpid = id;
00277 Stemp.value = val;
00278 Stemp.day = ndate;
00279 Stemp.time = ntime;
00280 statusarray.push_back(Stemp);
00281 ++nRows;
00282 }
00283 }
00284 std::cout << ">> Staus array --> size: " << statusarray.size() << " >> done." << std::endl << std::endl << std::endl;
00285
00286 delete queryS;
00287 session->transaction().commit();
00288 delete session;
00289
00290 return statusarray;
00291
00292 }
00293
00294
00295
00296
00297 std::vector<RPCObGas::Item> RPCFw::createGAS(long long since, long long till)
00298 {
00299 tMIN = UTtoT(since);
00300 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
00301
00302 coral::ISession* session = this->connect( m_connectionString,
00303 m_userName, m_password );
00304 session->transaction().start( true );
00305 coral::ISchema& schema = session->nominalSchema();
00306
00307 coral::TimeStamp tlast = tMIN;
00308
00309
00310 coral::IQuery* querySIN = schema.newQuery();
00311 querySIN->addToTableList( "RPCGASCHANNEL" );
00312 querySIN->addToOutputList( "RPCGASCHANNEL.DPID", "DPID" );
00313 querySIN->addToOutputList( "RPCGASCHANNEL.CHANGE_DATE", "TSTAMP" );
00314 querySIN->addToOutputList( "RPCGASCHANNEL.FLOWIN", "FLOWIN" );
00315
00316
00317 coral::IQuery* querySOUT = schema.newQuery();
00318 querySOUT->addToTableList( "RPCGASCHANNEL" );
00319 querySOUT->addToOutputList( "RPCGASCHANNEL.DPID", "DPID" );
00320 querySOUT->addToOutputList( "RPCGASCHANNEL.CHANGE_DATE", "TSTAMP" );
00321 querySOUT->addToOutputList( "RPCGASCHANNEL.FLOWOUT", "FLOWOUT" );
00322
00323
00324 RPCObGas::Item gastemp;
00325 std::vector<RPCObGas::Item> gasarray;
00326
00327 if (till > since) {
00328 tMAX = UTtoT(till);
00329 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
00330 std::cout << ">> creating GAS object..." << std::endl;
00331 std::cout << ">> processing FLOWIN..." << std::endl;
00332 coral::AttributeList conditionData;
00333 conditionData.extend<coral::TimeStamp>( "tmin" );
00334 conditionData.extend<coral::TimeStamp>( "tmax" );
00335 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00336 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00337 std::string conditionIN = "RPCGASCHANNEL.FLOWIN IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
00338
00339 querySIN->setCondition( conditionIN, conditionData );
00340 coral::ICursor& cursorSIN = querySIN->execute();
00341 while ( cursorSIN.next() ) {
00342 gastemp.dpid=0;gastemp.flowin=0;gastemp.flowout=0;gastemp.day=0;gastemp.time=0;
00343 const coral::AttributeList& row = cursorSIN.currentRow();
00344 float idoub = row["DPID"].data<float>();
00345 int id = static_cast<int>(idoub);
00346 float val = row["FLOWIN"].data<float>();
00347 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00348 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00349 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00350 gastemp.dpid = id;
00351 gastemp.flowin = val;
00352 gastemp.day = ndate;
00353 gastemp.time = ntime;
00354 gasarray.push_back(gastemp);
00355 }
00356 } else {
00357 std::cout << ">> creating GAS object..." << std::endl;
00358 std::cout << ">> processing FLOWIN..." << std::endl;
00359 coral::AttributeList conditionData;
00360 conditionData.extend<coral::TimeStamp>( "tmin" );
00361 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00362 std::string conditionIN = "RPCGASCHANNEL.FLOWIN IS NOT NULL AND CHANGE_DATE >:tmin";
00363 std::cout << "processing FLOWIN..." << std::endl;
00364 querySIN->setCondition( conditionIN, conditionData );
00365 coral::ICursor& cursorSIN = querySIN->execute();
00366 while ( cursorSIN.next() ) {
00367 gastemp.dpid=0;gastemp.flowin=0;gastemp.flowout=0;gastemp.day=0;gastemp.time=0;
00368 const coral::AttributeList& row = cursorSIN.currentRow();
00369 float idoub = row["DPID"].data<float>();
00370 int id = static_cast<int>(idoub);
00371 float val = row["FLOWIN"].data<float>();
00372 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00373 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00374 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00375 gastemp.dpid = id;
00376 gastemp.flowin = val;
00377 gastemp.day = ndate;
00378 gastemp.time = ntime;
00379 gasarray.push_back(gastemp);
00380 }
00381 }
00382
00383
00384 if (till > since) {
00385 tMAX = UTtoT(till);
00386
00387 std::cout << ">> processing FLOWOUT..." << std::endl;
00388 coral::AttributeList conditionData;
00389 conditionData.extend<coral::TimeStamp>( "tmin" );
00390 conditionData.extend<coral::TimeStamp>( "tmax" );
00391 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00392 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00393 std::string conditionOUT = "RPCGASCHANNEL.FLOWOUT IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
00394
00395 querySOUT->setCondition( conditionOUT, conditionData );
00396 coral::ICursor& cursorSOUT = querySOUT->execute();
00397 while ( cursorSOUT.next() ) {
00398 gastemp.dpid=0;gastemp.flowin=0;gastemp.flowout=0;gastemp.day=0;gastemp.time=0;
00399 const coral::AttributeList& row = cursorSOUT.currentRow();
00400 float idoub = row["DPID"].data<float>();
00401 int id = static_cast<int>(idoub);
00402 float val = row["FLOWOUT"].data<float>();
00403 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00404 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00405 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00406 gastemp.dpid = id;
00407 gastemp.flowout = val;
00408 gastemp.day = ndate;
00409 gastemp.time = ntime;
00410 gasarray.push_back(gastemp);
00411 }
00412 } else {
00413 std::cout << ">> processing FLOWOUT..." << std::endl;
00414 coral::AttributeList conditionData;
00415 conditionData.extend<coral::TimeStamp>( "tmin" );
00416 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00417 std::string conditionOUT = "RPCGASCHANNEL.FLOWOUT IS NOT NULL AND CHANGE_DATE >:tmin";
00418 querySOUT->setCondition( conditionOUT, conditionData );
00419 coral::ICursor& cursorSOUT = querySOUT->execute();
00420 while ( cursorSOUT.next() ) {
00421 gastemp.dpid=0;gastemp.flowin=0;gastemp.flowout=0;gastemp.day=0;gastemp.time=0;
00422 const coral::AttributeList& row = cursorSOUT.currentRow();
00423 float idoub = row["DPID"].data<float>();
00424 int id = static_cast<int>(idoub);
00425 float val = row["FLOWOUT"].data<float>();
00426 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00427 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00428 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00429 gastemp.dpid = id;
00430 gastemp.flowout = val;
00431 gastemp.day = ndate;
00432 gastemp.time = ntime;
00433 gasarray.push_back(gastemp);
00434 }
00435 }
00436
00437
00438 N_IOV = TtoUT(tlast);
00439 if (till > since) N_IOV = till;
00440 std::cout << ">> Gas array --> size: " << gasarray.size() << " >> done." << std::endl << std::endl << std::endl;
00441
00442 delete querySIN;
00443 delete querySOUT;
00444 session->transaction().commit();
00445 delete session;
00446
00447 return gasarray;
00448
00449 }
00450
00451
00452
00453
00454 std::vector<RPCObTemp::T_Item> RPCFw::createT(long long since, long long till)
00455 {
00456 tMIN = UTtoT(since);
00457 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
00458
00459 coral::ISession* session = this->connect( m_connectionString,
00460 m_userName, m_password );
00461 session->transaction().start( true );
00462 coral::ISchema& schema = session->nominalSchema();
00463 int nRows = 0;
00464 coral::IQuery* queryS = schema.newQuery();
00465 queryS->addToTableList( "FWCAENCHANNELADC" );
00466 queryS->addToOutputList( "FWCAENCHANNELADC.DPID", "DPID" );
00467 queryS->addToOutputList( "FWCAENCHANNELADC.CHANGE_DATE", "TSTAMP" );
00468 queryS->addToOutputList( "FWCAENCHANNELADC.ACTUAL_TEMPERATURE", "TEMPERATURE" );
00469 RPCObTemp::T_Item Ttemp;
00470 std::vector<RPCObTemp::T_Item> temparray;
00471 coral::TimeStamp tlast = tMIN;
00472 if (till > since) {
00473 tMAX = UTtoT(till);
00474 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
00475 std::cout << ">> creating TEMPERATURE object..." << std::endl;
00476 coral::AttributeList conditionData;
00477 conditionData.extend<coral::TimeStamp>( "tmin" );
00478 conditionData.extend<coral::TimeStamp>( "tmax" );
00479 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00480 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00481 std::string condition = "FWCAENCHANNELADC.ACTUAL_TEMPERATURE IS NOT NULL AND CHANGE_DATE >:tmin AND CHANGE_DATE <:tmax";
00482 queryS->setCondition( condition , conditionData );
00483 coral::ICursor& cursorS = queryS->execute();
00484 while ( cursorS.next() ) {
00485 const coral::AttributeList& row = cursorS.currentRow();
00486 float idoub = row["DPID"].data<float>();
00487 int id = static_cast<int>(idoub);
00488 float val = row["TEMPERATURE"].data<float>();
00489 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00490 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00491 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00492
00493 Ttemp.dpid = id;
00494 Ttemp.value = val;
00495 Ttemp.day = ndate;
00496 Ttemp.time = ntime;
00497 temparray.push_back(Ttemp);
00498
00499 ++nRows;
00500 }
00501 } else {
00502 std::cout << ">> creating TEMPERATURE object..." << std::endl;
00503 coral::AttributeList conditionData;
00504 conditionData.extend<coral::TimeStamp>( "tmin" );
00505 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00506 std::string condition = "FWCAENCHANNELADC.ACTUAL_TEMPERATURE IS NOT NULL AND CHANGE_DATE >:tmin";
00507 queryS->setCondition( condition , conditionData );
00508 coral::ICursor& cursorS = queryS->execute();
00509 while ( cursorS.next() ) {
00510 const coral::AttributeList& row = cursorS.currentRow();
00511 float idoub = row["DPID"].data<float>();
00512 int id = static_cast<int>(idoub);
00513 float val = row["TEMPERATURE"].data<float>();
00514 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00515 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00516 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00517
00518 Ttemp.dpid = id;
00519 Ttemp.value = val;
00520 Ttemp.day = ndate;
00521 Ttemp.time = ntime;
00522 temparray.push_back(Ttemp);
00523
00524 ++nRows;
00525 }
00526 }
00527 N_IOV = TtoUT(tlast);
00528 if (till > since) N_IOV = till;
00529 std::cout << ">> Temperature array --> size: " << temparray.size() << " >> done." << std::endl << std::endl << std::endl;
00530
00531 delete queryS;
00532 session->transaction().commit();
00533 delete session;
00534
00535 return temparray;
00536
00537 }
00538
00539
00540
00541 std::vector<RPCObPVSSmap::Item> RPCFw::createIDMAP()
00542 {
00543
00544 std::cout <<">> Processing data..." << std::endl;
00545
00546 coral::ISession* session = this->connect( m_connectionString,
00547 m_userName, m_password );
00548 session->transaction().start( true );
00549 coral::ISchema& schema = session->nominalSchema();
00550 int nRows = 0;
00551 std::cout << ">> creating IDMAP object..." << std::endl;
00552 coral::IQuery* queryM = schema.newQuery();
00553 queryM->addToTableList( "RPCPVSSDETID");
00554 queryM->addToOutputList( "RPCPVSSDETID.SINCE", "SINCE" );
00555 queryM->addToOutputList( "RPCPVSSDETID.PVSS_ID", "PVSS_ID" );
00556 queryM->addToOutputList( "RPCPVSSDETID.REGION", "REGION" );
00557 queryM->addToOutputList( "RPCPVSSDETID.RING", "RING" );
00558 queryM->addToOutputList( "RPCPVSSDETID.STATION", "STATION" );
00559 queryM->addToOutputList( "RPCPVSSDETID.SECTOR", "SECTOR" );
00560 queryM->addToOutputList( "RPCPVSSDETID.LAYER", "LAYER" );
00561 queryM->addToOutputList( "RPCPVSSDETID.SUBSECTOR", "SUBSECTOR" );
00562 queryM->addToOutputList( "RPCPVSSDETID.SUPPLYTYPE", "SUPPLYTYPE" );
00563
00564 std::string condM = "RPCPVSSDETID.PVSS_ID is not NULL";
00565
00566
00567 coral::ICursor& cursorM = queryM->execute();
00568
00569 RPCObPVSSmap::Item Itemp;
00570 std::vector<RPCObPVSSmap::Item> idmaparray;
00571 while ( cursorM.next() ) {
00572 const coral::AttributeList& row = cursorM.currentRow();
00573 int id = row["PVSS_ID"].data<int>();
00574 std::string reg_s = row["REGION"].data<std::string>();
00575 std::string rin_s = row["RING"].data<std::string>();
00576 std::string sta_s = row["STATION"].data<std::string>();
00577 std::string sec_s = row["SECTOR"].data<std::string>();
00578 std::string lay_s = row["LAYER"].data<std::string>();
00579 std::string sub_s = row["SUBSECTOR"].data<std::string>();
00580 std::string sup_s = row["SUPPLYTYPE"].data<std::string>();
00581
00582 int reg = atoi(reg_s.c_str());
00583 int rin = atoi(rin_s.c_str());
00584 int sta = atoi(sta_s.c_str());
00585 int sec = atoi(sec_s.c_str());
00586 int lay = atoi(lay_s.c_str());
00587 int sub = atoi(sub_s.c_str());
00588 int sup = 5;
00589
00590 if (sup_s == "HV") sup = 0;
00591 if (sup_s == "LVA") sup = 1;
00592 if (sup_s == "LVD") sup = 2;
00593 if (sup_s == "LB") sup = 3;
00594 if (sup_s == "T") sup = 4;
00595
00596
00597 coral::TimeStamp ts = row["SINCE"].data<coral::TimeStamp>();
00598
00599 std::ostringstream dday;
00600 std::ostringstream dmon;
00601 std::ostringstream dyea;
00602 dday << ts.day();
00603 dmon << ts.month();
00604 dyea << ts.year();
00605 std::string date = dday.str() + "-" + dmon.str() + "-" + dyea.str();
00606
00607 Itemp.since = atoi(date.c_str());
00608 Itemp.dpid = id;
00609 Itemp.region = reg;
00610 Itemp.ring = rin;
00611 Itemp.station = sta;
00612 Itemp.sector = sec;
00613 Itemp.layer = lay;
00614 Itemp.subsector = sub;
00615 Itemp.suptype = sup;
00616
00617 idmaparray.push_back(Itemp);
00618
00619 ++nRows;
00620 }
00621
00622
00623 std::cout << ">> IDMAP array --> size: " << idmaparray.size() << " >> done." << std::endl;
00624 delete queryM;
00625 session->transaction().commit();
00626 delete session;
00627 return idmaparray;
00628 }
00629
00630
00631
00632
00633
00634 std::vector<RPCObFebmap::Feb_Item> RPCFw::createFEB(long long since, long long till)
00635 {
00636 tMIN = UTtoT(since);
00637 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
00638
00639 coral::ISession* session = this->connect( m_connectionString,
00640 m_userName, m_password );
00641 session->transaction().start( true );
00642 coral::ISchema& schema = session->nominalSchema();
00643 std::cout << ">> creating FEB object..." << std::endl;
00644
00645
00646 coral::IQuery* queryFVTH1 = schema.newQuery();
00647 queryFVTH1->addToTableList( "RPCFEB");
00648 queryFVTH1->addToOutputList( "RPCFEB.DPID", "DPID" );
00649 queryFVTH1->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00650 queryFVTH1->addToOutputList( "RPCFEB.VTH1", "VTH1" );
00651
00652
00653 coral::IQuery* queryFVTH2 = schema.newQuery();
00654 queryFVTH2->addToTableList( "RPCFEB");
00655 queryFVTH2->addToOutputList( "RPCFEB.DPID", "DPID" );
00656 queryFVTH2->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00657 queryFVTH2->addToOutputList( "RPCFEB.VTH2", "VTH2" );
00658
00659
00660 coral::IQuery* queryFVTH3 = schema.newQuery();
00661 queryFVTH3->addToTableList( "RPCFEB");
00662 queryFVTH3->addToOutputList( "RPCFEB.DPID", "DPID" );
00663 queryFVTH3->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00664 queryFVTH3->addToOutputList( "RPCFEB.VTH3", "VTH3" );
00665
00666
00667 coral::IQuery* queryFVTH4 = schema.newQuery();
00668 queryFVTH4->addToTableList( "RPCFEB");
00669 queryFVTH4->addToOutputList( "RPCFEB.DPID", "DPID" );
00670 queryFVTH4->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00671 queryFVTH4->addToOutputList( "RPCFEB.VTH4", "VTH4" );
00672
00673
00674 coral::IQuery* queryFVMON1 = schema.newQuery();
00675 queryFVMON1->addToTableList( "RPCFEB");
00676 queryFVMON1->addToOutputList( "RPCFEB.DPID", "DPID" );
00677 queryFVMON1->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00678 queryFVMON1->addToOutputList( "RPCFEB.VMON1", "VMON1" );
00679
00680
00681 coral::IQuery* queryFVMON2 = schema.newQuery();
00682 queryFVMON2->addToTableList( "RPCFEB");
00683 queryFVMON2->addToOutputList( "RPCFEB.DPID", "DPID" );
00684 queryFVMON2->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00685 queryFVMON2->addToOutputList( "RPCFEB.VMON2", "VMON2" );
00686
00687
00688 coral::IQuery* queryFVMON3 = schema.newQuery();
00689 queryFVMON3->addToTableList( "RPCFEB");
00690 queryFVMON3->addToOutputList( "RPCFEB.DPID", "DPID" );
00691 queryFVMON3->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00692 queryFVMON3->addToOutputList( "RPCFEB.VMON3", "VMON3" );
00693
00694
00695 coral::IQuery* queryFVMON4 = schema.newQuery();
00696 queryFVMON4->addToTableList( "RPCFEB");
00697 queryFVMON4->addToOutputList( "RPCFEB.DPID", "DPID" );
00698 queryFVMON4->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00699 queryFVMON4->addToOutputList( "RPCFEB.VMON4", "VMON4" );
00700
00701
00702 coral::IQuery* queryFTEMP1 = schema.newQuery();
00703 queryFTEMP1->addToTableList( "RPCFEB");
00704 queryFTEMP1->addToOutputList( "RPCFEB.DPID", "DPID" );
00705 queryFTEMP1->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00706 queryFTEMP1->addToOutputList( "RPCFEB.TEMPERATURE1", "TEMP1" );
00707
00708
00709 coral::IQuery* queryFTEMP2 = schema.newQuery();
00710 queryFTEMP2->addToTableList( "RPCFEB");
00711 queryFTEMP2->addToOutputList( "RPCFEB.DPID", "DPID" );
00712 queryFTEMP2->addToOutputList( "RPCFEB.CHANGE_DATE", "TSTAMP" );
00713 queryFTEMP2->addToOutputList( "RPCFEB.TEMPERATURE2", "TEMP2" );
00714
00715 RPCObFebmap::Feb_Item Itemp;
00716 std::vector<RPCObFebmap::Feb_Item> febarray;
00717 coral::TimeStamp tlast = tMIN;
00718 if (till > since) {
00719 tMAX = UTtoT(till);
00720 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
00721 std::cout << "Processing VTH1..." << std::endl;
00722 coral::AttributeList conditionData;
00723 conditionData.extend<coral::TimeStamp>( "tmin" );
00724 conditionData.extend<coral::TimeStamp>( "tmax" );
00725 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00726 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00727 std::string conditionVTH1 = "RPCFEB.VTH1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
00728 queryFVTH1->setCondition( conditionVTH1, conditionData );
00729 coral::ICursor& cursorFVTH1 = queryFVTH1->execute();
00730 while ( cursorFVTH1.next() ) {
00731 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00732 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00733 const coral::AttributeList& row = cursorFVTH1.currentRow();
00734 float idoub = row["DPID"].data<float>();
00735 int id = static_cast<int>(idoub);
00736 float vth1 = row["VTH1"].data<float>();
00737 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00738 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00739 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00740 Itemp.dpid = id;
00741 Itemp.thr1 = vth1;
00742 Itemp.day = ndate;
00743 Itemp.time = ntime;
00744 febarray.push_back(Itemp);
00745 }
00746 }else {
00747 std::cout << ">> Processing VTH1..." << std::endl;
00748 coral::AttributeList conditionData;
00749 conditionData.extend<coral::TimeStamp>( "tmin" );
00750 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00751 std::string conditionVTH1 = "RPCFEB.VTH1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
00752 queryFVTH1->setCondition( conditionVTH1, conditionData );
00753 coral::ICursor& cursorFVTH1 = queryFVTH1->execute();
00754 while ( cursorFVTH1.next() ) {
00755 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00756 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00757 const coral::AttributeList& row = cursorFVTH1.currentRow();
00758 float idoub = row["DPID"].data<float>();
00759 int id = static_cast<int>(idoub);
00760 float vth1 = row["VTH1"].data<float>();
00761 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00762 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00763 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00764 Itemp.dpid = id;
00765 Itemp.thr1 = vth1;
00766 Itemp.day = ndate;
00767 Itemp.time = ntime;
00768 febarray.push_back(Itemp);
00769 }
00770 }
00771
00772 if (till > since) {
00773 tMAX = UTtoT(till);
00774 std::cout << "Processing VTH2..." << std::endl;
00775 coral::AttributeList conditionData;
00776 conditionData.extend<coral::TimeStamp>( "tmin" );
00777 conditionData.extend<coral::TimeStamp>( "tmax" );
00778 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00779 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00780 std::string conditionVTH2 = "RPCFEB.VTH2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
00781 queryFVTH2->setCondition( conditionVTH2, conditionData );
00782 coral::ICursor& cursorFVTH2 = queryFVTH2->execute();
00783 while ( cursorFVTH2.next() ) {
00784 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00785 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00786 const coral::AttributeList& row = cursorFVTH2.currentRow();
00787 float idoub = row["DPID"].data<float>();
00788 int id = static_cast<int>(idoub);
00789 float vth2 = row["VTH2"].data<float>();
00790 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00791 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00792 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00793 Itemp.dpid = id;
00794 Itemp.thr2 = vth2;
00795 Itemp.day = ndate;
00796 Itemp.time = ntime;
00797 febarray.push_back(Itemp);
00798 }
00799 } else {
00800 std::cout << ">> Processing VTH2..." << std::endl;
00801 coral::AttributeList conditionData;
00802 conditionData.extend<coral::TimeStamp>( "tmin" );
00803 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00804 std::string conditionVTH2 = "RPCFEB.VTH2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
00805 queryFVTH2->setCondition( conditionVTH2, conditionData );
00806 coral::ICursor& cursorFVTH2 = queryFVTH2->execute();
00807 while ( cursorFVTH2.next() ) {
00808 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00809 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00810 const coral::AttributeList& row = cursorFVTH2.currentRow();
00811 float idoub = row["DPID"].data<float>();
00812 int id = static_cast<int>(idoub);
00813 float vth2 = row["VTH2"].data<float>();
00814 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00815 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00816 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00817 Itemp.dpid = id;
00818 Itemp.thr2 = vth2;
00819 Itemp.day = ndate;
00820 Itemp.time = ntime;
00821 febarray.push_back(Itemp);
00822 }
00823 }
00824
00825
00826 if (till > since) {
00827 tMAX = UTtoT(till);
00828 std::cout << "Processing VTH3..." << std::endl;
00829 coral::AttributeList conditionData;
00830 conditionData.extend<coral::TimeStamp>( "tmin" );
00831 conditionData.extend<coral::TimeStamp>( "tmax" );
00832 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00833 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00834 std::string conditionVTH3 = "RPCFEB.VTH3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
00835 queryFVTH3->setCondition( conditionVTH3, conditionData );
00836 coral::ICursor& cursorFVTH3 = queryFVTH3->execute();
00837 while ( cursorFVTH3.next() ) {
00838 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00839 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00840 const coral::AttributeList& row = cursorFVTH3.currentRow();
00841 float idoub = row["DPID"].data<float>();
00842 int id = static_cast<int>(idoub);
00843 float vth3 = row["VTH3"].data<float>();
00844 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00845 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00846 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00847 Itemp.dpid = id;
00848 Itemp.thr3 = vth3;
00849 Itemp.day = ndate;
00850 Itemp.time = ntime;
00851 febarray.push_back(Itemp);
00852 }
00853 } else {
00854 std::cout << ">> Processing VTH3..." << std::endl;
00855 coral::AttributeList conditionData;
00856 conditionData.extend<coral::TimeStamp>( "tmin" );
00857 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00858 std::string conditionVTH3 = "RPCFEB.VTH3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
00859 queryFVTH3->setCondition( conditionVTH3, conditionData );
00860 coral::ICursor& cursorFVTH3 = queryFVTH3->execute();
00861 while ( cursorFVTH3.next() ) {
00862 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00863 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00864 const coral::AttributeList& row = cursorFVTH3.currentRow();
00865 float idoub = row["DPID"].data<float>();
00866 int id = static_cast<int>(idoub);
00867 float vth3 = row["VTH3"].data<float>();
00868 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00869 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00870 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00871 Itemp.dpid = id;
00872 Itemp.thr3 = vth3;
00873 Itemp.day = ndate;
00874 Itemp.time = ntime;
00875 febarray.push_back(Itemp);
00876 }
00877 }
00878
00879
00880 if (till > since) {
00881 tMAX = UTtoT(till);
00882 std::cout << "Processing VTH4..." << std::endl;
00883 coral::AttributeList conditionData;
00884 conditionData.extend<coral::TimeStamp>( "tmin" );
00885 conditionData.extend<coral::TimeStamp>( "tmax" );
00886 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00887 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00888 std::string conditionVTH4 = "RPCFEB.VTH4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
00889 queryFVTH4->setCondition( conditionVTH4, conditionData );
00890 coral::ICursor& cursorFVTH4 = queryFVTH4->execute();
00891 while ( cursorFVTH4.next() ) {
00892 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00893 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00894 const coral::AttributeList& row = cursorFVTH4.currentRow();
00895 float idoub = row["DPID"].data<float>();
00896 int id = static_cast<int>(idoub);
00897 float vth4 = row["VTH4"].data<float>();
00898 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00899 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00900 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00901 Itemp.dpid = id;
00902 Itemp.thr4 = vth4;
00903 Itemp.day = ndate;
00904 Itemp.time = ntime;
00905 febarray.push_back(Itemp);
00906 }
00907 } else {
00908 std::cout << ">> Processing VTH4..." << std::endl;
00909 coral::AttributeList conditionData;
00910 conditionData.extend<coral::TimeStamp>( "tmin" );
00911 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00912 std::string conditionVTH4 = "RPCFEB.VTH4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
00913 queryFVTH4->setCondition( conditionVTH4, conditionData );
00914 coral::ICursor& cursorFVTH4 = queryFVTH4->execute();
00915 while ( cursorFVTH4.next() ) {
00916 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00917 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00918 const coral::AttributeList& row = cursorFVTH4.currentRow();
00919 float idoub = row["DPID"].data<float>();
00920 int id = static_cast<int>(idoub);
00921 float vth4 = row["VTH4"].data<float>();
00922 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00923 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00924 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00925 Itemp.dpid = id;
00926 Itemp.thr4 = vth4;
00927 Itemp.day = ndate;
00928 Itemp.time = ntime;
00929 febarray.push_back(Itemp);
00930 }
00931 }
00932
00933 if (till > since) {
00934 tMAX = UTtoT(till);
00935 std::cout << "Processing VMON1..." << std::endl;
00936 coral::AttributeList conditionData;
00937 conditionData.extend<coral::TimeStamp>( "tmin" );
00938 conditionData.extend<coral::TimeStamp>( "tmax" );
00939 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00940 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00941 std::string conditionVMON1 = "RPCFEB.VMON1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
00942 queryFVMON1->setCondition( conditionVMON1, conditionData );
00943 coral::ICursor& cursorFVMON1 = queryFVMON1->execute();
00944 while ( cursorFVMON1.next() ) {
00945 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00946 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00947 const coral::AttributeList& row = cursorFVMON1.currentRow();
00948 float idoub = row["DPID"].data<float>();
00949 int id = static_cast<int>(idoub);
00950 float vmon1 = row["VMON1"].data<float>();
00951 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00952 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00953 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00954 Itemp.dpid = id;
00955 Itemp.vmon1 = vmon1;
00956 Itemp.day = ndate;
00957 Itemp.time = ntime;
00958 febarray.push_back(Itemp);
00959 }
00960 } else {
00961 std::cout << ">> Processing VMON1..." << std::endl;
00962 coral::AttributeList conditionData;
00963 conditionData.extend<coral::TimeStamp>( "tmin" );
00964 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00965 std::string conditionVMON1 = "RPCFEB.VMON1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
00966 queryFVMON1->setCondition( conditionVMON1, conditionData );
00967 coral::ICursor& cursorFVMON1 = queryFVMON1->execute();
00968 while ( cursorFVMON1.next() ) {
00969 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
00970 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
00971 const coral::AttributeList& row = cursorFVMON1.currentRow();
00972 float idoub = row["DPID"].data<float>();
00973 int id = static_cast<int>(idoub);
00974 float vmon1 = row["VMON1"].data<float>();
00975 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
00976 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
00977 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
00978 Itemp.dpid = id;
00979 Itemp.vmon1 = vmon1;
00980 Itemp.day = ndate;
00981 Itemp.time = ntime;
00982 febarray.push_back(Itemp);
00983 }
00984 }
00985
00986
00987
00988 if (till > since) {
00989 tMAX = UTtoT(till);
00990 std::cout << "Processing VMON2..." << std::endl;
00991 coral::AttributeList conditionData;
00992 conditionData.extend<coral::TimeStamp>( "tmin" );
00993 conditionData.extend<coral::TimeStamp>( "tmax" );
00994 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
00995 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
00996 std::string conditionVMON2 = "RPCFEB.VMON2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
00997 queryFVMON2->setCondition( conditionVMON2, conditionData );
00998 coral::ICursor& cursorFVMON2 = queryFVMON2->execute();
00999 while ( cursorFVMON2.next() ) {
01000 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01001 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01002 const coral::AttributeList& row = cursorFVMON2.currentRow();
01003 float idoub = row["DPID"].data<float>();
01004 int id = static_cast<int>(idoub);
01005 float vmon2 = row["VMON2"].data<float>();
01006 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01007 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01008 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01009 Itemp.dpid = id;
01010 Itemp.vmon2 = vmon2;
01011 Itemp.day = ndate;
01012 Itemp.time = ntime;
01013 febarray.push_back(Itemp);
01014 }
01015 } else {
01016 std::cout << ">> Processing VMON2..." << std::endl;
01017 coral::AttributeList conditionData;
01018 conditionData.extend<coral::TimeStamp>( "tmin" );
01019 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01020 std::string conditionVMON2 = "RPCFEB.VMON2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
01021 queryFVMON2->setCondition( conditionVMON2, conditionData );
01022 coral::ICursor& cursorFVMON2 = queryFVMON2->execute();
01023 while ( cursorFVMON2.next() ) {
01024 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01025 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01026 const coral::AttributeList& row = cursorFVMON2.currentRow();
01027 float idoub = row["DPID"].data<float>();
01028 int id = static_cast<int>(idoub);
01029 float vmon2 = row["VMON2"].data<float>();
01030 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01031 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01032 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01033 Itemp.dpid = id;
01034 Itemp.vmon2 = vmon2;
01035 Itemp.day = ndate;
01036 Itemp.time = ntime;
01037 febarray.push_back(Itemp);
01038 }
01039 }
01040
01041
01042 if (till > since) {
01043 tMAX = UTtoT(till);
01044 std::cout << "Processing VMON3..." << std::endl;
01045 coral::AttributeList conditionData;
01046 conditionData.extend<coral::TimeStamp>( "tmin" );
01047 conditionData.extend<coral::TimeStamp>( "tmax" );
01048 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01049 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
01050 std::string conditionVMON3 = "RPCFEB.VMON3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
01051 queryFVMON3->setCondition( conditionVMON3, conditionData );
01052 coral::ICursor& cursorFVMON3 = queryFVMON3->execute();
01053 while ( cursorFVMON3.next() ) {
01054 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01055 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01056 const coral::AttributeList& row = cursorFVMON3.currentRow();
01057 float idoub = row["DPID"].data<float>();
01058 int id = static_cast<int>(idoub);
01059 float vmon3 = row["VMON3"].data<float>();
01060 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01061 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01062 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01063 Itemp.dpid = id;
01064 Itemp.vmon3 = vmon3;
01065 Itemp.day = ndate;
01066 Itemp.time = ntime;
01067 febarray.push_back(Itemp);
01068 }
01069 } else {
01070 std::cout << ">> Processing VMON3..." << std::endl;
01071 coral::AttributeList conditionData;
01072 conditionData.extend<coral::TimeStamp>( "tmin" );
01073 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01074 std::string conditionVMON3 = "RPCFEB.VMON3 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
01075 queryFVMON3->setCondition( conditionVMON3, conditionData );
01076 coral::ICursor& cursorFVMON3 = queryFVMON3->execute();
01077 while ( cursorFVMON3.next() ) {
01078 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01079 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01080 const coral::AttributeList& row = cursorFVMON3.currentRow();
01081 float idoub = row["DPID"].data<float>();
01082 int id = static_cast<int>(idoub);
01083 float vmon3 = row["VMON3"].data<float>();
01084 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01085 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01086 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01087 Itemp.dpid = id;
01088 Itemp.vmon3 = vmon3;
01089 Itemp.day = ndate;
01090 Itemp.time = ntime;
01091 febarray.push_back(Itemp);
01092 }
01093 }
01094
01095
01096 if (till > since) {
01097 tMAX = UTtoT(till);
01098 std::cout << "Processing VMON4..." << std::endl;
01099 coral::AttributeList conditionData;
01100 conditionData.extend<coral::TimeStamp>( "tmin" );
01101 conditionData.extend<coral::TimeStamp>( "tmax" );
01102 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01103 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
01104 std::string conditionVMON4 = "RPCFEB.VMON4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
01105 queryFVMON4->setCondition( conditionVMON4, conditionData );
01106 coral::ICursor& cursorFVMON4 = queryFVMON4->execute();
01107 while ( cursorFVMON4.next() ) {
01108 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01109 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01110 const coral::AttributeList& row = cursorFVMON4.currentRow();
01111 float idoub = row["DPID"].data<float>();
01112 int id = static_cast<int>(idoub);
01113 float vmon4 = row["VMON4"].data<float>();
01114 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01115 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01116 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01117 Itemp.dpid = id;
01118 Itemp.vmon4 = vmon4;
01119 Itemp.day = ndate;
01120 Itemp.time = ntime;
01121 febarray.push_back(Itemp);
01122 }
01123 } else {
01124 std::cout << ">> Processing VMON4..." << std::endl;
01125 coral::AttributeList conditionData;
01126 conditionData.extend<coral::TimeStamp>( "tmin" );
01127 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01128 std::string conditionVMON4 = "RPCFEB.VMON4 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
01129 queryFVMON4->setCondition( conditionVMON4, conditionData );
01130 coral::ICursor& cursorFVMON4 = queryFVMON4->execute();
01131 while ( cursorFVMON4.next() ) {
01132 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01133 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01134 const coral::AttributeList& row = cursorFVMON4.currentRow();
01135 float idoub = row["DPID"].data<float>();
01136 int id = static_cast<int>(idoub);
01137 float vmon4 = row["VMON4"].data<float>();
01138 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01139 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01140 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01141 Itemp.dpid = id;
01142 Itemp.vmon4 = vmon4;
01143 Itemp.day = ndate;
01144 Itemp.time = ntime;
01145 febarray.push_back(Itemp);
01146 }
01147 }
01148
01149
01150 if (till > since) {
01151 tMAX = UTtoT(till);
01152 std::cout << "Processing TEMP1..." << std::endl;
01153 coral::AttributeList conditionData;
01154 conditionData.extend<coral::TimeStamp>( "tmin" );
01155 conditionData.extend<coral::TimeStamp>( "tmax" );
01156 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01157 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
01158 std::string conditionTEMP1 = "RPCFEB.TEMPERATURE1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
01159 queryFTEMP1->setCondition( conditionTEMP1, conditionData );
01160 coral::ICursor& cursorFTEMP1 = queryFTEMP1->execute();
01161 while ( cursorFTEMP1.next() ) {
01162 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01163 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01164 const coral::AttributeList& row = cursorFTEMP1.currentRow();
01165 float idoub = row["DPID"].data<float>();
01166 int id = static_cast<int>(idoub);
01167 float temp1 = row["TEMP1"].data<float>();
01168 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01169 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01170 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01171 Itemp.dpid = id;
01172 Itemp.temp1 = temp1;
01173 Itemp.day = ndate;
01174 Itemp.time = ntime;
01175 febarray.push_back(Itemp);
01176 }
01177 } else {
01178 std::cout << ">> Processing TEMP1..." << std::endl;
01179 coral::AttributeList conditionData;
01180 conditionData.extend<coral::TimeStamp>( "tmin" );
01181 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01182 std::string conditionTEMP1 = "RPCFEB.TEMPERATURE1 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
01183 queryFTEMP1->setCondition( conditionTEMP1, conditionData );
01184 coral::ICursor& cursorFTEMP1 = queryFTEMP1->execute();
01185 while ( cursorFTEMP1.next() ) {
01186 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01187 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01188 const coral::AttributeList& row = cursorFTEMP1.currentRow();
01189 float idoub = row["DPID"].data<float>();
01190 int id = static_cast<int>(idoub);
01191 float temp1 = row["TEMP1"].data<float>();
01192 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01193 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01194 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01195 Itemp.dpid = id;
01196 Itemp.temp1 = temp1;
01197 Itemp.day = ndate;
01198 Itemp.time = ntime;
01199 febarray.push_back(Itemp);
01200 }
01201 }
01202
01203
01204 if (till > since) {
01205 tMAX = UTtoT(till);
01206 std::cout << "Processing TEMP2..." << std::endl;
01207 coral::AttributeList conditionData;
01208 conditionData.extend<coral::TimeStamp>( "tmin" );
01209 conditionData.extend<coral::TimeStamp>( "tmax" );
01210 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01211 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
01212 std::string conditionTEMP2 = "RPCFEB.TEMPERATURE2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin AND RPCFEB.CHANGE_DATE <:tmax";
01213 queryFTEMP2->setCondition( conditionTEMP2, conditionData );
01214 coral::ICursor& cursorFTEMP2 = queryFTEMP2->execute();
01215 while ( cursorFTEMP2.next() ) {
01216 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01217 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01218 const coral::AttributeList& row = cursorFTEMP2.currentRow();
01219 float idoub = row["DPID"].data<float>();
01220 int id = static_cast<int>(idoub);
01221 float temp2 = row["TEMP2"].data<float>();
01222 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01223 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01224 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01225 Itemp.dpid = id;
01226 Itemp.temp2 = temp2;
01227 Itemp.day = ndate;
01228 Itemp.time = ntime;
01229 febarray.push_back(Itemp);
01230 }
01231 } else {
01232 std::cout << ">> Processing TEMP2..." << std::endl;
01233 coral::AttributeList conditionData;
01234 conditionData.extend<coral::TimeStamp>( "tmin" );
01235 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01236 std::string conditionTEMP2 = "RPCFEB.TEMPERATURE2 IS NOT NULL AND RPCFEB.CHANGE_DATE >:tmin";
01237 queryFTEMP2->setCondition( conditionTEMP2, conditionData );
01238 coral::ICursor& cursorFTEMP2 = queryFTEMP2->execute();
01239 while ( cursorFTEMP2.next() ) {
01240 Itemp.thr1=0;Itemp.thr2=0;Itemp.thr3=0;Itemp.thr4=0;Itemp.vmon1=0;Itemp.vmon2=0;Itemp.vmon3=0;
01241 Itemp.vmon4=0;Itemp.temp1=0;Itemp.temp2=0;Itemp.noise1=0;Itemp.noise2=0;Itemp.noise3=0;Itemp.noise4=0;
01242 const coral::AttributeList& row = cursorFTEMP2.currentRow();
01243 float idoub = row["DPID"].data<float>();
01244 int id = static_cast<int>(idoub);
01245 float temp2 = row["TEMP2"].data<float>();
01246 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01247 int ndate = (ts.day() * 10000) + (ts.month() * 100) + (ts.year()-2000);
01248 int ntime = (ts.hour() * 10000) + (ts.minute() * 100) + ts.second();
01249 Itemp.dpid = id;
01250 Itemp.temp2 = temp2;
01251 Itemp.day = ndate;
01252 Itemp.time = ntime;
01253 febarray.push_back(Itemp);
01254 }
01255 }
01256
01257 std::cout << ">> FEB array --> size: " << febarray.size() << " >> done." << std::endl;
01258 delete queryFVTH1;
01259 delete queryFVTH2;
01260 delete queryFVTH3;
01261 delete queryFVTH4;
01262 delete queryFTEMP1;
01263 session->transaction().commit();
01264 delete session;
01265 return febarray;
01266 }
01267
01268
01269
01270
01271 std::vector<RPCObUXC::Item> RPCFw::createUXC(long long since, long long till)
01272 {
01273 tMIN = UTtoT(since);
01274 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
01275
01276 coral::ISession* session = this->connect( m_connectionString,
01277 m_userName, m_password );
01278 session->transaction().start( true );
01279 coral::ISchema& schema = session->nominalSchema();
01280 std::cout << ">> creating UXC object..." << std::endl;
01281
01282
01283 coral::IQuery* queryUXCP = schema.newQuery();
01284 queryUXCP->addToTableList( "RPCGASPARAMETERS");
01285 queryUXCP->addToTableList( "DP_NAME2ID" );
01286 queryUXCP->addToOutputList( "DP_NAME2ID.DPNAME", "DPNAME" );
01287 queryUXCP->addToOutputList("DP_NAME2ID.ID","ID");
01288 queryUXCP->addToOutputList( "RPCGASPARAMETERS.DPID", "DPID" );
01289 queryUXCP->addToOutputList( "RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP" );
01290 queryUXCP->addToOutputList( "RPCGASPARAMETERS.VALUE", "VALUE" );
01291 coral::IQuery* queryUXCT = schema.newQuery();
01292 queryUXCT->addToTableList( "RPCCOOLING");
01293 queryUXCT->addToTableList( "DP_NAME2ID" );
01294 queryUXCT->addToOutputList( "DP_NAME2ID.DPNAME", "DPNAME" );
01295 queryUXCT->addToOutputList("DP_NAME2ID.ID","ID");
01296 queryUXCT->addToOutputList( "RPCCOOLING.DPID", "DPID" );
01297 queryUXCT->addToOutputList( "RPCCOOLING.CHANGE_DATE", "TSTAMP" );
01298 queryUXCT->addToOutputList( "RPCCOOLING.VALUE", "VALUE" );
01299 coral::IQuery* queryUXCH = schema.newQuery();
01300 queryUXCH->addToTableList( "RPCCOOLING");
01301 queryUXCH->addToTableList( "DP_NAME2ID" );
01302 queryUXCH->addToOutputList( "DP_NAME2ID.DPNAME", "DPNAME" );
01303 queryUXCH->addToOutputList("DP_NAME2ID.ID","ID");
01304 queryUXCH->addToOutputList( "RPCCOOLING.DPID", "DPID" );
01305 queryUXCH->addToOutputList( "RPCCOOLING.CHANGE_DATE", "TSTAMP" );
01306 queryUXCH->addToOutputList( "RPCCOOLING.VALUE", "VALUE" );
01307
01308
01309 RPCObUXC::Item Itemp;
01310 std::vector<RPCObUXC::Item> uxcarray;
01311 coral::TimeStamp tlast = tMIN;
01312 if (till > since) {
01313 tMAX = UTtoT(till);
01314 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
01315 std::cout << "Processing UXC..." << std::endl;
01316 coral::AttributeList conditionData;
01317 conditionData.extend<coral::TimeStamp>( "tmin" );
01318 conditionData.extend<coral::TimeStamp>( "tmax" );
01319 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01320 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
01321 std::string conditionUXCP = "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%UXCPressure%')";
01322 queryUXCP->setCondition( conditionUXCP, conditionData );
01323 coral::ICursor& cursorUXCP = queryUXCP->execute();
01324 while ( cursorUXCP.next() ) {
01325 Itemp.temperature=0;Itemp.pressure=0;Itemp.dewpoint=0;
01326 const coral::AttributeList& row = cursorUXCP.currentRow();
01327 float value = row["VALUE"].data<float>();
01328 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01329 unsigned long long ut_time = TtoUT(ts);
01330 Itemp.pressure = value;
01331 Itemp.unixtime = ut_time;
01332 uxcarray.push_back(Itemp);
01333 }
01334 std::string conditionUXCT = "RPCCOOLING.DPID = DP_NAME2ID.ID AND RPCCOOLING.CHANGE_DATE >:tmin AND RPCCOOLING.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%TempUXC%')";
01335 queryUXCT->setCondition( conditionUXCT, conditionData );
01336 coral::ICursor& cursorUXCT = queryUXCT->execute();
01337 while ( cursorUXCT.next() ) {
01338 Itemp.temperature=0;Itemp.pressure=0;Itemp.dewpoint=0;
01339 const coral::AttributeList& row = cursorUXCT.currentRow();
01340 float value = row["VALUE"].data<float>();
01341 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01342 unsigned long long ut_time = TtoUT(ts);
01343 Itemp.temperature = value;
01344 Itemp.unixtime = ut_time;
01345 uxcarray.push_back(Itemp);
01346 }
01347 std::string conditionUXCH = "RPCCOOLING.DPID = DP_NAME2ID.ID AND RPCCOOLING.CHANGE_DATE >:tmin AND RPCCOOLING.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%DewpointUXC%')";
01348 queryUXCH->setCondition( conditionUXCH, conditionData );
01349 coral::ICursor& cursorUXCH = queryUXCH->execute();
01350 while ( cursorUXCH.next() ) {
01351 Itemp.temperature=0;Itemp.pressure=0;Itemp.dewpoint=0;
01352 const coral::AttributeList& row = cursorUXCH.currentRow();
01353 float value = row["VALUE"].data<float>();
01354 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01355 unsigned long long ut_time = TtoUT(ts);
01356 Itemp.dewpoint = value;
01357 Itemp.unixtime = ut_time;
01358 uxcarray.push_back(Itemp);
01359 }
01360 }else {
01361
01362 std::cout << "This objects cannot be copied in this mode. Use RANGE mode!" << std::endl;
01363
01364 }
01365
01366
01367 std::cout << ">> UXC array --> size: " << uxcarray.size() << " >> done." << std::endl;
01368 delete queryUXCT;
01369 delete queryUXCP;
01370 delete queryUXCH;
01371 session->transaction().commit();
01372 delete session;
01373 return uxcarray;
01374
01375 }
01376
01377
01378
01379
01380 std::vector<RPCObGasMix::Item> RPCFw::createMix(long long since, long long till)
01381 {
01382 tMIN = UTtoT(since);
01383 std::cout <<">> Processing since: "<<tMIN.day()<<"/"<<tMIN.month()<<"/"<<tMIN.year()<<" "<<tMIN.hour()<<":"<<tMIN.minute()<<"."<<tMIN.second()<< std::endl;
01384
01385 coral::ISession* session = this->connect( m_connectionString,
01386 m_userName, m_password );
01387 session->transaction().start( true );
01388 coral::ISchema& schema = session->nominalSchema();
01389 std::cout << ">> creating UXC object..." << std::endl;
01390
01391 coral::IQuery* queryMix = schema.newQuery();
01392 queryMix->addToTableList( "RPCGASPARAMETERS");
01393 queryMix->addToTableList( "DP_NAME2ID" );
01394 queryMix->addToOutputList( "DP_NAME2ID.DPNAME", "DPNAME" );
01395 queryMix->addToOutputList("DP_NAME2ID.ID","ID");
01396 queryMix->addToOutputList( "RPCGASPARAMETERS.DPID", "DPID" );
01397 queryMix->addToOutputList( "RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP" );
01398 queryMix->addToOutputList( "RPCGASPARAMETERS.VALUE", "VALUE" );
01399
01400 coral::IQuery* queryMix2 = schema.newQuery();
01401 queryMix2->addToTableList( "RPCGASPARAMETERS");
01402 queryMix2->addToTableList( "DP_NAME2ID" );
01403 queryMix2->addToOutputList( "DP_NAME2ID.DPNAME", "DPNAME" );
01404 queryMix2->addToOutputList("DP_NAME2ID.ID","ID");
01405 queryMix2->addToOutputList( "RPCGASPARAMETERS.DPID", "DPID" );
01406 queryMix2->addToOutputList( "RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP" );
01407 queryMix2->addToOutputList( "RPCGASPARAMETERS.VALUE", "VALUE" );
01408
01409 coral::IQuery* queryMix3 = schema.newQuery();
01410 queryMix3->addToTableList( "RPCGASPARAMETERS");
01411 queryMix3->addToTableList( "DP_NAME2ID" );
01412 queryMix3->addToOutputList( "DP_NAME2ID.DPNAME", "DPNAME" );
01413 queryMix3->addToOutputList("DP_NAME2ID.ID","ID");
01414 queryMix3->addToOutputList( "RPCGASPARAMETERS.DPID", "DPID" );
01415 queryMix3->addToOutputList( "RPCGASPARAMETERS.CHANGE_DATE", "TSTAMP" );
01416 queryMix3->addToOutputList( "RPCGASPARAMETERS.VALUE", "VALUE" );
01417
01418 RPCObGasMix::Item Mtemp;
01419 std::vector<RPCObGasMix::Item> marray;
01420 coral::TimeStamp tlast = tMIN;
01421 if (till > since) {
01422 tMAX = UTtoT(till);
01423 std::cout <<">> Processing till: "<<tMAX.day()<<"/"<<tMAX.month()<<"/"<<tMAX.year()<<" "<<tMAX.hour()<<":"<<tMAX.minute()<<"."<<tMAX.second()<< std::endl;
01424 std::cout << "Processing UXC..." << std::endl;
01425 coral::AttributeList conditionData;
01426 conditionData.extend<coral::TimeStamp>( "tmin" );
01427 conditionData.extend<coral::TimeStamp>( "tmax" );
01428 conditionData["tmin"].data<coral::TimeStamp>() = tMIN;
01429 conditionData["tmax"].data<coral::TimeStamp>() = tMAX;
01430 std::string conditionM1 = "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%IC4H10Ratio%')";
01431 queryMix->setCondition( conditionM1, conditionData );
01432 coral::ICursor& cursorMix = queryMix->execute();
01433 while ( cursorMix.next() ) {
01434 Mtemp.gas1=0;Mtemp.gas2=0;Mtemp.gas3=0;
01435 const coral::AttributeList& row = cursorMix.currentRow();
01436 float value = row["VALUE"].data<float>();
01437 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01438 unsigned long long ut_time = TtoUT(ts);
01439 Mtemp.gas1 = value;
01440 Mtemp.unixtime = ut_time;
01441 marray.push_back(Mtemp);
01442 }
01443 std::string conditionM2 = "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%C2H2F4Ratio%')";
01444 queryMix2->setCondition( conditionM2, conditionData );
01445 coral::ICursor& cursorMix2 = queryMix2->execute();
01446 while ( cursorMix2.next() ) {
01447 Mtemp.gas1=0;Mtemp.gas2=0;Mtemp.gas3=0;
01448 const coral::AttributeList& row = cursorMix2.currentRow();
01449 float value = row["VALUE"].data<float>();
01450 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01451 unsigned long long ut_time = TtoUT(ts);
01452 Mtemp.gas2 = value;
01453 Mtemp.unixtime = ut_time;
01454 marray.push_back(Mtemp);
01455 }
01456 std::string conditionM3 = "RPCGASPARAMETERS.DPID = DP_NAME2ID.ID AND RPCGASPARAMETERS.CHANGE_DATE >:tmin AND RPCGASPARAMETERS.CHANGE_DATE <:tmax AND (DP_NAME2ID.DPNAME like '%SF6Ratio%')";
01457 queryMix3->setCondition( conditionM3, conditionData );
01458 coral::ICursor& cursorMix3 = queryMix3->execute();
01459 while ( cursorMix3.next() ) {
01460 Mtemp.gas1=0;Mtemp.gas2=0;Mtemp.gas3=0;
01461 const coral::AttributeList& row = cursorMix3.currentRow();
01462 float value = row["VALUE"].data<float>();
01463 coral::TimeStamp ts = row["TSTAMP"].data<coral::TimeStamp>();
01464 unsigned long long ut_time = TtoUT(ts);
01465 Mtemp.gas3 = value;
01466 Mtemp.unixtime = ut_time;
01467 marray.push_back(Mtemp);
01468 }
01469 } else {
01470
01471 std::cout << "This objects cannot be copied in this mode. Use RANGE mode!" << std::endl;
01472
01473 }
01474
01475
01476 std::cout << ">> GasMix array --> size: " << marray.size() << " >> done." << std::endl;
01477 delete queryMix;
01478 session->transaction().commit();
01479 delete session;
01480 return marray;
01481
01482 }
01483
01484
01485
01486
01487 coral::TimeStamp RPCFw::UTtoT(long long utime)
01488 {
01489
01490
01491 int yea = static_cast<int>(trunc(utime/31536000) + 1970);
01492 int yes = (yea-1970)*31536000;
01493 int cony = ((yea-1972)%4)+1;
01494 if (cony == 0) yes = yes + (yea-1972)/4*86400;
01495 else yes = yes + static_cast<int>(trunc((yea-1972)/4))*86400;
01496 int day = static_cast<int>(trunc((utime - yes)/86400));
01497 int rest = static_cast<int>(utime - yes - day*86400);
01498 int mon = 0;
01499
01500 if (cony == 0) {
01501 day = day + 1;
01502 if (day < 32){
01503 mon = 1;
01504 day = day - 0;
01505 }
01506 if (day >= 32 && day < 61){
01507 mon = 2;
01508 day = day - 31;
01509 }
01510 if (day >= 61 && day < 92){
01511 mon = 3;
01512 day = day - 60;
01513 }
01514 if (day >= 92 && day < 122){
01515 mon = 4;
01516 day = day - 91;
01517 }
01518 if (day >= 122 && day < 153){
01519 mon = 5;
01520 day = day - 121;
01521 }
01522 if (day >= 153 && day < 183){
01523 mon = 6;
01524 day = day - 152;
01525 }
01526 if (day >= 183 && day < 214){
01527 mon = 7;
01528 day = day - 182;
01529 }
01530 if (day >= 214 && day < 245){
01531 mon = 8;
01532 day = day - 213;
01533 }
01534 if (day >= 245 && day < 275){
01535 mon = 9;
01536 day = day - 244;
01537 }
01538 if (day >= 275 && day < 306){
01539 mon = 10;
01540 day = day - 274;
01541 }
01542 if (day >= 306 && day < 336){
01543 mon = 11;
01544 day = day - 305;
01545 }
01546 if (day >= 336){
01547 mon = 12;
01548 day = day - 335;
01549 }
01550 }
01551
01552 else {
01553 if (day < 32){
01554 mon = 1;
01555 day = day - 0;
01556 }
01557 if (day >= 32 && day < 60){
01558 mon = 2;
01559 day = day - 31;
01560 }
01561 if (day >= 60 && day < 91){
01562 mon = 3;
01563 day = day - 59;
01564 }
01565 if (day >= 91 && day < 121){
01566 mon = 4;
01567 day = day - 90;
01568 }
01569 if (day >= 121 && day < 152){
01570 mon = 5;
01571 day = day - 120;
01572 }
01573 if (day >= 152 && day < 182){
01574 mon = 6;
01575 day = day - 151;
01576 }
01577 if (day >= 182 && day < 213){
01578 mon = 7;
01579 day = day - 181;
01580 }
01581 if (day >= 213 && day < 244){
01582 mon = 8;
01583 day = day - 212;
01584 }
01585 if (day >= 244 && day < 274){
01586 mon = 9;
01587 day = day - 243;
01588 }
01589 if (day >= 274 && day < 305){
01590 mon = 10;
01591 day = day - 273;
01592 }
01593 if (day >= 305 && day < 335){
01594 mon = 11;
01595 day = day - 304;
01596 }
01597 if (day >= 335){
01598 mon = 12;
01599 day = day - 334;
01600 }
01601 }
01602
01603 int hou = static_cast<int>(trunc(rest/3600));
01604 rest = rest - hou*3600;
01605 int min = static_cast<int>(trunc(rest/60));
01606 rest = rest - min*60;
01607 int sec = rest;
01608 int nan = 0;
01609
01610
01611
01612 coral::TimeStamp Tthr;
01613
01614 Tthr = coral::TimeStamp(yea, mon, day, hou, min, sec, nan);
01615 return Tthr;
01616 }
01617
01618
01619
01620
01621 unsigned long long RPCFw::TtoUT(coral::TimeStamp time)
01622 {
01623
01624 long long utime = (time.year()-1970)*31536000+static_cast<int>(trunc((time.year()-1972)/4))*86400+
01625 (((time.month()-1)*31)*86400)+((time.day()-1)*86400)+time.hour()*3600+time.minute()*60+time.second();
01626
01627 if (time.month() == 3) utime = utime - 3*86400;
01628 if (time.month() == 4) utime = utime - 3*86400;
01629 if (time.month() == 5) utime = utime - 4*86400;
01630 if (time.month() == 6) utime = utime - 4*86400;
01631 if (time.month() == 7) utime = utime - 5*86400;
01632 if (time.month() == 8) utime = utime - 5*86400;
01633 if (time.month() == 9) utime = utime - 5*86400;
01634 if (time.month() == 10) utime = utime - 6*86400;
01635 if (time.month() == 11) utime = utime - 6*86400;
01636 if (time.month() == 12) utime = utime - 7*86400;
01637
01638 return utime;
01639 }
01640
01641
01642
01643 bool RPCFw::isMajor(coral::TimeStamp fir, coral::TimeStamp sec)
01644 {
01645
01646 double first = fir.year()*1e10+fir.month()+1e8+fir.day()*1e6+fir.hour()*1e4+fir.minute()*1e2+fir.second();
01647 double second = sec.year()*1e10+sec.month()+1e8+sec.day()*1e6+sec.hour()*1e4+sec.minute()*1e2+sec.second();
01648
01649 if (first > second) return true;
01650
01651 return false;
01652 }