refs #391, allow to send aircraft parts from GUI

* GUI component for aircraft parts
* remote aircraft selector component
* Adjusted GUI for internals component
* Enable / disable debug messages from GUI
* Allow to init engines directly
* Removed unused async sort in sequence

In same step fixed found issues in interpolator
* allow to set max rendered aircraft
This commit is contained in:
Klaus Basan
2015-03-07 03:34:17 +01:00
parent f31445e873
commit 5ed95aee3d
63 changed files with 1575 additions and 165 deletions

View File

@@ -54,7 +54,7 @@ namespace BlackCore
this->connect(this->m_vatsimDataFileReader, &CVatsimDataFileReader::dataRead, this, &CAirspaceMonitor::ps_receivedDataFile);
// Watchdog
// ATC stations send updates every 25 s. Configure timeout after 50 s.
// ATC stations send updates every 25s. Configure timeout after 50s.
this->m_atcWatchdog.setTimeout(CTime(50, CTimeUnit::s()));
this->connect(&this->m_aircraftWatchdog, &CAirspaceWatchdog::timeout, this, &CAirspaceMonitor::ps_pilotDisconnected);
this->connect(&this->m_atcWatchdog, &CAirspaceWatchdog::timeout, this, &CAirspaceMonitor::ps_atcControllerDisconnected);
@@ -338,13 +338,18 @@ namespace BlackCore
void CAirspaceMonitor::testCreateDummyOnlineAtcStations(int number)
{
if (number < 1) return;
if (number < 1) { return; }
this->m_atcStationsOnline.push_back(
BlackMisc::Aviation::CTesting::createAtcStations(number)
);
emit this->changedAtcStationsOnline();
}
void CAirspaceMonitor::testAddAircraftParts(const CAircraftParts &parts, bool incremental)
{
this->ps_aircraftConfigReceived(parts.getCallsign(), parts.toJson(), !incremental);
}
void CAirspaceMonitor::clear()
{
m_metarCache.clear();
@@ -573,7 +578,7 @@ namespace BlackCore
// build simulated aircraft and crosscheck if all data are available
CSimulatedAircraft remoteAircraft(this->m_aircraftInRange.findFirstByCallsign(callsign));
Q_ASSERT(remoteAircraft.hasValidCallsign());
Q_ASSERT_X(remoteAircraft.hasValidCallsign(), "ps_sendReadyForModelMatching", "Inavlid callsign");
CClient remoteClient = this->m_otherClients.findFirstByCallsign(callsign);
remoteAircraft.setClient(remoteClient);
remoteAircraft.setModel(remoteClient.getAircraftModel());
@@ -753,15 +758,20 @@ namespace BlackCore
void CAirspaceMonitor::ps_aircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
{
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
Q_ASSERT_X(BlackCore::isCurrentThreadCreatingThread(this), "ps_aircraftUpdateReceived", "Called in different thread");
if (!this->m_connected) { return; }
CCallsign callsign(situation.getCallsign());
Q_ASSERT(!callsign.isEmpty());
Q_ASSERT_X(!callsign.isEmpty(), "ps_aircraftUpdateReceived", "Empty callsign");
if (callsign.isObserverCallsign())
{
return; // just ignore
}
// store situation history
// this->m_aircraftSituations.insert_front(situation);
// this->m_aircraftSituations.removeOlderThanNowMinusOffset(AircraftSituationsRemovedOffsetMs);
this->m_aircraftSituations.push_front(situation);
this->m_aircraftSituations.removeOlderThanNowMinusOffset(AircraftSituationsRemovedOffsetMs);
emit this->addedRemoteAircraftSituation(situation);
bool exists = this->m_aircraftInRange.containsCallsign(callsign);
@@ -846,6 +856,8 @@ namespace BlackCore
// if with contains false remove here, in case of inconsistencies
this->m_aircraftWatchdog.removeCallsign(callsign);
this->m_otherClients.removeByCallsign(callsign);
this->m_aircraftSituations.removeByCallsign(callsign);
this->m_aircraftParts.removeByCallsign(callsign);
this->removeFromAircraftCaches(callsign);
if (contains)
@@ -865,29 +877,38 @@ namespace BlackCore
if (changed > 0) { emit this->changedAircraftInRange(); }
}
void CAirspaceMonitor::ps_aircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &incremental, bool isFull)
void CAirspaceMonitor::ps_aircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, bool isFull)
{
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
CSimulatedAircraftList list = this->m_aircraftInRange.findByCallsign(callsign);
// Skip unknown callsigns
if (list.isEmpty()) return;
if (list.isEmpty()) { return; }
CSimulatedAircraft simAircraft = list.front();
// If we are not yet synchronized, we throw away any incremental packet
if (!simAircraft.isPartsSynchronized() && !isFull) return;
if (!simAircraft.isPartsSynchronized() && !isFull) { return; }
CAircraftParts parts = m_aircraftParts.findBackByCallsign(callsign);
CAircraftParts parts;
if (isFull)
{
parts.convertFromJson(jsonObject);
}
else
{
// incremental update
parts = m_aircraftParts.findFirstByCallsign(callsign);
QJsonObject config = applyIncrementalObject(parts.toJson(), jsonObject);
parts.convertFromJson(config);
}
// make sure in any case right time / callsign
parts.setCurrentUtcTime();
parts.setCallsign(callsign); // for default values
// update
QJsonObject config = applyIncrementalObject(parts.toJson(), incremental);
parts.convertFromJson(config);
parts.setCallsign(callsign);
// store part history
// this->m_aircraftParts.insert_front(parts);
// this->m_aircraftParts.removeOlderThanNowMinusOffset(AircraftPartsRemoveOffsetMs);
this->m_aircraftParts.push_front(parts);
this->m_aircraftParts.removeOlderThanNowMinusOffset(AircraftPartsRemoveOffsetMs);
emit this->addedRemoteAircraftParts(parts);
CPropertyIndexVariantMap vm;

View File

@@ -111,6 +111,9 @@ namespace BlackCore
//! Create dummy entries for performance tests
void testCreateDummyOnlineAtcStations(int number);
//! Test injected aircraft parts
void testAddAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts, bool incremental);
//! Aircraft situations
virtual BlackMisc::Aviation::CAircraftSituationList getRenderedAircraftSituations() const;
@@ -219,7 +222,7 @@ namespace BlackCore
void ps_frequencyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency);
void ps_receivedBookings(const BlackMisc::Aviation::CAtcStationList &bookedStations);
void ps_receivedDataFile();
void ps_aircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &incremental, bool isFull);
void ps_aircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, bool isFull);
//! Send the information if aircraft and(!) client are vailable
void ps_sendReadyForModelMatching(const BlackMisc::Aviation::CCallsign &callsign, int trial);

