void CHistData::queryDBase()
{
dbase->setDatabaseName( "HMIDATABASE" );
dbase->setUserName( "" );
dbase->setPassword( "");
dbase->setHostName( "");
if( !dbase->open() )
{
dbase->lastError().showMessage( "An error occured. Please read the README file in the sqltable"
"dir for more information.\n\n" );
printf("Unable to open DB");
}
else
printf(" opened DB");
QString strFromTime
=qplot
->fromTimeStr;
QString strToTime
=qplot
->toTimeStr;
int plotScreenXPixelCounter = 0;
QString strFromDateTime
=qplot
->fromDateStr;
QString strToDateTime
=qplot
->toDateStr;
strFromDateTime.append(" ");
strToDateTime.append(" ");
// Store from & to - datetime specified by user in QString
strFromDateTime.append(strFromTime);
strToDateTime.append(strToTime);
// Store from & to datetime specified by user in string datatype of sql
QString fromDateTime
= strFromDateTime;
QString toDateTime
= strToDateTime;
// //cout<<"FROM DateTime before query: "<<fromDateTime<<endl;
// //cout<<"TO DateTime before query: "<<toDateTime<<endl;
//qplot->databaseEnabled = FALSE;
// create QString object to store FGU-FSM ID selected by user
//fguFsmID ="";
fguFsmID.append(qplot->options.FGUSel);
fguFsmID.append(qplot->options.FSMSel);
// //cout<<" FGUId check"<<fguFsmID<<endl;
// cName.append(' ');
cName.append(fguFsmID);
// Query to retrieve records for given From and To date
cName.append("A");
QString retrieveA
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime ";
//////////////////////////////////////////////
// qApp->processEvents();
printf("before resA.exec()\n");
resA=retrieveA;
resA.exec();
printf("after resA.exec()\n");
// //cout<<"querySize: checking resA"<<resA.size()<<endl;
////////////////////////////
// Query to retrieve records when given From Date does not have a record+
QString prevA
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime desc limit 1";
//qApp->processEvents();
resPrevQueryA=prevA;
resPrevQueryA.exec();
// //cout<<"querySize: checking resPrevQueryA"<<resPrevQueryA.size()<<endl;
cName.truncate(5);
cName.append("B");
// //cout<<"----------------------------"<<cName<<endl;
// Query to retrieve records for given From and To date
QString retrieveB
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime";
//qApp->processEvents();
resB=retrieveB;
resB.exec();
// //cout<<"querySize: checking resB"<<resB.size()<<endl;
// Query to retrieve records when given From Date does not have a record+
QString prevB
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime desc limit 1";
//qApp->processEvents();
resPrevQueryB=prevB;
resPrevQueryB.exec();
//cout<<"querySize: checking resPrevQueryB"<<resPrevQueryB.size()<<endl;
cName.truncate(5);
cName.append("C");
// Query to retrieve records for given From and To date
QString retrieveC
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime";
//qApp->processEvents();
resC=retrieveC;
resC.exec();
//cout<<"querySize: checking resC"<<resC.size()<<endl;
// Query to retrieve records when given From Date does not have a record+
QString prevC
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime desc limit 1";
//qApp->processEvents();
resPrevQueryC=prevC;
resPrevQueryC.exec();
//cout<<"querySize: checking resPrevQueryC"<<resPrevQueryC.size()<<endl;
cName.truncate(5);
cName.append("D");
// Query to retrieve records for given From and To date
QString retrieveD
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime ";
//qApp->processEvents();
resD=retrieveD;
resD.exec();
//cout<<"querySize: checking resD"<<resD.size()<<endl;
// Query to retrieve records when given From Date does not have a record+
QString prevD
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime desc limit 1";
//qApp->processEvents();
resPrevQueryD=prevD;
resPrevQueryD.exec();
//cout<<"querySize: checking resPrevQueryD"<<resPrevQueryD.size()<<endl;
cName.truncate(5);
cName.append("E");
// Query to retrieve records for given From and To date
QString retrieveE
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime ";
//qApp->processEvents();
resE=retrieveE;
resE.exec();
//cout<<"querySize: checking resE"<<resE.size()<<endl;
// Query to retrieve records when given From Date does not have a record+
QString prevE
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime desc limit 1";
//cout<<fguFsmID<<endl;
//qApp->processEvents();
resPrevQueryE=prevE;
resPrevQueryE.exec();
//cout<<"querySize: checking resPrevQueryE"<<resPrevQueryE.size()<<endl;
cName.truncate(5);
cName.append("F");
// Query to retrieve records for given From and To date
QString retrieveF
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime ";
// qApp->processEvents();
resF=retrieveF;
resF.exec();
//cout<<"querySize : checking resF"<<resF.size()<<endl;
// Query to retrieve records when given From Date does not have a record+
QString prevF
= "select * from FreqTab where ChName = '"+cName
+"' and ChDateTime between '"+fromDateTime
+"' and '"+toDateTime
+"' order by ChDateTime desc limit 1";
// qApp->processEvents();
resPrevQueryF=prevF;
resPrevQueryF.exec();
//cout<<"querySize: checking "<<resPrevQueryF.size()<<endl;
dbase->close();
}
Bookmarks