Hint for simulator if network is connected (slightly related T307)

This commit is contained in:
Klaus Basan
2018-08-19 14:07:04 +02:00
parent 9df19fb064
commit d7b1ed8d31
5 changed files with 50 additions and 8 deletions

View File

@@ -414,6 +414,12 @@ namespace BlackCore
// try to connect to simulator // try to connect to simulator
const bool connected = simulator->connectTo(); const bool connected = simulator->connectTo();
if (!connected)
{
CLogMessage(this).error("Simulator plugin connection to simulator '%1' failed") << simulatorPluginInfo.toQString(true);
return false;
}
simulator->setWeatherActivated(m_isWeatherActivated); simulator->setWeatherActivated(m_isWeatherActivated);
// when everything is set up connected, update the current plugin info // when everything is set up connected, update the current plugin info
@@ -626,6 +632,10 @@ namespace BlackCore
if (to == INetwork::Connected && this->getIContextNetwork()) if (to == INetwork::Connected && this->getIContextNetwork())
{ {
m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId(); m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId();
if (m_simulatorPlugin.second) // check in case the plugin has been unloaded
{
m_simulatorPlugin.second->setFlightNetworkConnected(true);
}
} }
else if (INetwork::isDisconnectedStatus(to)) else if (INetwork::isDisconnectedStatus(to))
{ {
@@ -637,6 +647,7 @@ namespace BlackCore
{ {
const CStatusMessageList verifyMessages = m_simulatorPlugin.second->debugVerifyStateAfterAllAircraftRemoved(); const CStatusMessageList verifyMessages = m_simulatorPlugin.second->debugVerifyStateAfterAllAircraftRemoved();
m_simulatorPlugin.second->clearAllRemoteAircraftData(); m_simulatorPlugin.second->clearAllRemoteAircraftData();
m_simulatorPlugin.second->setFlightNetworkConnected(false);
if (!verifyMessages.isEmpty()) { emit this->driverMessages(verifyMessages); } if (!verifyMessages.isEmpty()) { emit this->driverMessages(verifyMessages); }
} }
} }

View File

@@ -123,6 +123,11 @@ namespace BlackCore
} }
} }
void ISimulator::setFlightNetworkConnected(bool connected)
{
m_networkConnected = connected;
}
void ISimulator::reloadWeatherSettings() void ISimulator::reloadWeatherSettings()
{ {
if (!m_isWeatherActivated) { return; } if (!m_isWeatherActivated) { return; }

View File

@@ -169,6 +169,14 @@ namespace BlackCore
//! Activates or deactivates simulator weather //! Activates or deactivates simulator weather
virtual void setWeatherActivated(bool activated); virtual void setWeatherActivated(bool activated);
//! Flight network has been connected
//! \remark hint if network connected and we expect any planes
//! \sa ISimulator::isFlightNetworkConnected
virtual void setFlightNetworkConnected(bool connected);
//! Is the flight network connected
bool isFlightNetworkConnected() const { return m_networkConnected; }
//! Reload weather settings //! Reload weather settings
void reloadWeatherSettings(); void reloadWeatherSettings();
@@ -538,18 +546,24 @@ namespace BlackCore
//! Display a logged situation in simulator //! Display a logged situation in simulator
void displayLoggedSituationInSimulator(const BlackMisc::Aviation::CCallsign &cs, bool stopLogging, int times = 40); void displayLoggedSituationInSimulator(const BlackMisc::Aviation::CCallsign &cs, bool stopLogging, int times = 40);
bool m_blinkCycle = false; //!< used for highlighting
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
int m_timerCounter = 0; //!< allows to calculate n seconds
QTimer m_oneSecondTimer; //!< multi purpose timer with 1 sec. interval
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
// statistics values of how often those functions are called // 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) // those are the added counters, overflow will not be an issue here (discussed in T171 review)
int m_statsPhysicallyAddedAircraft = 0; //!< statistics, how many aircraft added int m_statsPhysicallyAddedAircraft = 0; //!< statistics, how many aircraft added
int m_statsPhysicallyRemovedAircraft = 0; //!< statistics, how many aircraft removed int m_statsPhysicallyRemovedAircraft = 0; //!< statistics, how many aircraft removed
// highlighting
bool m_blinkCycle = false; //!< used for highlighting
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
// timer
int m_timerCounter = 0; //!< allows to calculate n seconds
QTimer m_oneSecondTimer; //!< multi purpose timer with 1 sec. interval
// misc. as callsigns
bool m_networkConnected = false; //!< flight network connected
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
}; };
//! \brief Interface to a simulator listener. //! \brief Interface to a simulator listener.

View File

@@ -343,6 +343,17 @@ namespace BlackSimPlugin
CSimulatorPluginCommon::resetAircraftStatistics(); CSimulatorPluginCommon::resetAircraftStatistics();
} }
void CSimulatorFsxCommon::setFlightNetworkConnected(bool connected)
{
if (connected == !this->isFlightNetworkConnected())
{
// toggling, we trace for a while to better monitor those "critical" phases
this->triggerAutoTraceSendId();
}
ISimulator::setFlightNetworkConnected(connected);
}
CSimConnectDefinitions::SimObjectRequest CSimulatorFsxCommon::requestToSimObjectRequest(DWORD requestId) CSimConnectDefinitions::SimObjectRequest CSimulatorFsxCommon::requestToSimObjectRequest(DWORD requestId)
{ {
DWORD v = static_cast<DWORD>(CSimConnectDefinitions::SimObjectEndMarker); DWORD v = static_cast<DWORD>(CSimConnectDefinitions::SimObjectEndMarker);

View File

@@ -132,6 +132,7 @@ namespace BlackSimPlugin
virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const override; virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const override;
virtual QString getStatisticsSimulatorSpecific() const override; virtual QString getStatisticsSimulatorSpecific() const override;
virtual void resetAircraftStatistics() override; virtual void resetAircraftStatistics() override;
virtual void setFlightNetworkConnected(bool connected) override;
//! @} //! @}
//! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation //! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation