adding doxygen comments

This commit is contained in:
Travis Hunter 2023-04-22 16:29:08 -06:00
parent ed5ecc766c
commit 32c9cda4b8
14 changed files with 250 additions and 116 deletions

View File

@ -12,14 +12,9 @@ AnalysisWindow::AnalysisWindow(QWidget *parent) :
this->hide();
this->show();
std::shared_ptr<Rocket> rocket = QtRocket::getInstance()->getRocket();
const std::vector<std::pair<double, std::vector<double>>>& res = rocket->getStates();
/*
for(const auto& i : res)
{
std::cout << i.first << ": " << "(" << i.second[0] << ", " << i.second[1] << ", " << i.second[2] << ")\n";
}
*/
auto& plot = ui->plotWidget;
plot->setInteraction(QCP::iRangeDrag, true);
plot->setInteraction(QCP::iRangeZoom, true);

View File

@ -18,14 +18,21 @@ class AnalysisWindow;
/**
* @brief The AnalysisWindow class.
*
* The Analysis Windows class shows a plot of data. This allows visual inspection of
* data
* The Analysis Window class shows a plot of rocket state data. This allows visual inspection of
* flight data such as altitude vs. time.
*/
class AnalysisWindow : public QDialog
{
Q_OBJECT
public:
/**
* @brief AnalysisWindow constructor.
* @param parent Parent widget
*
* @note The constructor will make a call to QtRocket and grab the current Rocket model
* and automatically plot altitude vs time
*/
explicit AnalysisWindow(QWidget *parent = nullptr);
~AnalysisWindow();

View File

@ -32,6 +32,7 @@ public:
~MainWindow();
private slots:
void on_actionAbout_triggered();
void on_testButton1_clicked();

View File

@ -1,15 +1,6 @@
#ifndef MODEL_MOTORCASE_H
#define MODEL_MOTORCASE_H
enum class MotorManufacturerEnum
{
AEROTECH,
CESARONI,
LOKI,
AMW,
ESTES
};
class MotorCase
{
public:
@ -20,4 +11,4 @@ private:
};
#endif // MODEL_MOTORCASE_H
#endif // MODEL_MOTORCASE_H

View File

@ -9,9 +9,3 @@ MotorModel::~MotorModel()
{
}
void MotorModel::setDataFromJsonString(const std::string& jsonString)
{
}

View File

@ -8,45 +8,98 @@
// 3rd party headers
// For boost serialization. We're using boost::serialize to save
// and load Motor data to file
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
// and load Motor data to file. (CURRENTLY UNUSED)
//#include <boost/archive/text_iarchive.hpp>
//#include <boost/archive/text_oarchive.hpp>
/// \endcond
// qtrocke theaders
#include "Thrustcurve.h"
// qtrocket theaders
#include "ThrustCurve.h"
/**
* @brief The MotorModel class
*
* The MotorModel class defines a structure that holds data relating to a hobby
* rocket motor such as the manufacturer, burn time, maximum thrust, propellant
* weight, etc. It also holds a ThrustCurve object that contains thrust sample data
* for that motor.
*
* There are several additional classes defined within the MotorModel class designed
* to encapsulate and define several pieces of motor related data as well.
*/
class MotorModel
{
public:
/**
* @brief MotorModel constructor
*/
MotorModel();
/**
* @brief MotorModel copy constructor is defaulted
*/
MotorModel(const MotorModel&) = default;
/**
* @brief MotorModel move constructor is defaulted
*/
MotorModel(MotorModel&&) = default;
~MotorModel();
/**
* @brief Copy assignment operator is defaulted
* @return Copy of MotorModel
*/
MotorModel& operator=(const MotorModel&) = default;
/**
* @brief Move assignment operator is defaulted
* @return Moved MotorModel
*/
MotorModel& operator=(MotorModel&&) = default;
void setDataFromJsonString(const std::string& jsonString);
/**
* @brief The AVAILABILITY enum class identifies whether a motor is
* out of production, or still available
*/
enum class AVAILABILITY
{
REGULAR, // available
OOP // Out of Production
REGULAR, /// available
OOP /// Out of Production
};
/**
* @brief The MOTORMANUFACTURER enum class identifies the motor
* manufacturer
*/
enum class MOTORMANUFACTURER
{
AEROTECH,
CESARONI,
LOKI,
AMW,
ESTES,
APOGEE,
UNKNOWN
};
/**
* @brief The CERTORG enum class identifies the Certification Organization
* that certified the motor
*/
enum class CERTORG
{
AMRS,
CAR,
NAR,
TRA,
UNC,
UNK
AMRS, /// Australian Model Rocket Society
CAR, /// Canadian Association of Rocketry
NAR, /// National Association of Rocketry
TRA, /// Tripoli
UNC, /// Uncertified
UNK /// Unknown Certification
};
/**
* @brief The MOTORTYPE enum class identifies the motor type, either
* Single-Use, Reload, or Hybrid
*/
enum class MOTORTYPE
{
SU,
@ -54,6 +107,11 @@ public:
HYBRID
};
/**
* @brief The MotorAvailability struct wraps the AVAILABILITY enum and
* provides a helper function to return a string representation
* of the AVAILABILITY enum.
*/
struct MotorAvailability
{
MotorAvailability(const AVAILABILITY& a) : availability(a) {}
@ -65,6 +123,10 @@ public:
MotorAvailability& operator=(MotorAvailability&&) = default;
AVAILABILITY availability{AVAILABILITY::REGULAR};
/**
* @brief str Returns a string representation of AVAILABILITY enum
* @return string representation
*/
std::string str()
{
if(availability == AVAILABILITY::REGULAR)
@ -74,6 +136,11 @@ public:
}
};
/**
* @brief The CertOrg struct wraps the CERTORG enum and
* provides a helper function to return a string representation
* of the CERTORG enum.
*/
struct CertOrg
{
CertOrg(const CERTORG& c) : org(c) {}
@ -85,6 +152,10 @@ public:
CertOrg& operator=(CertOrg&&) = default;
CERTORG org{CERTORG::UNC};
/**
* @brief str Returns a string representation of CERTORG enum
* @return string representation
*/
std::string str()
{
if(org == CERTORG::AMRS)
@ -102,6 +173,11 @@ public:
}
};
/**
* @brief The MotorType struct wraps the MOTORTYPE enum and
* provides a helper function to return a string representation
* of the MOTORTYPE enum.
*/
struct MotorType
{
MotorType(const MOTORTYPE& t) : type(t) {}
@ -113,6 +189,10 @@ public:
MotorType& operator=(MotorType&&) = default;
MOTORTYPE type;
/**
* @brief str Returns a string representation of MOTORTYPE enum
* @return string representation
*/
std::string str()
{
if(type == MOTORTYPE::SU)
@ -124,60 +204,79 @@ public:
}
};
// TODO: make these private. Public just for testing
/**
* @brief The MotorManufacturer struct wraps the MOTORMANUFACTURER enum and
* provides a helper function to return a string representation
* of the MOTORMANUFACTURER enum.
*/
struct MotorManufacturer
{
MotorManufacturer(const MOTORMANUFACTURER& m) : manufacturer(m) {}
MotorManufacturer() : manufacturer(MOTORMANUFACTURER::UNKNOWN) {}
MotorManufacturer(const MotorManufacturer&) = default;
MotorManufacturer(MotorManufacturer&&) = default;
MotorManufacturer& operator=(const MotorManufacturer&) = default;
MotorManufacturer& operator=(MotorManufacturer&&) = default;
MOTORMANUFACTURER manufacturer;
/**
* @brief str Returns a string representation of MOTORMANUFACTURER enum
* @return string representation
*/
std::string str()
{
switch(manufacturer)
{
case MOTORMANUFACTURER::AEROTECH:
return std::string("AeroTech");
case MOTORMANUFACTURER::AMW:
return std::string("AMW");
case MOTORMANUFACTURER::CESARONI:
return std::string("Cesaroni");
case MOTORMANUFACTURER::ESTES:
return std::string("Estes");
case MOTORMANUFACTURER::LOKI:
return std::string("Loki");
case MOTORMANUFACTURER::APOGEE:
return std::string("Apogee");
case MOTORMANUFACTURER::UNKNOWN:
default:
return std::string("Unknown");
}
}
};
/// TODO: make these MotorModel members private. Public just for testing
//private:
// Needed for boost serialize
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version);
MotorAvailability availability{AVAILABILITY::REGULAR};
double avgThrust{0.0};
double burnTime{0.0};
CertOrg certOrg{CERTORG::UNC};
std::string commonName{""};
MotorAvailability availability{AVAILABILITY::REGULAR}; /// Motor Availability
double avgThrust{0.0}; /// Average thrust in Newtons
double burnTime{0.0}; /// Burn time in seconds
CertOrg certOrg{CERTORG::UNC}; /// The certification organization, defaults to Uncertified
std::string commonName{""}; /// Common name, e.g. A8 or J615
// int dataFiles
std::vector<int> delays; // -1 delay means no ejection charge
std::string designation{""};
double diameter{0};
std::string impulseClass; // 'A', 'B', '1/2A', 'M', etc
std::string infoUrl{""};
double length{0.0};
std::string manufacturer{""};
std::vector<int> delays; /// 1000 delay means no ejection charge
std::string designation{""}; /// Other name, usually includes prop type, e.g. H110W
double diameter{0}; /// motor diameter in mm
std::string impulseClass; /// Motor letter, e.g. 'A', 'B', '1/2A', 'M', etc
std::string infoUrl{""}; /// TODO: ???
double length{0.0}; /// motor length in mm
MotorManufacturer manufacturer{MOTORMANUFACTURER::UNKNOWN}; /// Motor Manufacturer
double maxThrust{0.0};
std::string motorIdTC{""}; // 24 character hex string used by thrustcurve to ID a motor
std::string propType{""}; // black powder, etc
double propWeight{0.0};
bool sparky{false};
double totalImpulse{0.0};
double totalWeight{0.0};
MotorType type{MOTORTYPE::SU};
std::string lastUpdated{""};
double maxThrust{0.0}; /// Max thrust in Newtons
std::string motorIdTC{""}; /// 24 character hex string used by thrustcurve.org to ID a motor
std::string propType{""}; /// Propellant type, e.g. black powder
double propWeight{0.0}; /// Propellant weight in grams
bool sparky{false}; /// true if the motor is "sparky", false otherwise
double totalImpulse{0.0}; /// Total impulse in Newton-seconds
double totalWeight{0.0}; /// Total weight in grams
MotorType type{MOTORTYPE::SU}; /// Motor type, e.g. single-use, reload, or hybrid
std::string lastUpdated{""}; /// Date last updated on ThrustCurve.org
// Thrust parameters
Thrustcurve thrust;
ThrustCurve thrust; /// The measured motor thrust curve
// Physical dimensions
};
template<class Archive>
void MotorModel::serialize(Archive& ar, const unsigned int version)
{
ar & manufacturer;
ar & impulseClass;
ar & propType;
ar & sparky;
ar & totalImpulse;
ar & delays;
ar & burnTime;
ar & thrust;
ar & diameter;
ar & length;
ar & totalWeight;
ar & propWeight;
}
#endif // MODEL_MOTORMODEL_H

