bool createConnection()
{
sVector3<double> pos(0.0,0.0,0.0);
sVector3<double> orient(0.0,0.0,0.0);
sVector3<double> vel(0.0,0.0,0.0);
double time(0.0),sltRngToGo(0.0),fuel(0.0),seekerEl(0.0),seekerAz(0.0);
...
//Set up MySQL template query for insertion
//Delete old table if it exists, if not no harm no foul
query.exec("drop table Missile2");
query.exec("create table Missile2 ( "
"Time double,"
"PositionX double, PositionY double, PositionZ double,"
"OrientationX double, OrientationY double, OrientationZ double,"
"VelocityX double, VelocityY double, VelocityZ double,"
"SltRngToGo double, Fuel double, SeekerAcq smallint, SeekerEl double,"
"SeekerAz double)"
"ENGINE = MyISAM ");
query.prepare("insert into missile2 (Time,PositionX, PositionY, PositionZ,"
"OrientationX, OrientationY, OrientationZ,"
"VelocityX, VelocityY, VelocityZ, SltRngToGo, Fuel, "
"SeekerAcq, SeekerEl, SeekerAz)"
"Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
for(int i=0; i <= 10000; ++i)
{
//made up values
time = i;
pos[0] = i+100;
pos[1] = i+10;
pos[2] = i;
orient[0] = i+50;
orient[1] = i+5;
orient[2] = i;
vel[0] += 25.123;
vel[1] += 2.456;
vel[2] += 0.7890123;
sltRngToGo = sltRngToGo+1.2345;
fuel = fuel+0.567;
seekerAcq = true;
seekerEl = 2.2;
seekerAz = 3.45;
query.addBindValue(time);
query.addBindValue(pos[0]);
query.addBindValue(pos[1]);
query.addBindValue(pos[2]);
query.addBindValue(orient[0]);
query.addBindValue(orient[1]);
query.addBindValue(orient[2]);
query.addBindValue(vel[0]);
query.addBindValue(vel[1]);
query.addBindValue(vel[2]);
query.addBindValue(sltRngToGo);
query.addBindValue(fuel);
query.addBindValue(seekerAcq);
query.addBindValue(seekerEl);
query.addBindValue(seekerAz);
query.exec();
}
return true;
}
bool createConnection()
{
sVector3<double> pos(0.0,0.0,0.0);
sVector3<double> orient(0.0,0.0,0.0);
sVector3<double> vel(0.0,0.0,0.0);
double time(0.0),sltRngToGo(0.0),fuel(0.0),seekerEl(0.0),seekerAz(0.0);
...
//Set up MySQL template query for insertion
QSqlQuery query;
//Delete old table if it exists, if not no harm no foul
query.exec("drop table Missile2");
query.exec("create table Missile2 ( "
"Time double,"
"PositionX double, PositionY double, PositionZ double,"
"OrientationX double, OrientationY double, OrientationZ double,"
"VelocityX double, VelocityY double, VelocityZ double,"
"SltRngToGo double, Fuel double, SeekerAcq smallint, SeekerEl double,"
"SeekerAz double)"
"ENGINE = MyISAM ");
query.prepare("insert into missile2 (Time,PositionX, PositionY, PositionZ,"
"OrientationX, OrientationY, OrientationZ,"
"VelocityX, VelocityY, VelocityZ, SltRngToGo, Fuel, "
"SeekerAcq, SeekerEl, SeekerAz)"
"Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
for(int i=0; i <= 10000; ++i)
{
//made up values
time = i;
pos[0] = i+100;
pos[1] = i+10;
pos[2] = i;
orient[0] = i+50;
orient[1] = i+5;
orient[2] = i;
vel[0] += 25.123;
vel[1] += 2.456;
vel[2] += 0.7890123;
sltRngToGo = sltRngToGo+1.2345;
fuel = fuel+0.567;
seekerAcq = true;
seekerEl = 2.2;
seekerAz = 3.45;
query.addBindValue(time);
query.addBindValue(pos[0]);
query.addBindValue(pos[1]);
query.addBindValue(pos[2]);
query.addBindValue(orient[0]);
query.addBindValue(orient[1]);
query.addBindValue(orient[2]);
query.addBindValue(vel[0]);
query.addBindValue(vel[1]);
query.addBindValue(vel[2]);
query.addBindValue(sltRngToGo);
query.addBindValue(fuel);
query.addBindValue(seekerAcq);
query.addBindValue(seekerEl);
query.addBindValue(seekerAz);
query.exec();
}
return true;
}
To copy to clipboard, switch view to plain text mode
Bookmarks