Finetuning

* Improved reloading of booked stations
* Improved error reporting in data file reader
* Finetuning of network context, mostly reg. VATSIM data file
This commit is contained in:
Klaus Basan
2014-06-09 02:47:32 +02:00
parent 1b83197691
commit 2325881c91
5 changed files with 46 additions and 22 deletions

View File

@@ -51,15 +51,17 @@ namespace BlackCore
aircraft.setCallsign(callsign);
aircraft.setSituation(situation);
aircraft.setTransponder(transponder);
aircraft.calculcateDistanceToPlane(this->ownAircraft().getPosition());
this->m_vatsimDataFileReader->getAircrafts().updateFromVatsimDataFileAircraft(aircraft);
aircraft.setCalculcatedDistanceToPosition(this->ownAircraft().getPosition()); // distance from myself
this->m_vatsimDataFileReader->updateWithVatsimDataFileData(aircraft);
this->m_aircraftsInRange.push_back(aircraft);
// and new client, there is a chance it has been created by
// custom package first
if (!this->m_otherClients.contains(&CClient::getCallsign, callsign))
this->m_otherClients.push_back(CClient(callsign)); // initial, will be filled by data later
{
CClient c(callsign);
this->m_otherClients.push_back(c); // initial, will be filled by data later
}
if (this->isConnected())
{
@@ -75,7 +77,7 @@ namespace BlackCore
else
{
// update
CLength distance = this->ownAircraft().calculcateDistanceToPlane(situation.getPosition());
CLength distance = this->ownAircraft().calculcateDistanceToPosition(situation.getPosition());
distance.switchUnit(CLengthUnit::NM());
CIndexVariantMap vm;
vm.addValue(CAircraft::IndexTransponder, transponder);

View File

@@ -45,7 +45,7 @@ namespace BlackCore
*/
void CContextNetwork::psReceivedBookings(const CAtcStationList &bookedStations)
{
const int interval = 60 * 1000;
const int interval = 180 * 1000;
if (this->m_vatsimBookingReader->interval() < interval) this->m_vatsimBookingReader->setInterval(interval);
this->m_atcStationsBooked.clear();
foreach(CAtcStation bookedStation, bookedStations)
@@ -266,15 +266,20 @@ namespace BlackCore
{
QString trimmedUrl = url.trimmed();
CIndexVariantMap vm(CAtcStation::IndexVoiceRoomUrl, trimmedUrl);
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign))
{
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
emit this->changedAtcStationsBooked();
}
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign))
{
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
CAtcStation station = this->m_atcStationsOnline.findFirstByCallsign(callsign);
emit this->changedAtcStationsBooked();
emit this->changedAtcStationOnlineConnectionStatus(station, true);
}
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
vm = CIndexVariantMap(CClient::IndexVoiceCapabilities, CVoiceCapabilities(CVoiceCapabilities::Voice).toQVariant());
this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm);
}
/*

View File

@@ -40,24 +40,24 @@ namespace BlackCore
// 1. Init by "network driver"
this->m_network = new CNetworkVatlib(this);
// 3. Init VATSIM bookings
// 2. Init VATSIM bookings
this->m_vatsimBookingReader = new CVatsimBookingReader(this->getRuntime()->getIContextSettings()->getNetworkSettings().getBookingServiceUrl(), this);
this->connect(this->m_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CContextNetwork::psReceivedBookings);
this->m_vatsimBookingReader->setInterval(10 * 1000); // first read
this->m_vatsimBookingReader->setInterval(15 * 1000); // first read
// 4. VATSIM data file
// 3. VATSIM data file
QStringList dataFileUrls;
dataFileUrls << "http://info.vroute.net/vatsim-data.txt";
this->m_vatsimDataFileReader = new CVatsimDataFileReader(dataFileUrls, this);
this->connect(this->m_vatsimDataFileReader, &CVatsimDataFileReader::dataRead, this, &CContextNetwork::psDataFileRead);
this->m_vatsimDataFileReader->setInterval(5 * 1000); // first read, will be fixed when first read to longer period
// 5. Update timer for data (network data such as frequency)
// 4. Update timer for data (network data such as frequency)
this->m_dataUpdateTimer = new QTimer(this);
this->connect(this->m_dataUpdateTimer, &QTimer::timeout, this, &CContextNetwork::requestDataUpdates);
this->m_dataUpdateTimer->start(30 * 1000);
// 6. connect signals and slots
// 5. connect signals and slots
this->connect(this->m_network, &INetwork::connectionStatusChanged, this, &CContextNetwork::psFsdConnectionStatusChanged);
this->connect(this->m_network, &INetwork::atcPositionUpdate, this, &CContextNetwork::psFsdAtcPositionUpdate);
this->connect(this->m_network, &INetwork::atisReplyReceived, this, &CContextNetwork::psFsdAtisQueryReceived);
@@ -375,12 +375,12 @@ namespace BlackCore
}
/*
* Data file has been read
* Data file (VATSIM) has been read
*/
void CContextNetwork::psDataFileRead()
{
if (this->getRuntime()->isSlotLogForNetworkEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
const int interval = 60 * 1000;
const int interval = 90 * 1000;
if (this->m_vatsimDataFileReader->interval() < interval) this->m_vatsimDataFileReader->setInterval(interval);
this->getIContextApplication()->sendStatusMessage(CStatusMessage::getInfoMessage("Read VATSIM data file", CStatusMessage::TypeTrafficNetwork));
}

View File

@@ -122,10 +122,12 @@ namespace BlackCore
/*
* Data file read from XML
* Example: http://info.vroute.net/vatsim-data.txt
*/
void CVatsimDataFileReader::parseVatsimFileInBackground(QNetworkReply *nwReply)
{
// Example: http://info.vroute.net/vatsim-data.txt
QStringList illegalIcaoCodes;
if (nwReply->error() == QNetworkReply::NoError)
{
const QString dataFileData = nwReply->readAll();
@@ -211,8 +213,7 @@ namespace BlackCore
}
else
{
const QString w = QString("Illegal ICAO code in VATSIM data file: %1").arg(icaoCode);
qWarning(w.toLatin1());
illegalIcaoCodes.append(icaoCode);
}
}
@@ -265,6 +266,13 @@ namespace BlackCore
nwReply->close();
nwReply->deleteLater(); // we are responsible for reading this
emit this->dataRead();
// warnings, if required
if (!illegalIcaoCodes.isEmpty())
{
const QString w = QString("Illegal ICAO code(s) in VATSIM data file: %1").arg(illegalIcaoCodes.join(", "));
qWarning(w.toLatin1());
}
}
const QMap<QString, QString> CVatsimDataFileReader::clientPartsToMap(const QString &currentLine, const QStringList &clientSectionAttributes)