Ref T260, utility functions/improvements in aviation/simulation value objects

This commit is contained in:
Klaus Basan
2018-04-13 20:27:11 +02:00
committed by Roland Winklmeier
parent 04f99d10ac
commit 7f4ee19d24
5 changed files with 76 additions and 40 deletions

View File

@@ -703,6 +703,12 @@ namespace BlackMisc
return i; return i;
} }
const CAircraftIcaoCode &CAircraftIcaoCode::unassignedIcao()
{
static const CAircraftIcaoCode z(getUnassignedDesignator());
return z;
}
const QStringList &CAircraftIcaoCode::getSpecialDesignators() const QStringList &CAircraftIcaoCode::getSpecialDesignators()
{ {
static const QStringList s({ "ZZZZ", "SHIP", "BALL", "GLID", "ULAC", "GYRO", "UHEL" }); static const QStringList s({ "ZZZZ", "SHIP", "BALL", "GLID", "ULAC", "GYRO", "UHEL" });

View File

@@ -309,6 +309,9 @@ namespace BlackMisc
//! The unassigned designator ("ZZZZ") //! The unassigned designator ("ZZZZ")
static const QString &getUnassignedDesignator(); static const QString &getUnassignedDesignator();
//! Unassigned ICAO code "ZZZZ"
static const CAircraftIcaoCode &unassignedIcao();
//! List of the special designators ("ZZZZ", "UHEL", ...) //! List of the special designators ("ZZZZ", "UHEL", ...)
static const QStringList &getSpecialDesignators(); static const QStringList &getSpecialDesignators();

View File

@@ -66,35 +66,50 @@ namespace BlackMisc
CAircraftEngineList engines; CAircraftEngineList engines;
parts.setLights(CAircraftLights::guessedLights(situation)); parts.setLights(CAircraftLights::guessedLights(situation));
// set some reasonable defaults
const bool onGround = situation.isOnGround(); const bool onGround = situation.isOnGround();
if (onGround) parts.setGearDown(onGround);
engines.initEngines(engineNumber, !onGround || situation.isMoving());
if (situation.hasGroundElevation())
{ {
parts.setGearDown(true); const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft());
engines.initEngines(engineNumber, situation.isMoving()); if (aGroundFt < 1000)
{
parts.setGearDown(true);
parts.setFlapsPercent(25);
}
else if (aGroundFt < 2000)
{
parts.setGearDown(true);
parts.setFlapsPercent(10);
}
else
{
parts.setGearDown(false);
parts.setFlapsPercent(0);
}
} }
else else
{ {
parts.setGearDown(false); if (!situation.hasInboundGroundInformation())
engines.initEngines(engineNumber, true);
if (vtol)
{ {
// the ground flag is not reliable and we have no ground elevation
} if (situation.getOnGroundDetails() == CAircraftSituation::OnGroundByGuessing)
else if (situation.hasGroundElevation())
{
const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft());
if (aGroundFt < 1000)
{ {
parts.setGearDown(true); // should be OK
parts.setFlapsPercent(25);
} }
else if (aGroundFt < 2000) else
{ {
parts.setGearDown(true); if (!vtol)
parts.setFlapsPercent(10); {
const bool gearDown = situation.getGroundSpeed().value(CSpeedUnit::kts()) < 60;
parts.setGearDown(gearDown);
}
} }
} }
} }
parts.setEngines(engines); parts.setEngines(engines);
parts.setPartsDetails(GuessedParts); parts.setPartsDetails(GuessedParts);
return parts; return parts;

View File

