refs #246 added ISimulator::aircraftModelChanged signal which can be sent via the contexts to CAirspaceMonitor, which needs the model when sending FSIPI(R) custom packets

This commit is contained in:
Mathew Sutcliffe
2014-06-13 11:46:40 +01:00
parent 2e23f2fd8d
commit a6cd44be8d
9 changed files with 27 additions and 16 deletions

View File

@@ -287,12 +287,7 @@ namespace BlackCore
{
CAircraft me = this->m_ownAircraft;
CAircraftIcao icao = me.getIcaoInfo();
QString modelString;
// FIXME (MS) simulator or ownaircraft context should send an ownAircraftModelChanged signal, so we wouldn't need to interrogate the simulator context here.
//if (this->getIContextSimulator())
//{
// if (this->getIContextSimulator()->isConnected()) modelString = this->getIContextSimulator()->getOwnAircraftModel().getQueriedModelString();
//}
QString modelString = this->m_ownAircraftModel.getQueriedModelString();
if (modelString.isEmpty()) modelString = CProject::systemNameAndVersion();
this->m_network->sendFsipiCustomPacket(recipientCallsign, icao.getAirlineDesignator(), icao.getAircraftDesignator(), icao.getAircraftCombinedType(), modelString);
}
@@ -301,12 +296,7 @@ namespace BlackCore
{
CAircraft me = this->m_ownAircraft;
CAircraftIcao icao = me.getIcaoInfo();
QString modelString;
// FIXME (MS) simulator or ownaircraft context should send an ownAircraftModelChanged signal, so we wouldn't need to interrogate the simulator context here.
//if (this->getIContextSimulator())
//{
// if (this->getIContextSimulator()->isConnected()) modelString = this->getIContextSimulator()->getOwnAircraftModel().getQueriedModelString();
//}
QString modelString = this->m_ownAircraftModel.getQueriedModelString();
if (modelString.isEmpty()) modelString = CProject::systemNameAndVersion();
this->m_network->sendFsipirCustomPacket(recipientCallsign, icao.getAirlineDesignator(), icao.getAircraftDesignator(), icao.getAircraftCombinedType(), modelString);
}

View File

@@ -90,6 +90,9 @@ namespace BlackCore
public slots:
//! Own aircraft updated
void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) { m_ownAircraft = ownAircraft; }
//! Own aircraft model updated
void setOwnAircraftModel(const BlackMisc::Network::CAircraftModel &model) { m_ownAircraftModel = model; }
public:
//! Clear the contents
@@ -112,6 +115,7 @@ namespace BlackCore
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache;
BlackMisc::Aviation::CAircraft m_ownAircraft;
BlackMisc::Network::CAircraftModel m_ownAircraftModel;
INetwork *m_network;
CVatsimBookingReader *m_vatsimBookingReader;

View File

@@ -69,6 +69,7 @@ namespace BlackCore
this->connect(this->m_airspace, &CAirspaceMonitor::changedAircraftsInRange, this, &CContextNetwork::changedAircraftsInRange);
this->connect(this->m_airspace, &CAirspaceMonitor::changedAircraftSituation, this, &CContextNetwork::changedAircraftSituation);
this->connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraft, this->m_airspace, &CAirspaceMonitor::setOwnAircraft);
this->connect(this->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this->m_airspace, &CAirspaceMonitor::setOwnAircraftModel);
// FIXME (MS) conditional increases the number of scenarios which must be considered and continuously tested
if (this->getIContextApplication())

View File

@@ -394,9 +394,6 @@ namespace BlackCore
}
times.insert("Audio", time.restart());
this->m_contextNetwork = IContextNetwork::create(this, config.getModeNetwork(), this->m_dbusServer, this->m_dbusConnection);
times.insert("Network", time.restart());
switch (config.getModeSimulator())
{
case CRuntimeConfig::Local:
@@ -411,6 +408,9 @@ namespace BlackCore
}
times.insert("Simulator", time.restart());
this->m_contextNetwork = IContextNetwork::create(this, config.getModeNetwork(), this->m_dbusServer, this->m_dbusConnection);
times.insert("Network", time.restart());
// checks --------------
// 1. own aircraft and simulator should reside in same location
Q_ASSERT(!this->m_contextSimulator || (this->m_contextOwnAircraft->usingLocalObjects() == this->m_contextSimulator->usingLocalObjects()));

View File

@@ -52,6 +52,9 @@ namespace BlackCore
//! Emitted when the simulator connection changes
void connectionChanged(bool value);
//! Emitted when own aircraft model changes (TODO move to own aircraft context?)
void ownAircraftModelChanged(BlackMisc::Network::CAircraftModel model);
public slots:
//! Return list of available simulator plugins

View File

@@ -114,6 +114,7 @@ namespace BlackCore
Q_ASSERT(m_simulator);
connect(m_simulator, SIGNAL(statusChanged(ISimulator::Status)), this, SLOT(setConnectionStatus(ISimulator::Status)));
connect(m_simulator, &ISimulator::aircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
return true;
}

View File

@@ -87,6 +87,9 @@ namespace BlackCore
//! Emitted when the connection status has changed
void statusChanged(ISimulator::Status status);
//! Emitted when own aircraft model has changed
void aircraftModelChanged(BlackMisc::Network::CAircraftModel model);
//! Simulator started
void simulatorStarted();

View File

@@ -178,6 +178,15 @@ namespace BlackSimPlugin
return this->m_simulatorInfo;
}
void CSimulatorFsx::setAircraftModel(const BlackMisc::Network::CAircraftModel &model)
{
if (m_aircraftModel != model)
{
m_aircraftModel = model;
emit aircraftModelChanged(model);
}
}
bool CSimulatorFsx::updateOwnSimulatorCockpit(const CAircraft &ownAircraft)
{
CComSystem newCom1 = ownAircraft.getCom1System();

View File

@@ -144,7 +144,7 @@ namespace BlackSimPlugin
void onSimExit();
//! \private
void setAircraftModel(const BlackMisc::Network::CAircraftModel &model) { m_aircraftModel = model; }
void setAircraftModel(const BlackMisc::Network::CAircraftModel &model);
protected:
//! Timer event