Ref T668, allow to set an additional time offset via "dot command"

This commit is contained in:
Klaus Basan
2019-05-18 00:34:21 +02:00
parent 6596397c1e
commit a37ce2d258
5 changed files with 64 additions and 20 deletions

View File

@@ -6,36 +6,37 @@
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "blackconfig/buildconfig.h"
#include "blackcore/airspaceanalyzer.h"
#include "blackcore/airspacemonitor.h"
#include "blackcore/application.h"
#include "blackcore/vatsim/networkvatlib.h"
#include "blackcore/context/contextnetworkimpl.h"
#include "blackcore/context/contextownaircraft.h"
#include "blackcore/context/contextownaircraftimpl.h"
#include "blackcore/context/contextsimulatorimpl.h"
#include "blackcore/airspaceanalyzer.h"
#include "blackcore/airspacemonitor.h"
#include "blackcore/application.h"
#include "blackcore/corefacade.h"
#include "blackcore/vatsim/networkvatlib.h"
#include "blackcore/webdataservices.h"
#include "blackmisc/simulation/simulatorplugininfo.h"
#include "blackmisc/aviation/aircrafticaocode.h"
#include "blackmisc/aviation/aircraftparts.h"
#include "blackmisc/aviation/atcstationlist.h"
#include "blackmisc/aviation/comsystem.h"
#include "blackmisc/aviation/callsign.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/networkutils.h"
#include "blackmisc/network/textmessage.h"
#include "blackmisc/pq/constants.h"
#include "blackmisc/pq/frequency.h"
#include "blackmisc/pq/time.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/dbusserver.h"
#include "blackmisc/logcategory.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/sequence.h"
#include "blackmisc/simplecommandparser.h"
#include "blackmisc/simulation/simulatorplugininfo.h"
#include "blackmisc/stringutils.h"
#include "blackconfig/buildconfig.h"
#include "contextnetworkimpl.h"
#include <stdbool.h>
@@ -280,7 +281,7 @@ namespace BlackCore
{
Q_UNUSED(originator;)
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);
parser.parse(commandLine);
if (!parser.isKnownCommand()) { return false; }
@@ -394,6 +395,27 @@ namespace BlackCore
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"))
{
if (!m_airspace) { return false; }

View File

@@ -207,11 +207,12 @@ namespace BlackCore
//! \addtogroup swiftdotcommands
//! @{
//! <pre>
//! .m .msg .chat message text
//! .altos .altoffset altitude offset for testing
//! .reinit .reinitialize re-initialize all aircraft
//! .watchdog on|off watchdog on/off
//! .wallop message send wallop message
//! .m .msg .chat message text
//! .altos .altoffset altitude offset for testing
//! .addtimeos .addtimeoffse additional offset time for testing
//! .reinit .reinitialize re-initialize all aircraft
//! .watchdog on|off watchdog on/off
//! .wallop message send wallop message
//! </pre>
//! @}
//! \copydoc IContextNetwork::parseCommandLine
@@ -225,6 +226,7 @@ namespace BlackCore
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)"});
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({".wallop message", "send a wallop message"});
BlackMisc::CSimpleCommandParser::registerCommand({".reinit", "re-initialize all aircraft"});