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:
Klaus Basan
2018-07-28 00:19:06 +02:00
parent a05d11fff0
commit fbfbdedb65
10 changed files with 67 additions and 34 deletions

View File

@@ -32,6 +32,7 @@ using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Simulation::Settings;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Network;
using namespace BlackMisc::Weather;
@@ -612,6 +613,10 @@ namespace BlackCore
connect(sApp, &CApplication::aboutToShutdown, this, &ISimulator::unload, Qt::QueuedConnection);
// info data
m_simulatorInternals.setSimulatorName(this->getSimulatorName());
m_simulatorInternals.setSwiftPluginName(this->getSimulatorPluginInfo().toQString());
// info
CLogMessage(this).info("Initialized simulator driver: '%1'") << this->getSimulatorInfo().toQString();
}
@@ -724,6 +729,14 @@ namespace BlackCore
// 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)
{
if (callsign.isEmpty()) { return; }

View File

@@ -172,6 +172,9 @@ namespace BlackCore
//! Reload weather settings
void reloadWeatherSettings();
//! Settings for current simulator
BlackMisc::Simulation::Settings::CSimulatorSettings getSimulatorSettings() const { return m_settings.getSettings(this->getSimulatorInfo()); }
//! Driver will be unloaded
virtual void unload();
@@ -346,6 +349,9 @@ namespace BlackCore
virtual void onSwiftDbAirportsRead();
//! @}
//! Init the internals info
virtual void initSimulatorInternals();
//! Parsed in derived classes
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
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
bool m_isWeatherActivated = false; //!< Is simulator weather activated?
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last

View File

@@ -73,6 +73,12 @@
</property>
<item>
<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">
<bool>false</bool>
</attribute>

View File

@@ -19,7 +19,7 @@ namespace BlackMisc
{
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
@@ -57,6 +57,16 @@ namespace BlackMisc
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
{
return this->getStringValue("all/versionInfo");
@@ -82,30 +92,23 @@ namespace BlackMisc
CVariant CSimulatorInternals::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexData:
return CVariant::from(m_data);
default:
return CValueObject::propertyByIndex(index);
case IndexData: return CVariant::from(m_data);
default: return CValueObject::propertyByIndex(index);
}
}
void CSimulatorInternals::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
{
if (index.isMyself()) { (*this) = variant.to<CSimulatorInternals>(); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexData:
this->m_data = variant.to<CNameVariantPairList>();
break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
case IndexData: m_data = variant.to<CNameVariantPairList>(); break;
default: CValueObject::setPropertyByIndex(index, variant); break;
}
}
} // ns
} // ns

View File

@@ -68,6 +68,12 @@ namespace BlackMisc
//! Set simulator 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"
QString getSimulatorVersion() const;

View File

@@ -142,7 +142,7 @@ namespace BlackSimPlugin
{
m_fsuipc->connect(); // connect FSUIPC too
}
initSimulatorInternals();
this->initSimulatorInternals();
m_timerId = startTimer(50);
return true;
}

View File

@@ -45,17 +45,15 @@ namespace BlackSimPlugin
void CSimulatorFsCommon::initSimulatorInternals()
{
CSimulatorInternals s;
s.setSimulatorName(this->getSimulatorName());
s.setSimulatorVersion(this->getSimulatorVersion());
s.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
CSimulatorPluginCommon::initSimulatorInternals();
m_simulatorInternals.setSimulatorVersion(this->getSimulatorVersion());
m_simulatorInternals.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
if (m_fsuipc)
{
const QString v(m_fsuipc->getVersion());
if (!v.isEmpty()) { s.setValue("fscommon/fsuipcversion", v); }
s.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
if (!v.isEmpty()) { m_simulatorInternals.setValue("fscommon/fsuipcversion", v); }
m_simulatorInternals.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
}
m_simulatorInternals = s;
}
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)

View File

@@ -56,7 +56,7 @@ namespace BlackSimPlugin
QObject *parent = nullptr);
//! Init the internal objects
virtual void initSimulatorInternals();
virtual void initSimulatorInternals() override;
//! \name When swift DB data are read
//! @{

View File

@@ -370,10 +370,10 @@ namespace BlackSimPlugin
this->initSimulatorInternals();
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)
const QPointer<CSimulatorFsxCommon> myself(this);
QTimer::singleShot(1000, this, [myself]
QTimer::singleShot(2500, this, [myself]
{
if (myself.isNull()) { return; }
myself->initSimulatorInternals();
@@ -1833,13 +1833,8 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::initSimulatorInternals()
{
CSimulatorFsCommon::initSimulatorInternals();
CSimulatorInternals s = m_simulatorInternals;
const QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); // can be empty for remote FSX
if (!fsxPath.isEmpty()) { s.setSimulatorInstallationDirectory(fsxPath); }
s.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getSwiftLocalSimConnectCfgFilename());
s.setValue("fsx/simConnectVersion", m_simConnectVersion);
m_simulatorInternals = s;
m_simulatorInternals.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getSwiftLocalSimConnectCfgFilename());
m_simulatorInternals.setValue("fsx/simConnectVersion", m_simConnectVersion);
}
void CSimulatorFsxCommon::reset()

View File

@@ -294,6 +294,7 @@ namespace BlackSimPlugin
m_trafficProxy = new CXSwiftBusTrafficProxy(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())
{
emitOwnAircraftModelChanged(m_serviceProxy->getAircraftModelPath(), m_serviceProxy->getAircraftModelFilename(), m_serviceProxy->getAircraftLivery(),
@@ -308,13 +309,15 @@ namespace BlackSimPlugin
m_trafficProxy->removeAllPlanes();
this->loadCslPackages();
this->emitSimulatorCombinedStatus();
return true;
ok = true;
}
else
{
this->disconnectFrom();
return false;
}
if (ok) { this->initSimulatorInternals(); }
return ok;
}
bool CSimulatorXPlane::disconnectFrom()