Simulator driver fetches and injects weather from weather manager

This commit is contained in:
Roland Winklmeier
2016-03-28 20:57:39 +02:00
parent 5801962a99
commit 781707fb7e
9 changed files with 100 additions and 37 deletions

View File

@@ -133,11 +133,6 @@ namespace BlackSimPlugin
m_fsuipc->connect(); // connect FSUIPC too
}
m_dispatchTimerId = startTimer(50);
// Pull weather data from core.
// Since we don't get weather data from core yet, use hard coded weather.
injectWeatherGrid(CWeatherGrid::getCavokGrid());
return true;
}
@@ -333,7 +328,17 @@ namespace BlackSimPlugin
{
MPPositionVelocity mpPositionVelocity;
MultiPlayerPacketParser::readMessage(message, mpPositionVelocity);
updateOwnSituation(aircraftSituationfromFS9(mpPositionVelocity));
auto aircraftSituation = aircraftSituationfromFS9(mpPositionVelocity);
updateOwnSituation(aircraftSituation);
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude(), {0} };
if (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:

View File

@@ -115,6 +115,8 @@ namespace BlackSimPlugin
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
};
//! Listener for FS9