refs #324 connect airspace watchdog to airspace monitor

This commit is contained in:
Roland Winklmeier
2014-10-05 20:03:32 +02:00
parent d6cbf10854
commit 5fe4ea3039
2 changed files with 17 additions and 1 deletions

View File

@@ -24,7 +24,8 @@ namespace BlackCore
using namespace BlackMisc::PhysicalQuantities;
CAirspaceMonitor::CAirspaceMonitor(QObject *parent, INetwork *network, CVatsimBookingReader *bookings, CVatsimDataFileReader *dataFile)
: QObject(parent), m_network(network), m_vatsimBookingReader(bookings), m_vatsimDataFileReader(dataFile)
: QObject(parent), m_network(network), m_vatsimBookingReader(bookings), m_vatsimDataFileReader(dataFile),
m_atcWatchdog(this), m_aircraftWatchdog(this)
{
this->connect(this->m_network, &INetwork::atcPositionUpdate, this, &CAirspaceMonitor::ps_atcPositionUpdate);
this->connect(this->m_network, &INetwork::atisReplyReceived, this, &CAirspaceMonitor::ps_atisReceived);
@@ -45,6 +46,12 @@ namespace BlackCore
// AutoConnection: this should also avoid race conditions by updating the bookings
this->connect(this->m_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CAirspaceMonitor::ps_receivedBookings);
this->connect(this->m_vatsimDataFileReader, &CVatsimDataFileReader::dataRead, this, &CAirspaceMonitor::ps_receivedDataFile);
// Watchdog
// ATC stations send updates every 25 s. Configure timeout after 50 s.
m_atcWatchdog.setTimeout(CTime(50, CTimeUnit::s()));
this->connect(&this->m_aircraftWatchdog, &CAirspaceWatchdog::timeout, this, &CAirspaceMonitor::ps_pilotDisconnected);
this->connect(&this->m_atcWatchdog, &CAirspaceWatchdog::timeout, this, &CAirspaceMonitor::ps_atcControllerDisconnected);
}
CFlightPlan CAirspaceMonitor::loadFlightPlanFromNetwork(const CCallsign &callsign)
@@ -388,6 +395,7 @@ namespace BlackCore
emit this->m_network->sendServerQuery(callsign);
}
this->m_atcWatchdog.addCallsign(callsign);
emit this->changedAtcStationsOnline();
// Remark: this->changedAtcStationOnlineConnectionStatus(station, true);
// will be sent in psFsdAtisVoiceRoomReceived
@@ -401,6 +409,7 @@ namespace BlackCore
vm.addValue(CAtcStation::IndexRange, range);
int changed = this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm, true);
if (changed > 0) { emit this->changedAtcStationsOnline(); }
this->m_atcWatchdog.resetCallsign(callsign);
}
}
@@ -411,6 +420,7 @@ namespace BlackCore
{
CAtcStation removeStation = this->m_atcStationsOnline.findByCallsign(callsign).front();
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
this->m_atcWatchdog.removeCallsign(callsign);
emit this->changedAtcStationsOnline();
emit this->changedAtcStationOnlineConnectionStatus(removeStation, false);
}
@@ -535,6 +545,7 @@ namespace BlackCore
this->sendFsipirCustomPacket(callsign); // own aircraft model
}
this->m_aircraftWatchdog.addCallsign(callsign);
emit this->addedAircraft(callsign, situation);
}
else
@@ -549,6 +560,7 @@ namespace BlackCore
// here I expect always a changed value
this->m_aircraftsInRange.applyIf(&CAircraft::getCallsign, callsign, vm, false);
this->m_aircraftWatchdog.resetCallsign(callsign);
emit this->changedAircraftSituation(callsign, situation);
}
@@ -559,6 +571,7 @@ namespace BlackCore
{
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
bool contains = this->m_aircraftsInRange.contains(&CAircraft::getCallsign, callsign);
this->m_aircraftWatchdog.removeCallsign(callsign);
if (contains)
{
this->m_aircraftsInRange.removeIf(&CAircraft::getCallsign, callsign);

View File

@@ -21,6 +21,7 @@
#include "network.h"
#include "vatsimbookingreader.h"
#include "vatsimdatafilereader.h"
#include "airspace_watchdog.h"
namespace BlackCore
{
@@ -133,6 +134,8 @@ namespace BlackCore
INetwork *m_network;
CVatsimBookingReader *m_vatsimBookingReader;
CVatsimDataFileReader *m_vatsimDataFileReader;
CAirspaceWatchdog m_atcWatchdog;
CAirspaceWatchdog m_aircraftWatchdog;
// FIXME (MS) should be in INetwork
void sendFsipiCustomPacket(const BlackMisc::Aviation::CCallsign &recipientCallsign) const;