Skip to content

Commit

Permalink
chore: add NOMINMAX to fbw, revert clang-format change for fbw (flyby…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecologne authored Sep 17, 2024
1 parent 486d4da commit 71ebfd4
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
5 changes: 5 additions & 0 deletions fbw-a32nx/src/wasm/fbw_a320/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
BasedOnStyle: Chromium
---
Language: Cpp
ColumnLimit: 140
1 change: 1 addition & 0 deletions fbw-a32nx/src/wasm/fbw_a320/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ clang++ \
-D_LIBCPP_HAS_NO_THREADS \
-D_WINDLL \
-D_MBCS \
-DNOMINMAX \
-mthread-model single \
-fno-exceptions \
-fms-extensions \
Expand Down
10 changes: 5 additions & 5 deletions fbw-a32nx/src/wasm/fbw_a320/src/FlyByWireInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void FlyByWireInterface::setupLocalVariables() {
idFmgcAccelerationAltitudeGoAround = std::make_unique<LocalVariable>("A32NX_FM1_MISSED_ACC_ALT");
idFmgcAccelerationAltitudeGoAroundEngineOut = std::make_unique<LocalVariable>("A32NX_FM1_MISSED_EO_ACC_ALT");

idFmgcCruiseAltitude = std::make_unique<LocalVariable>("A32NX_AIRLINER_CRUISE_ALTITUDE");
idFmgcCruiseAltitude = std::make_unique<LocalVariable>("A32NX_AIRLINER_CRUISE_ALTITUDE");
idFmgcFlexTemperature = std::make_unique<LocalVariable>("A32NX_AIRLINER_TO_FLEX_TEMP");

idFlightGuidanceAvailable = std::make_unique<LocalVariable>("A32NX_FG_AVAIL");
Expand Down Expand Up @@ -894,7 +894,7 @@ bool FlyByWireInterface::readDataAndLocalVariables(double sampleTime) {
}

// calculate delta time (and ensure it does not get 0 -> max 500 fps)
calculatedSampleTime = max(0.002, simData.simulationTime - previousSimulationTime);
calculatedSampleTime = std::max(0.002, simData.simulationTime - previousSimulationTime);

monotonicTime += calculatedSampleTime;

Expand Down Expand Up @@ -955,7 +955,7 @@ bool FlyByWireInterface::handleSimulationRate(double sampleTime) {
if (simData.simulation_rate > idMaximumSimulationRate->get()) {
// set target simulation rate
targetSimulationRateModified = true;
targetSimulationRate = max(1, simData.simulation_rate / 2);
targetSimulationRate = std::max(1., simData.simulation_rate / 2);
// sed event to reduce simulation rate
simConnectInterface.sendEvent(SimConnectInterface::Events::SIM_RATE_DECR, 0, SIMCONNECT_GROUP_PRIORITY_DEFAULT);
// log event of reduction
Expand All @@ -977,7 +977,7 @@ bool FlyByWireInterface::handleSimulationRate(double sampleTime) {
elac2ProtActive || autopilotStateMachineOutput.speed_protection_mode == 1) {
// set target simulation rate
targetSimulationRateModified = true;
targetSimulationRate = max(1, simData.simulation_rate / 2);
targetSimulationRate = std::max(1., simData.simulation_rate / 2);
// send event to reduce simulation rate
simConnectInterface.sendEvent(SimConnectInterface::Events::SIM_RATE_DECR, 0, SIMCONNECT_GROUP_PRIORITY_DEFAULT);
// reset low performance timer
Expand Down Expand Up @@ -2383,7 +2383,7 @@ bool FlyByWireInterface::updateFlyByWire(double sampleTime) {
idSideStickPositionY->set(-1.0 * simInput.inputs[0]);

// set rudder pedals position
idRudderPedalPosition->set(max(-100, min(100, (-100.0 * simInput.inputs[2]))));
idRudderPedalPosition->set(std::max(-100., std::min(100., (-100. * simInput.inputs[2]))));

// provide tracking mode state
idTrackingMode->set(wasInSlew || pauseDetected || idExternalOverride->get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2767,7 +2767,7 @@ void SimConnectInterface::processEventWithOneParam(const DWORD eventId, const DW
}

case Events::SIM_RATE_SET: {
long targetSimulationRate = min(maxSimulationRate, max(1, static_cast<long>(data0)));
long targetSimulationRate = std::min(static_cast<long>(maxSimulationRate), std::max(1l, static_cast<long>(data0)));
sendEvent(SIM_RATE_SET, targetSimulationRate, SIMCONNECT_GROUP_PRIORITY_DEFAULT);
std::cout << "WASM: Simulation Rate set to " << targetSimulationRate << std::endl;
break;
Expand Down
5 changes: 5 additions & 0 deletions fbw-a380x/src/wasm/fbw_a380/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
BasedOnStyle: Chromium
---
Language: Cpp
ColumnLimit: 140
2 changes: 2 additions & 0 deletions fbw-a380x/src/wasm/fbw_a380/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ clang \
-D_LIBCPP_HAS_NO_THREADS \
-D_WINDLL \
-D_MBCS \
-DNOMINMAX \
-mthread-model single \
-fno-exceptions \
-fms-extensions \
Expand Down Expand Up @@ -76,6 +77,7 @@ clang++ \
-D_LIBCPP_HAS_NO_THREADS \
-D_WINDLL \
-D_MBCS \
-DNOMINMAX \
-mthread-model single \
-fno-exceptions \
-fms-extensions \
Expand Down
14 changes: 7 additions & 7 deletions fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ void FlyByWireInterface::setupLocalVariables() {
idFmgcAccelerationAltitudeEngineOut = std::make_unique<LocalVariable>("A32NX_FM1_EO_ACC_ALT");
idFmgcAccelerationAltitudeGoAround = std::make_unique<LocalVariable>("A32NX_FM1_MISSED_ACC_ALT");
idFmgcAccelerationAltitudeGoAroundEngineOut = std::make_unique<LocalVariable>("A32NX_FM1_MISSED_EO_ACC_ALT");
idFmgcCruiseAltitude = std::make_unique<LocalVariable>("A32NX_AIRLINER_CRUISE_ALTITUDE");
idFmgcFlexTemperature = std::make_unique<LocalVariable>("A32NX_AIRLINER_TO_FLEX_TEMP");
idFmgcCruiseAltitude = std::make_unique<LocalVariable>("A32NX_AIRLINER_CRUISE_ALTITUDE");
idFmgcFlexTemperature = std::make_unique<LocalVariable>("A32NX_AIRLINER_TO_FLEX_TEMP");

idFlightGuidanceAvailable = std::make_unique<LocalVariable>("A32NX_FG_AVAIL");
idFlightGuidanceCrossTrackError = std::make_unique<LocalVariable>("A32NX_FG_CROSS_TRACK_ERROR");
Expand Down Expand Up @@ -935,7 +935,7 @@ bool FlyByWireInterface::readDataAndLocalVariables(double sampleTime) {
}

// calculate delta time (and ensure it does not get 0 -> max 500 fps)
calculatedSampleTime = max(0.002, simData.simulationTime - previousSimulationTime);
calculatedSampleTime = std::max(0.002, simData.simulationTime - previousSimulationTime);

monotonicTime += calculatedSampleTime;

Expand Down Expand Up @@ -996,7 +996,7 @@ bool FlyByWireInterface::handleSimulationRate(double sampleTime) {
if (simData.simulation_rate > idMaximumSimulationRate->get()) {
// set target simulation rate
targetSimulationRateModified = true;
targetSimulationRate = max(1, simData.simulation_rate / 2);
targetSimulationRate = std::max(1., simData.simulation_rate / 2);
// sed event to reduce simulation rate
simConnectInterface.sendEvent(SimConnectInterface::Events::SIM_RATE_DECR, 0, SIMCONNECT_GROUP_PRIORITY_DEFAULT);
// log event of reduction
Expand All @@ -1018,7 +1018,7 @@ bool FlyByWireInterface::handleSimulationRate(double sampleTime) {
elac2ProtActive || autopilotStateMachineOutput.speed_protection_mode == 1) {
// set target simulation rate
targetSimulationRateModified = true;
targetSimulationRate = max(1, simData.simulation_rate / 2);
targetSimulationRate = std::max(1., simData.simulation_rate / 2);
// send event to reduce simulation rate
simConnectInterface.sendEvent(SimConnectInterface::Events::SIM_RATE_DECR, 0, SIMCONNECT_GROUP_PRIORITY_DEFAULT);
// reset low performance timer
Expand Down Expand Up @@ -2593,8 +2593,8 @@ bool FlyByWireInterface::updateFlyByWire(double sampleTime) {
idSideStickPositionY->set(-1.0 * simInput.inputs[0]);

// set rudder pedals position
idRudderPedalPosition->set(max(-100, min(100, (-100.0 * simInput.inputs[2]))));
idRudderPedalAnimationPosition->set(max(-100, min(100, (-100.0 * simInput.inputs[2]) + (100.0 * simData.zeta_trim_pos))));
idRudderPedalPosition->set(std::max(-100., std::min(100., (-100. * simInput.inputs[2]))));
idRudderPedalAnimationPosition->set(std::max(-100., std::min(100., (-100. * simInput.inputs[2]) + (100. * simData.zeta_trim_pos))));

// provide tracking mode state
idTrackingMode->set(wasInSlew || pauseDetected || idExternalOverride->get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3021,7 +3021,7 @@ void SimConnectInterface::processEventWithOneParam(const DWORD eventId, const DW
}

case Events::SIM_RATE_SET: {
long targetSimulationRate = min(maxSimulationRate, max(1, static_cast<long>(data0)));
long targetSimulationRate = std::min(static_cast<long>(maxSimulationRate), std::max(1l, static_cast<long>(data0)));
sendEvent(Events::SIM_RATE_SET, targetSimulationRate, SIMCONNECT_GROUP_PRIORITY_DEFAULT);
std::cout << "WASM: Simulation Rate set to " << targetSimulationRate << std::endl;
break;
Expand Down

0 comments on commit 71ebfd4

Please sign in to comment.