mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #452 signals in reader classes. adjusted METAR reader
* renamed to connectDataReadSignal * removed unused individual signals, e.g. vatsimMetarsRead -> replace by data read signal + entity flag * added data in METAR class (kept there, not in airspace monitor) -> reader aware
This commit is contained in:
committed by
Mathew Sutcliffe
parent
29d436ee67
commit
8827b68b3b
@@ -8,12 +8,16 @@
|
||||
*/
|
||||
|
||||
#include "vatsimmetarreader.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QTextStream>
|
||||
#include <QFile>
|
||||
#include <QReadLocker>
|
||||
#include <QWriteLocker>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Weather;
|
||||
|
||||
namespace BlackCore
|
||||
@@ -34,6 +38,24 @@ namespace BlackCore
|
||||
Q_UNUSED(s);
|
||||
}
|
||||
|
||||
CMetarSet CVatsimMetarReader::getMetars() const
|
||||
{
|
||||
QReadLocker l(&m_lock);
|
||||
return m_metars;
|
||||
}
|
||||
|
||||
CMetar CVatsimMetarReader::getMetarForAirport(const Aviation::CAirportIcaoCode &icao) const
|
||||
{
|
||||
QReadLocker l(&m_lock);
|
||||
return m_metars.getMetarForAirport(icao);
|
||||
}
|
||||
|
||||
int CVatsimMetarReader::getMetarsCount() const
|
||||
{
|
||||
QReadLocker l(&m_lock);
|
||||
return m_metars.size();
|
||||
}
|
||||
|
||||
void CVatsimMetarReader::ps_readMetars()
|
||||
{
|
||||
this->threadAssertCheck();
|
||||
@@ -85,19 +107,26 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
QWriteLocker l(&m_lock);
|
||||
m_metars = metars;
|
||||
}
|
||||
|
||||
// I could use those for logging, etc.
|
||||
Q_UNUSED(invalidMetars);
|
||||
if (invalidLineCount > 0)
|
||||
{
|
||||
CLogMessage(this).warning("Reading METARs failed for %1 entries") << invalidLineCount;
|
||||
}
|
||||
emit dataRead(metars);
|
||||
emit metarsRead(metars);
|
||||
emit dataRead(CEntityFlags::MetarEntity, CEntityFlags::ReadFinished, metars.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
// network error
|
||||
CLogMessage(this).warning("Reading METARs failed %1 %2") << nwReply->errorString() << nwReply->url().toString();
|
||||
nwReply->abort();
|
||||
emit dataRead(CEntityFlags::MetarEntity, CEntityFlags::ReadFailed, 0);
|
||||
}
|
||||
} // method
|
||||
|
||||
|
||||
Reference in New Issue
Block a user