View File

@@ -70,6 +70,16 @@ namespace BlackCore
return this->getRuntime()->getIContextSimulator();
}
void CContext::setDebugEnabled(bool debug)
{
this->m_debugEnabled = debug;
}
bool CContext::isDebugEnabled() const
{
return this->m_debugEnabled;
}
const IContextSimulator *CContext::getIContextSimulator() const
{
return this->getRuntime()->getIContextSimulator();

View File

@@ -112,6 +112,12 @@ namespace BlackCore
//! Simulator
IContextSimulator *getIContextSimulator();
//! Set debug flag
void setDebugEnabled(bool debug);
//! Debug enabled?
bool isDebugEnabled() const;
//! Id and path name for round trip protection
virtual QString getPathAndContextId() const = 0;
@@ -136,6 +142,8 @@ namespace BlackCore
BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).warning("Empty context called, details: %1") << functionName;
}
bool m_debugEnabled = false; //!< debug messages enabled
//! Standard message when status message is returned in empty context
static const BlackMisc::CStatusMessage &statusMessageEmptyContext();
};

View File

@@ -71,6 +71,9 @@ namespace BlackCore
//! An aircraft disappeared
void removedAircraft(const BlackMisc::Aviation::CCallsign &callsign);
//! A new aircraft appeared
void addedAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft);
//! Read for model matching
void readyForModelMatching(const BlackMisc::Simulation::CSimulatedAircraft &renderedAircraft);
@@ -218,6 +221,9 @@ namespace BlackCore
//! Create dummy ATC stations for performance tests etc.
virtual void testCreateDummyOnlineAtcStations(int number) = 0;
//! Inject aircraft parts for testing
virtual void testAddAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) = 0;
protected:
//! Constructor
IContextNetwork(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}

