mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
refs #894, register dot commands for help
(wherever dor commands are implemented)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
b287d8d9d7
commit
38ea336cbb
@@ -62,6 +62,7 @@ namespace BlackCore
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getIContextOwnAircraft());
|
||||
Q_ASSERT(this->getIContextOwnAircraft()->isUsingImplementingObject());
|
||||
CContextNetwork::registerHelp();
|
||||
|
||||
// 1. Init by "network driver"
|
||||
this->m_network = new CNetworkVatlib(this->getRuntime()->getCContextOwnAircraft(), this);
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
|
||||
class QTimer;
|
||||
|
||||
@@ -141,6 +142,15 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
|
||||
//! Register help
|
||||
static void registerHelp()
|
||||
{
|
||||
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CContextNetwork")) { return; }
|
||||
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"});
|
||||
}
|
||||
|
||||
//! \publicsection
|
||||
//! @{
|
||||
virtual BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override;
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
this->setObjectName("CContextOwnAircraft");
|
||||
CContextOwnAircraft::registerHelp();
|
||||
|
||||
if (sApp && sApp->getWebDataServices())
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QReadWriteLock>
|
||||
@@ -141,6 +142,7 @@ namespace BlackCore
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .x .xpdr code set transponder code BlackCore::Context::CContextOwnAircraft
|
||||
//! .x .xpdr mode set transponder mode BlackCore::Context::CContextOwnAircraft
|
||||
//! .com1 .com2 frequency set COM1/2 frequency BlackCore::Context::CContextOwnAircraft
|
||||
//! .selcal code set SELCAL code BlackCore::Context::CContextOwnAircraft
|
||||
//! </pre>
|
||||
@@ -148,6 +150,18 @@ namespace BlackCore
|
||||
//! \copydoc IContextOwnAircraft::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
|
||||
//! Register help
|
||||
static void registerHelp()
|
||||
{
|
||||
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::Context::CContextOwnAircraft")) { return; }
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".x", "alias: .xpdr"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".x code|mode", "set XPDR code or mode"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".selcal code", "set SELCAL code"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".com1", "alias .c1"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".com1 frequency", "set COM1 frequency"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".com2 frequency", "set COM2 frequency"});
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Constructor, with link to runtime
|
||||
CContextOwnAircraft(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime);
|
||||
|
||||
@@ -51,6 +51,13 @@ namespace BlackCore
|
||||
return static_cast<SimulatorStatus>(status);
|
||||
}
|
||||
|
||||
ISimulator::ISimulator(QObject *parent) :
|
||||
QObject(parent),
|
||||
BlackMisc::CIdentifiable(this)
|
||||
{
|
||||
ISimulator::registerHelp();
|
||||
}
|
||||
|
||||
void ISimulator::emitSimulatorCombinedStatus(int oldStatus)
|
||||
{
|
||||
int newStatus = getSimulatorStatus();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
|
||||
#include <QFlags>
|
||||
#include <QObject>
|
||||
@@ -159,6 +160,15 @@ namespace BlackCore
|
||||
//! Parse command line
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0;
|
||||
|
||||
//! Register help
|
||||
static void registerHelp()
|
||||
{
|
||||
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv unload", "unload driver"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "enable/disable FSUIPC (if applicable)"});
|
||||
}
|
||||
|
||||
//! Status to string
|
||||
static QString statusToString(int status);
|
||||
|
||||
@@ -188,10 +198,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
ISimulator(QObject *parent = nullptr) :
|
||||
QObject(parent),
|
||||
BlackMisc::CIdentifiable(this)
|
||||
{}
|
||||
ISimulator(QObject *parent = nullptr);
|
||||
|
||||
//! Are we connected to the simulator?
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace BlackCore
|
||||
m_simulatorPluginInfo(info)
|
||||
{
|
||||
this->setObjectName("Simulator: " + info.getIdentifier());
|
||||
CSimulatorCommon::registerHelp();
|
||||
|
||||
// provider signals, hook up with remote aircraft provider
|
||||
m_remoteAircraftProviderConnections.append(
|
||||
|
||||
@@ -88,15 +88,27 @@ namespace BlackCore
|
||||
//! \addtogroup swiftdotcommands
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .plugin unload unload plugin BlackCore::CSimulatorCommon
|
||||
//! .plugin logint callsign log interpolator for callsign BlackCore::CSimulatorCommon
|
||||
//! .plugin logint off no log information for interpolator BlackCore::CSimulatorCommon
|
||||
//! .plugin logint write write interpolator log to file BlackCore::CSimulatorCommon
|
||||
//! .plugin logint clear clear current log BlackCore::CSimulatorCommon
|
||||
//! .drv unload unload plugin BlackCore::CSimulatorCommon
|
||||
//! .drv logint callsign log interpolator for callsign BlackCore::CSimulatorCommon
|
||||
//! .drv logint off no log information for interpolator BlackCore::CSimulatorCommon
|
||||
//! .drv logint write write interpolator log to file BlackCore::CSimulatorCommon
|
||||
//! .drv logint clear clear current log BlackCore::CSimulatorCommon
|
||||
//! </pre>
|
||||
//! @}
|
||||
//! \copydoc ISimulator::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
|
||||
//! Register help
|
||||
static void registerHelp()
|
||||
{
|
||||
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CSimulatorCommon")) { return; }
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv logint callsign", "log interpolator for callsign"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv logint off", "no log information for interpolator"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv logint write", "write interpolator log to file"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv logint clear", "clear current log"});
|
||||
}
|
||||
|
||||
// --------- ISimulator implementations ------------
|
||||
|
||||
protected slots:
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -19,8 +20,8 @@ using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
QList<CSimpleCommandParser::CommandHtmlHelp> CSimpleCommandParser::s_commands = QList<CSimpleCommandParser::CommandHtmlHelp>();
|
||||
QSet<QString> CSimpleCommandParser::s_registered = QSet<QString>();
|
||||
QList<CSimpleCommandParser::CommandHtmlHelp> CSimpleCommandParser::s_commands;
|
||||
QSet<QString> CSimpleCommandParser::s_registered;
|
||||
|
||||
CSimpleCommandParser::CSimpleCommandParser(const QStringList &knownCommands)
|
||||
{
|
||||
@@ -135,30 +136,30 @@ namespace BlackMisc
|
||||
|
||||
void CSimpleCommandParser::registerCommand(const CSimpleCommandParser::CommandHtmlHelp &command)
|
||||
{
|
||||
for (const CommandHtmlHelp &help : as_const(CSimpleCommandParser::s_commands))
|
||||
for (const CommandHtmlHelp &help : as_const(s_commands))
|
||||
{
|
||||
// avoid duplicates
|
||||
if (help.command == command.command) { return; }
|
||||
}
|
||||
CSimpleCommandParser::s_commands.append(command);
|
||||
s_commands.append(command);
|
||||
}
|
||||
|
||||
bool CSimpleCommandParser::registered(const QString &helpContext)
|
||||
{
|
||||
if (CSimpleCommandParser::s_registered.contains(helpContext)) { return true; };
|
||||
CSimpleCommandParser::s_registered.insert(helpContext);
|
||||
if (s_registered.contains(helpContext)) { return true; };
|
||||
s_registered.insert(helpContext);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString CSimpleCommandParser::commandsHtmlHelp()
|
||||
{
|
||||
if (CSimpleCommandParser::s_commands.isEmpty()) { return ""; }
|
||||
if (s_commands.isEmpty()) { return ""; }
|
||||
|
||||
static const QString html("<table style=\"font-size: 8pt; white-space: nowrap;\">\n%1\n</table>");
|
||||
static const QString row("<td>%1</td><td>%2</td>");
|
||||
|
||||
QString rows;
|
||||
QList<CommandHtmlHelp> cmds(CSimpleCommandParser::s_commands);
|
||||
QList<CommandHtmlHelp> cmds(s_commands);
|
||||
qSort(cmds.begin(), cmds.end(), CommandHtmlHelp::less);
|
||||
for (int i = 0; i < cmds.size(); i++)
|
||||
{
|
||||
|
||||
@@ -89,7 +89,6 @@ namespace BlackMisc
|
||||
//! Compare by command
|
||||
static bool less(const CommandHtmlHelp &a, const CommandHtmlHelp &b)
|
||||
{
|
||||
// may want to check that the pointers aren't zero...
|
||||
return a.command < b.command;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,7 +34,9 @@ namespace BlackSimPlugin
|
||||
QObject *parent) :
|
||||
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, parent),
|
||||
m_fsuipc(new CFsuipc())
|
||||
{ }
|
||||
{
|
||||
CSimulatorFsCommon::registerHelp();
|
||||
}
|
||||
|
||||
CSimulatorFsCommon::~CSimulatorFsCommon() { }
|
||||
|
||||
|
||||
@@ -65,11 +65,19 @@ namespace BlackSimPlugin
|
||||
//! \addtogroup swiftdotcommands
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .plugin fsuipc on|off FSUIPC on/off
|
||||
//! .drv fsuipc on|off FSUIPC on/off
|
||||
//! </pre>
|
||||
//! @}
|
||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override;
|
||||
|
||||
//! Register help
|
||||
static void registerHelp()
|
||||
{
|
||||
if (BlackMisc::CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; }
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
|
||||
BlackMisc::CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "FSUIPC on|off if applicable"});
|
||||
}
|
||||
|
||||
QString m_simulatorName; //!< name of simulator
|
||||
QString m_simulatorDetails; //!< describes version etc.
|
||||
QString m_simulatorVersion; //!< Simulator version
|
||||
|
||||
Reference in New Issue
Block a user