mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T260, utility functions/improvements in aviation/simulation value objects
This commit is contained in:
committed by
Roland Winklmeier
parent
04f99d10ac
commit
7f4ee19d24
@@ -703,6 +703,12 @@ namespace BlackMisc
|
||||
return i;
|
||||
}
|
||||
|
||||
const CAircraftIcaoCode &CAircraftIcaoCode::unassignedIcao()
|
||||
{
|
||||
static const CAircraftIcaoCode z(getUnassignedDesignator());
|
||||
return z;
|
||||
}
|
||||
|
||||
const QStringList &CAircraftIcaoCode::getSpecialDesignators()
|
||||
{
|
||||
static const QStringList s({ "ZZZZ", "SHIP", "BALL", "GLID", "ULAC", "GYRO", "UHEL" });
|
||||
|
||||
@@ -309,6 +309,9 @@ namespace BlackMisc
|
||||
//! The unassigned designator ("ZZZZ")
|
||||
static const QString &getUnassignedDesignator();
|
||||
|
||||
//! Unassigned ICAO code "ZZZZ"
|
||||
static const CAircraftIcaoCode &unassignedIcao();
|
||||
|
||||
//! List of the special designators ("ZZZZ", "UHEL", ...)
|
||||
static const QStringList &getSpecialDesignators();
|
||||
|
||||
|
||||
@@ -66,35 +66,50 @@ namespace BlackMisc
|
||||
CAircraftEngineList engines;
|
||||
parts.setLights(CAircraftLights::guessedLights(situation));
|
||||
|
||||
// set some reasonable defaults
|
||||
const bool onGround = situation.isOnGround();
|
||||
if (onGround)
|
||||
parts.setGearDown(onGround);
|
||||
engines.initEngines(engineNumber, !onGround || situation.isMoving());
|
||||
|
||||
if (situation.hasGroundElevation())
|
||||
{
|
||||
parts.setGearDown(true);
|
||||
engines.initEngines(engineNumber, situation.isMoving());
|
||||
const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft());
|
||||
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
|
||||
{
|
||||
parts.setGearDown(false);
|
||||
engines.initEngines(engineNumber, true);
|
||||
if (vtol)
|
||||
if (!situation.hasInboundGroundInformation())
|
||||
{
|
||||
|
||||
}
|
||||
else if (situation.hasGroundElevation())
|
||||
{
|
||||
const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft());
|
||||
if (aGroundFt < 1000)
|
||||
// the ground flag is not reliable and we have no ground elevation
|
||||
if (situation.getOnGroundDetails() == CAircraftSituation::OnGroundByGuessing)
|
||||
{
|
||||
parts.setGearDown(true);
|
||||
parts.setFlapsPercent(25);
|
||||
// should be OK
|
||||
}
|
||||
else if (aGroundFt < 2000)
|
||||
else
|
||||
{
|
||||
parts.setGearDown(true);
|
||||
parts.setFlapsPercent(10);
|
||||
if (!vtol)
|
||||
{
|
||||
const bool gearDown = situation.getGroundSpeed().value(CSpeedUnit::kts()) < 60;
|
||||
parts.setGearDown(gearDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parts.setEngines(engines);
|
||||
parts.setPartsDetails(GuessedParts);
|
||||
return parts;
|
||||
|
||||
@@ -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";
|
||||
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->getAircraftIcaoCode().asHtmlSummary(), separator)
|
||||
.arg(this->getLivery().asHtmlSummary(" ")).replace(" ", " ");
|
||||
@@ -692,19 +692,30 @@ namespace BlackMisc
|
||||
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)
|
||||
{
|
||||
case TypeQueriedFromNetwork: return "queried";
|
||||
case TypeModelMatching: return "matching";
|
||||
case TypeDatabaseEntry: return "database";
|
||||
case TypeModelMatchingDefaultModel: return "map. default";
|
||||
case TypeOwnSimulatorModel: return "own simulator";
|
||||
case TypeManuallySet: return "set";
|
||||
case TypeFSInnData: return "FSInn";
|
||||
case TypeQueriedFromNetwork: return queried;
|
||||
case TypeModelMatching: return matching;
|
||||
case TypeDatabaseEntry: return db;
|
||||
case TypeModelMatchingDefaultModel: return def;
|
||||
case TypeOwnSimulatorModel: return ownSim;
|
||||
case TypeManuallySet: return set;
|
||||
case TypeFSInnData: return fsinn;
|
||||
case TypeTerrainProbe: return probe;
|
||||
case TypeUnknown:
|
||||
default: return "unknown";
|
||||
default: return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ namespace BlackMisc
|
||||
TypeDatabaseEntry, //!< used along with mapping definition
|
||||
TypeManuallySet, //!< manually set, e.g. from GUI
|
||||
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
|
||||
@@ -263,7 +264,7 @@ namespace BlackMisc
|
||||
ModelType getModelType() const { return m_modelType; }
|
||||
|
||||
//! Model type
|
||||
QString getModelTypeAsString() const { return modelTypeToString(getModelType()); }
|
||||
const QString &getModelTypeAsString() const { return modelTypeToString(getModelType()); }
|
||||
|
||||
//! Set type
|
||||
void setModelType(ModelType type) { m_modelType = type; }
|
||||
@@ -404,7 +405,7 @@ namespace BlackMisc
|
||||
// ---------------- end file related functions --------------
|
||||
|
||||
//! Model type
|
||||
static QString modelTypeToString(ModelType type);
|
||||
static const QString &modelTypeToString(ModelType type);
|
||||
|
||||
//! File path used for DB
|
||||
static QString normalizeFileNameForDb(const QString &filePath);
|
||||
@@ -430,16 +431,16 @@ namespace BlackMisc
|
||||
Aviation::CCallsign m_callsign; //!< aircraft's callsign if any
|
||||
Aviation::CAircraftIcaoCode m_aircraftIcao; //!< ICAO code if available
|
||||
Aviation::CLivery m_livery; //!< livery information
|
||||
CSimulatorInfo m_simulator; //!< model for given simulator
|
||||
CDistributor m_distributor; //!< who designed or distributed the model
|
||||
QString m_modelString; //!< Simulator model key, unique
|
||||
QString m_name; //!< Model name
|
||||
QString m_description; //!< descriptive text
|
||||
QString m_fileName; //!< file name
|
||||
QString m_iconPath; //!< a file representing the aircraft as icon
|
||||
qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable)
|
||||
ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...?
|
||||
ModelMode m_modelMode = Include; //!< model mode (include / exclude)
|
||||
CSimulatorInfo m_simulator; //!< model for given simulator
|
||||
CDistributor m_distributor; //!< who designed or distributed the model
|
||||
QString m_modelString; //!< Simulator model key, unique
|
||||
QString m_name; //!< Model name
|
||||
QString m_description; //!< descriptive text
|
||||
QString m_fileName; //!< file name
|
||||
QString m_iconPath; //!< a file representing the aircraft as icon
|
||||
qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable)
|
||||
ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...?
|
||||
ModelMode m_modelMode = Include; //!< model mode (include / exclude)
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAircraftModel,
|
||||
|
||||
Reference in New Issue
Block a user