View File

@@ -190,6 +190,14 @@ namespace BlackCore
logEmptyContextWarning(Q_FUNC_INFO);
}
//! \copydoc IContextNetwork::testAddAircraftParts
virtual void testAddAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override
{
Q_UNUSED(parts);
Q_UNUSED(incremental);
logEmptyContextWarning(Q_FUNC_INFO);
}
//! \copydoc IContextNetwork::parseCommandLine
virtual bool parseCommandLine(const QString &commandLine) override
{

View File

@@ -81,6 +81,7 @@ namespace BlackCore
connect(this->m_airspace, &CAirspaceMonitor::readyForModelMatching, this, &CContextNetwork::readyForModelMatching);
connect(this->m_airspace, &CAirspaceMonitor::addedRemoteAircraftParts, this, &CContextNetwork::addedRemoteAircraftParts);
connect(this->m_airspace, &CAirspaceMonitor::addedRemoteAircraftSituation, this, &CContextNetwork::addedRemoteAircraftSituation);
connect(this->m_airspace, &CAirspaceMonitor::addedAircraft, this, &CContextNetwork::addedAircraft);
}
CContextNetwork::~CContextNetwork()
@@ -142,7 +143,7 @@ namespace BlackCore
CStatusMessage CContextNetwork::connectToNetwork(const CServer &server, uint loginMode)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) {CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
QString msg;
if (!server.getUser().isValid())
{
@@ -182,7 +183,7 @@ namespace BlackCore
CStatusMessage CContextNetwork::disconnectFromNetwork()
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (this->m_network->isConnected())
{
this->m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect
@@ -202,7 +203,7 @@ namespace BlackCore
bool CContextNetwork::isConnected() const
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_network->isConnected();
}
@@ -223,30 +224,32 @@ namespace BlackCore
void CContextNetwork::sendTextMessages(const CTextMessageList &textMessages)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << textMessages;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << textMessages; }
this->m_network->sendTextMessages(textMessages);
}
void CContextNetwork::sendFlightPlan(const CFlightPlan &flightPlan)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << flightPlan;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << flightPlan; }
this->m_network->sendFlightPlan(flightPlan);
this->m_network->sendFlightPlanQuery(this->ownAircraft().getCallsign());
}
CFlightPlan CContextNetwork::loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->loadFlightPlanFromNetwork(callsign);
}
CUserList CContextNetwork::getUsers() const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getUsers();
}
CUserList CContextNetwork::getUsersForCallsigns(const CCallsignList &callsigns) const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CUserList users;
if (callsigns.isEmpty()) return users;
return this->m_airspace->getUsersForCallsigns(callsigns);
@@ -254,6 +257,7 @@ namespace BlackCore
CUser CContextNetwork::getUserForCallsign(const CCallsign &callsign) const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CCallsignList callsigns;
callsigns.push_back(callsign);
CUserList users = this->getUsersForCallsigns(callsigns);
@@ -263,23 +267,28 @@ namespace BlackCore
CClientList CContextNetwork::getOtherClients() const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getOtherClients();
}
CClientList CContextNetwork::getOtherClientsForCallsigns(const CCallsignList &callsigns) const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getOtherClientsForCallsigns(callsigns);
}
CServerList CContextNetwork::getVatsimFsdServers() const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
Q_ASSERT(this->m_vatsimDataFileReader);
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
return this->m_vatsimDataFileReader->getFsdServers();
}
CServerList CContextNetwork::getVatsimVoiceServers() const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
Q_ASSERT(this->m_vatsimDataFileReader);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
return this->m_vatsimDataFileReader->getVoiceServers();
@@ -287,7 +296,7 @@ namespace BlackCore
void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << from << to;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << from << to; }
auto fromOld = this->m_currentStatus; // own status cached
this->m_currentStatus = to;
@@ -327,14 +336,14 @@ namespace BlackCore
void CContextNetwork::ps_dataFileRead()
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CLogMessage(this).info("Read VATSIM data file");
emit vatsimDataFileRead();
}
void CContextNetwork::ps_fsdTextMessageReceived(const CTextMessageList &messages)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << messages;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << messages; }
this->textMessagesReceived(messages); // relay
}
@@ -354,31 +363,31 @@ namespace BlackCore
CAtcStationList CContextNetwork::getAtcStationsOnline() const
{
BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getAtcStationsOnline();
}
CAtcStationList CContextNetwork::getAtcStationsBooked() const
{
BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->getAtcStationsBooked();
}
CSimulatedAircraftList CContextNetwork::getAircraftInRange() const
{
BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return this->m_airspace->remoteAircraft();
}
CSimulatedAircraft CContextNetwork::getAircraftForCallsign(const CCallsign &callsign) const
{
BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign;
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->remoteAircraft().findFirstByCallsign(callsign);
}
void CContextNetwork::ps_receivedBookings(const CAtcStationList &)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CLogMessage(this).info("Read bookings from network");
emit vatsimBookingsRead();
}
@@ -386,7 +395,7 @@ namespace BlackCore
void CContextNetwork::requestDataUpdates()
{
Q_ASSERT(this->m_network);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (!this->isConnected()) { return; }
this->requestAtisUpdates();
@@ -396,7 +405,7 @@ namespace BlackCore
void CContextNetwork::requestAtisUpdates()
{
Q_ASSERT(this->m_network);
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (!this->isConnected()) { return; }
this->m_airspace->requestAtisUpdates();
@@ -404,7 +413,7 @@ namespace BlackCore
bool CContextNetwork::updateAircraftEnabled(const CCallsign &callsign, bool enabledForRedering, const QString &originator)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << enabledForRedering << originator;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << enabledForRedering << originator; }
bool c = this->m_airspace->updateAircraftEnabled(callsign, enabledForRedering, originator);
if (c)
{
@@ -415,7 +424,7 @@ namespace BlackCore
bool CContextNetwork::updateAircraftModel(const CCallsign &callsign, const CAircraftModel &model, const QString &originator)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << model << originator;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign << model << originator; }
bool c = this->m_airspace->updateAircraftModel(callsign, model, originator);
if (c)
{
@@ -426,32 +435,39 @@ namespace BlackCore
bool CContextNetwork::isInterimPositionSendingEnabled() const
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
Q_ASSERT(this->m_network);
return m_network->isInterimPositionSendingEnabled();
}
void CContextNetwork::enableInterimPositionSending(bool enable)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enable;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enable; }
Q_ASSERT(this->m_network);
m_network->enableInterimPositionSending(enable);
}
void CContextNetwork::testCreateDummyOnlineAtcStations(int number)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << number;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << number; }
this->m_airspace->testCreateDummyOnlineAtcStations(number);
}
void CContextNetwork::testAddAircraftParts(const CAircraftParts &parts, bool incremental)
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << parts << incremental; }
this->m_airspace->testAddAircraftParts(parts, incremental);
}
BlackMisc::Aviation::CInformationMessage CContextNetwork::getMetar(const BlackMisc::Aviation::CAirportIcao &airportIcaoCode)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << airportIcaoCode;
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << airportIcaoCode; }
return m_airspace->getMetar(airportIcaoCode);
}
CAtcStationList CContextNetwork::getSelectedAtcStations() const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CAtcStation com1Station = this->m_airspace->getAtcStationForComUnit(this->ownAircraft().getCom1System());
CAtcStation com2Station = this->m_airspace->getAtcStationForComUnit(this->ownAircraft().getCom2System());
@@ -463,6 +479,7 @@ namespace BlackCore
CVoiceRoomList CContextNetwork::getSelectedVoiceRooms() const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CAtcStationList stations = this->getSelectedAtcStations();
Q_ASSERT(stations.size() == 2);
CVoiceRoomList rooms;

