Added method getSelectedAtcStations() to network context.

Further isConnected checks in order to avoid updating when not connected (leading to wrnings / errors)
This commit is contained in:
Klaus Basan
2014-02-05 21:45:17 +00:00
committed by Mathew Sutcliffe
parent 243ace74fe
commit 6aa6058c57
5 changed files with 51 additions and 12 deletions

View File

@@ -158,6 +158,9 @@ namespace BlackCore
*/
virtual BlackMisc::Voice::CVoiceRoomList getSelectedVoiceRooms() const;
//! \copydoc IContextNetwork::getSelectedAtcStations
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const;
/*!
* \copydoc IContextNetwork::getUsers()
*/

View File

@@ -31,8 +31,12 @@ namespace BlackCore
aircraft.setIcaoInfo(icaoData);
aircraft.calculcateDistanceToPlane(this->m_ownAircraft.getPosition());
this->m_aircraftsInRange.push_back(aircraft);
emit this->m_network->sendFrequencyQuery(callsign);
emit this->m_network->sendRealNameQuery(callsign);
if (this->isConnected())
{
// emit only if still connected
emit this->m_network->sendFrequencyQuery(callsign);
emit this->m_network->sendRealNameQuery(callsign);
}
emit this->changedAircraftsInRange();
}
else
@@ -60,9 +64,14 @@ namespace BlackCore
aircraft.setTransponder(transponder);
aircraft.calculcateDistanceToPlane(this->m_ownAircraft.getPosition());
this->m_aircraftsInRange.push_back(aircraft);
emit this->m_network->sendFrequencyQuery(callsign);
emit this->m_network->sendRealNameQuery(callsign);
emit this->m_network->sendIcaoCodesQuery(callsign);
if (this->isConnected())
{
// only emit if still connected
emit this->m_network->sendFrequencyQuery(callsign);
emit this->m_network->sendRealNameQuery(callsign);
emit this->m_network->sendIcaoCodesQuery(callsign);
}
emit this->changedAircraftsInRange();
}
else

View File

@@ -85,17 +85,30 @@ namespace BlackCore
/*
* Selected voice rooms
*/
CVoiceRoomList CContextNetwork::getSelectedVoiceRooms() const
CAtcStationList CContextNetwork::getSelectedAtcStations() const
{
CAtcStationList stationsCom1 = this->m_atcStationsOnline.findIfComUnitTunedIn25KHz(this->m_ownAircraft.getCom1System());
CAtcStationList stationsCom2 = this->m_atcStationsOnline.findIfComUnitTunedIn25KHz(this->m_ownAircraft.getCom2System());
stationsCom1.sortBy(&CAtcStation::getDistanceToPlane);
stationsCom2.sortBy(&CAtcStation::getDistanceToPlane);
CVoiceRoom vr;
CAtcStation s;
CAtcStationList stations;
stations.push_back(stationsCom1.isEmpty() ? s : stationsCom1[0]);
stations.push_back(stationsCom2.isEmpty() ? s : stationsCom2[0]);
return stations;
}
/*
* Selected voice rooms
*/
CVoiceRoomList CContextNetwork::getSelectedVoiceRooms() const
{
CAtcStationList stations = this->getSelectedAtcStations();
Q_ASSERT(stations.size() == 2);
CVoiceRoomList rooms;
rooms.push_back(stationsCom1.isEmpty() ? vr : stationsCom1[0].getVoiceRoom());
rooms.push_back(stationsCom2.isEmpty() ? vr : stationsCom2[0].getVoiceRoom());
rooms.push_back(stations[0].getVoiceRoom());
rooms.push_back(stations[1].getVoiceRoom());
return rooms;
}
@@ -181,9 +194,13 @@ namespace BlackCore
station.calculcateDistanceToPlane(this->m_ownAircraft.getPosition());
this->m_atcStationsOnline.push_back(station);
emit this->changedAtcStationsOnline();
emit this->m_network->sendAtisQuery(callsign); // request ATIS
emit this->m_network->sendRealNameQuery(callsign);
emit this->m_network->sendServerQuery(callsign);
if (this->isConnected())
{
emit this->m_network->sendAtisQuery(callsign); // request ATIS
emit this->m_network->sendRealNameQuery(callsign);
emit this->m_network->sendServerQuery(callsign);
}
}
else
{

View File

@@ -96,6 +96,11 @@ namespace BlackCore
return this->m_dBusInterface->callDBusRet<BlackMisc::Voice::CVoiceRoomList>(QLatin1Literal("getSelectedVoiceRooms"));
}
BlackMisc::Aviation::CAtcStationList IContextNetwork::getSelectedAtcStations() const
{
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAtcStationList>(QLatin1Literal("getSelectedAtcStations"));
}
BlackMisc::Aviation::CAircraft IContextNetwork::getOwnAircraft() const
{
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraft>(QLatin1Literal("getOwnAircraft"));

View File

@@ -247,6 +247,11 @@ namespace BlackCore
* \brief Use the selected COM1/2 frequencies, and get the corresponding voice room for it
*/
virtual BlackMisc::Voice::CVoiceRoomList getSelectedVoiceRooms() const;
/*!
* \brief Use the selected COM1/2 frequencies, and get the corresponding ATC stations for it
*/
virtual BlackMisc::Aviation::CAtcStationList getSelectedAtcStations() const;
};
}