mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 15:49:30 +08:00
protocol type -MD added
This commit is contained in:
@@ -92,6 +92,7 @@ namespace BlackCore
|
|||||||
connect(m_fsdClient, &CFSDClient::serverResponseReceived, this, &CAirspaceMonitor::onServerReplyReceived);
|
connect(m_fsdClient, &CFSDClient::serverResponseReceived, this, &CAirspaceMonitor::onServerReplyReceived);
|
||||||
connect(m_fsdClient, &CFSDClient::aircraftConfigReceived, this, &CAirspaceMonitor::onAircraftConfigReceived);
|
connect(m_fsdClient, &CFSDClient::aircraftConfigReceived, this, &CAirspaceMonitor::onAircraftConfigReceived);
|
||||||
connect(m_fsdClient, &CFSDClient::connectionStatusChanged, this, &CAirspaceMonitor::onConnectionStatusChanged);
|
connect(m_fsdClient, &CFSDClient::connectionStatusChanged, this, &CAirspaceMonitor::onConnectionStatusChanged);
|
||||||
|
connect(m_fsdClient, &CFSDClient::revbAircraftConfigReceived, this, &CAirspaceMonitor::onRevBAircraftConfigReceived);
|
||||||
|
|
||||||
// AutoConnection: this should also avoid race conditions by updating the bookings
|
// AutoConnection: this should also avoid race conditions by updating the bookings
|
||||||
Q_ASSERT_X(sApp && sApp->hasWebDataServices(), Q_FUNC_INFO, "Missing data reader");
|
Q_ASSERT_X(sApp && sApp->hasWebDataServices(), Q_FUNC_INFO, "Missing data reader");
|
||||||
@@ -1346,6 +1347,67 @@ namespace BlackCore
|
|||||||
this->updateAircraftInRange(callsign, vm);
|
this->updateAircraftInRange(callsign, vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAirspaceMonitor::onRevBAircraftConfigReceived(const CCallsign &callsign, const QString &config, qint64 currentOffsetMs)
|
||||||
|
{
|
||||||
|
|
||||||
|
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
||||||
|
BLACK_AUDIT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
|
||||||
|
if (callsign.isEmpty()) { return; }
|
||||||
|
|
||||||
|
unsigned long pp = 0;
|
||||||
|
bool ok;
|
||||||
|
pp = config.toULong(&ok, 10);
|
||||||
|
|
||||||
|
bool gear = (pp & 1u);
|
||||||
|
bool landLight = (pp & 2u);
|
||||||
|
bool navLight = (pp & 4u);
|
||||||
|
bool strobeLight = (pp & 8u);
|
||||||
|
bool beaconLight = (pp & 16u);
|
||||||
|
bool taxiLight = (pp & 32u);
|
||||||
|
bool engine1Running = (pp & 64u);
|
||||||
|
bool engine2Running = (pp & 128u);
|
||||||
|
bool engine3Running = (pp & 256u);
|
||||||
|
bool engine4Running = (pp & 512u);
|
||||||
|
|
||||||
|
//CLogMessage(this).info(u"taxiLight %1 landLight %2 beaconLight %3 strobeLight %4 gear %5") << taxiLight << landLight << beaconLight << strobeLight << gear;
|
||||||
|
//CLogMessage(this).info(u"engine1Running %1 engine2Running %2 engine3Running %3 engine4Running %4") << engine1Running << engine2Running << engine3Running << engine4Running;
|
||||||
|
|
||||||
|
CAircraftParts aircraftparts;
|
||||||
|
aircraftparts.setGearDown(gear);
|
||||||
|
|
||||||
|
CAircraftLights lights;
|
||||||
|
lights.setStrobeOn(strobeLight);
|
||||||
|
lights.setLandingOn(landLight);
|
||||||
|
lights.setTaxiOn(taxiLight);
|
||||||
|
lights.setBeaconOn(beaconLight);
|
||||||
|
lights.setNavOn(navLight);
|
||||||
|
aircraftparts.setLights(lights);
|
||||||
|
|
||||||
|
CAircraftEngineList engines;
|
||||||
|
engines.initEngines(4, false);
|
||||||
|
engines.setEngineOn(1, engine1Running);
|
||||||
|
engines.setEngineOn(2, engine2Running);
|
||||||
|
engines.setEngineOn(3, engine3Running);
|
||||||
|
engines.setEngineOn(4, engine4Running);
|
||||||
|
aircraftparts.setEngines(engines);
|
||||||
|
|
||||||
|
// make sure in any case right time and correct details
|
||||||
|
aircraftparts.setCurrentUtcTime();
|
||||||
|
aircraftparts.setTimeOffsetMs(currentOffsetMs);
|
||||||
|
aircraftparts.setPartsDetails(CAircraftParts::FSDAircraftParts);
|
||||||
|
|
||||||
|
// store parts
|
||||||
|
this->storeAircraftParts(callsign, aircraftparts, true);
|
||||||
|
|
||||||
|
// update client capability
|
||||||
|
CClient client = this->getClientOrDefaultForCallsign(callsign);
|
||||||
|
client.setUserCallsign(callsign); // make valid by setting a callsign
|
||||||
|
if (client.hasCapability(CClient::FsdWithAircraftConfig)) { return; }
|
||||||
|
client.addCapability(CClient::FsdWithAircraftConfig);
|
||||||
|
this->setOtherClient(client);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::onAircraftConfigReceived(const CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs)
|
void CAirspaceMonitor::onAircraftConfigReceived(const CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs)
|
||||||
{
|
{
|
||||||
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
|
||||||
|
|||||||
@@ -444,6 +444,8 @@ namespace BlackCore
|
|||||||
void onAircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs);
|
void onAircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs);
|
||||||
void onAircraftInterimUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
void onAircraftInterimUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||||
void onConnectionStatusChanged(BlackMisc::Network::CConnectionStatus oldStatus, BlackMisc::Network::CConnectionStatus newStatus);
|
void onConnectionStatusChanged(BlackMisc::Network::CConnectionStatus oldStatus, BlackMisc::Network::CConnectionStatus newStatus);
|
||||||
|
void onRevBAircraftConfigReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &config, qint64 currentOffsetMs);
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "blackcore/fsd/planeinformation.h"
|
#include "blackcore/fsd/planeinformation.h"
|
||||||
#include "blackcore/fsd/planeinforequestfsinn.h"
|
#include "blackcore/fsd/planeinforequestfsinn.h"
|
||||||
#include "blackcore/fsd/planeinformationfsinn.h"
|
#include "blackcore/fsd/planeinformationfsinn.h"
|
||||||
|
#include "blackcore/fsd/revbclientparts.h"
|
||||||
|
|
||||||
#include "blackmisc/aviation/flightplan.h"
|
#include "blackmisc/aviation/flightplan.h"
|
||||||
#include "blackmisc/network/rawfsdmessage.h"
|
#include "blackmisc/network/rawfsdmessage.h"
|
||||||
@@ -907,6 +908,8 @@ namespace BlackCore
|
|||||||
// IVAO only
|
// IVAO only
|
||||||
// Ref: https://github.com/DemonRem/X-IvAP/blob/1b0a14880532a0f5c8fe84be44e462c6892a5596/src/XIvAp/FSDprotocol.h
|
// Ref: https://github.com/DemonRem/X-IvAP/blob/1b0a14880532a0f5c8fe84be44e462c6892a5596/src/XIvAp/FSDprotocol.h
|
||||||
m_messageTypeMapping["!R"] = MessageType::RegistrationInfo;
|
m_messageTypeMapping["!R"] = MessageType::RegistrationInfo;
|
||||||
|
m_messageTypeMapping["-MD"] = MessageType::RevBClientParts;
|
||||||
|
m_messageTypeMapping["-PD"] = MessageType::RevBPilotDescription; // not handled, to avoid error messages
|
||||||
|
|
||||||
// IVAO parts
|
// IVAO parts
|
||||||
// https://discordapp.com/channels/539048679160676382/695961646992195644/707915838845485187
|
// https://discordapp.com/channels/539048679160676382/695961646992195644/707915838845485187
|
||||||
@@ -1360,6 +1363,23 @@ namespace BlackCore
|
|||||||
if (serverError.isFatalError()) { disconnectFromServer(); }
|
if (serverError.isFatalError()) { disconnectFromServer(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFSDClient::handleRevBClientPartsPacket(const QStringList &tokens)
|
||||||
|
{
|
||||||
|
CLogMessage(this).debug(u"handleRevBClientPartsPacket");
|
||||||
|
|
||||||
|
const RevBClientParts RevBClientParts = RevBClientParts::fromTokens(tokens);
|
||||||
|
const CCallsign callsign(RevBClientParts.sender(), CCallsign::Aircraft);
|
||||||
|
|
||||||
|
const bool inRange = isAircraftInRange(callsign);
|
||||||
|
|
||||||
|
if (!inRange) { return; } // sort out all broadcasted we DO NOT NEED
|
||||||
|
if (!getSetupForServer().receiveAircraftParts()) { return; }
|
||||||
|
|
||||||
|
const qint64 offsetTimeMs = currentOffsetTime(callsign);
|
||||||
|
emit revbAircraftConfigReceived(RevBClientParts.sender(), RevBClientParts.m_partsval1, offsetTimeMs);
|
||||||
|
CLogMessage(this).debug(u"Set Config at %1 ") << offsetTimeMs ;
|
||||||
|
}
|
||||||
|
|
||||||
void CFSDClient::handleCustomPilotPacket(const QStringList &tokens)
|
void CFSDClient::handleCustomPilotPacket(const QStringList &tokens)
|
||||||
{
|
{
|
||||||
const QString subType = tokens.at(2);
|
const QString subType = tokens.at(2);
|
||||||
@@ -1922,6 +1942,8 @@ namespace BlackCore
|
|||||||
case MessageType::ProController:
|
case MessageType::ProController:
|
||||||
case MessageType::ClientIdentification:
|
case MessageType::ClientIdentification:
|
||||||
case MessageType::RegistrationInfo:
|
case MessageType::RegistrationInfo:
|
||||||
|
case MessageType::RevBPilotDescription:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// handled ones
|
// handled ones
|
||||||
@@ -1941,6 +1963,10 @@ namespace BlackCore
|
|||||||
case MessageType::ServerError: handleServerError(tokens); break;
|
case MessageType::ServerError: handleServerError(tokens); break;
|
||||||
case MessageType::TextMessage: handleTextMessage(tokens); break;
|
case MessageType::TextMessage: handleTextMessage(tokens); break;
|
||||||
case MessageType::PilotClientCom: handleCustomPilotPacket(tokens); break;
|
case MessageType::PilotClientCom: handleCustomPilotPacket(tokens); break;
|
||||||
|
case MessageType::RevBClientParts: handleRevBClientPartsPacket(tokens); break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// normally we should not get here
|
// normally we should not get here
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -219,6 +219,8 @@ namespace BlackCore
|
|||||||
void interimPilotDataUpdatedReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
void interimPilotDataUpdatedReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||||
void rawFsdMessage(const BlackMisc::Network::CRawFsdMessage &rawFsdMessage);
|
void rawFsdMessage(const BlackMisc::Network::CRawFsdMessage &rawFsdMessage);
|
||||||
void planeInformationFsinnReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &airlineIcaoDesignator, const QString &aircraftDesignator, const QString &combinedAircraftType, const QString &modelString);
|
void planeInformationFsinnReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &airlineIcaoDesignator, const QString &aircraftDesignator, const QString &combinedAircraftType, const QString &modelString);
|
||||||
|
void revbAircraftConfigReceived(const QString &sender, const QString &config, qint64 currentOffsetTimeMs);
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! We received a reply to one of our ATIS queries.
|
//! We received a reply to one of our ATIS queries.
|
||||||
@@ -361,6 +363,8 @@ namespace BlackCore
|
|||||||
void handleServerError(const QStringList &tokens);
|
void handleServerError(const QStringList &tokens);
|
||||||
void handleCustomPilotPacket(const QStringList &tokens);
|
void handleCustomPilotPacket(const QStringList &tokens);
|
||||||
void handleFsdIdentification(const QStringList &tokens);
|
void handleFsdIdentification(const QStringList &tokens);
|
||||||
|
void handleRevBClientPartsPacket(const QStringList &tokens);
|
||||||
|
|
||||||
//
|
//
|
||||||
void handleUnknownPacket(const QString &line);
|
void handleUnknownPacket(const QString &line);
|
||||||
void handleUnknownPacket(const QStringList &tokens);
|
void handleUnknownPacket(const QStringList &tokens);
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ enum class MessageType
|
|||||||
RegistrationInfo, // IVAO only
|
RegistrationInfo, // IVAO only
|
||||||
TextMessage,
|
TextMessage,
|
||||||
PilotClientCom,
|
PilotClientCom,
|
||||||
|
RevBClientParts, // IVAO only
|
||||||
|
RevBPilotDescription, // -PD IVAO only not handled in swift
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
|
|||||||
53
src/blackcore/fsd/revbclientparts.cpp
Normal file
53
src/blackcore/fsd/revbclientparts.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* Copyright (C) 2020
|
||||||
|
* swift project community / contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||||
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "revbclientparts.h"
|
||||||
|
#include "serializer.h"
|
||||||
|
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
|
namespace BlackCore
|
||||||
|
{
|
||||||
|
namespace Fsd
|
||||||
|
{
|
||||||
|
RevBClientParts::RevBClientParts()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
RevBClientParts::RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval2, const QString &partsval3)
|
||||||
|
: MessageBase(sender),
|
||||||
|
m_partsval1(partsval1),
|
||||||
|
m_partsval2(partsval2),
|
||||||
|
m_partsval3(partsval3)
|
||||||
|
|
||||||
|
{ }
|
||||||
|
|
||||||
|
QStringList RevBClientParts::toTokens() const
|
||||||
|
{
|
||||||
|
QStringList tokens;
|
||||||
|
tokens.push_back(m_sender);
|
||||||
|
tokens.push_back(m_partsval1);
|
||||||
|
tokens.push_back(m_partsval2);
|
||||||
|
tokens.push_back(m_partsval3);
|
||||||
|
return tokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RevBClientParts RevBClientParts::fromTokens(const QStringList &tokens)
|
||||||
|
{
|
||||||
|
if (tokens.size() < 4)
|
||||||
|
{
|
||||||
|
BlackMisc::CLogMessage(static_cast<RevBClientParts *>(nullptr)).debug(u"Wrong number of arguments.");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return RevBClientParts(tokens[0], tokens[1], tokens[2], tokens[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
75
src/blackcore/fsd/revbclientparts.h
Normal file
75
src/blackcore/fsd/revbclientparts.h
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/* Copyright (C) 2020
|
||||||
|
* swift project community / contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||||
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKCORE_FSD_REVBCLIENTPARTS_H
|
||||||
|
#define BLACKCORE_FSD_REVBCLIENTPARTS_H
|
||||||
|
|
||||||
|
#include "messagebase.h"
|
||||||
|
#include "enums.h"
|
||||||
|
|
||||||
|
namespace BlackCore
|
||||||
|
{
|
||||||
|
namespace Fsd
|
||||||
|
{
|
||||||
|
//! This packet is used to translate client’s parts from RevB IVAO -MD.
|
||||||
|
//! -MDMDN0104:262396:262396:262396
|
||||||
|
//!
|
||||||
|
class BLACKCORE_EXPORT RevBClientParts : public MessageBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval3, const QString &partsval2);
|
||||||
|
|
||||||
|
|
||||||
|
//! Message converted to tokens
|
||||||
|
QStringList toTokens() const;
|
||||||
|
|
||||||
|
|
||||||
|
//! Construct from tokens
|
||||||
|
static RevBClientParts fromTokens(const QStringList &tokens);
|
||||||
|
|
||||||
|
//! PDU identifier
|
||||||
|
static QString pdu() { return "-MD"; }
|
||||||
|
|
||||||
|
//! Properties @{
|
||||||
|
ClientQueryType m_queryType = ClientQueryType::Unknown;
|
||||||
|
QStringList m_queryData;
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
|
||||||
|
//! Properties @{
|
||||||
|
QString m_partsval1;
|
||||||
|
QString m_partsval2;
|
||||||
|
QString m_partsval3;
|
||||||
|
//! @
|
||||||
|
|
||||||
|
private:
|
||||||
|
RevBClientParts();
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Equal to operator
|
||||||
|
inline bool operator==(const RevBClientParts &lhs, const RevBClientParts &rhs)
|
||||||
|
{
|
||||||
|
return lhs.sender() == rhs.sender() &&
|
||||||
|
lhs.m_partsval1 == rhs.m_partsval1 &&
|
||||||
|
lhs.m_partsval2 == rhs.m_partsval2 &&
|
||||||
|
lhs.m_partsval3 == rhs.m_partsval3;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Not equal to operator
|
||||||
|
inline bool operator!=(const RevBClientParts &lhs, const RevBClientParts &rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user