mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T294, display simulator internals correctly
* view rows not selectable * added settings to ISimulator * ISimulator implements initSimulatorInternals() and sets default values * also display plugin name * XPlane using initSimulatorInternals()
This commit is contained in:
@@ -32,6 +32,7 @@ using namespace BlackMisc;
|
|||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
|
using namespace BlackMisc::Simulation::Settings;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Weather;
|
using namespace BlackMisc::Weather;
|
||||||
@@ -612,6 +613,10 @@ namespace BlackCore
|
|||||||
|
|
||||||
connect(sApp, &CApplication::aboutToShutdown, this, &ISimulator::unload, Qt::QueuedConnection);
|
connect(sApp, &CApplication::aboutToShutdown, this, &ISimulator::unload, Qt::QueuedConnection);
|
||||||
|
|
||||||
|
// info data
|
||||||
|
m_simulatorInternals.setSimulatorName(this->getSimulatorName());
|
||||||
|
m_simulatorInternals.setSwiftPluginName(this->getSimulatorPluginInfo().toQString());
|
||||||
|
|
||||||
// info
|
// info
|
||||||
CLogMessage(this).info("Initialized simulator driver: '%1'") << this->getSimulatorInfo().toQString();
|
CLogMessage(this).info("Initialized simulator driver: '%1'") << this->getSimulatorInfo().toQString();
|
||||||
}
|
}
|
||||||
@@ -724,6 +729,14 @@ namespace BlackCore
|
|||||||
// void, can be overridden in specialized drivers
|
// void, can be overridden in specialized drivers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ISimulator::initSimulatorInternals()
|
||||||
|
{
|
||||||
|
const CSimulatorSettings s = this->getSimulatorSettings();
|
||||||
|
m_simulatorInternals.setSimulatorName(this->getSimulatorName());
|
||||||
|
m_simulatorInternals.setSwiftPluginName(this->getSimulatorPluginInfo().toQString());
|
||||||
|
m_simulatorInternals.setSimulatorInstallationDirectory(s.getSimulatorDirectory());
|
||||||
|
}
|
||||||
|
|
||||||
void ISimulator::rememberElevationAndCG(const CCallsign &callsign, const QString &modelString, const Geo::CElevationPlane &elevation, const CLength &cg)
|
void ISimulator::rememberElevationAndCG(const CCallsign &callsign, const QString &modelString, const Geo::CElevationPlane &elevation, const CLength &cg)
|
||||||
{
|
{
|
||||||
if (callsign.isEmpty()) { return; }
|
if (callsign.isEmpty()) { return; }
|
||||||
|
|||||||
@@ -172,6 +172,9 @@ namespace BlackCore
|
|||||||
//! Reload weather settings
|
//! Reload weather settings
|
||||||
void reloadWeatherSettings();
|
void reloadWeatherSettings();
|
||||||
|
|
||||||
|
//! Settings for current simulator
|
||||||
|
BlackMisc::Simulation::Settings::CSimulatorSettings getSimulatorSettings() const { return m_settings.getSettings(this->getSimulatorInfo()); }
|
||||||
|
|
||||||
//! Driver will be unloaded
|
//! Driver will be unloaded
|
||||||
virtual void unload();
|
virtual void unload();
|
||||||
|
|
||||||
@@ -346,6 +349,9 @@ namespace BlackCore
|
|||||||
virtual void onSwiftDbAirportsRead();
|
virtual void onSwiftDbAirportsRead();
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Init the internals info
|
||||||
|
virtual void initSimulatorInternals();
|
||||||
|
|
||||||
//! Parsed in derived classes
|
//! Parsed in derived classes
|
||||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) = 0;
|
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) = 0;
|
||||||
|
|
||||||
@@ -512,6 +518,9 @@ namespace BlackCore
|
|||||||
BlackMisc::CTokenBucket m_limitUpdateAircraftBucket { 5, 100, 5 }; //!< means 50 per second
|
BlackMisc::CTokenBucket m_limitUpdateAircraftBucket { 5, 100, 5 }; //!< means 50 per second
|
||||||
bool m_limitUpdateAircraft = false; //!< limit the update frequency by using BlackMisc::CTokenBucket
|
bool m_limitUpdateAircraft = false; //!< limit the update frequency by using BlackMisc::CTokenBucket
|
||||||
|
|
||||||
|
// general settings
|
||||||
|
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_settings { this }; //!< simulator settings for all simulators
|
||||||
|
|
||||||
// weather
|
// weather
|
||||||
bool m_isWeatherActivated = false; //!< Is simulator weather activated?
|
bool m_isWeatherActivated = false; //!< Is simulator weather activated?
|
||||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||||
|
|||||||
@@ -73,6 +73,12 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="BlackGui::Views::CNameVariantPairView" name="tvp_Internals">
|
<widget class="BlackGui::Views::CNameVariantPairView" name="tvp_Internals">
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::NoSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
<attribute name="verticalHeaderVisible">
|
<attribute name="verticalHeaderVisible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
void CSimulatorInternals::setValue(const QString &name, const QString &value)
|
void CSimulatorInternals::setValue(const QString &name, const QString &value)
|
||||||
{
|
{
|
||||||
this->m_data.addOrReplaceValue(name, value);
|
m_data.addOrReplaceValue(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVariant CSimulatorInternals::getVariantValue(const QString &name) const
|
CVariant CSimulatorInternals::getVariantValue(const QString &name) const
|
||||||
@@ -57,6 +57,16 @@ namespace BlackMisc
|
|||||||
this->setValue("all/simulatorName", name);
|
this->setValue("all/simulatorName", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CSimulatorInternals::getSimulatorSwiftPluginName() const
|
||||||
|
{
|
||||||
|
return this->getStringValue("all/pluginName");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimulatorInternals::setSwiftPluginName(const QString &name)
|
||||||
|
{
|
||||||
|
this->setValue("all/pluginName", name);
|
||||||
|
}
|
||||||
|
|
||||||
QString CSimulatorInternals::getSimulatorVersion() const
|
QString CSimulatorInternals::getSimulatorVersion() const
|
||||||
{
|
{
|
||||||
return this->getStringValue("all/versionInfo");
|
return this->getStringValue("all/versionInfo");
|
||||||
@@ -82,30 +92,23 @@ namespace BlackMisc
|
|||||||
CVariant CSimulatorInternals::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
CVariant CSimulatorInternals::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { return CVariant::from(*this); }
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexData:
|
case IndexData: return CVariant::from(m_data);
|
||||||
return CVariant::from(m_data);
|
default: return CValueObject::propertyByIndex(index);
|
||||||
default:
|
|
||||||
return CValueObject::propertyByIndex(index);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorInternals::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
void CSimulatorInternals::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { (*this) = variant.to<CSimulatorInternals>(); return; }
|
if (index.isMyself()) { (*this) = variant.to<CSimulatorInternals>(); return; }
|
||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexData:
|
case IndexData: m_data = variant.to<CNameVariantPairList>(); break;
|
||||||
this->m_data = variant.to<CNameVariantPairList>();
|
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CValueObject::setPropertyByIndex(index, variant);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ namespace BlackMisc
|
|||||||
//! Set simulator name
|
//! Set simulator name
|
||||||
void setSimulatorName(const QString &name);
|
void setSimulatorName(const QString &name);
|
||||||
|
|
||||||
|
//! Plugin name
|
||||||
|
QString getSimulatorSwiftPluginName() const;
|
||||||
|
|
||||||
|
//! Set plugin name
|
||||||
|
void setSwiftPluginName(const QString &name);
|
||||||
|
|
||||||
//! Simulator version info, something like "10.3.2"
|
//! Simulator version info, something like "10.3.2"
|
||||||
QString getSimulatorVersion() const;
|
QString getSimulatorVersion() const;
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
m_fsuipc->connect(); // connect FSUIPC too
|
m_fsuipc->connect(); // connect FSUIPC too
|
||||||
}
|
}
|
||||||
initSimulatorInternals();
|
this->initSimulatorInternals();
|
||||||
m_timerId = startTimer(50);
|
m_timerId = startTimer(50);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,17 +45,15 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
void CSimulatorFsCommon::initSimulatorInternals()
|
void CSimulatorFsCommon::initSimulatorInternals()
|
||||||
{
|
{
|
||||||
CSimulatorInternals s;
|
CSimulatorPluginCommon::initSimulatorInternals();
|
||||||
s.setSimulatorName(this->getSimulatorName());
|
m_simulatorInternals.setSimulatorVersion(this->getSimulatorVersion());
|
||||||
s.setSimulatorVersion(this->getSimulatorVersion());
|
m_simulatorInternals.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
|
||||||
s.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
|
|
||||||
if (m_fsuipc)
|
if (m_fsuipc)
|
||||||
{
|
{
|
||||||
const QString v(m_fsuipc->getVersion());
|
const QString v(m_fsuipc->getVersion());
|
||||||
if (!v.isEmpty()) { s.setValue("fscommon/fsuipcversion", v); }
|
if (!v.isEmpty()) { m_simulatorInternals.setValue("fscommon/fsuipcversion", v); }
|
||||||
s.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
|
m_simulatorInternals.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
|
||||||
}
|
}
|
||||||
m_simulatorInternals = s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
|
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace BlackSimPlugin
|
|||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
//! Init the internal objects
|
//! Init the internal objects
|
||||||
virtual void initSimulatorInternals();
|
virtual void initSimulatorInternals() override;
|
||||||
|
|
||||||
//! \name When swift DB data are read
|
//! \name When swift DB data are read
|
||||||
//! @{
|
//! @{
|
||||||
|
|||||||
@@ -370,10 +370,10 @@ namespace BlackSimPlugin
|
|||||||
this->initSimulatorInternals();
|
this->initSimulatorInternals();
|
||||||
this->emitSimulatorCombinedStatus();
|
this->emitSimulatorCombinedStatus();
|
||||||
|
|
||||||
// Internals depends on sim data which take a while to be read
|
// Internals depends on simulator data which take a while to be read
|
||||||
// this is a trick and I re-init again after a while (which is not really expensive)
|
// this is a trick and I re-init again after a while (which is not really expensive)
|
||||||
const QPointer<CSimulatorFsxCommon> myself(this);
|
const QPointer<CSimulatorFsxCommon> myself(this);
|
||||||
QTimer::singleShot(1000, this, [myself]
|
QTimer::singleShot(2500, this, [myself]
|
||||||
{
|
{
|
||||||
if (myself.isNull()) { return; }
|
if (myself.isNull()) { return; }
|
||||||
myself->initSimulatorInternals();
|
myself->initSimulatorInternals();
|
||||||
@@ -1833,13 +1833,8 @@ namespace BlackSimPlugin
|
|||||||
void CSimulatorFsxCommon::initSimulatorInternals()
|
void CSimulatorFsxCommon::initSimulatorInternals()
|
||||||
{
|
{
|
||||||
CSimulatorFsCommon::initSimulatorInternals();
|
CSimulatorFsCommon::initSimulatorInternals();
|
||||||
CSimulatorInternals s = m_simulatorInternals;
|
m_simulatorInternals.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getSwiftLocalSimConnectCfgFilename());
|
||||||
const QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); // can be empty for remote FSX
|
m_simulatorInternals.setValue("fsx/simConnectVersion", m_simConnectVersion);
|
||||||
if (!fsxPath.isEmpty()) { s.setSimulatorInstallationDirectory(fsxPath); }
|
|
||||||
|
|
||||||
s.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getSwiftLocalSimConnectCfgFilename());
|
|
||||||
s.setValue("fsx/simConnectVersion", m_simConnectVersion);
|
|
||||||
m_simulatorInternals = s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorFsxCommon::reset()
|
void CSimulatorFsxCommon::reset()
|
||||||
|
|||||||
@@ -294,6 +294,7 @@ namespace BlackSimPlugin
|
|||||||
m_trafficProxy = new CXSwiftBusTrafficProxy(m_dBusConnection, this);
|
m_trafficProxy = new CXSwiftBusTrafficProxy(m_dBusConnection, this);
|
||||||
m_weatherProxy = new CXSwiftBusWeatherProxy(m_dBusConnection, this);
|
m_weatherProxy = new CXSwiftBusWeatherProxy(m_dBusConnection, this);
|
||||||
|
|
||||||
|
bool ok = false;
|
||||||
if (m_serviceProxy->isValid() && m_trafficProxy->isValid() && m_weatherProxy->isValid() && m_trafficProxy->initialize())
|
if (m_serviceProxy->isValid() && m_trafficProxy->isValid() && m_weatherProxy->isValid() && m_trafficProxy->initialize())
|
||||||
{
|
{
|
||||||
emitOwnAircraftModelChanged(m_serviceProxy->getAircraftModelPath(), m_serviceProxy->getAircraftModelFilename(), m_serviceProxy->getAircraftLivery(),
|
emitOwnAircraftModelChanged(m_serviceProxy->getAircraftModelPath(), m_serviceProxy->getAircraftModelFilename(), m_serviceProxy->getAircraftLivery(),
|
||||||
@@ -308,13 +309,15 @@ namespace BlackSimPlugin
|
|||||||
m_trafficProxy->removeAllPlanes();
|
m_trafficProxy->removeAllPlanes();
|
||||||
this->loadCslPackages();
|
this->loadCslPackages();
|
||||||
this->emitSimulatorCombinedStatus();
|
this->emitSimulatorCombinedStatus();
|
||||||
return true;
|
ok = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->disconnectFrom();
|
this->disconnectFrom();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ok) { this->initSimulatorInternals(); }
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorXPlane::disconnectFrom()
|
bool CSimulatorXPlane::disconnectFrom()
|
||||||
|
|||||||
Reference in New Issue
Block a user