mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #789, improvements when addressing FSX driver issue
* added new utility funtion is model list / aircraft list * added setters/getters for CSimConnectObject * added setters/getters for InterpolationStatus / PartsStatus * added CSimConnectObjects (better encapsulation)
This commit is contained in:
@@ -40,7 +40,7 @@ namespace BlackMisc
|
||||
CAircraftPartsList IInterpolator::getPartsBeforeTime(const CAircraftPartsList &parts, qint64 cutoffTime, BlackMisc::IInterpolator::PartsStatus &partsStatus) const
|
||||
{
|
||||
partsStatus.reset();
|
||||
partsStatus.supportsParts = true;
|
||||
partsStatus.setSupportsParts(true);
|
||||
|
||||
if (cutoffTime < 0) { return parts; }
|
||||
return parts.findBefore(cutoffTime);
|
||||
@@ -51,8 +51,8 @@ namespace BlackMisc
|
||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
|
||||
partsStatus.reset();
|
||||
|
||||
partsStatus.supportsParts = this->isRemoteAircraftSupportingParts(callsign);
|
||||
if (!partsStatus.supportsParts) { return {}; }
|
||||
partsStatus.setSupportsParts(this->isRemoteAircraftSupportingParts(callsign));
|
||||
if (!partsStatus.isSupportingParts()) { return {}; }
|
||||
return this->remoteAircraftParts(callsign, cutoffTime);
|
||||
}
|
||||
|
||||
@@ -70,22 +70,22 @@ namespace BlackMisc
|
||||
|
||||
bool IInterpolator::InterpolationStatus::allTrue() const
|
||||
{
|
||||
return interpolationSucceeded && changedPosition;
|
||||
return m_interpolationSucceeded && m_changedPosition;
|
||||
}
|
||||
|
||||
void IInterpolator::InterpolationStatus::reset()
|
||||
{
|
||||
changedPosition = false;
|
||||
interpolationSucceeded = false;
|
||||
m_changedPosition = false;
|
||||
m_interpolationSucceeded = false;
|
||||
}
|
||||
|
||||
bool IInterpolator::PartsStatus::allTrue() const
|
||||
{
|
||||
return supportsParts;
|
||||
return m_supportsParts;
|
||||
}
|
||||
|
||||
void IInterpolator::PartsStatus::reset()
|
||||
{
|
||||
supportsParts = false;
|
||||
m_supportsParts = false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -43,9 +43,22 @@ namespace BlackMisc
|
||||
//! Status of interpolation
|
||||
struct BLACKMISC_EXPORT InterpolationStatus
|
||||
{
|
||||
private:
|
||||
bool m_changedPosition = false; //!< position was changed
|
||||
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
|
||||
|
||||
public:
|
||||
bool changedPosition = false; //!< position was changed
|
||||
bool interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
|
||||
//! Did interpolation succeed?
|
||||
bool didInterpolationSucceed() const { return m_interpolationSucceeded; }
|
||||
|
||||
//! Set succeeded
|
||||
void setInterpolationSucceeded(bool succeeded) { m_interpolationSucceeded = succeeded; }
|
||||
|
||||
//! Changed position?
|
||||
bool hasChangedPosition() const { return m_changedPosition; }
|
||||
|
||||
//! Set as changed
|
||||
void setChangedPosition(bool changed) { m_changedPosition = changed; }
|
||||
|
||||
//! all OK
|
||||
bool allTrue() const;
|
||||
@@ -57,11 +70,19 @@ namespace BlackMisc
|
||||
//! Status regarding parts
|
||||
struct BLACKMISC_EXPORT PartsStatus
|
||||
{
|
||||
bool supportsParts = false; //!< supports parts for given callsign
|
||||
private:
|
||||
bool m_supportsParts = false; //!< supports parts for given callsign
|
||||
|
||||
public:
|
||||
//! all OK
|
||||
bool allTrue() const;
|
||||
|
||||
//! Supporting parts
|
||||
bool isSupportingParts() const { return m_supportsParts; }
|
||||
|
||||
//! Set support flag
|
||||
void setSupportsParts(bool supports) { m_supportsParts = supports; }
|
||||
|
||||
//! Reset to default values
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -60,8 +60,8 @@ namespace BlackMisc
|
||||
// interpolation situations
|
||||
CAircraftSituation oldSituation;
|
||||
CAircraftSituation newSituation;
|
||||
status.interpolationSucceeded = true;
|
||||
status.changedPosition = true; //! \todo efficiently determine whether the position has changed
|
||||
status.setInterpolationSucceeded(true);
|
||||
status.setChangedPosition(true); //! \todo efficiently determine whether the position has changed
|
||||
|
||||
// latest first, now 00:20 split time
|
||||
// time pos
|
||||
|
||||
@@ -54,6 +54,16 @@ namespace BlackMisc
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAircraftModelList::containsCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
return this->contains(&CAircraftModel::getCallsign, callsign);
|
||||
}
|
||||
|
||||
bool CAircraftModelList::containsModelsWithAircraftAndAirlineDesignator(const QString &aircraftDesignator, const QString &airlineDesignator) const
|
||||
{
|
||||
return this->contains(&CAircraftModel::getAircraftIcaoCodeDesignator, aircraftDesignator, &CAircraftModel::getAirlineIcaoCodeDesignator, airlineDesignator);
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
||||
{
|
||||
return this->findBy([ & ](const CAircraftModel & model)
|
||||
|
||||
@@ -65,6 +65,12 @@ namespace BlackMisc
|
||||
//! Contains model with model string or id
|
||||
bool containsModelStringOrDbKey(const BlackMisc::Simulation::CAircraftModel &model, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
||||
|
||||
//! Contains model for callsign
|
||||
bool containsCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Contains any model with aircraft and airline designator
|
||||
bool containsModelsWithAircraftAndAirlineDesignator(const QString &aircraftDesignator, const QString &airlineDesignator) const;
|
||||
|
||||
//! Find by model string
|
||||
//! \remark normally CAircraftModelList::findFirstByModelStringOrDefault would be used
|
||||
CAircraftModelList findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
||||
|
||||
@@ -153,5 +153,18 @@ namespace BlackMisc
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSimulatedAircraftList::replaceOrAddByCallsign(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
const CCallsign cs(aircraft.getCallsign());
|
||||
if (cs.isEmpty()) { return false; }
|
||||
|
||||
if (this->containsCallsign(cs))
|
||||
{
|
||||
int c = this->replaceIf(&CSimulatedAircraft::getCallsign, cs, aircraft);
|
||||
return c > 0;
|
||||
}
|
||||
this->push_back(aircraft);
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -92,8 +92,9 @@ namespace BlackMisc
|
||||
//! Rendered?
|
||||
bool isRendered(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Replace or add by callsign
|
||||
bool replaceOrAddByCallsign(const CSimulatedAircraft &aircraft);
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user