mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #93, update network data such as ATIS or pilot frequencies from time to time,
as these data are not actively pushed from network when changing * timer in network context * update methods, one specific method for ATIS as this can also be manually re-read(from GUI)
This commit is contained in:
@@ -33,13 +33,18 @@ namespace BlackCore
|
||||
// 2. Init own aircraft
|
||||
this->initOwnAircraft();
|
||||
|
||||
// 3. Init network access driver for XML data (bookings)
|
||||
// 3a. Init network access driver for XML data (bookings)
|
||||
this->m_networkManager = new QNetworkAccessManager(this);
|
||||
this->m_atcBookingTimer = new QTimer(this);
|
||||
this->connect(this->m_networkManager, &QNetworkAccessManager::finished, this, &CContextNetwork::psAtcBookingsRead);
|
||||
this->connect(this->m_atcBookingTimer, &QTimer::timeout, this, &CContextNetwork::readAtcBookingsFromSource);
|
||||
this->m_atcBookingTimer->start(10 * 1000); // will be reset in method to a longer time
|
||||
|
||||
// 3b. Update timer for data
|
||||
this->m_dataUpdateTimer = new QTimer(this);
|
||||
this->connect(this->m_dataUpdateTimer, &QTimer::timeout, this, &CContextNetwork::requestDataUpdates);
|
||||
this->m_dataUpdateTimer->start(30 * 1000);
|
||||
|
||||
// 4. connect signals and slots
|
||||
this->connect(this->m_network, &INetwork::connectionStatusChanged, this, &CContextNetwork::psFsdConnectionStatusChanged);
|
||||
this->connect(this->m_network, &INetwork::atcPositionUpdate, this, &CContextNetwork::psFsdAtcPositionUpdate);
|
||||
|
||||
@@ -159,6 +159,12 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::getUsersForCallsigns
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const;
|
||||
|
||||
//! \copydoc IContextNetwork::requestDataUpdates
|
||||
virtual void requestDataUpdates();
|
||||
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates();
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsOnline;
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStationsBooked;
|
||||
@@ -169,7 +175,8 @@ namespace BlackCore
|
||||
|
||||
// for reading XML
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QTimer *m_atcBookingTimer;
|
||||
QTimer *m_atcBookingTimer; //!< ATC stations bookings
|
||||
QTimer *m_dataUpdateTimer; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
|
||||
QDateTime m_atcBookingsUpdateTimestamp;
|
||||
|
||||
/*!
|
||||
@@ -291,6 +298,7 @@ namespace BlackCore
|
||||
* \todo encapsulate reading from WWW in some class
|
||||
*/
|
||||
void psAtcBookingsRead(QNetworkReply *nwReply);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,35 @@ namespace BlackCore
|
||||
this->m_networkManager->get(request);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update data
|
||||
*/
|
||||
void CContextNetwork::requestDataUpdates()
|
||||
{
|
||||
Q_ASSERT(this->m_network);
|
||||
if (!this->isConnected()) return;
|
||||
this->requestAtisUpdates();
|
||||
|
||||
// other updates
|
||||
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
||||
{
|
||||
this->m_network->sendFrequencyQuery(aircraft.getCallsign());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Request new ATIS data
|
||||
*/
|
||||
void CContextNetwork::requestAtisUpdates()
|
||||
{
|
||||
Q_ASSERT(this->m_network);
|
||||
if (!this->isConnected()) return;
|
||||
foreach(CAtcStation station, this->m_atcStationsOnline)
|
||||
{
|
||||
this->m_network->sendAtisQuery(station.getCallsign());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Booked stations
|
||||
*/
|
||||
|
||||
@@ -101,6 +101,16 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAtcStationList>(QLatin1Literal("getSelectedAtcStations"));
|
||||
}
|
||||
|
||||
void IContextNetwork::requestDataUpdates()
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("requestDataUpdates"));
|
||||
}
|
||||
|
||||
void IContextNetwork::requestAtisUpdates()
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("requestAtisUpdates"));
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CAircraft IContextNetwork::getOwnAircraft() const
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraft>(QLatin1Literal("getOwnAircraft"));
|
||||
|
||||
@@ -252,6 +252,16 @@ namespace BlackCore
|
||||
* \brief Use the selected COM1/2 frequencies, and get the corresponding ATC stations for it
|
||||
*/
|
||||
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const;
|
||||
|
||||
/*!
|
||||
* \brief Request data updates (pilot' frequencies, ATIS, ..)
|
||||
*/
|
||||
virtual void requestDataUpdates();
|
||||
|
||||
/*!
|
||||
* \brief Request ATIS updates (for all stations)
|
||||
*/
|
||||
virtual void requestAtisUpdates();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user