View File

@ -1,22 +1,49 @@
#ifndef MOTORMODELDATABASE_H
#define MOTORMODELDATABASE_H
/// \cond
// C headers
// C++ headers
#include <vector>
// 3rd party headers
/// \endcond
// qtrocket headers
#include "model/MotorModel.h"
/**
* @brief The MotorModelDatabase class provides a storage and search mechanism for
* MotorModels
*/
class MotorModelDatabase
{
public:
/**
* @brief MotorModelDatabase constructor
*/
MotorModelDatabase();
std::vector<MotorModel> findMotorsByManufacturer(const std::string& manu);
/**
* @brief MotorModelDatabase destructor is defaulted
*/
~MotorModelDatabase() = default;
/**
* @brief findMotorsByManufacturer returns a vector of MotorModel from a given
* manufacturer
* @param manufacturer The manufacturer to search for
* @return vector of MotorModels from a given manufacturer
*/
std::vector<MotorModel> findMotorsByManufacturer(const std::string& manufacturer);
/**
* @brief findMotersByImpulseClass returns a vector of MotorModels with a given
* impulse class
* @param imClass Impulse class to search for
* @return vector of MotorModels with a given Impulse class
*/
std::vector<MotorModel> findMotersByImpulseClass(const std::string& imClass);
MotorModel getMotorByName(const std::string& name);
std::vector<std::pair<double, double>> getThrustCurveByName(const std::string& motorName);
private:
std::vector<MotorModel> motors;

View File

@ -36,7 +36,7 @@ double Rocket::getThrust(double t)
return tc.getThrust(t);
}
void Rocket::setThrustCurve(const Thrustcurve& curve)
void Rocket::setThrustCurve(const ThrustCurve& curve)
{
tc = curve;
}

