diff --git a/src/blackcore/context/contextnetworkimpl.cpp b/src/blackcore/context/contextnetworkimpl.cpp index fc3210eee..cd0777cd8 100644 --- a/src/blackcore/context/contextnetworkimpl.cpp +++ b/src/blackcore/context/contextnetworkimpl.cpp @@ -417,6 +417,11 @@ namespace BlackCore return m_airspace->autoAdjustCientGndCapability(situation); } + bool CContextNetwork::addClientGndCapability(const CCallsign &callsign) + { + return m_airspace->addClientGndCapability(callsign); + } + CServerList CContextNetwork::getVatsimFsdServers() const { Q_ASSERT_X(sApp->getWebDataServices(), Q_FUNC_INFO, "Missing data reader"); diff --git a/src/blackcore/context/contextnetworkimpl.h b/src/blackcore/context/contextnetworkimpl.h index 476a6ceae..690df1f0f 100644 --- a/src/blackcore/context/contextnetworkimpl.h +++ b/src/blackcore/context/contextnetworkimpl.h @@ -120,6 +120,7 @@ namespace BlackCore virtual int updateOrAddClient(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CPropertyIndexVariantMap &vm, bool skipEqualValues = true) override; virtual int removeClient(const BlackMisc::Aviation::CCallsign &callsign) override; virtual bool autoAdjustCientGndCapability(const BlackMisc::Aviation::CAircraftSituation &situation) override; + virtual bool addClientGndCapability(const BlackMisc::Aviation::CCallsign &callsign) override; //! @} public slots: diff --git a/src/blackgui/models/simulatedaircraftlistmodel.cpp b/src/blackgui/models/simulatedaircraftlistmodel.cpp index 0f3438ecf..40d64ad2f 100644 --- a/src/blackgui/models/simulatedaircraftlistmodel.cpp +++ b/src/blackgui/models/simulatedaircraftlistmodel.cpp @@ -93,6 +93,7 @@ namespace BlackGui m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundSpeed }, new CSpeedKtsFormatter())); m_columns.addColumn(CColumn("p.", "parts", CSimulatedAircraft::IndexPartsSynchronized, new CBoolIconFormatter("parts", "no parts"), true)); m_columns.addColumn(CColumn("fp.", "fast position updates", CSimulatedAircraft::IndexFastPositionUpdates, new CBoolIconFormatter("enabled", "disabled"), true)); + m_columns.addColumn(CColumn("gnd", "supports gnd.flag", CSimulatedAircraft::IndexSupportsGndFlag, new CBoolIconFormatter("yes", "no"), true)); m_columns.addColumn(CColumn::standardString("realname", "pilot's real name", { CSimulatedAircraft::IndexPilot, CUser::IndexRealName })); m_columns.addColumn(CColumn::standardString("icao", CSimulatedAircraft::IndexCombinedIcaoLiveryString)); m_columns.addColumn(CColumn::standardString("model", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexModelString})); diff --git a/src/blackmisc/aviation/aircraftsituation.cpp b/src/blackmisc/aviation/aircraftsituation.cpp index e2413c352..ce85db133 100644 --- a/src/blackmisc/aviation/aircraftsituation.cpp +++ b/src/blackmisc/aviation/aircraftsituation.cpp @@ -243,6 +243,16 @@ namespace BlackMisc m_onGroundDetails = CAircraftSituation::NotSetGroundDetails; } + bool CAircraftSituation::isOnGroundFromParts() const + { + return this->isOnGround() && this->getOnGroundDetails() == InFromParts; + } + + bool CAircraftSituation::isOnGroundFromNetwork() const + { + return this->isOnGround() && this->getOnGroundDetails() == InFromNetwork; + } + const QString &CAircraftSituation::onGroundAsString() const { return CAircraftSituation::isOnGroundToString(this->getOnGround()); diff --git a/src/blackmisc/aviation/aircraftsituation.h b/src/blackmisc/aviation/aircraftsituation.h index e86194050..3fde7ca51 100644 --- a/src/blackmisc/aviation/aircraftsituation.h +++ b/src/blackmisc/aviation/aircraftsituation.h @@ -171,6 +171,12 @@ namespace BlackMisc //! Is on ground? bool isOnGround() const { return this->getOnGround() == OnGround; } + //! On ground by parts? + bool isOnGroundFromParts() const; + + //! On ground by network flag? + bool isOnGroundFromNetwork() const; + //! On ground? const QString &onGroundAsString() const; diff --git a/src/blackmisc/aviation/aircraftsituationlist.cpp b/src/blackmisc/aviation/aircraftsituationlist.cpp index d8ffd074b..f6cd44669 100644 --- a/src/blackmisc/aviation/aircraftsituationlist.cpp +++ b/src/blackmisc/aviation/aircraftsituationlist.cpp @@ -115,12 +115,12 @@ namespace BlackMisc return this->findBy(&CAircraftSituation::hasInboundGroundDetails, hasGroundInfo); } - bool CAircraftSituationList::hasSituationWithoutGroundElevation() const + bool CAircraftSituationList::containsSituationWithoutGroundElevation() const { return this->contains(&CAircraftSituation::hasGroundElevation, false); } - bool CAircraftSituationList::hasGroundElevationOutsideRange(const CLength &range) const + bool CAircraftSituationList::containsGroundElevationOutsideRange(const CLength &range) const { for (const CAircraftSituation &situation : *this) { @@ -297,6 +297,11 @@ namespace BlackMisc return false; } + bool CAircraftSituationList::containsOnGroundFromNetwork() const + { + return this->contains(&CAircraftSituation::isOnGroundFromNetwork, true); + } + int CAircraftSituationList::countOnGround(CAircraftSituation::IsOnGround og) const { int c = 0; diff --git a/src/blackmisc/aviation/aircraftsituationlist.h b/src/blackmisc/aviation/aircraftsituationlist.h index a4f89cd16..c917ea5b9 100644 --- a/src/blackmisc/aviation/aircraftsituationlist.h +++ b/src/blackmisc/aviation/aircraftsituationlist.h @@ -70,16 +70,23 @@ namespace BlackMisc //! Find if having inbound information CAircraftSituationList findByInboundGroundInformation(bool hasGroundInfo) const; - //! Any situation without ground info - bool hasSituationWithoutGroundElevation() const; + //! Any situation without ground info? + bool containsSituationWithoutGroundElevation() const; //! Any situation outside range? - bool hasGroundElevationOutsideRange(const PhysicalQuantities::CLength &range) const; + bool containsGroundElevationOutsideRange(const PhysicalQuantities::CLength &range) const; - //! Contains on ground details + //! Contains on ground details? bool containsOnGroundDetails(CAircraftSituation::OnGroundDetails details) const; - //! Are all on ground details the same + //! Contains any push back? + //! \remark only valid for non VTOL aircraft + bool containsPushBack() const; + + //! Contains any gnd.flag \c true ? + bool containsOnGroundFromNetwork() const; + + //! Are all on ground details the same? bool areAllOnGroundDetailsSame(CAircraftSituation::OnGroundDetails details) const; //! Are all situations on ground? @@ -112,10 +119,6 @@ namespace BlackMisc //! Is rotating up? bool isRotatingUp(bool alreadySortedLatestFirst = false) const; - //! Contains any push back - //! \remark only valid for non VTOL aircraft - bool containsPushBack() const; - //! Count the number of situations with CAircraftSituation::IsOnGround int countOnGround(CAircraftSituation::IsOnGround og) const; diff --git a/src/blackmisc/network/clientprovider.cpp b/src/blackmisc/network/clientprovider.cpp index b05613df6..d071a2c7c 100644 --- a/src/blackmisc/network/clientprovider.cpp +++ b/src/blackmisc/network/clientprovider.cpp @@ -96,12 +96,16 @@ namespace BlackMisc if (situation.getCallsign().isEmpty()) { return false; } // no callsign if (!situation.isOnGround()) { return false; } // nothing to adjust if (situation.getOnGroundDetails() != CAircraftSituation::InFromNetwork) { return false; } // not from network + return this->addClientGndCapability(situation.getCallsign()); + } - CClient client = this->getClientOrDefaultForCallsign(situation.getCallsign()); + bool CClientProvider::addClientGndCapability(const CCallsign &callsign) + { + CClient client = this->getClientOrDefaultForCallsign(callsign); // need to change? if (!client.isValid()) { return false; } // no client - if (client.hasGndFlagCapability()) { return false; } // already set + if (client.hasGndFlagCapability()) { return true; } // already set, but set client.addCapability(CClient::FsdWithGroundFlag); QWriteLocker l(&m_lockClient); @@ -145,6 +149,18 @@ namespace BlackMisc return 0; } + bool CClientAware::autoAdjustCientGndCapability(const CAircraftSituation &situation) + { + if (this->provider()) { return this->provider()->autoAdjustCientGndCapability(situation); } + return false; + } + + bool CClientAware::addClientGndCapability(const CCallsign &callsign) + { + if (this->provider()) { return this->provider()->addClientGndCapability(callsign); } + return false; + } + CClientProviderDummy *CClientProviderDummy::instance() { static CClientProviderDummy *dummy = new CClientProviderDummy(); diff --git a/src/blackmisc/network/clientprovider.h b/src/blackmisc/network/clientprovider.h index fc0050d2d..59bffcdf6 100644 --- a/src/blackmisc/network/clientprovider.h +++ b/src/blackmisc/network/clientprovider.h @@ -69,6 +69,10 @@ namespace BlackMisc //! Adjust gnd.flag capability from situation //! \threadsafe virtual bool autoAdjustCientGndCapability(const Aviation::CAircraftSituation &situation) = 0; + + //! Add gnd.flag capability + //! \threadsafe + virtual bool addClientGndCapability(const Aviation::CCallsign &callsign) = 0; }; //! Direct in memory access to client (network client) data @@ -88,6 +92,7 @@ namespace BlackMisc virtual int updateOrAddClient(const Aviation::CCallsign &callsign, const CPropertyIndexVariantMap &vm, bool skipEqualValues = true) override; virtual int removeClient(const Aviation::CCallsign &callsign) override; virtual bool autoAdjustCientGndCapability(const Aviation::CAircraftSituation &situation) override; + virtual bool addClientGndCapability(const Aviation::CCallsign &callsign) override; //! @} private: @@ -126,6 +131,12 @@ namespace BlackMisc //! \copydoc CClientProvider::removeClient int removeClient(const Aviation::CCallsign &callsign); + //! \copydoc CClientProvider::autoAdjustCientGndCapability + bool autoAdjustCientGndCapability(const Aviation::CAircraftSituation &situation); + + //! \copydoc CClientProvider::addClientGndCapability + bool addClientGndCapability(const Aviation::CCallsign &callsign); + //! Provider void setClientProvider(CClientProvider *provider) { this->setProvider(provider); } diff --git a/src/blackmisc/simulation/simulatedaircraft.cpp b/src/blackmisc/simulation/simulatedaircraft.cpp index 64a80bdf5..c5b8a5ed8 100644 --- a/src/blackmisc/simulation/simulatedaircraft.cpp +++ b/src/blackmisc/simulation/simulatedaircraft.cpp @@ -97,6 +97,7 @@ namespace BlackMisc { m_situation = situation; m_situation.setCallsign(this->getCallsign()); + this->setSupportingGndFlag(situation.hasInboundGroundDetails()); } const CAircraftIcaoCode &CSimulatedAircraft::getAircraftIcaoCode() const @@ -311,6 +312,7 @@ namespace BlackMisc case IndexRendered: return CVariant::fromValue(this->isRendered()); case IndexPartsSynchronized: return CVariant::fromValue(this->isPartsSynchronized()); case IndexFastPositionUpdates: return CVariant::fromValue(this->fastPositionUpdates()); + case IndexSupportsGndFlag: return CVariant::fromValue(this->isSupportingGndFlag()); case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved()); case IndexPilot: return m_pilot.propertyByIndex(index.copyFrontRemoved()); case IndexRelativeDistance: return m_relativeDistance.propertyByIndex(index.copyFrontRemoved()); @@ -350,6 +352,7 @@ namespace BlackMisc case IndexRendered: m_rendered = variant.toBool(); break; case IndexPartsSynchronized: m_partsSynchronized = variant.toBool(); break; case IndexFastPositionUpdates: m_fastPositionUpdates = variant.toBool(); break; + case IndexSupportsGndFlag: m_supportsGndFlag = variant.toBool(); break; case IndexLivery: Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported"); break; case IndexModel: m_models[CurrentModel].setPropertyByIndex(index.copyFrontRemoved(), variant); @@ -391,6 +394,7 @@ namespace BlackMisc case IndexRendered: return Compare::compare(m_rendered, compareValue.isRendered()); case IndexPartsSynchronized: return Compare::compare(m_partsSynchronized, compareValue.isPartsSynchronized()); case IndexFastPositionUpdates: return Compare::compare(m_fastPositionUpdates, compareValue.fastPositionUpdates()); + case IndexSupportsGndFlag: return Compare::compare(m_supportsGndFlag, compareValue.isSupportingGndFlag()); case IndexCombinedIcaoLiveryString: return this->getCombinedIcaoLiveryString(false).compare(compareValue.getCombinedIcaoLiveryString(false)); case IndexCombinedIcaoLiveryStringNetworkModel: return this->getCombinedIcaoLiveryString(true).compare(compareValue.getCombinedIcaoLiveryString(true)); default: diff --git a/src/blackmisc/simulation/simulatedaircraft.h b/src/blackmisc/simulation/simulatedaircraft.h index b723bea04..565fbdb16 100644 --- a/src/blackmisc/simulation/simulatedaircraft.h +++ b/src/blackmisc/simulation/simulatedaircraft.h @@ -88,7 +88,8 @@ namespace BlackMisc IndexEnabled, IndexRendered, IndexPartsSynchronized, - IndexFastPositionUpdates + IndexFastPositionUpdates, + IndexSupportsGndFlag }; //! Default constructor. @@ -419,6 +420,13 @@ namespace BlackMisc //! Set the synchronisation flag void setPartsSynchronized(bool synchronized) { m_partsSynchronized = synchronized; } + //! Is supporting gnd.flag? + bool isSupportingGndFlag() const { return m_supportsGndFlag; } + + //! Indicate gnd.flag is supported + //! \remark normally automatically set from BlackMisc::Aviation::CAircraftSituation::hasInboundGroundDetails + void setSupportingGndFlag(bool supports) { m_supportsGndFlag = supports; } + //! \copydoc BlackMisc::Mixin::Index::propertyByIndex CVariant propertyByIndex(const CPropertyIndex &index) const; @@ -442,11 +450,12 @@ namespace BlackMisc Aviation::CTransponder m_transponder; Aviation::CAircraftParts m_parts; Aviation::CSelcal m_selcal; - CAircraftModelList m_models = { { CAircraftModel(), CAircraftModel() } }; //!< Shorter DBus signature: current model, and model received from network + CAircraftModelList m_models = {{ CAircraftModel(), CAircraftModel() }}; //!< Shorter DBus signature: current model, and model received from network bool m_enabled = true; //!< to be displayed in simulator bool m_rendered = false; //!< really shown in simulator bool m_partsSynchronized = false; //!< synchronize parts bool m_fastPositionUpdates = false; //!< use fast position updates + bool m_supportsGndFlag = false; //!< supports gnd. flag //! Init, which synchronizes some denormalized values void init(); diff --git a/src/blackmisc/simulation/simulatedaircraftlist.cpp b/src/blackmisc/simulation/simulatedaircraftlist.cpp index ae4a19b5f..31d1934d1 100644 --- a/src/blackmisc/simulation/simulatedaircraftlist.cpp +++ b/src/blackmisc/simulation/simulatedaircraftlist.cpp @@ -180,7 +180,7 @@ namespace BlackMisc for (CSimulatedAircraft &aircraft : (*this)) { if (aircraft.getCallsign() != callsign) { continue; } - aircraft.setSituation(situation); + aircraft.setSituation(situation); // also sets setSupportingGndFlag if (onlyFirst) break; } return c;