mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
refs #242, adjusted network context
* some formatting * own aircraft data used for voice room member resolution
This commit is contained in:
@@ -53,6 +53,9 @@ namespace BlackCore
|
|||||||
//! ATC station (booked) list has been changed
|
//! ATC station (booked) list has been changed
|
||||||
void changedAtcStationsBooked();
|
void changedAtcStationsBooked();
|
||||||
|
|
||||||
|
//! Connection status changed for online station
|
||||||
|
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &atcStation, bool connected);
|
||||||
|
|
||||||
//! Aircraft list has been changed
|
//! Aircraft list has been changed
|
||||||
void changedAircraftsInRange();
|
void changedAircraftsInRange();
|
||||||
|
|
||||||
|
|||||||
@@ -145,8 +145,12 @@ namespace BlackCore
|
|||||||
|
|
||||||
CAtcStation s;
|
CAtcStation s;
|
||||||
CAtcStationList stations;
|
CAtcStationList stations;
|
||||||
stations.push_back(stationsCom1.isEmpty() ? s : stationsCom1[0]);
|
CAtcStation com1 = stationsCom1.isEmpty() ? s : stationsCom1[0];
|
||||||
stations.push_back(stationsCom2.isEmpty() ? s : stationsCom2[0]);
|
CAtcStation com2 = stationsCom2.isEmpty() ? s : stationsCom2[0];
|
||||||
|
|
||||||
|
stations.push_back(com1);
|
||||||
|
stations.push_back(com2);
|
||||||
|
|
||||||
return stations;
|
return stations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +172,6 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::psFsdAtcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
|
void CContextNetwork::psFsdAtcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
|
||||||
{
|
{
|
||||||
// this->log(Q_FUNC_INFO, callsign.toQString(), frequency.toQString(), position.toQString(), range.toQString());
|
|
||||||
CAtcStationList stationsWithCallsign = this->m_atcStationsOnline.findByCallsign(callsign);
|
CAtcStationList stationsWithCallsign = this->m_atcStationsOnline.findByCallsign(callsign);
|
||||||
if (stationsWithCallsign.isEmpty())
|
if (stationsWithCallsign.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -182,14 +185,17 @@ namespace BlackCore
|
|||||||
station.calculcateDistanceToPlane(this->ownAircraft().getPosition());
|
station.calculcateDistanceToPlane(this->ownAircraft().getPosition());
|
||||||
this->m_vatsimDataFileReader->getAtcStations().updateFromVatsimDataFileStation(station); // prefill
|
this->m_vatsimDataFileReader->getAtcStations().updateFromVatsimDataFileStation(station); // prefill
|
||||||
this->m_atcStationsOnline.push_back(station);
|
this->m_atcStationsOnline.push_back(station);
|
||||||
emit this->changedAtcStationsOnline();
|
|
||||||
|
|
||||||
if (this->isConnected())
|
if (this->isConnected())
|
||||||
{
|
{
|
||||||
emit this->m_network->sendAtisQuery(callsign); // request ATIS
|
|
||||||
emit this->m_network->sendRealNameQuery(callsign);
|
emit this->m_network->sendRealNameQuery(callsign);
|
||||||
|
emit this->m_network->sendAtisQuery(callsign); // request ATIS and voice rooms
|
||||||
emit this->m_network->sendServerQuery(callsign);
|
emit this->m_network->sendServerQuery(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit this->changedAtcStationsOnline();
|
||||||
|
// Remark: this->changedAtcStationOnlineConnectionStatus(station, true);
|
||||||
|
// will be sent in psFsdAtisVoiceRoomQueryReceived
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -208,8 +214,15 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::psFsdAtcControllerDisconnected(const CCallsign &callsign)
|
void CContextNetwork::psFsdAtcControllerDisconnected(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
|
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign))
|
||||||
emit this->changedAtcStationsOnline();
|
{
|
||||||
|
CAtcStation removeStation = this->m_atcStationsOnline.findByCallsign(callsign).front();
|
||||||
|
this->m_atcStationsOnline.removeIf(&CAtcStation::getCallsign, callsign);
|
||||||
|
emit this->changedAtcStationsOnline();
|
||||||
|
emit this->changedAtcStationOnlineConnectionStatus(removeStation, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// booked
|
||||||
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, CIndexVariantMap(CAtcStation::IndexIsOnline, QVariant(false)));
|
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, CIndexVariantMap(CAtcStation::IndexIsOnline, QVariant(false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +248,12 @@ namespace BlackCore
|
|||||||
CIndexVariantMap vm(CAtcStation::IndexVoiceRoomUrl, trimmedUrl);
|
CIndexVariantMap vm(CAtcStation::IndexVoiceRoomUrl, trimmedUrl);
|
||||||
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
|
||||||
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
|
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign))
|
||||||
|
{
|
||||||
|
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();
|
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +285,6 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CContextNetwork::psFsdMetarReceived(const QString &metarMessage)
|
void CContextNetwork::psFsdMetarReceived(const QString &metarMessage)
|
||||||
{
|
{
|
||||||
// this->log(Q_FUNC_INFO, metarMessage);
|
|
||||||
if (metarMessage.length() < 10) return; // invalid
|
if (metarMessage.length() < 10) return; // invalid
|
||||||
const QString icaoCode = metarMessage.left(4).toUpper();
|
const QString icaoCode = metarMessage.left(4).toUpper();
|
||||||
const QString icaoCodeTower = icaoCode + "_TWR";
|
const QString icaoCodeTower = icaoCode + "_TWR";
|
||||||
|
|||||||
@@ -314,6 +314,14 @@ namespace BlackCore
|
|||||||
if (callsigns.isEmpty()) return users;
|
if (callsigns.isEmpty()) return users;
|
||||||
CCallsignList searchList(callsigns);
|
CCallsignList searchList(callsigns);
|
||||||
|
|
||||||
|
// myself, which is not in the lists below
|
||||||
|
CAircraft ownAircraft = this->getOwnAircraft();
|
||||||
|
if (!ownAircraft.getCallsign().isEmpty() && searchList.contains(ownAircraft.getCallsign()))
|
||||||
|
{
|
||||||
|
searchList.remove(ownAircraft.getCallsign());
|
||||||
|
users.push_back(ownAircraft.getPilot());
|
||||||
|
}
|
||||||
|
|
||||||
// do aircrafts first, this will handle most callsigns
|
// do aircrafts first, this will handle most callsigns
|
||||||
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
||||||
{
|
{
|
||||||
@@ -408,7 +416,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send as message
|
// send as message
|
||||||
QString m("connection status changed from %1 to %2");
|
QString m("Connection status changed from %1 to %2");
|
||||||
m = m.arg(INetwork::connectionStatusToString(from), INetwork::connectionStatusToString(to));
|
m = m.arg(INetwork::connectionStatusToString(from), INetwork::connectionStatusToString(to));
|
||||||
if (!message.isEmpty()) m.append(" ").append(message);
|
if (!message.isEmpty()) m.append(" ").append(message);
|
||||||
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork,
|
msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork,
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ namespace BlackCore
|
|||||||
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||||
"changedAtcStationsOnline", this, SIGNAL(changedAtcStationsOnline()));
|
"changedAtcStationsOnline", this, SIGNAL(changedAtcStationsOnline()));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||||
|
"changedAtcStationOnlineConnectionStatus", this, SIGNAL(changedAtcStationOnlineConnectionStatus(BlackMisc::Aviation::CAtcStation,bool)));
|
||||||
|
Q_ASSERT(s);
|
||||||
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||||
"connectionTerminated", this, SIGNAL(connectionTerminated()));
|
"connectionTerminated", this, SIGNAL(connectionTerminated()));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
|
|
||||||
//! \brief Network context proxy
|
//! Network context proxy
|
||||||
class CContextNetworkProxy : public IContextNetwork
|
class CContextNetworkProxy : public IContextNetwork
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -34,14 +34,14 @@ namespace BlackCore
|
|||||||
private:
|
private:
|
||||||
BlackMisc::CGenericDBusInterface *m_dBusInterface; /*!< DBus interface */
|
BlackMisc::CGenericDBusInterface *m_dBusInterface; /*!< DBus interface */
|
||||||
|
|
||||||
//! \brief Relay connection signals to local signals.
|
//! Relay connection signals to local signals.
|
||||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \brief Constructor
|
//! Constructor
|
||||||
CContextNetworkProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr) {}
|
CContextNetworkProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr) {}
|
||||||
|
|
||||||
//! \brief DBus version constructor
|
//! DBus version constructor
|
||||||
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||||
|
|
||||||
public slots: // IContextNetwork overrides
|
public slots: // IContextNetwork overrides
|
||||||
@@ -49,16 +49,10 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||||
virtual void readAtcBookingsFromSource() const override;
|
virtual void readAtcBookingsFromSource() const override;
|
||||||
|
|
||||||
/*!
|
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
||||||
* \copydoc IContextNetwork::getAtcStationsOnline()
|
|
||||||
* \todo If I make this &getAtcStations XML is not generated correctly, needs to be crosschecked with the latest version of Qt
|
|
||||||
*/
|
|
||||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override;
|
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override;
|
||||||
|
|
||||||
/*!
|
//! \copydoc IContextNetwork::getAtcStationsBooked()
|
||||||
* \copydoc IContextNetwork::getAtcStationsBooked()
|
|
||||||
* \todo If I make this &getAtcStations XML is not generated correctly
|
|
||||||
*/
|
|
||||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override;
|
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override;
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::getAircraftsInRange()
|
//! \copydoc IContextNetwork::getAircraftsInRange()
|
||||||
|
|||||||
Reference in New Issue
Block a user