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,21 +66,12 @@ 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());
parts.setGearDown(true);
engines.initEngines(engineNumber, situation.isMoving());
}
else
{
parts.setGearDown(false);
engines.initEngines(engineNumber, true);
if (vtol)
{
} if (situation.hasGroundElevation())
else if (situation.hasGroundElevation())
{ {
const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft()); const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft());
if (aGroundFt < 1000) if (aGroundFt < 1000)
@@ -93,8 +84,32 @@ namespace BlackMisc
parts.setGearDown(true); parts.setGearDown(true);
parts.setFlapsPercent(10); parts.setFlapsPercent(10);
} }
else
{
parts.setGearDown(false);
parts.setFlapsPercent(0);
} }
} }
else
{
if (!situation.hasInboundGroundInformation())
{
// the ground flag is not reliable and we have no ground elevation
if (situation.getOnGroundDetails() == CAircraftSituation::OnGroundByGuessing)
{
// should be OK
}
else
{
if (!vtol)
{
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);