commit
1158bb4222
@ -13,9 +13,6 @@
|
|||||||
// qtrocket headers
|
// qtrocket headers
|
||||||
#include "QtRocket.h"
|
#include "QtRocket.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
#include "sim/ConstantAtmosphere.h"
|
|
||||||
#include "sim/ConstantGravityModel.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize static member data
|
// Initialize static member data
|
||||||
QtRocket* QtRocket::instance = nullptr;
|
QtRocket* QtRocket::instance = nullptr;
|
||||||
|
@ -90,9 +90,8 @@ void MainWindow::on_testButton2_clicked()
|
|||||||
|
|
||||||
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
||||||
double initialVelocityZ = initialVelocity * std::sin(initialAngle / 57.2958);
|
double initialVelocityZ = initialVelocity * std::sin(initialAngle / 57.2958);
|
||||||
std::shared_ptr<Rocket> rocket = std::make_shared<Rocket>();
|
|
||||||
QtRocket::getInstance()->addRocket(rocket);
|
|
||||||
std::vector<double> initialState = {0.0, 0.0, 0.0, initialVelocityX, 0.0, initialVelocityZ, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
std::vector<double> initialState = {0.0, 0.0, 0.0, initialVelocityX, 0.0, initialVelocityZ, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||||
|
auto rocket = QtRocket::getInstance()->getRocket();
|
||||||
rocket->setInitialState(initialState);
|
rocket->setInitialState(initialState);
|
||||||
rocket->setMass(mass);
|
rocket->setMass(mass);
|
||||||
rocket->setDragCoefficient(dragCoeff);
|
rocket->setDragCoefficient(dragCoeff);
|
||||||
@ -111,14 +110,14 @@ void MainWindow::on_loadRSE_button_clicked()
|
|||||||
"/home",
|
"/home",
|
||||||
tr("Rocksim Engine Files (*.rse)"));
|
tr("Rocksim Engine Files (*.rse)"));
|
||||||
|
|
||||||
utils::RSEDatabaseLoader loader(rseFile.toStdString());
|
rseDatabase.reset(new utils::RSEDatabaseLoader(rseFile.toStdString()));
|
||||||
|
|
||||||
ui->rocketPartButtons->findChild<QLineEdit*>(QString("databaseFileLine"))->setText(rseFile);
|
ui->rocketPartButtons->findChild<QLineEdit*>(QString("databaseFileLine"))->setText(rseFile);
|
||||||
|
|
||||||
QComboBox* engineSelector =
|
QComboBox* engineSelector =
|
||||||
ui->rocketPartButtons->findChild<QComboBox*>(QString("engineSelectorComboBox"));
|
ui->rocketPartButtons->findChild<QComboBox*>(QString("engineSelectorComboBox"));
|
||||||
|
|
||||||
const std::vector<model::MotorModel>& motors = loader.getMotors();
|
const std::vector<model::MotorModel>& motors = rseDatabase->getMotors();
|
||||||
for(const auto& motor : motors)
|
for(const auto& motor : motors)
|
||||||
{
|
{
|
||||||
std::cout << "Adding: " << motor.data.commonName << std::endl;
|
std::cout << "Adding: " << motor.data.commonName << std::endl;
|
||||||
@ -146,3 +145,13 @@ void MainWindow::on_actionSimulation_Options_triggered()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_setMotor_clicked()
|
||||||
|
{
|
||||||
|
QString motorName = ui->engineSelectorComboBox->currentText();
|
||||||
|
model::MotorModel mm = rseDatabase->getMotorModelByName(motorName.toStdString());
|
||||||
|
QtRocket::getInstance()->getRocket()->setMotorModel(mm);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
/// \cond
|
/// \cond
|
||||||
// C headers
|
// C headers
|
||||||
// C++ headers
|
// C++ headers
|
||||||
|
#include <memory>
|
||||||
// 3rd Party headers
|
// 3rd Party headers
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
/// \endcond
|
/// \endcond
|
||||||
@ -12,6 +13,7 @@
|
|||||||
#include "QtRocket.h"
|
#include "QtRocket.h"
|
||||||
|
|
||||||
#include "gui/SimOptionsWindow.h"
|
#include "gui/SimOptionsWindow.h"
|
||||||
|
#include "utils/RSEDatabaseLoader.h"
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -47,10 +49,13 @@ private slots:
|
|||||||
|
|
||||||
void on_actionSimulation_Options_triggered();
|
void on_actionSimulation_Options_triggered();
|
||||||
|
|
||||||
|
void on_setMotor_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
QtRocket* qtRocket;
|
QtRocket* qtRocket;
|
||||||
|
|
||||||
SimOptionsWindow* simOptionsWindow{nullptr};
|
SimOptionsWindow* simOptionsWindow{nullptr};
|
||||||
|
std::unique_ptr<utils::RSEDatabaseLoader> rseDatabase;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -211,6 +211,13 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QComboBox" name="engineSelectorComboBox"/>
|
<widget class="QComboBox" name="engineSelectorComboBox"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="setMotor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Set Motor</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="getTCMotorData">
|
<widget class="QPushButton" name="getTCMotorData">
|
||||||
|
@ -1,14 +1,64 @@
|
|||||||
|
|
||||||
|
/// \cond
|
||||||
|
// C headers
|
||||||
|
// C++ headers
|
||||||
|
#include <memory>
|
||||||
|
// 3rd party headers
|
||||||
|
/// \endcond
|
||||||
|
|
||||||
|
// qtrocket headers
|
||||||
|
#include "QtRocket.h"
|
||||||
#include "SimOptionsWindow.h"
|
#include "SimOptionsWindow.h"
|
||||||
#include "ui_SimOptionsWindow.h"
|
#include "ui_SimOptionsWindow.h"
|
||||||
|
|
||||||
|
#include "sim/SimulationOptions.h"
|
||||||
|
|
||||||
SimOptionsWindow::SimOptionsWindow(QWidget *parent) :
|
SimOptionsWindow::SimOptionsWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::SimOptionsWindow)
|
ui(new Ui::SimOptionsWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// populate the combo boxes
|
||||||
|
|
||||||
|
std::shared_ptr<sim::SimulationOptions> options(new sim::SimulationOptions);
|
||||||
|
std::vector<std::string> atmosphereModels = options->getAvailableAtmosphereModels();
|
||||||
|
std::vector<std::string> gravityModels = options->getAvailableGravityModels();
|
||||||
|
|
||||||
|
for(const auto& i : atmosphereModels)
|
||||||
|
{
|
||||||
|
ui->atmosphereModelCombo->addItem(QString::fromStdString(i));
|
||||||
|
}
|
||||||
|
for(const auto& i : gravityModels)
|
||||||
|
{
|
||||||
|
ui->gravityModelCombo->addItem(QString::fromStdString(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimOptionsWindow::~SimOptionsWindow()
|
SimOptionsWindow::~SimOptionsWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimOptionsWindow::on_buttonBox_rejected()
|
||||||
|
{
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SimOptionsWindow::on_buttonBox_accepted()
|
||||||
|
{
|
||||||
|
QtRocket* qtrocket = QtRocket::getInstance();
|
||||||
|
|
||||||
|
std::shared_ptr<sim::SimulationOptions> options(new sim::SimulationOptions);
|
||||||
|
|
||||||
|
options->setTimeStep(ui->timeStep->text().toDouble());
|
||||||
|
options->setGravityModel(ui->gravityModelCombo->currentText().toStdString());
|
||||||
|
options->setAtmosphereModel(ui->atmosphereModelCombo->currentText().toStdString());
|
||||||
|
qtrocket->setSimulationOptions(options);
|
||||||
|
|
||||||
|
this->close();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,11 @@ public:
|
|||||||
explicit SimOptionsWindow(QWidget *parent = nullptr);
|
explicit SimOptionsWindow(QWidget *parent = nullptr);
|
||||||
~SimOptionsWindow();
|
~SimOptionsWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_buttonBox_rejected();
|
||||||
|
|
||||||
|
void on_buttonBox_accepted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SimOptionsWindow *ui;
|
Ui::SimOptionsWindow *ui;
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<x>60</x>
|
<x>60</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>261</width>
|
<width>261</width>
|
||||||
<height>131</height>
|
<height>156</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "model/MotorModel.h"
|
#include "model/MotorModel.h"
|
||||||
#include "utils/math/Constants.h"
|
#include "utils/math/Constants.h"
|
||||||
#include "utils/math/UtilityMathFunctions.h"
|
#include "utils/math/UtilityMathFunctions.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
namespace model
|
namespace model
|
||||||
{
|
{
|
||||||
@ -69,6 +70,22 @@ double MotorModel::getMass(double simTime) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double MotorModel::getThrust(double simTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(simTime > thrust.getMaxTime() + ignitionTime)
|
||||||
|
{
|
||||||
|
if(!burnOutOccurred)
|
||||||
|
{
|
||||||
|
utils::Logger::getInstance()->info("motor burnout occurred: " + std::to_string(simTime));
|
||||||
|
burnOutOccurred = true;
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
utils::Logger::getInstance()->info("simTime: " + std::to_string(simTime) + ": thrust: " + std::to_string(thrust.getThrust(simTime)));
|
||||||
|
return thrust.getThrust(simTime);
|
||||||
|
}
|
||||||
|
|
||||||
void MotorModel::setMetaData(const MetaData& md)
|
void MotorModel::setMetaData(const MetaData& md)
|
||||||
{
|
{
|
||||||
data = md;
|
data = md;
|
||||||
|
@ -396,11 +396,13 @@ public:
|
|||||||
|
|
||||||
void startMotor(double startTime) { ignitionOccurred = true; ignitionTime = startTime; }
|
void startMotor(double startTime) { ignitionOccurred = true; ignitionTime = startTime; }
|
||||||
|
|
||||||
|
void addThrustCurve(const ThrustCurve& tc) { thrust = tc; }
|
||||||
|
|
||||||
// Thrust parameters
|
// Thrust parameters
|
||||||
MetaData data;
|
MetaData data;
|
||||||
private:
|
private:
|
||||||
bool ignitionOccurred{false};
|
bool ignitionOccurred{false};
|
||||||
|
bool burnOutOccurred{false};
|
||||||
double emptyMass;
|
double emptyMass;
|
||||||
double isp;
|
double isp;
|
||||||
double maxTime;
|
double maxTime;
|
||||||
|
@ -9,6 +9,9 @@ Rocket::Rocket() : propagator(this)
|
|||||||
void Rocket::launch()
|
void Rocket::launch()
|
||||||
{
|
{
|
||||||
propagator.setTimeStep(QtRocket::getInstance()->getTimeStep());
|
propagator.setTimeStep(QtRocket::getInstance()->getTimeStep());
|
||||||
|
propagator.clearStates();
|
||||||
|
propagator.setCurrentTime(0.0);
|
||||||
|
mm.startMotor(0.0);
|
||||||
propagator.runUntilTerminate();
|
propagator.runUntilTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,10 +31,5 @@ bool Rocket::terminateCondition(const std::pair<double, std::vector<double>>& co
|
|||||||
|
|
||||||
double Rocket::getThrust(double t)
|
double Rocket::getThrust(double t)
|
||||||
{
|
{
|
||||||
return tc.getThrust(t);
|
return mm.getThrust(t);
|
||||||
}
|
|
||||||
|
|
||||||
void Rocket::setThrustCurve(const ThrustCurve& curve)
|
|
||||||
{
|
|
||||||
tc = curve;
|
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,6 @@ private:
|
|||||||
double mass; /// @todo get rid of this, should be dynamically computed, but is the current rocket mass
|
double mass; /// @todo get rid of this, should be dynamically computed, but is the current rocket mass
|
||||||
|
|
||||||
model::MotorModel mm; /// Current Motor Model
|
model::MotorModel mm; /// Current Motor Model
|
||||||
ThrustCurve tc; /// @todo get rid of this, should be returned from the MotorModel
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,12 +55,6 @@ void ThrustCurve::setIgnitionTime(double t)
|
|||||||
double ThrustCurve::getThrust(double t)
|
double ThrustCurve::getThrust(double t)
|
||||||
{
|
{
|
||||||
// calculate t relative to the start time of the motor
|
// calculate t relative to the start time of the motor
|
||||||
static bool burnout{false};
|
|
||||||
if(!burnout && t >= (maxTime + ignitionTime))
|
|
||||||
{
|
|
||||||
burnout = true;
|
|
||||||
utils::Logger::getInstance()->info("Motor burnout at time: " + std::to_string(t));
|
|
||||||
}
|
|
||||||
t -= ignitionTime;
|
t -= ignitionTime;
|
||||||
if(t < 0.0 || t > maxTime)
|
if(t < 0.0 || t > maxTime)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/// \cond
|
/// \cond
|
||||||
// C headers
|
// C headers
|
||||||
// C++ headers
|
// C++ headers
|
||||||
|
#include <cmath>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -97,20 +98,20 @@ double Propagator::getMass()
|
|||||||
double Propagator::getForceX()
|
double Propagator::getForceX()
|
||||||
{
|
{
|
||||||
QtRocket* qtrocket = QtRocket::getInstance();
|
QtRocket* qtrocket = QtRocket::getInstance();
|
||||||
return - qtrocket->getAtmosphereModel()->getDensity(currentState[3])/ 2.0 * 0.008107 * rocket->getDragCoefficient() * currentState[3]* currentState[3];
|
return (currentState[3] >= 0 ? -1.0 : 1.0) * qtrocket->getAtmosphereModel()->getDensity(currentState[2])/ 2.0 * 0.008107 * rocket->getDragCoefficient() * currentState[3]* currentState[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
double Propagator::getForceY()
|
double Propagator::getForceY()
|
||||||
{
|
{
|
||||||
QtRocket* qtrocket = QtRocket::getInstance();
|
QtRocket* qtrocket = QtRocket::getInstance();
|
||||||
return -qtrocket->getAtmosphereModel()->getDensity(currentState[3]) / 2.0 * 0.008107 * rocket->getDragCoefficient() * currentState[4]* currentState[4];
|
return (currentState[4] >= 0 ? -1.0 : 1.0) * qtrocket->getAtmosphereModel()->getDensity(currentState[2]) / 2.0 * 0.008107 * rocket->getDragCoefficient() * currentState[4]* currentState[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
double Propagator::getForceZ()
|
double Propagator::getForceZ()
|
||||||
{
|
{
|
||||||
QtRocket* qtrocket = QtRocket::getInstance();
|
QtRocket* qtrocket = QtRocket::getInstance();
|
||||||
double gravity = (qtrocket->getGravityModel()->getAccel(currentState[0], currentState[1], currentState[2])).x3;
|
double gravity = (qtrocket->getGravityModel()->getAccel(currentState[0], currentState[1], currentState[2])).x3;
|
||||||
double airDrag = -qtrocket->getAtmosphereModel()->getDensity(currentState[3]) / 2.0 * 0.008107 * rocket->getDragCoefficient() * currentState[5]* currentState[5];
|
double airDrag = (currentState[5] >= 0 ? -1.0 : 1.0) * qtrocket->getAtmosphereModel()->getDensity(currentState[2]) / 2.0 * 0.008107 * rocket->getDragCoefficient() * currentState[5]* currentState[5];
|
||||||
double thrust = rocket->getThrust(currentTime);
|
double thrust = rocket->getThrust(currentTime);
|
||||||
return gravity + airDrag + thrust;
|
return gravity + airDrag + thrust;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,9 @@ public:
|
|||||||
|
|
||||||
const std::vector<std::pair<double, std::vector<double>>>& getStates() const { return states; }
|
const std::vector<std::pair<double, std::vector<double>>>& getStates() const { return states; }
|
||||||
|
|
||||||
|
void clearStates() { states.clear(); }
|
||||||
|
void setCurrentTime(double t) { currentTime = t; }
|
||||||
|
|
||||||
void setTimeStep(double ts) { timeStep = ts; }
|
void setTimeStep(double ts) { timeStep = ts; }
|
||||||
|
|
||||||
void setSaveStats(bool s) { saveStates = s; }
|
void setSaveStats(bool s) { saveStates = s; }
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
/// \cond
|
/// \cond
|
||||||
// C headers
|
// C headers
|
||||||
// C++ headers
|
// C++ headers
|
||||||
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -42,6 +43,22 @@ public:
|
|||||||
SimulationOptions& operator=(const SimulationOptions&) = delete;
|
SimulationOptions& operator=(const SimulationOptions&) = delete;
|
||||||
SimulationOptions& operator=(SimulationOptions&&) = delete;
|
SimulationOptions& operator=(SimulationOptions&&) = delete;
|
||||||
|
|
||||||
|
std::vector<std::string> getAvailableGravityModels()
|
||||||
|
{
|
||||||
|
std::vector<std::string> retVal(gravityModels.size());
|
||||||
|
std::transform(gravityModels.begin(), gravityModels.end(), std::back_inserter(retVal),
|
||||||
|
[](auto& i) { return i.first; });
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> getAvailableAtmosphereModels()
|
||||||
|
{
|
||||||
|
std::vector<std::string> retVal(atmosphereModels.size());
|
||||||
|
std::transform(atmosphereModels.begin(), atmosphereModels.end(), std::back_inserter(retVal),
|
||||||
|
[](auto& i) { return i.first; });
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
void setTimeStep(double t) { timeStep = t; }
|
void setTimeStep(double t) { timeStep = t; }
|
||||||
void setGravityModel(const std::string& model)
|
void setGravityModel(const std::string& model)
|
||||||
{
|
{
|
||||||
@ -62,16 +79,20 @@ public:
|
|||||||
if(model == "Constant Atmosphere")
|
if(model == "Constant Atmosphere")
|
||||||
{
|
{
|
||||||
atmosphereModel = model;
|
atmosphereModel = model;
|
||||||
atmosphereModels[gravityModel].reset(new sim::ConstantAtmosphere);
|
atmosphereModels[atmosphereModel].reset(new sim::ConstantAtmosphere);
|
||||||
}
|
}
|
||||||
else if(model == "US Standard 1976")
|
else if(model == "US Standard 1976")
|
||||||
{
|
{
|
||||||
atmosphereModel = model;
|
atmosphereModel = model;
|
||||||
atmosphereModels[gravityModel].reset(new sim::USStandardAtmosphere);
|
atmosphereModels[atmosphereModel].reset(new sim::USStandardAtmosphere);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<sim::AtmosphericModel> getAtmosphericModel() { return atmosphereModels[atmosphereModel]; }
|
std::shared_ptr<sim::AtmosphericModel> getAtmosphericModel()
|
||||||
|
{
|
||||||
|
auto retVal = atmosphereModels[atmosphereModel];
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
std::shared_ptr<sim::GravityModel> getGravityModel() { return gravityModels[gravityModel]; }
|
std::shared_ptr<sim::GravityModel> getGravityModel() { return gravityModels[gravityModel]; }
|
||||||
double getTimeStep() { return timeStep; }
|
double getTimeStep() { return timeStep; }
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// C headers
|
// C headers
|
||||||
// C++ headers
|
// C++ headers
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// 3rd party headers
|
// 3rd party headers
|
||||||
@ -12,6 +13,7 @@
|
|||||||
// qtrocket headers
|
// qtrocket headers
|
||||||
#include "utils/RSEDatabaseLoader.h"
|
#include "utils/RSEDatabaseLoader.h"
|
||||||
#include "QtRocket.h"
|
#include "QtRocket.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
@ -33,6 +35,19 @@ RSEDatabaseLoader::RSEDatabaseLoader(const std::string& filename)
|
|||||||
RSEDatabaseLoader::~RSEDatabaseLoader()
|
RSEDatabaseLoader::~RSEDatabaseLoader()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
model::MotorModel RSEDatabaseLoader::getMotorModelByName(const std::string &name)
|
||||||
|
{
|
||||||
|
|
||||||
|
auto mm = std::find_if(motors.begin(), motors.end(),
|
||||||
|
[&name](const auto& i) { return name == i.data.commonName; });
|
||||||
|
if(mm == motors.end())
|
||||||
|
{
|
||||||
|
Logger::getInstance()->error("Unable to locate " + name + " in RSE database");
|
||||||
|
return model::MotorModel();
|
||||||
|
}
|
||||||
|
return *mm;
|
||||||
|
}
|
||||||
|
|
||||||
void RSEDatabaseLoader::buildAndAppendMotorModel(boost::property_tree::ptree& v)
|
void RSEDatabaseLoader::buildAndAppendMotorModel(boost::property_tree::ptree& v)
|
||||||
{
|
{
|
||||||
model::MotorModel::MetaData mm;
|
model::MotorModel::MetaData mm;
|
||||||
@ -70,7 +85,9 @@ void RSEDatabaseLoader::buildAndAppendMotorModel(boost::property_tree::ptree& v)
|
|||||||
thrustData.push_back(std::make_pair(tdata, fdata));
|
thrustData.push_back(std::make_pair(tdata, fdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThrustCurve tc(thrustData);
|
||||||
model::MotorModel motorModel;
|
model::MotorModel motorModel;
|
||||||
|
motorModel.addThrustCurve(tc);
|
||||||
motorModel.moveMetaData(std::move(mm));
|
motorModel.moveMetaData(std::move(mm));
|
||||||
motors.emplace_back(std::move(motorModel));
|
motors.emplace_back(std::move(motorModel));
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,9 @@ public:
|
|||||||
RSEDatabaseLoader(const std::string& filename);
|
RSEDatabaseLoader(const std::string& filename);
|
||||||
~RSEDatabaseLoader();
|
~RSEDatabaseLoader();
|
||||||
|
|
||||||
const std::vector<model::MotorModel>& getMotors() const { return motors; }
|
std::vector<model::MotorModel>& getMotors() { return motors; }
|
||||||
|
|
||||||
|
model::MotorModel getMotorModelByName(const std::string& name);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<model::MotorModel> motors;
|
std::vector<model::MotorModel> motors;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user