mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-24 06:25:37 +08:00
refs #289, settings for simulator
This commit is contained in:
@@ -21,14 +21,39 @@ namespace BlackMisc
|
|||||||
return rp;
|
return rp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrong cmd message
|
||||||
|
*/
|
||||||
|
BlackMisc::CStatusMessage CSettingUtilities::wrongCommandMessage(const QString &command)
|
||||||
|
{
|
||||||
|
QString msg = "wrong command";
|
||||||
|
if (!command.isEmpty())
|
||||||
|
{
|
||||||
|
msg.append(": ").append(command);
|
||||||
|
}
|
||||||
|
BlackMisc::CStatusMessage rc(BlackMisc::CStatusMessage::TypeValidation,
|
||||||
|
BlackMisc::CStatusMessage::SeverityError, msg);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wrong path name messages
|
* Wrong path name messages
|
||||||
*/
|
*/
|
||||||
CStatusMessageList CSettingUtilities::wrongPathMessages(const QString &path)
|
CStatusMessageList CSettingUtilities::wrongPathMessages(const QString &path)
|
||||||
{
|
{
|
||||||
BlackMisc::CStatusMessageList rps;
|
BlackMisc::CStatusMessageList wrongPath;
|
||||||
rps.push_back(CSettingUtilities::wrongPathMessage(path));
|
wrongPath.push_back(CSettingUtilities::wrongPathMessage(path));
|
||||||
return rps;
|
return wrongPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrong command message
|
||||||
|
*/
|
||||||
|
CStatusMessageList CSettingUtilities::wrongCommandMessages(const QString &command)
|
||||||
|
{
|
||||||
|
BlackMisc::CStatusMessageList wrongCmds;
|
||||||
|
wrongCmds.push_back(CSettingUtilities::wrongCommandMessage(command));
|
||||||
|
return wrongCmds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ namespace BlackMisc
|
|||||||
//! Wrong path messages
|
//! Wrong path messages
|
||||||
static BlackMisc::CStatusMessageList wrongPathMessages(const QString &path = "");
|
static BlackMisc::CStatusMessageList wrongPathMessages(const QString &path = "");
|
||||||
|
|
||||||
|
//! Wrong command message
|
||||||
|
static BlackMisc::CStatusMessage wrongCommandMessage(const QString &command);
|
||||||
|
|
||||||
|
//! Wrong command messages
|
||||||
|
static BlackMisc::CStatusMessageList wrongCommandMessages(const QString &command);
|
||||||
|
|
||||||
//! Value not changed message
|
//! Value not changed message
|
||||||
static BlackMisc::CStatusMessage valueNotChangedMessage(const QString &valueName);
|
static BlackMisc::CStatusMessage valueNotChangedMessage(const QString &valueName);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Settings;
|
using namespace BlackMisc::Settings;
|
||||||
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
{
|
{
|
||||||
@@ -98,7 +99,7 @@ namespace BlackSim
|
|||||||
*/
|
*/
|
||||||
QJsonObject CSettingsSimulator::toJson() const
|
QJsonObject CSettingsSimulator::toJson() const
|
||||||
{
|
{
|
||||||
return BlackMisc::serializeJson(CSettingsSimulator::jsonMembers(), TupleConverter<CSettingsSimulator>::toTuple(*this));
|
return BlackMisc::serializeJson(TupleConverter<CSettingsSimulator>::toMetaTuple(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -106,7 +107,7 @@ namespace BlackSim
|
|||||||
*/
|
*/
|
||||||
void CSettingsSimulator::fromJson(const QJsonObject &json)
|
void CSettingsSimulator::fromJson(const QJsonObject &json)
|
||||||
{
|
{
|
||||||
BlackMisc::deserializeJson(json, CSettingsSimulator::jsonMembers(), TupleConverter<CSettingsSimulator>::toTuple(*this));
|
BlackMisc::deserializeJson(json, TupleConverter<CSettingsSimulator>::toMetaTuple(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -123,6 +124,8 @@ namespace BlackSim
|
|||||||
void CSettingsSimulator::initDefaultValues()
|
void CSettingsSimulator::initDefaultValues()
|
||||||
{
|
{
|
||||||
this->m_selectedPlugin = CSimulatorInfo::FSX();
|
this->m_selectedPlugin = CSimulatorInfo::FSX();
|
||||||
|
this->m_timeSyncOffset = CTime(0, CTimeUnit::hrmin());
|
||||||
|
this->m_timeSync = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -146,18 +149,42 @@ namespace BlackSim
|
|||||||
{
|
{
|
||||||
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
|
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
|
||||||
{
|
{
|
||||||
if (command == CSettingUtilities::CmdUpdate())
|
CSimulatorInfo v = value.value<CSimulatorInfo>();
|
||||||
{
|
changedFlag = (v != this->m_selectedPlugin);
|
||||||
CSimulatorInfo v = value.value<CSimulatorInfo>();
|
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "selected driver"));
|
||||||
changedFlag = (v != this->m_selectedPlugin);
|
this->m_selectedPlugin = v;
|
||||||
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "selected driver"));
|
|
||||||
this->m_selectedPlugin = v;
|
|
||||||
return msgs;
|
|
||||||
}
|
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
return CSettingUtilities::wrongCommandMessages(command);
|
||||||
|
}
|
||||||
|
else if (path == CSettingsSimulator::ValueSyncTime())
|
||||||
|
{
|
||||||
|
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
|
||||||
|
{
|
||||||
|
bool v = value.value<bool>();
|
||||||
|
changedFlag = (v != this->m_timeSync);
|
||||||
|
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "time synchronization"));
|
||||||
|
this->m_timeSync = v;
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
return CSettingUtilities::wrongCommandMessages(command);
|
||||||
|
}
|
||||||
|
else if (path == CSettingsSimulator::ValueSyncTimeOffset())
|
||||||
|
{
|
||||||
|
if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate())
|
||||||
|
{
|
||||||
|
CTime v = value.value<CTime>();
|
||||||
|
changedFlag = (v != this->m_timeSyncOffset);
|
||||||
|
msgs.push_back(CSettingUtilities::valueChangedMessage(changedFlag, "time synchronization offset"));
|
||||||
|
this->m_timeSyncOffset = v;
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
return CSettingUtilities::wrongCommandMessages(command);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return CSettingUtilities::wrongPathMessages(path);
|
||||||
}
|
}
|
||||||
return CSettingUtilities::wrongPathMessages(path);
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "blackmisc/valueobject.h"
|
#include "blackmisc/valueobject.h"
|
||||||
#include "blackmisc/statusmessagelist.h"
|
#include "blackmisc/statusmessagelist.h"
|
||||||
#include "blackmisc/settingutilities.h"
|
#include "blackmisc/settingutilities.h"
|
||||||
|
#include "blackmisc/pqtime.h"
|
||||||
#include "simulatorinfo.h"
|
#include "simulatorinfo.h"
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
@@ -34,15 +35,41 @@ namespace BlackSim
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Path
|
||||||
|
static const QString &ValueSyncTimeOffset()
|
||||||
|
{
|
||||||
|
static const QString value("synctimeoffset");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Path
|
||||||
|
static const QString &ValueSyncTime()
|
||||||
|
{
|
||||||
|
static const QString value("synctime");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant()
|
//! \copydoc CValueObject::toQVariant()
|
||||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
|
|
||||||
//! Selected driver
|
//! Selected driver
|
||||||
BlackSim::CSimulatorInfo getSelectedPlugin() const { return this->m_selectedPlugin; }
|
const BlackSim::CSimulatorInfo &getSelectedPlugin() const { return this->m_selectedPlugin; }
|
||||||
|
|
||||||
//! Selected driver
|
//! Selected driver
|
||||||
void setSelectedPlugin(const BlackSim::CSimulatorInfo &plugin) { this->m_selectedPlugin = plugin; }
|
void setSelectedPlugin(const BlackSim::CSimulatorInfo &plugin) { this->m_selectedPlugin = plugin; }
|
||||||
|
|
||||||
|
//! Time synchronization offset time
|
||||||
|
const BlackMisc::PhysicalQuantities::CTime &getSyncTimeOffset() const { return this->m_timeSyncOffset;}
|
||||||
|
|
||||||
|
//! Set time synchronization offset time
|
||||||
|
void setSyncTimeOffset(const BlackMisc::PhysicalQuantities::CTime &offset) { this->m_timeSyncOffset = offset; this->m_timeSyncOffset.switchUnit(BlackMisc::PhysicalQuantities::CTimeUnit::hrmin());}
|
||||||
|
|
||||||
|
//! Time syncronization enabled?
|
||||||
|
bool isTimeSyncEnabled() const { return this->m_timeSync;}
|
||||||
|
|
||||||
|
//! Set time synchronization
|
||||||
|
void setTimeSyncEnabled(bool enabled) { this->m_timeSync = enabled; }
|
||||||
|
|
||||||
//! Equal operator ==
|
//! Equal operator ==
|
||||||
bool operator ==(const CSettingsSimulator &other) const;
|
bool operator ==(const CSettingsSimulator &other) const;
|
||||||
|
|
||||||
@@ -92,12 +119,14 @@ namespace BlackSim
|
|||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CSettingsSimulator)
|
BLACK_ENABLE_TUPLE_CONVERSION(CSettingsSimulator)
|
||||||
BlackSim::CSimulatorInfo m_selectedPlugin;
|
BlackSim::CSimulatorInfo m_selectedPlugin;
|
||||||
|
bool m_timeSync = false;
|
||||||
|
BlackMisc::PhysicalQuantities::CTime m_timeSyncOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(BlackSim::Settings::CSettingsSimulator)
|
Q_DECLARE_METATYPE(BlackSim::Settings::CSettingsSimulator)
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::Settings::CSettingsSimulator, (o.m_selectedPlugin))
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::Settings::CSettingsSimulator, (o.m_selectedPlugin, o.m_timeSync, o.m_timeSyncOffset))
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user