mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 18:25:42 +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
|
//! Reset model by matching it again
|
||||||
virtual bool resetToModelMatchingAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
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
|
//! 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;
|
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,13 @@ namespace BlackCore
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \copydoc IContextSimulator::setWeatherActivated
|
||||||
|
virtual void setWeatherActivated(bool activated) override
|
||||||
|
{
|
||||||
|
Q_UNUSED(activated);
|
||||||
|
logEmptyContextWarning(Q_FUNC_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
//! \copydoc IContextSimulator::requestWeatherGrid
|
//! \copydoc IContextSimulator::requestWeatherGrid
|
||||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override
|
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -324,6 +324,8 @@ namespace BlackCore
|
|||||||
emit simulatorPluginChanged(simulatorPluginInfo);
|
emit simulatorPluginChanged(simulatorPluginInfo);
|
||||||
CLogMessage(this).info("Simulator plugin loaded: %1") << simulatorPluginInfo.toQString(true);
|
CLogMessage(this).info("Simulator plugin loaded: %1") << simulatorPluginInfo.toQString(true);
|
||||||
|
|
||||||
|
simulator->setWeatherActivated(m_isWeatherActivated);
|
||||||
|
|
||||||
m_matchingMessages.clear();
|
m_matchingMessages.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -646,6 +648,15 @@ namespace BlackCore
|
|||||||
return true;
|
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)
|
void CContextSimulator::requestWeatherGrid(const Weather::CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
||||||
{
|
{
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << 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 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 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 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 void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||||
virtual bool isMatchingMessagesEnabled() const override;
|
virtual bool isMatchingMessagesEnabled() const override;
|
||||||
@@ -207,6 +208,7 @@ namespace BlackCore
|
|||||||
bool m_initallyAddAircrafts = false;
|
bool m_initallyAddAircrafts = false;
|
||||||
bool m_enableMatchingMessages = true;
|
bool m_enableMatchingMessages = true;
|
||||||
QString m_networkSessionId; //! Network session, if not connected empty
|
QString m_networkSessionId; //! Network session, if not connected empty
|
||||||
|
bool m_isWeatherActivated = false;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -174,6 +174,11 @@ namespace BlackCore
|
|||||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("resetToModelMatchingAircraft"), callsign, callsign);
|
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)
|
void CContextSimulatorProxy::requestWeatherGrid(const Weather::CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
||||||
{
|
{
|
||||||
m_dBusInterface->callDBus(QLatin1Literal("requestWeatherGrid"), weatherGrid, identifier);
|
m_dBusInterface->callDBus(QLatin1Literal("requestWeatherGrid"), weatherGrid, identifier);
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ namespace BlackCore
|
|||||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
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 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 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 void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) override;
|
||||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||||
virtual bool isMatchingMessagesEnabled() const override;
|
virtual bool isMatchingMessagesEnabled() const override;
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ namespace BlackCore
|
|||||||
//! Highlight the aircraft for given time (or disable highlight)
|
//! 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;
|
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
|
//! Driver will be unloaded
|
||||||
virtual void unload() = 0;
|
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)
|
void CSimulatorCommon::reverseLookupAndUpdateOwnAircraftModel(const QString &modelString)
|
||||||
{
|
{
|
||||||
CAircraftModel model = getOwnAircraftModel();
|
CAircraftModel model = getOwnAircraftModel();
|
||||||
@@ -246,6 +257,20 @@ namespace BlackCore
|
|||||||
return airports.findClosest(maxAirportsInRange(), ownPosition);
|
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)
|
CAircraftModel CSimulatorCommon::reverseLookupModel(const CAircraftModel &model)
|
||||||
{
|
{
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||||
#include "blackmisc/simulation/simulatorinternals.h"
|
#include "blackmisc/simulation/simulatorinternals.h"
|
||||||
|
#include "blackmisc/simulation/simulatorsettings.h"
|
||||||
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||||
#include "blackmisc/simulation/interpolationhints.h"
|
#include "blackmisc/simulation/interpolationhints.h"
|
||||||
#include "blackmisc/weather/weathergridprovider.h"
|
#include "blackmisc/weather/weathergridprovider.h"
|
||||||
@@ -79,6 +80,7 @@ namespace BlackCore
|
|||||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const override;
|
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const 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;
|
||||||
|
virtual void setWeatherActivated(bool activated) override;
|
||||||
virtual void unload() override;
|
virtual void unload() override;
|
||||||
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
||||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||||
@@ -135,6 +137,9 @@ namespace BlackCore
|
|||||||
//! Clear all aircraft related data
|
//! Clear all aircraft related data
|
||||||
virtual void clearAllAircraft();
|
virtual void clearAllAircraft();
|
||||||
|
|
||||||
|
//! Inject weather grid to simulator
|
||||||
|
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) { Q_UNUSED(weatherGrid); }
|
||||||
|
|
||||||
//! Airports from web services
|
//! Airports from web services
|
||||||
BlackMisc::Aviation::CAirportList getWebServiceAirports() const;
|
BlackMisc::Aviation::CAirportList getWebServiceAirports() const;
|
||||||
|
|
||||||
@@ -156,6 +161,9 @@ namespace BlackCore
|
|||||||
//! Set own model
|
//! Set own model
|
||||||
void reverseLookupAndUpdateOwnAircraftModel(const QString &modelString);
|
void reverseLookupAndUpdateOwnAircraftModel(const QString &modelString);
|
||||||
|
|
||||||
|
//! Reload weather settings
|
||||||
|
void reloadWeatherSettings();
|
||||||
|
|
||||||
//! Parse driver specific details for ISimulator::parseCommandLine
|
//! Parse driver specific details for ISimulator::parseCommandLine
|
||||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser);
|
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
|
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
|
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
|
//! Lookup against DB data
|
||||||
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);
|
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ namespace BlackGui
|
|||||||
auto scenario = m_weatherScenarioSetting.get();
|
auto scenario = m_weatherScenarioSetting.get();
|
||||||
ui->cb_weatherScenario->setCurrentIndex(scenario.getIndex());
|
ui->cb_weatherScenario->setCurrentIndex(scenario.getIndex());
|
||||||
|
|
||||||
|
ui->pb_ActivateWeather->setIcon(CIcons::metar());
|
||||||
|
|
||||||
setupConnections();
|
setupConnections();
|
||||||
setupInputValidators();
|
setupInputValidators();
|
||||||
setupCompleter();
|
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)
|
void CWeatherComponent::setWeatherScenario(int index)
|
||||||
{
|
{
|
||||||
if (index == -1) { return; }
|
if (index == -1) { return; }
|
||||||
@@ -198,6 +215,7 @@ namespace BlackGui
|
|||||||
connect(ui->le_Lon, &QLineEdit::returnPressed, this, &CWeatherComponent::updateWeatherInformation);
|
connect(ui->le_Lon, &QLineEdit::returnPressed, this, &CWeatherComponent::updateWeatherInformation);
|
||||||
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
|
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
|
||||||
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation);
|
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation);
|
||||||
|
connect(ui->pb_ActivateWeather, &QPushButton::clicked, this, &CWeatherComponent::toggleWeatherActivation);
|
||||||
|
|
||||||
// Context connections
|
// Context connections
|
||||||
Q_ASSERT(sGui->getIContextSimulator());
|
Q_ASSERT(sGui->getIContextSimulator());
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void toggleUseOwnAircraftPosition(bool checked);
|
void toggleUseOwnAircraftPosition(bool checked);
|
||||||
|
void toggleWeatherActivation();
|
||||||
void setWeatherScenario(int index);
|
void setWeatherScenario(int index);
|
||||||
|
|
||||||
void updateWeatherInformation();
|
void updateWeatherInformation();
|
||||||
@@ -76,6 +77,7 @@ namespace BlackGui
|
|||||||
QTimer m_weatherUpdateTimer { this };
|
QTimer m_weatherUpdateTimer { this };
|
||||||
BlackMisc::Geo::CCoordinateGeodetic m_lastOwnAircraftPosition;
|
BlackMisc::Geo::CCoordinateGeodetic m_lastOwnAircraftPosition;
|
||||||
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSetting { this };
|
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSetting { this };
|
||||||
|
bool m_isWeatherActivated = false;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -35,9 +35,16 @@
|
|||||||
<string>Weather Control</string>
|
<string>Weather Control</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gl_WeatherComponent">
|
<layout class="QGridLayout" name="gl_WeatherComponent">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QComboBox" name="cb_weatherScenario"/>
|
<widget class="QComboBox" name="cb_weatherScenario"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="pb_ActivateWeather">
|
||||||
|
<property name="text">
|
||||||
|
<string>Activate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
m_fsuipc->connect(); // connect FSUIPC too
|
m_fsuipc->connect(); // connect FSUIPC too
|
||||||
}
|
}
|
||||||
reloadWeatherSettings();
|
|
||||||
initInternalsObject();
|
initInternalsObject();
|
||||||
m_dispatchTimerId = startTimer(50);
|
m_dispatchTimerId = startTimer(50);
|
||||||
return true;
|
return true;
|
||||||
@@ -340,15 +339,17 @@ namespace BlackSimPlugin
|
|||||||
auto aircraftSituation = aircraftSituationfromFS9(mpPositionVelocity);
|
auto aircraftSituation = aircraftSituationfromFS9(mpPositionVelocity);
|
||||||
updateOwnSituation(aircraftSituation);
|
updateOwnSituation(aircraftSituation);
|
||||||
|
|
||||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
if (m_isWeatherActivated)
|
||||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
|
||||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
|
||||||
{
|
{
|
||||||
m_lastWeatherPosition = currentPosition;
|
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
||||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid });
|
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||||
|
{
|
||||||
|
m_lastWeatherPosition = currentPosition;
|
||||||
|
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||||
|
requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CFs9Sdk::MPCHAT_PACKET_ID_CHAT_TEXT_SEND:
|
case CFs9Sdk::MPCHAT_PACKET_ID_CHAT_TEXT_SEND:
|
||||||
@@ -390,18 +391,6 @@ namespace BlackSimPlugin
|
|||||||
m_fsuipc->write(weatherGrid);
|
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,
|
CSimulatorFs9Listener::CSimulatorFs9Listener(const CSimulatorPluginInfo &info,
|
||||||
const QSharedPointer<CFs9Host> &fs9Host,
|
const QSharedPointer<CFs9Host> &fs9Host,
|
||||||
const QSharedPointer<CLobbyClient> &lobbyClient) :
|
const QSharedPointer<CLobbyClient> &lobbyClient) :
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ namespace BlackSimPlugin
|
|||||||
virtual void timerEvent(QTimerEvent *event) override;
|
virtual void timerEvent(QTimerEvent *event) override;
|
||||||
//! \@}
|
//! \@}
|
||||||
|
|
||||||
|
//! \name Base class overrides
|
||||||
|
//! @{
|
||||||
|
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||||
|
//! @}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Dispatch SimConnect messages
|
//! Dispatch SimConnect messages
|
||||||
void ps_dispatch();
|
void ps_dispatch();
|
||||||
@@ -87,21 +92,12 @@ namespace BlackSimPlugin
|
|||||||
//! Disconnect all clients
|
//! Disconnect all clients
|
||||||
void disconnectAllClients();
|
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;
|
QHash<BlackMisc::Aviation::CCallsign, QPointer<CFs9Client>> m_hashFs9Clients;
|
||||||
QMetaObject::Connection m_connectionHostMessages;
|
QMetaObject::Connection m_connectionHostMessages;
|
||||||
int m_dispatchTimerId = -1;
|
int m_dispatchTimerId = -1;
|
||||||
bool m_simConnected = false; //!< Is simulator connected?
|
bool m_simConnected = false; //!< Is simulator connected?
|
||||||
QSharedPointer<CFs9Host> m_fs9Host;
|
QSharedPointer<CFs9Host> m_fs9Host;
|
||||||
QSharedPointer<CLobbyClient> m_lobbyClient;
|
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
|
//! Listener for FS9
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ namespace BlackSimPlugin
|
|||||||
initDataDefinitionsWhenConnected();
|
initDataDefinitionsWhenConnected();
|
||||||
m_simConnectTimerId = startTimer(10);
|
m_simConnectTimerId = startTimer(10);
|
||||||
m_realityBubbleTimer.start();
|
m_realityBubbleTimer.start();
|
||||||
reloadWeatherSettings();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,13 +469,16 @@ namespace BlackSimPlugin
|
|||||||
--m_skipCockpitUpdateCycles;
|
--m_skipCockpitUpdateCycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
if (m_isWeatherActivated)
|
||||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
|
||||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
|
||||||
{
|
{
|
||||||
m_lastWeatherPosition = currentPosition;
|
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
|
||||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFsx::injectWeatherGrid });
|
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);
|
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)
|
bool CSimulatorFsx::requestDataForSimObject(const CSimConnectObject &simObject, SIMCONNECT_PERIOD period)
|
||||||
{
|
{
|
||||||
if (!simObject.hasValidRequestAndObjectId()) { return false; }
|
if (!simObject.hasValidRequestAndObjectId()) { return false; }
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ namespace BlackSimPlugin
|
|||||||
virtual void reset() override;
|
virtual void reset() override;
|
||||||
virtual void clearAllAircraft() override;
|
virtual void clearAllAircraft() override;
|
||||||
virtual void initInternalsObject() override;
|
virtual void initInternalsObject() override;
|
||||||
|
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Timer event (our SimConnect event loop), runs ps_dispatch
|
//! Timer event (our SimConnect event loop), runs ps_dispatch
|
||||||
@@ -200,12 +201,6 @@ namespace BlackSimPlugin
|
|||||||
//! Sync time with user's computer
|
//! Sync time with user's computer
|
||||||
void synchronizeTime(const BlackMisc::PhysicalQuantities::CTime &zuluTimeSim, const BlackMisc::PhysicalQuantities::CTime &localTimeSim);
|
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)
|
//! Request data for a simObject (aka remote aircraft)
|
||||||
bool requestDataForSimObject(const CSimConnectObject &simObject, SIMCONNECT_PERIOD period = SIMCONNECT_PERIOD_SECOND);
|
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
|
HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object
|
||||||
CSimConnectObjects m_simConnectObjects; //!< AI objects and their object / request ids
|
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::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
|
QTimer m_realityBubbleTimer { this }; //!< updating of aircraft out of reality bubble
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -165,13 +165,16 @@ namespace BlackSimPlugin
|
|||||||
identifier()
|
identifier()
|
||||||
);
|
);
|
||||||
|
|
||||||
const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude(), {0} };
|
if (m_isWeatherActivated)
|
||||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
|
||||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
|
||||||
{
|
{
|
||||||
m_lastWeatherPosition = currentPosition;
|
const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude(), {0} };
|
||||||
const auto weatherGrid = CWeatherGrid { { "", currentPosition } };
|
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorXPlane::injectWeatherGrid });
|
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_service->updateAirportsInRange();
|
||||||
m_traffic->updateInstalledModels();
|
m_traffic->updateInstalledModels();
|
||||||
m_watcher->setConnection(m_conn);
|
m_watcher->setConnection(m_conn);
|
||||||
reloadWeatherSettings();
|
|
||||||
loadCslPackages();
|
loadCslPackages();
|
||||||
emitSimulatorCombinedStatus();
|
emitSimulatorCombinedStatus();
|
||||||
return true;
|
return true;
|
||||||
@@ -664,19 +666,6 @@ namespace BlackSimPlugin
|
|||||||
m_weather->setThunderstormRatio(0.0);
|
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,
|
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
|
||||||
IOwnAircraftProvider *ownAircraftProvider,
|
IOwnAircraftProvider *ownAircraftProvider,
|
||||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||||
|
|||||||
@@ -126,6 +126,11 @@ namespace BlackSimPlugin
|
|||||||
//! \copydoc BlackCore::ISimulator::isSimulating
|
//! \copydoc BlackCore::ISimulator::isSimulating
|
||||||
virtual bool isSimulating() const override { return isConnected(); }
|
virtual bool isSimulating() const override { return isConnected(); }
|
||||||
|
|
||||||
|
//! \name Base class overrides
|
||||||
|
//! @{
|
||||||
|
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||||
|
//! @}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ps_serviceUnregistered();
|
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);
|
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();
|
void loadCslPackages();
|
||||||
QString findCslPackage(const QString &modelFileName);
|
QString findCslPackage(const QString &modelFileName);
|
||||||
|
|
||||||
//! Inject weather grid to simulator
|
|
||||||
void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
|
||||||
void reloadWeatherSettings();
|
|
||||||
|
|
||||||
QDBusConnection m_conn { "default" };
|
QDBusConnection m_conn { "default" };
|
||||||
QDBusServiceWatcher *m_watcher { nullptr };
|
QDBusServiceWatcher *m_watcher { nullptr };
|
||||||
CXBusServiceProxy *m_service { 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::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::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?
|
//! \todo Add units to members? pitchDeg?, altitudeFt?
|
||||||
struct // data is written by DBus async method callbacks
|
struct // data is written by DBus async method callbacks
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user