mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
Ref T260, function to add an offset to received situations for testing
* "dot" command * context function * provider functions
This commit is contained in:
committed by
Roland Winklmeier
parent
456cb5d1ea
commit
eb0fa92e7e
@@ -11,6 +11,7 @@
|
||||
#include "blackcore/application.h"
|
||||
#include "blackcore/db/networkwatchdog.h"
|
||||
#include "blackcore/context/contextnetwork.h"
|
||||
#include "blackcore/context/contextsimulatorimpl.h"
|
||||
#include "blackcore/context/contextapplication.h"
|
||||
#include "blackcore/cookiemanager.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
@@ -1277,6 +1278,13 @@ namespace BlackCore
|
||||
return args.join(' ');
|
||||
}
|
||||
|
||||
ISimulator *CApplication::getISimulator() const
|
||||
{
|
||||
if (!this->getCoreFacade()) { return nullptr; }
|
||||
if (!this->getCoreFacade()->getCContextSimulator()) { return nullptr; }
|
||||
return this->getCoreFacade()->getCContextSimulator()->simulator();
|
||||
}
|
||||
|
||||
void CApplication::cmdLineHelpMessage()
|
||||
{
|
||||
m_parser.showHelp(); // terminates
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/cookiemanager.h"
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackcore/db/databasereaderconfig.h"
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackcore/application/applicationsettings.h"
|
||||
#include "blackcore/webreaderflags.h"
|
||||
#include "blackmisc/db/updateinfo.h"
|
||||
@@ -64,6 +64,7 @@ namespace BlackCore
|
||||
class CCoreFacade;
|
||||
class CSetupReader;
|
||||
class CWebDataServices;
|
||||
class ISimulator;
|
||||
namespace Context
|
||||
{
|
||||
class IContextApplication;
|
||||
@@ -295,6 +296,11 @@ namespace BlackCore
|
||||
virtual QString cmdLineArgumentsAsString(bool withExecutable = true);
|
||||
//! @}
|
||||
|
||||
// ----------------------- simulator ----------------------------------------
|
||||
|
||||
//! The simulator plugin, if available
|
||||
ISimulator *getISimulator() const;
|
||||
|
||||
// ----------------------- contexts ----------------------------------------
|
||||
|
||||
//! \name Context / core facade related
|
||||
|
||||
@@ -307,6 +307,9 @@ namespace BlackCore
|
||||
//! Request parts for callsign (from another client)
|
||||
virtual void testRequestAircraftConfig(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
//! Add altitude offset for testing
|
||||
virtual bool testAddAltitudeOffset(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CLength &offset = BlackMisc::PhysicalQuantities::CLength::null()) = 0;
|
||||
|
||||
public:
|
||||
//! Raw FSD message receiver functor
|
||||
using RawFsdMessageReceivedSlot = std::function<void(const BlackMisc::Network::CRawFsdMessage &)>;
|
||||
|
||||
@@ -258,6 +258,15 @@ namespace BlackCore
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::testAddAltitudeOffset
|
||||
virtual bool testAddAltitudeOffset(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CLength &offset = BlackMisc::PhysicalQuantities::CLength::null()) override
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
Q_UNUSED(offset);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override
|
||||
{
|
||||
|
||||
@@ -234,7 +234,8 @@ namespace BlackCore
|
||||
{
|
||||
Q_UNUSED(originator;)
|
||||
if (commandLine.isEmpty()) { return false; }
|
||||
CSimpleCommandParser parser({ ".msg", ".m" });
|
||||
static const QStringList cmds({ ".msg", ".m", ".altos", ".altoffset" });
|
||||
CSimpleCommandParser parser(cmds);
|
||||
parser.parse(commandLine);
|
||||
if (!parser.isKnownCommand()) { return false; }
|
||||
if (parser.matchesCommand(".msg", ".m"))
|
||||
@@ -314,6 +315,33 @@ namespace BlackCore
|
||||
this->sendTextMessages(tml);
|
||||
return true;
|
||||
}
|
||||
else if (parser.matchesCommand(".altos", ".altoffet"))
|
||||
{
|
||||
if (!m_airspace) { return false; }
|
||||
if (parser.countParts() < 2) { return false; }
|
||||
const CCallsign cs(parser.part(1));
|
||||
if (!m_airspace->isAircraftInRange(cs))
|
||||
{
|
||||
CLogMessage(this).validationError("Altitude offset unknown callsign");
|
||||
return false;
|
||||
}
|
||||
|
||||
CLength os(CLength::null());
|
||||
if (parser.hasPart(2))
|
||||
{
|
||||
os.parseFromString(parser.part(2));
|
||||
}
|
||||
const bool added = this->testAddAltitudeOffset(cs, os);
|
||||
if (added)
|
||||
{
|
||||
CLogMessage(this).info("Added altitude offset %1 for %2") << os.valueRoundedWithUnit(2) << cs.asString();
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).info("Removed altitude offset %1") << cs.asString();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -609,6 +637,12 @@ namespace BlackCore
|
||||
return m_airspace->partsLastModified(callsign);
|
||||
}
|
||||
|
||||
bool CContextNetwork::testAddAltitudeOffset(const CCallsign &callsign, const CLength &offset)
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||
return m_airspace->testAddAltitudeOffset(callsign, offset);
|
||||
}
|
||||
|
||||
CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace BlackCore
|
||||
virtual int aircraftPartsAdded() const override;
|
||||
virtual qint64 situationsLastModified(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual qint64 partsLastModified(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual bool testAddAltitudeOffset(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CLength &offset = BlackMisc::PhysicalQuantities::CLength::null()) override;
|
||||
//! @}
|
||||
|
||||
//! In transition state, e.g. connecting, disconnecting.
|
||||
@@ -145,7 +146,8 @@ namespace BlackCore
|
||||
//! \addtogroup swiftdotcommands
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .m .msg message text
|
||||
//! .m .msg message text
|
||||
//! .altos .altoffset altitude offset for testing
|
||||
//! </pre>
|
||||
//! @}
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
@@ -158,6 +160,7 @@ namespace BlackCore
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".m", "alias: .msg"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".m message <text>", "send text message"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".m callsign message <text>", "send text message"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign offsetvalue", "set altitude offset value (testing)"});
|
||||
}
|
||||
|
||||
//! \publicsection
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackCore
|
||||
CContextNetworkProxy::CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
m_dBusInterface = new CGenericDBusInterface(
|
||||
serviceName , IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
connection, this);
|
||||
this->relaySignals(serviceName, connection);
|
||||
}
|
||||
@@ -290,6 +290,11 @@ namespace BlackCore
|
||||
m_dBusInterface->callDBus(QLatin1String("testRequestAircraftConfig"), callsign);
|
||||
}
|
||||
|
||||
bool CContextNetworkProxy::testAddAltitudeOffset(const CCallsign &callsign, const PhysicalQuantities::CLength &offset)
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1String("testAddAltitudeOffset"), callsign, offset);
|
||||
}
|
||||
|
||||
CStatusMessage CContextNetworkProxy::connectToNetwork(const CServer &server, INetwork::LoginMode loginMode)
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1String("connectToNetwork"), server, loginMode);
|
||||
|
||||
@@ -122,6 +122,7 @@ namespace BlackCore
|
||||
virtual void testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override;
|
||||
virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
|
||||
virtual void testRequestAircraftConfig(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual bool testAddAltitudeOffset(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CLength &offset = BlackMisc::PhysicalQuantities::CLength::null()) override;
|
||||
//! @}
|
||||
|
||||
public:
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#ifndef BLACKCORE_CONTEXT_CONTEXTSIMULATOR_IMPL_H
|
||||
#define BLACKCORE_CONTEXT_CONTEXTSIMULATOR_IMPL_H
|
||||
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackcore/application/applicationsettings.h"
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackcore/aircraftmatcher.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/weathermanager.h"
|
||||
@@ -51,7 +51,6 @@ namespace BlackCore
|
||||
{
|
||||
class CCoreFacade;
|
||||
class CPluginManagerSimulator;
|
||||
class ISimulator;
|
||||
|
||||
namespace Context
|
||||
{
|
||||
@@ -125,7 +124,7 @@ namespace BlackCore
|
||||
//! Gracefully shut down, e.g. for plugin unloading
|
||||
void gracefulShutdown();
|
||||
|
||||
//! Simulator object
|
||||
//! Access to simulator (i.e. the plugin)
|
||||
ISimulator *simulator() const;
|
||||
|
||||
//! Register dot commands
|
||||
|
||||
Reference in New Issue
Block a user