mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:07:20 +08:00
Add control button to activate and deactivate swift weather
- GUI changes - Context and ISimulator APIs - Refactored settings and static weather injection in CSimulatorCommon refs #807
This commit is contained in:
committed by
Mathew Sutcliffe
parent
2cea07f174
commit
1a6c7fa192
@@ -199,6 +199,9 @@ namespace BlackCore
|
||||
//! Reset model by matching it again
|
||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
//! Activates or deactivates simulator weather
|
||||
virtual void setWeatherActivated(bool activated) = 0;
|
||||
|
||||
//! Request weather grid. Argument identifier is past in the signal to identify the requestor
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) = 0;
|
||||
|
||||
|
||||
@@ -185,6 +185,13 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::setWeatherActivated
|
||||
virtual void setWeatherActivated(bool activated) override
|
||||
{
|
||||
Q_UNUSED(activated);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::requestWeatherGrid
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override
|
||||
{
|
||||
|
||||
@@ -324,6 +324,8 @@ namespace BlackCore
|
||||
emit simulatorPluginChanged(simulatorPluginInfo);
|
||||
CLogMessage(this).info("Simulator plugin loaded: %1") << simulatorPluginInfo.toQString(true);
|
||||
|
||||
simulator->setWeatherActivated(m_isWeatherActivated);
|
||||
|
||||
m_matchingMessages.clear();
|
||||
return true;
|
||||
}
|
||||
@@ -646,6 +648,15 @@ namespace BlackCore
|
||||
return true;
|
||||
}
|
||||
|
||||
void CContextSimulator::setWeatherActivated(bool activated)
|
||||
{
|
||||
m_isWeatherActivated = activated;
|
||||
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
if (m_simulatorPlugin.first.isUnspecified()) { return; }
|
||||
m_simulatorPlugin.second->setWeatherActivated(activated);
|
||||
}
|
||||
|
||||
void CContextSimulator::requestWeatherGrid(const Weather::CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << identifier; }
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual bool isMatchingMessagesEnabled() const override;
|
||||
@@ -207,6 +208,7 @@ namespace BlackCore
|
||||
bool m_initallyAddAircrafts = false;
|
||||
bool m_enableMatchingMessages = true;
|
||||
QString m_networkSessionId; //! Network session, if not connected empty
|
||||
bool m_isWeatherActivated = false;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -174,6 +174,11 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("resetToModelMatchingAircraft"), callsign, callsign);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::setWeatherActivated(bool activated)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("setWeatherActivated"), activated);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::requestWeatherGrid(const Weather::CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("requestWeatherGrid"), weatherGrid, identifier);
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual bool isMatchingMessagesEnabled() const override;
|
||||
|
||||
@@ -141,6 +141,9 @@ namespace BlackCore
|
||||
//! Highlight the aircraft for given time (or disable highlight)
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) = 0;
|
||||
|
||||
//! Activates or deactivates simulator weather
|
||||
virtual void setWeatherActivated(bool activated) = 0;
|
||||
|
||||
//! Driver will be unloaded
|
||||
virtual void unload() = 0;
|
||||
|
||||
|
||||
@@ -194,6 +194,17 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorCommon::reloadWeatherSettings()
|
||||
{
|
||||
if (!m_isWeatherActivated) { return; }
|
||||
const auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorCommon::reverseLookupAndUpdateOwnAircraftModel(const QString &modelString)
|
||||
{
|
||||
CAircraftModel model = getOwnAircraftModel();
|
||||
@@ -246,6 +257,20 @@ namespace BlackCore
|
||||
return airports.findClosest(maxAirportsInRange(), ownPosition);
|
||||
}
|
||||
|
||||
void CSimulatorCommon::setWeatherActivated(bool activated)
|
||||
{
|
||||
m_isWeatherActivated = activated;
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
const auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftModel CSimulatorCommon::reverseLookupModel(const CAircraftModel &model)
|
||||
{
|
||||
bool modified = false;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/simulation/simulatorinternals.h"
|
||||
#include "blackmisc/simulation/simulatorsettings.h"
|
||||
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||
#include "blackmisc/simulation/interpolationhints.h"
|
||||
#include "blackmisc/weather/weathergridprovider.h"
|
||||
@@ -79,6 +80,7 @@ namespace BlackCore
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const override;
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
virtual void unload() override;
|
||||
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
@@ -135,6 +137,9 @@ namespace BlackCore
|
||||
//! Clear all aircraft related data
|
||||
virtual void clearAllAircraft();
|
||||
|
||||
//! Inject weather grid to simulator
|
||||
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) { Q_UNUSED(weatherGrid); }
|
||||
|
||||
//! Airports from web services
|
||||
BlackMisc::Aviation::CAirportList getWebServiceAirports() const;
|
||||
|
||||
@@ -156,6 +161,9 @@ namespace BlackCore
|
||||
//! Set own model
|
||||
void reverseLookupAndUpdateOwnAircraftModel(const QString &modelString);
|
||||
|
||||
//! Reload weather settings
|
||||
void reloadWeatherSettings();
|
||||
|
||||
//! Parse driver specific details for ISimulator::parseCommandLine
|
||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser);
|
||||
|
||||
@@ -172,6 +180,10 @@ namespace BlackCore
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_aircraftToAddAgainWhenRemoved; //!< add this model again when removed, normally used to change model
|
||||
QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CInterpolationHints> m_hints; //!< last ground elevation fetched
|
||||
|
||||
bool m_isWeatherActivated = false; //!< Is simulator weather activated?
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorCommon::reloadWeatherSettings }; //!< Selected weather scenario
|
||||
|
||||
//! Lookup against DB data
|
||||
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ namespace BlackGui
|
||||
auto scenario = m_weatherScenarioSetting.get();
|
||||
ui->cb_weatherScenario->setCurrentIndex(scenario.getIndex());
|
||||
|
||||
ui->pb_ActivateWeather->setIcon(CIcons::metar());
|
||||
|
||||
setupConnections();
|
||||
setupInputValidators();
|
||||
setupCompleter();
|
||||
@@ -107,6 +109,21 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CWeatherComponent::toggleWeatherActivation()
|
||||
{
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
m_isWeatherActivated = false;
|
||||
ui->pb_ActivateWeather->setText("Activate");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isWeatherActivated = true;
|
||||
ui->pb_ActivateWeather->setText("Deactivate");
|
||||
}
|
||||
sGui->getIContextSimulator()->setWeatherActivated(m_isWeatherActivated);
|
||||
}
|
||||
|
||||
void CWeatherComponent::setWeatherScenario(int index)
|
||||
{
|
||||
if (index == -1) { return; }
|
||||
@@ -198,6 +215,7 @@ namespace BlackGui
|
||||
connect(ui->le_Lon, &QLineEdit::returnPressed, this, &CWeatherComponent::updateWeatherInformation);
|
||||
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
|
||||
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation);
|
||||
connect(ui->pb_ActivateWeather, &QPushButton::clicked, this, &CWeatherComponent::toggleWeatherActivation);
|
||||
|
||||
// Context connections
|
||||
Q_ASSERT(sGui->getIContextSimulator());
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
void toggleUseOwnAircraftPosition(bool checked);
|
||||
void toggleWeatherActivation();
|
||||
void setWeatherScenario(int index);
|
||||
|
||||
void updateWeatherInformation();
|
||||
@@ -76,6 +77,7 @@ namespace BlackGui
|
||||
QTimer m_weatherUpdateTimer { this };
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastOwnAircraftPosition;
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSetting { this };
|
||||
bool m_isWeatherActivated = false;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -35,9 +35,16 @@
|
||||
<string>Weather Control</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_WeatherComponent">
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QComboBox" name="cb_weatherScenario"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pb_ActivateWeather">
|
||||
<property name="text">
|
||||
<string>Activate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -139,7 +139,6 @@ namespace BlackSimPlugin
|
||||
{
|
||||
m_fsuipc->connect(); // connect FSUIPC too
|
||||
}
|
||||
reloadWeatherSettings();
|
||||
initInternalsObject();
|
||||
m_dispatchTimerId = startTimer(50);
|
||||
return true;
|
||||
@@ -340,15 +339,17 @@ namespace BlackSimPlugin
|
||||
auto aircraftSituation = aircraftSituationfromFS9(mpPositionVelocity);
|
||||
updateOwnSituation(aircraftSituation);
|
||||
|
||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid });
|
||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid });
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case CFs9Sdk::MPCHAT_PACKET_ID_CHAT_TEXT_SEND:
|
||||
@@ -390,18 +391,6 @@ namespace BlackSimPlugin
|
||||
m_fsuipc->write(weatherGrid);
|
||||
}
|
||||
|
||||
void CSimulatorFs9::reloadWeatherSettings()
|
||||
{
|
||||
if (!m_useFsuipc || !m_fsuipc) { return; }
|
||||
if (!m_fsuipc->isConnected()) { return; }
|
||||
const auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
|
||||
CSimulatorFs9Listener::CSimulatorFs9Listener(const CSimulatorPluginInfo &info,
|
||||
const QSharedPointer<CFs9Host> &fs9Host,
|
||||
const QSharedPointer<CLobbyClient> &lobbyClient) :
|
||||
|
||||
@@ -73,6 +73,11 @@ namespace BlackSimPlugin
|
||||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
//! \@}
|
||||
|
||||
//! \name Base class overrides
|
||||
//! @{
|
||||
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
//! Dispatch SimConnect messages
|
||||
void ps_dispatch();
|
||||
@@ -87,21 +92,12 @@ namespace BlackSimPlugin
|
||||
//! Disconnect all clients
|
||||
void disconnectAllClients();
|
||||
|
||||
//! Inject weather grid to simulator
|
||||
void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
|
||||
//! Reload Weather settings
|
||||
void reloadWeatherSettings();
|
||||
|
||||
QHash<BlackMisc::Aviation::CCallsign, QPointer<CFs9Client>> m_hashFs9Clients;
|
||||
QMetaObject::Connection m_connectionHostMessages;
|
||||
int m_dispatchTimerId = -1;
|
||||
bool m_simConnected = false; //!< Is simulator connected?
|
||||
QSharedPointer<CFs9Host> m_fs9Host;
|
||||
QSharedPointer<CLobbyClient> m_lobbyClient;
|
||||
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorFs9::reloadWeatherSettings };
|
||||
};
|
||||
|
||||
//! Listener for FS9
|
||||
|
||||
@@ -97,7 +97,6 @@ namespace BlackSimPlugin
|
||||
initDataDefinitionsWhenConnected();
|
||||
m_simConnectTimerId = startTimer(10);
|
||||
m_realityBubbleTimer.start();
|
||||
reloadWeatherSettings();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -470,13 +469,16 @@ namespace BlackSimPlugin
|
||||
--m_skipCockpitUpdateCycles;
|
||||
}
|
||||
|
||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFsx::injectWeatherGrid });
|
||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFsx::injectWeatherGrid });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,18 +1062,6 @@ namespace BlackSimPlugin
|
||||
m_fsuipc->write(weatherGrid);
|
||||
}
|
||||
|
||||
void CSimulatorFsx::reloadWeatherSettings()
|
||||
{
|
||||
if (!m_useFsuipc || !m_fsuipc) { return; }
|
||||
if (!m_fsuipc->isConnected()) { return; }
|
||||
const auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorFsx::requestDataForSimObject(const CSimConnectObject &simObject, SIMCONNECT_PERIOD period)
|
||||
{
|
||||
if (!simObject.hasValidRequestAndObjectId()) { return false; }
|
||||
|
||||
@@ -114,6 +114,7 @@ namespace BlackSimPlugin
|
||||
virtual void reset() override;
|
||||
virtual void clearAllAircraft() override;
|
||||
virtual void initInternalsObject() override;
|
||||
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||
//! @}
|
||||
|
||||
//! Timer event (our SimConnect event loop), runs ps_dispatch
|
||||
@@ -200,12 +201,6 @@ namespace BlackSimPlugin
|
||||
//! Sync time with user's computer
|
||||
void synchronizeTime(const BlackMisc::PhysicalQuantities::CTime &zuluTimeSim, const BlackMisc::PhysicalQuantities::CTime &localTimeSim);
|
||||
|
||||
//! Inject weather grid to simulator
|
||||
void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
|
||||
//! Reload weather settings
|
||||
void reloadWeatherSettings();
|
||||
|
||||
//! Request data for a simObject (aka remote aircraft)
|
||||
bool requestDataForSimObject(const CSimConnectObject &simObject, SIMCONNECT_PERIOD period = SIMCONNECT_PERIOD_SECOND);
|
||||
|
||||
@@ -233,8 +228,6 @@ namespace BlackSimPlugin
|
||||
HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object
|
||||
CSimConnectObjects m_simConnectObjects; //!< AI objects and their object / request ids
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_outOfRealityBubble; //!< aircraft removed by FSX because they are out of reality bubble
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorFsx::reloadWeatherSettings };
|
||||
QTimer m_realityBubbleTimer { this }; //!< updating of aircraft out of reality bubble
|
||||
};
|
||||
|
||||
|
||||
@@ -165,13 +165,16 @@ namespace BlackSimPlugin
|
||||
identifier()
|
||||
);
|
||||
|
||||
const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude(), {0} };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorXPlane::injectWeatherGrid });
|
||||
const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude(), {0} };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorXPlane::injectWeatherGrid });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,7 +256,6 @@ namespace BlackSimPlugin
|
||||
m_service->updateAirportsInRange();
|
||||
m_traffic->updateInstalledModels();
|
||||
m_watcher->setConnection(m_conn);
|
||||
reloadWeatherSettings();
|
||||
loadCslPackages();
|
||||
emitSimulatorCombinedStatus();
|
||||
return true;
|
||||
@@ -664,19 +666,6 @@ namespace BlackSimPlugin
|
||||
m_weather->setThunderstormRatio(0.0);
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::reloadWeatherSettings()
|
||||
{
|
||||
if (m_weather)
|
||||
{
|
||||
auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
|
||||
@@ -126,6 +126,11 @@ namespace BlackSimPlugin
|
||||
//! \copydoc BlackCore::ISimulator::isSimulating
|
||||
virtual bool isSimulating() const override { return isConnected(); }
|
||||
|
||||
//! \name Base class overrides
|
||||
//! @{
|
||||
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
void ps_serviceUnregistered();
|
||||
void ps_setAirportsInRange(const QStringList &icaoCodes, const QStringList &names, const BlackMisc::CSequence<double> &lats, const BlackMisc::CSequence<double> &lons, const BlackMisc::CSequence<double> &alts);
|
||||
@@ -138,10 +143,6 @@ namespace BlackSimPlugin
|
||||
void loadCslPackages();
|
||||
QString findCslPackage(const QString &modelFileName);
|
||||
|
||||
//! Inject weather grid to simulator
|
||||
void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
void reloadWeatherSettings();
|
||||
|
||||
QDBusConnection m_conn { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
CXBusServiceProxy *m_service { nullptr };
|
||||
@@ -153,9 +154,6 @@ namespace BlackSimPlugin
|
||||
BlackMisc::Simulation::CAircraftModelList m_installedModels; //!< \todo Do we still need this, as we now focus on model set
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelSetCacheXP> m_modelSet { this };
|
||||
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorXPlane::reloadWeatherSettings };
|
||||
|
||||
//! \todo Add units to members? pitchDeg?, altitudeFt?
|
||||
struct // data is written by DBus async method callbacks
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user