mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 06:35:41 +08:00
refs #895, renamed data structure to DataDefinitionRemoteAircraftPartsWithoutLights
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a737b27ce8
commit
4a0ddfb5d1
@@ -184,7 +184,7 @@ namespace BlackSimPlugin
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataDefinitionRemoteAircraftParts::operator==(const DataDefinitionRemoteAircraftParts &rhs) const
|
bool DataDefinitionRemoteAircraftPartsWithoutLights::operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const
|
||||||
{
|
{
|
||||||
return std::tie(flapsLeadingEdgeLeftPercent, flapsLeadingEdgeRightPercent, flapsTrailingEdgeLeftPercent, flapsTrailingEdgeRightPercent,
|
return std::tie(flapsLeadingEdgeLeftPercent, flapsLeadingEdgeRightPercent, flapsTrailingEdgeLeftPercent, flapsTrailingEdgeRightPercent,
|
||||||
gearHandlePosition, spoilersHandlePosition,
|
gearHandlePosition, spoilersHandlePosition,
|
||||||
@@ -194,7 +194,7 @@ namespace BlackSimPlugin
|
|||||||
rhs.engine1Combustion, rhs.engine2Combustion, rhs.engine3Combustion, rhs.engine4Combustion);
|
rhs.engine1Combustion, rhs.engine2Combustion, rhs.engine3Combustion, rhs.engine4Combustion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataDefinitionRemoteAircraftParts::setAllEngines(bool on)
|
void DataDefinitionRemoteAircraftPartsWithoutLights::setAllEngines(bool on)
|
||||||
{
|
{
|
||||||
engine1Combustion = on ? 1 : 0;
|
engine1Combustion = on ? 1 : 0;
|
||||||
engine2Combustion = on ? 1 : 0;
|
engine2Combustion = on ? 1 : 0;
|
||||||
@@ -202,7 +202,7 @@ namespace BlackSimPlugin
|
|||||||
engine4Combustion = on ? 1 : 0;
|
engine4Combustion = on ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataDefinitionRemoteAircraftParts::resetAllFlaps()
|
void DataDefinitionRemoteAircraftPartsWithoutLights::resetAllFlaps()
|
||||||
{
|
{
|
||||||
flapsLeadingEdgeLeftPercent = 0;
|
flapsLeadingEdgeLeftPercent = 0;
|
||||||
flapsLeadingEdgeRightPercent = 0;
|
flapsLeadingEdgeRightPercent = 0;
|
||||||
@@ -210,7 +210,7 @@ namespace BlackSimPlugin
|
|||||||
flapsTrailingEdgeRightPercent = 0;
|
flapsTrailingEdgeRightPercent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataDefinitionRemoteAircraftParts::resetSpoilers()
|
void DataDefinitionRemoteAircraftPartsWithoutLights::resetSpoilers()
|
||||||
{
|
{
|
||||||
spoilersHandlePosition = 0;
|
spoilersHandlePosition = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace BlackSimPlugin
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Data struct of remote aircraft parts
|
//! Data struct of remote aircraft parts
|
||||||
struct DataDefinitionRemoteAircraftParts
|
struct DataDefinitionRemoteAircraftPartsWithoutLights
|
||||||
{
|
{
|
||||||
double flapsLeadingEdgeLeftPercent; //!< Leading edge left in percent
|
double flapsLeadingEdgeLeftPercent; //!< Leading edge left in percent
|
||||||
double flapsLeadingEdgeRightPercent; //!< Leading edge right in percent
|
double flapsLeadingEdgeRightPercent; //!< Leading edge right in percent
|
||||||
@@ -89,7 +89,7 @@ namespace BlackSimPlugin
|
|||||||
double engine4Combustion; //!< Engine 4 combustion flag
|
double engine4Combustion; //!< Engine 4 combustion flag
|
||||||
|
|
||||||
//! Equal to other parts
|
//! Equal to other parts
|
||||||
bool operator==(const DataDefinitionRemoteAircraftParts &rhs) const;
|
bool operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const;
|
||||||
|
|
||||||
//! All engines on/off
|
//! All engines on/off
|
||||||
void setAllEngines(bool on);
|
void setAllEngines(bool on);
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ namespace BlackSimPlugin
|
|||||||
void setCurrentLightsInSimulator(const BlackMisc::Aviation::CAircraftLights &lights) { m_currentLightsInSim = lights; }
|
void setCurrentLightsInSimulator(const BlackMisc::Aviation::CAircraftLights &lights) { m_currentLightsInSim = lights; }
|
||||||
|
|
||||||
//! Parts as sent to simulator
|
//! Parts as sent to simulator
|
||||||
const DataDefinitionRemoteAircraftParts &getPartsAsSent() const { return m_partsAsSent; }
|
const DataDefinitionRemoteAircraftPartsWithoutLights &getPartsAsSent() const { return m_partsAsSent; }
|
||||||
|
|
||||||
//! Parts as sent to simulator
|
//! Parts as sent to simulator
|
||||||
void setPartsAsSent(const DataDefinitionRemoteAircraftParts &parts) { m_partsAsSent = parts; }
|
void setPartsAsSent(const DataDefinitionRemoteAircraftPartsWithoutLights &parts) { m_partsAsSent = parts; }
|
||||||
|
|
||||||
//! Lights as sent to simulator
|
//! Lights as sent to simulator
|
||||||
const BlackMisc::Aviation::CAircraftLights &getLightsAsSent() const { return m_lightsAsSent; }
|
const BlackMisc::Aviation::CAircraftLights &getLightsAsSent() const { return m_lightsAsSent; }
|
||||||
@@ -128,7 +128,7 @@ namespace BlackSimPlugin
|
|||||||
bool m_confirmedAdded = false;
|
bool m_confirmedAdded = false;
|
||||||
bool m_pendingRemoved = false;
|
bool m_pendingRemoved = false;
|
||||||
int m_lightsRequestedAt = -1;
|
int m_lightsRequestedAt = -1;
|
||||||
DataDefinitionRemoteAircraftParts m_partsAsSent {}; //!< parts as sent
|
DataDefinitionRemoteAircraftPartsWithoutLights m_partsAsSent {}; //!< parts as sent
|
||||||
BlackMisc::Aviation::CAircraftLights m_currentLightsInSim { nullptr }; //!< current lights to know state for toggling
|
BlackMisc::Aviation::CAircraftLights m_currentLightsInSim { nullptr }; //!< current lights to know state for toggling
|
||||||
BlackMisc::Aviation::CAircraftLights m_lightsAsSent { nullptr }; //!< lights as sent to simulator
|
BlackMisc::Aviation::CAircraftLights m_lightsAsSent { nullptr }; //!< lights as sent to simulator
|
||||||
SIMCONNECT_PERIOD m_requestSimDataPeriod = SIMCONNECT_PERIOD_NEVER; //!< how often do we query ground elevation
|
SIMCONNECT_PERIOD m_requestSimDataPeriod = SIMCONNECT_PERIOD_NEVER; //!< how often do we query ground elevation
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ namespace BlackSimPlugin
|
|||||||
namespace FsxCommon
|
namespace FsxCommon
|
||||||
{
|
{
|
||||||
CSimulatorFsxCommon::CSimulatorFsxCommon(const CSimulatorPluginInfo &info,
|
CSimulatorFsxCommon::CSimulatorFsxCommon(const CSimulatorPluginInfo &info,
|
||||||
IOwnAircraftProvider *ownAircraftProvider,
|
IOwnAircraftProvider *ownAircraftProvider,
|
||||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||||
IWeatherGridProvider *weatherGridProvider,
|
IWeatherGridProvider *weatherGridProvider,
|
||||||
QObject *parent) :
|
QObject *parent) :
|
||||||
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
|
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(ownAircraftProvider, Q_FUNC_INFO, "Missing provider");
|
Q_ASSERT_X(ownAircraftProvider, Q_FUNC_INFO, "Missing provider");
|
||||||
@@ -868,7 +868,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
void CSimulatorFsxCommon::updateRemoteAircraft()
|
void CSimulatorFsxCommon::updateRemoteAircraft()
|
||||||
{
|
{
|
||||||
static_assert(sizeof(DataDefinitionRemoteAircraftParts) == sizeof(double) * 10, "DataDefinitionRemoteAircraftParts has an incorrect size.");
|
static_assert(sizeof(DataDefinitionRemoteAircraftPartsWithoutLights) == sizeof(double) * 10, "DataDefinitionRemoteAircraftParts has an incorrect size.");
|
||||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
|
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
|
||||||
|
|
||||||
// nothing to do, reset request id and exit
|
// nothing to do, reset request id and exit
|
||||||
@@ -953,17 +953,17 @@ namespace BlackSimPlugin
|
|||||||
if (!interpolationStatus.didInterpolationSucceed()) { return false; }
|
if (!interpolationStatus.didInterpolationSucceed()) { return false; }
|
||||||
|
|
||||||
CAircraftLights lights;
|
CAircraftLights lights;
|
||||||
DataDefinitionRemoteAircraftParts ddRemoteAircraftParts = {}; // init members
|
DataDefinitionRemoteAircraftPartsWithoutLights ddRemoteAircraftPartsWintoutLights = {}; // init members
|
||||||
const bool isOnGround = interpolatedSituation.isOnGround() == CAircraftSituation::OnGround;
|
const bool isOnGround = interpolatedSituation.isOnGround() == CAircraftSituation::OnGround;
|
||||||
const double gsKts = interpolatedSituation.getGroundSpeed().value(CSpeedUnit::kts());
|
const double gsKts = interpolatedSituation.getGroundSpeed().value(CSpeedUnit::kts());
|
||||||
ddRemoteAircraftParts.setAllEngines(true);
|
ddRemoteAircraftPartsWintoutLights.setAllEngines(true);
|
||||||
lights.setCabinOn(true);
|
lights.setCabinOn(true);
|
||||||
lights.setRecognitionOn(true);
|
lights.setRecognitionOn(true);
|
||||||
|
|
||||||
// when first detected moving, lights on
|
// when first detected moving, lights on
|
||||||
if (isOnGround)
|
if (isOnGround)
|
||||||
{
|
{
|
||||||
ddRemoteAircraftParts.gearHandlePosition = 1;
|
ddRemoteAircraftPartsWintoutLights.gearHandlePosition = 1;
|
||||||
lights.setTaxiOn(true);
|
lights.setTaxiOn(true);
|
||||||
lights.setBeaconOn(true);
|
lights.setBeaconOn(true);
|
||||||
lights.setNavOn(true);
|
lights.setNavOn(true);
|
||||||
@@ -985,13 +985,13 @@ namespace BlackSimPlugin
|
|||||||
// slow movements or parking
|
// slow movements or parking
|
||||||
lights.setTaxiOn(false);
|
lights.setTaxiOn(false);
|
||||||
lights.setLandingOn(false);
|
lights.setLandingOn(false);
|
||||||
ddRemoteAircraftParts.setAllEngines(false);
|
ddRemoteAircraftPartsWintoutLights.setAllEngines(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// not on ground
|
// not on ground
|
||||||
ddRemoteAircraftParts.gearHandlePosition = 0;
|
ddRemoteAircraftPartsWintoutLights.gearHandlePosition = 0;
|
||||||
lights.setTaxiOn(false);
|
lights.setTaxiOn(false);
|
||||||
lights.setBeaconOn(true);
|
lights.setBeaconOn(true);
|
||||||
lights.setNavOn(true);
|
lights.setNavOn(true);
|
||||||
@@ -1002,20 +1002,20 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
if (interpolatedSituation.getHeightAboveGround().value(CLengthUnit::ft()) < 1000)
|
if (interpolatedSituation.getHeightAboveGround().value(CLengthUnit::ft()) < 1000)
|
||||||
{
|
{
|
||||||
ddRemoteAircraftParts.gearHandlePosition = 1;
|
ddRemoteAircraftPartsWintoutLights.gearHandlePosition = 1;
|
||||||
ddRemoteAircraftParts.flapsTrailingEdgeRightPercent = 25;
|
ddRemoteAircraftPartsWintoutLights.flapsTrailingEdgeRightPercent = 25;
|
||||||
ddRemoteAircraftParts.flapsTrailingEdgeLeftPercent = 25;
|
ddRemoteAircraftPartsWintoutLights.flapsTrailingEdgeLeftPercent = 25;
|
||||||
}
|
}
|
||||||
else if (interpolatedSituation.getHeightAboveGround().value(CLengthUnit::ft()) < 2000)
|
else if (interpolatedSituation.getHeightAboveGround().value(CLengthUnit::ft()) < 2000)
|
||||||
{
|
{
|
||||||
ddRemoteAircraftParts.gearHandlePosition = 1;
|
ddRemoteAircraftPartsWintoutLights.gearHandlePosition = 1;
|
||||||
ddRemoteAircraftParts.flapsTrailingEdgeRightPercent = 10;
|
ddRemoteAircraftPartsWintoutLights.flapsTrailingEdgeRightPercent = 10;
|
||||||
ddRemoteAircraftParts.flapsTrailingEdgeLeftPercent = 10;
|
ddRemoteAircraftPartsWintoutLights.flapsTrailingEdgeLeftPercent = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->sendRemoteAircraftPartsToSimulator(simObj, ddRemoteAircraftParts, lights);
|
return this->sendRemoteAircraftPartsToSimulator(simObj, ddRemoteAircraftPartsWintoutLights, lights);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFsxCommon::updateRemoteAircraftParts(const CSimConnectObject &simObj, const CAircraftParts &parts, const CPartsStatus &partsStatus)
|
bool CSimulatorFsxCommon::updateRemoteAircraftParts(const CSimConnectObject &simObj, const CAircraftParts &parts, const CPartsStatus &partsStatus)
|
||||||
@@ -1023,44 +1023,44 @@ namespace BlackSimPlugin
|
|||||||
if (!simObj.hasValidRequestAndObjectId()) { return false; }
|
if (!simObj.hasValidRequestAndObjectId()) { return false; }
|
||||||
if (!partsStatus.isSupportingParts()) { return false; }
|
if (!partsStatus.isSupportingParts()) { return false; }
|
||||||
|
|
||||||
DataDefinitionRemoteAircraftParts ddRemoteAircraftParts; // no init, all values will be set
|
DataDefinitionRemoteAircraftPartsWithoutLights ddRemoteAircraftPartsWithoutLights; // no init, all values will be set
|
||||||
ddRemoteAircraftParts.flapsLeadingEdgeLeftPercent = parts.getFlapsPercent() / 100.0;
|
ddRemoteAircraftPartsWithoutLights.flapsLeadingEdgeLeftPercent = parts.getFlapsPercent() / 100.0;
|
||||||
ddRemoteAircraftParts.flapsLeadingEdgeRightPercent = parts.getFlapsPercent() / 100.0;
|
ddRemoteAircraftPartsWithoutLights.flapsLeadingEdgeRightPercent = parts.getFlapsPercent() / 100.0;
|
||||||
ddRemoteAircraftParts.flapsTrailingEdgeLeftPercent = parts.getFlapsPercent() / 100.0;
|
ddRemoteAircraftPartsWithoutLights.flapsTrailingEdgeLeftPercent = parts.getFlapsPercent() / 100.0;
|
||||||
ddRemoteAircraftParts.flapsTrailingEdgeRightPercent = parts.getFlapsPercent() / 100.0;
|
ddRemoteAircraftPartsWithoutLights.flapsTrailingEdgeRightPercent = parts.getFlapsPercent() / 100.0;
|
||||||
ddRemoteAircraftParts.spoilersHandlePosition = parts.isSpoilersOut() ? 1 : 0;
|
ddRemoteAircraftPartsWithoutLights.spoilersHandlePosition = parts.isSpoilersOut() ? 1 : 0;
|
||||||
ddRemoteAircraftParts.gearHandlePosition = parts.isGearDown() ? 1 : 0;
|
ddRemoteAircraftPartsWithoutLights.gearHandlePosition = parts.isGearDown() ? 1 : 0;
|
||||||
ddRemoteAircraftParts.engine1Combustion = parts.isEngineOn(1) ? 1 : 0;
|
ddRemoteAircraftPartsWithoutLights.engine1Combustion = parts.isEngineOn(1) ? 1 : 0;
|
||||||
ddRemoteAircraftParts.engine2Combustion = parts.isEngineOn(2) ? 1 : 0;
|
ddRemoteAircraftPartsWithoutLights.engine2Combustion = parts.isEngineOn(2) ? 1 : 0;
|
||||||
ddRemoteAircraftParts.engine3Combustion = parts.isEngineOn(3) ? 1 : 0;
|
ddRemoteAircraftPartsWithoutLights.engine3Combustion = parts.isEngineOn(3) ? 1 : 0;
|
||||||
ddRemoteAircraftParts.engine4Combustion = parts.isEngineOn(4) ? 1 : 0;
|
ddRemoteAircraftPartsWithoutLights.engine4Combustion = parts.isEngineOn(4) ? 1 : 0;
|
||||||
|
|
||||||
CAircraftLights lights = parts.getLights();
|
CAircraftLights lights = parts.getLights();
|
||||||
lights.setRecognitionOn(parts.isAnyEngineOn());
|
lights.setRecognitionOn(parts.isAnyEngineOn());
|
||||||
lights.setCabinOn(parts.isAnyEngineOn());
|
lights.setCabinOn(parts.isAnyEngineOn());
|
||||||
|
|
||||||
return this->sendRemoteAircraftPartsToSimulator(simObj, ddRemoteAircraftParts, parts.getLights());
|
return this->sendRemoteAircraftPartsToSimulator(simObj, ddRemoteAircraftPartsWithoutLights, parts.getLights());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFsxCommon::sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObj, DataDefinitionRemoteAircraftParts &ddRemoteAircraftParts, const CAircraftLights &lights)
|
bool CSimulatorFsxCommon::sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObj, DataDefinitionRemoteAircraftPartsWithoutLights &ddRemoteAircraftPartsWithoutLights, const CAircraftLights &lights)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_hSimConnect);
|
Q_ASSERT(m_hSimConnect);
|
||||||
const DWORD objectId = simObj.getObjectId();
|
const DWORD objectId = simObj.getObjectId();
|
||||||
|
|
||||||
// same as in simulator or same as already send to simulator?
|
// same as in simulator or same as already send to simulator?
|
||||||
const CAircraftLights sentLights(simObj.getLightsAsSent());
|
const CAircraftLights sentLights(simObj.getLightsAsSent());
|
||||||
if (simObj.getPartsAsSent() == ddRemoteAircraftParts && sentLights == lights) { return true; }
|
if (simObj.getPartsAsSent() == ddRemoteAircraftPartsWithoutLights && sentLights == lights) { return true; }
|
||||||
|
|
||||||
// in case we sent, we sent everything
|
// in case we sent, we sent everything
|
||||||
const HRESULT hr = SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts,
|
const HRESULT hr = SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftParts,
|
||||||
objectId, SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0,
|
objectId, SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0,
|
||||||
sizeof(DataDefinitionRemoteAircraftParts), &ddRemoteAircraftParts);
|
sizeof(DataDefinitionRemoteAircraftPartsWithoutLights), &ddRemoteAircraftPartsWithoutLights);
|
||||||
|
|
||||||
if (hr == S_OK)
|
if (hr == S_OK)
|
||||||
{
|
{
|
||||||
// Update data
|
// Update data
|
||||||
CSimConnectObject &objUdpate = m_simConnectObjects[simObj.getCallsign()];
|
CSimConnectObject &objUdpate = m_simConnectObjects[simObj.getCallsign()];
|
||||||
objUdpate.setPartsAsSent(ddRemoteAircraftParts);
|
objUdpate.setPartsAsSent(ddRemoteAircraftPartsWithoutLights);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ namespace BlackSimPlugin
|
|||||||
const BlackMisc::Aviation::CAircraftSituation &interpolatedSituation, const BlackMisc::Simulation::CInterpolationStatus &interpolationStatus);
|
const BlackMisc::Aviation::CAircraftSituation &interpolatedSituation, const BlackMisc::Simulation::CInterpolationStatus &interpolationStatus);
|
||||||
|
|
||||||
//! Send parts to simulator
|
//! Send parts to simulator
|
||||||
bool sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObj, DataDefinitionRemoteAircraftParts &ddRemoteAircraftParts, const BlackMisc::Aviation::CAircraftLights &lights);
|
bool sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObj, DataDefinitionRemoteAircraftPartsWithoutLights &ddRemoteAircraftParts, const BlackMisc::Aviation::CAircraftLights &lights);
|
||||||
|
|
||||||
//! Send lights to simulator (those which have to be toggled)
|
//! Send lights to simulator (those which have to be toggled)
|
||||||
//! \remark challenge here is that I can only sent those value if I have already obtained the current light state from simulator
|
//! \remark challenge here is that I can only sent those value if I have already obtained the current light state from simulator
|
||||||
|
|||||||
Reference in New Issue
Block a user