@@ -129,7 +129,7 @@ namespace BlackMisc
{ {
static const QString html = "Model: %1 changed: %2%3Simulator: %4 Mode: %5 Distributor: %6%7Aircraft ICAO: %8%9Livery: %10"; static const QString html = "Model: %1 changed: %2%3Simulator: %4 Mode: %5 Distributor: %6%7Aircraft ICAO: %8%9Livery: %10";
return html return html
.arg(this->getModelStringAndDbKey(), this->getFormattedUtcTimestampYmdhms() , separator, .arg(this->getModelStringAndDbKey(), this->getFormattedUtcTimestampYmdhms(), separator,
this->getSimulator().toQString(true), this->getModelModeAsString(), this->getDistributor().getIdAndDescription(), separator, this->getSimulator().toQString(true), this->getModelModeAsString(), this->getDistributor().getIdAndDescription(), separator,
this->getAircraftIcaoCode().asHtmlSummary(), separator) this->getAircraftIcaoCode().asHtmlSummary(), separator)
.arg(this->getLivery().asHtmlSummary("&nbsp;")).replace(" ", "&nbsp;"); .arg(this->getLivery().asHtmlSummary("&nbsp;")).replace(" ", "&nbsp;");
@@ -692,19 +692,30 @@ namespace BlackMisc
return !changed; return !changed;
} }
QString CAircraftModel::modelTypeToString(CAircraftModel::ModelType type) const QString &CAircraftModel::modelTypeToString(CAircraftModel::ModelType type)
{ {
static const QString queried("queried");
static const QString matching("matching");
static const QString db("database");
static const QString def("map.default");
static const QString ownSim("own simulator");
static const QString set("set");
static const QString fsinn("FSInn");
static const QString probe("probe");
static const QString unknown("unknown");
switch (type) switch (type)
{ {
case TypeQueriedFromNetwork: return "queried"; case TypeQueriedFromNetwork: return queried;
case TypeModelMatching: return "matching"; case TypeModelMatching: return matching;
case TypeDatabaseEntry: return "database"; case TypeDatabaseEntry: return db;
case TypeModelMatchingDefaultModel: return "map. default"; case TypeModelMatchingDefaultModel: return def;
case TypeOwnSimulatorModel: return "own simulator"; case TypeOwnSimulatorModel: return ownSim;
case TypeManuallySet: return "set"; case TypeManuallySet: return set;
case TypeFSInnData: return "FSInn"; case TypeFSInnData: return fsinn;
case TypeTerrainProbe: return probe;
case TypeUnknown: case TypeUnknown:
default: return "unknown"; default: return unknown;
} }
} }

View File

@@ -65,7 +65,8 @@ namespace BlackMisc
TypeDatabaseEntry, //!< used along with mapping definition TypeDatabaseEntry, //!< used along with mapping definition
TypeManuallySet, //!< manually set, e.g. from GUI TypeManuallySet, //!< manually set, e.g. from GUI
TypeOwnSimulatorModel, //!< represents own simulator model TypeOwnSimulatorModel, //!< represents own simulator model
TypeVPilotRuleBased //!< based on a vPilot rule TypeVPilotRuleBased, //!< based on a vPilot rule
TypeTerrainProbe //!< peudo aircraft used for terrain probing (FSX)
}; };
//! Mode, decides if a model is supposed to be used in the model set for model matching //! Mode, decides if a model is supposed to be used in the model set for model matching
@@ -263,7 +264,7 @@ namespace BlackMisc
ModelType getModelType() const { return m_modelType; } ModelType getModelType() const { return m_modelType; }
//! Model type //! Model type
QString getModelTypeAsString() const { return modelTypeToString(getModelType()); } const QString &getModelTypeAsString() const { return modelTypeToString(getModelType()); }
//! Set type //! Set type
void setModelType(ModelType type) { m_modelType = type; } void setModelType(ModelType type) { m_modelType = type; }
@@ -404,7 +405,7 @@ namespace BlackMisc
// ---------------- end file related functions -------------- // ---------------- end file related functions --------------
//! Model type //! Model type
static QString modelTypeToString(ModelType type); static const QString &modelTypeToString(ModelType type);
//! File path used for DB //! File path used for DB
static QString normalizeFileNameForDb(const QString &filePath); static QString normalizeFileNameForDb(const QString &filePath);
@@ -430,16 +431,16 @@ namespace BlackMisc
Aviation::CCallsign m_callsign; //!< aircraft's callsign if any Aviation::CCallsign m_callsign; //!< aircraft's callsign if any
Aviation::CAircraftIcaoCode m_aircraftIcao; //!< ICAO code if available Aviation::CAircraftIcaoCode m_aircraftIcao; //!< ICAO code if available
Aviation::CLivery m_livery; //!< livery information Aviation::CLivery m_livery; //!< livery information
CSimulatorInfo m_simulator; //!< model for given simulator CSimulatorInfo m_simulator; //!< model for given simulator
CDistributor m_distributor; //!< who designed or distributed the model CDistributor m_distributor; //!< who designed or distributed the model
QString m_modelString; //!< Simulator model key, unique QString m_modelString; //!< Simulator model key, unique
QString m_name; //!< Model name QString m_name; //!< Model name
QString m_description; //!< descriptive text QString m_description; //!< descriptive text
QString m_fileName; //!< file name QString m_fileName; //!< file name
QString m_iconPath; //!< a file representing the aircraft as icon QString m_iconPath; //!< a file representing the aircraft as icon
qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable) qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable)
ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...? ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...?
ModelMode m_modelMode = Include; //!< model mode (include / exclude) ModelMode m_modelMode = Include; //!< model mode (include / exclude)
BLACK_METACLASS( BLACK_METACLASS(
CAircraftModel, CAircraftModel,