View File

@@ -184,6 +184,9 @@ namespace BlackCore
//! \copydoc IContextNetwork::testCreateDummyOnlineAtcStations
virtual void testCreateDummyOnlineAtcStations(int number) override;
//! \copydoc IContextNetwork::testAddAircraftParts
virtual void testAddAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override;
//! Gracefully shut down, e.g. for thread safety
void gracefulShutdown();

View File

@@ -78,7 +78,12 @@ namespace BlackCore
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAircraftEnabled", this, SIGNAL(changedAircraftEnabled(BlackMisc::Simulation::CSimulatedAircraft, QString)));
Q_ASSERT(s);
Q_UNUSED(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"addedAircraft", this, SIGNAL(addedAircraft(BlackMisc::Simulation::CSimulatedAircraft)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"removedAircraft", this, SIGNAL(removedAircraft(BlackMisc::Aviation::CCallsign)));
Q_ASSERT(s);
}
void CContextNetworkProxy::readAtcBookingsFromSource() const
@@ -186,6 +191,11 @@ namespace BlackCore
this->m_dBusInterface->callDBus(QLatin1Literal("testCreateDummyOnlineAtcStations"), number);
}
void CContextNetworkProxy::testAddAircraftParts(const CAircraftParts &parts, bool incremental)
{
this->m_dBusInterface->callDBus(QLatin1Literal("testAddAircraftParts"), parts, incremental);
}
CStatusMessage CContextNetworkProxy::connectToNetwork(const CServer &server, uint loginMode)
{
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1Literal("connectToNetwork"), server, loginMode);

