refs #452, changed DB read signals to combined signal with flags

This commit is contained in:
Klaus Basan
2015-09-23 19:38:04 +02:00
committed by Mathew Sutcliffe
parent 542c93051f
commit 898b4fc935
4 changed files with 38 additions and 31 deletions

View File

@@ -20,6 +20,7 @@
#include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/simulation/simulatedaircraftlist.h"
#include "blackmisc/statusmessage.h" #include "blackmisc/statusmessage.h"
#include "blackmisc/statusmessagelist.h" #include "blackmisc/statusmessagelist.h"
#include "blackmisc/network/dbflags.h"
#include "blackmisc/network/textmessagelist.h" #include "blackmisc/network/textmessagelist.h"
#include "blackmisc/network/userlist.h" #include "blackmisc/network/userlist.h"
#include "blackmisc/network/clientlist.h" #include "blackmisc/network/clientlist.h"
@@ -39,7 +40,6 @@
namespace BlackCore namespace BlackCore
{ {
//! Network context proxy //! Network context proxy
class BLACKCORE_EXPORT IContextNetwork : public CContext class BLACKCORE_EXPORT IContextNetwork : public CContext
{ {
@@ -144,20 +144,8 @@ namespace BlackCore
//! Metar read //! Metar read
void vatsimMetarsRead(int number); void vatsimMetarsRead(int number);
//! ICAO codes read //! swift DB data read
void aircraftIcaoCodeRead(int number); void swiftDbDataRead(BlackMisc::Network::CDbFlags::Entity entity, BlackMisc::Network::CDbFlags::ReadState, int number);
//! ICAO codes read
void airlineIcaoCodeRead(int number);
//! Liveries read
void liveriesRead(int number);
//! Distributors read
void distributorsRead(int number);
//! Number of models read
void modelsRead(int number);
public slots: public slots:
//! Reload bookings from booking service //! Reload bookings from booking service

View File

@@ -16,7 +16,7 @@
#include "network_vatlib.h" #include "network_vatlib.h"
#include "vatsim_metar_reader.h" #include "vatsim_metar_reader.h"
#include "airspace_monitor.h" #include "airspace_monitor.h"
#include "web_datareader.h" #include "webdataservices.h"
#include "blackmisc/networkutils.h" #include "blackmisc/networkutils.h"
#include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/aviation/atcstationlist.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
@@ -58,20 +58,18 @@ namespace BlackCore
this->m_dataUpdateTimer->start(30 * 1000); this->m_dataUpdateTimer->start(30 * 1000);
// 3. data reader // 3. data reader
this->m_webDataReader = new CWebDataReader(CWebDataReader::AllReaders, this); this->m_webDataReader = new CWebDataServices(CWebReaderFlags::AllReaders, this);
this->m_webReaderSignalConnections = this->m_webDataReader->connectVatsimDataSignals( this->m_webReaderSignalConnections = this->m_webDataReader->connectVatsimDataSignals(
this, // the object here must be the same as in the bind
std::bind(&CContextNetwork::vatsimBookingsRead, this, std::placeholders::_1), std::bind(&CContextNetwork::vatsimBookingsRead, this, std::placeholders::_1),
std::bind(&CContextNetwork::vatsimDataFileRead, this, std::placeholders::_1), std::bind(&CContextNetwork::vatsimDataFileRead, this, std::placeholders::_1),
std::bind(&CContextNetwork::vatsimMetarsRead, this, std::placeholders::_1)); std::bind(&CContextNetwork::vatsimMetarsRead, this, std::placeholders::_1));
this->m_webReaderSignalConnections.append( this->m_webReaderSignalConnections.append(
this->m_webDataReader->connectSwiftDatabaseSignals( this->m_webDataReader->connectSwiftDatabaseSignals(
this, // the object here must be the same as in the bind this, // the object here must be the same as in the bind
std::bind(&CContextNetwork::aircraftIcaoCodeRead, this, std::placeholders::_1), std::bind(&CContextNetwork::swiftDbDataRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
std::bind(&CContextNetwork::airlineIcaoCodeRead, this, std::placeholders::_1), )
std::bind(&CContextNetwork::liveriesRead, this, std::placeholders::_1), );
std::bind(&CContextNetwork::distributorsRead, this, std::placeholders::_1),
std::bind(&CContextNetwork::modelsRead, this, std::placeholders::_1)
));
this->m_webDataReader->readAllInBackground(1000); this->m_webDataReader->readAllInBackground(1000);
// 4. Airspace contents // 4. Airspace contents
@@ -143,7 +141,7 @@ namespace BlackCore
void CContextNetwork::gracefulShutdown() void CContextNetwork::gracefulShutdown()
{ {
this->disconnect(); // all signals this->disconnect(); // all signals
this->m_webReaderSignalConnections.clear(); // disconnect this->disconnectReaderSignals(); // disconnect
this->m_webDataReader->gracefulShutdown(); this->m_webDataReader->gracefulShutdown();
if (this->isConnected()) { this->disconnectFromNetwork(); } if (this->isConnected()) { this->disconnectFromNetwork(); }
@@ -158,7 +156,7 @@ namespace BlackCore
{ {
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityError, "Invalid user credentials"); return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityError, "Invalid user credentials");
} }
else if (!this->ownAircraft().getIcaoInfo().hasAircraftDesignator()) else if (!this->ownAircraft().getAircraftIcaoCode().hasDesignator())
{ {
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityError, "Invalid ICAO data for own aircraft"); return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityError, "Invalid ICAO data for own aircraft");
} }
@@ -180,11 +178,11 @@ namespace BlackCore
this->m_airspace->setConnected(true); this->m_airspace->setConnected(true);
INetwork::LoginMode mode = static_cast<INetwork::LoginMode>(loginMode); INetwork::LoginMode mode = static_cast<INetwork::LoginMode>(loginMode);
this->getIContextOwnAircraft()->updateOwnAircraftPilot(server.getUser()); this->getIContextOwnAircraft()->updateOwnAircraftPilot(server.getUser());
const CAircraft ownAircraft = this->ownAircraft(); const CSimulatedAircraft ownAircraft(this->ownAircraft());
this->m_network->presetServer(server); this->m_network->presetServer(server);
this->m_network->presetLoginMode(mode); this->m_network->presetLoginMode(mode);
this->m_network->presetCallsign(ownAircraft.getCallsign()); this->m_network->presetCallsign(ownAircraft.getCallsign());
this->m_network->presetIcaoCodes(ownAircraft.getIcaoInfo()); this->m_network->presetIcaoCodes(ownAircraft);
if (getIContextSimulator()) if (getIContextSimulator())
{ {
this->m_network->presetSimulatorInfo(getIContextSimulator()->getSimulatorPluginInfo()); this->m_network->presetSimulatorInfo(getIContextSimulator()->getSimulatorPluginInfo());
@@ -469,6 +467,15 @@ namespace BlackCore
return this->getRuntime()->getCContextOwnAircraft()->getOwnAircraft(); return this->getRuntime()->getCContextOwnAircraft()->getOwnAircraft();
} }
void CContextNetwork::disconnectReaderSignals()
{
for (QMetaObject::Connection c : m_webReaderSignalConnections)
{
QObject::disconnect(c);
}
m_webReaderSignalConnections.clear();
}
CAtcStationList CContextNetwork::getAtcStationsOnline() const CAtcStationList CContextNetwork::getAtcStationsOnline() const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
@@ -496,7 +503,13 @@ namespace BlackCore
CSimulatedAircraft CContextNetwork::getAircraftInRangeForCallsign(const CCallsign &callsign) const CSimulatedAircraft CContextNetwork::getAircraftInRangeForCallsign(const CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->getAircraftInRange().findFirstByCallsign(callsign); return this->m_airspace->getAircraftInRangeForCallsign(callsign);
}
CAircraftModel CContextNetwork::getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const
{
if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
return this->m_airspace->getAircraftInRangeModelForCallsign(callsign);
} }
CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const

View File

@@ -33,8 +33,8 @@
namespace BlackCore namespace BlackCore
{ {
class CAirspaceMonitor; class CAirspaceMonitor;
class CWebDataReader;
class CVatsimMetarReader; class CVatsimMetarReader;
class CWebDataServices;
//! Network context implementation //! Network context implementation
class BLACKCORE_EXPORT CContextNetwork : class BLACKCORE_EXPORT CContextNetwork :
@@ -131,6 +131,10 @@ namespace BlackCore
//! \ingroup remoteaircraftprovider //! \ingroup remoteaircraftprovider
virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
//! \copydoc IContextNetwork::getAircraftinRangeModelForCallsign
//! \ingroup remoteaircraftprovider
virtual BlackMisc::Simulation::CAircraftModel getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
//! \copydoc IContextNetwork::getOnlineStationForCallsign //! \copydoc IContextNetwork::getOnlineStationForCallsign
virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
@@ -236,7 +240,7 @@ namespace BlackCore
private: private:
CAirspaceMonitor *m_airspace = nullptr; CAirspaceMonitor *m_airspace = nullptr;
INetwork *m_network = nullptr; INetwork *m_network = nullptr;
CWebDataReader *m_webDataReader = nullptr; //!< web service readers CWebDataServices *m_webDataReader = nullptr; //!< web service readers
QList<QMetaObject::Connection> m_webReaderSignalConnections; QList<QMetaObject::Connection> m_webReaderSignalConnections;
INetwork::ConnectionStatus m_currentStatus = INetwork::Disconnected; //!< used to detect pending connections INetwork::ConnectionStatus m_currentStatus = INetwork::Disconnected; //!< used to detect pending connections
QTimer *m_dataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates() QTimer *m_dataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
@@ -250,6 +254,9 @@ namespace BlackCore
//! Own aircraft from \sa CContextOwnAircraft //! Own aircraft from \sa CContextOwnAircraft
const BlackMisc::Simulation::CSimulatedAircraft ownAircraft() const; const BlackMisc::Simulation::CSimulatedAircraft ownAircraft() const;
//! Disconnect all signals from swift DB readers
void disconnectReaderSignals();
private slots: private slots:
//! Update METAR collection //! Update METAR collection
void ps_updateMetars(const BlackMisc::Weather::CMetarSet &metars); void ps_updateMetars(const BlackMisc::Weather::CMetarSet &metars);

View File

@@ -20,7 +20,6 @@ using namespace BlackMisc::Weather;
namespace BlackCore namespace BlackCore
{ {
/* /*
* Constructor for DBus * Constructor for DBus
*/ */