mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refs #466 Resolved TODO items in INetwork.
This commit is contained in:
@@ -64,7 +64,6 @@ Client::Client(QObject *parent)
|
||||
connect(this, &Client::setOwnAircraftCockpit, COwnAircraftProviderDummy::instance(), &COwnAircraftProviderDummy::updateCockpit);
|
||||
connect(this, &Client::sendPing, m_net, &INetwork::sendPing);
|
||||
connect(this, &Client::sendMetarQuery, m_net, &INetwork::sendMetarQuery);
|
||||
connect(this, &Client::sendWeatherDataQuery, m_net, &INetwork::sendWeatherDataQuery);
|
||||
connect(this, &Client::sendCustomPacket, m_net, &INetwork::sendCustomPacket);
|
||||
|
||||
using namespace std::placeholders;
|
||||
@@ -95,7 +94,6 @@ Client::Client(QObject *parent)
|
||||
m_commands["setcockpit"] = std::bind(&Client::setOwnAircraftCockpitCmd, this, _1);
|
||||
m_commands["ping"] = std::bind(&Client::sendPingCmd, this, _1);
|
||||
m_commands["metar"] = std::bind(&Client::sendMetarQueryCmd, this, _1);
|
||||
m_commands["weather"] = std::bind(&Client::sendWeatherDataQueryCmd, this, _1);
|
||||
m_commands["custom"] = std::bind(&Client::sendCustomPacketCmd, this, _1);
|
||||
}
|
||||
|
||||
@@ -400,13 +398,6 @@ void Client::sendMetarQueryCmd(QTextStream &args)
|
||||
emit sendMetarQuery(airportICAO);
|
||||
}
|
||||
|
||||
void Client::sendWeatherDataQueryCmd(QTextStream &args)
|
||||
{
|
||||
QString airportICAO;
|
||||
args >> airportICAO;
|
||||
emit sendWeatherDataQuery(airportICAO);
|
||||
}
|
||||
|
||||
void Client::sendCustomPacketCmd(QTextStream &args)
|
||||
{
|
||||
QString callsign;
|
||||
|
||||
@@ -66,7 +66,6 @@ private: //commands
|
||||
void setOwnAircraftCockpitCmd(QTextStream &args);
|
||||
void sendPingCmd(QTextStream &args);
|
||||
void sendMetarQueryCmd(QTextStream &args);
|
||||
void sendWeatherDataQueryCmd(QTextStream &args);
|
||||
void sendCustomPacketCmd(QTextStream &args);
|
||||
|
||||
signals: //to send to INetwork
|
||||
@@ -93,7 +92,6 @@ signals: //to send to INetwork
|
||||
const BlackMisc::Aviation::CTransponder &xpdr, const QString &originator);
|
||||
void sendPing(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void sendMetarQuery(const QString &airportICAO);
|
||||
void sendWeatherDataQuery(const QString &airportICAO);
|
||||
void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data);
|
||||
|
||||
public slots: //to receive from INetwork
|
||||
|
||||
@@ -364,15 +364,6 @@ namespace BlackCore
|
||||
*/
|
||||
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) = 0;
|
||||
|
||||
/*!
|
||||
* Send a message querying the weather data for the airport with a specific ICAO code.
|
||||
* \pre Network must be connected when calling this function.
|
||||
* \sa temperatureDataReplyReceived
|
||||
* \sa windDataReplyReceived
|
||||
* \sa cloudDataReplyReceived
|
||||
*/
|
||||
virtual void sendWeatherDataQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) = 0;
|
||||
|
||||
signals:
|
||||
//! @}
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -457,8 +448,6 @@ namespace BlackCore
|
||||
*/
|
||||
void frequencyReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &freq);
|
||||
|
||||
// TODO void aircraftInterimPositionUpdate(...);
|
||||
|
||||
//! @}
|
||||
////////////////////////////////////////////////////////////////
|
||||
//! \name Network signals
|
||||
@@ -543,10 +532,6 @@ namespace BlackCore
|
||||
*/
|
||||
void metarReplyReceived(const QString &data);
|
||||
|
||||
// TODO void temperatureDataReplyReceived(...);
|
||||
// TODO void windDataReplyReceived(...);
|
||||
// TODO void cloudDataReplyReceived(...);
|
||||
|
||||
//! @}
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -91,9 +90,6 @@ namespace BlackCore
|
||||
Vat_SetControllerAtisHandler(m_net.data(), onAtisReplyReceived, this);
|
||||
Vat_SetFlightPlanHandler(m_net.data(), onFlightPlanReceived, this);
|
||||
Vat_SetServerErrorHandler(m_net.data(), onErrorReceived, this);
|
||||
Vat_SetTemperatureDataHandler(m_net.data(), onTemperatureDataReceived, this);
|
||||
Vat_SetWindDataHandler(m_net.data(), onWindDataReceived, this);
|
||||
Vat_SetCloudDataHandler(m_net.data(), onCloudDataReceived, this);
|
||||
Vat_SetAircraftInfoRequestHandler(m_net.data(), onPilotInfoRequestReceived, this);
|
||||
Vat_SetAircraftInfoHandler(m_net.data(), onPilotInfoReceived, this);
|
||||
Vat_SetCustomPilotPacketHandler(m_net.data(), onCustomPacketReceived, this);
|
||||
@@ -303,7 +299,8 @@ namespace BlackCore
|
||||
Q_ASSERT_X(isDisconnected(), "CNetworkVatlib", "Can't change ICAO codes while still connected");
|
||||
m_ownAircraftIcaoCode = ownAircraft.getAircraftIcaoCode();
|
||||
m_ownAirlineIcaoCode = ownAircraft.getAirlineIcaoCode();
|
||||
updateOwnIcaoCodes(m_ownAircraftIcaoCode, m_ownAirlineIcaoCode);
|
||||
m_ownLiveryDescription = ownAircraft.getLivery().getDescription();
|
||||
updateOwnIcaoCodes(m_ownAircraftIcaoCode, m_ownAirlineIcaoCode); // \todo livery?
|
||||
}
|
||||
|
||||
void CNetworkVatlib::presetLoginMode(LoginMode mode)
|
||||
@@ -426,7 +423,6 @@ namespace BlackCore
|
||||
if (this->m_loginMode == LoginNormal)
|
||||
{
|
||||
VatInterimPilotPosition pos;
|
||||
// TODO: we need to distinguish true and pressure altitude
|
||||
pos.altitudeTrue = myAircraft.getAltitude().value(CLengthUnit::ft());
|
||||
pos.heading = myAircraft.getHeading().value(CAngleUnit::deg());
|
||||
pos.pitch = myAircraft.getPitch().value(CAngleUnit::deg());
|
||||
@@ -533,13 +529,9 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::replyToConfigQuery(const CCallsign &callsign)
|
||||
{
|
||||
QJsonObject currentConfig(getOwnAircraftParts().toJson());
|
||||
// Fixme: Use QJsonObject with std::initializer_list once 5.4 is baseline
|
||||
currentConfig.insert("is_full_data", true);
|
||||
QJsonObject packet;
|
||||
packet.insert("config", currentConfig);
|
||||
QJsonDocument doc(packet);
|
||||
QString data { doc.toJson(QJsonDocument::Compact) };
|
||||
QJsonObject config = getOwnAircraftParts().toJson();
|
||||
config.insert("is_full_data", true);
|
||||
QString data = QJsonDocument(QJsonObject { { "config", config } }).toJson(QJsonDocument::Compact);
|
||||
data = convertToUnicodeEscaped(data);
|
||||
Vat_SendAircraftConfig(m_net.data(), toFSD(callsign), toFSD(data));
|
||||
}
|
||||
@@ -554,7 +546,7 @@ namespace BlackCore
|
||||
{
|
||||
const QByteArray acTypeICAObytes = toFSD(m_ownAircraftIcaoCode.getDesignator());
|
||||
const QByteArray airlineICAObytes = toFSD(m_ownAirlineIcaoCode.getDesignator());
|
||||
const QByteArray liverybytes; //! \todo VATLIB: send livery
|
||||
const QByteArray liverybytes = toFSD(m_ownLiveryDescription);
|
||||
|
||||
VatAircraftInfo aircraftInfo {acTypeICAObytes, airlineICAObytes, liverybytes};
|
||||
Vat_SendModernPlaneInfo(m_net.data(), toFSD(callsign), &aircraftInfo);
|
||||
@@ -597,12 +589,6 @@ namespace BlackCore
|
||||
Vat_RequestMetar(m_net.data(), toFSD(airportIcao.asString()));
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendWeatherDataQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao)
|
||||
{
|
||||
Q_ASSERT_X(isConnected(), "CNetworkVatlib", "Can't send to server when disconnected");
|
||||
Vat_RequestWeather(m_net.data(), toFSD(airportIcao.asString()));
|
||||
}
|
||||
|
||||
void CNetworkVatlib::sendCustomFsinnQuery(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
{
|
||||
Q_ASSERT_X(isConnected(), "CNetworkVatlib", "Can't send to server when disconnected");
|
||||
@@ -639,11 +625,7 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::broadcastAircraftConfig(const QJsonObject &config)
|
||||
{
|
||||
// Fixme: Use QJsonObject with std::initializer_list once 5.4 is baseline
|
||||
QJsonObject packet;
|
||||
packet.insert("config", config);
|
||||
QJsonDocument doc(packet);
|
||||
QString data { doc.toJson(QJsonDocument::Compact) };
|
||||
QString data = QJsonDocument(QJsonObject { { "config", config } }).toJson(QJsonDocument::Compact);
|
||||
data = convertToUnicodeEscaped(data);
|
||||
Vat_SendAircraftConfigBroadcast(m_net.data(), toFSD(data));
|
||||
}
|
||||
@@ -684,12 +666,17 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::onRadioMessageReceived(VatSessionID, const char *from, int numFreq, int *freqList, const char *msg, void *cbvar)
|
||||
{
|
||||
// FIXME: This method forwards radio message for EVERY frequency. We should only forward those to which our COM's are listening to.
|
||||
int com1 = cbvar_cast(cbvar)->getOwnAircraft().getCom1System().getFrequencyActive().valueInteger(CFrequencyUnit::kHz());
|
||||
int com2 = cbvar_cast(cbvar)->getOwnAircraft().getCom2System().getFrequencyActive().valueInteger(CFrequencyUnit::kHz());
|
||||
QList<CFrequency> frequencies;
|
||||
for (int i = 0; i < numFreq; ++i)
|
||||
{
|
||||
frequencies.push_back(CFrequency(freqList[i], CFrequencyUnit::kHz()));
|
||||
if (freqList[i] == com1 || freqList[i] == com2)
|
||||
{
|
||||
frequencies.push_back(CFrequency(freqList[i], CFrequencyUnit::kHz()));
|
||||
}
|
||||
}
|
||||
if (frequencies.isEmpty()) { return; }
|
||||
BlackMisc::Network::CTextMessageList messages(cbvar_cast(cbvar)->fromFSD(msg), frequencies, CCallsign(cbvar_cast(cbvar)->fromFSD(from)));
|
||||
emit cbvar_cast(cbvar)->textMessagesReceived(messages);
|
||||
}
|
||||
@@ -971,11 +958,6 @@ namespace BlackCore
|
||||
emit cbvar_cast(cbvar)->flightPlanReplyReceived(CCallsign(callsign, CCallsign::Atc), flightPlan);
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onTemperatureDataReceived(VatSessionID, const VatTempLayer /** layer **/ [4], int /** pressure **/, void * /** cbvar **/)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onErrorReceived(VatSessionID, VatServerError error, const char *msg, const char *data, void *cbvar)
|
||||
{
|
||||
auto *self = cbvar_cast(cbvar);
|
||||
@@ -1006,16 +988,6 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onWindDataReceived(VatSessionID, const VatWindLayer /** layer **/ [4], void * /** cbvar **/)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onCloudDataReceived(VatSessionID, const VatCloudLayer /** layers **/ [2], VatThunderStormLayer /** storm **/, float /** vis **/, void * /** cbvar **/)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void CNetworkVatlib::onPilotInfoRequestReceived(VatSessionID, const char *callsignString, void *cbvar)
|
||||
{
|
||||
auto timer = new QTimer(cbvar_cast(cbvar));
|
||||
@@ -1043,10 +1015,7 @@ namespace BlackCore
|
||||
|
||||
QJsonObject CNetworkVatlib::JsonPackets::aircraftConfigRequest()
|
||||
{
|
||||
// Fixme: Use static QJsonObject with std::initializer_list once 5.4 is baseline
|
||||
QJsonObject request;
|
||||
request.insert("request", "full");
|
||||
return request;
|
||||
return { { "request", "full" } };
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -89,7 +89,6 @@ namespace BlackCore
|
||||
//! \name Weather functions
|
||||
//! @{
|
||||
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) override;
|
||||
virtual void sendWeatherDataQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
@@ -116,9 +115,6 @@ namespace BlackCore
|
||||
static void onCapabilitiesReplyReceived(VatSessionID, const char *callsign, int capabilityFlags, void *cbvar);
|
||||
static void onAtisReplyReceived(VatSessionID, const char *callsign, const VatControllerAtis *atis, void *cbvar);
|
||||
static void onFlightPlanReceived(VatSessionID, const char *callsign, const VatFlightPlan *fp, void *cbvar);
|
||||
static void onTemperatureDataReceived(VatSessionID, const VatTempLayer layer[4], int pressure, void *cbvar);
|
||||
static void onWindDataReceived(VatSessionID, const VatWindLayer layer[4], void *cbvar);
|
||||
static void onCloudDataReceived(VatSessionID, const VatCloudLayer cloudLayer[2], VatThunderStormLayer thunderStormLayer, float visibility, void *cbvar);
|
||||
static void onErrorReceived(VatSessionID, VatServerError error, const char *msg, const char *data, void *cbvar);
|
||||
static void onPilotDisconnected(VatSessionID, const char *callsign, void *cbvar);
|
||||
static void onPilotInfoRequestReceived(VatSessionID, const char *callsign, void *cbvar);
|
||||
@@ -177,6 +173,7 @@ namespace BlackCore
|
||||
BlackMisc::Aviation::CCallsign m_ownCallsign; //!< "buffered callsign", as this must not change when connected
|
||||
BlackMisc::Aviation::CAircraftIcaoCode m_ownAircraftIcaoCode; //!< "buffered icao", as this must not change when connected
|
||||
BlackMisc::Aviation::CAirlineIcaoCode m_ownAirlineIcaoCode; //!< "buffered icao", as this must not change when connected
|
||||
QString m_ownLiveryDescription; //!< "buffered livery", as this must not change when connected
|
||||
|
||||
QTimer m_processingTimer;
|
||||
QTimer m_positionUpdateTimer;
|
||||
|
||||
Reference in New Issue
Block a user