View File

@@ -140,6 +140,9 @@ namespace BlackCore
//! \copydoc IContextNetwork::testCreateDummyOnlineAtcStations
virtual void testCreateDummyOnlineAtcStations(int number) override;
//! \copydoc IContextNetwork::testAddAircraftParts
virtual void testAddAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override;
};
}

View File

@@ -1,7 +1,11 @@
/* Copyright (C) 2013 VATSIM Community / contributors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "context_ownaircraft.h"
#include "context_ownaircraft_impl.h"

View File

@@ -1,7 +1,11 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "blackcore/context_ownaircraft_proxy.h"
#include <QObject>

View File

@@ -137,8 +137,8 @@ namespace BlackCore
//! Max. number of remote aircraft rendered
virtual int getMaxRenderedAircraft() const = 0;
//! Max. number of remote aircraft rendered
virtual void setMaxRenderedAircraft(int number) = 0;
//! Max. number of remote aircraft rendered and provide optional selection which aircraft this are
virtual void setMaxRenderedAircraft(int number, const BlackMisc::Aviation::CCallsignList &renderedAircraft) = 0;
//! Time synchronization offset
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const = 0;
@@ -164,6 +164,9 @@ namespace BlackCore
//! Icon representing the model
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const = 0;
//! Enable debugging
virtual void enableDebugMessages(bool driver, bool interpolator) = 0;
protected:
//! Constructor
IContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}

View File

@@ -158,13 +158,13 @@ namespace BlackCore
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (!m_simulator) return 0;
return 13;
return m_simulator->getMaxRenderedAircraft();
}
void CContextSimulator::setMaxRenderedAircraft(int number)
void CContextSimulator::setMaxRenderedAircraft(int number, const CCallsignList &renderedAircraft)
{
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
if (m_simulator) { this->m_simulator->setMaxRenderedAircraft(number); }
if (m_simulator) { this->m_simulator->setMaxRenderedAircraft(number, renderedAircraft); }
}
CTime CContextSimulator::getTimeSynchronizationOffset() const
@@ -263,7 +263,7 @@ namespace BlackCore
bool CContextSimulator::loadSimulatorPluginFromSettings()
{
Q_ASSERT(this->getIContextSettings());
if (!this->getIContextSettings()) return false;
if (!this->getIContextSettings()) { return false; }
// TODO warnings if we didn't load the plugin which the settings asked for
@@ -398,6 +398,12 @@ namespace BlackCore
return this->m_simulator->iconForModel(modelString);
}
void CContextSimulator::enableDebugMessages(bool driver, bool interpolator)
{
if (!this->m_simulator) { return; }
return this->m_simulator->enableDebugMessages(driver, interpolator);
}
bool CContextSimulator::isPaused() const
{
if (!this->m_simulator) return false;

View File

@@ -90,7 +90,7 @@ namespace BlackCore
virtual int getMaxRenderedAircraft() const override;
//! \copydoc IContextSimulator::setMaxRenderedAircraft
virtual void setMaxRenderedAircraft(int number) override;
virtual void setMaxRenderedAircraft(int number, const BlackMisc::Aviation::CCallsignList &renderedAircraft) override;
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
@@ -110,6 +110,9 @@ namespace BlackCore
//! \copydoc IContextSimulator::iconForModel
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
//! \copydoc ISimulator::enableDebuggingMessages
virtual void enableDebugMessages(bool driver, bool interpolator) override;
protected:
//! \brief Constructor
CContextSimulator(CRuntimeConfig::ContextMode, CRuntime *runtime);

View File

@@ -119,9 +119,9 @@ namespace BlackCore
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isTimeSynchronized"));
}
void CContextSimulatorProxy::setMaxRenderedAircraft(int number)
void CContextSimulatorProxy::setMaxRenderedAircraft(int number, const CCallsignList &renderedAircraft)
{
m_dBusInterface->callDBus(QLatin1Literal("setMaxRenderedRemoteAircraft"), number);
m_dBusInterface->callDBus(QLatin1Literal("setMaxRenderedRemoteAircraft"), number, renderedAircraft);
}
int CContextSimulatorProxy::getMaxRenderedAircraft() const
@@ -159,6 +159,11 @@ namespace BlackCore
return m_dBusInterface->callDBusRet<CPixmap>(QLatin1Literal("iconForModel"), modelString);
}
void CContextSimulatorProxy::enableDebugMessages(bool driver, bool interpolator)
{
m_dBusInterface->callDBus(QLatin1Literal("enableDebugMessages"), driver, interpolator);
}
bool CContextSimulatorProxy::isPaused() const
{
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isPaused"));

View File

@@ -93,7 +93,7 @@ namespace BlackCore
virtual int getMaxRenderedAircraft() const override;
//! \copydoc IContextSimulator::setMaxRenderedRemoteAircraft
virtual void setMaxRenderedAircraft(int number) override;
virtual void setMaxRenderedAircraft(int number, const BlackMisc::Aviation::CCallsignList &renderedAircraft) override;
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
@@ -113,6 +113,9 @@ namespace BlackCore
//! \copydoc IContextSimulator::iconForModel
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
//! \copydoc ISimulator::enableDebuggingMessages
virtual void enableDebugMessages(bool driver, bool interpolator) override;
};
} // namespace BlackCore

View File

@@ -69,6 +69,7 @@ namespace BlackCore
CAircraftPartsList IInterpolator::getAndRemovePartsBeforeTime(const CCallsign &callsign, qint64 cutoffTime, BlackCore::IInterpolator::PartsStatus &partsStatus)
{
static const CAircraftPartsList empty;
Q_ASSERT_X(!callsign.isEmpty(), "getAndRemovePartsBeforeTime", "empty callsign");
partsStatus.reset();
QWriteLocker l(&m_lockParts);
if (this->m_partsByCallsign.contains(callsign))
@@ -108,7 +109,12 @@ namespace BlackCore
return m_partsByCallsign[callsign];
}
void IInterpolator::forceSorting(bool sort)
void IInterpolator::enableDebugMessages(bool enabled)
{
this->m_withDebugMsg = enabled;
}
void IInterpolator::forceSortingOfAddedValues(bool sort)
{
this->m_forceSortWhenAddingValues = sort;
}
@@ -117,7 +123,7 @@ namespace BlackCore
{
QWriteLocker lock(&m_lockSituations);
const CCallsign callsign(situation.getCallsign());
Q_ASSERT(!callsign.isEmpty());
Q_ASSERT_X(!callsign.isEmpty(), "ps_onAddedAircraftSituation", "empty callsign");
if (callsign.isEmpty()) { return; }
if (this->m_withDebugMsg) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << situation.getCallsign() << situation.getMSecsSinceEpoch(); }
@@ -134,7 +140,7 @@ namespace BlackCore
{
QWriteLocker lock(&m_lockParts);
const CCallsign callsign(parts.getCallsign());
Q_ASSERT(!callsign.isEmpty());
Q_ASSERT_X(!callsign.isEmpty(), "ps_onAddedAircraftParts", "empty callsign");
if (callsign.isEmpty()) { return; }
if (this->m_withDebugMsg) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << parts.getCallsign() << parts.getMSecsSinceEpoch(); }
@@ -148,7 +154,6 @@ namespace BlackCore
// check sort order
Q_ASSERT(l.size() < 2 || l[0].getMSecsSinceEpoch() >= l[1].getMSecsSinceEpoch());
}
void IInterpolator::ps_onRemovedAircraft(const CCallsign &callsign)

View File

@@ -103,7 +103,7 @@ namespace BlackCore
void enableDebugMessages(bool enabled);
//! Force sorting (latest first), not required if order can be guaranteed
void forceSorting(bool sort);
void forceSortingOfAddedValues(bool sort);
static const qint64 TimeOffsetMs = 6000; //!< offset for interpolation
static const int MaxSituationsPerCallsign = 6; //!< How many situations per callsign

View File

@@ -28,9 +28,10 @@ namespace BlackCore
return m_maxRenderedAircraft;
}
void CSimulatorCommon::setMaxRenderedAircraft(int maxRenderedAircraft)
void CSimulatorCommon::setMaxRenderedAircraft(int maxRenderedAircraft, const BlackMisc::Aviation::CCallsignList &callsigns)
{
m_maxRenderedAircraft = maxRenderedAircraft;
m_callsignsToBeRendered = callsigns;
}
CSimulatorInfo CSimulatorCommon::getSimulatorInfo() const
@@ -38,4 +39,10 @@ namespace BlackCore
return m_simulatorInfo;
}
void CSimulatorCommon::enableDebugMessages(bool driver, bool interpolator)
{
this->m_debugMessages = driver;
Q_UNUSED(interpolator);
}
} // namespace

View File

@@ -126,7 +126,10 @@ namespace BlackCore
virtual int getMaxRenderedAircraft() const = 0;
//! Max. rendered aircraft
virtual void setMaxRenderedAircraft(int maxRenderedAircraft) = 0;
virtual void setMaxRenderedAircraft(int maxRenderedAircraft, const BlackMisc::Aviation::CCallsignList &callsigns) = 0;
//! Enable debugging messages
virtual void enableDebugMessages(bool driver, bool interpolator) = 0;
signals:
//! Emitted when the connection status has changed
@@ -187,20 +190,26 @@ namespace BlackCore
//! Common base class with providers, interface and some base functionality
class CSimulatorCommon :
public BlackCore::ISimulator,
public BlackMisc::Simulation::COwnAircraftProviderSupport, // gain access to in memor own aircraft data
public BlackMisc::Simulation::COwnAircraftProviderSupport, // gain access to in memor own aircraft data
public BlackMisc::Simulation::CRemoteAircraftProviderSupport // gain access to in memory rendered aircraft data
{
public:
Q_OBJECT
public slots:
//! \copydoc ISimulator::getMaxRenderedAircraft
int getMaxRenderedAircraft() const override;
virtual int getMaxRenderedAircraft() const override;
//! \copydoc ISimulator::setMaxRenderedAircraft
void setMaxRenderedAircraft(int maxRenderedAircraft) override;
virtual void setMaxRenderedAircraft(int maxRenderedAircraft, const BlackMisc::Aviation::CCallsignList &callsigns) override;
//! \copydoc ISimulator::getSimulatorInfo
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
//! \copydoc ISimulator::enableDebuggingMessages
virtual void enableDebugMessages(bool driver, bool interpolator) override;
protected:
//! Constructor
CSimulatorCommon(
@@ -211,6 +220,8 @@ namespace BlackCore
BlackSim::CSimulatorInfo m_simulatorInfo; //!< about the simulator
int m_maxRenderedAircraft = 99; //!< max. rendered aircraft
bool m_debugMessages = false; //!< Display debug messages
BlackMisc::Aviation::CCallsignList m_callsignsToBeRendered; //!< all other aircraft are to be ignored
};
} // namespace