diff --git a/src/blackgui/components/internalscomponent.cpp b/src/blackgui/components/internalscomponent.cpp
index f1969ef39..be6da8bac 100644
--- a/src/blackgui/components/internalscomponent.cpp
+++ b/src/blackgui/components/internalscomponent.cpp
@@ -72,6 +72,7 @@ namespace BlackGui
connect(ui->cb_DebugDriver, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
connect(ui->cb_DebugInterpolator, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
connect(ui->cb_ForceFullInterpolation, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
+ connect(ui->cb_EnableParts, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
connect(ui->pb_SendTextMessage, &QPushButton::pressed, this, &CInternalsComponent::ps_sendTextMessage);
connect(ui->tb_LogStatusMessage, &QPushButton::pressed, this, &CInternalsComponent::ps_logStatusMessage);
@@ -176,17 +177,18 @@ namespace BlackGui
bool debug = (checkState == Qt::Checked);
QObject *sender = QObject::sender();
- if (sender == ui->cb_DebugContextApplication) { sGui->getIContextApplication()->setDebugEnabled(debug); }
- else if (sender == ui->cb_DebugContextAudio) { sGui->getIContextAudio()->setDebugEnabled(debug); }
- else if (sender == ui->cb_DebugContextNetwork) { sGui->getIContextNetwork()->setDebugEnabled(debug);}
- else if (sender == ui->cb_DebugContextOwnAircraft) { sGui->getIContextOwnAircraft()->setDebugEnabled(debug); }
- else if (sender == ui->cb_DebugContextSimulator) { sGui->getIContextSimulator()->setDebugEnabled(debug);}
- else if (sender == ui->cb_DebugDriver || sender == ui->cb_DebugInterpolator || sender == ui->cb_ForceFullInterpolation)
+ if (sender == ui->cb_DebugContextApplication) { sGui->getIContextApplication()->setDebugEnabled(debug); }
+ else if (sender == ui->cb_DebugContextAudio) { sGui->getIContextAudio()->setDebugEnabled(debug); }
+ else if (sender == ui->cb_DebugContextNetwork) { sGui->getIContextNetwork()->setDebugEnabled(debug);}
+ else if (sender == ui->cb_DebugContextOwnAircraft) { sGui->getIContextOwnAircraft()->setDebugEnabled(debug); }
+ else if (sender == ui->cb_DebugContextSimulator) { sGui->getIContextSimulator()->setDebugEnabled(debug);}
+ else if (sender == ui->cb_DebugDriver || sender == ui->cb_EnableParts || sender == ui->cb_DebugInterpolator || sender == ui->cb_ForceFullInterpolation)
{
CInterpolationAndRenderingSetup setup;
setup.setForceFullInterpolation(ui->cb_ForceFullInterpolation->isChecked());
setup.setDriverDebuggingMessages(ui->cb_DebugDriver->isChecked());
setup.setInterpolatorDebuggingMessages(ui->cb_DebugInterpolator->isChecked());
+ setup.setEnabledAircraftParts(ui->cb_EnableParts->isChecked());
sGui->getIContextSimulator()->setInterpolationAndRenderingSetup(setup);
}
}
diff --git a/src/blackgui/components/internalscomponent.ui b/src/blackgui/components/internalscomponent.ui
index 1a08cbcb4..713e6b696 100644
--- a/src/blackgui/components/internalscomponent.ui
+++ b/src/blackgui/components/internalscomponent.ui
@@ -104,7 +104,7 @@
-
- Driver dbg. msgs.
+ driver dbg. msgs.
@@ -115,10 +115,20 @@
- -
+
-
- force full interpolation
+ force full interpol.
+
+
+
+ -
+
+
+ enable parts
+
+
+ true
diff --git a/src/blackmisc/interpolationrenderingsetup.cpp b/src/blackmisc/interpolationrenderingsetup.cpp
index 883540f54..31b48cdfe 100644
--- a/src/blackmisc/interpolationrenderingsetup.cpp
+++ b/src/blackmisc/interpolationrenderingsetup.cpp
@@ -34,6 +34,11 @@ namespace BlackMisc
return isRenderingEnabled() && (isMaxAircraftRestricted() || isMaxDistanceRestricted());
}
+ bool CInterpolationAndRenderingSetup::isAircraftPartsEnabled() const
+ {
+ return this->m_enabledAircraftParts;
+ }
+
int CInterpolationAndRenderingSetup::getMaxRenderedAircraft() const
{
return (m_maxRenderedAircraft <= InfiniteAircraft()) ? m_maxRenderedAircraft : InfiniteAircraft();
@@ -79,6 +84,13 @@ namespace BlackMisc
return true;
}
+ bool CInterpolationAndRenderingSetup::setEnabledAircraftParts(bool enabled)
+ {
+ if (this->m_enabledAircraftParts == enabled) { return false; }
+ m_enabledAircraftParts = enabled;
+ return true;
+ }
+
void CInterpolationAndRenderingSetup::clearMaxRenderedDistance()
{
this->setMaxRenderedDistance(CLength(0.0, CLengthUnit::nullUnit()));
@@ -154,6 +166,8 @@ namespace BlackMisc
return CVariant::fromValue(m_maxRenderedAircraft);
case IndexMaxRenderedDistance:
return CVariant::fromValue(m_maxRenderedDistance);
+ case IndexEnabledAircraftParts:
+ return CVariant::fromValue(m_enabledAircraftParts);
default:
return CValueObject::propertyByIndex(index);
}
@@ -184,6 +198,9 @@ namespace BlackMisc
case IndexMaxRenderedDistance:
this->m_maxRenderedDistance = variant.value();
break;
+ case IndexEnabledAircraftParts:
+ this->m_enabledAircraftParts = variant.toBool();
+ break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
diff --git a/src/blackmisc/interpolationrenderingsetup.h b/src/blackmisc/interpolationrenderingsetup.h
index c738ee8d8..8558de6de 100644
--- a/src/blackmisc/interpolationrenderingsetup.h
+++ b/src/blackmisc/interpolationrenderingsetup.h
@@ -34,7 +34,8 @@ namespace BlackMisc
IndexSimulatorDebugMessages,
IndexForceFullInterpolation,
IndexMaxRenderedAircraft,
- IndexMaxRenderedDistance
+ IndexMaxRenderedDistance,
+ IndexEnabledAircraftParts
};
//! Constructor.
@@ -70,6 +71,9 @@ namespace BlackMisc
//! Max. distance for rendering
bool setMaxRenderedDistance(const BlackMisc::PhysicalQuantities::CLength &distance);
+ //! Set enabled aircraft parts
+ bool setEnabledAircraftParts(bool enabled);
+
//! Disable
void clearMaxRenderedDistance();
@@ -79,6 +83,9 @@ namespace BlackMisc
//! Rendering enabled, but restricted
bool isRenderingRestricted() const;
+ //! Aircraft parts enabled
+ bool isAircraftPartsEnabled() const;
+
//! Max.distance for rendering
BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const { return m_maxRenderedDistance; }
@@ -107,9 +114,10 @@ namespace BlackMisc
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
private:
- bool m_interpolatorDebugMessage = false; //! Debug messages in interpolator
- bool m_simulatorDebugMessages = false; //! Debug messages of simulator (aka plugin)
- bool m_forceFullInterpolation = false; //! always do a full interpolation, even if aircraft is not moving
+ bool m_interpolatorDebugMessage = false; //! Debug messages in interpolator
+ bool m_simulatorDebugMessages = false; //! Debug messages of simulator (aka plugin)
+ bool m_forceFullInterpolation = false; //! always do a full interpolation, even if aircraft is not moving
+ bool m_enabledAircraftParts = true; //! Update aircraft parts
int m_maxRenderedAircraft = InfiniteAircraft(); //!< max.rendered aircraft
BlackMisc::PhysicalQuantities::CLength m_maxRenderedDistance { 0.0, BlackMisc::PhysicalQuantities::CLengthUnit::nullUnit()}; //!< max.distance for rendering
@@ -118,6 +126,7 @@ namespace BlackMisc
BLACK_METAMEMBER(interpolatorDebugMessage),
BLACK_METAMEMBER(simulatorDebugMessages),
BLACK_METAMEMBER(forceFullInterpolation),
+ BLACK_METAMEMBER(enabledAircraftParts),
BLACK_METAMEMBER(maxRenderedAircraft),
BLACK_METAMEMBER(maxRenderedDistance)
);
diff --git a/src/plugins/simulator/fsx/simconnectdatadefinition.cpp b/src/plugins/simulator/fsx/simconnectdatadefinition.cpp
index a52da8b2a..3a7384040 100644
--- a/src/plugins/simulator/fsx/simconnectdatadefinition.cpp
+++ b/src/plugins/simulator/fsx/simconnectdatadefinition.cpp
@@ -74,6 +74,9 @@ namespace BlackSimPlugin
// Position
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPosition, "Initial Position", NULL, SIMCONNECT_DATATYPE_INITPOSITION);
+ // Hint: "Bool" and "Percent .." are units name
+ // default data type is SIMCONNECT_DATATYPE_FLOAT64 -> double
+
// Lights
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts, "LIGHT STROBE", "Bool");
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts, "LIGHT LANDING", "Bool");
diff --git a/src/plugins/simulator/fsx/simulatorfsx.cpp b/src/plugins/simulator/fsx/simulatorfsx.cpp
index 5c209dc55..0d3c5d08a 100644
--- a/src/plugins/simulator/fsx/simulatorfsx.cpp
+++ b/src/plugins/simulator/fsx/simulatorfsx.cpp
@@ -93,7 +93,7 @@ namespace BlackSimPlugin
// set structures and move on
initEvents();
initDataDefinitionsWhenConnected();
- m_simconnectTimerId = startTimer(10);
+ m_simConnectTimerId = startTimer(10);
m_realityBubbleTimer.start();
reloadWeatherSettings();
return true;
@@ -102,8 +102,8 @@ namespace BlackSimPlugin
bool CSimulatorFsx::disconnectFrom()
{
if (!m_simConnected) { return true; }
- if (m_simconnectTimerId >= 0) { killTimer(m_simconnectTimerId); }
- m_simconnectTimerId = -1;
+ if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
+ m_simConnectTimerId = -1;
if (m_hSimConnect)
{
SimConnect_Close(m_hSimConnect);
@@ -803,8 +803,9 @@ namespace BlackSimPlugin
const int remoteAircraftNo = this->getAircraftInRangeCount();
if (remoteAircraftNo < 1) { m_interpolationRequest = 0; return; }
- // interpolate and send to SIM
+ // interpolate and send to simulator
m_interpolationRequest++;
+ const bool enableAircraftParts = m_interpolationRenderingSetup.isAircraftPartsEnabled(); // allow to disable all parts updates for testing
// values used for position and parts
bool isOnGround = false;
@@ -814,7 +815,7 @@ namespace BlackSimPlugin
const QList simObjects(m_simConnectObjects.values());
for (const CSimConnectObject &simObj : simObjects)
{
- // happending if aircraft is not yet added to SIM or to be deleted
+ // happening if aircraft is not yet added to simulator or to be deleted
if (simObj.isPendingAdded()) { continue; }
if (simObj.isPendingRemoved()) { continue; }
@@ -828,9 +829,9 @@ namespace BlackSimPlugin
// having the onGround flag in parts forces me to obtain parts here
// which is not the smartest thing regarding performance
IInterpolator::PartsStatus partsStatus;
- partsStatus.setSupportsParts(aircraftWithParts.contains(callsign));
+ partsStatus.setSupportsParts(enableAircraftParts && aircraftWithParts.contains(callsign));
CAircraftPartsList parts;
- if (partsStatus.allTrue())
+ if (enableAircraftParts && partsStatus.allTrue())
{
parts = this->m_interpolator->getPartsBeforeTime(callsign, currentTimestamp, partsStatus);
}
@@ -841,7 +842,7 @@ namespace BlackSimPlugin
SIMCONNECT_DATA_INITPOSITION position = aircraftSituationToFsxPosition(interpolatedSituation);
//! \fixme The onGround in parts is no ideal, as already mentioned in the discussion
- // a) I am forced to read parts even if i just want to update position
+ // a) I am forced to read parts even if I just want to update position
// b) Unlike the other values it is not a fire and forget value, as I need it again in the next cycle
if (partsStatus.isSupportingParts() && !parts.isEmpty())
{
@@ -867,9 +868,12 @@ namespace BlackSimPlugin
if (interpolatorStatus.didInterpolationSucceed())
{
- // aircraft parts
- // inside "interpolator if", as no parts can be sent without position
- updateRemoteAircraftParts(simObj, parts, partsStatus, interpolatedSituation, isOnGround); // update and retrieve parts in the same step
+ // aircraft parts inside "interpolator if", as no parts can be set without situation
+ // situation is used to anticipate parts if other client does not send them
+ if (enableAircraftParts)
+ {
+ updateRemoteAircraftParts(simObj, parts, partsStatus, interpolatedSituation, isOnGround); // update and retrieve parts in the same step
+ }
}
} // all callsigns
@@ -892,17 +896,17 @@ namespace BlackSimPlugin
// we have parts
CAircraftParts newestParts = parts.front();
- ddRemoteAircraftParts.lightStrobe = newestParts.getLights().isStrobeOn() ? 1.0 : 0.0;
- ddRemoteAircraftParts.lightLanding = newestParts.getLights().isLandingOn() ? 1.0 : 0.0;
- // ddRemoteAircraftParts.lightTaxi = newestParts.getLights().isTaxiOn() ? 1.0 : 0.0;
- ddRemoteAircraftParts.lightBeacon = newestParts.getLights().isBeaconOn() ? 1.0 : 0.0;
- ddRemoteAircraftParts.lightNav = newestParts.getLights().isNavOn() ? 1.0 : 0.0;
- ddRemoteAircraftParts.lightLogo = newestParts.getLights().isLogoOn() ? 1.0 : 0.0;
+ ddRemoteAircraftParts.lightStrobe = newestParts.getLights().isStrobeOn() ? 1 : 0;
+ ddRemoteAircraftParts.lightLanding = newestParts.getLights().isLandingOn() ? 1 : 0;
+ // ddRemoteAircraftParts.lightTaxi = newestParts.getLights().isTaxiOn() ? 1 : 0;
+ ddRemoteAircraftParts.lightBeacon = newestParts.getLights().isBeaconOn() ? 1 : 0;
+ ddRemoteAircraftParts.lightNav = newestParts.getLights().isNavOn() ? 1 : 0;
+ ddRemoteAircraftParts.lightLogo = newestParts.getLights().isLogoOn() ? 1 : 0;
ddRemoteAircraftParts.flapsLeadingEdgeLeftPercent = newestParts.getFlapsPercent() / 100.0;
ddRemoteAircraftParts.flapsLeadingEdgeRightPercent = newestParts.getFlapsPercent() / 100.0;
ddRemoteAircraftParts.flapsTrailingEdgeLeftPercent = newestParts.getFlapsPercent() / 100.0;
ddRemoteAircraftParts.flapsTrailingEdgeRightPercent = newestParts.getFlapsPercent() / 100.0;
- ddRemoteAircraftParts.spoilersHandlePosition = newestParts.isSpoilersOut() ? 1.0 : 0.0;
+ ddRemoteAircraftParts.spoilersHandlePosition = newestParts.isSpoilersOut() ? 1 : 0;
ddRemoteAircraftParts.gearHandlePosition = newestParts.isGearDown() ? 1 : 0;
ddRemoteAircraftParts.engine1Combustion = newestParts.isEngineOn(1) ? 1 : 0;
ddRemoteAircraftParts.engine2Combustion = newestParts.isEngineOn(2) ? 1 : 0;
@@ -912,43 +916,43 @@ namespace BlackSimPlugin
else
{
// mode is guessing parts
- if (this->m_interpolationRequest % 20 != 0) { return false; } // only update every 20th cycle
+ // if (this->m_interpolationRequest % 20 != 0) { return false; } // only update every 20th cycle
ddRemoteAircraftParts.gearHandlePosition = isOnGround ? 1 : 0;
// when first detected moving, lights on
if (isOnGround)
{
- // ddRemoteAircraftParts.lightTaxi = 1.0;
- ddRemoteAircraftParts.lightBeacon = 1.0;
- ddRemoteAircraftParts.lightNav = 1.0;
+ // ddRemoteAircraftParts.lightTaxi = 1;
+ ddRemoteAircraftParts.lightBeacon = 1;
+ ddRemoteAircraftParts.lightNav = 1;
double gskmh = interpolatedSituation.getGroundSpeed().value(CSpeedUnit::km_h());
if (gskmh > 7.5)
{
// mode taxi
- // ddRemoteAircraftParts.lightTaxi = 1.0;
- ddRemoteAircraftParts.lightLanding = 0.0;
+ // ddRemoteAircraftParts.lightTaxi = 1;
+ ddRemoteAircraftParts.lightLanding = 0;
}
else if (gskmh > 25)
{
// mode accelaration for takeoff
- // ddRemoteAircraftParts.lightTaxi = 0.0;
- ddRemoteAircraftParts.lightLanding = 1.0;
+ // ddRemoteAircraftParts.lightTaxi = 0;
+ ddRemoteAircraftParts.lightLanding = 1;
}
else
{
// slow movements or parking
- // ddRemoteAircraftParts.lightTaxi = 0.0;
- ddRemoteAircraftParts.lightLanding = 0.0;
+ // ddRemoteAircraftParts.lightTaxi = 0;
+ ddRemoteAircraftParts.lightLanding = 0;
}
}
else
{
- // ddRemoteAircraftParts.lightTaxi = 0.0;
- ddRemoteAircraftParts.lightBeacon = 1.0;
- ddRemoteAircraftParts.lightNav = 1.0;
+ // ddRemoteAircraftParts.lightTaxi = 0;
+ ddRemoteAircraftParts.lightBeacon = 1;
+ ddRemoteAircraftParts.lightNav = 1;
// landing lights for < 10000ft (normally MSL, here ignored)
- ddRemoteAircraftParts.lightLanding = (interpolatedSituation.getAltitude().value(CLengthUnit::ft()) < 10000) ? 1.0 : 0;
+ ddRemoteAircraftParts.lightLanding = (interpolatedSituation.getAltitude().value(CLengthUnit::ft()) < 10000) ? 1 : 0;
}
}
@@ -1052,14 +1056,13 @@ namespace BlackSimPlugin
void CSimulatorFsx::reset()
{
- if (m_simconnectTimerId >= 0) { killTimer(m_simconnectTimerId); }
- m_simconnectTimerId = -1;
+ if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
+ m_simConnectTimerId = -1;
m_simConnected = false;
m_simSimulating = false;
m_syncDeferredCounter = 0;
m_skipCockpitUpdateCycles = 0;
m_interpolationRequest = 0;
- m_interpolationsSkipped = 0;
m_requestId = 1;
m_dispatchErrors = 0;
m_receiveExceptionCount = 0;
diff --git a/src/plugins/simulator/fsx/simulatorfsx.h b/src/plugins/simulator/fsx/simulatorfsx.h
index 266ada2d0..44e82ebda 100644
--- a/src/plugins/simulator/fsx/simulatorfsx.h
+++ b/src/plugins/simulator/fsx/simulatorfsx.h
@@ -212,14 +212,13 @@ namespace BlackSimPlugin
bool m_simSimulating = false; //!< Simulator running?
bool m_useSbOffsets = true; //!< with SB offsets
int m_syncDeferredCounter = 0; //!< Set when synchronized, used to wait some time
- int m_simconnectTimerId = -1; //!< Timer identifier
+ int m_simConnectTimerId = -1; //!< Timer identifier
int m_skipCockpitUpdateCycles = 0; //!< Skip some update cycles to allow changes in simulator cockpit to be set
int m_interpolationRequest = 0; //!< current interpolation request
- int m_interpolationsSkipped = 0; //!< number of skipped interpolation request
int m_dispatchErrors = 0; //!< number of dispatched failed, \sa ps_dispatch
int m_receiveExceptionCount = 0; //!< exceptions
DWORD m_requestId = 1; //!< request id
- HANDLE m_hSimConnect = nullptr; //!< Handle to SimConnect object
+ HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object
CSimConnectObjects m_simConnectObjects; //!< AI objects and their object / request ids
BlackMisc::Simulation::CSimulatedAircraftList m_outOfRealityBubble; //!< aircraft removed by FSX because they are out of reality bubble
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last