mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #811, airports default implementation
* if no sim data are available use reader data * merge airport data for FSX * Added "network" in .pro (needed for network classes such as readers)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
load(common_pre)
|
||||
|
||||
QT += core dbus concurrent xml
|
||||
QT += core dbus concurrent xml network
|
||||
|
||||
TARGET = simulatorfscommon
|
||||
TEMPLATE = lib
|
||||
|
||||
@@ -8,17 +8,18 @@
|
||||
*/
|
||||
|
||||
#include "simulatorfscommon.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
@@ -80,7 +81,11 @@ namespace BlackSimPlugin
|
||||
|
||||
CAirportList CSimulatorFsCommon::getAirportsInRange() const
|
||||
{
|
||||
return m_airportsInRange;
|
||||
if (!m_airportsInRangeFromSimulator.isEmpty())
|
||||
{
|
||||
return m_airportsInRangeFromSimulator;
|
||||
}
|
||||
return CSimulatorCommon::getAirportsInRange();
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
|
||||
@@ -104,5 +109,15 @@ namespace BlackSimPlugin
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::ps_allSwiftDataRead()
|
||||
{
|
||||
const CAirportList webServiceAirports = this->getWebServiceAirports();
|
||||
if (!webServiceAirports.isEmpty())
|
||||
{
|
||||
this->m_airportsInRangeFromSimulator.updateMissingParts(webServiceAirports);
|
||||
}
|
||||
CSimulatorCommon::ps_allSwiftDataRead();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace BlackSimPlugin
|
||||
virtual bool changeRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
||||
//! @}
|
||||
|
||||
protected slots:
|
||||
//! \copydoc BlackCore::CSimulatorCommon::ps_allSwiftDataRead
|
||||
virtual void ps_allSwiftDataRead() override;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CSimulatorFsCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
@@ -64,7 +68,7 @@ namespace BlackSimPlugin
|
||||
bool m_simPaused = false; //!< Simulator paused?
|
||||
bool m_simTimeSynced = false; //!< Time synchronized?
|
||||
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< airports in range of own aircraft
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRangeFromSimulator; //!< airports in range of own aircraft
|
||||
|
||||
// cockpit as set in SIM
|
||||
BlackMisc::Aviation::CComSystem m_simCom1; //!< cockpit COM1 state in simulator
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_AIRPORT_LIST:
|
||||
{
|
||||
const CLength maxDistance(200.0, CLengthUnit::NM());
|
||||
static const CLength maxDistance(200.0, CLengthUnit::NM());
|
||||
const CCoordinateGeodetic posAircraft(simulatorFsx->getOwnAircraftPosition());
|
||||
SIMCONNECT_RECV_AIRPORT_LIST *pAirportList = (SIMCONNECT_RECV_AIRPORT_LIST *) pData;
|
||||
for (unsigned i = 0; i < pAirportList->dwArraySize; ++i)
|
||||
@@ -224,11 +224,14 @@ namespace BlackSimPlugin
|
||||
CAirport airport(CAirportIcaoCode(icao), pos);
|
||||
const CLength d = airport.calculcateAndUpdateRelativeDistanceAndBearing(posAircraft);
|
||||
if (d > maxDistance) { continue; }
|
||||
simulatorFsx->m_airportsInRange.replaceOrAddByIcao(airport);
|
||||
airport.updateMissingParts(simulatorFsx->getWebServiceAirport(icao));
|
||||
simulatorFsx->m_airportsInRangeFromSimulator.replaceOrAddByIcao(airport);
|
||||
}
|
||||
if (simulatorFsx->m_airportsInRange.size() > 20)
|
||||
|
||||
if (simulatorFsx->m_airportsInRangeFromSimulator.size() > simulatorFsx->maxAirportsInRange())
|
||||
{
|
||||
simulatorFsx->m_airportsInRange.removeIfOutsideRange(posAircraft, maxDistance, true);
|
||||
simulatorFsx->m_airportsInRangeFromSimulator.sortByDistanceToOwnAircraft();
|
||||
simulatorFsx->m_airportsInRangeFromSimulator.truncate(simulatorFsx->maxAirportsInRange());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -351,6 +351,7 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorXPlane::ps_setAirportsInRange(const QStringList &icaos, const QStringList &names, const BlackMisc::CSequence<double> &lats, const BlackMisc::CSequence<double> &lons, const BlackMisc::CSequence<double> &alts)
|
||||
{
|
||||
//! \todo restrict to maxAirportsInRange()
|
||||
m_airportsInRange.clear();
|
||||
auto icaoIt = icaos.begin();
|
||||
auto nameIt = names.begin();
|
||||
|
||||
Reference in New Issue
Block a user