mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #324 connect airspace watchdog to airspace monitor
This commit is contained in:
@@ -24,7 +24,8 @@ namespace BlackCore
|
|||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
CAirspaceMonitor::CAirspaceMonitor(QObject *parent, INetwork *network, CVatsimBookingReader *bookings, CVatsimDataFileReader *dataFile)
|
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::atcPositionUpdate, this, &CAirspaceMonitor::ps_atcPositionUpdate);
|
||||||
this->connect(this->m_network, &INetwork::atisReplyReceived, this, &CAirspaceMonitor::ps_atisReceived);
|
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
|
// 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_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CAirspaceMonitor::ps_receivedBookings);
|
||||||
this->connect(this->m_vatsimDataFileReader, &CVatsimDataFileReader::dataRead, this, &CAirspaceMonitor::ps_receivedDataFile);
|
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)
|
CFlightPlan CAirspaceMonitor::loadFlightPlanFromNetwork(const CCallsign &callsign)
|
||||||
@@ -388,6 +395,7 @@ namespace BlackCore
|
|||||||
emit this->m_network->sendServerQuery(callsign);
|
emit this->m_network->sendServerQuery(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->m_atcWatchdog.addCallsign(callsign);
|
||||||
emit this->changedAtcStationsOnline();
|
emit this->changedAtcStationsOnline();
|
||||||
// Remark: this->changedAtcStationOnlineConnectionStatus(station, true);
|
// Remark: this->changedAtcStationOnlineConnectionStatus(station, true);
|
||||||
// will be sent in psFsdAtisVoiceRoomReceived
|
// will be sent in psFsdAtisVoiceRoomReceived
|
||||||
@@ -401,6 +409,7 @@ namespace BlackCore
|
|||||||
vm.addValue(CAtcStation::IndexRange, range);
|
vm.addValue(CAtcStation::IndexRange, range);
|
||||||
int changed = this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm, true);
|
int changed = this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm, true);
|
||||||
if (changed > 0) { emit this->changedAtcStationsOnline(); }
|
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();
|
CAtcStation removeStation = this->m_atcStationsOnline.findByCallsign(callsign).front();
|
||||||
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
|
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
|
||||||
|
this->m_atcWatchdog.removeCallsign(callsign);
|
||||||
emit this->changedAtcStationsOnline();
|
emit this->changedAtcStationsOnline();
|
||||||
emit this->changedAtcStationOnlineConnectionStatus(removeStation, false);
|
emit this->changedAtcStationOnlineConnectionStatus(removeStation, false);
|
||||||
}
|
}
|
||||||
@@ -535,6 +545,7 @@ namespace BlackCore
|
|||||||
this->sendFsipirCustomPacket(callsign); // own aircraft model
|
this->sendFsipirCustomPacket(callsign); // own aircraft model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->m_aircraftWatchdog.addCallsign(callsign);
|
||||||
emit this->addedAircraft(callsign, situation);
|
emit this->addedAircraft(callsign, situation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -549,6 +560,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
// here I expect always a changed value
|
// here I expect always a changed value
|
||||||
this->m_aircraftsInRange.applyIf(&CAircraft::getCallsign, callsign, vm, false);
|
this->m_aircraftsInRange.applyIf(&CAircraft::getCallsign, callsign, vm, false);
|
||||||
|
this->m_aircraftWatchdog.resetCallsign(callsign);
|
||||||
emit this->changedAircraftSituation(callsign, situation);
|
emit this->changedAircraftSituation(callsign, situation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,6 +571,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
|
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
|
||||||
bool contains = this->m_aircraftsInRange.contains(&CAircraft::getCallsign, callsign);
|
bool contains = this->m_aircraftsInRange.contains(&CAircraft::getCallsign, callsign);
|
||||||
|
this->m_aircraftWatchdog.removeCallsign(callsign);
|
||||||
if (contains)
|
if (contains)
|
||||||
{
|
{
|
||||||
this->m_aircraftsInRange.removeIf(&CAircraft::getCallsign, callsign);
|
this->m_aircraftsInRange.removeIf(&CAircraft::getCallsign, callsign);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include "vatsimbookingreader.h"
|
#include "vatsimbookingreader.h"
|
||||||
#include "vatsimdatafilereader.h"
|
#include "vatsimdatafilereader.h"
|
||||||
|
#include "airspace_watchdog.h"
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -133,6 +134,8 @@ namespace BlackCore
|
|||||||
INetwork *m_network;
|
INetwork *m_network;
|
||||||
CVatsimBookingReader *m_vatsimBookingReader;
|
CVatsimBookingReader *m_vatsimBookingReader;
|
||||||
CVatsimDataFileReader *m_vatsimDataFileReader;
|
CVatsimDataFileReader *m_vatsimDataFileReader;
|
||||||
|
CAirspaceWatchdog m_atcWatchdog;
|
||||||
|
CAirspaceWatchdog m_aircraftWatchdog;
|
||||||
|
|
||||||
// FIXME (MS) should be in INetwork
|
// FIXME (MS) should be in INetwork
|
||||||
void sendFsipiCustomPacket(const BlackMisc::Aviation::CCallsign &recipientCallsign) const;
|
void sendFsipiCustomPacket(const BlackMisc::Aviation::CCallsign &recipientCallsign) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user