mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T709, added "follow aircraft distance" and timestamp, removed old settings
This commit is contained in:
committed by
Mat Sutcliffe
parent
8845d1d35c
commit
5ebf119acb
@@ -24,13 +24,15 @@ namespace BlackMisc
|
||||
CVariant CXSwiftBusSettings::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMaxPlanes: return CVariant::fromValue(m_maxPlanes);
|
||||
case IndexDBusServerAddress: return CVariant::fromValue(QString::fromStdString(m_dBusServerAddress));
|
||||
case IndexDrawingLabels: return CVariant::fromValue(m_drawingLabels);
|
||||
case IndexMaxDrawingDistance: return CVariant::fromValue(m_maxDrawDistanceNM);
|
||||
case IndexMaxPlanes: return CVariant::fromValue(m_maxPlanes);
|
||||
case IndexDBusServerAddress: return CVariant::fromValue(QString::fromStdString(m_dBusServerAddress));
|
||||
case IndexDrawingLabels: return CVariant::fromValue(m_drawingLabels);
|
||||
case IndexMaxDrawingDistance: return CVariant::fromValue(m_maxDrawDistanceNM);
|
||||
case IndexFollowAircraftDistance: return CVariant::fromValue(m_followAircraftDistanceM);
|
||||
default: break;
|
||||
}
|
||||
return CValueObject::propertyByIndex(index);
|
||||
@@ -39,13 +41,16 @@ namespace BlackMisc
|
||||
void CXSwiftBusSettings::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CXSwiftBusSettings>(); return; }
|
||||
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); }
|
||||
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMaxPlanes: m_maxPlanes = variant.toInt(); break;
|
||||
case IndexDBusServerAddress: m_dBusServerAddress = variant.toStdString(); break;
|
||||
case IndexDrawingLabels: m_drawingLabels = variant.toBool(); break;
|
||||
case IndexMaxDrawingDistance: m_maxDrawDistanceNM = variant.toDouble(); break;
|
||||
case IndexMaxPlanes: m_maxPlanes = variant.toInt(); break;
|
||||
case IndexDBusServerAddress: m_dBusServerAddress = variant.toStdString(); break;
|
||||
case IndexDrawingLabels: m_drawingLabels = variant.toBool(); break;
|
||||
case IndexMaxDrawingDistance: m_maxDrawDistanceNM = variant.toDouble(); break;
|
||||
case IndexFollowAircraftDistance: m_followAircraftDistanceM = variant.toInt(); break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
@@ -58,6 +63,12 @@ namespace BlackMisc
|
||||
return QString::fromStdString(CXSwiftBusSettingsQtFree::convertToString());
|
||||
}
|
||||
|
||||
void CXSwiftBusSettings::setCurrentUtcTime()
|
||||
{
|
||||
ITimestampBased::setCurrentUtcTime();
|
||||
m_msSinceEpochQtFree = m_timestampMSecsSinceEpoch;
|
||||
}
|
||||
|
||||
CStatusMessageList CXSwiftBusSettings::validate() const
|
||||
{
|
||||
CStatusMessageList msgs;
|
||||
|
||||
@@ -39,7 +39,8 @@ namespace BlackMisc
|
||||
IndexDBusServerAddress = CPropertyIndex::GlobalIndexCXSwiftBusSettings,
|
||||
IndexMaxPlanes,
|
||||
IndexDrawingLabels,
|
||||
IndexMaxDrawingDistance
|
||||
IndexMaxDrawingDistance,
|
||||
IndexFollowAircraftDistance
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
@@ -69,6 +70,9 @@ namespace BlackMisc
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::parseXSwiftBusString
|
||||
void parseXSwiftBusStringQt(const QString &json) { this->parseXSwiftBusString(json.toStdString()); }
|
||||
|
||||
//! Sets both timestamps
|
||||
virtual void setCurrentUtcTime() override;
|
||||
|
||||
//! Valid settings?
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
@@ -82,29 +86,11 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(maxPlanes),
|
||||
BLACK_METAMEMBER(drawingLabels),
|
||||
BLACK_METAMEMBER(maxDrawDistanceNM),
|
||||
BLACK_METAMEMBER(followAircraftDistanceM),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForComparison | DisabledForHashing)
|
||||
);
|
||||
};
|
||||
|
||||
/*!
|
||||
* Setting for XSwiftBus.
|
||||
* @deprecated will be changed to JSON Settings
|
||||
*/
|
||||
struct TXSwiftBusServer : public TSettingTrait<QString>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "xswiftbus/server"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("XSwiftBus"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static QString defaultValue() { return "tcp:host=127.0.0.1,port=45001"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const QString &dBusAddress, QString &) { return BlackMisc::CDBusServer::isSessionOrSystemAddress(dBusAddress) || BlackMisc::CDBusServer::isQtDBusAddress(dBusAddress); }
|
||||
};
|
||||
|
||||
/*!
|
||||
* Setting for XSwiftBus.
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,8 @@ constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonDB
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonDrawingLabels[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMaxPlanes[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMaxDrawDistance[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTimestamp[];
|
||||
//! @endcond
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -60,7 +62,15 @@ namespace BlackMisc
|
||||
{
|
||||
m_maxDrawDistanceNM = settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxDrawDistance].GetDouble(); c++;
|
||||
}
|
||||
return c == 4;
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM) && settingsDoc[CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM].IsInt())
|
||||
{
|
||||
m_followAircraftDistanceM = settingsDoc[CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM].GetInt(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonTimestamp) && settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].IsInt64())
|
||||
{
|
||||
m_msSinceEpochQtFree = settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].GetInt64(); c++;
|
||||
}
|
||||
return c == 6;
|
||||
}
|
||||
|
||||
std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const
|
||||
@@ -77,6 +87,8 @@ namespace BlackMisc
|
||||
document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
|
||||
document.AddMember(JsonMaxPlanes, m_maxPlanes, a);
|
||||
document.AddMember(JsonMaxDrawDistance, m_maxDrawDistanceNM, a);
|
||||
document.AddMember(JsonTimestamp, m_msSinceEpochQtFree, a);
|
||||
document.AddMember(JsonFollowAircraftDistanceM, m_followAircraftDistanceM, a);
|
||||
|
||||
// document[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].SetString(StringRef(m_dBusServerAddress.c_str(), m_dBusServerAddress.size()));
|
||||
// document[CXSwiftBusSettingsQtFree::JsonDrawingLabels].SetBool(m_drawingLabels);
|
||||
@@ -95,7 +107,9 @@ namespace BlackMisc
|
||||
return "DBusServer: " + m_dBusServerAddress +
|
||||
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
|
||||
", max planes: " + std::to_string(m_maxPlanes) +
|
||||
", max distance NM: " + std::to_string(m_maxDrawDistanceNM);
|
||||
", max distance NM: " + std::to_string(m_maxDrawDistanceNM) +
|
||||
", follow dist m: " + std::to_string(m_followAircraftDistanceM) +
|
||||
", ts: " + std::to_string(m_msSinceEpochQtFree);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -45,6 +45,12 @@ namespace BlackMisc
|
||||
//! Get the maximum number of aircraft.
|
||||
int getMaxPlanes() const { return m_maxPlanes; }
|
||||
|
||||
//! Set follow aircraft distance
|
||||
void setFollowAircraftDistanceM(int meters) { m_followAircraftDistanceM = meters; }
|
||||
|
||||
//! Get follow aircraft distance
|
||||
int getFollowAircraftDistanceM() const { return m_followAircraftDistanceM; }
|
||||
|
||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
||||
double getMaxDrawDistanceNM() const { return m_maxDrawDistanceNM; }
|
||||
|
||||
@@ -66,12 +72,16 @@ namespace BlackMisc
|
||||
static constexpr char JsonDrawingLabels[] = "drawinglabels";
|
||||
static constexpr char JsonMaxPlanes[] = "maxplanes";
|
||||
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
|
||||
static constexpr char JsonTimestamp[] = "timestamp";
|
||||
static constexpr char JsonFollowAircraftDistanceM[] = "followAircraftDistance";
|
||||
//! @}
|
||||
|
||||
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server
|
||||
int m_maxPlanes = 100; //!< max. planes in XPlane
|
||||
bool m_drawingLabels = true; //!< labels in XPlane
|
||||
double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
|
||||
int m_maxPlanes = 100; //!< max. planes in XPlane
|
||||
int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
|
||||
bool m_drawingLabels = true; //!< labels in XPlane
|
||||
double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
|
||||
int64_t m_msSinceEpochQtFree = 0; //!< timestamp
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user