mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Ref T668, allow to set an additional time offset via "dot command"
This commit is contained in:
@@ -6,36 +6,37 @@
|
|||||||
* or distributed except according to the terms contained in the LICENSE file.
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackconfig/buildconfig.h"
|
#include "blackcore/vatsim/networkvatlib.h"
|
||||||
#include "blackcore/airspaceanalyzer.h"
|
|
||||||
#include "blackcore/airspacemonitor.h"
|
|
||||||
#include "blackcore/application.h"
|
|
||||||
#include "blackcore/context/contextnetworkimpl.h"
|
#include "blackcore/context/contextnetworkimpl.h"
|
||||||
#include "blackcore/context/contextownaircraft.h"
|
#include "blackcore/context/contextownaircraft.h"
|
||||||
#include "blackcore/context/contextownaircraftimpl.h"
|
#include "blackcore/context/contextownaircraftimpl.h"
|
||||||
#include "blackcore/context/contextsimulatorimpl.h"
|
#include "blackcore/context/contextsimulatorimpl.h"
|
||||||
|
#include "blackcore/airspaceanalyzer.h"
|
||||||
|
#include "blackcore/airspacemonitor.h"
|
||||||
|
#include "blackcore/application.h"
|
||||||
#include "blackcore/corefacade.h"
|
#include "blackcore/corefacade.h"
|
||||||
#include "blackcore/vatsim/networkvatlib.h"
|
|
||||||
#include "blackcore/webdataservices.h"
|
#include "blackcore/webdataservices.h"
|
||||||
|
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||||
#include "blackmisc/aviation/aircraftparts.h"
|
#include "blackmisc/aviation/aircraftparts.h"
|
||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
#include "blackmisc/aviation/comsystem.h"
|
#include "blackmisc/aviation/comsystem.h"
|
||||||
#include "blackmisc/aviation/callsign.h"
|
#include "blackmisc/aviation/callsign.h"
|
||||||
#include "blackmisc/aviation/comsystem.h"
|
#include "blackmisc/aviation/comsystem.h"
|
||||||
#include "blackmisc/dbusserver.h"
|
|
||||||
#include "blackmisc/logcategory.h"
|
|
||||||
#include "blackmisc/logmessage.h"
|
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/entityflags.h"
|
||||||
#include "blackmisc/network/networkutils.h"
|
#include "blackmisc/network/networkutils.h"
|
||||||
#include "blackmisc/network/textmessage.h"
|
#include "blackmisc/network/textmessage.h"
|
||||||
#include "blackmisc/pq/constants.h"
|
#include "blackmisc/pq/constants.h"
|
||||||
#include "blackmisc/pq/frequency.h"
|
#include "blackmisc/pq/frequency.h"
|
||||||
|
#include "blackmisc/pq/time.h"
|
||||||
#include "blackmisc/pq/units.h"
|
#include "blackmisc/pq/units.h"
|
||||||
|
#include "blackmisc/dbusserver.h"
|
||||||
|
#include "blackmisc/logcategory.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
#include "blackmisc/simplecommandparser.h"
|
#include "blackmisc/simplecommandparser.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
|
||||||
#include "blackmisc/stringutils.h"
|
#include "blackmisc/stringutils.h"
|
||||||
|
#include "blackconfig/buildconfig.h"
|
||||||
#include "contextnetworkimpl.h"
|
#include "contextnetworkimpl.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -280,7 +281,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
Q_UNUSED(originator;)
|
Q_UNUSED(originator;)
|
||||||
if (commandLine.isEmpty()) { return false; }
|
if (commandLine.isEmpty()) { return false; }
|
||||||
static const QStringList cmds({ ".msg", ".m", ".chat", ".altos", ".altoffset", ".wallop", ".watchdog", ".reinit", ".reinitialize", ".enable", ".disable", ".ignore", ".unignore" });
|
static const QStringList cmds({ ".msg", ".m", ".chat", ".altos", ".altoffset", ".addtimeos", ".addtimeoffset", ".wallop", ".watchdog", ".reinit", ".reinitialize", ".enable", ".disable", ".ignore", ".unignore" });
|
||||||
CSimpleCommandParser parser(cmds);
|
CSimpleCommandParser parser(cmds);
|
||||||
parser.parse(commandLine);
|
parser.parse(commandLine);
|
||||||
if (!parser.isKnownCommand()) { return false; }
|
if (!parser.isKnownCommand()) { return false; }
|
||||||
@@ -394,6 +395,27 @@ namespace BlackCore
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (parser.matchesCommand(".addtimeos", ".addtimeoffset"))
|
||||||
|
{
|
||||||
|
if (!m_airspace) { return false; }
|
||||||
|
if (parser.countParts() < 2) { return false; }
|
||||||
|
|
||||||
|
CTime os(CTime::null());
|
||||||
|
if (parser.hasPart(2))
|
||||||
|
{
|
||||||
|
os.parseFromString(parser.part(2), CPqString::SeparatorBestGuess);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!os.isNull() && os.isPositiveWithEpsilonConsidered())
|
||||||
|
{
|
||||||
|
const qint64 ost = os.valueInteger(CTimeUnit::ms());
|
||||||
|
CLogMessage(this).info(u"Added add offset time %1ms") << ost;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLogMessage(this).info(u"Reset add. time offset");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (parser.matchesCommand(".watchdog"))
|
else if (parser.matchesCommand(".watchdog"))
|
||||||
{
|
{
|
||||||
if (!m_airspace) { return false; }
|
if (!m_airspace) { return false; }
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ namespace BlackCore
|
|||||||
//! <pre>
|
//! <pre>
|
||||||
//! .m .msg .chat message text
|
//! .m .msg .chat message text
|
||||||
//! .altos .altoffset altitude offset for testing
|
//! .altos .altoffset altitude offset for testing
|
||||||
|
//! .addtimeos .addtimeoffse additional offset time for testing
|
||||||
//! .reinit .reinitialize re-initialize all aircraft
|
//! .reinit .reinitialize re-initialize all aircraft
|
||||||
//! .watchdog on|off watchdog on/off
|
//! .watchdog on|off watchdog on/off
|
||||||
//! .wallop message send wallop message
|
//! .wallop message send wallop message
|
||||||
@@ -225,6 +226,7 @@ namespace BlackCore
|
|||||||
BlackMisc::CSimpleCommandParser::registerCommand({".m message text", "send text message"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".m message text", "send text message"});
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".m callsign 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)"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".altos callsign|? offsetvalue", "set altitude offset value (testing)"});
|
||||||
|
BlackMisc::CSimpleCommandParser::registerCommand({".addtimeos offsetvalue", "add (delta) time offset (testing), e.g. 50ms"});
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".watchdog on|off", "enable/disable network watchdog (testing)"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".watchdog on|off", "enable/disable network watchdog (testing)"});
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".wallop message", "send a wallop message"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".wallop message", "send a wallop message"});
|
||||||
BlackMisc::CSimpleCommandParser::registerCommand({".reinit", "re-initialize all aircraft"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".reinit", "re-initialize all aircraft"});
|
||||||
|
|||||||
@@ -395,6 +395,19 @@ namespace BlackCore
|
|||||||
* \sa metarReplyReceived
|
* \sa metarReplyReceived
|
||||||
*/
|
*/
|
||||||
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) = 0;
|
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) = 0;
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
//! \name Others
|
||||||
|
//! @{
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//! Additional offset time @{
|
||||||
|
virtual qint64 getAdditionalOffsetTime() const = 0;
|
||||||
|
virtual void setAdditionalOffsetTime(qint64 addOffset) = 0;
|
||||||
|
//! @}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! @}
|
//! @}
|
||||||
|
|||||||
@@ -1273,7 +1273,7 @@ namespace BlackCore
|
|||||||
offsetTime = CFsdSetup::c_interimPositionTimeOffsetMsec;
|
offsetTime = CFsdSetup::c_interimPositionTimeOffsetMsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
return offsetTime;
|
return m_additionalOffsetTime + offsetTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 CNetworkVatlib::currentOffsetTime(const CCallsign &callsign) const
|
qint64 CNetworkVatlib::currentOffsetTime(const CCallsign &callsign) const
|
||||||
|
|||||||
@@ -121,14 +121,19 @@ namespace BlackCore
|
|||||||
virtual const BlackMisc::Aviation::CCallsignSet &getInterimPositionReceivers() const override;
|
virtual const BlackMisc::Aviation::CCallsignSet &getInterimPositionReceivers() const override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Arguments to be passed to another swift appplication
|
|
||||||
static QStringList vatlibArguments();
|
|
||||||
|
|
||||||
//! \name Weather functions
|
//! \name Weather functions
|
||||||
//! @{
|
//! @{
|
||||||
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) override;
|
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Additional offset time @{
|
||||||
|
virtual qint64 getAdditionalOffsetTime() const override { return m_additionalOffsetTime; }
|
||||||
|
virtual void setAdditionalOffsetTime(qint64 addOffset) override { m_additionalOffsetTime = addOffset; }
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! Arguments to be passed to another swift appplication
|
||||||
|
static QStringList vatlibArguments();
|
||||||
|
|
||||||
//! Command line options this library can handle
|
//! Command line options this library can handle
|
||||||
static const QList<QCommandLineOption> &getCmdLineOptions();
|
static const QList<QCommandLineOption> &getCmdLineOptions();
|
||||||
|
|
||||||
@@ -136,6 +141,7 @@ namespace BlackCore
|
|||||||
static int constexpr c_processingIntervalMsec = 100; //!< interval for the processing timer
|
static int constexpr c_processingIntervalMsec = 100; //!< interval for the processing timer
|
||||||
static int constexpr c_updatePostionIntervalMsec = 5000; //!< interval for the position update timer (send our position to network)
|
static int constexpr c_updatePostionIntervalMsec = 5000; //!< interval for the position update timer (send our position to network)
|
||||||
static int constexpr c_updateInterimPostionIntervalMsec = 1000; //!< interval for iterim position updates (send our position as interim position)
|
static int constexpr c_updateInterimPostionIntervalMsec = 1000; //!< interval for iterim position updates (send our position as interim position)
|
||||||
|
qint64 m_additionalOffsetTime = 0; //!< additional offset time
|
||||||
|
|
||||||
static bool getCmdLineClientIdAndKey(int &id, QString &key);
|
static bool getCmdLineClientIdAndKey(int &id, QString &key);
|
||||||
|
|
||||||
@@ -186,11 +192,12 @@ namespace BlackCore
|
|||||||
void initializeSession();
|
void initializeSession();
|
||||||
void changeConnectionStatus(VatConnectionStatus newStatus);
|
void changeConnectionStatus(VatConnectionStatus newStatus);
|
||||||
bool isDisconnected() const { return m_status != vatStatusConnecting && m_status != vatStatusConnected; }
|
bool isDisconnected() const { return m_status != vatStatusConnecting && m_status != vatStatusConnected; }
|
||||||
|
void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data);
|
||||||
|
|
||||||
static QString convertToUnicodeEscaped(const QString &str);
|
static QString convertToUnicodeEscaped(const QString &str);
|
||||||
static VatSimType convertToSimType(BlackMisc::Simulation::CSimulatorPluginInfo &simInfo);
|
static VatSimType convertToSimType(BlackMisc::Simulation::CSimulatorPluginInfo &simInfo);
|
||||||
static void networkLogHandler(VatSeverityLevel severity, const char *context, const char *message);
|
static void networkLogHandler(VatSeverityLevel severity, const char *context, const char *message);
|
||||||
static QString simplifyTextMessage(const QString &msg);
|
static QString simplifyTextMessage(const QString &msg);
|
||||||
void sendCustomPacket(const BlackMisc::Aviation::CCallsign &callsign, const QString &packetId, const QStringList &data);
|
|
||||||
|
|
||||||
//! Default model string
|
//! Default model string
|
||||||
static const QString &defaultModelString()
|
static const QString &defaultModelString()
|
||||||
|
|||||||
Reference in New Issue
Block a user