mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 12:45:35 +08:00
Ref T709, added "follow aircraft distance" and timestamp, removed old settings
This commit is contained in:
committed by
Mat Sutcliffe
parent
a5cefcf18c
commit
c0b4d38331
@@ -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
|
||||
|
||||
@@ -1061,7 +1061,8 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (!this->isConnected()) { return false; }
|
||||
if (!m_serviceProxy) { return false; }
|
||||
const CXSwiftBusSettings s = m_xSwiftBusServerSettings.get();
|
||||
CXSwiftBusSettings s = m_xSwiftBusServerSettings.get();
|
||||
s.setCurrentUtcTime();
|
||||
m_serviceProxy->setSettings(s.toXSwiftBusJsonStringQt());
|
||||
CLogMessage(this).info(u"Send settings: %1") << s.toQString(true);
|
||||
return true;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
CSimulatorXPlaneConfig::CSimulatorXPlaneConfig(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
// void
|
||||
}
|
||||
|
||||
BlackGui::CPluginConfigWindow *CSimulatorXPlaneConfig::createConfigWindow(QWidget *parent)
|
||||
@@ -25,5 +25,5 @@ namespace BlackSimPlugin
|
||||
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow(parent);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace BlackSimPlugin
|
||||
s.setDBusServerAddressQt(ui->comp_SettingsXSwiftBus->getDBusAddress());
|
||||
s.setMaxDrawDistanceNM(ui->ds_MaxDrawDistanceNM->value());
|
||||
s.setMaxPlanes(ui->sb_MaxAircraft->value());
|
||||
s.setFollowAircraftDistanceM(ui->sb_FollowAircraftDistanceM->value());
|
||||
s.setDrawingLabels(ui->cb_DrawLabels->isChecked());
|
||||
return s;
|
||||
}
|
||||
@@ -73,6 +74,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
ui->comp_SettingsXSwiftBus->set(settings.getDBusServerAddressQt());
|
||||
ui->sb_MaxAircraft->setValue(settings.getMaxPlanes());
|
||||
ui->sb_FollowAircraftDistanceM->setValue(settings.getFollowAircraftDistanceM());
|
||||
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
|
||||
ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>250</width>
|
||||
<height>272</height>
|
||||
<height>298</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -113,20 +113,37 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_Labels">
|
||||
<property name="text">
|
||||
<string>Labels</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="cb_DrawLabels">
|
||||
<property name="text">
|
||||
<string>draw labels</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_FollowAircraftDistance">
|
||||
<property name="text">
|
||||
<string>Follow aircraft distance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="sb_FollowAircraftDistanceM">
|
||||
<property name="suffix">
|
||||
<string>m</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>300</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -143,6 +160,7 @@
|
||||
<tabstops>
|
||||
<tabstop>sb_MaxAircraft</tabstop>
|
||||
<tabstop>ds_MaxDrawDistanceNM</tabstop>
|
||||
<tabstop>sb_FollowAircraftDistanceM</tabstop>
|
||||
<tabstop>cb_DrawLabels</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
||||
Reference in New Issue
Block a user