Ref T261, detect gnd.flag (from network) suppport, display gnd.flag info in UI

* add flag info in simulated aircraft
* allow to display info  in UI
* unified naming to "contains" in situation list
* updated client provider
This commit is contained in:
Klaus Basan
2018-05-09 08:11:31 +02:00
parent 6e249aa15d
commit 7ad4c29d28
12 changed files with 87 additions and 16 deletions

View File

@@ -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");

View File

@@ -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:

View File

@@ -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}));

View File

@@ -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());

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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); }

View File

@@ -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:

View File

@@ -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();

View File

@@ -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;