mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T259, Ref T243 added setup provider to simulator interface/simulator common
This commit is contained in:
@@ -19,7 +19,7 @@ using namespace BlackMisc;
|
|||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Weather;
|
using namespace BlackMisc::Weather;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
@@ -34,6 +34,14 @@ namespace BlackCore
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CInterpolationAndRenderingSetupPerCallsign ISimulator::getInterpolationSetupConsolidated(const CCallsign &callsign) const
|
||||||
|
{
|
||||||
|
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign);
|
||||||
|
const CClient client = this->getClientOrDefaultForCallsign(callsign);
|
||||||
|
setup.consolidateWithClient(client);
|
||||||
|
return setup;
|
||||||
|
}
|
||||||
|
|
||||||
void ISimulator::registerHelp()
|
void ISimulator::registerHelp()
|
||||||
{
|
{
|
||||||
if (CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
if (CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
||||||
@@ -64,6 +72,7 @@ namespace BlackCore
|
|||||||
CRemoteAircraftAware(remoteAircraftProvider),
|
CRemoteAircraftAware(remoteAircraftProvider),
|
||||||
CWeatherGridAware(weatherGridProvider),
|
CWeatherGridAware(weatherGridProvider),
|
||||||
ISimulationEnvironmentProvider(pluginInfo),
|
ISimulationEnvironmentProvider(pluginInfo),
|
||||||
|
IInterpolationSetupProvider(),
|
||||||
CIdentifiable(this)
|
CIdentifiable(this)
|
||||||
{
|
{
|
||||||
ISimulator::registerHelp();
|
ISimulator::registerHelp();
|
||||||
|
|||||||
@@ -22,8 +22,10 @@
|
|||||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||||
#include "blackmisc/simulation/simulationenvironmentprovider.h"
|
#include "blackmisc/simulation/simulationenvironmentprovider.h"
|
||||||
|
#include "blackmisc/simulation/interpolationsetupprovider.h"
|
||||||
#include "blackmisc/aviation/airportlist.h"
|
#include "blackmisc/aviation/airportlist.h"
|
||||||
#include "blackmisc/aviation/callsignset.h"
|
#include "blackmisc/aviation/callsignset.h"
|
||||||
|
#include "blackmisc/network/clientprovider.h"
|
||||||
#include "blackmisc/weather/weathergridprovider.h"
|
#include "blackmisc/weather/weathergridprovider.h"
|
||||||
#include "blackmisc/pq/length.h"
|
#include "blackmisc/pq/length.h"
|
||||||
#include "blackmisc/pq/time.h"
|
#include "blackmisc/pq/time.h"
|
||||||
@@ -52,12 +54,14 @@ namespace BlackCore
|
|||||||
public BlackMisc::Simulation::COwnAircraftAware, // gain access to in memory own aircraft data
|
public BlackMisc::Simulation::COwnAircraftAware, // gain access to in memory own aircraft data
|
||||||
public BlackMisc::Simulation::CRemoteAircraftAware, // gain access to in memory remote aircraft data
|
public BlackMisc::Simulation::CRemoteAircraftAware, // gain access to in memory remote aircraft data
|
||||||
public BlackMisc::Weather::CWeatherGridAware, // gain access to in memory weather grid
|
public BlackMisc::Weather::CWeatherGridAware, // gain access to in memory weather grid
|
||||||
public BlackMisc::Simulation::ISimulationEnvironmentProvider, // give access to elevation
|
public BlackMisc::Network::CClientAware, // the network client with its capabilities
|
||||||
|
public BlackMisc::Simulation::ISimulationEnvironmentProvider, // give access to elevation etc.
|
||||||
|
public BlackMisc::Simulation::IInterpolationSetupProvider, // setup
|
||||||
public BlackMisc::CIdentifiable
|
public BlackMisc::CIdentifiable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(BlackMisc::Simulation::ISimulationEnvironmentProvider)
|
Q_INTERFACES(BlackMisc::Simulation::ISimulationEnvironmentProvider)
|
||||||
Q_INTERFACES(BlackMisc::IProvider)
|
Q_INTERFACES(BlackMisc::Simulation::IInterpolationSetupProvider)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! ISimulator status
|
//! ISimulator status
|
||||||
@@ -141,13 +145,13 @@ namespace BlackCore
|
|||||||
//! Time synchronization offset
|
//! Time synchronization offset
|
||||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const = 0;
|
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const = 0;
|
||||||
|
|
||||||
//! Debugging messages etc.
|
//! Consolidate setup with other data like from BlackMisc::Simulation::IRemoteAircraftProvider
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetup getInterpolationAndRenderingSetup() const = 0;
|
BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationSetupConsolidated(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||||
|
|
||||||
//! Enable debugging messages etc.
|
//! Enable debugging messages etc.
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup) = 0;
|
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) = 0;
|
||||||
|
|
||||||
//! Is the aircraft rendered (displayed in simulator)?
|
//! Is the aircraft rendered (displayed in simulator)?
|
||||||
//! This shall only return true if the aircraft is really visible in the simulator
|
//! This shall only return true if the aircraft is really visible in the simulator
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace BlackCore
|
|||||||
Q_ASSERT_X(remoteAircraft.hasModelString(), Q_FUNC_INFO, "Missing model string");
|
Q_ASSERT_X(remoteAircraft.hasModelString(), Q_FUNC_INFO, "Missing model string");
|
||||||
Q_ASSERT_X(remoteAircraft.hasCallsign(), Q_FUNC_INFO, "Missing callsign");
|
Q_ASSERT_X(remoteAircraft.hasCallsign(), Q_FUNC_INFO, "Missing callsign");
|
||||||
|
|
||||||
const bool renderingRestricted = this->getInterpolationAndRenderingSetup().isRenderingRestricted();
|
const bool renderingRestricted = this->getInterpolationSetupGlobal().isRenderingRestricted();
|
||||||
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Restricted: %1 cs: '%2' enabled: %3").arg(boolToYesNo(renderingRestricted), remoteAircraft.getCallsignAsString(), boolToYesNo(remoteAircraft.isEnabled()))); }
|
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Restricted: %1 cs: '%2' enabled: %3").arg(boolToYesNo(renderingRestricted), remoteAircraft.getCallsignAsString(), boolToYesNo(remoteAircraft.isEnabled()))); }
|
||||||
if (!remoteAircraft.isEnabled()) { return false; }
|
if (!remoteAircraft.isEnabled()) { return false; }
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ namespace BlackCore
|
|||||||
bool CSimulatorCommon::logicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
bool CSimulatorCommon::logicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
// if not restriced, directly change
|
// if not restriced, directly change
|
||||||
if (!this->getInterpolationAndRenderingSetup().isRenderingRestricted())
|
if (!this->getInterpolationSetupGlobal().isRenderingRestricted())
|
||||||
{
|
{
|
||||||
m_statsPhysicallyAddedAircraft++;
|
m_statsPhysicallyAddedAircraft++;
|
||||||
this->callPhysicallyRemoveRemoteAircraft(callsign); return true;
|
this->callPhysicallyRemoveRemoteAircraft(callsign); return true;
|
||||||
@@ -214,7 +214,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
bool CSimulatorCommon::showDebugLogMessage() const
|
bool CSimulatorCommon::showDebugLogMessage() const
|
||||||
{
|
{
|
||||||
return this->getInterpolationAndRenderingSetup().showSimulatorDebugMessages();
|
return this->getInterpolationSetupGlobal().showSimulatorDebugMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorCommon::reverseLookupAndUpdateOwnAircraftModel(const BlackMisc::Simulation::CAircraftModel &model)
|
void CSimulatorCommon::reverseLookupAndUpdateOwnAircraftModel(const BlackMisc::Simulation::CAircraftModel &model)
|
||||||
@@ -350,26 +350,15 @@ namespace BlackCore
|
|||||||
return renderedOnes.intersection(disabledOnes);
|
return renderedOnes.intersection(disabledOnes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorCommon::setInterpolationAndRenderingSetup(const CInterpolationAndRenderingSetup &setup)
|
void CSimulatorCommon::setInterpolationAndRenderingSetup(const CInterpolationAndRenderingSetupGlobal &setup)
|
||||||
{
|
{
|
||||||
{
|
if (!this->setInterpolationSetupGlobal(setup)) { return; }
|
||||||
QWriteLocker lock(&m_interpolationRenderingSetupMutex);
|
|
||||||
if (m_interpolationRenderingSetup == setup) { return; }
|
|
||||||
m_interpolationRenderingSetup = setup;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool r = setup.isRenderingRestricted();
|
const bool r = setup.isRenderingRestricted();
|
||||||
const bool e = setup.isRenderingEnabled();
|
const bool e = setup.isRenderingEnabled();
|
||||||
|
|
||||||
emit this->renderRestrictionsChanged(r, e, setup.getMaxRenderedAircraft(), setup.getMaxRenderedDistance());
|
emit this->renderRestrictionsChanged(r, e, setup.getMaxRenderedAircraft(), setup.getMaxRenderedDistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
CInterpolationAndRenderingSetup CSimulatorCommon::getInterpolationAndRenderingSetup() const
|
|
||||||
{
|
|
||||||
QReadLocker lock(&m_interpolationRenderingSetupMutex);
|
|
||||||
return m_interpolationRenderingSetup;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimulatorCommon::highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime)
|
void CSimulatorCommon::highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime)
|
||||||
{
|
{
|
||||||
const CCallsign cs(aircraftToHighlight.getCallsign());
|
const CCallsign cs(aircraftToHighlight.getCallsign());
|
||||||
@@ -424,16 +413,14 @@ namespace BlackCore
|
|||||||
if (part2 == "off" || part2 == "false")
|
if (part2 == "off" || part2 == "false")
|
||||||
{
|
{
|
||||||
CStatusMessage(this).info("Disabled interpolation logging");
|
CStatusMessage(this).info("Disabled interpolation logging");
|
||||||
QWriteLocker l(&m_interpolationRenderingSetupMutex);
|
this->clearInterpolationLogCallsigns();
|
||||||
m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (part2 == "clear" || part2 == "clr")
|
if (part2 == "clear" || part2 == "clr")
|
||||||
{
|
{
|
||||||
m_interpolationLogger.clearLog();
|
m_interpolationLogger.clearLog();
|
||||||
CStatusMessage(this).info("Cleared interpolation logging");
|
CStatusMessage(this).info("Cleared interpolation logging");
|
||||||
QWriteLocker l(&m_interpolationRenderingSetupMutex);
|
this->clearInterpolationLogCallsigns();
|
||||||
m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (part2.startsWith("max"))
|
if (part2.startsWith("max"))
|
||||||
@@ -449,10 +436,7 @@ namespace BlackCore
|
|||||||
if (part2 == "write" || part2 == "save")
|
if (part2 == "write" || part2 == "save")
|
||||||
{
|
{
|
||||||
// stop logging of other log
|
// stop logging of other log
|
||||||
{
|
this->clearInterpolationLogCallsigns();
|
||||||
QWriteLocker l(&m_interpolationRenderingSetupMutex);
|
|
||||||
m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
|
|
||||||
}
|
|
||||||
|
|
||||||
// write
|
// write
|
||||||
m_interpolationLogger.writeLogInBackground();
|
m_interpolationLogger.writeLogInBackground();
|
||||||
@@ -479,8 +463,7 @@ namespace BlackCore
|
|||||||
if (this->getAircraftInRangeCallsigns().contains(cs))
|
if (this->getAircraftInRangeCallsigns().contains(cs))
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Will log interpolation for '%1'") << cs.asString();
|
CLogMessage(this).info("Will log interpolation for '%1'") << cs.asString();
|
||||||
QWriteLocker l(&m_interpolationRenderingSetupMutex);
|
this->setLogCallsign(true, cs);
|
||||||
m_interpolationRenderingSetup.addCallsignToLog(cs);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -494,38 +477,25 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
const CCallsign cs(parser.hasPart(2) ? parser.part(2) : "");
|
const CCallsign cs(parser.hasPart(2) ? parser.part(2) : "");
|
||||||
const bool changed = this->setInterpolatorMode(CInterpolatorMulti::modeFromString(part1), cs);
|
const bool changed = this->setInterpolatorMode(CInterpolatorMulti::modeFromString(part1), cs);
|
||||||
CLogMessage(this).info(changed ?
|
CLogMessage(this).info(changed ? "Changed interpolation mode" : "Unchanged interpolation mode");
|
||||||
"Changed interpolation mode" :
|
|
||||||
"Unchanged interpolation mode");
|
|
||||||
return true;
|
return true;
|
||||||
} // spline/linear
|
} // spline/linear
|
||||||
|
|
||||||
if (part1.startsWith("pos"))
|
if (part1.startsWith("pos"))
|
||||||
{
|
{
|
||||||
CCallsign cs(parser.part(2).toUpper());
|
CCallsign cs(parser.part(2).toUpper());
|
||||||
const CInterpolationAndRenderingSetup s = this->getInterpolationAndRenderingSetup();
|
|
||||||
if (!cs.isValid())
|
if (!cs.isValid())
|
||||||
{
|
{
|
||||||
|
const CCallsignSet csSet = this->getLogCallsigns();
|
||||||
if (s.getLogCallsigns().size() != 1) { return false; }
|
if (csSet.size() != 1) { return false; }
|
||||||
|
|
||||||
// if there is just one we take that one
|
// if there is just one we take that one
|
||||||
cs = s.getLogCallsigns().toQList().front();
|
cs = *csSet.begin();
|
||||||
}
|
|
||||||
|
|
||||||
bool addedCallsign = false;
|
|
||||||
{
|
|
||||||
const bool isLoggedCallsign = s.isLogCallsign(cs);
|
|
||||||
QWriteLocker l(&m_interpolationRenderingSetupMutex);
|
|
||||||
if (!isLoggedCallsign)
|
|
||||||
{
|
|
||||||
m_interpolationRenderingSetup.addCallsignToLog(cs);
|
|
||||||
addedCallsign = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->setLogCallsign(true, cs);
|
||||||
CLogMessage(this).info("Display position for '%1'") << cs.asString();
|
CLogMessage(this).info("Display position for '%1'") << cs.asString();
|
||||||
this->displayLoggedSituationInSimulator(cs, addedCallsign);
|
this->displayLoggedSituationInSimulator(cs, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,8 +739,8 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (cs.isEmpty()) { return; }
|
if (cs.isEmpty()) { return; }
|
||||||
if (this->isShuttingDown()) { return; }
|
if (this->isShuttingDown()) { return; }
|
||||||
const CInterpolationAndRenderingSetup setup = this->getInterpolationAndRenderingSetup();
|
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(cs);
|
||||||
const bool logsCs = setup.isLogCallsign(cs);
|
const bool logsCs = setup.logInterpolation();
|
||||||
if (!logsCs) { return; }
|
if (!logsCs) { return; }
|
||||||
|
|
||||||
stopLogging = stopLogging || !this->isSimulating(); // stop when sim was stopped
|
stopLogging = stopLogging || !this->isSimulating(); // stop when sim was stopped
|
||||||
@@ -781,8 +751,7 @@ namespace BlackCore
|
|||||||
if (!stopLogging && !inRange) { return; }
|
if (!stopLogging && !inRange) { return; }
|
||||||
if (stopLogging && (times < 1 || !inRange))
|
if (stopLogging && (times < 1 || !inRange))
|
||||||
{
|
{
|
||||||
QWriteLocker wl(&m_interpolationRenderingSetupMutex);
|
this->setLogCallsign(false, cs);
|
||||||
m_interpolationRenderingSetup.removeCallsignFromLog(cs);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ namespace BlackCore
|
|||||||
virtual ~CSimulatorCommon();
|
virtual ~CSimulatorCommon();
|
||||||
|
|
||||||
// --------- ISimulator implementations ------------
|
// --------- ISimulator implementations ------------
|
||||||
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup) override;
|
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override;
|
||||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetup getInterpolationAndRenderingSetup() const override;
|
|
||||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const override;
|
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const override;
|
||||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||||
@@ -220,10 +219,6 @@ namespace BlackCore
|
|||||||
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
||||||
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log interpolation
|
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log interpolation
|
||||||
|
|
||||||
// setup for logging etc.
|
|
||||||
mutable QReadWriteLock m_interpolationRenderingSetupMutex; //!< mutex protecting setup object
|
|
||||||
BlackMisc::Simulation::CInterpolationAndRenderingSetup m_interpolationRenderingSetup; //!< logging, rendering etc.
|
|
||||||
|
|
||||||
// some optional functionality which can be used by the simulators as needed
|
// some optional functionality which can be used by the simulators as needed
|
||||||
BlackMisc::Simulation::CSimulatedAircraftList m_addAgainAircraftWhenRemoved; //!< add this model again when removed, normally used to change model
|
BlackMisc::Simulation::CSimulatedAircraftList m_addAgainAircraftWhenRemoved; //!< add this model again when removed, normally used to change model
|
||||||
QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CInterpolationHints> m_hints; //!< hints for callsign, contains last ground elevation fetched
|
QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CInterpolationHints> m_hints; //!< hints for callsign, contains last ground elevation fetched
|
||||||
|
|||||||
Reference in New Issue
Block a user