View File

@ -11,12 +11,19 @@
/// \endcond
// qtrocket headers
#include "model/Thrustcurve.h"
#include "model/ThrustCurve.h"
#include "sim/Propagator.h"
/**
* @brief The Rocket class holds all rocket components
*
*/
class Rocket
{
public:
/**
* @brief Rocket class constructor
*/
Rocket();
void launch();
@ -31,7 +38,7 @@ public:
double getDragCoefficient() const { return dragCoeff; }
double getThrust(double t);
void setThrustCurve(const Thrustcurve& curve);
void setThrustCurve(const ThrustCurve& curve);
bool terminateCondition(const std::pair<double, std::vector<double>>& cond);
@ -43,7 +50,7 @@ private:
double dragCoeff;
double mass;
Thrustcurve tc;
ThrustCurve tc;
};

View File

@ -7,10 +7,10 @@
// 3rd party headers
/// \endcond
#include "Thrustcurve.h"
#include "ThrustCurve.h"
Thrustcurve::Thrustcurve(std::vector<std::pair<double, double>>& tc)
ThrustCurve::ThrustCurve(std::vector<std::pair<double, double>>& tc)
: thrustCurve(tc),
maxTime(0.0),
ignitionTime(0.0)
@ -23,16 +23,16 @@ Thrustcurve::Thrustcurve(std::vector<std::pair<double, double>>& tc)
})->first;
}
Thrustcurve::Thrustcurve()
ThrustCurve::ThrustCurve()
{
thrustCurve.emplace_back(0.0, 0.0);
maxTime = 0.0;
}
Thrustcurve::~Thrustcurve()
ThrustCurve::~ThrustCurve()
{}
void Thrustcurve::setThrustCurveVector(const std::vector<std::pair<double, double>>& v)
void ThrustCurve::setThrustCurveVector(const std::vector<std::pair<double, double>>& v)
{
thrustCurve.clear();
thrustCurve.resize(v.size());
@ -45,13 +45,13 @@ void Thrustcurve::setThrustCurveVector(const std::vector<std::pair<double, doubl
})->first;
}
void Thrustcurve::setIgnitionTime(double t)
void ThrustCurve::setIgnitionTime(double t)
{
ignitionTime = t;
//maxTime += ignitionTime;
}
double Thrustcurve::getThrust(double t)
double ThrustCurve::getThrust(double t)
{
// calculate t relative to the start time of the motor
t -= ignitionTime;

View File

@ -11,24 +11,24 @@
#include <boost/archive/text_oarchive.hpp>
/// \endcond
class Thrustcurve
class ThrustCurve
{
public:
/**
* Constructor takes a vector of pairs. The first item a timestamp,
* the second the thrust in newtons.
*/
Thrustcurve(std::vector<std::pair<double, double>>& tc);
ThrustCurve(std::vector<std::pair<double, double>>& tc);
/**
* Default constructor. Will create an empty thrustcurve, always returning 0.0
* for all requested times.
*/
Thrustcurve();
Thrustcurve(const Thrustcurve&) = default;
Thrustcurve(Thrustcurve&&) = default;
~Thrustcurve();
ThrustCurve();
ThrustCurve(const ThrustCurve&) = default;
ThrustCurve(ThrustCurve&&) = default;
~ThrustCurve();
Thrustcurve& operator=(const Thrustcurve& rhs)
ThrustCurve& operator=(const ThrustCurve& rhs)
{
if(this != &rhs)
{
@ -39,7 +39,7 @@ public:
return *this;
}
Thrustcurve& operator=(Thrustcurve&& rhs)
ThrustCurve& operator=(ThrustCurve&& rhs)
{
thrustCurve = std::move(rhs.thrustCurve);
maxTime = std::move(rhs.maxTime);
@ -76,7 +76,7 @@ private:
};
template<class Archive>
void Thrustcurve::serialize(Archive& ar, const unsigned int version)
void ThrustCurve::serialize(Archive& ar, const unsigned int version)
{
ar & maxTime;
ar & thrustCurve;

View File

@ -21,7 +21,7 @@ SOURCES += \
model/MotorModel.cpp \
model/MotorModelDatabase.cpp \
model/Rocket.cpp \
model/Thrustcurve.cpp \
model/ThrustCurve.cpp \
sim/ConstantGravityModel.cpp \
sim/GravityModel.cpp \
sim/Propagator.cpp \
@ -51,7 +51,7 @@ HEADERS += \
model/MotorModel.h \
model/MotorModelDatabase.h \
model/Rocket.h \
model/Thrustcurve.h \
model/ThrustCurve.h \
sim/AtmosphericModel.h \
sim/ConstantAtmosphere.h \
sim/ConstantGravityModel.h \

View File

@ -59,7 +59,17 @@ void RSEDatabaseLoader::buildAndAppendMotorModel(boost::property_tree::ptree& v)
// infoUrl not present in RSE file
mm.infoUrl = "";
mm.length = v.get<double>("<xmlattr>.len", 0.0);
mm.manufacturer = v.get<std::string>("<xmlattr>.mfg", "");
{
std::string manufacturer = v.get<std::string>("<xmlattr>.mfg", "");
MotorModel::MotorManufacturer manu(MotorModel::MOTORMANUFACTURER::UNKNOWN);
if(manufacturer == "Aerotech")
manu = MotorModel::MOTORMANUFACTURER::AEROTECH;
else if(manufacturer == "Animal Motor Works")
manu = MotorModel::MOTORMANUFACTURER::AMW;
else if(manufacturer == "Apogee")
manu = MotorModel::MOTORMANUFACTURER::APOGEE;
mm.manufacturer = manu;
}
mm.maxThrust = v.get<double>("<xmlattr>.peakThrust", 0.0);
mm.propWeight = v.get<double>("<xmlattr>.propWt", 0.0);
mm.totalImpulse = v.get<double>("<xmlattr>.Itot", 0.0);

View File

@ -34,8 +34,8 @@ MotorModel ThrustCurveAPI::getMotorData(const std::string& motorId)
std::string res = curlConnection.get(endpoint.str(), extraHeaders);
/// TODO: fix this
MotorModel mm;
mm.setDataFromJsonString(res);
return mm;
}
@ -165,7 +165,10 @@ std::vector<MotorModel> ThrustCurveAPI::searchMotors(const SearchCriteria& c)
mm.diameter = (*iter)["diameter"].asDouble();
mm.impulseClass = (*iter)["impulseClass"].asString();
mm.length = (*iter)["length"].asDouble();
mm.manufacturer = (*iter)["manufacturer"].asString();
std::string manu = (*iter)["manufacturer"].asString();
if(manu == "AeroTech")
mm.manufacturer = MotorModel::MOTORMANUFACTURER::AEROTECH;
//mm.manufacturer = (*iter)["manufacturer"].asString();
mm.maxThrust = (*iter)["maxThrustN"].asDouble();
mm.motorIdTC = (*iter)["motorId"].asString();
mm.propType = (*iter)["propInfo"].asString();