mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T259, Ref T243 moved the "awareness" classes to the interfaces
* allows access to the awareness objects if only the interface is available * can change the provider via the interface
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
#define BLACKCORE_NETWORK_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||
#include "blackmisc/simulation/simulationenvironmentprovider.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
@@ -53,7 +55,10 @@ namespace BlackCore
|
||||
* which is connected to an INetwork slot, then at least one of those connections
|
||||
* must be a Qt::QueuedConnection.
|
||||
*/
|
||||
class BLACKCORE_EXPORT INetwork : public QObject
|
||||
class BLACKCORE_EXPORT INetwork :
|
||||
public QObject,
|
||||
public BlackMisc::Simulation::COwnAircraftAware, // network vatlib consumes own aircraft data and sets ICAO/callsign data
|
||||
public BlackMisc::Simulation::CSimulationEnvironmentAware // allows to consume ground elevations
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -61,7 +66,9 @@ namespace BlackCore
|
||||
/*!
|
||||
* Constructor
|
||||
*/
|
||||
INetwork(QObject *parent = nullptr) : QObject(parent) {}
|
||||
INetwork(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraft, QObject *parent = nullptr) :
|
||||
QObject(parent),
|
||||
BlackMisc::Simulation::COwnAircraftAware(ownAircraft) {}
|
||||
|
||||
public:
|
||||
/*!
|
||||
|
||||
@@ -14,21 +14,23 @@
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Weather;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
ISimulator::SimulatorStatus ISimulator::getSimulatorStatus() const
|
||||
{
|
||||
if (!this->isConnected()) { return Disconnected; }
|
||||
if (!this->isConnected()) { return ISimulator::Disconnected; }
|
||||
const SimulatorStatus status =
|
||||
Connected
|
||||
| (this->isSimulating() ? Simulating : static_cast<ISimulator::SimulatorStatusFlag>(0))
|
||||
| (this->isPaused() ? Paused : static_cast<ISimulator::SimulatorStatusFlag>(0));
|
||||
| (this->isSimulating() ? ISimulator::Simulating : static_cast<ISimulator::SimulatorStatusFlag>(0))
|
||||
| (this->isPaused() ? ISimulator::Paused : static_cast<ISimulator::SimulatorStatusFlag>(0));
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -39,12 +41,12 @@ namespace BlackCore
|
||||
|
||||
void ISimulator::registerHelp()
|
||||
{
|
||||
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv unload", "unload driver"});
|
||||
if (BlackConfig::CBuildConfig::isCompiledWithFsuipcSupport())
|
||||
if (CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
||||
CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
|
||||
CSimpleCommandParser::registerCommand({".drv unload", "unload driver"});
|
||||
if (CBuildConfig::isCompiledWithFsuipcSupport())
|
||||
{
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "enable/disable FSUIPC (if applicable)"});
|
||||
CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "enable/disable FSUIPC (if applicable)"});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +61,12 @@ namespace BlackCore
|
||||
return s.join(", ");
|
||||
}
|
||||
|
||||
ISimulator::ISimulator(QObject *parent) :
|
||||
ISimulator::ISimulator(IOwnAircraftProvider *ownAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider, IWeatherGridProvider *weatherGridProvider, QObject *parent) :
|
||||
QObject(parent),
|
||||
BlackMisc::CIdentifiable(this)
|
||||
COwnAircraftAware(ownAircraftProvider),
|
||||
CRemoteAircraftAware(remoteAircraftProvider),
|
||||
CWeatherGridAware(weatherGridProvider),
|
||||
CIdentifiable(this)
|
||||
{
|
||||
ISimulator::registerHelp();
|
||||
}
|
||||
@@ -114,5 +119,4 @@ namespace BlackCore
|
||||
this->stopImpl();
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -12,15 +12,19 @@
|
||||
#ifndef BLACKCORE_SIMULATOR_H
|
||||
#define BLACKCORE_SIMULATOR_H
|
||||
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackmisc/aviation/airportlist.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||
#include "blackmisc/simulation/simulatorinternals.h"
|
||||
#include "blackmisc/simulation/interpolatormulti.h"
|
||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||
#include "blackmisc/simulation/simulationenvironmentprovider.h"
|
||||
#include "blackmisc/aviation/airportlist.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/weather/weathergridprovider.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/pq/time.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -28,6 +32,7 @@
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include <QFlags>
|
||||
#include <QObject>
|
||||
@@ -37,13 +42,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation { class CCallsign; }
|
||||
namespace Network { class CTextMessage; }
|
||||
namespace Simulation
|
||||
{
|
||||
class CSimulatorInternals;
|
||||
class IOwnAircraftProvider;
|
||||
class IRemoteAircraftProvider;
|
||||
}
|
||||
namespace Weather { class IWeatherGridProvider; }
|
||||
}
|
||||
|
||||
namespace BlackCore
|
||||
@@ -51,9 +49,14 @@ namespace BlackCore
|
||||
//! Interface to a simulator.
|
||||
class BLACKCORE_EXPORT ISimulator :
|
||||
public QObject,
|
||||
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::Weather::CWeatherGridAware, // gain access to in memory weather grid
|
||||
public BlackMisc::Simulation::ISimulationEnvironmentProvider, // give access to elevation
|
||||
public BlackMisc::CIdentifiable
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackMisc::Simulation::ISimulationEnvironmentProvider)
|
||||
|
||||
public:
|
||||
//! ISimulator status
|
||||
@@ -228,7 +231,10 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
ISimulator(QObject *parent = nullptr);
|
||||
ISimulator(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! Are we connected to the simulator?
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
@@ -52,10 +52,7 @@ namespace BlackCore
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent)
|
||||
: ISimulator(parent),
|
||||
COwnAircraftAware(ownAircraftProvider),
|
||||
CRemoteAircraftAware(remoteAircraftProvider),
|
||||
CWeatherGridAware(weatherGridProvider),
|
||||
: ISimulator(ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent),
|
||||
m_simulatorPluginInfo(info)
|
||||
{
|
||||
this->setObjectName("Simulator: " + info.getIdentifier());
|
||||
|
||||
@@ -20,10 +20,7 @@
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/simulation/aircraftmodelsetloader.h"
|
||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
@@ -32,7 +29,7 @@
|
||||
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||
#include "blackmisc/simulation/interpolationhints.h"
|
||||
#include "blackmisc/simulation/interpolationlogger.h"
|
||||
#include "blackmisc/weather/weathergridprovider.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/pq/time.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
@@ -58,12 +55,7 @@ namespace BlackMisc
|
||||
namespace BlackCore
|
||||
{
|
||||
//! Common base class with providers, interface and some base functionality
|
||||
class BLACKCORE_EXPORT CSimulatorCommon :
|
||||
public BlackCore::ISimulator,
|
||||
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::Weather::CWeatherGridAware // gain access to in memory weather grid
|
||||
{
|
||||
class BLACKCORE_EXPORT CSimulatorCommon : public BlackCore::ISimulator {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -268,10 +260,10 @@ namespace BlackCore
|
||||
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
|
||||
int m_timerCounter = 0; //!< allows to calculate n seconds
|
||||
QTimer m_oneSecondTimer; //!< multi purpose timer
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
|
||||
|
||||
// statistics values of how often those functions are called
|
||||
// those are the added counters, overflow will not be an issue here (discussed in T171 review)
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
CNetworkVatlib::CNetworkVatlib(IOwnAircraftProvider *ownAircraft, QObject *parent)
|
||||
: INetwork(parent), COwnAircraftAware(ownAircraft),
|
||||
: INetwork(ownAircraft, parent),
|
||||
m_loginMode(LoginNormal),
|
||||
m_status(vatStatusDisconnected),
|
||||
m_tokenBucket(10, CTime(5, CTimeUnit::s()), 1)
|
||||
@@ -828,9 +828,9 @@ namespace BlackCore
|
||||
void CNetworkVatlib::onTextMessageReceived(VatFsdClient *, const char *from, const char *to, const char *msg, void *cbvar)
|
||||
{
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
CCallsign sender(self->fromFSD(from));
|
||||
CCallsign receiver(self->fromFSD(to));
|
||||
QString message(self->fromFSD(msg));
|
||||
const CCallsign sender(self->fromFSD(from));
|
||||
const CCallsign receiver(self->fromFSD(to));
|
||||
const QString message(self->fromFSD(msg));
|
||||
|
||||
// Other FSD servers send the controller ATIS as text message. The following conditions need to be met:
|
||||
// * non-VATSIM server. VATSIM has a specific ATIS message
|
||||
@@ -881,7 +881,7 @@ namespace BlackCore
|
||||
emit cbvar_cast(cbvar)->atcDisconnected(CCallsign(cbvar_cast(cbvar)->fromFSD(callsign), CCallsign::Atc));
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onPilotPositionUpdate(VatFsdClient *, const char *callsignChar , const VatPilotPosition *position, void *cbvar)
|
||||
void CNetworkVatlib::onPilotPositionUpdate(VatFsdClient *, const char *callsignChar, const VatPilotPosition *position, void *cbvar)
|
||||
{
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
|
||||
@@ -892,8 +892,7 @@ namespace BlackCore
|
||||
CHeading(position->heading, CHeading::True, CAngleUnit::deg()),
|
||||
CAngle(position->pitch, CAngleUnit::deg()),
|
||||
CAngle(position->bank, CAngleUnit::deg()),
|
||||
CSpeed(position->groundSpeed, CSpeedUnit::kts()),
|
||||
CAltitude({ 0, nullptr }, CAltitude::MeanSeaLevel)
|
||||
CSpeed(position->groundSpeed, CSpeedUnit::kts())
|
||||
);
|
||||
|
||||
//! we set a dynamically updating offset time here
|
||||
@@ -942,7 +941,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
CCallsign callsign(self->fromFSD(callsignChar), CCallsign::Aircraft);
|
||||
const CCallsign callsign(self->fromFSD(callsignChar), CCallsign::Aircraft);
|
||||
const QJsonObject packet = doc.object();
|
||||
if (packet == JsonPackets::aircraftConfigRequest())
|
||||
{
|
||||
@@ -966,8 +965,7 @@ namespace BlackCore
|
||||
CHeading(position->heading, CHeading::True, CAngleUnit::deg()),
|
||||
CAngle(position->pitch, CAngleUnit::deg()),
|
||||
CAngle(position->bank, CAngleUnit::deg()),
|
||||
CSpeed(0.0, nullptr), // There is no speed information in a interim packet
|
||||
CAltitude({ 0, nullptr }, CAltitude::MeanSeaLevel)
|
||||
CSpeed::null() // There is no speed information in a interim packet
|
||||
);
|
||||
situation.setCurrentUtcTime();
|
||||
situation.setTimeOffsetMs(c_interimPositionTimeOffsetMsec);
|
||||
@@ -1091,7 +1089,6 @@ namespace BlackCore
|
||||
Vat_SetFsdMessageHandler(m_net.data(), CNetworkVatlib::onRawFsdMessage, this);
|
||||
|
||||
if (setting.getFileWriteMode() == CRawFsdMessageSettings::None || setting.getFileDir().isEmpty()) { return; }
|
||||
|
||||
if (setting.getFileWriteMode() == CRawFsdMessageSettings::Truncate)
|
||||
{
|
||||
QString filePath = CFileUtils::appendFilePaths(setting.getFileDir(), "rawfsdmessages.log");
|
||||
@@ -1258,7 +1255,7 @@ namespace BlackCore
|
||||
int flags = 0;
|
||||
if (capabilityFlags & vatCapsAtcInfo) { flags |= AcceptsAtisResponses; }
|
||||
if (capabilityFlags & vatCapsFastPos) { flags |= SupportsInterimPosUpdates; }
|
||||
if (capabilityFlags & vatCapsAircraftInfo) { flags |= SupportsIcaoCodes; }
|
||||
if (capabilityFlags & vatCapsAircraftInfo) { flags |= SupportsIcaoCodes; }
|
||||
if (capabilityFlags & vatCapsAircraftConfig) { flags |= SupportsAircraftConfigs; }
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
emit self->capabilitiesReplyReceived(self->fromFSD(callsign), flags);
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackcore/vatsim/vatsimsettings.h"
|
||||
#include "blackmisc/tokenbucket.h"
|
||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
@@ -26,6 +24,7 @@
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/network/server.h"
|
||||
#include "blackmisc/network/textmessagelist.h"
|
||||
#include "blackmisc/tokenbucket.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
|
||||
@@ -56,9 +55,7 @@ namespace BlackCore
|
||||
namespace Vatsim
|
||||
{
|
||||
//! Implementation of INetwork using the vatlib shim
|
||||
class BLACKCORE_EXPORT CNetworkVatlib :
|
||||
public INetwork,
|
||||
public BlackMisc::Simulation::COwnAircraftAware // network vatlib consumes own aircraft data and sets ICAO/callsign data
|
||||
class BLACKCORE_EXPORT CNetworkVatlib : public INetwork
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user