mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
Ref T339, simulator info message (version) for SUP supervisor
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include "blackmisc/pq/speed.h"
|
#include "blackmisc/pq/speed.h"
|
||||||
#include "blackmisc/pq/time.h"
|
#include "blackmisc/pq/time.h"
|
||||||
#include "blackmisc/pq/units.h"
|
#include "blackmisc/pq/units.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
#include "blackmisc/compare.h"
|
#include "blackmisc/compare.h"
|
||||||
#include "blackmisc/json.h"
|
#include "blackmisc/json.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
@@ -112,6 +113,7 @@ namespace BlackCore
|
|||||||
void CNetworkVatlib::initializeSession()
|
void CNetworkVatlib::initializeSession()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(isDisconnected(), Q_FUNC_INFO, "attempted to reinitialize session while still connected");
|
Q_ASSERT_X(isDisconnected(), Q_FUNC_INFO, "attempted to reinitialize session while still connected");
|
||||||
|
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp");
|
||||||
|
|
||||||
int clientCapabilities = vatCapsAircraftInfo | vatCapsFastPos | vatCapsAtcInfo | vatCapsAircraftConfig;
|
int clientCapabilities = vatCapsAircraftInfo | vatCapsFastPos | vatCapsAtcInfo | vatCapsAircraftConfig;
|
||||||
if (m_loginMode == LoginStealth)
|
if (m_loginMode == LoginStealth)
|
||||||
@@ -134,10 +136,11 @@ namespace BlackCore
|
|||||||
default: serverType = vatServerLegacyFsd; break;
|
default: serverType = vatServerLegacyFsd; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString hostApplication = this->getNetworkHostApplicationString().replace(':', ' ');
|
||||||
m_net.reset(Vat_CreateNetworkSession(serverType, sApp->swiftVersionChar(),
|
m_net.reset(Vat_CreateNetworkSession(serverType, sApp->swiftVersionChar(),
|
||||||
CBuildConfig::getVersion().majorVersion(),
|
CBuildConfig::getVersion().majorVersion(),
|
||||||
CBuildConfig::getVersion().minorVersion(),
|
CBuildConfig::getVersion().minorVersion(),
|
||||||
"None", clientId, clientKey.toLocal8Bit().constData(),
|
toFSD(hostApplication), clientId, toFSD(clientKey),
|
||||||
clientCapabilities));
|
clientCapabilities));
|
||||||
|
|
||||||
Vat_SetStateChangeHandler(m_net.data(), onConnectionStatusChanged, this);
|
Vat_SetStateChangeHandler(m_net.data(), onConnectionStatusChanged, this);
|
||||||
@@ -335,6 +338,11 @@ namespace BlackCore
|
|||||||
return m_fsdTextCodec->toUnicode(cstr);
|
return m_fsdTextCodec->toUnicode(cstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CNetworkVatlib::getNetworkHostApplicationString() const
|
||||||
|
{
|
||||||
|
return this->getSimulatorNameAndVersion();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList CNetworkVatlib::fromFSD(const char **cstrArray, int size) const
|
QStringList CNetworkVatlib::fromFSD(const char **cstrArray, int size) const
|
||||||
{
|
{
|
||||||
QStringList qstrList;
|
QStringList qstrList;
|
||||||
@@ -1002,7 +1010,7 @@ namespace BlackCore
|
|||||||
// ATIS often have a range of 0 nm. Correct this to a proper value.
|
// ATIS often have a range of 0 nm. Correct this to a proper value.
|
||||||
if (cs.contains("_ATIS") && pos->visibleRange == 0) { range.setValueSameUnit(50.0); }
|
if (cs.contains("_ATIS") && pos->visibleRange == 0) { range.setValueSameUnit(50.0); }
|
||||||
CCoordinateGeodetic position(pos->latitude, pos->longitude, 0);
|
CCoordinateGeodetic position(pos->latitude, pos->longitude, 0);
|
||||||
emit cbvar_cast(cbvar)->atcPositionUpdate( CCallsign(cs, CCallsign::Atc), freq, position, range);
|
emit cbvar_cast(cbvar)->atcPositionUpdate(CCallsign(cs, CCallsign::Atc), freq, position, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetworkVatlib::onKicked(VatFsdClient *, const char *reason, void *cbvar)
|
void CNetworkVatlib::onKicked(VatFsdClient *, const char *reason, void *cbvar)
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ namespace BlackCore
|
|||||||
QByteArray toFSD(const BlackMisc::Aviation::CCallsign &callsign) const;
|
QByteArray toFSD(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||||
std::function<const char **()> toFSD(const QStringList &qstrList) const;
|
std::function<const char **()> toFSD(const QStringList &qstrList) const;
|
||||||
QString fromFSD(const char *cstr) const;
|
QString fromFSD(const char *cstr) const;
|
||||||
|
QString getNetworkHostApplicationString() const; //!< simulator version and details info string
|
||||||
QStringList fromFSD(const char **cstrArray, int size) const;
|
QStringList fromFSD(const char **cstrArray, int size) const;
|
||||||
bool isInterimPositionUpdateEnabledForServer() const;
|
bool isInterimPositionUpdateEnabledForServer() const;
|
||||||
const BlackMisc::Network::CFsdSetup &getSetupForServer() const;
|
const BlackMisc::Network::CFsdSetup &getSetupForServer() const;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "simulationenvironmentprovider.h"
|
#include "simulationenvironmentprovider.h"
|
||||||
|
#include <QStringBuilder>
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
@@ -210,6 +211,24 @@ namespace BlackMisc
|
|||||||
return this->getSimulatorPluginInfo().getSimulatorInfo();
|
return this->getSimulatorPluginInfo().getSimulatorInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ISimulationEnvironmentProvider::getSimulatorNameAndVersion() const
|
||||||
|
{
|
||||||
|
QString n;
|
||||||
|
QString v;
|
||||||
|
{
|
||||||
|
QReadLocker l(&m_lockSimInfo);
|
||||||
|
n = m_simulatorName;
|
||||||
|
v = m_simulatorVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!n.isEmpty() && !v.isEmpty()) { return n % QStringLiteral(" ") % v; }
|
||||||
|
if (!n.isEmpty()) { return n; }
|
||||||
|
|
||||||
|
const CSimulatorInfo simInfo = this->getSimulatorInfo();
|
||||||
|
if (!simInfo.isUnspecified()) { return simInfo.toQString(true); }
|
||||||
|
return "not available";
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftModel ISimulationEnvironmentProvider::getDefaultModel() const
|
CAircraftModel ISimulationEnvironmentProvider::getDefaultModel() const
|
||||||
{
|
{
|
||||||
QReadLocker l(&m_lockModel);
|
QReadLocker l(&m_lockModel);
|
||||||
@@ -407,6 +426,12 @@ namespace BlackMisc
|
|||||||
return this->provider()->getSimulatorInfo();
|
return this->provider()->getSimulatorInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CSimulationEnvironmentAware::getSimulatorNameAndVersion() const
|
||||||
|
{
|
||||||
|
if (!this->hasProvider()) { return "not avialbale"; }
|
||||||
|
return this->provider()->getSimulatorNameAndVersion();
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftModel CSimulationEnvironmentAware::getDefaultModel() const
|
CAircraftModel CSimulationEnvironmentAware::getDefaultModel() const
|
||||||
{
|
{
|
||||||
if (!this->hasProvider()) { return CAircraftModel(); }
|
if (!this->hasProvider()) { return CAircraftModel(); }
|
||||||
|
|||||||
@@ -78,6 +78,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
CSimulatorInfo getSimulatorInfo() const;
|
CSimulatorInfo getSimulatorInfo() const;
|
||||||
|
|
||||||
|
//! Version and simulator details info
|
||||||
|
//! \threadsafe
|
||||||
|
QString getSimulatorNameAndVersion() const;
|
||||||
|
|
||||||
//! Default model
|
//! Default model
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
CAircraftModel getDefaultModel() const;
|
CAircraftModel getDefaultModel() const;
|
||||||
@@ -129,14 +133,17 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Simulator name as set from the running simulator
|
//! Simulator name as set from the running simulator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
|
//! \remark something like "Name: 'Lockheed Martin® Prepar3D® v4"
|
||||||
QString getSimulatorName() const;
|
QString getSimulatorName() const;
|
||||||
|
|
||||||
//! Simulator version as set from the running simulator
|
//! Simulator version as set from the running simulator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
|
//! \remark something like "4.1.7.22841"
|
||||||
QString getSimulatorVersion() const;
|
QString getSimulatorVersion() const;
|
||||||
|
|
||||||
//! Simulator details as set from the running simulator
|
//! Simulator details as set from the running simulator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
|
//! \remark something like "Name: 'Lockheed Martin® Prepar3D® v4' Version: 4.1.7.22841 SimConnect: 4.1.0.0"
|
||||||
QString getSimulatorDetails() const;
|
QString getSimulatorDetails() const;
|
||||||
|
|
||||||
//! Default model
|
//! Default model
|
||||||
@@ -199,7 +206,7 @@ namespace BlackMisc
|
|||||||
QString m_simulatorVersion; //!< Simulator version
|
QString m_simulatorVersion; //!< Simulator version
|
||||||
CAircraftModel m_defaultModel; //!< default model
|
CAircraftModel m_defaultModel; //!< default model
|
||||||
int m_maxElevations = 100; //!< How many elevations we keep
|
int m_maxElevations = 100; //!< How many elevations we keep
|
||||||
Geo::CCoordinateGeodeticList m_elvCoordinates; //!< elevation cache
|
Geo::CCoordinateGeodeticList m_elvCoordinates; //!< elevation cache
|
||||||
Aviation::CTimestampPerCallsign m_pendingElevationRequests; //!< pending elevation requests
|
Aviation::CTimestampPerCallsign m_pendingElevationRequests; //!< pending elevation requests
|
||||||
Aviation::CLengthPerCallsign m_cgsPerCallsign; //!< CGs per callsign
|
Aviation::CLengthPerCallsign m_cgsPerCallsign; //!< CGs per callsign
|
||||||
QHash<QString, PhysicalQuantities::CLength> m_cgsPerModel; //!< CGs per model string
|
QHash<QString, PhysicalQuantities::CLength> m_cgsPerModel; //!< CGs per model string
|
||||||
@@ -252,6 +259,9 @@ namespace BlackMisc
|
|||||||
//! \copydoc ISimulationEnvironmentProvider::getSimulatorPluginInfo
|
//! \copydoc ISimulationEnvironmentProvider::getSimulatorPluginInfo
|
||||||
CSimulatorInfo getSimulatorInfo() const;
|
CSimulatorInfo getSimulatorInfo() const;
|
||||||
|
|
||||||
|
//! \copydoc ISimulationEnvironmentProvider::getSimulatorNameAndVersion
|
||||||
|
QString getSimulatorNameAndVersion() const;
|
||||||
|
|
||||||
//! \copydoc ISimulationEnvironmentProvider::getDefaultModel
|
//! \copydoc ISimulationEnvironmentProvider::getDefaultModel
|
||||||
CAircraftModel getDefaultModel() const;
|
CAircraftModel getDefaultModel() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user