From adbd362b54a3a16597642ed58a3191ce4dba10ee Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Tue, 31 Dec 2024 02:06:38 +0100 Subject: [PATCH 01/11] changelog --- .github/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 015fa7ec4b3..fbee058386f 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -110,6 +110,7 @@ 1. [ATC/TCAS] Fixed TCAS failure on baro corrected altitude going invalid - @tracernz (Mike) 1. [ATC/TCAS] Fixed TCAS slant range computation - @tracernz (Mike) 1. [A380X] Add baro unit (hPa/in.Hg) auto selection - @tracernz (Mike) +1. [A380X/PRIM] Adapt alpha speeds to new flight model - @flogross89 (floridude) ## 0.12.0 From 6cd97d9f6751bfbffa7411386290fb7d4b2640f9 Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Thu, 2 Jan 2025 04:32:46 +0100 Subject: [PATCH 02/11] rename FAC --- fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt | 4 +- fbw-a380x/src/wasm/fbw_a380/build.sh | 4 +- fbw-a380x/src/wasm/fbw_a380/src/fac/Fac.h | 6 +- .../src/interface/SimConnectInterface.h | 2 +- .../fbw_a380/src/model/A380FacComputer.cpp | 1460 +++++++++++++++++ .../{FacComputer.h => A380FacComputer.h} | 174 +- ...uter_data.cpp => A380FacComputer_data.cpp} | 33 +- .../src/model/A380FacComputer_private.h | 6 + ...mputer_types.h => A380FacComputer_types.h} | 34 +- .../wasm/fbw_a380/src/model/FacComputer.cpp | 1422 ---------------- .../fbw_a380/src/model/FacComputer_private.h | 6 - 11 files changed, 1601 insertions(+), 1550 deletions(-) create mode 100644 fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer.cpp rename fbw-a380x/src/wasm/fbw_a380/src/model/{FacComputer.h => A380FacComputer.h} (65%) rename fbw-a380x/src/wasm/fbw_a380/src/model/{FacComputer_data.cpp => A380FacComputer_data.cpp} (96%) create mode 100644 fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_private.h rename fbw-a380x/src/wasm/fbw_a380/src/model/{FacComputer_types.h => A380FacComputer_types.h} (99%) delete mode 100644 fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer.cpp delete mode 100644 fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_private.h diff --git a/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt b/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt index 78439739458..b9d0ac01e0c 100644 --- a/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt +++ b/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt @@ -44,6 +44,8 @@ add_executable(flybywire-a380x-fbw src/fac/Fac.cpp src/failures/FailuresConsumer.cpp src/interface/SimConnectInterface.cpp + src/model/A380FacComputer_data.cpp + src/model/A380FacComputer.cpp src/model/A380LateralDirectLaw.cpp src/model/A380LateralNormalLaw.cpp src/model/A380PitchAlternateLaw.cpp @@ -61,8 +63,6 @@ add_executable(flybywire-a380x-fbw src/model/Autothrust.cpp src/model/binsearch_u32d.cpp src/model/Double2MultiWord.cpp - src/model/FacComputer_data.cpp - src/model/FacComputer.cpp src/model/intrp3d_l_pw.cpp src/model/look1_binlxpw.cpp src/model/look2_binlxpw.cpp diff --git a/fbw-a380x/src/wasm/fbw_a380/build.sh b/fbw-a380x/src/wasm/fbw_a380/build.sh index e8f2786146e..5c7e761741e 100755 --- a/fbw-a380x/src/wasm/fbw_a380/build.sh +++ b/fbw-a380x/src/wasm/fbw_a380/build.sh @@ -115,6 +115,8 @@ clang++ \ "${DIR}/src/model/Autothrust.cpp" \ "${DIR}/src/model/binsearch_u32d.cpp" \ "${DIR}/src/model/Double2MultiWord.cpp" \ + "${DIR}/src/model/A380FacComputer_data.cpp" \ + "${DIR}/src/model/A380FacComputer.cpp" \ "${DIR}/src/model/A380PrimComputer_data.cpp" \ "${DIR}/src/model/A380PrimComputer.cpp" \ "${DIR}/src/model/A380SecComputer_data.cpp" \ @@ -124,8 +126,6 @@ clang++ \ "${DIR}/src/model/A380PitchDirectLaw.cpp" \ "${DIR}/src/model/A380LateralNormalLaw.cpp" \ "${DIR}/src/model/A380LateralDirectLaw.cpp" \ - "${DIR}/src/model/FacComputer_data.cpp" \ - "${DIR}/src/model/FacComputer.cpp" \ "${DIR}/src/model/intrp3d_l_pw.cpp" \ "${DIR}/src/model/look1_binlxpw.cpp" \ "${DIR}/src/model/look2_binlxpw.cpp" \ diff --git a/fbw-a380x/src/wasm/fbw_a380/src/fac/Fac.h b/fbw-a380x/src/wasm/fbw_a380/src/fac/Fac.h index d0ad35ed62d..916c77697ce 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/fac/Fac.h +++ b/fbw-a380x/src/wasm/fbw_a380/src/fac/Fac.h @@ -1,7 +1,7 @@ #pragma once #include "../Arinc429Utils.h" -#include "../model/FacComputer.h" +#include "../model/A380FacComputer.h" #include "../utils/PulseNode.h" #include "../utils/SRFlipFlop.h" @@ -19,7 +19,7 @@ class Fac { base_fac_analog_outputs getAnalogOutputs(); - FacComputer::ExternalInputs_FacComputer_T modelInputs = {}; + A380FacComputer::ExternalInputs_A380FacComputer_T modelInputs = {}; private: void initSelfTests(); @@ -33,7 +33,7 @@ class Fac { void updateSelfTest(double deltaTime); // Model - FacComputer facComputer; + A380FacComputer facComputer; fac_outputs modelOutputs; // Computer Self-monitoring vars diff --git a/fbw-a380x/src/wasm/fbw_a380/src/interface/SimConnectInterface.h b/fbw-a380x/src/wasm/fbw_a380/src/interface/SimConnectInterface.h index b5c6093f39f..49efbd3c810 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/interface/SimConnectInterface.h +++ b/fbw-a380x/src/wasm/fbw_a380/src/interface/SimConnectInterface.h @@ -10,9 +10,9 @@ #include "../ThrottleAxisMapping.h" #include "SimConnectData.h" +#include "../model/A380FacComputer_types.h" #include "../model/A380PrimComputer_types.h" #include "../model/A380SecComputer_types.h" -#include "../model/FacComputer_types.h" class SimConnectInterface { public: diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer.cpp new file mode 100644 index 00000000000..17d9b0b283d --- /dev/null +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer.cpp @@ -0,0 +1,1460 @@ +#include "A380FacComputer.h" +#include "A380FacComputer_types.h" +#include "rtwtypes.h" +#include +#include "look2_binlxpw.h" +#include "look1_binlxpw.h" +#include "plook_binx.h" +#include "intrp3d_l_pw.h" + +const uint8_T A380FacComputer_IN_Flying{ 1U }; + +const uint8_T A380FacComputer_IN_Landed{ 2U }; + +const uint8_T A380FacComputer_IN_Landing100ft{ 3U }; + +const uint8_T A380FacComputer_IN_NO_ACTIVE_CHILD{ 0U }; + +const uint8_T A380FacComputer_IN_Takeoff100ft{ 4U }; + +void A380FacComputer::A380FacComputer_MATLABFunction(const base_arinc_429 *rtu_u, boolean_T *rty_y) +{ + *rty_y = (rtu_u->SSM != static_cast(SignStatusMatrix::FailureWarning)); +} + +void A380FacComputer::A380FacComputer_MATLABFunction_g(const base_arinc_429 *rtu_u, real_T rtu_bit, uint32_T *rty_y) +{ + real32_T tmp; + uint32_T a; + tmp = std::round(rtu_u->Data); + if (tmp < 4.2949673E+9F) { + if (tmp >= 0.0F) { + a = static_cast(tmp); + } else { + a = 0U; + } + } else { + a = MAX_uint32_T; + } + + if (-(rtu_bit - 1.0) >= 0.0) { + if (-(rtu_bit - 1.0) <= 31.0) { + a <<= static_cast(-(rtu_bit - 1.0)); + } else { + a = 0U; + } + } else if (-(rtu_bit - 1.0) >= -31.0) { + a >>= static_cast(rtu_bit - 1.0); + } else { + a = 0U; + } + + *rty_y = a & 1U; +} + +void A380FacComputer::A380FacComputer_LagFilter_Reset(rtDW_LagFilter_A380FacComputer_T *localDW) +{ + localDW->pY_not_empty = false; + localDW->pU_not_empty = false; +} + +void A380FacComputer::A380FacComputer_LagFilter(real_T rtu_U, real_T rtu_C1, real_T rtu_dt, real_T *rty_Y, + rtDW_LagFilter_A380FacComputer_T *localDW) +{ + real_T ca; + real_T denom_tmp; + if ((!localDW->pY_not_empty) || (!localDW->pU_not_empty)) { + localDW->pU = rtu_U; + localDW->pU_not_empty = true; + localDW->pY = rtu_U; + localDW->pY_not_empty = true; + } + + denom_tmp = rtu_dt * rtu_C1; + ca = denom_tmp / (denom_tmp + 2.0); + *rty_Y = (2.0 - denom_tmp) / (denom_tmp + 2.0) * localDW->pY + (rtu_U * ca + localDW->pU * ca); + localDW->pY = *rty_Y; + localDW->pU = rtu_U; +} + +void A380FacComputer::A380FacComputer_RateLimiter_Reset(rtDW_RateLimiter_A380FacComputer_T *localDW) +{ + localDW->pY_not_empty = false; +} + +void A380FacComputer::A380FacComputer_RateLimiter(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, boolean_T + rtu_reset, real_T *rty_Y, rtDW_RateLimiter_A380FacComputer_T *localDW) +{ + if ((!localDW->pY_not_empty) || rtu_reset) { + localDW->pY = rtu_u; + localDW->pY_not_empty = true; + } + + if (rtu_reset) { + *rty_Y = rtu_u; + } else { + *rty_Y = std::fmax(std::fmin(rtu_u - localDW->pY, std::abs(rtu_up) * rtu_Ts), -std::abs(rtu_lo) * rtu_Ts) + + localDW->pY; + } + + localDW->pY = *rty_Y; +} + +void A380FacComputer::A380FacComputer_CalculateV_alpha_max(real_T rtu_v_ias, real_T rtu_alpha, real_T rtu_alpha_0, + real_T rtu_alpha_target, real_T *rty_V_alpha_target) +{ + *rty_V_alpha_target = std::sqrt(std::abs(rtu_alpha - rtu_alpha_0) / (rtu_alpha_target - rtu_alpha_0)) * rtu_v_ias; +} + +void A380FacComputer::A380FacComputer_LagFilter_c_Reset(rtDW_LagFilter_A380FacComputer_g_T *localDW) +{ + localDW->pY_not_empty = false; + localDW->pU_not_empty = false; +} + +void A380FacComputer::A380FacComputer_LagFilter_k(real32_T rtu_U, real_T rtu_C1, real_T rtu_dt, real32_T *rty_Y, + rtDW_LagFilter_A380FacComputer_g_T *localDW) +{ + real_T ca; + real_T denom_tmp; + if ((!localDW->pY_not_empty) || (!localDW->pU_not_empty)) { + localDW->pU = rtu_U; + localDW->pU_not_empty = true; + localDW->pY = rtu_U; + localDW->pY_not_empty = true; + } + + denom_tmp = rtu_dt * rtu_C1; + ca = denom_tmp / (denom_tmp + 2.0); + *rty_Y = static_cast((2.0 - denom_tmp) / (denom_tmp + 2.0)) * localDW->pY + (rtu_U * static_cast + (ca) + localDW->pU * static_cast(ca)); + localDW->pY = *rty_Y; + localDW->pU = rtu_U; +} + +void A380FacComputer::A380FacComputer_VS1GfromVLS(real_T rtu_vls_conf_0, real_T rtu_vls_conf_other, real_T + rtu_flap_handle_index, real_T *rty_vs1g) +{ + if (rtu_flap_handle_index == 0.0) { + *rty_vs1g = rtu_vls_conf_0 / 1.23; + } else { + *rty_vs1g = rtu_vls_conf_other / 1.23; + } +} + +void A380FacComputer::A380FacComputer_RateLimiter_o_Reset(rtDW_RateLimiter_A380FacComputer_b_T *localDW) +{ + localDW->pY_not_empty = false; +} + +void A380FacComputer::A380FacComputer_RateLimiter_f(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T + rtu_init, boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_A380FacComputer_b_T *localDW) +{ + if ((!localDW->pY_not_empty) || rtu_reset) { + localDW->pY = rtu_init; + localDW->pY_not_empty = true; + } + + if (rtu_reset) { + *rty_Y = rtu_init; + } else { + *rty_Y = std::fmax(std::fmin(rtu_u - localDW->pY, std::abs(rtu_up) * rtu_Ts), -std::abs(rtu_lo) * rtu_Ts) + + localDW->pY; + } + + localDW->pY = *rty_Y; +} + +void A380FacComputer::A380FacComputer_RateLimiter_h_Reset(rtDW_RateLimiter_A380FacComputer_d_T *localDW) +{ + localDW->pY_not_empty = false; +} + +void A380FacComputer::A380FacComputer_RateLimiter_p(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T + rtu_init, boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_A380FacComputer_d_T *localDW) +{ + if ((!localDW->pY_not_empty) || rtu_reset) { + localDW->pY = rtu_init; + localDW->pY_not_empty = true; + } + + if (rtu_reset) { + *rty_Y = rtu_init; + } else { + *rty_Y = std::fmax(std::fmin(rtu_u - localDW->pY, std::abs(rtu_up) * rtu_Ts), -std::abs(rtu_lo) * rtu_Ts) + + localDW->pY; + } + + localDW->pY = *rty_Y; +} + +void A380FacComputer::A380FacComputer_MATLABFunction_pm_Reset(rtDW_MATLABFunction_A380FacComputer_f_T *localDW) +{ + localDW->output = false; + localDW->timeSinceCondition = 0.0; +} + +void A380FacComputer::A380FacComputer_MATLABFunction_p(boolean_T rtu_u, real_T rtu_Ts, boolean_T rtu_isRisingEdge, + real_T rtu_timeDelay, boolean_T *rty_y, rtDW_MATLABFunction_A380FacComputer_f_T *localDW) +{ + if (rtu_u == rtu_isRisingEdge) { + localDW->timeSinceCondition += rtu_Ts; + if (localDW->timeSinceCondition >= rtu_timeDelay) { + localDW->output = rtu_u; + } + } else { + localDW->timeSinceCondition = 0.0; + localDW->output = rtu_u; + } + + *rty_y = localDW->output; +} + +void A380FacComputer::A380FacComputer_MATLABFunction_g3(const boolean_T rtu_u[19], real32_T *rty_y) +{ + uint32_T out; + out = 0U; + for (int32_T i{0}; i < 19; i++) { + out |= static_cast(rtu_u[i]) << (i + 10); + } + + *rty_y = static_cast(out); +} + +void A380FacComputer::step() +{ + real_T fractions[3]; + real_T fractions_0[3]; + real_T fractions_1[3]; + real_T fractions_2[3]; + real_T Vcas; + real_T rtb_BusAssignment_c_flight_envelope_v_ls_kn; + real_T rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg; + real_T rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn; + real_T rtb_BusAssignment_f_flight_envelope_v_fe_next_kn; + real_T rtb_BusAssignment_f_flight_envelope_v_stall_kn; + real_T rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn; + real_T rtb_Gain; + real_T rtb_Switch; + real_T rtb_Switch1; + real_T rtb_Switch4_f; + real_T rtb_Switch6; + real_T rtb_Switch_b; + real_T rtb_Y_br; + real_T rtb_Y_g4; + real_T rtb_Y_l; + real_T rtb_beta; + real_T rtb_conf; + real_T rtb_vs1g; + real_T rtb_vs1g_h; + int32_T rtb_alpha_floor_inhib; + int32_T rtb_speed_trend_kn_SSM; + int32_T rtb_v_3_kn_SSM; + int32_T rtb_v_4_kn_SSM; + int32_T rtb_v_alpha_prot_kn_SSM; + int32_T rtb_v_ls_kn_SSM; + int32_T rtb_v_man_kn_SSM; + int32_T rtb_v_stall_kn_SSM; + int32_T rtb_v_stall_warn_kn_SSM; + real32_T rtb_DataTypeConversion2; + real32_T rtb_Switch_i_idx_0; + real32_T rtb_Switch_i_idx_1; + real32_T rtb_Switch_i_idx_2; + real32_T rtb_Switch_i_idx_3; + real32_T rtb_V_ias; + real32_T rtb_V_tas; + real32_T rtb_alpha; + real32_T rtb_alt; + real32_T rtb_mach; + real32_T rtb_n_x; + real32_T rtb_n_y; + real32_T rtb_n_z; + real32_T rtb_p_s_c; + real32_T rtb_phi; + real32_T rtb_phi_dot; + real32_T rtb_q; + real32_T rtb_r; + real32_T rtb_theta; + real32_T rtb_theta_dot; + real32_T rtb_y_a; + real32_T rtb_y_oi; + uint32_T bpIndices[3]; + uint32_T bpIndices_0[3]; + uint32_T bpIndices_1[3]; + uint32_T bpIndices_2[3]; + uint32_T rtb_y_ep; + uint32_T rtb_y_ig; + uint32_T rtb_y_l2; + uint32_T rtb_y_m; + uint32_T rtb_y_os; + uint32_T rtb_y_p; + uint32_T rtb_y_ph; + boolean_T rtb_VectorConcatenate[19]; + boolean_T rtb_VectorConcatenate_i[19]; + boolean_T guard1; + boolean_T rtb_AND; + boolean_T rtb_AND1; + boolean_T rtb_AND1_d; + boolean_T rtb_BusAssignment_d_flight_envelope_beta_target_visible; + boolean_T rtb_BusAssignment_d_logic_speed_scale_visible; + boolean_T rtb_BusAssignment_f_flight_envelope_v_3_visible; + boolean_T rtb_BusAssignment_h_logic_on_ground; + boolean_T rtb_BusAssignment_logic_lgciu_own_valid; + boolean_T rtb_BusAssignment_m_logic_sfcc_own_valid; + boolean_T rtb_DataTypeConversion_f5; + boolean_T rtb_DataTypeConversion_gi; + boolean_T rtb_DataTypeConversion_kr; + boolean_T rtb_DataTypeConversion_l3; + boolean_T rtb_DataTypeConversion_l5; + boolean_T rtb_DataTypeConversion_o; + boolean_T rtb_Memory; + boolean_T rtb_OR1; + boolean_T rtb_Switch_io_idx_1; + boolean_T rtb_Switch_io_idx_2; + boolean_T rtb_rudderTravelLimEngaged; + boolean_T rtb_rudderTrimEngaged; + boolean_T rtb_y_b4; + boolean_T rtb_y_h; + boolean_T rtb_y_ool; + boolean_T rtb_yawDamperEngaged; + boolean_T rudderTravelLimCanEngage; + boolean_T rudderTravelLimHasPriority; + boolean_T rudderTrimCanEngage; + boolean_T rudderTrimHasPriority; + boolean_T yawDamperCanEngage; + boolean_T yawDamperHasPriority; + if (A380FacComputer_U.in.sim_data.computer_running) { + if (!A380FacComputer_DWork.Runtime_MODE) { + A380FacComputer_DWork.Delay_DSTATE = A380FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition; + A380FacComputer_DWork.Delay_DSTATE_d = A380FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition_l; + A380FacComputer_DWork.Memory_PreviousInput = A380FacComputer_P.SRFlipFlop_initial_condition; + A380FacComputer_DWork.icLoad = true; + A380FacComputer_MATLABFunction_pm_Reset(&A380FacComputer_DWork.sf_MATLABFunction_a); + A380FacComputer_MATLABFunction_pm_Reset(&A380FacComputer_DWork.sf_MATLABFunction_jf); + A380FacComputer_MATLABFunction_pm_Reset(&A380FacComputer_DWork.sf_MATLABFunction_p); + A380FacComputer_LagFilter_Reset(&A380FacComputer_DWork.sf_LagFilter_d); + A380FacComputer_LagFilter_c_Reset(&A380FacComputer_DWork.sf_LagFilter_k); + A380FacComputer_LagFilter_Reset(&A380FacComputer_DWork.sf_LagFilter_f); + A380FacComputer_LagFilter_c_Reset(&A380FacComputer_DWork.sf_LagFilter_d5); + A380FacComputer_LagFilter_Reset(&A380FacComputer_DWork.sf_LagFilter_c); + A380FacComputer_RateLimiter_Reset(&A380FacComputer_DWork.sf_RateLimiter); + A380FacComputer_LagFilter_Reset(&A380FacComputer_DWork.sf_LagFilter); + A380FacComputer_DWork.is_active_c15_A380FacComputer = 0U; + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_NO_ACTIVE_CHILD; + A380FacComputer_DWork.sAlphaFloor = 0.0; + A380FacComputer_RateLimiter_Reset(&A380FacComputer_DWork.sf_RateLimiter_c); + A380FacComputer_RateLimiter_Reset(&A380FacComputer_DWork.sf_RateLimiter_a); + A380FacComputer_RateLimiter_Reset(&A380FacComputer_DWork.sf_RateLimiter_n); + A380FacComputer_RateLimiter_Reset(&A380FacComputer_DWork.sf_RateLimiter_j); + A380FacComputer_RateLimiter_o_Reset(&A380FacComputer_DWork.sf_RateLimiter_g0); + A380FacComputer_DWork.takeoff_config = 0.0; + A380FacComputer_RateLimiter_o_Reset(&A380FacComputer_DWork.sf_RateLimiter_g); + A380FacComputer_DWork.takeoff_config_c = 0.0; + A380FacComputer_DWork.takeoff_config_g = 0.0; + A380FacComputer_LagFilter_Reset(&A380FacComputer_DWork.sf_LagFilter_i); + A380FacComputer_RateLimiter_o_Reset(&A380FacComputer_DWork.sf_RateLimiter_f); + A380FacComputer_DWork.previousInput_not_empty = false; + A380FacComputer_RateLimiter_h_Reset(&A380FacComputer_DWork.sf_RateLimiter_l); + A380FacComputer_DWork.pY_not_empty = false; + A380FacComputer_DWork.pU_not_empty = false; + A380FacComputer_RateLimiter_h_Reset(&A380FacComputer_DWork.sf_RateLimiter_fu); + A380FacComputer_RateLimiter_h_Reset(&A380FacComputer_DWork.sf_RateLimiter_p); + A380FacComputer_DWork.Runtime_MODE = true; + } + + A380FacComputer_MATLABFunction(&A380FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_1, &rtb_y_b4); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_2, + A380FacComputer_P.BitfromLabel_bit, &rtb_y_ep); + A380FacComputer_MATLABFunction_p((A380FacComputer_U.in.discrete_inputs.nose_gear_pressed == (rtb_y_ep != 0U)), + A380FacComputer_U.in.time.dt, A380FacComputer_P.ConfirmNode_isRisingEdge, A380FacComputer_P.ConfirmNode_timeDelay, + &rtb_y_ool, &A380FacComputer_DWork.sf_MATLABFunction_a); + rtb_Memory = (rtb_y_b4 && rtb_y_ool); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_2, + A380FacComputer_P.BitfromLabel5_bit, &rtb_y_p); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_2, + A380FacComputer_P.BitfromLabel6_bit, &rtb_y_l2); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_3, + A380FacComputer_P.BitfromLabel7_bit, &rtb_y_ph); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_3, + A380FacComputer_P.BitfromLabel8_bit, &rtb_y_ig); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel1_bit, &rtb_y_ep); + A380FacComputer_MATLABFunction(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, &rtb_y_b4); + rtb_AND1 = ((rtb_y_ep != 0U) && rtb_y_b4); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel4_bit, &rtb_y_m); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel3_bit, &rtb_y_os); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel2_bit, &rtb_y_ep); + if (rtb_Memory) { + rtb_y_b4 = (rtb_y_p != 0U); + rtb_Switch_io_idx_1 = (rtb_y_l2 != 0U); + rtb_Switch_io_idx_2 = ((rtb_y_ph != 0U) || (rtb_y_ig != 0U)); + } else if (rtb_AND1) { + rtb_y_b4 = (rtb_y_m != 0U); + rtb_Switch_io_idx_1 = (rtb_y_os != 0U); + rtb_Switch_io_idx_2 = (rtb_y_ep != 0U); + } else { + rtb_y_b4 = A380FacComputer_P.Constant_Value_c; + rtb_Switch_io_idx_1 = A380FacComputer_P.Constant_Value_c; + rtb_Switch_io_idx_2 = A380FacComputer_P.Constant_Value_c; + } + + rtb_BusAssignment_logic_lgciu_own_valid = rtb_Memory; + rtb_AND1 = ((!rtb_Memory) && (!rtb_AND1)); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel1_bit_d, &rtb_y_ep); + A380FacComputer_MATLABFunction(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, &rtb_y_ool); + rtb_AND1_d = ((rtb_y_ep != 0U) && rtb_y_ool); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel8_bit_i, &rtb_y_p); + rtb_DataTypeConversion_gi = (rtb_y_p != 0U); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel9_bit, &rtb_y_l2); + rtb_DataTypeConversion_l5 = (rtb_y_l2 != 0U); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel10_bit, &rtb_y_ph); + rtb_DataTypeConversion_o = (rtb_y_ph != 0U); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel11_bit, &rtb_y_ig); + rtb_DataTypeConversion_f5 = (rtb_y_ig != 0U); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, + A380FacComputer_P.BitfromLabel12_bit, &rtb_y_ep); + rtb_DataTypeConversion_l3 = (rtb_y_ep != 0U); + A380FacComputer_MATLABFunction(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, + &rtb_Memory); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_actual_position_word, + A380FacComputer_P.BitfromLabel_bit_m, &rtb_y_ep); + A380FacComputer_MATLABFunction_p((A380FacComputer_U.in.discrete_inputs.slats_extended != (rtb_y_ep != 0U)), + A380FacComputer_U.in.time.dt, A380FacComputer_P.ConfirmNode_isRisingEdge_a, + A380FacComputer_P.ConfirmNode_timeDelay_m, &rtb_y_ool, &A380FacComputer_DWork.sf_MATLABFunction_jf); + rtb_DataTypeConversion_kr = (rtb_Memory && rtb_y_ool); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, + A380FacComputer_P.BitfromLabel2_bit_n, &rtb_y_ep); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, + A380FacComputer_P.BitfromLabel3_bit_i, &rtb_y_ig); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, + A380FacComputer_P.BitfromLabel4_bit_p, &rtb_y_ph); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, + A380FacComputer_P.BitfromLabel5_bit_g, &rtb_y_m); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, + A380FacComputer_P.BitfromLabel6_bit_n, &rtb_y_p); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, + A380FacComputer_P.BitfromLabel7_bit_p, &rtb_y_l2); + if (rtb_DataTypeConversion_kr) { + if (rtb_y_ep != 0U) { + rtb_Switch_i_idx_0 = 0.0F; + } else if ((rtb_y_ig != 0U) && (rtb_y_l2 != 0U)) { + rtb_Switch_i_idx_0 = 1.0F; + } else if ((rtb_y_ig != 0U) && (rtb_y_l2 == 0U)) { + rtb_Switch_i_idx_0 = 2.0F; + } else if (rtb_y_ph != 0U) { + rtb_Switch_i_idx_0 = 3.0F; + } else if (rtb_y_m != 0U) { + rtb_Switch_i_idx_0 = 4.0F; + } else if (rtb_y_p != 0U) { + rtb_Switch_i_idx_0 = 5.0F; + } else { + rtb_Switch_i_idx_0 = 0.0F; + } + + rtb_Switch_i_idx_1 = A380FacComputer_U.in.bus_inputs.sfcc_own_bus.flap_actual_position_deg.Data; + rtb_Switch_i_idx_2 = A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_actual_position_deg.Data; + rtb_Switch_i_idx_3 = A380FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_actual_position_word.Data; + } else if (rtb_AND1_d) { + if (rtb_DataTypeConversion_gi) { + rtb_Switch_i_idx_0 = 1.0F; + } else if (rtb_DataTypeConversion_l5) { + rtb_Switch_i_idx_0 = 2.0F; + } else if (rtb_DataTypeConversion_o) { + rtb_Switch_i_idx_0 = 3.0F; + } else if (rtb_DataTypeConversion_f5) { + rtb_Switch_i_idx_0 = 4.0F; + } else if (rtb_DataTypeConversion_l3) { + rtb_Switch_i_idx_0 = 5.0F; + } else { + rtb_Switch_i_idx_0 = 0.0F; + } + + rtb_Switch_i_idx_1 = A380FacComputer_U.in.bus_inputs.fac_opp_bus.fac_flap_angle_deg.Data; + rtb_Switch_i_idx_2 = A380FacComputer_U.in.bus_inputs.fac_opp_bus.fac_slat_angle_deg.Data; + rtb_Switch_i_idx_3 = A380FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_1.Data; + } else if (rtb_Switch_io_idx_2) { + rtb_Switch_i_idx_0 = A380FacComputer_P.Constant2_Value_k; + rtb_Switch_i_idx_1 = A380FacComputer_P.Constant3_Value_d; + rtb_Switch_i_idx_2 = A380FacComputer_P.Constant6_Value; + rtb_Switch_i_idx_3 = A380FacComputer_P.Constant4_Value_j; + } else { + rtb_Switch_i_idx_0 = A380FacComputer_P.Constant1_Value_c; + rtb_Switch_i_idx_1 = A380FacComputer_P.Constant1_Value_c; + rtb_Switch_i_idx_2 = A380FacComputer_P.Constant1_Value_c; + rtb_Switch_i_idx_3 = A380FacComputer_P.Constant1_Value_c; + } + + rtb_Memory = ((A380FacComputer_U.in.bus_inputs.adr_own_bus.airspeed_computed_kn.SSM == static_cast + (SignStatusMatrix::FailureWarning)) || + (A380FacComputer_U.in.bus_inputs.adr_own_bus.aoa_corrected_deg.SSM == static_cast + (SignStatusMatrix::FailureWarning))); + rtb_DataTypeConversion_gi = ((A380FacComputer_U.in.bus_inputs.adr_opp_bus.airspeed_computed_kn.SSM == + static_cast(SignStatusMatrix::FailureWarning)) || + (A380FacComputer_U.in.bus_inputs.adr_opp_bus.aoa_corrected_deg.SSM == static_cast(SignStatusMatrix:: + FailureWarning))); + rtb_DataTypeConversion_l5 = ((A380FacComputer_U.in.bus_inputs.adr_3_bus.airspeed_computed_kn.SSM == + static_cast(SignStatusMatrix::FailureWarning)) || + (A380FacComputer_U.in.bus_inputs.adr_3_bus.aoa_corrected_deg.SSM == static_cast(SignStatusMatrix:: + FailureWarning))); + rtb_DataTypeConversion_o = ((A380FacComputer_U.in.bus_inputs.ir_own_bus.body_yaw_rate_deg_s.SSM != static_cast< + uint32_T>(SignStatusMatrix::NormalOperation)) || (A380FacComputer_U.in.bus_inputs.ir_own_bus.body_lat_accel_g.SSM + != static_cast(SignStatusMatrix::NormalOperation))); + rtb_DataTypeConversion_f5 = ((A380FacComputer_U.in.bus_inputs.ir_opp_bus.body_yaw_rate_deg_s.SSM != + static_cast(SignStatusMatrix::NormalOperation)) || + (A380FacComputer_U.in.bus_inputs.ir_opp_bus.body_lat_accel_g.SSM != static_cast(SignStatusMatrix:: + NormalOperation))); + rtb_DataTypeConversion_l3 = ((A380FacComputer_U.in.bus_inputs.ir_3_bus.body_yaw_rate_deg_s.SSM != + static_cast(SignStatusMatrix::NormalOperation)) || + (A380FacComputer_U.in.bus_inputs.ir_3_bus.body_lat_accel_g.SSM != static_cast(SignStatusMatrix:: + NormalOperation))); + if (!rtb_Memory) { + rtb_V_ias = A380FacComputer_U.in.bus_inputs.adr_own_bus.airspeed_computed_kn.Data; + rtb_V_tas = A380FacComputer_U.in.bus_inputs.adr_own_bus.airspeed_true_kn.Data; + rtb_mach = A380FacComputer_U.in.bus_inputs.adr_own_bus.mach.Data; + rtb_alpha = A380FacComputer_U.in.bus_inputs.adr_own_bus.aoa_corrected_deg.Data; + rtb_p_s_c = A380FacComputer_U.in.bus_inputs.adr_own_bus.corrected_average_static_pressure.Data; + rtb_alt = A380FacComputer_U.in.bus_inputs.adr_own_bus.altitude_corrected_ft.Data; + } else if (!rtb_DataTypeConversion_l5) { + rtb_V_ias = A380FacComputer_U.in.bus_inputs.adr_3_bus.airspeed_computed_kn.Data; + rtb_V_tas = A380FacComputer_U.in.bus_inputs.adr_3_bus.airspeed_true_kn.Data; + rtb_mach = A380FacComputer_U.in.bus_inputs.adr_3_bus.mach.Data; + rtb_alpha = A380FacComputer_U.in.bus_inputs.adr_3_bus.aoa_corrected_deg.Data; + rtb_p_s_c = A380FacComputer_U.in.bus_inputs.adr_3_bus.corrected_average_static_pressure.Data; + rtb_alt = A380FacComputer_U.in.bus_inputs.adr_own_bus.altitude_corrected_ft.Data; + } else { + rtb_V_ias = 0.0F; + rtb_V_tas = 0.0F; + rtb_mach = 0.0F; + rtb_alpha = 0.0F; + rtb_p_s_c = 0.0F; + rtb_alt = 0.0F; + } + + if (!rtb_DataTypeConversion_o) { + rtb_theta = A380FacComputer_U.in.bus_inputs.ir_own_bus.pitch_angle_deg.Data; + rtb_phi = A380FacComputer_U.in.bus_inputs.ir_own_bus.roll_angle_deg.Data; + rtb_q = A380FacComputer_U.in.bus_inputs.ir_own_bus.body_pitch_rate_deg_s.Data; + rtb_r = A380FacComputer_U.in.bus_inputs.ir_own_bus.body_yaw_rate_deg_s.Data; + rtb_n_x = A380FacComputer_U.in.bus_inputs.ir_own_bus.body_long_accel_g.Data; + rtb_n_y = A380FacComputer_U.in.bus_inputs.ir_own_bus.body_lat_accel_g.Data; + rtb_n_z = A380FacComputer_U.in.bus_inputs.ir_own_bus.body_normal_accel_g.Data; + rtb_theta_dot = A380FacComputer_U.in.bus_inputs.ir_own_bus.pitch_att_rate_deg_s.Data; + rtb_phi_dot = A380FacComputer_U.in.bus_inputs.ir_own_bus.roll_att_rate_deg_s.Data; + } else if (!rtb_DataTypeConversion_l3) { + rtb_theta = A380FacComputer_U.in.bus_inputs.ir_3_bus.pitch_angle_deg.Data; + rtb_phi = A380FacComputer_U.in.bus_inputs.ir_3_bus.roll_angle_deg.Data; + rtb_q = A380FacComputer_U.in.bus_inputs.ir_3_bus.body_pitch_rate_deg_s.Data; + rtb_r = A380FacComputer_U.in.bus_inputs.ir_3_bus.body_yaw_rate_deg_s.Data; + rtb_n_x = A380FacComputer_U.in.bus_inputs.ir_3_bus.body_long_accel_g.Data; + rtb_n_y = A380FacComputer_U.in.bus_inputs.ir_3_bus.body_lat_accel_g.Data; + rtb_n_z = A380FacComputer_U.in.bus_inputs.ir_3_bus.body_normal_accel_g.Data; + rtb_theta_dot = A380FacComputer_U.in.bus_inputs.ir_3_bus.pitch_att_rate_deg_s.Data; + rtb_phi_dot = A380FacComputer_U.in.bus_inputs.ir_3_bus.roll_att_rate_deg_s.Data; + } else { + rtb_theta = 0.0F; + rtb_phi = 0.0F; + rtb_q = 0.0F; + rtb_r = 0.0F; + rtb_n_x = 0.0F; + rtb_n_y = 0.0F; + rtb_n_z = 0.0F; + rtb_theta_dot = 0.0F; + rtb_phi_dot = 0.0F; + } + + rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn = rtb_phi; + rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn = rtb_q; + rtb_vs1g_h = rtb_r; + rtb_vs1g = rtb_n_x; + rtb_Switch1 = rtb_theta_dot; + rtb_BusAssignment_m_logic_sfcc_own_valid = rtb_DataTypeConversion_kr; + rtb_AND1_d = ((!rtb_DataTypeConversion_kr) && (!rtb_AND1_d)); + rtb_DataTypeConversion_kr = (rtb_y_b4 || rtb_Switch_io_idx_1); + yawDamperCanEngage = (A380FacComputer_U.in.discrete_inputs.yaw_damper_has_hyd_press && + A380FacComputer_U.in.discrete_inputs.fac_engaged_from_switch); + rtb_y_ool = !A380FacComputer_U.in.discrete_inputs.is_unit_1; + yawDamperHasPriority = (A380FacComputer_U.in.discrete_inputs.is_unit_1 || (rtb_y_ool && + (!A380FacComputer_U.in.discrete_inputs.yaw_damper_opp_engaged))); + rtb_yawDamperEngaged = (yawDamperCanEngage && yawDamperHasPriority); + rudderTrimCanEngage = (A380FacComputer_U.in.discrete_inputs.rudder_trim_actuator_healthy && + A380FacComputer_U.in.discrete_inputs.fac_engaged_from_switch); + rudderTrimHasPriority = (A380FacComputer_U.in.discrete_inputs.is_unit_1 || (rtb_y_ool && + (!A380FacComputer_U.in.discrete_inputs.rudder_trim_opp_engaged))); + rtb_rudderTrimEngaged = (rudderTrimCanEngage && rudderTrimHasPriority); + rudderTravelLimCanEngage = (A380FacComputer_U.in.discrete_inputs.rudder_travel_lim_actuator_healthy && + A380FacComputer_U.in.discrete_inputs.fac_engaged_from_switch); + rudderTravelLimHasPriority = (A380FacComputer_U.in.discrete_inputs.is_unit_1 || (rtb_y_ool && + (!A380FacComputer_U.in.discrete_inputs.rudder_travel_lim_opp_engaged))); + rtb_rudderTravelLimEngaged = (rudderTravelLimCanEngage && rudderTravelLimHasPriority); + rtb_OR1 = !rtb_DataTypeConversion_kr; + A380FacComputer_MATLABFunction_p(rtb_OR1, A380FacComputer_U.in.time.dt, A380FacComputer_P.ConfirmNode_isRisingEdge_o, + A380FacComputer_P.ConfirmNode_timeDelay_l, &rtb_y_ool, &A380FacComputer_DWork.sf_MATLABFunction_p); + rtb_BusAssignment_h_logic_on_ground = rtb_DataTypeConversion_kr; + Vcas = rtb_V_ias * 0.5144; + if (rtb_V_ias >= 30.0F) { + rtb_beta = rtb_n_y * 9.81 / (Vcas * Vcas * 0.6125 * 122.0 / (70000.0 * Vcas) * -0.62 * Vcas) * 180.0 / + 3.1415926535897931; + } else { + rtb_beta = 0.0; + } + + A380FacComputer_LagFilter(rtb_beta, A380FacComputer_P.LagFilter1_C1, A380FacComputer_U.in.time.dt, &Vcas, + &A380FacComputer_DWork.sf_LagFilter_d); + A380FacComputer_LagFilter_k(A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data - + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data, A380FacComputer_P.LagFilter1_C1_d, + A380FacComputer_U.in.time.dt, &rtb_y_oi, &A380FacComputer_DWork.sf_LagFilter_k); + if (rtb_alpha > A380FacComputer_P.Saturation_UpperSat_a) { + rtb_Y_br = A380FacComputer_P.Saturation_UpperSat_a; + } else if (rtb_alpha < A380FacComputer_P.Saturation_LowerSat_l) { + rtb_Y_br = A380FacComputer_P.Saturation_LowerSat_l; + } else { + rtb_Y_br = rtb_alpha; + } + + A380FacComputer_LagFilter(rtb_Y_br, A380FacComputer_P.LagFilter2_C1, A380FacComputer_U.in.time.dt, &rtb_Switch1, + &A380FacComputer_DWork.sf_LagFilter_f); + A380FacComputer_LagFilter_k(A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data - + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data, A380FacComputer_P.LagFilter3_C1, + A380FacComputer_U.in.time.dt, &rtb_y_a, &A380FacComputer_DWork.sf_LagFilter_d5); + if (rtb_V_ias > A380FacComputer_P.Saturation1_UpperSat_o) { + rtb_Switch6 = A380FacComputer_P.Saturation1_UpperSat_o; + } else if (rtb_V_ias < A380FacComputer_P.Saturation1_LowerSat_n) { + rtb_Switch6 = A380FacComputer_P.Saturation1_LowerSat_n; + } else { + rtb_Switch6 = rtb_V_ias; + } + + rtb_beta = (rtb_Switch1 * rtb_y_a * A380FacComputer_P.Gain5_Gain + A380FacComputer_P.Gain4_Gain_o * rtb_y_oi) / + rtb_Switch6 / rtb_Switch6 * A380FacComputer_P.Gain_Gain_k; + A380FacComputer_LagFilter(static_cast(rtb_alpha), A380FacComputer_P.LagFilter_C1, + A380FacComputer_U.in.time.dt, &rtb_Switch6, &A380FacComputer_DWork.sf_LagFilter_c); + rtb_BusAssignment_d_logic_speed_scale_visible = rtb_y_ool; + rtb_BusAssignment_d_flight_envelope_beta_target_visible = ((std::abs + (A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data - + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data) >= + A380FacComputer_P.CompareToConstant_const_f) && + ((A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data > A380FacComputer_P.CompareToConstant1_const_l) + || (A380FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data > + A380FacComputer_P.CompareToConstant2_const_i))); + rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg = rtb_Switch6; + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_2, + A380FacComputer_P.BitfromLabel6_bit_m, &rtb_y_ep); + rtb_DataTypeConversion_kr = (rtb_y_ep != 0U); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_2, + A380FacComputer_P.BitfromLabel7_bit_i, &rtb_y_ep); + rtb_Switch1 = look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), + A380FacComputer_P.alphamax_bp01Data, A380FacComputer_P.alphamax_bp02Data, A380FacComputer_P.alphamax_tableData, + A380FacComputer_P.alphamax_maxIndex, 4U); + A380FacComputer_RateLimiter(A380FacComputer_P.Gain3_Gain * (rtb_Switch1 + look2_binlxpw(static_cast(rtb_mach), + static_cast(rtb_Switch_i_idx_0), A380FacComputer_P.alphaprotection_bp01Data, + A380FacComputer_P.alphaprotection_bp02Data, A380FacComputer_P.alphaprotection_tableData, + A380FacComputer_P.alphaprotection_maxIndex, 4U)), A380FacComputer_P.RateLimiterGenericVariableTs1_up, + A380FacComputer_P.RateLimiterGenericVariableTs1_lo, A380FacComputer_U.in.time.dt, A380FacComputer_P.reset_Value, + &rtb_Switch1, &A380FacComputer_DWork.sf_RateLimiter); + rtb_Gain = A380FacComputer_P.DiscreteDerivativeVariableTs_Gain * rtb_V_ias; + rtb_Switch6 = rtb_Gain - A380FacComputer_DWork.Delay_DSTATE; + A380FacComputer_LagFilter(rtb_Switch6 / A380FacComputer_U.in.time.dt, A380FacComputer_P.LagFilter_C1_k, + A380FacComputer_U.in.time.dt, &rtb_Switch6, &A380FacComputer_DWork.sf_LagFilter); + A380FacComputer_MATLABFunction(&A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fg_radio_height_ft, &rtb_y_ool); + if (rtb_y_ool) { + rtb_Switch = A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fg_radio_height_ft.Data; + } else { + rtb_Switch = A380FacComputer_P.Constant_Value; + } + + if (A380FacComputer_DWork.is_active_c15_A380FacComputer == 0) { + A380FacComputer_DWork.is_active_c15_A380FacComputer = 1U; + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Landed; + rtb_alpha_floor_inhib = 1; + } else { + switch (A380FacComputer_DWork.is_c15_A380FacComputer) { + case A380FacComputer_IN_Flying: + if (rtb_Switch < 100.0) { + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Landing100ft; + rtb_alpha_floor_inhib = 1; + } else if (rtb_BusAssignment_h_logic_on_ground) { + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Landed; + rtb_alpha_floor_inhib = 1; + } else { + rtb_alpha_floor_inhib = 0; + } + break; + + case A380FacComputer_IN_Landed: + if (rtb_OR1) { + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Takeoff100ft; + rtb_alpha_floor_inhib = 0; + } else { + rtb_alpha_floor_inhib = 1; + } + break; + + case A380FacComputer_IN_Landing100ft: + if (rtb_Switch > 100.0) { + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Flying; + rtb_alpha_floor_inhib = 0; + } else if (rtb_BusAssignment_h_logic_on_ground) { + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Landed; + rtb_alpha_floor_inhib = 1; + } else { + rtb_alpha_floor_inhib = 1; + } + break; + + default: + if (rtb_BusAssignment_h_logic_on_ground) { + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Landed; + rtb_alpha_floor_inhib = 1; + } else if (rtb_Switch > 100.0) { + A380FacComputer_DWork.is_c15_A380FacComputer = A380FacComputer_IN_Flying; + rtb_alpha_floor_inhib = 0; + } else { + rtb_alpha_floor_inhib = 0; + } + break; + } + } + + guard1 = false; + if ((rtb_alpha_floor_inhib == 0) && (rtb_mach < 0.6)) { + if (rtb_Switch_i_idx_0 >= 4.0F) { + rtb_v_ls_kn_SSM = -3; + } else { + rtb_v_ls_kn_SSM = 0; + } + + if ((rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg > rtb_Switch1 + std::fmin(std::fmax(rtb_Switch6, + static_cast(rtb_v_ls_kn_SSM)), 0.0)) && A380FacComputer_P.Constant1_Value_mf) { + A380FacComputer_DWork.sAlphaFloor = 1.0; + } else { + guard1 = true; + } + } else { + guard1 = true; + } + + if (guard1) { + if ((rtb_alpha_floor_inhib != 0) || ((!rtb_DataTypeConversion_kr) && (rtb_y_ep == 0U)) || + (!A380FacComputer_P.Constant1_Value_mf)) { + A380FacComputer_DWork.sAlphaFloor = 0.0; + } + } + + rtb_Switch6 = rtb_Switch_i_idx_0; + A380FacComputer_RateLimiter(look1_binlxpw(static_cast(rtb_Switch_i_idx_0), A380FacComputer_P.alpha0_bp01Data, + A380FacComputer_P.alpha0_tableData, 5U), A380FacComputer_P.RateLimiterGenericVariableTs1_up_g, + A380FacComputer_P.RateLimiterGenericVariableTs1_lo_n, A380FacComputer_U.in.time.dt, + A380FacComputer_P.reset_Value_k, &rtb_vs1g_h, &A380FacComputer_DWork.sf_RateLimiter_c); + A380FacComputer_RateLimiter(look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), + A380FacComputer_P.alphamax_bp01Data_m, A380FacComputer_P.alphamax_bp02Data_a, + A380FacComputer_P.alphamax_tableData_b, A380FacComputer_P.alphamax_maxIndex_g, 4U), + A380FacComputer_P.RateLimiterGenericVariableTs4_up, A380FacComputer_P.RateLimiterGenericVariableTs4_lo, + A380FacComputer_U.in.time.dt, A380FacComputer_P.reset_Value_o, &rtb_Switch1, + &A380FacComputer_DWork.sf_RateLimiter_a); + A380FacComputer_CalculateV_alpha_max(static_cast(rtb_V_ias), + rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg, rtb_vs1g_h, rtb_Switch1, + &rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn); + A380FacComputer_RateLimiter(look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), + A380FacComputer_P.alphaprotection_bp01Data_b, A380FacComputer_P.alphaprotection_bp02Data_m, + A380FacComputer_P.alphaprotection_tableData_p, A380FacComputer_P.alphaprotection_maxIndex_m, 4U), + A380FacComputer_P.RateLimiterGenericVariableTs3_up, A380FacComputer_P.RateLimiterGenericVariableTs3_lo, + A380FacComputer_U.in.time.dt, A380FacComputer_P.reset_Value_a, &rtb_Switch1, + &A380FacComputer_DWork.sf_RateLimiter_n); + A380FacComputer_CalculateV_alpha_max(static_cast(rtb_V_ias), + rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg, rtb_vs1g_h, rtb_Switch1, + &rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn); + A380FacComputer_RateLimiter(look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), + A380FacComputer_P.alphamax1_bp01Data, A380FacComputer_P.alphamax1_bp02Data, A380FacComputer_P.alphamax1_tableData, + A380FacComputer_P.alphamax1_maxIndex, 4U), A380FacComputer_P.RateLimiterGenericVariableTs2_up, + A380FacComputer_P.RateLimiterGenericVariableTs2_lo, A380FacComputer_U.in.time.dt, A380FacComputer_P.reset_Value_i, + &rtb_Switch6, &A380FacComputer_DWork.sf_RateLimiter_j); + A380FacComputer_CalculateV_alpha_max(static_cast(rtb_V_ias), + rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg, rtb_vs1g_h, rtb_Switch6, &rtb_Switch); + if (A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_weight_lbs.SSM == static_cast(SignStatusMatrix:: + NormalOperation)) { + rtb_DataTypeConversion2 = A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_weight_lbs.Data; + } else { + rtb_DataTypeConversion2 = A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fac_weight_lbs.Data; + } + + rtb_Switch6 = A380FacComputer_P.Gain2_Gain_d * rtb_DataTypeConversion2; + bpIndices[0U] = plook_binx(rtb_Switch6, A380FacComputer_P.nDLookupTable_bp01Data, 7U, &rtb_vs1g); + fractions[0U] = rtb_vs1g; + bpIndices[1U] = plook_binx(A380FacComputer_P.Gain3_Gain_h * + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, A380FacComputer_P.nDLookupTable_bp02Data, 1U, + &rtb_vs1g); + fractions[1U] = rtb_vs1g; + bpIndices[2U] = plook_binx(static_cast(rtb_Switch_i_idx_0), A380FacComputer_P.nDLookupTable_bp03Data, 5U, + &rtb_vs1g); + fractions[2U] = rtb_vs1g; + A380FacComputer_VS1GfromVLS(look2_binlxpw(rtb_Switch6, static_cast(rtb_alt), + A380FacComputer_P.uDLookupTable1_bp01Data, A380FacComputer_P.uDLookupTable1_bp02Data, + A380FacComputer_P.uDLookupTable1_tableData, A380FacComputer_P.uDLookupTable1_maxIndex, 8U), intrp3d_l_pw(bpIndices, + fractions, A380FacComputer_P.nDLookupTable_tableData, A380FacComputer_P.nDLookupTable_dimSizes), + static_cast(rtb_Switch_i_idx_0), &rtb_Switch6); + A380FacComputer_RateLimiter_f(rtb_Switch6, A380FacComputer_P.RateLimiterGenericVariableTs1_up_d, + A380FacComputer_P.RateLimiterGenericVariableTs1_lo_f, A380FacComputer_U.in.time.dt, + A380FacComputer_P.RateLimiterGenericVariableTs1_InitialCondition, A380FacComputer_P.reset_Value_k5, &rtb_Y_l, + &A380FacComputer_DWork.sf_RateLimiter_g0); + rtb_Switch6 = std::fmax(A380FacComputer_U.in.analog_inputs.left_spoiler_pos_deg, + A380FacComputer_U.in.analog_inputs.right_spoiler_pos_deg); + rtb_Switch1 = rtb_Switch6 / look1_binlxpw(static_cast(rtb_Switch_i_idx_0), + A380FacComputer_P.spoilermaxdeflection_bp01Data, A380FacComputer_P.spoilermaxdeflection_tableData, 5U) * + look1_binlxpw(static_cast(rtb_Switch_i_idx_0), A380FacComputer_P.VLSincreasemaxdeflection_bp01Data, + A380FacComputer_P.VLSincreasemaxdeflection_tableData, 5U); + rtb_OR1 = ((!rtb_AND1) && rtb_y_b4 && rtb_Switch_io_idx_1); + if (rtb_OR1) { + A380FacComputer_DWork.takeoff_config = rtb_Switch_i_idx_0; + } else if (A380FacComputer_DWork.takeoff_config != rtb_Switch_i_idx_0) { + A380FacComputer_DWork.takeoff_config = -1.0; + } + + if (rtb_Switch_i_idx_0 == 0.0F) { + rtb_Y_br = 1.23; + } else if (rtb_Switch_i_idx_0 == 1.0F) { + rtb_Y_br = 1.18; + } else if (A380FacComputer_DWork.takeoff_config != -1.0) { + rtb_Y_br = 1.15; + } else { + rtb_Y_br = 1.23; + } + + A380FacComputer_RateLimiter_f(rtb_Y_br, A380FacComputer_P.RateLimiterGenericVariableTs_up, + A380FacComputer_P.RateLimiterGenericVariableTs_lo, A380FacComputer_U.in.time.dt, + A380FacComputer_P.RateLimiterGenericVariableTs_InitialCondition, A380FacComputer_P.reset_Value_m, &rtb_Switch6, + &A380FacComputer_DWork.sf_RateLimiter_g); + rtb_BusAssignment_c_flight_envelope_v_ls_kn = std::fmax(A380FacComputer_P.Vmcl_Value, rtb_Switch6 * rtb_Y_l) + + rtb_Switch1; + rtb_Switch1 = A380FacComputer_P.Gain2_Gain_j * rtb_DataTypeConversion2; + bpIndices_0[0U] = plook_binx(rtb_Switch1, A380FacComputer_P.nDLookupTable_bp01Data_p, 7U, &rtb_vs1g); + fractions_0[0U] = rtb_vs1g; + bpIndices_0[1U] = plook_binx(A380FacComputer_P.Gain3_Gain_d * + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, A380FacComputer_P.nDLookupTable_bp02Data_b, 1U, + &rtb_vs1g); + fractions_0[1U] = rtb_vs1g; + bpIndices_0[2U] = plook_binx(A380FacComputer_P._Value, A380FacComputer_P.nDLookupTable_bp03Data_h, 5U, &rtb_vs1g); + fractions_0[2U] = rtb_vs1g; + A380FacComputer_VS1GfromVLS(look2_binlxpw(rtb_Switch1, static_cast(rtb_alt), + A380FacComputer_P.uDLookupTable1_bp01Data_p, A380FacComputer_P.uDLookupTable1_bp02Data_n, + A380FacComputer_P.uDLookupTable1_tableData_j, A380FacComputer_P.uDLookupTable1_maxIndex_k, 8U), intrp3d_l_pw + (bpIndices_0, fractions_0, A380FacComputer_P.nDLookupTable_tableData_e, A380FacComputer_P.nDLookupTable_dimSizes_l), + A380FacComputer_P._Value, &rtb_vs1g_h); + if (rtb_OR1) { + A380FacComputer_DWork.takeoff_config_c = rtb_Switch_i_idx_0; + A380FacComputer_DWork.takeoff_config_g = rtb_Switch_i_idx_0; + } else { + if (A380FacComputer_DWork.takeoff_config_c != rtb_Switch_i_idx_0) { + A380FacComputer_DWork.takeoff_config_c = -1.0; + } + + if (A380FacComputer_DWork.takeoff_config_g != rtb_Switch_i_idx_0) { + A380FacComputer_DWork.takeoff_config_g = -1.0; + } + } + + rtb_Switch1 = A380FacComputer_P.Gain2_Gain_o * rtb_DataTypeConversion2; + if (A380FacComputer_DWork.takeoff_config_g != -1.0) { + rtb_conf = 2.0; + } else { + rtb_conf = rtb_Switch_i_idx_0; + } + + bpIndices_1[0U] = plook_binx(rtb_Switch1, A380FacComputer_P.nDLookupTable_bp01Data_a, 7U, &rtb_vs1g); + fractions_1[0U] = rtb_vs1g; + bpIndices_1[1U] = plook_binx(A380FacComputer_P.Gain3_Gain_n * + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, A380FacComputer_P.nDLookupTable_bp02Data_f, 1U, + &rtb_vs1g); + fractions_1[1U] = rtb_vs1g; + bpIndices_1[2U] = plook_binx(rtb_conf, A380FacComputer_P.nDLookupTable_bp03Data_m, 5U, &rtb_vs1g); + fractions_1[2U] = rtb_vs1g; + A380FacComputer_VS1GfromVLS(look2_binlxpw(rtb_Switch1, static_cast(rtb_alt), + A380FacComputer_P.uDLookupTable1_bp01Data_a, A380FacComputer_P.uDLookupTable1_bp02Data_l, + A380FacComputer_P.uDLookupTable1_tableData_o, A380FacComputer_P.uDLookupTable1_maxIndex_b, 8U), intrp3d_l_pw + (bpIndices_1, fractions_1, A380FacComputer_P.nDLookupTable_tableData_p, A380FacComputer_P.nDLookupTable_dimSizes_p), + rtb_conf, &rtb_vs1g); + if (static_cast(A380FacComputer_DWork.takeoff_config_c != -1.0) > A380FacComputer_P.Switch_Threshold) { + rtb_Switch1 = std::fmax(A380FacComputer_P.Vmcl5_Value, A380FacComputer_P.Gain4_Gain * rtb_vs1g_h); + } else { + rtb_Switch1 = std::fmin(A380FacComputer_P.Vfe_35_Value, std::fmax(rtb_vs1g * look1_binlxpw(static_cast + (rtb_Switch_i_idx_0), A380FacComputer_P.uDLookupTable_bp01Data, A380FacComputer_P.uDLookupTable_tableData, 1U), + A380FacComputer_P.Vmcl10_Value)); + } + + rtb_vs1g_h = A380FacComputer_P.Gain2_Gain_c * rtb_DataTypeConversion2; + bpIndices_2[0U] = plook_binx(rtb_vs1g_h, A380FacComputer_P.nDLookupTable_bp01Data_o, 7U, &rtb_vs1g); + fractions_2[0U] = rtb_vs1g; + bpIndices_2[1U] = plook_binx(A380FacComputer_P.Gain3_Gain_a * + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, A380FacComputer_P.nDLookupTable_bp02Data_m, 1U, + &rtb_vs1g); + fractions_2[1U] = rtb_vs1g; + bpIndices_2[2U] = plook_binx(A380FacComputer_P.Constant2_Value_c, A380FacComputer_P.nDLookupTable_bp03Data_md, 5U, + &rtb_vs1g); + fractions_2[2U] = rtb_vs1g; + A380FacComputer_VS1GfromVLS(look2_binlxpw(rtb_vs1g_h, static_cast(rtb_alt), + A380FacComputer_P.uDLookupTable1_bp01Data_l, A380FacComputer_P.uDLookupTable1_bp02Data_p, + A380FacComputer_P.uDLookupTable1_tableData_i, A380FacComputer_P.uDLookupTable1_maxIndex_g, 8U), intrp3d_l_pw + (bpIndices_2, fractions_2, A380FacComputer_P.nDLookupTable_tableData_k, A380FacComputer_P.nDLookupTable_dimSizes_i), + A380FacComputer_P.Constant2_Value_c, &rtb_vs1g_h); + rtb_vs1g_h = std::fmin(std::fmax(A380FacComputer_P.Gain2_Gain_e * rtb_vs1g_h, A380FacComputer_P.Vmcl20_Value), + A380FacComputer_P.Vfe_25_Value); + rtb_conf = look2_binlxpw(A380FacComputer_P.Gain3_Gain_b * rtb_DataTypeConversion2, static_cast(rtb_alt), + A380FacComputer_P.uDLookupTable_bp01Data_n, A380FacComputer_P.uDLookupTable_bp02Data, + A380FacComputer_P.uDLookupTable_tableData_m, A380FacComputer_P.uDLookupTable_maxIndex, 8U); + rtb_DataTypeConversion_kr = (rtb_Switch_i_idx_0 == A380FacComputer_P.CompareToConstant_const); + rtb_OR1 = ((rtb_Switch_i_idx_0 < A380FacComputer_P.CompareToConstant_const_i) && (rtb_alt <= + A380FacComputer_P.CompareToConstant1_const_i)); + if (rtb_Switch_io_idx_2) { + rtb_Y_br = A380FacComputer_P.Constant2_Value; + } else { + rtb_Y_br = A380FacComputer_P.Constant3_Value; + } + + rtb_Switch4_f = std::fmin(std::fmin(rtb_Y_br, std::sqrt(std::pow((std::pow(A380FacComputer_P.Constant1_Value_p * + A380FacComputer_P.Constant1_Value_p * 0.2 + 1.0, 3.5) - 1.0) * (rtb_p_s_c / 1013.25) + 1.0, 0.2857142857142857) - + 1.0) * 1479.1), look1_binlxpw(static_cast(rtb_Switch_i_idx_0), A380FacComputer_P.uDLookupTable_bp01Data_a, + A380FacComputer_P.uDLookupTable_tableData_a, 5U)); + if (rtb_V_ias > A380FacComputer_P.Saturation_UpperSat_j) { + rtb_Y_br = A380FacComputer_P.Saturation_UpperSat_j; + } else if (rtb_V_ias < A380FacComputer_P.Saturation_LowerSat_c) { + rtb_Y_br = A380FacComputer_P.Saturation_LowerSat_c; + } else { + rtb_Y_br = rtb_V_ias; + } + + rtb_vs1g = A380FacComputer_P.DiscreteDerivativeVariableTs_Gain_l * rtb_Y_br; + rtb_Switch6 = rtb_vs1g - A380FacComputer_DWork.Delay_DSTATE_d; + A380FacComputer_LagFilter(rtb_Switch6 / A380FacComputer_U.in.time.dt, A380FacComputer_P.LagFilter_C1_f, + A380FacComputer_U.in.time.dt, &rtb_Y_br, &A380FacComputer_DWork.sf_LagFilter_i); + A380FacComputer_RateLimiter_f(rtb_Y_br, A380FacComputer_P.RateLimiterGenericVariableTs_up_g, + A380FacComputer_P.RateLimiterGenericVariableTs_lo_e, A380FacComputer_U.in.time.dt, + A380FacComputer_P.RateLimiterGenericVariableTs_InitialCondition_o, A380FacComputer_P.reset_Value_i3, &rtb_Switch6, + &A380FacComputer_DWork.sf_RateLimiter_f); + rtb_Switch_b = A380FacComputer_P.Gain_Gain_j * rtb_Switch6; + rtb_BusAssignment_f_flight_envelope_v_stall_kn = rtb_Y_l; + rtb_BusAssignment_f_flight_envelope_v_3_visible = ((rtb_Switch_i_idx_0 == A380FacComputer_P.CompareToConstant4_const) + || (rtb_Switch_i_idx_0 == A380FacComputer_P.CompareToConstant2_const)); + rtb_BusAssignment_f_flight_envelope_v_fe_next_kn = look1_binlxpw(static_cast(rtb_Switch_i_idx_0), + A380FacComputer_P.uDLookupTable1_bp01Data_pi, A380FacComputer_P.uDLookupTable1_tableData_ow, 5U); + rtb_y_ool = (A380FacComputer_U.in.discrete_inputs.ap_own_engaged || + A380FacComputer_U.in.discrete_inputs.ap_opp_engaged); + rtb_AND = (A380FacComputer_U.in.discrete_inputs.rudder_trim_reset_button && (!rtb_y_ool)); + if (!A380FacComputer_DWork.previousInput_not_empty) { + A380FacComputer_DWork.previousInput = A380FacComputer_P.PulseNode_isRisingEdge; + A380FacComputer_DWork.previousInput_not_empty = true; + } + + if (A380FacComputer_P.PulseNode_isRisingEdge) { + rtb_y_h = (rtb_AND && (!A380FacComputer_DWork.previousInput)); + } else { + rtb_y_h = ((!rtb_AND) && A380FacComputer_DWork.previousInput); + } + + A380FacComputer_DWork.previousInput = rtb_AND; + A380FacComputer_DWork.Memory_PreviousInput = A380FacComputer_P.Logic_table + [(((A380FacComputer_U.in.discrete_inputs.rudder_trim_switch_left || + A380FacComputer_U.in.discrete_inputs.rudder_trim_switch_right || rtb_y_ool) + (static_cast(rtb_y_h) << + 1)) << 1) + A380FacComputer_DWork.Memory_PreviousInput]; + rtb_AND = !rtb_rudderTrimEngaged; + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_1, + A380FacComputer_P.BitfromLabel_bit_j, &rtb_y_ph); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_1, + A380FacComputer_P.BitfromLabel1_bit_e, &rtb_y_ig); + if (rtb_y_ool) { + if (A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fg_radio_height_ft.Data >= A380FacComputer_P.Switch6_Threshold_n) + { + if ((rtb_y_ph != 0U) && A380FacComputer_U.in.discrete_inputs.elac_1_healthy) { + rtb_Y_br = A380FacComputer_U.in.bus_inputs.elac_1_bus.yaw_damper_command_deg.Data; + } else if ((rtb_y_ig != 0U) && A380FacComputer_U.in.discrete_inputs.elac_2_healthy) { + rtb_Y_br = A380FacComputer_U.in.bus_inputs.elac_2_bus.yaw_damper_command_deg.Data; + } else { + rtb_Y_br = A380FacComputer_P.Constant1_Value_m; + } + + rtb_Switch6 = A380FacComputer_P.Gain2_Gain * rtb_Y_br; + } else { + rtb_Switch6 = A380FacComputer_P.Constant2_Value_m; + } + + if (rtb_Switch6 > A380FacComputer_P.Saturation_UpperSat) { + rtb_Switch6 = A380FacComputer_P.Saturation_UpperSat; + } else if (rtb_Switch6 < A380FacComputer_P.Saturation_LowerSat) { + rtb_Switch6 = A380FacComputer_P.Saturation_LowerSat; + } + } else if (A380FacComputer_U.in.discrete_inputs.rudder_trim_switch_left) { + rtb_Switch6 = 1.0; + } else if (A380FacComputer_U.in.discrete_inputs.rudder_trim_switch_right) { + rtb_Switch6 = -1.0; + } else { + rtb_Switch6 = 0.0; + } + + rtb_Switch6 = A380FacComputer_P.DiscreteTimeIntegratorVariableTs_Gain * rtb_Switch6 * A380FacComputer_U.in.time.dt; + A380FacComputer_DWork.icLoad = (A380FacComputer_DWork.Memory_PreviousInput || rtb_AND || + A380FacComputer_DWork.icLoad); + if (A380FacComputer_DWork.icLoad) { + if (rtb_AND) { + rtb_Y_br = A380FacComputer_U.in.analog_inputs.rudder_trim_position_deg; + } else { + rtb_Y_br = A380FacComputer_P.Constant_Value_g; + } + + A380FacComputer_DWork.Delay_DSTATE_dc = rtb_Y_br - rtb_Switch6; + } + + A380FacComputer_DWork.Delay_DSTATE_dc += rtb_Switch6; + if (A380FacComputer_DWork.Delay_DSTATE_dc > A380FacComputer_P.DiscreteTimeIntegratorVariableTs_UpperLimit) { + A380FacComputer_DWork.Delay_DSTATE_dc = A380FacComputer_P.DiscreteTimeIntegratorVariableTs_UpperLimit; + } else if (A380FacComputer_DWork.Delay_DSTATE_dc < A380FacComputer_P.DiscreteTimeIntegratorVariableTs_LowerLimit) { + A380FacComputer_DWork.Delay_DSTATE_dc = A380FacComputer_P.DiscreteTimeIntegratorVariableTs_LowerLimit; + } + + A380FacComputer_RateLimiter_p(A380FacComputer_DWork.Delay_DSTATE_dc, + A380FacComputer_P.RateLimiterGenericVariableTs_up_l, A380FacComputer_P.RateLimiterGenericVariableTs_lo_d, + A380FacComputer_U.in.time.dt, A380FacComputer_U.in.analog_inputs.rudder_trim_position_deg, rtb_AND, &rtb_Y_l, + &A380FacComputer_DWork.sf_RateLimiter_l); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_1, + A380FacComputer_P.BitfromLabel_bit_c, &rtb_y_ep); + rtb_y_ool = (rtb_y_ep != 0U); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_1, + A380FacComputer_P.BitfromLabel1_bit_n, &rtb_y_ep); + rtb_AND = (rtb_y_ool && A380FacComputer_U.in.discrete_inputs.elac_1_healthy && (rtb_y_ep != 0U)); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_1, + A380FacComputer_P.BitfromLabel3_bit_k, &rtb_y_ep); + rtb_y_ool = (rtb_y_ep != 0U); + A380FacComputer_MATLABFunction_g(&A380FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_1, + A380FacComputer_P.BitfromLabel4_bit_k, &rtb_y_ep); + if ((!A380FacComputer_DWork.pY_not_empty) || (!A380FacComputer_DWork.pU_not_empty)) { + A380FacComputer_DWork.pU = rtb_r; + A380FacComputer_DWork.pU_not_empty = true; + A380FacComputer_DWork.pY = rtb_r; + A380FacComputer_DWork.pY_not_empty = true; + } + + rtb_Switch6 = A380FacComputer_U.in.time.dt * A380FacComputer_P.WashoutFilter_C1; + rtb_Y_br = 2.0 / (rtb_Switch6 + 2.0); + A380FacComputer_DWork.pY = (2.0 - rtb_Switch6) / (rtb_Switch6 + 2.0) * A380FacComputer_DWork.pY + (rtb_r * rtb_Y_br + - A380FacComputer_DWork.pU * rtb_Y_br); + A380FacComputer_DWork.pU = rtb_r; + if (rtb_AND || (rtb_y_ool && A380FacComputer_U.in.discrete_inputs.elac_2_healthy && (rtb_y_ep != 0U))) { + if (rtb_AND) { + rtb_Switch6 = A380FacComputer_U.in.bus_inputs.elac_1_bus.yaw_damper_command_deg.Data; + } else { + rtb_Switch6 = A380FacComputer_U.in.bus_inputs.elac_2_bus.yaw_damper_command_deg.Data; + } + } else { + rtb_Switch6 = A380FacComputer_P.Gain_Gain * A380FacComputer_DWork.pY; + if (rtb_Switch6 > A380FacComputer_P.Saturation1_UpperSat) { + rtb_Switch6 = A380FacComputer_P.Saturation1_UpperSat; + } else if (rtb_Switch6 < A380FacComputer_P.Saturation1_LowerSat) { + rtb_Switch6 = A380FacComputer_P.Saturation1_LowerSat; + } + } + + if (rtb_Switch6 > A380FacComputer_P.Saturation_UpperSat_e) { + rtb_Switch6 = A380FacComputer_P.Saturation_UpperSat_e; + } else if (rtb_Switch6 < A380FacComputer_P.Saturation_LowerSat_o) { + rtb_Switch6 = A380FacComputer_P.Saturation_LowerSat_o; + } + + A380FacComputer_RateLimiter_p(rtb_Switch6, A380FacComputer_P.RateLimiterGenericVariableTs_up_a, + A380FacComputer_P.RateLimiterGenericVariableTs_lo_f, A380FacComputer_U.in.time.dt, + A380FacComputer_U.in.analog_inputs.yaw_damper_position_deg, !rtb_yawDamperEngaged, &rtb_Y_br, + &A380FacComputer_DWork.sf_RateLimiter_fu); + rtb_Switch6 = look1_binlxpw(static_cast(rtb_V_ias), A380FacComputer_P.uDLookupTable_bp01Data_i, + A380FacComputer_P.uDLookupTable_tableData_j, 6U); + if (rtb_Switch6 > A380FacComputer_P.Saturation_UpperSat_g) { + rtb_Switch6 = A380FacComputer_P.Saturation_UpperSat_g; + } else if (rtb_Switch6 < A380FacComputer_P.Saturation_LowerSat_f) { + rtb_Switch6 = A380FacComputer_P.Saturation_LowerSat_f; + } + + A380FacComputer_RateLimiter_p(rtb_Switch6, A380FacComputer_P.RateLimiterGenericVariableTs_up_c, + A380FacComputer_P.RateLimiterGenericVariableTs_lo_p, A380FacComputer_U.in.time.dt, + A380FacComputer_U.in.analog_inputs.rudder_travel_lim_position_deg, !rtb_rudderTravelLimEngaged, &rtb_Y_g4, + &A380FacComputer_DWork.sf_RateLimiter_p); + A380FacComputer_Y.out.bus_outputs.v_fe_next_kn.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant2_Value); + rtb_VectorConcatenate[0] = rtb_yawDamperEngaged; + rtb_VectorConcatenate[1] = A380FacComputer_U.in.discrete_inputs.yaw_damper_opp_engaged; + rtb_VectorConcatenate[2] = rtb_rudderTrimEngaged; + rtb_VectorConcatenate[3] = A380FacComputer_U.in.discrete_inputs.rudder_trim_opp_engaged; + rtb_VectorConcatenate[4] = rtb_rudderTravelLimEngaged; + rtb_VectorConcatenate[5] = A380FacComputer_U.in.discrete_inputs.rudder_travel_lim_opp_engaged; + rtb_VectorConcatenate[6] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[7] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[8] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[9] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[10] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[11] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[12] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[13] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[14] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[15] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[16] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[17] = A380FacComputer_P.Constant10_Value; + rtb_VectorConcatenate[18] = A380FacComputer_P.Constant10_Value; + A380FacComputer_MATLABFunction_g3(rtb_VectorConcatenate, &rtb_y_a); + if (A380FacComputer_P.Constant_Value_b5) { + rtb_alpha_floor_inhib = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_v_ls_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_v_stall_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_v_alpha_prot_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_v_stall_warn_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_speed_trend_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_v_3_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_v_4_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + rtb_v_man_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + A380FacComputer_Y.out.bus_outputs.v_max_kn.SSM = static_cast(A380FacComputer_P.EnumeratedConstant2_Value); + } else { + if (rtb_BusAssignment_d_logic_speed_scale_visible) { + rtb_alpha_floor_inhib = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + rtb_v_ls_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + } else { + rtb_alpha_floor_inhib = static_cast(A380FacComputer_P.EnumeratedConstant_Value); + rtb_v_ls_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant_Value); + } + + rtb_v_stall_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + if (rtb_BusAssignment_d_logic_speed_scale_visible) { + rtb_v_alpha_prot_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + rtb_v_stall_warn_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + } else { + rtb_v_alpha_prot_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant_Value); + rtb_v_stall_warn_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant_Value); + } + + rtb_speed_trend_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + if (rtb_BusAssignment_d_logic_speed_scale_visible && rtb_BusAssignment_f_flight_envelope_v_3_visible) { + rtb_v_3_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + } else { + rtb_v_3_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant_Value); + } + + if (rtb_BusAssignment_d_logic_speed_scale_visible && ((rtb_Switch_i_idx_0 == + A380FacComputer_P.CompareToConstant3_const) || (rtb_Switch_i_idx_0 == + A380FacComputer_P.CompareToConstant1_const))) { + rtb_v_4_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + } else { + rtb_v_4_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant_Value); + } + + if (rtb_BusAssignment_d_logic_speed_scale_visible && rtb_DataTypeConversion_kr) { + rtb_v_man_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + } else { + rtb_v_man_kn_SSM = static_cast(A380FacComputer_P.EnumeratedConstant_Value); + } + + A380FacComputer_Y.out.bus_outputs.v_max_kn.SSM = static_cast(A380FacComputer_P.EnumeratedConstant1_Value); + if (rtb_BusAssignment_d_logic_speed_scale_visible && rtb_OR1) { + A380FacComputer_Y.out.bus_outputs.v_fe_next_kn.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + } else { + A380FacComputer_Y.out.bus_outputs.v_fe_next_kn.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant_Value); + } + } + + rtb_VectorConcatenate[0] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[1] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[2] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[3] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[4] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[5] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[6] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[7] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[8] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[9] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[10] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[11] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[12] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[13] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[14] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[15] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[16] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[17] = A380FacComputer_P.Constant18_Value; + rtb_VectorConcatenate[18] = A380FacComputer_P.Constant18_Value; + A380FacComputer_MATLABFunction_g3(rtb_VectorConcatenate, &rtb_y_oi); + rtb_VectorConcatenate[0] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[1] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[2] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[3] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[4] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[5] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[6] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[7] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[8] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[9] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[10] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[11] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[12] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[13] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[14] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[15] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[16] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[17] = A380FacComputer_P.Constant9_Value; + rtb_VectorConcatenate[18] = A380FacComputer_P.Constant9_Value; + A380FacComputer_MATLABFunction_g3(rtb_VectorConcatenate, &A380FacComputer_Y.out.bus_outputs.discrete_word_4.Data); + rtb_VectorConcatenate_i[0] = (rtb_Switch_i_idx_0 == 1.0F); + rtb_VectorConcatenate_i[1] = (rtb_Switch_i_idx_0 == 2.0F); + rtb_VectorConcatenate_i[2] = (rtb_Switch_i_idx_0 == 3.0F); + rtb_VectorConcatenate_i[3] = (rtb_Switch_i_idx_0 == 4.0F); + rtb_VectorConcatenate_i[4] = (rtb_Switch_i_idx_0 == 5.0F); + rtb_VectorConcatenate_i[5] = rtb_BusAssignment_logic_lgciu_own_valid; + rtb_VectorConcatenate_i[6] = rtb_AND1; + rtb_VectorConcatenate_i[7] = rtb_y_b4; + rtb_VectorConcatenate_i[8] = rtb_Switch_io_idx_1; + rtb_VectorConcatenate_i[9] = rtb_Switch_io_idx_2; + rtb_VectorConcatenate_i[10] = rtb_BusAssignment_m_logic_sfcc_own_valid; + rtb_VectorConcatenate_i[11] = rtb_AND1_d; + rtb_VectorConcatenate_i[12] = A380FacComputer_P.Constant19_Value; + rtb_VectorConcatenate_i[13] = A380FacComputer_P.Constant19_Value; + rtb_VectorConcatenate_i[14] = A380FacComputer_P.Constant19_Value; + rtb_VectorConcatenate_i[15] = A380FacComputer_P.Constant19_Value; + rtb_VectorConcatenate_i[16] = A380FacComputer_P.Constant19_Value; + rtb_VectorConcatenate_i[17] = A380FacComputer_P.Constant19_Value; + rtb_VectorConcatenate_i[18] = (A380FacComputer_DWork.sAlphaFloor != 0.0); + A380FacComputer_MATLABFunction_g3(rtb_VectorConcatenate_i, &A380FacComputer_Y.out.bus_outputs.discrete_word_5.Data); + A380FacComputer_Y.out.data = A380FacComputer_U.in; + A380FacComputer_Y.out.laws.yaw_damper_command_deg = rtb_Y_br; + A380FacComputer_Y.out.laws.rudder_trim_command_deg = rtb_Y_l; + A380FacComputer_Y.out.laws.rudder_travel_lim_command_deg = rtb_Y_g4; + A380FacComputer_Y.out.logic.lgciu_own_valid = rtb_BusAssignment_logic_lgciu_own_valid; + A380FacComputer_Y.out.logic.all_lgciu_lost = rtb_AND1; + A380FacComputer_Y.out.logic.left_main_gear_pressed = rtb_y_b4; + A380FacComputer_Y.out.logic.right_main_gear_pressed = rtb_Switch_io_idx_1; + A380FacComputer_Y.out.logic.main_gear_out = rtb_Switch_io_idx_2; + A380FacComputer_Y.out.logic.sfcc_own_valid = rtb_BusAssignment_m_logic_sfcc_own_valid; + A380FacComputer_Y.out.logic.all_sfcc_lost = rtb_AND1_d; + A380FacComputer_Y.out.logic.flap_handle_index = rtb_Switch_i_idx_0; + A380FacComputer_Y.out.logic.flap_angle_deg = rtb_Switch_i_idx_1; + A380FacComputer_Y.out.logic.slat_angle_deg = rtb_Switch_i_idx_2; + A380FacComputer_Y.out.logic.slat_flap_actual_pos = rtb_Switch_i_idx_3; + A380FacComputer_Y.out.logic.on_ground = rtb_BusAssignment_h_logic_on_ground; + A380FacComputer_Y.out.logic.tracking_mode_on = (A380FacComputer_U.in.sim_data.slew_on || + A380FacComputer_U.in.sim_data.pause_on || A380FacComputer_U.in.sim_data.tracking_mode_on_override); + A380FacComputer_Y.out.logic.double_self_detected_adr_failure = ((rtb_Memory && rtb_DataTypeConversion_gi) || + (rtb_Memory && rtb_DataTypeConversion_l5) || (rtb_DataTypeConversion_gi && rtb_DataTypeConversion_l5)); + A380FacComputer_Y.out.logic.double_self_detected_ir_failure = ((rtb_DataTypeConversion_o && + rtb_DataTypeConversion_f5) || (rtb_DataTypeConversion_o && rtb_DataTypeConversion_l3) || + (rtb_DataTypeConversion_f5 && rtb_DataTypeConversion_l3)); + A380FacComputer_Y.out.logic.double_not_self_detected_adr_failure = A380FacComputer_P.Constant_Value_h; + A380FacComputer_Y.out.logic.double_not_self_detected_ir_failure = A380FacComputer_P.Constant_Value_h; + A380FacComputer_Y.out.logic.adr_computation_data.V_ias_kn = rtb_V_ias; + A380FacComputer_Y.out.logic.adr_computation_data.V_tas_kn = rtb_V_tas; + A380FacComputer_Y.out.logic.adr_computation_data.mach = rtb_mach; + A380FacComputer_Y.out.logic.adr_computation_data.alpha_deg = rtb_alpha; + A380FacComputer_Y.out.logic.adr_computation_data.p_s_c_hpa = rtb_p_s_c; + A380FacComputer_Y.out.logic.adr_computation_data.altitude_corrected_ft = rtb_alt; + A380FacComputer_Y.out.logic.ir_computation_data.theta_deg = rtb_theta; + A380FacComputer_Y.out.logic.ir_computation_data.phi_deg = rtb_phi; + A380FacComputer_Y.out.logic.ir_computation_data.q_deg_s = rtb_q; + A380FacComputer_Y.out.logic.ir_computation_data.r_deg_s = rtb_r; + A380FacComputer_Y.out.logic.ir_computation_data.n_x_g = rtb_n_x; + A380FacComputer_Y.out.logic.ir_computation_data.n_y_g = rtb_n_y; + A380FacComputer_Y.out.logic.ir_computation_data.n_z_g = rtb_n_z; + A380FacComputer_Y.out.logic.ir_computation_data.theta_dot_deg_s = rtb_theta_dot; + A380FacComputer_Y.out.logic.ir_computation_data.phi_dot_deg_s = rtb_phi_dot; + A380FacComputer_Y.out.logic.yaw_damper_engaged = rtb_yawDamperEngaged; + A380FacComputer_Y.out.logic.yaw_damper_can_engage = yawDamperCanEngage; + A380FacComputer_Y.out.logic.yaw_damper_has_priority = yawDamperHasPriority; + A380FacComputer_Y.out.logic.rudder_trim_engaged = rtb_rudderTrimEngaged; + A380FacComputer_Y.out.logic.rudder_trim_can_engage = rudderTrimCanEngage; + A380FacComputer_Y.out.logic.rudder_trim_has_priority = rudderTrimHasPriority; + A380FacComputer_Y.out.logic.rudder_travel_lim_engaged = rtb_rudderTravelLimEngaged; + A380FacComputer_Y.out.logic.rudder_travel_lim_can_engage = rudderTravelLimCanEngage; + A380FacComputer_Y.out.logic.rudder_travel_lim_has_priority = rudderTravelLimHasPriority; + A380FacComputer_Y.out.logic.speed_scale_lost = A380FacComputer_P.Constant_Value_b5; + A380FacComputer_Y.out.logic.speed_scale_visible = rtb_BusAssignment_d_logic_speed_scale_visible; + A380FacComputer_Y.out.flight_envelope.estimated_beta_deg = Vcas; + A380FacComputer_Y.out.flight_envelope.beta_target_deg = rtb_beta; + A380FacComputer_Y.out.flight_envelope.beta_target_visible = rtb_BusAssignment_d_flight_envelope_beta_target_visible; + A380FacComputer_Y.out.flight_envelope.alpha_floor_condition = (A380FacComputer_DWork.sAlphaFloor != 0.0); + A380FacComputer_Y.out.flight_envelope.alpha_filtered_deg = rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg; + A380FacComputer_Y.out.flight_envelope.computed_weight_lbs = rtb_DataTypeConversion2; + A380FacComputer_Y.out.flight_envelope.computed_cg_percent = + A380FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data; + A380FacComputer_Y.out.flight_envelope.v_alpha_max_kn = rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn; + A380FacComputer_Y.out.flight_envelope.v_alpha_prot_kn = rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn; + A380FacComputer_Y.out.flight_envelope.v_stall_warn_kn = rtb_Switch; + A380FacComputer_Y.out.flight_envelope.v_ls_kn = rtb_BusAssignment_c_flight_envelope_v_ls_kn; + A380FacComputer_Y.out.flight_envelope.v_stall_kn = rtb_BusAssignment_f_flight_envelope_v_stall_kn; + A380FacComputer_Y.out.flight_envelope.v_3_kn = rtb_Switch1; + A380FacComputer_Y.out.flight_envelope.v_3_visible = rtb_BusAssignment_f_flight_envelope_v_3_visible; + A380FacComputer_Y.out.flight_envelope.v_4_kn = rtb_vs1g_h; + A380FacComputer_Y.out.flight_envelope.v_4_visible = ((rtb_Switch_i_idx_0 == + A380FacComputer_P.CompareToConstant3_const) || (rtb_Switch_i_idx_0 == A380FacComputer_P.CompareToConstant1_const)); + A380FacComputer_Y.out.flight_envelope.v_man_kn = rtb_conf; + A380FacComputer_Y.out.flight_envelope.v_man_visible = rtb_DataTypeConversion_kr; + A380FacComputer_Y.out.flight_envelope.v_max_kn = rtb_Switch4_f; + A380FacComputer_Y.out.flight_envelope.v_fe_next_kn = rtb_BusAssignment_f_flight_envelope_v_fe_next_kn; + A380FacComputer_Y.out.flight_envelope.v_fe_next_visible = rtb_OR1; + A380FacComputer_Y.out.flight_envelope.v_c_trend_kn = rtb_Switch_b; + A380FacComputer_Y.out.discrete_outputs.fac_healthy = A380FacComputer_P.Constant2_Value_o; + A380FacComputer_Y.out.discrete_outputs.yaw_damper_engaged = rtb_yawDamperEngaged; + A380FacComputer_Y.out.discrete_outputs.rudder_trim_engaged = rtb_rudderTrimEngaged; + A380FacComputer_Y.out.discrete_outputs.rudder_travel_lim_engaged = rtb_rudderTravelLimEngaged; + A380FacComputer_Y.out.discrete_outputs.rudder_travel_lim_emergency_reset = A380FacComputer_P.Constant1_Value_d; + A380FacComputer_Y.out.discrete_outputs.yaw_damper_avail_for_norm_law = yawDamperCanEngage; + if (rtb_yawDamperEngaged) { + A380FacComputer_Y.out.analog_outputs.yaw_damper_order_deg = rtb_Y_br; + } else { + A380FacComputer_Y.out.analog_outputs.yaw_damper_order_deg = A380FacComputer_P.Constant_Value_b; + } + + if (rtb_rudderTrimEngaged) { + A380FacComputer_Y.out.analog_outputs.rudder_trim_order_deg = rtb_Y_l; + } else { + A380FacComputer_Y.out.analog_outputs.rudder_trim_order_deg = A380FacComputer_P.Constant_Value_b; + } + + if (rtb_rudderTravelLimEngaged) { + A380FacComputer_Y.out.analog_outputs.rudder_travel_limit_order_deg = rtb_Y_g4; + } else { + A380FacComputer_Y.out.analog_outputs.rudder_travel_limit_order_deg = A380FacComputer_P.Constant_Value_b; + } + + if (rtb_BusAssignment_m_logic_sfcc_own_valid) { + A380FacComputer_Y.out.bus_outputs.discrete_word_1.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + } else { + A380FacComputer_Y.out.bus_outputs.discrete_word_1.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant_Value); + } + + A380FacComputer_Y.out.bus_outputs.discrete_word_1.Data = rtb_Switch_i_idx_3; + A380FacComputer_Y.out.bus_outputs.gamma_a_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.gamma_a_deg.Data = A380FacComputer_P.Constant28_Value; + A380FacComputer_Y.out.bus_outputs.gamma_t_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.gamma_t_deg.Data = A380FacComputer_P.Constant22_Value; + A380FacComputer_Y.out.bus_outputs.total_weight_lbs.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.total_weight_lbs.Data = A380FacComputer_P.Constant21_Value; + A380FacComputer_Y.out.bus_outputs.center_of_gravity_pos_percent.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.center_of_gravity_pos_percent.Data = A380FacComputer_P.Constant4_Value_b; + if (A380FacComputer_P.Constant_Value_d > A380FacComputer_P.Switch7_Threshold) { + A380FacComputer_Y.out.bus_outputs.sideslip_target_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant2_Value); + } else if (rtb_BusAssignment_d_flight_envelope_beta_target_visible) { + A380FacComputer_Y.out.bus_outputs.sideslip_target_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + } else { + A380FacComputer_Y.out.bus_outputs.sideslip_target_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant_Value); + } + + A380FacComputer_Y.out.bus_outputs.sideslip_target_deg.Data = static_cast(rtb_beta); + if (rtb_BusAssignment_m_logic_sfcc_own_valid) { + A380FacComputer_Y.out.bus_outputs.fac_slat_angle_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + } else { + A380FacComputer_Y.out.bus_outputs.fac_slat_angle_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant_Value); + } + + A380FacComputer_Y.out.bus_outputs.fac_slat_angle_deg.Data = rtb_Switch_i_idx_2; + if (rtb_BusAssignment_m_logic_sfcc_own_valid) { + A380FacComputer_Y.out.bus_outputs.fac_flap_angle_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + } else { + A380FacComputer_Y.out.bus_outputs.fac_flap_angle_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant_Value); + } + + A380FacComputer_Y.out.bus_outputs.fac_flap_angle_deg.Data = rtb_Switch_i_idx_1; + A380FacComputer_Y.out.bus_outputs.discrete_word_2.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.discrete_word_2.Data = rtb_y_a; + A380FacComputer_Y.out.bus_outputs.rudder_travel_limit_command_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.rudder_travel_limit_command_deg.Data = static_cast + (A380FacComputer_U.in.analog_inputs.rudder_travel_lim_position_deg); + A380FacComputer_Y.out.bus_outputs.delta_r_yaw_damper_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.delta_r_yaw_damper_deg.Data = A380FacComputer_P.Constant26_Value; + if (A380FacComputer_P.Constant1_Value_l > A380FacComputer_P.Switch6_Threshold) { + A380FacComputer_Y.out.bus_outputs.estimated_sideslip_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant2_Value); + } else { + A380FacComputer_Y.out.bus_outputs.estimated_sideslip_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + } + + A380FacComputer_Y.out.bus_outputs.estimated_sideslip_deg.Data = static_cast(Vcas); + A380FacComputer_Y.out.bus_outputs.v_alpha_lim_kn.SSM = static_cast(rtb_alpha_floor_inhib); + A380FacComputer_Y.out.bus_outputs.v_alpha_lim_kn.Data = static_cast + (rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn); + A380FacComputer_Y.out.bus_outputs.v_ls_kn.SSM = static_cast(rtb_v_ls_kn_SSM); + A380FacComputer_Y.out.bus_outputs.v_ls_kn.Data = static_cast(rtb_BusAssignment_c_flight_envelope_v_ls_kn); + A380FacComputer_Y.out.bus_outputs.v_stall_kn.SSM = static_cast(rtb_v_stall_kn_SSM); + A380FacComputer_Y.out.bus_outputs.v_stall_kn.Data = static_cast + (rtb_BusAssignment_f_flight_envelope_v_stall_kn); + A380FacComputer_Y.out.bus_outputs.v_alpha_prot_kn.SSM = static_cast(rtb_v_alpha_prot_kn_SSM); + A380FacComputer_Y.out.bus_outputs.v_alpha_prot_kn.Data = static_cast + (rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn); + A380FacComputer_Y.out.bus_outputs.v_stall_warn_kn.SSM = static_cast(rtb_v_stall_warn_kn_SSM); + A380FacComputer_Y.out.bus_outputs.v_stall_warn_kn.Data = static_cast(rtb_Switch); + A380FacComputer_Y.out.bus_outputs.speed_trend_kn.SSM = static_cast(rtb_speed_trend_kn_SSM); + A380FacComputer_Y.out.bus_outputs.speed_trend_kn.Data = static_cast(rtb_Switch_b); + A380FacComputer_Y.out.bus_outputs.v_3_kn.SSM = static_cast(rtb_v_3_kn_SSM); + A380FacComputer_Y.out.bus_outputs.v_3_kn.Data = static_cast(rtb_Switch1); + A380FacComputer_Y.out.bus_outputs.v_4_kn.SSM = static_cast(rtb_v_4_kn_SSM); + A380FacComputer_Y.out.bus_outputs.v_4_kn.Data = static_cast(rtb_vs1g_h); + A380FacComputer_Y.out.bus_outputs.v_man_kn.SSM = static_cast(rtb_v_man_kn_SSM); + A380FacComputer_Y.out.bus_outputs.v_man_kn.Data = static_cast(rtb_conf); + A380FacComputer_Y.out.bus_outputs.v_max_kn.Data = static_cast(rtb_Switch4_f); + A380FacComputer_Y.out.bus_outputs.v_fe_next_kn.Data = static_cast + (rtb_BusAssignment_f_flight_envelope_v_fe_next_kn); + A380FacComputer_Y.out.bus_outputs.discrete_word_3.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.discrete_word_3.Data = rtb_y_oi; + A380FacComputer_Y.out.bus_outputs.discrete_word_4.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.discrete_word_5.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.delta_r_rudder_trim_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.delta_r_rudder_trim_deg.Data = static_cast(rtb_Y_l); + A380FacComputer_Y.out.bus_outputs.rudder_trim_pos_deg.SSM = static_cast + (A380FacComputer_P.EnumeratedConstant1_Value); + A380FacComputer_Y.out.bus_outputs.rudder_trim_pos_deg.Data = static_cast + (A380FacComputer_U.in.analog_inputs.rudder_trim_position_deg); + A380FacComputer_DWork.Delay_DSTATE = rtb_Gain; + A380FacComputer_DWork.Delay_DSTATE_d = rtb_vs1g; + A380FacComputer_DWork.icLoad = false; + } else { + A380FacComputer_DWork.Runtime_MODE = false; + } +} + +void A380FacComputer::initialize() +{ + A380FacComputer_DWork.Delay_DSTATE = A380FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition; + A380FacComputer_DWork.Delay_DSTATE_d = A380FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition_l; + A380FacComputer_DWork.Memory_PreviousInput = A380FacComputer_P.SRFlipFlop_initial_condition; + A380FacComputer_DWork.icLoad = true; + A380FacComputer_Y.out = A380FacComputer_P.out_Y0; +} + +void A380FacComputer::terminate() +{ +} + +A380FacComputer::A380FacComputer(): + A380FacComputer_U(), + A380FacComputer_Y(), + A380FacComputer_DWork() +{ +} + +A380FacComputer::~A380FacComputer() = default; diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer.h b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer.h similarity index 65% rename from fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer.h rename to fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer.h index 997bcfd7dc7..eeeeff7fb73 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer.h +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer.h @@ -1,46 +1,46 @@ -#ifndef FacComputer_h_ -#define FacComputer_h_ +#ifndef A380FacComputer_h_ +#define A380FacComputer_h_ #include "rtwtypes.h" -#include "FacComputer_types.h" +#include "A380FacComputer_types.h" -class FacComputer final +class A380FacComputer final { public: - struct rtDW_LagFilter_FacComputer_T { + struct rtDW_LagFilter_A380FacComputer_T { real_T pY; real_T pU; boolean_T pY_not_empty; boolean_T pU_not_empty; }; - struct rtDW_RateLimiter_FacComputer_T { + struct rtDW_RateLimiter_A380FacComputer_T { real_T pY; boolean_T pY_not_empty; }; - struct rtDW_LagFilter_FacComputer_g_T { + struct rtDW_LagFilter_A380FacComputer_g_T { real32_T pY; real32_T pU; boolean_T pY_not_empty; boolean_T pU_not_empty; }; - struct rtDW_RateLimiter_FacComputer_b_T { + struct rtDW_RateLimiter_A380FacComputer_b_T { real_T pY; boolean_T pY_not_empty; }; - struct rtDW_RateLimiter_FacComputer_d_T { + struct rtDW_RateLimiter_A380FacComputer_d_T { real_T pY; boolean_T pY_not_empty; }; - struct rtDW_MATLABFunction_FacComputer_f_T { + struct rtDW_MATLABFunction_A380FacComputer_f_T { real_T timeSinceCondition; boolean_T output; }; - struct D_Work_FacComputer_T { + struct D_Work_A380FacComputer_T { real_T Delay_DSTATE; real_T Delay_DSTATE_d; real_T Delay_DSTATE_dc; @@ -50,8 +50,8 @@ class FacComputer final real_T takeoff_config_c; real_T takeoff_config_g; real_T sAlphaFloor; - uint8_T is_active_c15_FacComputer; - uint8_T is_c15_FacComputer; + uint8_T is_active_c15_A380FacComputer; + uint8_T is_c15_A380FacComputer; boolean_T Memory_PreviousInput; boolean_T icLoad; boolean_T pY_not_empty; @@ -59,38 +59,38 @@ class FacComputer final boolean_T previousInput; boolean_T previousInput_not_empty; boolean_T Runtime_MODE; - rtDW_MATLABFunction_FacComputer_f_T sf_MATLABFunction_jf; - rtDW_MATLABFunction_FacComputer_f_T sf_MATLABFunction_a; - rtDW_MATLABFunction_FacComputer_f_T sf_MATLABFunction_p; - rtDW_RateLimiter_FacComputer_d_T sf_RateLimiter_fu; - rtDW_RateLimiter_FacComputer_d_T sf_RateLimiter_l; - rtDW_RateLimiter_FacComputer_d_T sf_RateLimiter_p; - rtDW_RateLimiter_FacComputer_b_T sf_RateLimiter_g0; - rtDW_RateLimiter_FacComputer_b_T sf_RateLimiter_g; - rtDW_RateLimiter_FacComputer_b_T sf_RateLimiter_f; - rtDW_LagFilter_FacComputer_T sf_LagFilter_i; - rtDW_LagFilter_FacComputer_T sf_LagFilter_c; - rtDW_LagFilter_FacComputer_g_T sf_LagFilter_d5; - rtDW_LagFilter_FacComputer_T sf_LagFilter_f; - rtDW_LagFilter_FacComputer_g_T sf_LagFilter_k; - rtDW_LagFilter_FacComputer_T sf_LagFilter_d; - rtDW_RateLimiter_FacComputer_T sf_RateLimiter_a; - rtDW_RateLimiter_FacComputer_T sf_RateLimiter_n; - rtDW_RateLimiter_FacComputer_T sf_RateLimiter_j; - rtDW_RateLimiter_FacComputer_T sf_RateLimiter_c; - rtDW_RateLimiter_FacComputer_T sf_RateLimiter; - rtDW_LagFilter_FacComputer_T sf_LagFilter; + rtDW_MATLABFunction_A380FacComputer_f_T sf_MATLABFunction_jf; + rtDW_MATLABFunction_A380FacComputer_f_T sf_MATLABFunction_a; + rtDW_MATLABFunction_A380FacComputer_f_T sf_MATLABFunction_p; + rtDW_RateLimiter_A380FacComputer_d_T sf_RateLimiter_fu; + rtDW_RateLimiter_A380FacComputer_d_T sf_RateLimiter_l; + rtDW_RateLimiter_A380FacComputer_d_T sf_RateLimiter_p; + rtDW_RateLimiter_A380FacComputer_b_T sf_RateLimiter_g0; + rtDW_RateLimiter_A380FacComputer_b_T sf_RateLimiter_g; + rtDW_RateLimiter_A380FacComputer_b_T sf_RateLimiter_f; + rtDW_LagFilter_A380FacComputer_T sf_LagFilter_i; + rtDW_LagFilter_A380FacComputer_T sf_LagFilter_c; + rtDW_LagFilter_A380FacComputer_g_T sf_LagFilter_d5; + rtDW_LagFilter_A380FacComputer_T sf_LagFilter_f; + rtDW_LagFilter_A380FacComputer_g_T sf_LagFilter_k; + rtDW_LagFilter_A380FacComputer_T sf_LagFilter_d; + rtDW_RateLimiter_A380FacComputer_T sf_RateLimiter_a; + rtDW_RateLimiter_A380FacComputer_T sf_RateLimiter_n; + rtDW_RateLimiter_A380FacComputer_T sf_RateLimiter_j; + rtDW_RateLimiter_A380FacComputer_T sf_RateLimiter_c; + rtDW_RateLimiter_A380FacComputer_T sf_RateLimiter; + rtDW_LagFilter_A380FacComputer_T sf_LagFilter; }; - struct ExternalInputs_FacComputer_T { + struct ExternalInputs_A380FacComputer_T { fac_inputs in; }; - struct ExternalOutputs_FacComputer_T { + struct ExternalOutputs_A380FacComputer_T { fac_outputs out; }; - struct Parameters_FacComputer_T { + struct Parameters_A380FacComputer_T { base_fac_analog_outputs fac_analog_output_MATLABStruct; base_fac_laws_outputs fac_laws_output_MATLABStruct; base_fac_discrete_outputs fac_discrete_output_MATLABStruct; @@ -213,21 +213,24 @@ class FacComputer final real_T Saturation1_UpperSat_o; real_T Saturation1_LowerSat_n; real_T Gain_Gain_k; - real_T alphafloor_tableData[24]; - real_T alphafloor_bp01Data[4]; - real_T alphafloor_bp02Data[6]; - real_T Gain3_Gain; - real_T alpha0_tableData[6]; - real_T alpha0_bp01Data[6]; real_T alphamax_tableData[24]; real_T alphamax_bp01Data[4]; real_T alphamax_bp02Data[6]; real_T alphaprotection_tableData[24]; real_T alphaprotection_bp01Data[4]; real_T alphaprotection_bp02Data[6]; - real_T alphastallwarn_tableData[24]; - real_T alphastallwarn_bp01Data[4]; - real_T alphastallwarn_bp02Data[6]; + real_T Gain3_Gain; + real_T alpha0_tableData[6]; + real_T alpha0_bp01Data[6]; + real_T alphamax_tableData_b[24]; + real_T alphamax_bp01Data_m[4]; + real_T alphamax_bp02Data_a[6]; + real_T alphaprotection_tableData_p[24]; + real_T alphaprotection_bp01Data_b[4]; + real_T alphaprotection_bp02Data_m[6]; + real_T alphamax1_tableData[24]; + real_T alphamax1_bp01Data[4]; + real_T alphamax1_bp02Data[6]; real_T Gain2_Gain_d; real_T uDLookupTable1_tableData[96]; real_T uDLookupTable1_bp01Data[8]; @@ -310,10 +313,11 @@ class FacComputer final real32_T Constant21_Value; real32_T Constant4_Value_b; real32_T Constant26_Value; - uint32_T alphafloor_maxIndex[2]; uint32_T alphamax_maxIndex[2]; uint32_T alphaprotection_maxIndex[2]; - uint32_T alphastallwarn_maxIndex[2]; + uint32_T alphamax_maxIndex_g[2]; + uint32_T alphaprotection_maxIndex_m[2]; + uint32_T alphamax1_maxIndex[2]; uint32_T uDLookupTable1_maxIndex[2]; uint32_T nDLookupTable_maxIndex[3]; uint32_T nDLookupTable_dimSizes[3]; @@ -348,55 +352,55 @@ class FacComputer final boolean_T Constant19_Value; }; - FacComputer(FacComputer const&) = delete; - FacComputer& operator= (FacComputer const&) & = delete; - FacComputer(FacComputer &&) = delete; - FacComputer& operator= (FacComputer &&) = delete; - void setExternalInputs(const ExternalInputs_FacComputer_T *pExternalInputs_FacComputer_T) + A380FacComputer(A380FacComputer const&) = delete; + A380FacComputer& operator= (A380FacComputer const&) & = delete; + A380FacComputer(A380FacComputer &&) = delete; + A380FacComputer& operator= (A380FacComputer &&) = delete; + void setExternalInputs(const ExternalInputs_A380FacComputer_T *pExternalInputs_A380FacComputer_T) { - FacComputer_U = *pExternalInputs_FacComputer_T; + A380FacComputer_U = *pExternalInputs_A380FacComputer_T; } - const ExternalOutputs_FacComputer_T &getExternalOutputs() const + const ExternalOutputs_A380FacComputer_T &getExternalOutputs() const { - return FacComputer_Y; + return A380FacComputer_Y; } void initialize(); void step(); static void terminate(); - FacComputer(); - ~FacComputer(); + A380FacComputer(); + ~A380FacComputer(); private: - ExternalInputs_FacComputer_T FacComputer_U; - ExternalOutputs_FacComputer_T FacComputer_Y; - D_Work_FacComputer_T FacComputer_DWork; - static Parameters_FacComputer_T FacComputer_P; - static void FacComputer_MATLABFunction(const base_arinc_429 *rtu_u, boolean_T *rty_y); - static void FacComputer_MATLABFunction_g(const base_arinc_429 *rtu_u, real_T rtu_bit, uint32_T *rty_y); - static void FacComputer_LagFilter_Reset(rtDW_LagFilter_FacComputer_T *localDW); - static void FacComputer_LagFilter(real_T rtu_U, real_T rtu_C1, real_T rtu_dt, real_T *rty_Y, - rtDW_LagFilter_FacComputer_T *localDW); - static void FacComputer_RateLimiter_Reset(rtDW_RateLimiter_FacComputer_T *localDW); - static void FacComputer_RateLimiter(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, boolean_T rtu_reset, - real_T *rty_Y, rtDW_RateLimiter_FacComputer_T *localDW); - static void FacComputer_CalculateV_alpha_max(real_T rtu_v_ias, real_T rtu_alpha, real_T rtu_alpha_0, real_T + ExternalInputs_A380FacComputer_T A380FacComputer_U; + ExternalOutputs_A380FacComputer_T A380FacComputer_Y; + D_Work_A380FacComputer_T A380FacComputer_DWork; + static Parameters_A380FacComputer_T A380FacComputer_P; + static void A380FacComputer_MATLABFunction(const base_arinc_429 *rtu_u, boolean_T *rty_y); + static void A380FacComputer_MATLABFunction_g(const base_arinc_429 *rtu_u, real_T rtu_bit, uint32_T *rty_y); + static void A380FacComputer_LagFilter_Reset(rtDW_LagFilter_A380FacComputer_T *localDW); + static void A380FacComputer_LagFilter(real_T rtu_U, real_T rtu_C1, real_T rtu_dt, real_T *rty_Y, + rtDW_LagFilter_A380FacComputer_T *localDW); + static void A380FacComputer_RateLimiter_Reset(rtDW_RateLimiter_A380FacComputer_T *localDW); + static void A380FacComputer_RateLimiter(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, boolean_T rtu_reset, + real_T *rty_Y, rtDW_RateLimiter_A380FacComputer_T *localDW); + static void A380FacComputer_CalculateV_alpha_max(real_T rtu_v_ias, real_T rtu_alpha, real_T rtu_alpha_0, real_T rtu_alpha_target, real_T *rty_V_alpha_target); - static void FacComputer_LagFilter_n_Reset(rtDW_LagFilter_FacComputer_g_T *localDW); - static void FacComputer_LagFilter_k(real32_T rtu_U, real_T rtu_C1, real_T rtu_dt, real32_T *rty_Y, - rtDW_LagFilter_FacComputer_g_T *localDW); - static void FacComputer_VS1GfromVLS(real_T rtu_vls_conf_0, real_T rtu_vls_conf_other, real_T rtu_flap_handle_index, + static void A380FacComputer_LagFilter_c_Reset(rtDW_LagFilter_A380FacComputer_g_T *localDW); + static void A380FacComputer_LagFilter_k(real32_T rtu_U, real_T rtu_C1, real_T rtu_dt, real32_T *rty_Y, + rtDW_LagFilter_A380FacComputer_g_T *localDW); + static void A380FacComputer_VS1GfromVLS(real_T rtu_vls_conf_0, real_T rtu_vls_conf_other, real_T rtu_flap_handle_index, real_T *rty_vs1g); - static void FacComputer_RateLimiter_o_Reset(rtDW_RateLimiter_FacComputer_b_T *localDW); - static void FacComputer_RateLimiter_f(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T rtu_init, - boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_FacComputer_b_T *localDW); - static void FacComputer_RateLimiter_ot_Reset(rtDW_RateLimiter_FacComputer_d_T *localDW); - static void FacComputer_RateLimiter_p(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T rtu_init, - boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_FacComputer_d_T *localDW); - static void FacComputer_MATLABFunction_i_Reset(rtDW_MATLABFunction_FacComputer_f_T *localDW); - static void FacComputer_MATLABFunction_p(boolean_T rtu_u, real_T rtu_Ts, boolean_T rtu_isRisingEdge, real_T - rtu_timeDelay, boolean_T *rty_y, rtDW_MATLABFunction_FacComputer_f_T *localDW); - static void FacComputer_MATLABFunction_g3(const boolean_T rtu_u[19], real32_T *rty_y); + static void A380FacComputer_RateLimiter_o_Reset(rtDW_RateLimiter_A380FacComputer_b_T *localDW); + static void A380FacComputer_RateLimiter_f(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T rtu_init, + boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_A380FacComputer_b_T *localDW); + static void A380FacComputer_RateLimiter_h_Reset(rtDW_RateLimiter_A380FacComputer_d_T *localDW); + static void A380FacComputer_RateLimiter_p(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T rtu_init, + boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_A380FacComputer_d_T *localDW); + static void A380FacComputer_MATLABFunction_pm_Reset(rtDW_MATLABFunction_A380FacComputer_f_T *localDW); + static void A380FacComputer_MATLABFunction_p(boolean_T rtu_u, real_T rtu_Ts, boolean_T rtu_isRisingEdge, real_T + rtu_timeDelay, boolean_T *rty_y, rtDW_MATLABFunction_A380FacComputer_f_T *localDW); + static void A380FacComputer_MATLABFunction_g3(const boolean_T rtu_u[19], real32_T *rty_y); }; #endif diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_data.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_data.cpp similarity index 96% rename from fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_data.cpp rename to fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_data.cpp index 908fb9e8b76..c29ad1697fd 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_data.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_data.cpp @@ -1,6 +1,6 @@ -#include "FacComputer.h" +#include "A380FacComputer.h" -FacComputer::Parameters_FacComputer_T FacComputer::FacComputer_P{ +A380FacComputer::Parameters_A380FacComputer_T A380FacComputer::A380FacComputer_P{ { 0.0, 0.0, @@ -1797,34 +1797,41 @@ FacComputer::Parameters_FacComputer_T FacComputer::FacComputer_P{ 1.0, 57.295779513082323, - { 7.6, 7.6, 6.03, 6.03, 12.5, 12.5, 12.5, 12.5, 12.7, 12.7, 12.7, 12.7, 13.1, 13.1, 13.1, 13.1, 12.1, 12.1, 12.1, 12.1, - 11.8, 11.8, 11.8, 11.8 }, + { 11.0, 11.0, 11.0, 11.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 14.0, 14.0, 14.0, 14.0, 13.4, 13.4, 13.4, + 13.4, 13.4, 13.4, 13.4, 13.4 }, { 0.0, 0.5, 0.9, 1.0 }, { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }, - 1.0, - { -1.08, -2.73, -5.35, -7.22, -10.89, -11.49 }, + { 9.0, 9.0, 9.0, 9.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 12.0, 12.0, 12.0, 12.0, 11.3, 11.3, 11.3, 11.3, + 11.3, 11.3, 11.3, 11.3 }, + + { 0.0, 0.5, 0.9, 1.0 }, { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }, + 0.5, - { 8.7, 8.7, 6.4, 6.4, 13.6, 13.6, 13.6, 13.6, 13.6, 13.6, 13.6, 13.6, 14.2, 14.2, 14.2, 14.2, 13.1, 13.1, 13.1, 13.1, - 13.0, 13.0, 13.0, 13.0 }, + { -1.08, -1.09, -4.07, -5.69, -7.95, -8.6 }, + + { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }, + + { 11.0, 11.0, 11.0, 11.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 14.0, 14.0, 14.0, 14.0, 13.4, 13.4, 13.4, + 13.4, 13.4, 13.4, 13.4, 13.4 }, { 0.0, 0.5, 0.9, 1.0 }, { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }, - { 6.5, 6.5, 4.6, 4.6, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.9, 11.9, 11.9, 11.9, 11.0, 11.0, 11.0, 11.0, - 10.6, 10.6, 10.6, 10.6 }, + { 9.0, 9.0, 9.0, 9.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 12.0, 12.0, 12.0, 12.0, 11.3, 11.3, 11.3, 11.3, + 11.3, 11.3, 11.3, 11.3 }, { 0.0, 0.5, 0.9, 1.0 }, { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }, - { 6.5, 6.5, 4.6, 4.6, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.9, 11.9, 11.9, 11.9, 11.0, 11.0, 11.0, 11.0, - 10.6, 10.6, 10.6, 10.6 }, + { 11.0, 11.0, 11.0, 11.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 14.0, 14.0, 14.0, 14.0, 13.4, 13.4, 13.4, + 13.4, 13.4, 13.4, 13.4, 13.4 }, { 0.0, 0.5, 0.9, 1.0 }, @@ -2003,6 +2010,8 @@ FacComputer::Parameters_FacComputer_T FacComputer::FacComputer_P{ { 3U, 5U }, + { 3U, 5U }, + { 7U, 11U }, { 7U, 1U, 5U }, diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_private.h b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_private.h new file mode 100644 index 00000000000..2f66ac02e9b --- /dev/null +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_private.h @@ -0,0 +1,6 @@ +#ifndef A380FacComputer_private_h_ +#define A380FacComputer_private_h_ +#include "rtwtypes.h" +#include "A380FacComputer_types.h" +#endif + diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_types.h b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_types.h similarity index 99% rename from fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_types.h rename to fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_types.h index 96aff7c2da0..869eb3c81a3 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_types.h +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380FacComputer_types.h @@ -1,5 +1,5 @@ -#ifndef FacComputer_types_h_ -#define FacComputer_types_h_ +#ifndef A380FacComputer_types_h_ +#define A380FacComputer_types_h_ #include "rtwtypes.h" #ifndef DEFINED_TYPEDEF_FOR_SignStatusMatrix_ #define DEFINED_TYPEDEF_FOR_SignStatusMatrix_ @@ -14,14 +14,17 @@ enum class SignStatusMatrix #endif -#ifndef DEFINED_TYPEDEF_FOR_base_fac_analog_outputs_ -#define DEFINED_TYPEDEF_FOR_base_fac_analog_outputs_ +#ifndef DEFINED_TYPEDEF_FOR_base_fac_discrete_outputs_ +#define DEFINED_TYPEDEF_FOR_base_fac_discrete_outputs_ -struct base_fac_analog_outputs +struct base_fac_discrete_outputs { - real_T yaw_damper_order_deg; - real_T rudder_trim_order_deg; - real_T rudder_travel_limit_order_deg; + boolean_T fac_healthy; + boolean_T yaw_damper_engaged; + boolean_T rudder_trim_engaged; + boolean_T rudder_travel_lim_engaged; + boolean_T rudder_travel_lim_emergency_reset; + boolean_T yaw_damper_avail_for_norm_law; }; #endif @@ -74,17 +77,14 @@ struct base_fac_bus #endif -#ifndef DEFINED_TYPEDEF_FOR_base_fac_discrete_outputs_ -#define DEFINED_TYPEDEF_FOR_base_fac_discrete_outputs_ +#ifndef DEFINED_TYPEDEF_FOR_base_fac_analog_outputs_ +#define DEFINED_TYPEDEF_FOR_base_fac_analog_outputs_ -struct base_fac_discrete_outputs +struct base_fac_analog_outputs { - boolean_T fac_healthy; - boolean_T yaw_damper_engaged; - boolean_T rudder_trim_engaged; - boolean_T rudder_travel_lim_engaged; - boolean_T rudder_travel_lim_emergency_reset; - boolean_T yaw_damper_avail_for_norm_law; + real_T yaw_damper_order_deg; + real_T rudder_trim_order_deg; + real_T rudder_travel_limit_order_deg; }; #endif diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer.cpp deleted file mode 100644 index 8a553996b18..00000000000 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer.cpp +++ /dev/null @@ -1,1422 +0,0 @@ -#include "FacComputer.h" -#include "FacComputer_types.h" -#include "rtwtypes.h" -#include -#include "look2_binlxpw.h" -#include "look1_binlxpw.h" -#include "plook_binx.h" -#include "intrp3d_l_pw.h" - -const uint8_T FacComputer_IN_Flying{ 1U }; - -const uint8_T FacComputer_IN_Landed{ 2U }; - -const uint8_T FacComputer_IN_Landing100ft{ 3U }; - -const uint8_T FacComputer_IN_NO_ACTIVE_CHILD{ 0U }; - -const uint8_T FacComputer_IN_Takeoff100ft{ 4U }; - -void FacComputer::FacComputer_MATLABFunction(const base_arinc_429 *rtu_u, boolean_T *rty_y) -{ - *rty_y = (rtu_u->SSM != static_cast(SignStatusMatrix::FailureWarning)); -} - -void FacComputer::FacComputer_MATLABFunction_g(const base_arinc_429 *rtu_u, real_T rtu_bit, uint32_T *rty_y) -{ - real32_T tmp; - uint32_T a; - tmp = std::round(rtu_u->Data); - if (tmp < 4.2949673E+9F) { - if (tmp >= 0.0F) { - a = static_cast(tmp); - } else { - a = 0U; - } - } else { - a = MAX_uint32_T; - } - - if (-(rtu_bit - 1.0) >= 0.0) { - if (-(rtu_bit - 1.0) <= 31.0) { - a <<= static_cast(-(rtu_bit - 1.0)); - } else { - a = 0U; - } - } else if (-(rtu_bit - 1.0) >= -31.0) { - a >>= static_cast(rtu_bit - 1.0); - } else { - a = 0U; - } - - *rty_y = a & 1U; -} - -void FacComputer::FacComputer_LagFilter_Reset(rtDW_LagFilter_FacComputer_T *localDW) -{ - localDW->pY_not_empty = false; - localDW->pU_not_empty = false; -} - -void FacComputer::FacComputer_LagFilter(real_T rtu_U, real_T rtu_C1, real_T rtu_dt, real_T *rty_Y, - rtDW_LagFilter_FacComputer_T *localDW) -{ - real_T ca; - real_T denom_tmp; - if ((!localDW->pY_not_empty) || (!localDW->pU_not_empty)) { - localDW->pU = rtu_U; - localDW->pU_not_empty = true; - localDW->pY = rtu_U; - localDW->pY_not_empty = true; - } - - denom_tmp = rtu_dt * rtu_C1; - ca = denom_tmp / (denom_tmp + 2.0); - *rty_Y = (2.0 - denom_tmp) / (denom_tmp + 2.0) * localDW->pY + (rtu_U * ca + localDW->pU * ca); - localDW->pY = *rty_Y; - localDW->pU = rtu_U; -} - -void FacComputer::FacComputer_RateLimiter_Reset(rtDW_RateLimiter_FacComputer_T *localDW) -{ - localDW->pY_not_empty = false; -} - -void FacComputer::FacComputer_RateLimiter(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, boolean_T rtu_reset, - real_T *rty_Y, rtDW_RateLimiter_FacComputer_T *localDW) -{ - if ((!localDW->pY_not_empty) || rtu_reset) { - localDW->pY = rtu_u; - localDW->pY_not_empty = true; - } - - if (rtu_reset) { - *rty_Y = rtu_u; - } else { - *rty_Y = std::fmax(std::fmin(rtu_u - localDW->pY, std::abs(rtu_up) * rtu_Ts), -std::abs(rtu_lo) * rtu_Ts) + - localDW->pY; - } - - localDW->pY = *rty_Y; -} - -void FacComputer::FacComputer_CalculateV_alpha_max(real_T rtu_v_ias, real_T rtu_alpha, real_T rtu_alpha_0, real_T - rtu_alpha_target, real_T *rty_V_alpha_target) -{ - *rty_V_alpha_target = std::sqrt(std::abs(rtu_alpha - rtu_alpha_0) / (rtu_alpha_target - rtu_alpha_0)) * rtu_v_ias; -} - -void FacComputer::FacComputer_LagFilter_n_Reset(rtDW_LagFilter_FacComputer_g_T *localDW) -{ - localDW->pY_not_empty = false; - localDW->pU_not_empty = false; -} - -void FacComputer::FacComputer_LagFilter_k(real32_T rtu_U, real_T rtu_C1, real_T rtu_dt, real32_T *rty_Y, - rtDW_LagFilter_FacComputer_g_T *localDW) -{ - real_T ca; - real_T denom_tmp; - if ((!localDW->pY_not_empty) || (!localDW->pU_not_empty)) { - localDW->pU = rtu_U; - localDW->pU_not_empty = true; - localDW->pY = rtu_U; - localDW->pY_not_empty = true; - } - - denom_tmp = rtu_dt * rtu_C1; - ca = denom_tmp / (denom_tmp + 2.0); - *rty_Y = static_cast((2.0 - denom_tmp) / (denom_tmp + 2.0)) * localDW->pY + (rtu_U * static_cast - (ca) + localDW->pU * static_cast(ca)); - localDW->pY = *rty_Y; - localDW->pU = rtu_U; -} - -void FacComputer::FacComputer_VS1GfromVLS(real_T rtu_vls_conf_0, real_T rtu_vls_conf_other, real_T rtu_flap_handle_index, - real_T *rty_vs1g) -{ - if (rtu_flap_handle_index == 0.0) { - *rty_vs1g = rtu_vls_conf_0 / 1.23; - } else { - *rty_vs1g = rtu_vls_conf_other / 1.23; - } -} - -void FacComputer::FacComputer_RateLimiter_o_Reset(rtDW_RateLimiter_FacComputer_b_T *localDW) -{ - localDW->pY_not_empty = false; -} - -void FacComputer::FacComputer_RateLimiter_f(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T rtu_init, - boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_FacComputer_b_T *localDW) -{ - if ((!localDW->pY_not_empty) || rtu_reset) { - localDW->pY = rtu_init; - localDW->pY_not_empty = true; - } - - if (rtu_reset) { - *rty_Y = rtu_init; - } else { - *rty_Y = std::fmax(std::fmin(rtu_u - localDW->pY, std::abs(rtu_up) * rtu_Ts), -std::abs(rtu_lo) * rtu_Ts) + - localDW->pY; - } - - localDW->pY = *rty_Y; -} - -void FacComputer::FacComputer_RateLimiter_ot_Reset(rtDW_RateLimiter_FacComputer_d_T *localDW) -{ - localDW->pY_not_empty = false; -} - -void FacComputer::FacComputer_RateLimiter_p(real_T rtu_u, real_T rtu_up, real_T rtu_lo, real_T rtu_Ts, real_T rtu_init, - boolean_T rtu_reset, real_T *rty_Y, rtDW_RateLimiter_FacComputer_d_T *localDW) -{ - if ((!localDW->pY_not_empty) || rtu_reset) { - localDW->pY = rtu_init; - localDW->pY_not_empty = true; - } - - if (rtu_reset) { - *rty_Y = rtu_init; - } else { - *rty_Y = std::fmax(std::fmin(rtu_u - localDW->pY, std::abs(rtu_up) * rtu_Ts), -std::abs(rtu_lo) * rtu_Ts) + - localDW->pY; - } - - localDW->pY = *rty_Y; -} - -void FacComputer::FacComputer_MATLABFunction_i_Reset(rtDW_MATLABFunction_FacComputer_f_T *localDW) -{ - localDW->output = false; - localDW->timeSinceCondition = 0.0; -} - -void FacComputer::FacComputer_MATLABFunction_p(boolean_T rtu_u, real_T rtu_Ts, boolean_T rtu_isRisingEdge, real_T - rtu_timeDelay, boolean_T *rty_y, rtDW_MATLABFunction_FacComputer_f_T *localDW) -{ - if (rtu_u == rtu_isRisingEdge) { - localDW->timeSinceCondition += rtu_Ts; - if (localDW->timeSinceCondition >= rtu_timeDelay) { - localDW->output = rtu_u; - } - } else { - localDW->timeSinceCondition = 0.0; - localDW->output = rtu_u; - } - - *rty_y = localDW->output; -} - -void FacComputer::FacComputer_MATLABFunction_g3(const boolean_T rtu_u[19], real32_T *rty_y) -{ - uint32_T out; - out = 0U; - for (int32_T i{0}; i < 19; i++) { - out |= static_cast(rtu_u[i]) << (i + 10); - } - - *rty_y = static_cast(out); -} - -void FacComputer::step() -{ - real_T fractions[3]; - real_T fractions_0[3]; - real_T fractions_1[3]; - real_T fractions_2[3]; - real_T Vcas; - real_T rtb_BusAssignment_c_flight_envelope_v_ls_kn; - real_T rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg; - real_T rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn; - real_T rtb_BusAssignment_f_flight_envelope_v_fe_next_kn; - real_T rtb_BusAssignment_f_flight_envelope_v_stall_kn; - real_T rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn; - real_T rtb_Gain; - real_T rtb_Switch; - real_T rtb_Switch1; - real_T rtb_Switch4_f; - real_T rtb_Switch6; - real_T rtb_Switch_b; - real_T rtb_Y_br; - real_T rtb_Y_g4; - real_T rtb_Y_l; - real_T rtb_beta; - real_T rtb_conf; - real_T rtb_vs1g; - real_T rtb_vs1g_h; - int32_T rtb_alpha_floor_inhib; - int32_T rtb_speed_trend_kn_SSM; - int32_T rtb_v_3_kn_SSM; - int32_T rtb_v_4_kn_SSM; - int32_T rtb_v_alpha_prot_kn_SSM; - int32_T rtb_v_ls_kn_SSM; - int32_T rtb_v_man_kn_SSM; - int32_T rtb_v_stall_kn_SSM; - int32_T rtb_v_stall_warn_kn_SSM; - real32_T rtb_DataTypeConversion2; - real32_T rtb_Switch_i_idx_0; - real32_T rtb_Switch_i_idx_1; - real32_T rtb_Switch_i_idx_2; - real32_T rtb_Switch_i_idx_3; - real32_T rtb_V_ias; - real32_T rtb_V_tas; - real32_T rtb_alpha; - real32_T rtb_alt; - real32_T rtb_mach; - real32_T rtb_n_x; - real32_T rtb_n_y; - real32_T rtb_n_z; - real32_T rtb_p_s_c; - real32_T rtb_phi; - real32_T rtb_phi_dot; - real32_T rtb_q; - real32_T rtb_r; - real32_T rtb_theta; - real32_T rtb_theta_dot; - real32_T rtb_y_a; - real32_T rtb_y_oi; - uint32_T bpIndices[3]; - uint32_T bpIndices_0[3]; - uint32_T bpIndices_1[3]; - uint32_T bpIndices_2[3]; - uint32_T rtb_y_ep; - uint32_T rtb_y_ig; - uint32_T rtb_y_l2; - uint32_T rtb_y_m; - uint32_T rtb_y_os; - uint32_T rtb_y_p; - uint32_T rtb_y_ph; - boolean_T rtb_VectorConcatenate[19]; - boolean_T rtb_VectorConcatenate_i[19]; - boolean_T guard1; - boolean_T rtb_AND; - boolean_T rtb_AND1; - boolean_T rtb_AND1_d; - boolean_T rtb_BusAssignment_d_flight_envelope_beta_target_visible; - boolean_T rtb_BusAssignment_d_logic_speed_scale_visible; - boolean_T rtb_BusAssignment_f_flight_envelope_v_3_visible; - boolean_T rtb_BusAssignment_h_logic_on_ground; - boolean_T rtb_BusAssignment_logic_lgciu_own_valid; - boolean_T rtb_BusAssignment_m_logic_sfcc_own_valid; - boolean_T rtb_DataTypeConversion_f5; - boolean_T rtb_DataTypeConversion_gi; - boolean_T rtb_DataTypeConversion_kr; - boolean_T rtb_DataTypeConversion_l3; - boolean_T rtb_DataTypeConversion_l5; - boolean_T rtb_DataTypeConversion_o; - boolean_T rtb_Memory; - boolean_T rtb_OR1; - boolean_T rtb_Switch_io_idx_1; - boolean_T rtb_Switch_io_idx_2; - boolean_T rtb_rudderTravelLimEngaged; - boolean_T rtb_rudderTrimEngaged; - boolean_T rtb_y_b4; - boolean_T rtb_y_h; - boolean_T rtb_y_ool; - boolean_T rtb_yawDamperEngaged; - boolean_T rudderTravelLimCanEngage; - boolean_T rudderTravelLimHasPriority; - boolean_T rudderTrimCanEngage; - boolean_T rudderTrimHasPriority; - boolean_T yawDamperCanEngage; - boolean_T yawDamperHasPriority; - if (FacComputer_U.in.sim_data.computer_running) { - if (!FacComputer_DWork.Runtime_MODE) { - FacComputer_DWork.Delay_DSTATE = FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition; - FacComputer_DWork.Delay_DSTATE_d = FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition_l; - FacComputer_DWork.Memory_PreviousInput = FacComputer_P.SRFlipFlop_initial_condition; - FacComputer_DWork.icLoad = true; - FacComputer_MATLABFunction_i_Reset(&FacComputer_DWork.sf_MATLABFunction_a); - FacComputer_MATLABFunction_i_Reset(&FacComputer_DWork.sf_MATLABFunction_jf); - FacComputer_MATLABFunction_i_Reset(&FacComputer_DWork.sf_MATLABFunction_p); - FacComputer_LagFilter_Reset(&FacComputer_DWork.sf_LagFilter_d); - FacComputer_LagFilter_n_Reset(&FacComputer_DWork.sf_LagFilter_k); - FacComputer_LagFilter_Reset(&FacComputer_DWork.sf_LagFilter_f); - FacComputer_LagFilter_n_Reset(&FacComputer_DWork.sf_LagFilter_d5); - FacComputer_LagFilter_Reset(&FacComputer_DWork.sf_LagFilter_c); - FacComputer_RateLimiter_Reset(&FacComputer_DWork.sf_RateLimiter); - FacComputer_LagFilter_Reset(&FacComputer_DWork.sf_LagFilter); - FacComputer_DWork.is_active_c15_FacComputer = 0U; - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_NO_ACTIVE_CHILD; - FacComputer_DWork.sAlphaFloor = 0.0; - FacComputer_RateLimiter_Reset(&FacComputer_DWork.sf_RateLimiter_c); - FacComputer_RateLimiter_Reset(&FacComputer_DWork.sf_RateLimiter_a); - FacComputer_RateLimiter_Reset(&FacComputer_DWork.sf_RateLimiter_n); - FacComputer_RateLimiter_Reset(&FacComputer_DWork.sf_RateLimiter_j); - FacComputer_RateLimiter_o_Reset(&FacComputer_DWork.sf_RateLimiter_g0); - FacComputer_DWork.takeoff_config = 0.0; - FacComputer_RateLimiter_o_Reset(&FacComputer_DWork.sf_RateLimiter_g); - FacComputer_DWork.takeoff_config_c = 0.0; - FacComputer_DWork.takeoff_config_g = 0.0; - FacComputer_LagFilter_Reset(&FacComputer_DWork.sf_LagFilter_i); - FacComputer_RateLimiter_o_Reset(&FacComputer_DWork.sf_RateLimiter_f); - FacComputer_DWork.previousInput_not_empty = false; - FacComputer_RateLimiter_ot_Reset(&FacComputer_DWork.sf_RateLimiter_l); - FacComputer_DWork.pY_not_empty = false; - FacComputer_DWork.pU_not_empty = false; - FacComputer_RateLimiter_ot_Reset(&FacComputer_DWork.sf_RateLimiter_fu); - FacComputer_RateLimiter_ot_Reset(&FacComputer_DWork.sf_RateLimiter_p); - FacComputer_DWork.Runtime_MODE = true; - } - - FacComputer_MATLABFunction(&FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_1, &rtb_y_b4); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_2, - FacComputer_P.BitfromLabel_bit, &rtb_y_ep); - FacComputer_MATLABFunction_p((FacComputer_U.in.discrete_inputs.nose_gear_pressed == (rtb_y_ep != 0U)), - FacComputer_U.in.time.dt, FacComputer_P.ConfirmNode_isRisingEdge, FacComputer_P.ConfirmNode_timeDelay, &rtb_y_ool, - &FacComputer_DWork.sf_MATLABFunction_a); - rtb_Memory = (rtb_y_b4 && rtb_y_ool); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_2, - FacComputer_P.BitfromLabel5_bit, &rtb_y_p); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_2, - FacComputer_P.BitfromLabel6_bit, &rtb_y_l2); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_3, - FacComputer_P.BitfromLabel7_bit, &rtb_y_ph); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.lgciu_own_bus.discrete_word_3, - FacComputer_P.BitfromLabel8_bit, &rtb_y_ig); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel1_bit, &rtb_y_ep); - FacComputer_MATLABFunction(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, &rtb_y_b4); - rtb_AND1 = ((rtb_y_ep != 0U) && rtb_y_b4); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel4_bit, &rtb_y_m); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel3_bit, &rtb_y_os); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel2_bit, &rtb_y_ep); - if (rtb_Memory) { - rtb_y_b4 = (rtb_y_p != 0U); - rtb_Switch_io_idx_1 = (rtb_y_l2 != 0U); - rtb_Switch_io_idx_2 = ((rtb_y_ph != 0U) || (rtb_y_ig != 0U)); - } else if (rtb_AND1) { - rtb_y_b4 = (rtb_y_m != 0U); - rtb_Switch_io_idx_1 = (rtb_y_os != 0U); - rtb_Switch_io_idx_2 = (rtb_y_ep != 0U); - } else { - rtb_y_b4 = FacComputer_P.Constant_Value_c; - rtb_Switch_io_idx_1 = FacComputer_P.Constant_Value_c; - rtb_Switch_io_idx_2 = FacComputer_P.Constant_Value_c; - } - - rtb_BusAssignment_logic_lgciu_own_valid = rtb_Memory; - rtb_AND1 = ((!rtb_Memory) && (!rtb_AND1)); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel1_bit_d, &rtb_y_ep); - FacComputer_MATLABFunction(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, &rtb_y_ool); - rtb_AND1_d = ((rtb_y_ep != 0U) && rtb_y_ool); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel8_bit_i, &rtb_y_p); - rtb_DataTypeConversion_gi = (rtb_y_p != 0U); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel9_bit, &rtb_y_l2); - rtb_DataTypeConversion_l5 = (rtb_y_l2 != 0U); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel10_bit, &rtb_y_ph); - rtb_DataTypeConversion_o = (rtb_y_ph != 0U); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel11_bit, &rtb_y_ig); - rtb_DataTypeConversion_f5 = (rtb_y_ig != 0U); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_5, - FacComputer_P.BitfromLabel12_bit, &rtb_y_ep); - rtb_DataTypeConversion_l3 = (rtb_y_ep != 0U); - FacComputer_MATLABFunction(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, &rtb_Memory); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_actual_position_word, - FacComputer_P.BitfromLabel_bit_m, &rtb_y_ep); - FacComputer_MATLABFunction_p((FacComputer_U.in.discrete_inputs.slats_extended != (rtb_y_ep != 0U)), - FacComputer_U.in.time.dt, FacComputer_P.ConfirmNode_isRisingEdge_a, FacComputer_P.ConfirmNode_timeDelay_m, - &rtb_y_ool, &FacComputer_DWork.sf_MATLABFunction_jf); - rtb_DataTypeConversion_kr = (rtb_Memory && rtb_y_ool); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, - FacComputer_P.BitfromLabel2_bit_n, &rtb_y_ep); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, - FacComputer_P.BitfromLabel3_bit_i, &rtb_y_ig); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, - FacComputer_P.BitfromLabel4_bit_p, &rtb_y_ph); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, - FacComputer_P.BitfromLabel5_bit_g, &rtb_y_m); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, - FacComputer_P.BitfromLabel6_bit_n, &rtb_y_p); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_system_status_word, - FacComputer_P.BitfromLabel7_bit_p, &rtb_y_l2); - if (rtb_DataTypeConversion_kr) { - if (rtb_y_ep != 0U) { - rtb_Switch_i_idx_0 = 0.0F; - } else if ((rtb_y_ig != 0U) && (rtb_y_l2 != 0U)) { - rtb_Switch_i_idx_0 = 1.0F; - } else if ((rtb_y_ig != 0U) && (rtb_y_l2 == 0U)) { - rtb_Switch_i_idx_0 = 2.0F; - } else if (rtb_y_ph != 0U) { - rtb_Switch_i_idx_0 = 3.0F; - } else if (rtb_y_m != 0U) { - rtb_Switch_i_idx_0 = 4.0F; - } else if (rtb_y_p != 0U) { - rtb_Switch_i_idx_0 = 5.0F; - } else { - rtb_Switch_i_idx_0 = 0.0F; - } - - rtb_Switch_i_idx_1 = FacComputer_U.in.bus_inputs.sfcc_own_bus.flap_actual_position_deg.Data; - rtb_Switch_i_idx_2 = FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_actual_position_deg.Data; - rtb_Switch_i_idx_3 = FacComputer_U.in.bus_inputs.sfcc_own_bus.slat_flap_actual_position_word.Data; - } else if (rtb_AND1_d) { - if (rtb_DataTypeConversion_gi) { - rtb_Switch_i_idx_0 = 1.0F; - } else if (rtb_DataTypeConversion_l5) { - rtb_Switch_i_idx_0 = 2.0F; - } else if (rtb_DataTypeConversion_o) { - rtb_Switch_i_idx_0 = 3.0F; - } else if (rtb_DataTypeConversion_f5) { - rtb_Switch_i_idx_0 = 4.0F; - } else if (rtb_DataTypeConversion_l3) { - rtb_Switch_i_idx_0 = 5.0F; - } else { - rtb_Switch_i_idx_0 = 0.0F; - } - - rtb_Switch_i_idx_1 = FacComputer_U.in.bus_inputs.fac_opp_bus.fac_flap_angle_deg.Data; - rtb_Switch_i_idx_2 = FacComputer_U.in.bus_inputs.fac_opp_bus.fac_slat_angle_deg.Data; - rtb_Switch_i_idx_3 = FacComputer_U.in.bus_inputs.fac_opp_bus.discrete_word_1.Data; - } else if (rtb_Switch_io_idx_2) { - rtb_Switch_i_idx_0 = FacComputer_P.Constant2_Value_k; - rtb_Switch_i_idx_1 = FacComputer_P.Constant3_Value_d; - rtb_Switch_i_idx_2 = FacComputer_P.Constant6_Value; - rtb_Switch_i_idx_3 = FacComputer_P.Constant4_Value_j; - } else { - rtb_Switch_i_idx_0 = FacComputer_P.Constant1_Value_c; - rtb_Switch_i_idx_1 = FacComputer_P.Constant1_Value_c; - rtb_Switch_i_idx_2 = FacComputer_P.Constant1_Value_c; - rtb_Switch_i_idx_3 = FacComputer_P.Constant1_Value_c; - } - - rtb_Memory = ((FacComputer_U.in.bus_inputs.adr_own_bus.airspeed_computed_kn.SSM == static_cast - (SignStatusMatrix::FailureWarning)) || (FacComputer_U.in.bus_inputs.adr_own_bus.aoa_corrected_deg.SSM - == static_cast(SignStatusMatrix::FailureWarning))); - rtb_DataTypeConversion_gi = ((FacComputer_U.in.bus_inputs.adr_opp_bus.airspeed_computed_kn.SSM == - static_cast(SignStatusMatrix::FailureWarning)) || - (FacComputer_U.in.bus_inputs.adr_opp_bus.aoa_corrected_deg.SSM == static_cast(SignStatusMatrix:: - FailureWarning))); - rtb_DataTypeConversion_l5 = ((FacComputer_U.in.bus_inputs.adr_3_bus.airspeed_computed_kn.SSM == static_cast - (SignStatusMatrix::FailureWarning)) || (FacComputer_U.in.bus_inputs.adr_3_bus.aoa_corrected_deg.SSM == - static_cast(SignStatusMatrix::FailureWarning))); - rtb_DataTypeConversion_o = ((FacComputer_U.in.bus_inputs.ir_own_bus.body_yaw_rate_deg_s.SSM != static_cast - (SignStatusMatrix::NormalOperation)) || (FacComputer_U.in.bus_inputs.ir_own_bus.body_lat_accel_g.SSM != - static_cast(SignStatusMatrix::NormalOperation))); - rtb_DataTypeConversion_f5 = ((FacComputer_U.in.bus_inputs.ir_opp_bus.body_yaw_rate_deg_s.SSM != static_cast - (SignStatusMatrix::NormalOperation)) || (FacComputer_U.in.bus_inputs.ir_opp_bus.body_lat_accel_g.SSM != - static_cast(SignStatusMatrix::NormalOperation))); - rtb_DataTypeConversion_l3 = ((FacComputer_U.in.bus_inputs.ir_3_bus.body_yaw_rate_deg_s.SSM != static_cast - (SignStatusMatrix::NormalOperation)) || (FacComputer_U.in.bus_inputs.ir_3_bus.body_lat_accel_g.SSM != static_cast< - uint32_T>(SignStatusMatrix::NormalOperation))); - if (!rtb_Memory) { - rtb_V_ias = FacComputer_U.in.bus_inputs.adr_own_bus.airspeed_computed_kn.Data; - rtb_V_tas = FacComputer_U.in.bus_inputs.adr_own_bus.airspeed_true_kn.Data; - rtb_mach = FacComputer_U.in.bus_inputs.adr_own_bus.mach.Data; - rtb_alpha = FacComputer_U.in.bus_inputs.adr_own_bus.aoa_corrected_deg.Data; - rtb_p_s_c = FacComputer_U.in.bus_inputs.adr_own_bus.corrected_average_static_pressure.Data; - rtb_alt = FacComputer_U.in.bus_inputs.adr_own_bus.altitude_corrected_ft.Data; - } else if (!rtb_DataTypeConversion_l5) { - rtb_V_ias = FacComputer_U.in.bus_inputs.adr_3_bus.airspeed_computed_kn.Data; - rtb_V_tas = FacComputer_U.in.bus_inputs.adr_3_bus.airspeed_true_kn.Data; - rtb_mach = FacComputer_U.in.bus_inputs.adr_3_bus.mach.Data; - rtb_alpha = FacComputer_U.in.bus_inputs.adr_3_bus.aoa_corrected_deg.Data; - rtb_p_s_c = FacComputer_U.in.bus_inputs.adr_3_bus.corrected_average_static_pressure.Data; - rtb_alt = FacComputer_U.in.bus_inputs.adr_own_bus.altitude_corrected_ft.Data; - } else { - rtb_V_ias = 0.0F; - rtb_V_tas = 0.0F; - rtb_mach = 0.0F; - rtb_alpha = 0.0F; - rtb_p_s_c = 0.0F; - rtb_alt = 0.0F; - } - - if (!rtb_DataTypeConversion_o) { - rtb_theta = FacComputer_U.in.bus_inputs.ir_own_bus.pitch_angle_deg.Data; - rtb_phi = FacComputer_U.in.bus_inputs.ir_own_bus.roll_angle_deg.Data; - rtb_q = FacComputer_U.in.bus_inputs.ir_own_bus.body_pitch_rate_deg_s.Data; - rtb_r = FacComputer_U.in.bus_inputs.ir_own_bus.body_yaw_rate_deg_s.Data; - rtb_n_x = FacComputer_U.in.bus_inputs.ir_own_bus.body_long_accel_g.Data; - rtb_n_y = FacComputer_U.in.bus_inputs.ir_own_bus.body_lat_accel_g.Data; - rtb_n_z = FacComputer_U.in.bus_inputs.ir_own_bus.body_normal_accel_g.Data; - rtb_theta_dot = FacComputer_U.in.bus_inputs.ir_own_bus.pitch_att_rate_deg_s.Data; - rtb_phi_dot = FacComputer_U.in.bus_inputs.ir_own_bus.roll_att_rate_deg_s.Data; - } else if (!rtb_DataTypeConversion_l3) { - rtb_theta = FacComputer_U.in.bus_inputs.ir_3_bus.pitch_angle_deg.Data; - rtb_phi = FacComputer_U.in.bus_inputs.ir_3_bus.roll_angle_deg.Data; - rtb_q = FacComputer_U.in.bus_inputs.ir_3_bus.body_pitch_rate_deg_s.Data; - rtb_r = FacComputer_U.in.bus_inputs.ir_3_bus.body_yaw_rate_deg_s.Data; - rtb_n_x = FacComputer_U.in.bus_inputs.ir_3_bus.body_long_accel_g.Data; - rtb_n_y = FacComputer_U.in.bus_inputs.ir_3_bus.body_lat_accel_g.Data; - rtb_n_z = FacComputer_U.in.bus_inputs.ir_3_bus.body_normal_accel_g.Data; - rtb_theta_dot = FacComputer_U.in.bus_inputs.ir_3_bus.pitch_att_rate_deg_s.Data; - rtb_phi_dot = FacComputer_U.in.bus_inputs.ir_3_bus.roll_att_rate_deg_s.Data; - } else { - rtb_theta = 0.0F; - rtb_phi = 0.0F; - rtb_q = 0.0F; - rtb_r = 0.0F; - rtb_n_x = 0.0F; - rtb_n_y = 0.0F; - rtb_n_z = 0.0F; - rtb_theta_dot = 0.0F; - rtb_phi_dot = 0.0F; - } - - rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn = rtb_phi; - rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn = rtb_q; - rtb_vs1g_h = rtb_r; - rtb_vs1g = rtb_n_x; - rtb_Switch1 = rtb_theta_dot; - rtb_BusAssignment_m_logic_sfcc_own_valid = rtb_DataTypeConversion_kr; - rtb_AND1_d = ((!rtb_DataTypeConversion_kr) && (!rtb_AND1_d)); - rtb_DataTypeConversion_kr = (rtb_y_b4 || rtb_Switch_io_idx_1); - yawDamperCanEngage = (FacComputer_U.in.discrete_inputs.yaw_damper_has_hyd_press && - FacComputer_U.in.discrete_inputs.fac_engaged_from_switch); - rtb_y_ool = !FacComputer_U.in.discrete_inputs.is_unit_1; - yawDamperHasPriority = (FacComputer_U.in.discrete_inputs.is_unit_1 || (rtb_y_ool && - (!FacComputer_U.in.discrete_inputs.yaw_damper_opp_engaged))); - rtb_yawDamperEngaged = (yawDamperCanEngage && yawDamperHasPriority); - rudderTrimCanEngage = (FacComputer_U.in.discrete_inputs.rudder_trim_actuator_healthy && - FacComputer_U.in.discrete_inputs.fac_engaged_from_switch); - rudderTrimHasPriority = (FacComputer_U.in.discrete_inputs.is_unit_1 || (rtb_y_ool && - (!FacComputer_U.in.discrete_inputs.rudder_trim_opp_engaged))); - rtb_rudderTrimEngaged = (rudderTrimCanEngage && rudderTrimHasPriority); - rudderTravelLimCanEngage = (FacComputer_U.in.discrete_inputs.rudder_travel_lim_actuator_healthy && - FacComputer_U.in.discrete_inputs.fac_engaged_from_switch); - rudderTravelLimHasPriority = (FacComputer_U.in.discrete_inputs.is_unit_1 || (rtb_y_ool && - (!FacComputer_U.in.discrete_inputs.rudder_travel_lim_opp_engaged))); - rtb_rudderTravelLimEngaged = (rudderTravelLimCanEngage && rudderTravelLimHasPriority); - rtb_OR1 = !rtb_DataTypeConversion_kr; - FacComputer_MATLABFunction_p(rtb_OR1, FacComputer_U.in.time.dt, FacComputer_P.ConfirmNode_isRisingEdge_o, - FacComputer_P.ConfirmNode_timeDelay_l, &rtb_y_ool, &FacComputer_DWork.sf_MATLABFunction_p); - rtb_BusAssignment_h_logic_on_ground = rtb_DataTypeConversion_kr; - Vcas = rtb_V_ias * 0.5144; - if (rtb_V_ias >= 30.0F) { - rtb_beta = rtb_n_y * 9.81 / (Vcas * Vcas * 0.6125 * 122.0 / (70000.0 * Vcas) * -0.62 * Vcas) * 180.0 / - 3.1415926535897931; - } else { - rtb_beta = 0.0; - } - - FacComputer_LagFilter(rtb_beta, FacComputer_P.LagFilter1_C1, FacComputer_U.in.time.dt, &Vcas, - &FacComputer_DWork.sf_LagFilter_d); - FacComputer_LagFilter_k(FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data - - FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data, FacComputer_P.LagFilter1_C1_d, - FacComputer_U.in.time.dt, &rtb_y_oi, &FacComputer_DWork.sf_LagFilter_k); - if (rtb_alpha > FacComputer_P.Saturation_UpperSat_a) { - rtb_Y_br = FacComputer_P.Saturation_UpperSat_a; - } else if (rtb_alpha < FacComputer_P.Saturation_LowerSat_l) { - rtb_Y_br = FacComputer_P.Saturation_LowerSat_l; - } else { - rtb_Y_br = rtb_alpha; - } - - FacComputer_LagFilter(rtb_Y_br, FacComputer_P.LagFilter2_C1, FacComputer_U.in.time.dt, &rtb_Switch1, - &FacComputer_DWork.sf_LagFilter_f); - FacComputer_LagFilter_k(FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data - - FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data, FacComputer_P.LagFilter3_C1, - FacComputer_U.in.time.dt, &rtb_y_a, &FacComputer_DWork.sf_LagFilter_d5); - if (rtb_V_ias > FacComputer_P.Saturation1_UpperSat_o) { - rtb_Switch6 = FacComputer_P.Saturation1_UpperSat_o; - } else if (rtb_V_ias < FacComputer_P.Saturation1_LowerSat_n) { - rtb_Switch6 = FacComputer_P.Saturation1_LowerSat_n; - } else { - rtb_Switch6 = rtb_V_ias; - } - - rtb_beta = (rtb_Switch1 * rtb_y_a * FacComputer_P.Gain5_Gain + FacComputer_P.Gain4_Gain_o * rtb_y_oi) / rtb_Switch6 / - rtb_Switch6 * FacComputer_P.Gain_Gain_k; - FacComputer_LagFilter(static_cast(rtb_alpha), FacComputer_P.LagFilter_C1, FacComputer_U.in.time.dt, - &rtb_Switch6, &FacComputer_DWork.sf_LagFilter_c); - rtb_BusAssignment_d_logic_speed_scale_visible = rtb_y_ool; - rtb_BusAssignment_d_flight_envelope_beta_target_visible = ((std::abs - (FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data - - FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data) >= FacComputer_P.CompareToConstant_const_f) && - ((FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_left_percent.Data > FacComputer_P.CompareToConstant1_const_l) || - (FacComputer_U.in.bus_inputs.fmgc_own_bus.n1_right_percent.Data > FacComputer_P.CompareToConstant2_const_i))); - rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg = rtb_Switch6; - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_2, - FacComputer_P.BitfromLabel6_bit_m, &rtb_y_ep); - rtb_DataTypeConversion_kr = (rtb_y_ep != 0U); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_2, - FacComputer_P.BitfromLabel7_bit_i, &rtb_y_ep); - FacComputer_RateLimiter(look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), - FacComputer_P.alphafloor_bp01Data, FacComputer_P.alphafloor_bp02Data, FacComputer_P.alphafloor_tableData, - FacComputer_P.alphafloor_maxIndex, 4U), FacComputer_P.RateLimiterGenericVariableTs1_up, - FacComputer_P.RateLimiterGenericVariableTs1_lo, FacComputer_U.in.time.dt, FacComputer_P.reset_Value, &rtb_Switch1, - &FacComputer_DWork.sf_RateLimiter); - rtb_Gain = FacComputer_P.DiscreteDerivativeVariableTs_Gain * rtb_V_ias; - rtb_Switch6 = rtb_Gain - FacComputer_DWork.Delay_DSTATE; - FacComputer_LagFilter(rtb_Switch6 / FacComputer_U.in.time.dt, FacComputer_P.LagFilter_C1_k, FacComputer_U.in.time.dt, - &rtb_Switch6, &FacComputer_DWork.sf_LagFilter); - FacComputer_MATLABFunction(&FacComputer_U.in.bus_inputs.fmgc_own_bus.fg_radio_height_ft, &rtb_y_ool); - if (rtb_y_ool) { - rtb_Switch = FacComputer_U.in.bus_inputs.fmgc_own_bus.fg_radio_height_ft.Data; - } else { - rtb_Switch = FacComputer_P.Constant_Value; - } - - if (FacComputer_DWork.is_active_c15_FacComputer == 0) { - FacComputer_DWork.is_active_c15_FacComputer = 1U; - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Landed; - rtb_alpha_floor_inhib = 1; - } else { - switch (FacComputer_DWork.is_c15_FacComputer) { - case FacComputer_IN_Flying: - if (rtb_Switch < 100.0) { - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Landing100ft; - rtb_alpha_floor_inhib = 1; - } else if (rtb_BusAssignment_h_logic_on_ground) { - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Landed; - rtb_alpha_floor_inhib = 1; - } else { - rtb_alpha_floor_inhib = 0; - } - break; - - case FacComputer_IN_Landed: - if (rtb_OR1) { - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Takeoff100ft; - rtb_alpha_floor_inhib = 0; - } else { - rtb_alpha_floor_inhib = 1; - } - break; - - case FacComputer_IN_Landing100ft: - if (rtb_Switch > 100.0) { - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Flying; - rtb_alpha_floor_inhib = 0; - } else if (rtb_BusAssignment_h_logic_on_ground) { - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Landed; - rtb_alpha_floor_inhib = 1; - } else { - rtb_alpha_floor_inhib = 1; - } - break; - - default: - if (rtb_BusAssignment_h_logic_on_ground) { - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Landed; - rtb_alpha_floor_inhib = 1; - } else if (rtb_Switch > 100.0) { - FacComputer_DWork.is_c15_FacComputer = FacComputer_IN_Flying; - rtb_alpha_floor_inhib = 0; - } else { - rtb_alpha_floor_inhib = 0; - } - break; - } - } - - guard1 = false; - if ((rtb_alpha_floor_inhib == 0) && (rtb_mach < 0.6)) { - if (rtb_Switch_i_idx_0 >= 4.0F) { - rtb_v_ls_kn_SSM = -3; - } else { - rtb_v_ls_kn_SSM = 0; - } - - if ((rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg > FacComputer_P.Gain3_Gain * rtb_Switch1 + std::fmin - (std::fmax(rtb_Switch6, static_cast(rtb_v_ls_kn_SSM)), 0.0)) && FacComputer_P.Constant1_Value_mf) { - FacComputer_DWork.sAlphaFloor = 1.0; - } else { - guard1 = true; - } - } else { - guard1 = true; - } - - if (guard1) { - if ((rtb_alpha_floor_inhib != 0) || ((!rtb_DataTypeConversion_kr) && (rtb_y_ep == 0U)) || - (!FacComputer_P.Constant1_Value_mf)) { - FacComputer_DWork.sAlphaFloor = 0.0; - } - } - - rtb_Switch6 = rtb_Switch_i_idx_0; - FacComputer_RateLimiter(look1_binlxpw(static_cast(rtb_Switch_i_idx_0), FacComputer_P.alpha0_bp01Data, - FacComputer_P.alpha0_tableData, 5U), FacComputer_P.RateLimiterGenericVariableTs1_up_g, - FacComputer_P.RateLimiterGenericVariableTs1_lo_n, FacComputer_U.in.time.dt, FacComputer_P.reset_Value_k, - &rtb_vs1g_h, &FacComputer_DWork.sf_RateLimiter_c); - FacComputer_RateLimiter(look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), - FacComputer_P.alphamax_bp01Data, FacComputer_P.alphamax_bp02Data, FacComputer_P.alphamax_tableData, - FacComputer_P.alphamax_maxIndex, 4U), FacComputer_P.RateLimiterGenericVariableTs4_up, - FacComputer_P.RateLimiterGenericVariableTs4_lo, FacComputer_U.in.time.dt, FacComputer_P.reset_Value_o, - &rtb_Switch1, &FacComputer_DWork.sf_RateLimiter_a); - FacComputer_CalculateV_alpha_max(static_cast(rtb_V_ias), - rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg, rtb_vs1g_h, rtb_Switch1, - &rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn); - FacComputer_RateLimiter(look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), - FacComputer_P.alphaprotection_bp01Data, FacComputer_P.alphaprotection_bp02Data, - FacComputer_P.alphaprotection_tableData, FacComputer_P.alphaprotection_maxIndex, 4U), - FacComputer_P.RateLimiterGenericVariableTs3_up, FacComputer_P.RateLimiterGenericVariableTs3_lo, - FacComputer_U.in.time.dt, FacComputer_P.reset_Value_a, &rtb_Switch1, &FacComputer_DWork.sf_RateLimiter_n); - FacComputer_CalculateV_alpha_max(static_cast(rtb_V_ias), - rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg, rtb_vs1g_h, rtb_Switch1, - &rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn); - FacComputer_RateLimiter(look2_binlxpw(static_cast(rtb_mach), static_cast(rtb_Switch_i_idx_0), - FacComputer_P.alphastallwarn_bp01Data, FacComputer_P.alphastallwarn_bp02Data, - FacComputer_P.alphastallwarn_tableData, FacComputer_P.alphastallwarn_maxIndex, 4U), - FacComputer_P.RateLimiterGenericVariableTs2_up, FacComputer_P.RateLimiterGenericVariableTs2_lo, - FacComputer_U.in.time.dt, FacComputer_P.reset_Value_i, &rtb_Switch6, &FacComputer_DWork.sf_RateLimiter_j); - FacComputer_CalculateV_alpha_max(static_cast(rtb_V_ias), - rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg, rtb_vs1g_h, rtb_Switch6, &rtb_Switch); - if (FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_weight_lbs.SSM == static_cast(SignStatusMatrix:: - NormalOperation)) { - rtb_DataTypeConversion2 = FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_weight_lbs.Data; - } else { - rtb_DataTypeConversion2 = FacComputer_U.in.bus_inputs.fmgc_own_bus.fac_weight_lbs.Data; - } - - rtb_Switch6 = FacComputer_P.Gain2_Gain_d * rtb_DataTypeConversion2; - bpIndices[0U] = plook_binx(rtb_Switch6, FacComputer_P.nDLookupTable_bp01Data, 7U, &rtb_vs1g); - fractions[0U] = rtb_vs1g; - bpIndices[1U] = plook_binx(FacComputer_P.Gain3_Gain_h * FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, - FacComputer_P.nDLookupTable_bp02Data, 1U, &rtb_vs1g); - fractions[1U] = rtb_vs1g; - bpIndices[2U] = plook_binx(static_cast(rtb_Switch_i_idx_0), FacComputer_P.nDLookupTable_bp03Data, 5U, - &rtb_vs1g); - fractions[2U] = rtb_vs1g; - FacComputer_VS1GfromVLS(look2_binlxpw(rtb_Switch6, static_cast(rtb_alt), - FacComputer_P.uDLookupTable1_bp01Data, FacComputer_P.uDLookupTable1_bp02Data, - FacComputer_P.uDLookupTable1_tableData, FacComputer_P.uDLookupTable1_maxIndex, 8U), intrp3d_l_pw(bpIndices, - fractions, FacComputer_P.nDLookupTable_tableData, FacComputer_P.nDLookupTable_dimSizes), static_cast - (rtb_Switch_i_idx_0), &rtb_Switch6); - FacComputer_RateLimiter_f(rtb_Switch6, FacComputer_P.RateLimiterGenericVariableTs1_up_d, - FacComputer_P.RateLimiterGenericVariableTs1_lo_f, FacComputer_U.in.time.dt, - FacComputer_P.RateLimiterGenericVariableTs1_InitialCondition, FacComputer_P.reset_Value_k5, &rtb_Y_l, - &FacComputer_DWork.sf_RateLimiter_g0); - rtb_Switch6 = std::fmax(FacComputer_U.in.analog_inputs.left_spoiler_pos_deg, - FacComputer_U.in.analog_inputs.right_spoiler_pos_deg); - rtb_Switch1 = rtb_Switch6 / look1_binlxpw(static_cast(rtb_Switch_i_idx_0), - FacComputer_P.spoilermaxdeflection_bp01Data, FacComputer_P.spoilermaxdeflection_tableData, 5U) * look1_binlxpw( - static_cast(rtb_Switch_i_idx_0), FacComputer_P.VLSincreasemaxdeflection_bp01Data, - FacComputer_P.VLSincreasemaxdeflection_tableData, 5U); - rtb_OR1 = ((!rtb_AND1) && rtb_y_b4 && rtb_Switch_io_idx_1); - if (rtb_OR1) { - FacComputer_DWork.takeoff_config = rtb_Switch_i_idx_0; - } else if (FacComputer_DWork.takeoff_config != rtb_Switch_i_idx_0) { - FacComputer_DWork.takeoff_config = -1.0; - } - - if (rtb_Switch_i_idx_0 == 0.0F) { - rtb_Y_br = 1.23; - } else if (rtb_Switch_i_idx_0 == 1.0F) { - rtb_Y_br = 1.18; - } else if (FacComputer_DWork.takeoff_config != -1.0) { - rtb_Y_br = 1.15; - } else { - rtb_Y_br = 1.23; - } - - FacComputer_RateLimiter_f(rtb_Y_br, FacComputer_P.RateLimiterGenericVariableTs_up, - FacComputer_P.RateLimiterGenericVariableTs_lo, FacComputer_U.in.time.dt, - FacComputer_P.RateLimiterGenericVariableTs_InitialCondition, FacComputer_P.reset_Value_m, &rtb_Switch6, - &FacComputer_DWork.sf_RateLimiter_g); - rtb_BusAssignment_c_flight_envelope_v_ls_kn = std::fmax(FacComputer_P.Vmcl_Value, rtb_Switch6 * rtb_Y_l) + - rtb_Switch1; - rtb_Switch1 = FacComputer_P.Gain2_Gain_j * rtb_DataTypeConversion2; - bpIndices_0[0U] = plook_binx(rtb_Switch1, FacComputer_P.nDLookupTable_bp01Data_p, 7U, &rtb_vs1g); - fractions_0[0U] = rtb_vs1g; - bpIndices_0[1U] = plook_binx(FacComputer_P.Gain3_Gain_d * - FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, FacComputer_P.nDLookupTable_bp02Data_b, 1U, &rtb_vs1g); - fractions_0[1U] = rtb_vs1g; - bpIndices_0[2U] = plook_binx(FacComputer_P._Value, FacComputer_P.nDLookupTable_bp03Data_h, 5U, &rtb_vs1g); - fractions_0[2U] = rtb_vs1g; - FacComputer_VS1GfromVLS(look2_binlxpw(rtb_Switch1, static_cast(rtb_alt), - FacComputer_P.uDLookupTable1_bp01Data_p, FacComputer_P.uDLookupTable1_bp02Data_n, - FacComputer_P.uDLookupTable1_tableData_j, FacComputer_P.uDLookupTable1_maxIndex_k, 8U), intrp3d_l_pw(bpIndices_0, - fractions_0, FacComputer_P.nDLookupTable_tableData_e, FacComputer_P.nDLookupTable_dimSizes_l), - FacComputer_P._Value, &rtb_vs1g_h); - if (rtb_OR1) { - FacComputer_DWork.takeoff_config_c = rtb_Switch_i_idx_0; - FacComputer_DWork.takeoff_config_g = rtb_Switch_i_idx_0; - } else { - if (FacComputer_DWork.takeoff_config_c != rtb_Switch_i_idx_0) { - FacComputer_DWork.takeoff_config_c = -1.0; - } - - if (FacComputer_DWork.takeoff_config_g != rtb_Switch_i_idx_0) { - FacComputer_DWork.takeoff_config_g = -1.0; - } - } - - rtb_Switch1 = FacComputer_P.Gain2_Gain_o * rtb_DataTypeConversion2; - if (FacComputer_DWork.takeoff_config_g != -1.0) { - rtb_conf = 2.0; - } else { - rtb_conf = rtb_Switch_i_idx_0; - } - - bpIndices_1[0U] = plook_binx(rtb_Switch1, FacComputer_P.nDLookupTable_bp01Data_a, 7U, &rtb_vs1g); - fractions_1[0U] = rtb_vs1g; - bpIndices_1[1U] = plook_binx(FacComputer_P.Gain3_Gain_n * - FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, FacComputer_P.nDLookupTable_bp02Data_f, 1U, &rtb_vs1g); - fractions_1[1U] = rtb_vs1g; - bpIndices_1[2U] = plook_binx(rtb_conf, FacComputer_P.nDLookupTable_bp03Data_m, 5U, &rtb_vs1g); - fractions_1[2U] = rtb_vs1g; - FacComputer_VS1GfromVLS(look2_binlxpw(rtb_Switch1, static_cast(rtb_alt), - FacComputer_P.uDLookupTable1_bp01Data_a, FacComputer_P.uDLookupTable1_bp02Data_l, - FacComputer_P.uDLookupTable1_tableData_o, FacComputer_P.uDLookupTable1_maxIndex_b, 8U), intrp3d_l_pw(bpIndices_1, - fractions_1, FacComputer_P.nDLookupTable_tableData_p, FacComputer_P.nDLookupTable_dimSizes_p), rtb_conf, &rtb_vs1g); - if (static_cast(FacComputer_DWork.takeoff_config_c != -1.0) > FacComputer_P.Switch_Threshold) { - rtb_Switch1 = std::fmax(FacComputer_P.Vmcl5_Value, FacComputer_P.Gain4_Gain * rtb_vs1g_h); - } else { - rtb_Switch1 = std::fmin(FacComputer_P.Vfe_35_Value, std::fmax(rtb_vs1g * look1_binlxpw(static_cast - (rtb_Switch_i_idx_0), FacComputer_P.uDLookupTable_bp01Data, FacComputer_P.uDLookupTable_tableData, 1U), - FacComputer_P.Vmcl10_Value)); - } - - rtb_vs1g_h = FacComputer_P.Gain2_Gain_c * rtb_DataTypeConversion2; - bpIndices_2[0U] = plook_binx(rtb_vs1g_h, FacComputer_P.nDLookupTable_bp01Data_o, 7U, &rtb_vs1g); - fractions_2[0U] = rtb_vs1g; - bpIndices_2[1U] = plook_binx(FacComputer_P.Gain3_Gain_a * - FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data, FacComputer_P.nDLookupTable_bp02Data_m, 1U, &rtb_vs1g); - fractions_2[1U] = rtb_vs1g; - bpIndices_2[2U] = plook_binx(FacComputer_P.Constant2_Value_c, FacComputer_P.nDLookupTable_bp03Data_md, 5U, &rtb_vs1g); - fractions_2[2U] = rtb_vs1g; - FacComputer_VS1GfromVLS(look2_binlxpw(rtb_vs1g_h, static_cast(rtb_alt), - FacComputer_P.uDLookupTable1_bp01Data_l, FacComputer_P.uDLookupTable1_bp02Data_p, - FacComputer_P.uDLookupTable1_tableData_i, FacComputer_P.uDLookupTable1_maxIndex_g, 8U), intrp3d_l_pw(bpIndices_2, - fractions_2, FacComputer_P.nDLookupTable_tableData_k, FacComputer_P.nDLookupTable_dimSizes_i), - FacComputer_P.Constant2_Value_c, &rtb_vs1g_h); - rtb_vs1g_h = std::fmin(std::fmax(FacComputer_P.Gain2_Gain_e * rtb_vs1g_h, FacComputer_P.Vmcl20_Value), - FacComputer_P.Vfe_25_Value); - rtb_conf = look2_binlxpw(FacComputer_P.Gain3_Gain_b * rtb_DataTypeConversion2, static_cast(rtb_alt), - FacComputer_P.uDLookupTable_bp01Data_n, FacComputer_P.uDLookupTable_bp02Data, - FacComputer_P.uDLookupTable_tableData_m, FacComputer_P.uDLookupTable_maxIndex, 8U); - rtb_DataTypeConversion_kr = (rtb_Switch_i_idx_0 == FacComputer_P.CompareToConstant_const); - rtb_OR1 = ((rtb_Switch_i_idx_0 < FacComputer_P.CompareToConstant_const_i) && (rtb_alt <= - FacComputer_P.CompareToConstant1_const_i)); - if (rtb_Switch_io_idx_2) { - rtb_Y_br = FacComputer_P.Constant2_Value; - } else { - rtb_Y_br = FacComputer_P.Constant3_Value; - } - - rtb_Switch4_f = std::fmin(std::fmin(rtb_Y_br, std::sqrt(std::pow((std::pow(FacComputer_P.Constant1_Value_p * - FacComputer_P.Constant1_Value_p * 0.2 + 1.0, 3.5) - 1.0) * (rtb_p_s_c / 1013.25) + 1.0, 0.2857142857142857) - 1.0) - * 1479.1), look1_binlxpw(static_cast(rtb_Switch_i_idx_0), FacComputer_P.uDLookupTable_bp01Data_a, - FacComputer_P.uDLookupTable_tableData_a, 5U)); - if (rtb_V_ias > FacComputer_P.Saturation_UpperSat_j) { - rtb_Y_br = FacComputer_P.Saturation_UpperSat_j; - } else if (rtb_V_ias < FacComputer_P.Saturation_LowerSat_c) { - rtb_Y_br = FacComputer_P.Saturation_LowerSat_c; - } else { - rtb_Y_br = rtb_V_ias; - } - - rtb_vs1g = FacComputer_P.DiscreteDerivativeVariableTs_Gain_l * rtb_Y_br; - rtb_Switch6 = rtb_vs1g - FacComputer_DWork.Delay_DSTATE_d; - FacComputer_LagFilter(rtb_Switch6 / FacComputer_U.in.time.dt, FacComputer_P.LagFilter_C1_f, FacComputer_U.in.time.dt, - &rtb_Y_br, &FacComputer_DWork.sf_LagFilter_i); - FacComputer_RateLimiter_f(rtb_Y_br, FacComputer_P.RateLimiterGenericVariableTs_up_g, - FacComputer_P.RateLimiterGenericVariableTs_lo_e, FacComputer_U.in.time.dt, - FacComputer_P.RateLimiterGenericVariableTs_InitialCondition_o, FacComputer_P.reset_Value_i3, &rtb_Switch6, - &FacComputer_DWork.sf_RateLimiter_f); - rtb_Switch_b = FacComputer_P.Gain_Gain_j * rtb_Switch6; - rtb_BusAssignment_f_flight_envelope_v_stall_kn = rtb_Y_l; - rtb_BusAssignment_f_flight_envelope_v_3_visible = ((rtb_Switch_i_idx_0 == FacComputer_P.CompareToConstant4_const) || - (rtb_Switch_i_idx_0 == FacComputer_P.CompareToConstant2_const)); - rtb_BusAssignment_f_flight_envelope_v_fe_next_kn = look1_binlxpw(static_cast(rtb_Switch_i_idx_0), - FacComputer_P.uDLookupTable1_bp01Data_pi, FacComputer_P.uDLookupTable1_tableData_ow, 5U); - rtb_y_ool = (FacComputer_U.in.discrete_inputs.ap_own_engaged || FacComputer_U.in.discrete_inputs.ap_opp_engaged); - rtb_AND = (FacComputer_U.in.discrete_inputs.rudder_trim_reset_button && (!rtb_y_ool)); - if (!FacComputer_DWork.previousInput_not_empty) { - FacComputer_DWork.previousInput = FacComputer_P.PulseNode_isRisingEdge; - FacComputer_DWork.previousInput_not_empty = true; - } - - if (FacComputer_P.PulseNode_isRisingEdge) { - rtb_y_h = (rtb_AND && (!FacComputer_DWork.previousInput)); - } else { - rtb_y_h = ((!rtb_AND) && FacComputer_DWork.previousInput); - } - - FacComputer_DWork.previousInput = rtb_AND; - FacComputer_DWork.Memory_PreviousInput = FacComputer_P.Logic_table - [(((FacComputer_U.in.discrete_inputs.rudder_trim_switch_left || - FacComputer_U.in.discrete_inputs.rudder_trim_switch_right || rtb_y_ool) + (static_cast(rtb_y_h) << 1)) - << 1) + FacComputer_DWork.Memory_PreviousInput]; - rtb_AND = !rtb_rudderTrimEngaged; - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_1, - FacComputer_P.BitfromLabel_bit_j, &rtb_y_ph); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_1, - FacComputer_P.BitfromLabel1_bit_e, &rtb_y_ig); - if (rtb_y_ool) { - if (FacComputer_U.in.bus_inputs.fmgc_own_bus.fg_radio_height_ft.Data >= FacComputer_P.Switch6_Threshold_n) { - if ((rtb_y_ph != 0U) && FacComputer_U.in.discrete_inputs.elac_1_healthy) { - rtb_Y_br = FacComputer_U.in.bus_inputs.elac_1_bus.yaw_damper_command_deg.Data; - } else if ((rtb_y_ig != 0U) && FacComputer_U.in.discrete_inputs.elac_2_healthy) { - rtb_Y_br = FacComputer_U.in.bus_inputs.elac_2_bus.yaw_damper_command_deg.Data; - } else { - rtb_Y_br = FacComputer_P.Constant1_Value_m; - } - - rtb_Switch6 = FacComputer_P.Gain2_Gain * rtb_Y_br; - } else { - rtb_Switch6 = FacComputer_P.Constant2_Value_m; - } - - if (rtb_Switch6 > FacComputer_P.Saturation_UpperSat) { - rtb_Switch6 = FacComputer_P.Saturation_UpperSat; - } else if (rtb_Switch6 < FacComputer_P.Saturation_LowerSat) { - rtb_Switch6 = FacComputer_P.Saturation_LowerSat; - } - } else if (FacComputer_U.in.discrete_inputs.rudder_trim_switch_left) { - rtb_Switch6 = 1.0; - } else if (FacComputer_U.in.discrete_inputs.rudder_trim_switch_right) { - rtb_Switch6 = -1.0; - } else { - rtb_Switch6 = 0.0; - } - - rtb_Switch6 = FacComputer_P.DiscreteTimeIntegratorVariableTs_Gain * rtb_Switch6 * FacComputer_U.in.time.dt; - FacComputer_DWork.icLoad = (FacComputer_DWork.Memory_PreviousInput || rtb_AND || FacComputer_DWork.icLoad); - if (FacComputer_DWork.icLoad) { - if (rtb_AND) { - rtb_Y_br = FacComputer_U.in.analog_inputs.rudder_trim_position_deg; - } else { - rtb_Y_br = FacComputer_P.Constant_Value_g; - } - - FacComputer_DWork.Delay_DSTATE_dc = rtb_Y_br - rtb_Switch6; - } - - FacComputer_DWork.Delay_DSTATE_dc += rtb_Switch6; - if (FacComputer_DWork.Delay_DSTATE_dc > FacComputer_P.DiscreteTimeIntegratorVariableTs_UpperLimit) { - FacComputer_DWork.Delay_DSTATE_dc = FacComputer_P.DiscreteTimeIntegratorVariableTs_UpperLimit; - } else if (FacComputer_DWork.Delay_DSTATE_dc < FacComputer_P.DiscreteTimeIntegratorVariableTs_LowerLimit) { - FacComputer_DWork.Delay_DSTATE_dc = FacComputer_P.DiscreteTimeIntegratorVariableTs_LowerLimit; - } - - FacComputer_RateLimiter_p(FacComputer_DWork.Delay_DSTATE_dc, FacComputer_P.RateLimiterGenericVariableTs_up_l, - FacComputer_P.RateLimiterGenericVariableTs_lo_d, FacComputer_U.in.time.dt, - FacComputer_U.in.analog_inputs.rudder_trim_position_deg, rtb_AND, &rtb_Y_l, &FacComputer_DWork.sf_RateLimiter_l); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_1, - FacComputer_P.BitfromLabel_bit_c, &rtb_y_ep); - rtb_y_ool = (rtb_y_ep != 0U); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_1_bus.discrete_status_word_1, - FacComputer_P.BitfromLabel1_bit_n, &rtb_y_ep); - rtb_AND = (rtb_y_ool && FacComputer_U.in.discrete_inputs.elac_1_healthy && (rtb_y_ep != 0U)); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_1, - FacComputer_P.BitfromLabel3_bit_k, &rtb_y_ep); - rtb_y_ool = (rtb_y_ep != 0U); - FacComputer_MATLABFunction_g(&FacComputer_U.in.bus_inputs.elac_2_bus.discrete_status_word_1, - FacComputer_P.BitfromLabel4_bit_k, &rtb_y_ep); - if ((!FacComputer_DWork.pY_not_empty) || (!FacComputer_DWork.pU_not_empty)) { - FacComputer_DWork.pU = rtb_r; - FacComputer_DWork.pU_not_empty = true; - FacComputer_DWork.pY = rtb_r; - FacComputer_DWork.pY_not_empty = true; - } - - rtb_Switch6 = FacComputer_U.in.time.dt * FacComputer_P.WashoutFilter_C1; - rtb_Y_br = 2.0 / (rtb_Switch6 + 2.0); - FacComputer_DWork.pY = (2.0 - rtb_Switch6) / (rtb_Switch6 + 2.0) * FacComputer_DWork.pY + (rtb_r * rtb_Y_br - - FacComputer_DWork.pU * rtb_Y_br); - FacComputer_DWork.pU = rtb_r; - if (rtb_AND || (rtb_y_ool && FacComputer_U.in.discrete_inputs.elac_2_healthy && (rtb_y_ep != 0U))) { - if (rtb_AND) { - rtb_Switch6 = FacComputer_U.in.bus_inputs.elac_1_bus.yaw_damper_command_deg.Data; - } else { - rtb_Switch6 = FacComputer_U.in.bus_inputs.elac_2_bus.yaw_damper_command_deg.Data; - } - } else { - rtb_Switch6 = FacComputer_P.Gain_Gain * FacComputer_DWork.pY; - if (rtb_Switch6 > FacComputer_P.Saturation1_UpperSat) { - rtb_Switch6 = FacComputer_P.Saturation1_UpperSat; - } else if (rtb_Switch6 < FacComputer_P.Saturation1_LowerSat) { - rtb_Switch6 = FacComputer_P.Saturation1_LowerSat; - } - } - - if (rtb_Switch6 > FacComputer_P.Saturation_UpperSat_e) { - rtb_Switch6 = FacComputer_P.Saturation_UpperSat_e; - } else if (rtb_Switch6 < FacComputer_P.Saturation_LowerSat_o) { - rtb_Switch6 = FacComputer_P.Saturation_LowerSat_o; - } - - FacComputer_RateLimiter_p(rtb_Switch6, FacComputer_P.RateLimiterGenericVariableTs_up_a, - FacComputer_P.RateLimiterGenericVariableTs_lo_f, FacComputer_U.in.time.dt, - FacComputer_U.in.analog_inputs.yaw_damper_position_deg, !rtb_yawDamperEngaged, &rtb_Y_br, - &FacComputer_DWork.sf_RateLimiter_fu); - rtb_Switch6 = look1_binlxpw(static_cast(rtb_V_ias), FacComputer_P.uDLookupTable_bp01Data_i, - FacComputer_P.uDLookupTable_tableData_j, 6U); - if (rtb_Switch6 > FacComputer_P.Saturation_UpperSat_g) { - rtb_Switch6 = FacComputer_P.Saturation_UpperSat_g; - } else if (rtb_Switch6 < FacComputer_P.Saturation_LowerSat_f) { - rtb_Switch6 = FacComputer_P.Saturation_LowerSat_f; - } - - FacComputer_RateLimiter_p(rtb_Switch6, FacComputer_P.RateLimiterGenericVariableTs_up_c, - FacComputer_P.RateLimiterGenericVariableTs_lo_p, FacComputer_U.in.time.dt, - FacComputer_U.in.analog_inputs.rudder_travel_lim_position_deg, !rtb_rudderTravelLimEngaged, &rtb_Y_g4, - &FacComputer_DWork.sf_RateLimiter_p); - FacComputer_Y.out.bus_outputs.v_fe_next_kn.SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_VectorConcatenate[0] = rtb_yawDamperEngaged; - rtb_VectorConcatenate[1] = FacComputer_U.in.discrete_inputs.yaw_damper_opp_engaged; - rtb_VectorConcatenate[2] = rtb_rudderTrimEngaged; - rtb_VectorConcatenate[3] = FacComputer_U.in.discrete_inputs.rudder_trim_opp_engaged; - rtb_VectorConcatenate[4] = rtb_rudderTravelLimEngaged; - rtb_VectorConcatenate[5] = FacComputer_U.in.discrete_inputs.rudder_travel_lim_opp_engaged; - rtb_VectorConcatenate[6] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[7] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[8] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[9] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[10] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[11] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[12] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[13] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[14] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[15] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[16] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[17] = FacComputer_P.Constant10_Value; - rtb_VectorConcatenate[18] = FacComputer_P.Constant10_Value; - FacComputer_MATLABFunction_g3(rtb_VectorConcatenate, &rtb_y_a); - if (FacComputer_P.Constant_Value_b5) { - rtb_alpha_floor_inhib = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_v_ls_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_v_stall_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_v_alpha_prot_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_v_stall_warn_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_speed_trend_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_v_3_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_v_4_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - rtb_v_man_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - FacComputer_Y.out.bus_outputs.v_max_kn.SSM = static_cast(FacComputer_P.EnumeratedConstant2_Value); - } else { - if (rtb_BusAssignment_d_logic_speed_scale_visible) { - rtb_alpha_floor_inhib = static_cast(FacComputer_P.EnumeratedConstant1_Value); - rtb_v_ls_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - } else { - rtb_alpha_floor_inhib = static_cast(FacComputer_P.EnumeratedConstant_Value); - rtb_v_ls_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - } - - rtb_v_stall_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - if (rtb_BusAssignment_d_logic_speed_scale_visible) { - rtb_v_alpha_prot_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - rtb_v_stall_warn_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - } else { - rtb_v_alpha_prot_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - rtb_v_stall_warn_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - } - - rtb_speed_trend_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - if (rtb_BusAssignment_d_logic_speed_scale_visible && rtb_BusAssignment_f_flight_envelope_v_3_visible) { - rtb_v_3_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - } else { - rtb_v_3_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - } - - if (rtb_BusAssignment_d_logic_speed_scale_visible && ((rtb_Switch_i_idx_0 == - FacComputer_P.CompareToConstant3_const) || (rtb_Switch_i_idx_0 == FacComputer_P.CompareToConstant1_const))) - { - rtb_v_4_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - } else { - rtb_v_4_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - } - - if (rtb_BusAssignment_d_logic_speed_scale_visible && rtb_DataTypeConversion_kr) { - rtb_v_man_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - } else { - rtb_v_man_kn_SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - } - - FacComputer_Y.out.bus_outputs.v_max_kn.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - if (rtb_BusAssignment_d_logic_speed_scale_visible && rtb_OR1) { - FacComputer_Y.out.bus_outputs.v_fe_next_kn.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - } else { - FacComputer_Y.out.bus_outputs.v_fe_next_kn.SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - } - } - - rtb_VectorConcatenate[0] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[1] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[2] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[3] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[4] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[5] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[6] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[7] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[8] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[9] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[10] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[11] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[12] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[13] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[14] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[15] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[16] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[17] = FacComputer_P.Constant18_Value; - rtb_VectorConcatenate[18] = FacComputer_P.Constant18_Value; - FacComputer_MATLABFunction_g3(rtb_VectorConcatenate, &rtb_y_oi); - rtb_VectorConcatenate[0] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[1] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[2] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[3] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[4] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[5] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[6] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[7] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[8] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[9] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[10] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[11] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[12] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[13] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[14] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[15] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[16] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[17] = FacComputer_P.Constant9_Value; - rtb_VectorConcatenate[18] = FacComputer_P.Constant9_Value; - FacComputer_MATLABFunction_g3(rtb_VectorConcatenate, &FacComputer_Y.out.bus_outputs.discrete_word_4.Data); - rtb_VectorConcatenate_i[0] = (rtb_Switch_i_idx_0 == 1.0F); - rtb_VectorConcatenate_i[1] = (rtb_Switch_i_idx_0 == 2.0F); - rtb_VectorConcatenate_i[2] = (rtb_Switch_i_idx_0 == 3.0F); - rtb_VectorConcatenate_i[3] = (rtb_Switch_i_idx_0 == 4.0F); - rtb_VectorConcatenate_i[4] = (rtb_Switch_i_idx_0 == 5.0F); - rtb_VectorConcatenate_i[5] = rtb_BusAssignment_logic_lgciu_own_valid; - rtb_VectorConcatenate_i[6] = rtb_AND1; - rtb_VectorConcatenate_i[7] = rtb_y_b4; - rtb_VectorConcatenate_i[8] = rtb_Switch_io_idx_1; - rtb_VectorConcatenate_i[9] = rtb_Switch_io_idx_2; - rtb_VectorConcatenate_i[10] = rtb_BusAssignment_m_logic_sfcc_own_valid; - rtb_VectorConcatenate_i[11] = rtb_AND1_d; - rtb_VectorConcatenate_i[12] = FacComputer_P.Constant19_Value; - rtb_VectorConcatenate_i[13] = FacComputer_P.Constant19_Value; - rtb_VectorConcatenate_i[14] = FacComputer_P.Constant19_Value; - rtb_VectorConcatenate_i[15] = FacComputer_P.Constant19_Value; - rtb_VectorConcatenate_i[16] = FacComputer_P.Constant19_Value; - rtb_VectorConcatenate_i[17] = FacComputer_P.Constant19_Value; - rtb_VectorConcatenate_i[18] = (FacComputer_DWork.sAlphaFloor != 0.0); - FacComputer_MATLABFunction_g3(rtb_VectorConcatenate_i, &FacComputer_Y.out.bus_outputs.discrete_word_5.Data); - FacComputer_Y.out.data = FacComputer_U.in; - FacComputer_Y.out.laws.yaw_damper_command_deg = rtb_Y_br; - FacComputer_Y.out.laws.rudder_trim_command_deg = rtb_Y_l; - FacComputer_Y.out.laws.rudder_travel_lim_command_deg = rtb_Y_g4; - FacComputer_Y.out.logic.lgciu_own_valid = rtb_BusAssignment_logic_lgciu_own_valid; - FacComputer_Y.out.logic.all_lgciu_lost = rtb_AND1; - FacComputer_Y.out.logic.left_main_gear_pressed = rtb_y_b4; - FacComputer_Y.out.logic.right_main_gear_pressed = rtb_Switch_io_idx_1; - FacComputer_Y.out.logic.main_gear_out = rtb_Switch_io_idx_2; - FacComputer_Y.out.logic.sfcc_own_valid = rtb_BusAssignment_m_logic_sfcc_own_valid; - FacComputer_Y.out.logic.all_sfcc_lost = rtb_AND1_d; - FacComputer_Y.out.logic.flap_handle_index = rtb_Switch_i_idx_0; - FacComputer_Y.out.logic.flap_angle_deg = rtb_Switch_i_idx_1; - FacComputer_Y.out.logic.slat_angle_deg = rtb_Switch_i_idx_2; - FacComputer_Y.out.logic.slat_flap_actual_pos = rtb_Switch_i_idx_3; - FacComputer_Y.out.logic.on_ground = rtb_BusAssignment_h_logic_on_ground; - FacComputer_Y.out.logic.tracking_mode_on = (FacComputer_U.in.sim_data.slew_on || FacComputer_U.in.sim_data.pause_on || - FacComputer_U.in.sim_data.tracking_mode_on_override); - FacComputer_Y.out.logic.double_self_detected_adr_failure = ((rtb_Memory && rtb_DataTypeConversion_gi) || (rtb_Memory - && rtb_DataTypeConversion_l5) || (rtb_DataTypeConversion_gi && rtb_DataTypeConversion_l5)); - FacComputer_Y.out.logic.double_self_detected_ir_failure = ((rtb_DataTypeConversion_o && rtb_DataTypeConversion_f5) || - (rtb_DataTypeConversion_o && rtb_DataTypeConversion_l3) || (rtb_DataTypeConversion_f5 && rtb_DataTypeConversion_l3)); - FacComputer_Y.out.logic.double_not_self_detected_adr_failure = FacComputer_P.Constant_Value_h; - FacComputer_Y.out.logic.double_not_self_detected_ir_failure = FacComputer_P.Constant_Value_h; - FacComputer_Y.out.logic.adr_computation_data.V_ias_kn = rtb_V_ias; - FacComputer_Y.out.logic.adr_computation_data.V_tas_kn = rtb_V_tas; - FacComputer_Y.out.logic.adr_computation_data.mach = rtb_mach; - FacComputer_Y.out.logic.adr_computation_data.alpha_deg = rtb_alpha; - FacComputer_Y.out.logic.adr_computation_data.p_s_c_hpa = rtb_p_s_c; - FacComputer_Y.out.logic.adr_computation_data.altitude_corrected_ft = rtb_alt; - FacComputer_Y.out.logic.ir_computation_data.theta_deg = rtb_theta; - FacComputer_Y.out.logic.ir_computation_data.phi_deg = rtb_phi; - FacComputer_Y.out.logic.ir_computation_data.q_deg_s = rtb_q; - FacComputer_Y.out.logic.ir_computation_data.r_deg_s = rtb_r; - FacComputer_Y.out.logic.ir_computation_data.n_x_g = rtb_n_x; - FacComputer_Y.out.logic.ir_computation_data.n_y_g = rtb_n_y; - FacComputer_Y.out.logic.ir_computation_data.n_z_g = rtb_n_z; - FacComputer_Y.out.logic.ir_computation_data.theta_dot_deg_s = rtb_theta_dot; - FacComputer_Y.out.logic.ir_computation_data.phi_dot_deg_s = rtb_phi_dot; - FacComputer_Y.out.logic.yaw_damper_engaged = rtb_yawDamperEngaged; - FacComputer_Y.out.logic.yaw_damper_can_engage = yawDamperCanEngage; - FacComputer_Y.out.logic.yaw_damper_has_priority = yawDamperHasPriority; - FacComputer_Y.out.logic.rudder_trim_engaged = rtb_rudderTrimEngaged; - FacComputer_Y.out.logic.rudder_trim_can_engage = rudderTrimCanEngage; - FacComputer_Y.out.logic.rudder_trim_has_priority = rudderTrimHasPriority; - FacComputer_Y.out.logic.rudder_travel_lim_engaged = rtb_rudderTravelLimEngaged; - FacComputer_Y.out.logic.rudder_travel_lim_can_engage = rudderTravelLimCanEngage; - FacComputer_Y.out.logic.rudder_travel_lim_has_priority = rudderTravelLimHasPriority; - FacComputer_Y.out.logic.speed_scale_lost = FacComputer_P.Constant_Value_b5; - FacComputer_Y.out.logic.speed_scale_visible = rtb_BusAssignment_d_logic_speed_scale_visible; - FacComputer_Y.out.flight_envelope.estimated_beta_deg = Vcas; - FacComputer_Y.out.flight_envelope.beta_target_deg = rtb_beta; - FacComputer_Y.out.flight_envelope.beta_target_visible = rtb_BusAssignment_d_flight_envelope_beta_target_visible; - FacComputer_Y.out.flight_envelope.alpha_floor_condition = (FacComputer_DWork.sAlphaFloor != 0.0); - FacComputer_Y.out.flight_envelope.alpha_filtered_deg = rtb_BusAssignment_d_flight_envelope_alpha_filtered_deg; - FacComputer_Y.out.flight_envelope.computed_weight_lbs = rtb_DataTypeConversion2; - FacComputer_Y.out.flight_envelope.computed_cg_percent = FacComputer_U.in.bus_inputs.fmgc_own_bus.fm_cg_percent.Data; - FacComputer_Y.out.flight_envelope.v_alpha_max_kn = rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn; - FacComputer_Y.out.flight_envelope.v_alpha_prot_kn = rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn; - FacComputer_Y.out.flight_envelope.v_stall_warn_kn = rtb_Switch; - FacComputer_Y.out.flight_envelope.v_ls_kn = rtb_BusAssignment_c_flight_envelope_v_ls_kn; - FacComputer_Y.out.flight_envelope.v_stall_kn = rtb_BusAssignment_f_flight_envelope_v_stall_kn; - FacComputer_Y.out.flight_envelope.v_3_kn = rtb_Switch1; - FacComputer_Y.out.flight_envelope.v_3_visible = rtb_BusAssignment_f_flight_envelope_v_3_visible; - FacComputer_Y.out.flight_envelope.v_4_kn = rtb_vs1g_h; - FacComputer_Y.out.flight_envelope.v_4_visible = ((rtb_Switch_i_idx_0 == FacComputer_P.CompareToConstant3_const) || - (rtb_Switch_i_idx_0 == FacComputer_P.CompareToConstant1_const)); - FacComputer_Y.out.flight_envelope.v_man_kn = rtb_conf; - FacComputer_Y.out.flight_envelope.v_man_visible = rtb_DataTypeConversion_kr; - FacComputer_Y.out.flight_envelope.v_max_kn = rtb_Switch4_f; - FacComputer_Y.out.flight_envelope.v_fe_next_kn = rtb_BusAssignment_f_flight_envelope_v_fe_next_kn; - FacComputer_Y.out.flight_envelope.v_fe_next_visible = rtb_OR1; - FacComputer_Y.out.flight_envelope.v_c_trend_kn = rtb_Switch_b; - FacComputer_Y.out.discrete_outputs.fac_healthy = FacComputer_P.Constant2_Value_o; - FacComputer_Y.out.discrete_outputs.yaw_damper_engaged = rtb_yawDamperEngaged; - FacComputer_Y.out.discrete_outputs.rudder_trim_engaged = rtb_rudderTrimEngaged; - FacComputer_Y.out.discrete_outputs.rudder_travel_lim_engaged = rtb_rudderTravelLimEngaged; - FacComputer_Y.out.discrete_outputs.rudder_travel_lim_emergency_reset = FacComputer_P.Constant1_Value_d; - FacComputer_Y.out.discrete_outputs.yaw_damper_avail_for_norm_law = yawDamperCanEngage; - if (rtb_yawDamperEngaged) { - FacComputer_Y.out.analog_outputs.yaw_damper_order_deg = rtb_Y_br; - } else { - FacComputer_Y.out.analog_outputs.yaw_damper_order_deg = FacComputer_P.Constant_Value_b; - } - - if (rtb_rudderTrimEngaged) { - FacComputer_Y.out.analog_outputs.rudder_trim_order_deg = rtb_Y_l; - } else { - FacComputer_Y.out.analog_outputs.rudder_trim_order_deg = FacComputer_P.Constant_Value_b; - } - - if (rtb_rudderTravelLimEngaged) { - FacComputer_Y.out.analog_outputs.rudder_travel_limit_order_deg = rtb_Y_g4; - } else { - FacComputer_Y.out.analog_outputs.rudder_travel_limit_order_deg = FacComputer_P.Constant_Value_b; - } - - if (rtb_BusAssignment_m_logic_sfcc_own_valid) { - FacComputer_Y.out.bus_outputs.discrete_word_1.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - } else { - FacComputer_Y.out.bus_outputs.discrete_word_1.SSM = static_cast(FacComputer_P.EnumeratedConstant_Value); - } - - FacComputer_Y.out.bus_outputs.discrete_word_1.Data = rtb_Switch_i_idx_3; - FacComputer_Y.out.bus_outputs.gamma_a_deg.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.gamma_a_deg.Data = FacComputer_P.Constant28_Value; - FacComputer_Y.out.bus_outputs.gamma_t_deg.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.gamma_t_deg.Data = FacComputer_P.Constant22_Value; - FacComputer_Y.out.bus_outputs.total_weight_lbs.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.total_weight_lbs.Data = FacComputer_P.Constant21_Value; - FacComputer_Y.out.bus_outputs.center_of_gravity_pos_percent.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.center_of_gravity_pos_percent.Data = FacComputer_P.Constant4_Value_b; - if (FacComputer_P.Constant_Value_d > FacComputer_P.Switch7_Threshold) { - FacComputer_Y.out.bus_outputs.sideslip_target_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant2_Value); - } else if (rtb_BusAssignment_d_flight_envelope_beta_target_visible) { - FacComputer_Y.out.bus_outputs.sideslip_target_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - } else { - FacComputer_Y.out.bus_outputs.sideslip_target_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant_Value); - } - - FacComputer_Y.out.bus_outputs.sideslip_target_deg.Data = static_cast(rtb_beta); - if (rtb_BusAssignment_m_logic_sfcc_own_valid) { - FacComputer_Y.out.bus_outputs.fac_slat_angle_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - } else { - FacComputer_Y.out.bus_outputs.fac_slat_angle_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant_Value); - } - - FacComputer_Y.out.bus_outputs.fac_slat_angle_deg.Data = rtb_Switch_i_idx_2; - if (rtb_BusAssignment_m_logic_sfcc_own_valid) { - FacComputer_Y.out.bus_outputs.fac_flap_angle_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - } else { - FacComputer_Y.out.bus_outputs.fac_flap_angle_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant_Value); - } - - FacComputer_Y.out.bus_outputs.fac_flap_angle_deg.Data = rtb_Switch_i_idx_1; - FacComputer_Y.out.bus_outputs.discrete_word_2.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.discrete_word_2.Data = rtb_y_a; - FacComputer_Y.out.bus_outputs.rudder_travel_limit_command_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.rudder_travel_limit_command_deg.Data = static_cast - (FacComputer_U.in.analog_inputs.rudder_travel_lim_position_deg); - FacComputer_Y.out.bus_outputs.delta_r_yaw_damper_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.delta_r_yaw_damper_deg.Data = FacComputer_P.Constant26_Value; - if (FacComputer_P.Constant1_Value_l > FacComputer_P.Switch6_Threshold) { - FacComputer_Y.out.bus_outputs.estimated_sideslip_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant2_Value); - } else { - FacComputer_Y.out.bus_outputs.estimated_sideslip_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - } - - FacComputer_Y.out.bus_outputs.estimated_sideslip_deg.Data = static_cast(Vcas); - FacComputer_Y.out.bus_outputs.v_alpha_lim_kn.SSM = static_cast(rtb_alpha_floor_inhib); - FacComputer_Y.out.bus_outputs.v_alpha_lim_kn.Data = static_cast - (rtb_BusAssignment_f_flight_envelope_v_alpha_max_kn); - FacComputer_Y.out.bus_outputs.v_ls_kn.SSM = static_cast(rtb_v_ls_kn_SSM); - FacComputer_Y.out.bus_outputs.v_ls_kn.Data = static_cast(rtb_BusAssignment_c_flight_envelope_v_ls_kn); - FacComputer_Y.out.bus_outputs.v_stall_kn.SSM = static_cast(rtb_v_stall_kn_SSM); - FacComputer_Y.out.bus_outputs.v_stall_kn.Data = static_cast(rtb_BusAssignment_f_flight_envelope_v_stall_kn); - FacComputer_Y.out.bus_outputs.v_alpha_prot_kn.SSM = static_cast(rtb_v_alpha_prot_kn_SSM); - FacComputer_Y.out.bus_outputs.v_alpha_prot_kn.Data = static_cast - (rtb_BusAssignment_kv_flight_envelope_v_alpha_prot_kn); - FacComputer_Y.out.bus_outputs.v_stall_warn_kn.SSM = static_cast(rtb_v_stall_warn_kn_SSM); - FacComputer_Y.out.bus_outputs.v_stall_warn_kn.Data = static_cast(rtb_Switch); - FacComputer_Y.out.bus_outputs.speed_trend_kn.SSM = static_cast(rtb_speed_trend_kn_SSM); - FacComputer_Y.out.bus_outputs.speed_trend_kn.Data = static_cast(rtb_Switch_b); - FacComputer_Y.out.bus_outputs.v_3_kn.SSM = static_cast(rtb_v_3_kn_SSM); - FacComputer_Y.out.bus_outputs.v_3_kn.Data = static_cast(rtb_Switch1); - FacComputer_Y.out.bus_outputs.v_4_kn.SSM = static_cast(rtb_v_4_kn_SSM); - FacComputer_Y.out.bus_outputs.v_4_kn.Data = static_cast(rtb_vs1g_h); - FacComputer_Y.out.bus_outputs.v_man_kn.SSM = static_cast(rtb_v_man_kn_SSM); - FacComputer_Y.out.bus_outputs.v_man_kn.Data = static_cast(rtb_conf); - FacComputer_Y.out.bus_outputs.v_max_kn.Data = static_cast(rtb_Switch4_f); - FacComputer_Y.out.bus_outputs.v_fe_next_kn.Data = static_cast - (rtb_BusAssignment_f_flight_envelope_v_fe_next_kn); - FacComputer_Y.out.bus_outputs.discrete_word_3.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.discrete_word_3.Data = rtb_y_oi; - FacComputer_Y.out.bus_outputs.discrete_word_4.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.discrete_word_5.SSM = static_cast(FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.delta_r_rudder_trim_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.delta_r_rudder_trim_deg.Data = static_cast(rtb_Y_l); - FacComputer_Y.out.bus_outputs.rudder_trim_pos_deg.SSM = static_cast - (FacComputer_P.EnumeratedConstant1_Value); - FacComputer_Y.out.bus_outputs.rudder_trim_pos_deg.Data = static_cast - (FacComputer_U.in.analog_inputs.rudder_trim_position_deg); - FacComputer_DWork.Delay_DSTATE = rtb_Gain; - FacComputer_DWork.Delay_DSTATE_d = rtb_vs1g; - FacComputer_DWork.icLoad = false; - } else { - FacComputer_DWork.Runtime_MODE = false; - } -} - -void FacComputer::initialize() -{ - FacComputer_DWork.Delay_DSTATE = FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition; - FacComputer_DWork.Delay_DSTATE_d = FacComputer_P.DiscreteDerivativeVariableTs_InitialCondition_l; - FacComputer_DWork.Memory_PreviousInput = FacComputer_P.SRFlipFlop_initial_condition; - FacComputer_DWork.icLoad = true; - FacComputer_Y.out = FacComputer_P.out_Y0; -} - -void FacComputer::terminate() -{ -} - -FacComputer::FacComputer(): - FacComputer_U(), - FacComputer_Y(), - FacComputer_DWork() -{ -} - -FacComputer::~FacComputer() = default; diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_private.h b/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_private.h deleted file mode 100644 index e599224b2ad..00000000000 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/FacComputer_private.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef FacComputer_private_h_ -#define FacComputer_private_h_ -#include "rtwtypes.h" -#include "FacComputer_types.h" -#endif - From a8ea28859485c29f59a7f73e026b539eeb4a1c10 Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Thu, 2 Jan 2025 05:03:28 +0100 Subject: [PATCH 03/11] change PFD HSP bar threshold --- fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx b/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx index cdad4d1b59a..6bc9d971b96 100644 --- a/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx +++ b/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx @@ -1469,7 +1469,7 @@ class VProtBug extends DisplayComponent<{ bus: EventBus }> { private handleVProtBugDisplay() { const showVProt = this.Vmax.value > 240 && this.Vmax.isNormalOperation(); - const offset = (-(this.Vmax.value + 6) * DistanceSpacing) / ValueSpacing; + const offset = (-(this.Vmax.value + 10) * DistanceSpacing) / ValueSpacing; const isNormalLawActive = this.fcdcWord1.bitValue(11) && !this.fcdcWord1.isFailureWarning(); From 287cd2e93783055c34cee5da91cbe38168e3f4ae Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Thu, 2 Jan 2025 05:07:23 +0100 Subject: [PATCH 04/11] PRIM: New alpha prot/max LUTs --- .../src/model/A380LateralDirectLaw.cpp | 13 +- .../src/model/A380LateralNormalLaw.cpp | 178 ++-- .../src/model/A380PitchAlternateLaw.cpp | 249 +++--- .../fbw_a380/src/model/A380PitchDirectLaw.cpp | 14 +- .../fbw_a380/src/model/A380PitchNormalLaw.cpp | 804 ++++++++---------- .../src/model/A380PrimComputer_data.cpp | 8 +- .../src/model/A380PrimComputer_types.h | 100 +-- 7 files changed, 628 insertions(+), 738 deletions(-) diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralDirectLaw.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralDirectLaw.cpp index 25e23a675d5..740028926f1 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralDirectLaw.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralDirectLaw.cpp @@ -51,19 +51,16 @@ void A380LateralDirectLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ *rty_Out_xi_outboard_deg, real_T *rty_Out_xi_spoiler_deg, real_T *rty_Out_zeta_upper_deg, real_T *rty_Out_zeta_lower_deg) { - real_T rtb_Gain1; *rty_Out_xi_spoiler_deg = A380LateralDirectLaw_rtP.Constant_Value; - rtb_Gain1 = A380LateralDirectLaw_rtP.Gain1_Gain * *rtu_In_delta_xi_pos; - A380LateralDirectLaw_RateLimiter(rtb_Gain1, A380LateralDirectLaw_rtP.RateLimiterVariableTs_up, - A380LateralDirectLaw_rtP.RateLimiterVariableTs_lo, rtu_In_time_dt, + A380LateralDirectLaw_RateLimiter(A380LateralDirectLaw_rtP.Gain1_Gain * *rtu_In_delta_xi_pos, + A380LateralDirectLaw_rtP.RateLimiterVariableTs_up, A380LateralDirectLaw_rtP.RateLimiterVariableTs_lo, rtu_In_time_dt, A380LateralDirectLaw_rtP.RateLimiterVariableTs_InitialCondition, rty_Out_xi_outboard_deg, &A380LateralDirectLaw_DWork.sf_RateLimiter); *rty_Out_xi_inboard_deg = *rty_Out_xi_outboard_deg; *rty_Out_xi_midboard_deg = *rty_Out_xi_outboard_deg; - rtb_Gain1 = A380LateralDirectLaw_rtP.Gain2_Gain * *rtu_In_delta_zeta_pos; - A380LateralDirectLaw_RateLimiter(rtb_Gain1, A380LateralDirectLaw_rtP.RateLimiterVariableTs1_up, - A380LateralDirectLaw_rtP.RateLimiterVariableTs1_lo, rtu_In_time_dt, - A380LateralDirectLaw_rtP.RateLimiterVariableTs1_InitialCondition, rty_Out_zeta_lower_deg, + A380LateralDirectLaw_RateLimiter(A380LateralDirectLaw_rtP.Gain2_Gain * *rtu_In_delta_zeta_pos, + A380LateralDirectLaw_rtP.RateLimiterVariableTs1_up, A380LateralDirectLaw_rtP.RateLimiterVariableTs1_lo, + rtu_In_time_dt, A380LateralDirectLaw_rtP.RateLimiterVariableTs1_InitialCondition, rty_Out_zeta_lower_deg, &A380LateralDirectLaw_DWork.sf_RateLimiter_n); *rty_Out_zeta_upper_deg = *rty_Out_zeta_lower_deg; } diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralNormalLaw.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralNormalLaw.cpp index cf0092a03b0..f3007e7cd0f 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralNormalLaw.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380LateralNormalLaw.cpp @@ -374,24 +374,21 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ real_T Vias; real_T Vtas; real_T denom; + real_T dynamic_pressure; real_T k_phi; real_T omega_0; real_T r; - real_T rtb_Divide; - real_T rtb_Gain1_h; - real_T rtb_Gain_b; real_T rtb_Limiterxi; + real_T rtb_Product_l; + real_T rtb_Sum; real_T rtb_Y; real_T rtb_Y_j; - real_T rtb_beDot; - real_T v_cas_ms; int32_T high_i; int32_T low_i; int32_T low_ip1; int32_T mid_i; int16_T r_tmp; boolean_T rtb_NOT_h_tmp; - boolean_T rtb_OR1; static const int16_T b[4]{ 0, 120, 150, 380 }; static const int8_T c[4]{ -15, -15, -15, -2 }; @@ -413,11 +410,7 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ A380LateralNormalLaw_rtP.RateLimiterVariableTs_lo, rtu_In_time_dt, A380LateralNormalLaw_rtP.RateLimiterVariableTs_InitialCondition, &rtb_Y_j, &A380LateralNormalLaw_DWork.sf_RateLimiter); - rtb_Gain_b = A380LateralNormalLaw_rtP.Gain_Gain_c * *rtu_In_delta_xi_pos; - rtb_Gain1_h = A380LateralNormalLaw_rtP.Gain1_Gain * *rtu_In_delta_zeta_pos; - r = *rtu_In_V_ias_kn; - v_cas_ms = *rtu_In_delta_zeta_pos; - Vias = std::fmax(r, 60.0); + Vias = std::fmax(*rtu_In_V_ias_kn, 60.0); r = 0.0; if (Vias <= 380.0) { high_i = 4; @@ -448,18 +441,14 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ rtb_Limiterxi = Vias * 0.5144; A380LateralNormalLaw_RateLimiter(0.814 / std::sqrt(1.3734E+6 / (149.45000000000002 * (rtb_Limiterxi * rtb_Limiterxi))) - * (r * v_cas_ms), A380LateralNormalLaw_rtP.RateLimiterVariableTs1_up, + * (r * *rtu_In_delta_zeta_pos), A380LateralNormalLaw_rtP.RateLimiterVariableTs1_up, A380LateralNormalLaw_rtP.RateLimiterVariableTs1_lo, rtu_In_time_dt, A380LateralNormalLaw_rtP.RateLimiterVariableTs1_InitialCondition, &Vias, &A380LateralNormalLaw_DWork.sf_RateLimiter_k); - rtb_beDot = *rtu_In_r_deg_s; - denom = *rtu_In_beta_deg; - rtb_Y = *rtu_In_V_ias_kn; - Vtas = *rtu_In_V_tas_kn; rtb_Limiterxi = A380LateralNormalLaw_rtP.Gain1_Gain_o * *rtu_In_delta_xi_pos; - v_cas_ms = std::fmax(*rtu_In_V_ias_kn, 80.0) * 0.5144; - Vias = v_cas_ms * v_cas_ms * 0.6125; - L_xi = Vias * 845.0 * 39.9 * -0.0964294411726867 / 8.5E+7; + Vias = std::fmax(*rtu_In_V_ias_kn, 80.0) * 0.5144; + dynamic_pressure = Vias * Vias * 0.6125; + L_xi = dynamic_pressure * 845.0 * 39.9 * -0.0964294411726867 / 8.5E+7; if (*rtu_In_V_ias_kn > 400.0) { omega_0 = 0.8; } else if (*rtu_In_V_ias_kn < -1.0) { @@ -495,7 +484,7 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ k_phi = -(omega_0 * omega_0) / L_xi; r = A380LateralNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain * rtb_Limiterxi; - rtb_Divide = (r - A380LateralNormalLaw_DWork.Delay_DSTATE) / *rtu_In_time_dt; + rtb_Sum = r - A380LateralNormalLaw_DWork.Delay_DSTATE; if (*rtu_In_high_speed_prot_active) { A380LateralNormalLaw_DWork.Delay_DSTATE = look1_binlxpw(*rtu_In_Phi_deg, A380LateralNormalLaw_rtP.BankAngleProtection2_bp01Data, A380LateralNormalLaw_rtP.BankAngleProtection2_tableData, @@ -509,13 +498,13 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ 8U); } - A380LateralNormalLaw_DWork.Delay_DSTATE += 1.0 / omega_0 * rtb_Divide + rtb_Limiterxi; - rtb_Divide = 15.0; + A380LateralNormalLaw_DWork.Delay_DSTATE += rtb_Sum / *rtu_In_time_dt * (1.0 / omega_0) + rtb_Limiterxi; + rtb_Sum = 15.0; rtb_Limiterxi = -15.0; if (A380LateralNormalLaw_DWork.Delay1_DSTATE >= 25.0) { rtb_Limiterxi = *rtu_In_pk_deg_s; } else if (A380LateralNormalLaw_DWork.Delay1_DSTATE <= -25.0) { - rtb_Divide = *rtu_In_pk_deg_s; + rtb_Sum = *rtu_In_pk_deg_s; } if (A380LateralNormalLaw_DWork.Delay_DSTATE > A380LateralNormalLaw_rtP.Saturation3_UpperSat) { @@ -524,14 +513,13 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_rtP.Saturation3_LowerSat; } - A380LateralNormalLaw_DWork.Delay_DSTATE = std::fmin(rtb_Divide, std::fmax(rtb_Limiterxi, + A380LateralNormalLaw_DWork.Delay_DSTATE = std::fmin(rtb_Sum, std::fmax(rtb_Limiterxi, A380LateralNormalLaw_DWork.Delay_DSTATE * rtb_Y_j)) * A380LateralNormalLaw_rtP.DiscreteTimeIntegratorVariableTs_Gain * *rtu_In_time_dt; - rtb_OR1 = ((rtb_Y_j == 0.0) || (*rtu_In_tracking_mode_on) || (*rtu_In_any_ap_engaged)); - rtb_Divide = *rtu_In_Phi_deg - A380LateralNormalLaw_DWork.Delay_DSTATE; - A380LateralNormalLaw_DWork.icLoad = (rtb_OR1 || A380LateralNormalLaw_DWork.icLoad); + A380LateralNormalLaw_DWork.icLoad = ((rtb_Y_j == 0.0) || (*rtu_In_tracking_mode_on) || (*rtu_In_any_ap_engaged) || + A380LateralNormalLaw_DWork.icLoad); if (A380LateralNormalLaw_DWork.icLoad) { - A380LateralNormalLaw_DWork.Delay_DSTATE_o = rtb_Divide; + A380LateralNormalLaw_DWork.Delay_DSTATE_o = *rtu_In_Phi_deg - A380LateralNormalLaw_DWork.Delay_DSTATE; } A380LateralNormalLaw_DWork.Delay_DSTATE += A380LateralNormalLaw_DWork.Delay_DSTATE_o; @@ -546,36 +534,37 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ if (*rtu_In_any_ap_engaged) { if (*rtu_In_tracking_mode_on) { - rtb_Divide = *rtu_In_Phi_deg; + rtb_Sum = *rtu_In_Phi_deg; } else { - rtb_Divide = *rtu_In_ap_phi_c_deg; + rtb_Sum = *rtu_In_ap_phi_c_deg; } } else { - rtb_Divide = A380LateralNormalLaw_DWork.Delay_DSTATE_o; + rtb_Sum = A380LateralNormalLaw_DWork.Delay_DSTATE_o; } - Vtas = std::fmax(1.0, Vtas * 0.5144); - rtb_Limiterxi = rtb_Y * 0.5144; - if (rtb_Y >= 60.0) { - rtb_beDot = ((rtb_Limiterxi * rtb_Limiterxi * 0.6125 * 122.0 / (70000.0 * Vtas) * 0.814 * denom * 3.1415926535897931 - / 180.0 - rtb_beDot * 3.1415926535897931 / 180.0) + rtb_Divide * 3.1415926535897931 / 180.0 * (9.81 / - Vtas)) * 180.0 / 3.1415926535897931; + Vtas = std::fmax(1.0, *rtu_In_V_tas_kn * 0.5144); + rtb_Limiterxi = *rtu_In_V_ias_kn * 0.5144; + if (*rtu_In_V_ias_kn >= 60.0) { + denom = *rtu_In_beta_deg; + rtb_Limiterxi = ((rtb_Limiterxi * rtb_Limiterxi * 0.6125 * 122.0 / (70000.0 * Vtas) * 0.814 * *rtu_In_beta_deg * + 3.1415926535897931 / 180.0 - *rtu_In_r_deg_s * 3.1415926535897931 / 180.0) + rtb_Sum * + 3.1415926535897931 / 180.0 * (9.81 / Vtas)) * 180.0 / 3.1415926535897931; } else { denom = 0.0; - rtb_beDot = 0.0; + rtb_Limiterxi = 0.0; } - rtb_Limiterxi = look1_binlxpw(*rtu_In_V_ias_kn, A380LateralNormalLaw_rtP.ScheduledGain3_BreakpointsForDimension1, - A380LateralNormalLaw_rtP.ScheduledGain3_Table, 3U); if (*rtu_In_any_ap_engaged) { A380LateralNormalLaw_DWork.Delay_DSTATE = *rtu_In_ap_beta_c_deg + A380LateralNormalLaw_rtP.Constant_Value; } else { - A380LateralNormalLaw_DWork.Delay_DSTATE = *rtu_In_delta_zeta_pos * rtb_Limiterxi; + A380LateralNormalLaw_DWork.Delay_DSTATE = *rtu_In_delta_zeta_pos * look1_binlxpw(*rtu_In_V_ias_kn, + A380LateralNormalLaw_rtP.ScheduledGain3_BreakpointsForDimension1, A380LateralNormalLaw_rtP.ScheduledGain3_Table, + 3U); } - rtb_Limiterxi = look1_binlxpw(*rtu_In_V_ias_kn, A380LateralNormalLaw_rtP.ScheduledGain1_BreakpointsForDimension1, - A380LateralNormalLaw_rtP.ScheduledGain1_Table, 4U); - rtb_Limiterxi = (A380LateralNormalLaw_DWork.Delay_DSTATE - denom) * rtb_Limiterxi - rtb_beDot; + rtb_Limiterxi = (A380LateralNormalLaw_DWork.Delay_DSTATE - denom) * look1_binlxpw(*rtu_In_V_ias_kn, + A380LateralNormalLaw_rtP.ScheduledGain1_BreakpointsForDimension1, A380LateralNormalLaw_rtP.ScheduledGain1_Table, 4U) + - rtb_Limiterxi; if ((!A380LateralNormalLaw_DWork.pY_not_empty) || (!A380LateralNormalLaw_DWork.pU_not_empty)) { A380LateralNormalLaw_DWork.pU = rtb_Limiterxi; A380LateralNormalLaw_DWork.pU_not_empty = true; @@ -584,13 +573,12 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ } denom = *rtu_In_time_dt * A380LateralNormalLaw_rtP.LagFilter_C1; - rtb_beDot = denom / (denom + 2.0); - A380LateralNormalLaw_DWork.pY = (2.0 - denom) / (denom + 2.0) * A380LateralNormalLaw_DWork.pY + (rtb_Limiterxi * - rtb_beDot + A380LateralNormalLaw_DWork.pU * rtb_beDot); + Vtas = denom / (denom + 2.0); + A380LateralNormalLaw_DWork.pY = (2.0 - denom) / (denom + 2.0) * A380LateralNormalLaw_DWork.pY + (rtb_Limiterxi * Vtas + + A380LateralNormalLaw_DWork.pU * Vtas); A380LateralNormalLaw_DWork.pU = rtb_Limiterxi; - rtb_Limiterxi = look1_binlxpw(*rtu_In_V_ias_kn, A380LateralNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1, - A380LateralNormalLaw_rtP.ScheduledGain_Table, 8U); - A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_DWork.Delay_DSTATE * rtb_Limiterxi + + A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_DWork.Delay_DSTATE * look1_binlxpw(*rtu_In_V_ias_kn, + A380LateralNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1, A380LateralNormalLaw_rtP.ScheduledGain_Table, 8U) + A380LateralNormalLaw_DWork.pY; if (A380LateralNormalLaw_DWork.Delay_DSTATE > A380LateralNormalLaw_rtP.Saturation_UpperSat_c) { A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_rtP.Saturation_UpperSat_c; @@ -615,22 +603,22 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ } denom = (A380LateralNormalLaw_rtP.Constant_Value_o - rtb_Limiterxi) * A380LateralNormalLaw_DWork.Delay_DSTATE; - rtb_beDot = *rtu_In_ap_beta_c_deg * rtb_Limiterxi; - rtb_Limiterxi = A380LateralNormalLaw_rtP.Gain1_Gain_l * *rtu_In_Theta_deg; - A380LateralNormalLaw_DWork.Delay_DSTATE = *rtu_In_V_tas_kn; - if (A380LateralNormalLaw_DWork.Delay_DSTATE > A380LateralNormalLaw_rtP.Saturation_UpperSat_e) { + Vtas = *rtu_In_ap_beta_c_deg * rtb_Limiterxi; + if (*rtu_In_V_tas_kn > A380LateralNormalLaw_rtP.Saturation_UpperSat_e) { A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_rtP.Saturation_UpperSat_e; - } else if (A380LateralNormalLaw_DWork.Delay_DSTATE < A380LateralNormalLaw_rtP.Saturation_LowerSat_jd) { + } else if (*rtu_In_V_tas_kn < A380LateralNormalLaw_rtP.Saturation_LowerSat_jd) { A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_rtP.Saturation_LowerSat_jd; + } else { + A380LateralNormalLaw_DWork.Delay_DSTATE = *rtu_In_V_tas_kn; } - rtb_Limiterxi = *rtu_In_r_deg_s - std::sin(A380LateralNormalLaw_rtP.Gain1_Gain_f * rtb_Divide) * - A380LateralNormalLaw_rtP.Constant2_Value * std::cos(rtb_Limiterxi) / (A380LateralNormalLaw_rtP.Gain6_Gain * - A380LateralNormalLaw_DWork.Delay_DSTATE) * A380LateralNormalLaw_rtP.Gain_Gain_i; + rtb_Limiterxi = A380LateralNormalLaw_rtP.Gain6_Gain * A380LateralNormalLaw_DWork.Delay_DSTATE; A380LateralNormalLaw_DWork.Delay_DSTATE = look1_binlxpw(*rtu_In_V_tas_kn, A380LateralNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_a, A380LateralNormalLaw_rtP.ScheduledGain_Table_e, 6U); - A380LateralNormalLaw_DWork.Delay_DSTATE *= rtb_Limiterxi; + A380LateralNormalLaw_DWork.Delay_DSTATE *= *rtu_In_r_deg_s - std::sin(A380LateralNormalLaw_rtP.Gain1_Gain_f * rtb_Sum) + * A380LateralNormalLaw_rtP.Constant2_Value * std::cos(A380LateralNormalLaw_rtP.Gain1_Gain_l * *rtu_In_Theta_deg) / + rtb_Limiterxi * A380LateralNormalLaw_rtP.Gain_Gain_i; if (A380LateralNormalLaw_DWork.Delay_DSTATE > A380LateralNormalLaw_rtP.Saturation1_UpperSat) { A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_rtP.Saturation1_UpperSat; } else if (A380LateralNormalLaw_DWork.Delay_DSTATE < A380LateralNormalLaw_rtP.Saturation1_LowerSat) { @@ -653,7 +641,7 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ rtb_Limiterxi = A380LateralNormalLaw_DWork.pY_a; } - Vtas = A380LateralNormalLaw_DWork.Delay_DSTATE * rtb_Limiterxi; + rtb_Product_l = A380LateralNormalLaw_DWork.Delay_DSTATE * rtb_Limiterxi; A380LateralNormalLaw_DWork.Delay_DSTATE = look1_binlxpw(*rtu_In_V_tas_kn, A380LateralNormalLaw_rtP.ScheduledGain1_BreakpointsForDimension1_j, A380LateralNormalLaw_rtP.ScheduledGain1_Table_m, 6U); @@ -664,7 +652,7 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_rtP.Saturation2_LowerSat; } - A380LateralNormalLaw_RateLimiter(A380LateralNormalLaw_rtP.Gain6_Gain_j * ((rtb_beDot + denom) + (Vtas + + A380LateralNormalLaw_RateLimiter(A380LateralNormalLaw_rtP.Gain6_Gain_j * ((Vtas + denom) + (rtb_Product_l + (A380LateralNormalLaw_rtP.Constant_Value_k - rtb_Limiterxi) * A380LateralNormalLaw_DWork.Delay_DSTATE)), A380LateralNormalLaw_rtP.RateLimiterVariableTs4_up, A380LateralNormalLaw_rtP.RateLimiterVariableTs4_lo, rtu_In_time_dt, A380LateralNormalLaw_rtP.RateLimiterVariableTs4_InitialCondition, &rtb_Y, @@ -685,8 +673,9 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ } A380LateralNormalLaw_RateLimiter(rtb_Y * rtb_Limiterxi + (A380LateralNormalLaw_rtP.Constant_Value_g - rtb_Limiterxi) * - rtb_Gain1_h, A380LateralNormalLaw_rtP.RateLimiterVariableTs3_up, A380LateralNormalLaw_rtP.RateLimiterVariableTs3_lo, - rtu_In_time_dt, A380LateralNormalLaw_rtP.RateLimiterVariableTs3_InitialCondition, &rtb_Y_j, + (A380LateralNormalLaw_rtP.Gain1_Gain * *rtu_In_delta_zeta_pos), A380LateralNormalLaw_rtP.RateLimiterVariableTs3_up, + A380LateralNormalLaw_rtP.RateLimiterVariableTs3_lo, rtu_In_time_dt, + A380LateralNormalLaw_rtP.RateLimiterVariableTs3_InitialCondition, &rtb_Y_j, &A380LateralNormalLaw_DWork.sf_RateLimiter_g); if (static_cast(rtb_NOT_h_tmp) > A380LateralNormalLaw_rtP.Switch1_Threshold) { rtb_Limiterxi = A380LateralNormalLaw_rtP.Gain3_Gain * rtb_Y_j; @@ -702,8 +691,7 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ *rty_Out_zeta_lower_deg = rtb_Limiterxi; } - rtb_OR1 = !rtb_NOT_h_tmp; - A380LateralNormalLaw_TransportDelay(rtb_Y_j, rtu_In_time_dt, rtb_OR1, &rtb_Limiterxi, + A380LateralNormalLaw_TransportDelay(rtb_Y_j, rtu_In_time_dt, !rtb_NOT_h_tmp, &rtb_Limiterxi, &A380LateralNormalLaw_DWork.sf_TransportDelay_p); if (rtb_Limiterxi > A380LateralNormalLaw_rtP.Saturation5_UpperSat) { *rty_Out_zeta_upper_deg = A380LateralNormalLaw_rtP.Saturation5_UpperSat; @@ -719,13 +707,11 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ A380LateralNormalLaw_DWork.Delay_DSTATE = A380LateralNormalLaw_rtP.Saturation_LowerSat_a; } - rtb_Gain1_h = A380LateralNormalLaw_rtP.Gain1_Gain_h * *rtu_In_Phi_deg; - rtb_Y_j = A380LateralNormalLaw_rtP.Gain1_Gain_d * *rtu_In_pk_deg_s; - rtb_Limiterxi = look1_binlxpw(*rtu_In_time_dt, A380LateralNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_b, - A380LateralNormalLaw_rtP.ScheduledGain_Table_h, 4U); - A380LateralNormalLaw_DWork.Delay1_DSTATE = ((-(Vias / v_cas_ms * 845.0 * 1592.01 * -0.5 / 8.5E+7 + 1.414 * omega_0) / - L_xi * rtb_Y_j + k_phi * rtb_Gain1_h) + A380LateralNormalLaw_rtP.Gain1_Gain_j * rtb_Divide * -k_phi) * rtb_Limiterxi - * A380LateralNormalLaw_rtP.Gain_Gain_cw; + A380LateralNormalLaw_DWork.Delay1_DSTATE = ((-(dynamic_pressure / Vias * 845.0 * 1592.01 * -0.5 / 8.5E+7 + 1.414 * + omega_0) / L_xi * (A380LateralNormalLaw_rtP.Gain1_Gain_d * *rtu_In_pk_deg_s) + A380LateralNormalLaw_rtP.Gain1_Gain_h + * *rtu_In_Phi_deg * k_phi) + A380LateralNormalLaw_rtP.Gain1_Gain_j * rtb_Sum * -k_phi) * look1_binlxpw + (*rtu_In_time_dt, A380LateralNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_b, + A380LateralNormalLaw_rtP.ScheduledGain_Table_h, 4U) * A380LateralNormalLaw_rtP.Gain_Gain_cw; if (A380LateralNormalLaw_DWork.Delay1_DSTATE > A380LateralNormalLaw_rtP.Limiterxi_UpperSat) { omega_0 = A380LateralNormalLaw_rtP.Limiterxi_UpperSat; } else if (A380LateralNormalLaw_DWork.Delay1_DSTATE < A380LateralNormalLaw_rtP.Limiterxi_LowerSat) { @@ -736,20 +722,21 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ A380LateralNormalLaw_RateLimiter(A380LateralNormalLaw_rtP.Gain5_Gain * omega_0, A380LateralNormalLaw_rtP.RateLimiterVariableTs2_up_g, A380LateralNormalLaw_rtP.RateLimiterVariableTs2_lo_o, - rtu_In_time_dt, A380LateralNormalLaw_rtP.RateLimiterVariableTs2_InitialCondition_c, &rtb_Y_j, + rtu_In_time_dt, A380LateralNormalLaw_rtP.RateLimiterVariableTs2_InitialCondition_c, &Vias, &A380LateralNormalLaw_DWork.sf_RateLimiter_l); - A380LateralNormalLaw_RateLimiter(rtb_Y_j * A380LateralNormalLaw_DWork.Delay_DSTATE + - (A380LateralNormalLaw_rtP.Constant_Value_j - A380LateralNormalLaw_DWork.Delay_DSTATE) * rtb_Gain_b, - A380LateralNormalLaw_rtP.RateLimiterVariableTs1_up_d, A380LateralNormalLaw_rtP.RateLimiterVariableTs1_lo_k, - rtu_In_time_dt, A380LateralNormalLaw_rtP.RateLimiterVariableTs1_InitialCondition_e, &rtb_Gain1_h, + A380LateralNormalLaw_RateLimiter(Vias * A380LateralNormalLaw_DWork.Delay_DSTATE + + (A380LateralNormalLaw_rtP.Constant_Value_j - A380LateralNormalLaw_DWork.Delay_DSTATE) * + (A380LateralNormalLaw_rtP.Gain_Gain_c * *rtu_In_delta_xi_pos), A380LateralNormalLaw_rtP.RateLimiterVariableTs1_up_d, + A380LateralNormalLaw_rtP.RateLimiterVariableTs1_lo_k, rtu_In_time_dt, + A380LateralNormalLaw_rtP.RateLimiterVariableTs1_InitialCondition_e, &rtb_Y_j, &A380LateralNormalLaw_DWork.sf_RateLimiter_i); if (static_cast(rtb_NOT_h_tmp) > A380LateralNormalLaw_rtP.Switch_Threshold) { - rtb_Gain_b = A380LateralNormalLaw_rtP.Gain_Gain * rtb_Gain1_h; + Vias = A380LateralNormalLaw_rtP.Gain_Gain * rtb_Y_j; } else { - rtb_Gain_b = rtb_Gain1_h; + Vias = rtb_Y_j; } - A380LateralNormalLaw_TransportDelay(rtb_Gain_b, rtu_In_time_dt, rtb_OR1, &A380LateralNormalLaw_DWork.Delay_DSTATE, + A380LateralNormalLaw_TransportDelay(Vias, rtu_In_time_dt, !rtb_NOT_h_tmp, &A380LateralNormalLaw_DWork.Delay_DSTATE, &A380LateralNormalLaw_DWork.sf_TransportDelay); if (A380LateralNormalLaw_DWork.Delay_DSTATE > A380LateralNormalLaw_rtP.Saturation3_UpperSat_o) { *rty_Out_xi_midboard_deg = A380LateralNormalLaw_rtP.Saturation3_UpperSat_o; @@ -759,41 +746,40 @@ void A380LateralNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_ *rty_Out_xi_midboard_deg = A380LateralNormalLaw_DWork.Delay_DSTATE; } - if (rtb_Gain_b > A380LateralNormalLaw_rtP.Saturation_UpperSat_a) { + if (Vias > A380LateralNormalLaw_rtP.Saturation_UpperSat_a) { *rty_Out_xi_inboard_deg = A380LateralNormalLaw_rtP.Saturation_UpperSat_a; - } else if (rtb_Gain_b < A380LateralNormalLaw_rtP.Saturation_LowerSat_m) { + } else if (Vias < A380LateralNormalLaw_rtP.Saturation_LowerSat_m) { *rty_Out_xi_inboard_deg = A380LateralNormalLaw_rtP.Saturation_LowerSat_m; } else { - *rty_Out_xi_inboard_deg = rtb_Gain_b; + *rty_Out_xi_inboard_deg = Vias; } if (A380LateralNormalLaw_rtP.Constant_Value_li) { - A380LateralNormalLaw_DWork.Delay_DSTATE = rtb_Gain1_h; + A380LateralNormalLaw_DWork.Delay_DSTATE = rtb_Y_j; } else { - rtb_Gain_b = std::abs(rtb_Gain1_h) + A380LateralNormalLaw_rtP.Bias_Bias; - if (rtb_Gain_b > A380LateralNormalLaw_rtP.Saturation4_UpperSat) { - rtb_Gain_b = A380LateralNormalLaw_rtP.Saturation4_UpperSat; - } else if (rtb_Gain_b < A380LateralNormalLaw_rtP.Saturation4_LowerSat) { - rtb_Gain_b = A380LateralNormalLaw_rtP.Saturation4_LowerSat; + Vias = std::abs(rtb_Y_j) + A380LateralNormalLaw_rtP.Bias_Bias; + if (Vias > A380LateralNormalLaw_rtP.Saturation4_UpperSat) { + Vias = A380LateralNormalLaw_rtP.Saturation4_UpperSat; + } else if (Vias < A380LateralNormalLaw_rtP.Saturation4_LowerSat) { + Vias = A380LateralNormalLaw_rtP.Saturation4_LowerSat; } - if (rtb_Gain1_h < 0.0) { + if (rtb_Y_j < 0.0) { high_i = -1; } else { - high_i = (rtb_Gain1_h > 0.0); + high_i = (rtb_Y_j > 0.0); } - A380LateralNormalLaw_DWork.Delay_DSTATE = rtb_Gain_b * static_cast(high_i) * - A380LateralNormalLaw_rtP.Gain2_Gain; + A380LateralNormalLaw_DWork.Delay_DSTATE = Vias * static_cast(high_i) * A380LateralNormalLaw_rtP.Gain2_Gain; } *rty_Out_xi_spoiler_deg = A380LateralNormalLaw_rtP.Gain1_Gain_m * A380LateralNormalLaw_DWork.Delay_DSTATE; - if (rtb_Gain1_h > A380LateralNormalLaw_rtP.Saturation2_UpperSat_n) { + if (rtb_Y_j > A380LateralNormalLaw_rtP.Saturation2_UpperSat_n) { *rty_Out_xi_outboard_deg = A380LateralNormalLaw_rtP.Saturation2_UpperSat_n; - } else if (rtb_Gain1_h < A380LateralNormalLaw_rtP.Saturation2_LowerSat_p) { + } else if (rtb_Y_j < A380LateralNormalLaw_rtP.Saturation2_LowerSat_p) { *rty_Out_xi_outboard_deg = A380LateralNormalLaw_rtP.Saturation2_LowerSat_p; } else { - *rty_Out_xi_outboard_deg = rtb_Gain1_h; + *rty_Out_xi_outboard_deg = rtb_Y_j; } A380LateralNormalLaw_DWork.Delay_DSTATE = r; diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchAlternateLaw.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchAlternateLaw.cpp index 7199baf80bc..cc6f165fd3f 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchAlternateLaw.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchAlternateLaw.cpp @@ -456,26 +456,23 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu real_T rtb_nz_limit_up_g; real_T rtb_nz_limit_lo_g; real_T rtb_TmpSignalConversionAtSFunctionInport1[3]; - real_T rtb_Bias_o; + real_T rtb_Bias_g; real_T rtb_Cos; - real_T rtb_Divide; real_T rtb_Divide1_e; - real_T rtb_Divide_c; - real_T rtb_Divide_d; - real_T rtb_Divide_i; - real_T rtb_Divide_n; real_T rtb_Gain; - real_T rtb_Gain1; real_T rtb_Gain5; - real_T rtb_Gain_b; + real_T rtb_Gain_h; + real_T rtb_Gain_j; real_T rtb_Gain_m; - real_T rtb_Product1_b; real_T rtb_Product1_d; real_T rtb_Product1_f; + real_T rtb_Sum1; + real_T rtb_Sum1_h; real_T rtb_Switch_c; real_T rtb_Switch_i; real_T rtb_eta_trim_deg_rate_limit_lo_deg_s; real_T rtb_eta_trim_deg_rate_limit_up_deg_s; + real_T u0; real_T y; real_T y_0; int32_T tmp; @@ -501,20 +498,14 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu } rtb_Gain = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs1_Gain * *rtu_In_qk_deg_s; - rtb_Divide = (rtb_Gain - A380PitchAlternateLaw_DWork.Delay_DSTATE) / *rtu_In_time_dt; - rtb_Gain1 = A380PitchAlternateLaw_rtP.Gain1_Gain_c * *rtu_In_Theta_deg; - rtb_Cos = std::cos(rtb_Gain1); - rtb_Gain1 = A380PitchAlternateLaw_rtP.Gain1_Gain_l * *rtu_In_Phi_deg; - rtb_Divide1_e = rtb_Cos / std::cos(rtb_Gain1); - rtb_Gain1 = A380PitchAlternateLaw_rtP.Gain1_Gain_o * *rtu_In_qk_deg_s; - rtb_Gain_m = *rtu_In_nz_g - rtb_Divide1_e; - rtb_Switch_i = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.uDLookupTable_bp01Data_o, - A380PitchAlternateLaw_rtP.uDLookupTable_tableData_e, 6U); - rtb_Switch_c = *rtu_In_V_tas_kn; - if (rtb_Switch_c > A380PitchAlternateLaw_rtP.Saturation3_UpperSat) { + rtb_Cos = std::cos(A380PitchAlternateLaw_rtP.Gain1_Gain_c * *rtu_In_Theta_deg); + rtb_Divide1_e = rtb_Cos / std::cos(A380PitchAlternateLaw_rtP.Gain1_Gain_l * *rtu_In_Phi_deg); + if (*rtu_In_V_tas_kn > A380PitchAlternateLaw_rtP.Saturation3_UpperSat) { rtb_Switch_c = A380PitchAlternateLaw_rtP.Saturation3_UpperSat; - } else if (rtb_Switch_c < A380PitchAlternateLaw_rtP.Saturation3_LowerSat) { + } else if (*rtu_In_V_tas_kn < A380PitchAlternateLaw_rtP.Saturation3_LowerSat) { rtb_Switch_c = A380PitchAlternateLaw_rtP.Saturation3_LowerSat; + } else { + rtb_Switch_c = *rtu_In_V_tas_kn; } rtb_Gain5 = A380PitchAlternateLaw_rtP.Gain5_Gain * rtb_Switch_c; @@ -572,32 +563,32 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu A380PitchAlternateLaw_rtP.RateLimiterVariableTs2_lo, rtu_In_time_dt, A380PitchAlternateLaw_rtP.RateLimiterVariableTs2_InitialCondition, &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_RateLimiter); - rtb_Switch_c = (A380PitchAlternateLaw_rtP.Gain_Gain_a * A380PitchAlternateLaw_rtP.Vm_currentms_Value * rtb_Gain1 + - rtb_Gain_m) - (rtb_Switch_i / rtb_Gain5 + A380PitchAlternateLaw_rtP.Bias_Bias) * (rtb_Switch_c - - rtb_Divide1_e); - rtb_Switch_i = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.PLUT_bp01Data, + rtb_Gain_m = *rtu_In_nz_g - rtb_Divide1_e; + rtb_Switch_c = (A380PitchAlternateLaw_rtP.Gain1_Gain_o * *rtu_In_qk_deg_s * (A380PitchAlternateLaw_rtP.Gain_Gain_a * + A380PitchAlternateLaw_rtP.Vm_currentms_Value) + rtb_Gain_m) - (look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchAlternateLaw_rtP.uDLookupTable_bp01Data_o, A380PitchAlternateLaw_rtP.uDLookupTable_tableData_e, 6U) / + rtb_Gain5 + A380PitchAlternateLaw_rtP.Bias_Bias) * (rtb_Switch_c - rtb_Divide1_e); + rtb_Product1_f = rtb_Switch_c * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.PLUT_bp01Data, A380PitchAlternateLaw_rtP.PLUT_tableData, 1U); - rtb_Product1_f = rtb_Switch_c * rtb_Switch_i; - rtb_Switch_i = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.DLUT_bp01Data, - A380PitchAlternateLaw_rtP.DLUT_tableData, 1U); - rtb_Gain1 = rtb_Switch_c * rtb_Switch_i * A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs_Gain; - rtb_Divide_c = (rtb_Gain1 - A380PitchAlternateLaw_DWork.Delay_DSTATE_k) / *rtu_In_time_dt; - rtb_Gain5 = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs2_Gain * *rtu_In_V_tas_kn; + rtb_Gain5 = rtb_Switch_c * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.DLUT_bp01Data, + A380PitchAlternateLaw_rtP.DLUT_tableData, 1U) * A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs_Gain; + rtb_Gain_j = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs2_Gain * *rtu_In_V_tas_kn; rtb_Switch_c = A380PitchAlternateLaw_DWork.Delay_DSTATE_d; - rtb_Divide_d = (rtb_Gain5 - A380PitchAlternateLaw_DWork.Delay_DSTATE_d) / *rtu_In_time_dt; - A380PitchAlternateLaw_LagFilter(rtb_Divide_d, A380PitchAlternateLaw_rtP.LagFilter_C1, rtu_In_time_dt, &rtb_Switch_c, - &A380PitchAlternateLaw_DWork.sf_LagFilter_g3); + A380PitchAlternateLaw_LagFilter((rtb_Gain_j - A380PitchAlternateLaw_DWork.Delay_DSTATE_d) / *rtu_In_time_dt, + A380PitchAlternateLaw_rtP.LagFilter_C1, rtu_In_time_dt, &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_LagFilter_g3); if (rtb_Switch_c > A380PitchAlternateLaw_rtP.SaturationV_dot_UpperSat) { rtb_Switch_c = A380PitchAlternateLaw_rtP.SaturationV_dot_UpperSat; } else if (rtb_Switch_c < A380PitchAlternateLaw_rtP.SaturationV_dot_LowerSat) { rtb_Switch_c = A380PitchAlternateLaw_rtP.SaturationV_dot_LowerSat; } - rtb_Divide_c = ((A380PitchAlternateLaw_rtP.Gain3_Gain * rtb_Divide + rtb_Product1_f) + rtb_Divide_c) + - A380PitchAlternateLaw_rtP.Gain_Gain_j * rtb_Switch_c; - rtb_Divide_d = std::fmin(*rtu_In_spoilers_left_pos, *rtu_In_spoilers_right_pos); - A380PitchAlternateLaw_WashoutFilter(rtb_Divide_d, A380PitchAlternateLaw_rtP.WashoutFilter_C1, rtu_In_time_dt, - &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_WashoutFilter_c); + rtb_Sum1 = (((rtb_Gain - A380PitchAlternateLaw_DWork.Delay_DSTATE) / *rtu_In_time_dt * + A380PitchAlternateLaw_rtP.Gain3_Gain + rtb_Product1_f) + (rtb_Gain5 - + A380PitchAlternateLaw_DWork.Delay_DSTATE_k) / *rtu_In_time_dt) + A380PitchAlternateLaw_rtP.Gain_Gain_j * + rtb_Switch_c; + u0 = std::fmin(*rtu_In_spoilers_left_pos, *rtu_In_spoilers_right_pos); + A380PitchAlternateLaw_WashoutFilter(u0, A380PitchAlternateLaw_rtP.WashoutFilter_C1, rtu_In_time_dt, &rtb_Switch_c, + &A380PitchAlternateLaw_DWork.sf_WashoutFilter_c); if (rtb_Switch_c > A380PitchAlternateLaw_rtP.SaturationSpoilers_UpperSat) { y = A380PitchAlternateLaw_rtP.SaturationSpoilers_UpperSat; } else if (rtb_Switch_c < A380PitchAlternateLaw_rtP.SaturationSpoilers_LowerSat) { @@ -606,20 +597,7 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu y = rtb_Switch_c; } - rtb_Divide = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs1_Gain_m * *rtu_In_qk_deg_s; - rtb_Divide_n = (rtb_Divide - A380PitchAlternateLaw_DWork.Delay_DSTATE_kd) / *rtu_In_time_dt; - rtb_Product1_f = A380PitchAlternateLaw_rtP.Gain1_Gain_e * *rtu_In_qk_deg_s; - rtb_Switch_c = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.uDLookupTable_bp01Data_b, - A380PitchAlternateLaw_rtP.uDLookupTable_tableData_h, 6U); - rtb_Product1_d = *rtu_In_V_tas_kn; - if (rtb_Product1_d > A380PitchAlternateLaw_rtP.Saturation3_UpperSat_b) { - rtb_Product1_d = A380PitchAlternateLaw_rtP.Saturation3_UpperSat_b; - } else if (rtb_Product1_d < A380PitchAlternateLaw_rtP.Saturation3_LowerSat_e) { - rtb_Product1_d = A380PitchAlternateLaw_rtP.Saturation3_LowerSat_e; - } - - rtb_Bias_o = rtb_Switch_c / (A380PitchAlternateLaw_rtP.Gain5_Gain_e * rtb_Product1_d) + - A380PitchAlternateLaw_rtP.Bias_Bias_f; + rtb_Product1_f = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs1_Gain_m * *rtu_In_qk_deg_s; if (!A380PitchAlternateLaw_DWork.pY_not_empty) { A380PitchAlternateLaw_DWork.pY = A380PitchAlternateLaw_rtP.RateLimiterVariableTs_InitialCondition; A380PitchAlternateLaw_DWork.pY_not_empty = true; @@ -629,23 +607,24 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu (A380PitchAlternateLaw_rtP.RateLimiterVariableTs_up) * *rtu_In_time_dt), -std::abs (A380PitchAlternateLaw_rtP.RateLimiterVariableTs_lo) * *rtu_In_time_dt); if (*rtu_In_stabilities_available) { - rtb_Switch_c = look1_binlxpw(*rtu_In_flaps_handle_index, A380PitchAlternateLaw_rtP.uDLookupTable_bp01Data, - A380PitchAlternateLaw_rtP.uDLookupTable_tableData, 5U); - rtb_Switch_c -= *rtu_In_V_ias_kn; - rtb_Switch_i = A380PitchAlternateLaw_rtP.Gain1_Gain * rtb_Switch_c; + rtb_Switch_i = (look1_binlxpw(*rtu_In_flaps_handle_index, A380PitchAlternateLaw_rtP.uDLookupTable_bp01Data, + A380PitchAlternateLaw_rtP.uDLookupTable_tableData, 5U) - *rtu_In_V_ias_kn) * A380PitchAlternateLaw_rtP.Gain1_Gain; + rtb_Switch_c = (std::fmin(A380PitchAlternateLaw_rtP.Constant5_Value, *rtu_In_V_ias_kn * + A380PitchAlternateLaw_rtP.Constant6_Value / *rtu_In_mach) - *rtu_In_V_ias_kn) * + A380PitchAlternateLaw_rtP.Gain2_Gain; } else { rtb_Switch_i = A380PitchAlternateLaw_rtP.Constant_Value_n; + rtb_Switch_c = A380PitchAlternateLaw_rtP.Constant3_Value; } - rtb_Switch_c = *rtu_In_V_ias_kn * A380PitchAlternateLaw_rtP.Constant6_Value / *rtu_In_mach; - if (*rtu_In_stabilities_available) { - rtb_Switch_c = std::fmin(A380PitchAlternateLaw_rtP.Constant5_Value, rtb_Switch_c) - *rtu_In_V_ias_kn; - rtb_Switch_c *= A380PitchAlternateLaw_rtP.Gain2_Gain; + if (*rtu_In_V_tas_kn > A380PitchAlternateLaw_rtP.Saturation3_UpperSat_b) { + rtb_Bias_g = A380PitchAlternateLaw_rtP.Saturation3_UpperSat_b; + } else if (*rtu_In_V_tas_kn < A380PitchAlternateLaw_rtP.Saturation3_LowerSat_e) { + rtb_Bias_g = A380PitchAlternateLaw_rtP.Saturation3_LowerSat_e; } else { - rtb_Switch_c = A380PitchAlternateLaw_rtP.Constant3_Value; + rtb_Bias_g = *rtu_In_V_tas_kn; } - rtb_Product1_d = *rtu_In_Phi_deg; if (rtb_Switch_i > A380PitchAlternateLaw_rtP.Saturation_UpperSat_m) { rtb_Switch_i = A380PitchAlternateLaw_rtP.Saturation_UpperSat_m; } else if (rtb_Switch_i < A380PitchAlternateLaw_rtP.Saturation_LowerSat_e) { @@ -658,39 +637,41 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu rtb_Switch_c = A380PitchAlternateLaw_rtP.Saturation1_LowerSat; } - if (rtb_Product1_d > A380PitchAlternateLaw_rtP.Saturation_UpperSat_f) { + if (*rtu_In_Phi_deg > A380PitchAlternateLaw_rtP.Saturation_UpperSat_f) { rtb_Product1_d = A380PitchAlternateLaw_rtP.Saturation_UpperSat_f; - } else if (rtb_Product1_d < A380PitchAlternateLaw_rtP.Saturation_LowerSat_o) { + } else if (*rtu_In_Phi_deg < A380PitchAlternateLaw_rtP.Saturation_LowerSat_o) { rtb_Product1_d = A380PitchAlternateLaw_rtP.Saturation_LowerSat_o; + } else { + rtb_Product1_d = *rtu_In_Phi_deg; } - rtb_Switch_c = (A380PitchAlternateLaw_rtP.Gain_Gain_b * A380PitchAlternateLaw_rtP.Vm_currentms_Value_h * - rtb_Product1_f + rtb_Gain_m) - ((((look1_binlxpw(A380PitchAlternateLaw_DWork.pY, + rtb_Switch_c = (A380PitchAlternateLaw_rtP.Gain1_Gain_e * *rtu_In_qk_deg_s * (A380PitchAlternateLaw_rtP.Gain_Gain_b * + A380PitchAlternateLaw_rtP.Vm_currentms_Value_h) + rtb_Gain_m) - ((((look1_binlxpw(A380PitchAlternateLaw_DWork.pY, A380PitchAlternateLaw_rtP.Loaddemand_bp01Data, A380PitchAlternateLaw_rtP.Loaddemand_tableData, 2U) + rtb_Switch_i) + rtb_Switch_c) + rtb_Cos / std::cos(A380PitchAlternateLaw_rtP.Gain1_Gain_lm * rtb_Product1_d)) - rtb_Divide1_e) * - rtb_Bias_o; - rtb_Switch_i = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.PLUT_bp01Data_f, + (look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.uDLookupTable_bp01Data_b, + A380PitchAlternateLaw_rtP.uDLookupTable_tableData_h, 6U) / (A380PitchAlternateLaw_rtP.Gain5_Gain_e * + rtb_Bias_g) + A380PitchAlternateLaw_rtP.Bias_Bias_f); + rtb_Product1_d = rtb_Switch_c * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.PLUT_bp01Data_f, A380PitchAlternateLaw_rtP.PLUT_tableData_k, 1U); - rtb_Product1_d = rtb_Switch_c * rtb_Switch_i; - rtb_Switch_i = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.DLUT_bp01Data_m, - A380PitchAlternateLaw_rtP.DLUT_tableData_a, 1U); - rtb_Cos = rtb_Switch_c * rtb_Switch_i * A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs_Gain_b; - rtb_Switch_i = (rtb_Cos - A380PitchAlternateLaw_DWork.Delay_DSTATE_j) / *rtu_In_time_dt; - rtb_Product1_f = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs2_Gain_c * *rtu_In_V_tas_kn; + rtb_Cos = rtb_Switch_c * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.DLUT_bp01Data_m, + A380PitchAlternateLaw_rtP.DLUT_tableData_a, 1U) * A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs_Gain_b; + rtb_Switch_i = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs2_Gain_c * *rtu_In_V_tas_kn; rtb_Switch_c = A380PitchAlternateLaw_DWork.Delay_DSTATE_dy; - rtb_Bias_o = (rtb_Product1_f - A380PitchAlternateLaw_DWork.Delay_DSTATE_dy) / *rtu_In_time_dt; - A380PitchAlternateLaw_LagFilter(rtb_Bias_o, A380PitchAlternateLaw_rtP.LagFilter_C1_p, rtu_In_time_dt, &rtb_Switch_c, - &A380PitchAlternateLaw_DWork.sf_LagFilter); + A380PitchAlternateLaw_LagFilter((rtb_Switch_i - A380PitchAlternateLaw_DWork.Delay_DSTATE_dy) / *rtu_In_time_dt, + A380PitchAlternateLaw_rtP.LagFilter_C1_p, rtu_In_time_dt, &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_LagFilter); if (rtb_Switch_c > A380PitchAlternateLaw_rtP.SaturationV_dot_UpperSat_b) { rtb_Switch_c = A380PitchAlternateLaw_rtP.SaturationV_dot_UpperSat_b; } else if (rtb_Switch_c < A380PitchAlternateLaw_rtP.SaturationV_dot_LowerSat_m) { rtb_Switch_c = A380PitchAlternateLaw_rtP.SaturationV_dot_LowerSat_m; } - rtb_Bias_o = ((A380PitchAlternateLaw_rtP.Gain3_Gain_c * rtb_Divide_n + rtb_Product1_d) + rtb_Switch_i) + - A380PitchAlternateLaw_rtP.Gain_Gain_f * rtb_Switch_c; - A380PitchAlternateLaw_WashoutFilter(rtb_Divide_d, A380PitchAlternateLaw_rtP.WashoutFilter_C1_l, rtu_In_time_dt, - &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_WashoutFilter); + rtb_Sum1_h = (((rtb_Product1_f - A380PitchAlternateLaw_DWork.Delay_DSTATE_kd) / *rtu_In_time_dt * + A380PitchAlternateLaw_rtP.Gain3_Gain_c + rtb_Product1_d) + (rtb_Cos - + A380PitchAlternateLaw_DWork.Delay_DSTATE_j) / *rtu_In_time_dt) + A380PitchAlternateLaw_rtP.Gain_Gain_f * + rtb_Switch_c; + A380PitchAlternateLaw_WashoutFilter(u0, A380PitchAlternateLaw_rtP.WashoutFilter_C1_l, rtu_In_time_dt, &rtb_Switch_c, + &A380PitchAlternateLaw_DWork.sf_WashoutFilter); if (rtb_Switch_c > A380PitchAlternateLaw_rtP.SaturationSpoilers_UpperSat_o) { y_0 = A380PitchAlternateLaw_rtP.SaturationSpoilers_UpperSat_o; } else if (rtb_Switch_c < A380PitchAlternateLaw_rtP.SaturationSpoilers_LowerSat_j) { @@ -699,63 +680,60 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu y_0 = rtb_Switch_c; } - rtb_Divide_n = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs1_Gain_c * *rtu_In_qk_deg_s; - rtb_Divide_i = (rtb_Divide_n - A380PitchAlternateLaw_DWork.Delay_DSTATE_e) / *rtu_In_time_dt; - rtb_Switch_i = A380PitchAlternateLaw_rtP.Gain1_Gain_b * *rtu_In_qk_deg_s; + rtb_Product1_d = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs1_Gain_c * *rtu_In_qk_deg_s; rtb_Switch_c = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.uDLookupTable_bp01Data_a, A380PitchAlternateLaw_rtP.uDLookupTable_tableData_p, 6U); - rtb_Product1_d = *rtu_In_V_tas_kn; - if (rtb_Product1_d > A380PitchAlternateLaw_rtP.Saturation3_UpperSat_n) { - rtb_Product1_d = A380PitchAlternateLaw_rtP.Saturation3_UpperSat_n; - } else if (rtb_Product1_d < A380PitchAlternateLaw_rtP.Saturation3_LowerSat_a) { - rtb_Product1_d = A380PitchAlternateLaw_rtP.Saturation3_LowerSat_a; + if (*rtu_In_V_tas_kn > A380PitchAlternateLaw_rtP.Saturation3_UpperSat_n) { + rtb_Bias_g = A380PitchAlternateLaw_rtP.Saturation3_UpperSat_n; + } else if (*rtu_In_V_tas_kn < A380PitchAlternateLaw_rtP.Saturation3_LowerSat_a) { + rtb_Bias_g = A380PitchAlternateLaw_rtP.Saturation3_LowerSat_a; + } else { + rtb_Bias_g = *rtu_In_V_tas_kn; } - rtb_Product1_d = rtb_Switch_c / (A380PitchAlternateLaw_rtP.Gain5_Gain_n * rtb_Product1_d) + + rtb_Bias_g = rtb_Switch_c / (A380PitchAlternateLaw_rtP.Gain5_Gain_n * rtb_Bias_g) + A380PitchAlternateLaw_rtP.Bias_Bias_a; A380PitchAlternateLaw_RateLimiter(rtb_nz_limit_lo_g, A380PitchAlternateLaw_rtP.RateLimiterVariableTs3_up, A380PitchAlternateLaw_rtP.RateLimiterVariableTs3_lo, rtu_In_time_dt, A380PitchAlternateLaw_rtP.RateLimiterVariableTs3_InitialCondition, &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_RateLimiter_n); - rtb_Switch_c = (A380PitchAlternateLaw_rtP.Gain_Gain_p * A380PitchAlternateLaw_rtP.Vm_currentms_Value_p * rtb_Switch_i - + rtb_Gain_m) - (rtb_Switch_c - rtb_Divide1_e) * rtb_Product1_d; - rtb_Switch_i = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.PLUT_bp01Data_a, - A380PitchAlternateLaw_rtP.PLUT_tableData_o, 1U); - rtb_Product1_b = rtb_Switch_c * rtb_Switch_i; - rtb_Switch_i = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.DLUT_bp01Data_k, - A380PitchAlternateLaw_rtP.DLUT_tableData_e, 1U); - rtb_Divide1_e = rtb_Switch_c * rtb_Switch_i * A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs_Gain_p; - rtb_Switch_i = (rtb_Divide1_e - A380PitchAlternateLaw_DWork.Delay_DSTATE_g) / *rtu_In_time_dt; + rtb_Switch_c = (A380PitchAlternateLaw_rtP.Gain1_Gain_b * *rtu_In_qk_deg_s * (A380PitchAlternateLaw_rtP.Gain_Gain_p * + A380PitchAlternateLaw_rtP.Vm_currentms_Value_p) + rtb_Gain_m) - (rtb_Switch_c - rtb_Divide1_e) * rtb_Bias_g; + rtb_Divide1_e = rtb_Switch_c * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchAlternateLaw_rtP.DLUT_bp01Data_k, + A380PitchAlternateLaw_rtP.DLUT_tableData_e, 1U) * A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs_Gain_p; + rtb_Bias_g = ((rtb_Product1_d - A380PitchAlternateLaw_DWork.Delay_DSTATE_e) / *rtu_In_time_dt * + A380PitchAlternateLaw_rtP.Gain3_Gain_b + rtb_Switch_c * look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchAlternateLaw_rtP.PLUT_bp01Data_a, A380PitchAlternateLaw_rtP.PLUT_tableData_o, 1U)) + (rtb_Divide1_e - + A380PitchAlternateLaw_DWork.Delay_DSTATE_g) / *rtu_In_time_dt; rtb_Gain_m = A380PitchAlternateLaw_rtP.DiscreteDerivativeVariableTs2_Gain_a * *rtu_In_V_tas_kn; rtb_Switch_c = A380PitchAlternateLaw_DWork.Delay_DSTATE_l; - rtb_Product1_d = (rtb_Gain_m - A380PitchAlternateLaw_DWork.Delay_DSTATE_l) / *rtu_In_time_dt; - A380PitchAlternateLaw_LagFilter(rtb_Product1_d, A380PitchAlternateLaw_rtP.LagFilter_C1_l, rtu_In_time_dt, - &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_LagFilter_g); + A380PitchAlternateLaw_LagFilter((rtb_Gain_m - A380PitchAlternateLaw_DWork.Delay_DSTATE_l) / *rtu_In_time_dt, + A380PitchAlternateLaw_rtP.LagFilter_C1_l, rtu_In_time_dt, &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_LagFilter_g); if (rtb_Switch_c > A380PitchAlternateLaw_rtP.SaturationV_dot_UpperSat_m) { rtb_Switch_c = A380PitchAlternateLaw_rtP.SaturationV_dot_UpperSat_m; } else if (rtb_Switch_c < A380PitchAlternateLaw_rtP.SaturationV_dot_LowerSat_e) { rtb_Switch_c = A380PitchAlternateLaw_rtP.SaturationV_dot_LowerSat_e; } - rtb_Gain_b = A380PitchAlternateLaw_rtP.Gain_Gain_k * rtb_Switch_c; - A380PitchAlternateLaw_WashoutFilter(rtb_Divide_d, A380PitchAlternateLaw_rtP.WashoutFilter_C1_h, rtu_In_time_dt, - &rtb_Switch_c, &A380PitchAlternateLaw_DWork.sf_WashoutFilter_d); - rtb_Product1_d = A380PitchAlternateLaw_rtP.Gain1_Gain_p * y + rtb_Divide_c; - if (rtb_Product1_d > A380PitchAlternateLaw_rtP.Saturation_UpperSat) { + rtb_Gain_h = A380PitchAlternateLaw_rtP.Gain_Gain_k * rtb_Switch_c; + A380PitchAlternateLaw_WashoutFilter(u0, A380PitchAlternateLaw_rtP.WashoutFilter_C1_h, rtu_In_time_dt, &rtb_Switch_c, + &A380PitchAlternateLaw_DWork.sf_WashoutFilter_d); + u0 = A380PitchAlternateLaw_rtP.Gain1_Gain_p * y + rtb_Sum1; + if (u0 > A380PitchAlternateLaw_rtP.Saturation_UpperSat) { rtb_TmpSignalConversionAtSFunctionInport1[0] = A380PitchAlternateLaw_rtP.Saturation_UpperSat; - } else if (rtb_Product1_d < A380PitchAlternateLaw_rtP.Saturation_LowerSat) { + } else if (u0 < A380PitchAlternateLaw_rtP.Saturation_LowerSat) { rtb_TmpSignalConversionAtSFunctionInport1[0] = A380PitchAlternateLaw_rtP.Saturation_LowerSat; } else { - rtb_TmpSignalConversionAtSFunctionInport1[0] = rtb_Product1_d; + rtb_TmpSignalConversionAtSFunctionInport1[0] = u0; } - rtb_Product1_d = A380PitchAlternateLaw_rtP.Gain1_Gain_h * y_0 + rtb_Bias_o; - if (rtb_Product1_d > A380PitchAlternateLaw_rtP.Saturation_UpperSat_k) { + u0 = A380PitchAlternateLaw_rtP.Gain1_Gain_h * y_0 + rtb_Sum1_h; + if (u0 > A380PitchAlternateLaw_rtP.Saturation_UpperSat_k) { rtb_TmpSignalConversionAtSFunctionInport1[1] = A380PitchAlternateLaw_rtP.Saturation_UpperSat_k; - } else if (rtb_Product1_d < A380PitchAlternateLaw_rtP.Saturation_LowerSat_p) { + } else if (u0 < A380PitchAlternateLaw_rtP.Saturation_LowerSat_p) { rtb_TmpSignalConversionAtSFunctionInport1[1] = A380PitchAlternateLaw_rtP.Saturation_LowerSat_p; } else { - rtb_TmpSignalConversionAtSFunctionInport1[1] = rtb_Product1_d; + rtb_TmpSignalConversionAtSFunctionInport1[1] = u0; } if (rtb_Switch_c > A380PitchAlternateLaw_rtP.SaturationSpoilers_UpperSat_h) { @@ -764,18 +742,15 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu rtb_Switch_c = A380PitchAlternateLaw_rtP.SaturationSpoilers_LowerSat_l; } - rtb_Product1_d = (((A380PitchAlternateLaw_rtP.Gain3_Gain_b * rtb_Divide_i + rtb_Product1_b) + rtb_Switch_i) + - rtb_Gain_b) + A380PitchAlternateLaw_rtP.Gain1_Gain_ov * rtb_Switch_c; - if (rtb_Product1_d > A380PitchAlternateLaw_rtP.Saturation_UpperSat_j) { + u0 = (rtb_Bias_g + rtb_Gain_h) + A380PitchAlternateLaw_rtP.Gain1_Gain_ov * rtb_Switch_c; + if (u0 > A380PitchAlternateLaw_rtP.Saturation_UpperSat_j) { rtb_TmpSignalConversionAtSFunctionInport1[2] = A380PitchAlternateLaw_rtP.Saturation_UpperSat_j; - } else if (rtb_Product1_d < A380PitchAlternateLaw_rtP.Saturation_LowerSat_d) { + } else if (u0 < A380PitchAlternateLaw_rtP.Saturation_LowerSat_d) { rtb_TmpSignalConversionAtSFunctionInport1[2] = A380PitchAlternateLaw_rtP.Saturation_LowerSat_d; } else { - rtb_TmpSignalConversionAtSFunctionInport1[2] = rtb_Product1_d; + rtb_TmpSignalConversionAtSFunctionInport1[2] = u0; } - rtb_Switch_c = look1_binlxpw(*rtu_In_flaps_handle_index, - A380PitchAlternateLaw_rtP.ScheduledGain_BreakpointsForDimension1, A380PitchAlternateLaw_rtP.ScheduledGain_Table, 5U); if (rtb_TmpSignalConversionAtSFunctionInport1[0] < rtb_TmpSignalConversionAtSFunctionInport1[1]) { if (rtb_TmpSignalConversionAtSFunctionInport1[1] < rtb_TmpSignalConversionAtSFunctionInport1[2]) { tmp = 1; @@ -792,18 +767,18 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu tmp = 1; } - rtb_Divide_c = rtb_TmpSignalConversionAtSFunctionInport1[tmp] * rtb_Switch_c; - rtb_Switch_c = look1_binlxpw(*rtu_In_time_dt, A380PitchAlternateLaw_rtP.ScheduledGain_BreakpointsForDimension1_d, - A380PitchAlternateLaw_rtP.ScheduledGain_Table_h, 4U); - rtb_Switch_c = rtb_Divide_c * rtb_Switch_c * A380PitchAlternateLaw_rtP.DiscreteTimeIntegratorVariableTs_Gain * - *rtu_In_time_dt; + rtb_Switch_c = rtb_TmpSignalConversionAtSFunctionInport1[tmp] * look1_binlxpw(*rtu_In_flaps_handle_index, + A380PitchAlternateLaw_rtP.ScheduledGain_BreakpointsForDimension1, A380PitchAlternateLaw_rtP.ScheduledGain_Table, 5U) + * look1_binlxpw(*rtu_In_time_dt, A380PitchAlternateLaw_rtP.ScheduledGain_BreakpointsForDimension1_d, + A380PitchAlternateLaw_rtP.ScheduledGain_Table_h, 4U) * + A380PitchAlternateLaw_rtP.DiscreteTimeIntegratorVariableTs_Gain * *rtu_In_time_dt; if (A380PitchAlternateLaw_rtP.Switch_Threshold < 0.0) { - rtb_Switch_i = *rtu_In_eta_deg; + u0 = *rtu_In_eta_deg; } else { - rtb_Switch_i = A380PitchAlternateLaw_rtP.Gain_Gain * *rtu_In_delta_eta_pos; + u0 = A380PitchAlternateLaw_rtP.Gain_Gain * *rtu_In_delta_eta_pos; } - A380PitchAlternateLaw_DWork.Delay_DSTATE_o = rtb_Switch_i - rtb_Switch_c; + A380PitchAlternateLaw_DWork.Delay_DSTATE_o = u0 - rtb_Switch_c; A380PitchAlternateLaw_DWork.Delay_DSTATE_o += rtb_Switch_c; if (A380PitchAlternateLaw_DWork.Delay_DSTATE_o > A380PitchAlternateLaw_rtP.DiscreteTimeIntegratorVariableTs_UpperLimit) { @@ -814,12 +789,12 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu } if (rtb_eta_trim_deg_should_freeze == A380PitchAlternateLaw_rtP.CompareToConstant_const) { - rtb_Switch_c = A380PitchAlternateLaw_rtP.Constant_Value; + u0 = A380PitchAlternateLaw_rtP.Constant_Value; } else { - rtb_Switch_c = A380PitchAlternateLaw_DWork.Delay_DSTATE_o; + u0 = A380PitchAlternateLaw_DWork.Delay_DSTATE_o; } - rtb_Switch_c *= A380PitchAlternateLaw_rtP.Gain_Gain_c; + rtb_Switch_c = A380PitchAlternateLaw_rtP.Gain_Gain_c * u0; if (rtb_Switch_c > rtb_eta_trim_deg_rate_limit_up_deg_s) { *rty_Out_eta_trim_dot_deg_s = rtb_eta_trim_deg_rate_limit_up_deg_s; } else if (rtb_Switch_c < rtb_eta_trim_deg_rate_limit_lo_deg_s) { @@ -861,12 +836,12 @@ void A380PitchAlternateLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu } A380PitchAlternateLaw_DWork.Delay_DSTATE = rtb_Gain; - A380PitchAlternateLaw_DWork.Delay_DSTATE_k = rtb_Gain1; - A380PitchAlternateLaw_DWork.Delay_DSTATE_d = rtb_Gain5; - A380PitchAlternateLaw_DWork.Delay_DSTATE_kd = rtb_Divide; + A380PitchAlternateLaw_DWork.Delay_DSTATE_k = rtb_Gain5; + A380PitchAlternateLaw_DWork.Delay_DSTATE_d = rtb_Gain_j; + A380PitchAlternateLaw_DWork.Delay_DSTATE_kd = rtb_Product1_f; A380PitchAlternateLaw_DWork.Delay_DSTATE_j = rtb_Cos; - A380PitchAlternateLaw_DWork.Delay_DSTATE_dy = rtb_Product1_f; - A380PitchAlternateLaw_DWork.Delay_DSTATE_e = rtb_Divide_n; + A380PitchAlternateLaw_DWork.Delay_DSTATE_dy = rtb_Switch_i; + A380PitchAlternateLaw_DWork.Delay_DSTATE_e = rtb_Product1_d; A380PitchAlternateLaw_DWork.Delay_DSTATE_g = rtb_Divide1_e; A380PitchAlternateLaw_DWork.Delay_DSTATE_l = rtb_Gain_m; A380PitchAlternateLaw_DWork.icLoad = false; diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchDirectLaw.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchDirectLaw.cpp index e58d0362274..569b26d54c7 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchDirectLaw.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchDirectLaw.cpp @@ -31,23 +31,23 @@ void A380PitchDirectLaw::reset(void) void A380PitchDirectLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In_delta_eta_pos, real_T *rty_Out_eta_deg, real_T *rty_Out_eta_trim_dot_deg_s, real_T *rty_Out_eta_trim_limit_lo, real_T *rty_Out_eta_trim_limit_up) { - real_T rtb_Gain; + real_T u0; *rty_Out_eta_trim_dot_deg_s = A380PitchDirectLaw_rtP.Constant_Value; *rty_Out_eta_trim_limit_up = A380PitchDirectLaw_rtP.Constant2_Value; *rty_Out_eta_trim_limit_lo = A380PitchDirectLaw_rtP.Constant3_Value; - rtb_Gain = A380PitchDirectLaw_rtP.Gain_Gain * *rtu_In_delta_eta_pos; if (!A380PitchDirectLaw_DWork.pY_not_empty) { A380PitchDirectLaw_DWork.pY = A380PitchDirectLaw_rtP.RateLimitereta_InitialCondition; A380PitchDirectLaw_DWork.pY_not_empty = true; } - if (rtb_Gain > A380PitchDirectLaw_rtP.Saturation_UpperSat) { - rtb_Gain = A380PitchDirectLaw_rtP.Saturation_UpperSat; - } else if (rtb_Gain < A380PitchDirectLaw_rtP.Saturation_LowerSat) { - rtb_Gain = A380PitchDirectLaw_rtP.Saturation_LowerSat; + u0 = A380PitchDirectLaw_rtP.Gain_Gain * *rtu_In_delta_eta_pos; + if (u0 > A380PitchDirectLaw_rtP.Saturation_UpperSat) { + u0 = A380PitchDirectLaw_rtP.Saturation_UpperSat; + } else if (u0 < A380PitchDirectLaw_rtP.Saturation_LowerSat) { + u0 = A380PitchDirectLaw_rtP.Saturation_LowerSat; } - A380PitchDirectLaw_DWork.pY += std::fmax(std::fmin(rtb_Gain - A380PitchDirectLaw_DWork.pY, std::abs + A380PitchDirectLaw_DWork.pY += std::fmax(std::fmin(u0 - A380PitchDirectLaw_DWork.pY, std::abs (A380PitchDirectLaw_rtP.RateLimitereta_up) * *rtu_In_time_dt), -std::abs(A380PitchDirectLaw_rtP.RateLimitereta_lo) * *rtu_In_time_dt); *rty_Out_eta_deg = A380PitchDirectLaw_DWork.pY; diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchNormalLaw.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchNormalLaw.cpp index 41ec0e05051..a892e1cd014 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchNormalLaw.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PitchNormalLaw.cpp @@ -1064,58 +1064,48 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In real_T rtb_nz_limit_up_g; real_T rtb_nz_limit_lo_g; real_T ca; - real_T rtb_Bias_o; + real_T denom; real_T rtb_Cos; - real_T rtb_Divide; - real_T rtb_Divide_an; - real_T rtb_Divide_bq; - real_T rtb_Divide_c; - real_T rtb_Divide_cq; - real_T rtb_Divide_ho; - real_T rtb_Divide_k; - real_T rtb_Divide_l; - real_T rtb_Divide_o; + real_T rtb_Divide_ew; + real_T rtb_Divide_nq; + real_T rtb_Divide_ox; real_T rtb_Gain; - real_T rtb_Gain1; - real_T rtb_Gain1_e; - real_T rtb_Gain1_ft; - real_T rtb_Gain5_gq; - real_T rtb_Gain_av; - real_T rtb_Gain_bs; - real_T rtb_Gain_f; - real_T rtb_Gain_ll; - real_T rtb_Gain_nu; + real_T rtb_Gain_a; + real_T rtb_Gain_b; + real_T rtb_Gain_ch; + real_T rtb_Gain_ct; + real_T rtb_Gain_e; + real_T rtb_Gain_ep; + real_T rtb_Gain_fm; + real_T rtb_Gain_g; real_T rtb_Gain_ot; real_T rtb_Gain_px; real_T rtb_Loaddemand2; real_T rtb_ManualSwitch; - real_T rtb_Product1_ck; - real_T rtb_Product1_dm; - real_T rtb_Product_k; - real_T rtb_Product_kz; - real_T rtb_Product_n3; + real_T rtb_Product_d; + real_T rtb_Product_fu; real_T rtb_Saturation_ix; - real_T rtb_Sum1_n; + real_T rtb_Sum1; + real_T rtb_Sum1_c; + real_T rtb_Sum1_mw; real_T rtb_Sum_ma; - real_T rtb_Y_a; + real_T rtb_Y_c; + real_T rtb_Y_d; real_T rtb_Y_dd; - real_T rtb_Y_j; - real_T rtb_Y_k2; + real_T rtb_Y_g; + real_T rtb_Y_k; real_T rtb_Y_lv; real_T rtb_Y_m; real_T rtb_Y_pa; real_T rtb_alpha_err_gain; real_T rtb_eta_trim_deg_rate_limit_lo_deg_s; real_T rtb_eta_trim_deg_rate_limit_up_deg_s; - real_T rtb_qk_dot_gain; - real_T rtb_qk_gain; - real_T rtb_uDLookupTable; real_T rtb_v_target; - real_T rtb_y; real_T rtb_y_c; + real_T y; int32_T rtb_in_flare; boolean_T rtb_AND; - boolean_T rtb_NOT; + boolean_T rtb_eta_trim_deg_should_freeze; if (A380PitchNormalLaw_DWork.is_active_c3_A380PitchNormalLaw == 0) { A380PitchNormalLaw_DWork.is_active_c3_A380PitchNormalLaw = 1U; A380PitchNormalLaw_DWork.is_c3_A380PitchNormalLaw = A380PitchNormalLaw_IN_Ground; @@ -1243,24 +1233,23 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In } } - rtb_NOT = !*rtu_In_any_ap_engaged; - rtb_AND = ((rtb_in_flare != 0) && rtb_NOT); + rtb_AND = ((rtb_in_flare != 0) && (!*rtu_In_any_ap_engaged)); if (A380PitchNormalLaw_DWork.is_active_c9_A380PitchNormalLaw == 0) { A380PitchNormalLaw_DWork.is_active_c9_A380PitchNormalLaw = 1U; A380PitchNormalLaw_DWork.is_c9_A380PitchNormalLaw = A380PitchNormalLaw_IN_running; - rtb_NOT = false; + rtb_eta_trim_deg_should_freeze = false; } else if (A380PitchNormalLaw_DWork.is_c9_A380PitchNormalLaw == A380PitchNormalLaw_IN_frozen) { if ((!rtb_AND) && (*rtu_In_nz_g < 1.25) && (*rtu_In_nz_g > 0.5) && (std::abs(*rtu_In_Phi_deg) <= 30.0)) { A380PitchNormalLaw_DWork.is_c9_A380PitchNormalLaw = A380PitchNormalLaw_IN_running; - rtb_NOT = false; + rtb_eta_trim_deg_should_freeze = false; } else { - rtb_NOT = true; + rtb_eta_trim_deg_should_freeze = true; } } else if (rtb_AND || (*rtu_In_nz_g >= 1.25) || (*rtu_In_nz_g <= 0.5) || (std::abs(*rtu_In_Phi_deg) > 30.0)) { A380PitchNormalLaw_DWork.is_c9_A380PitchNormalLaw = A380PitchNormalLaw_IN_frozen; - rtb_NOT = true; + rtb_eta_trim_deg_should_freeze = true; } else { - rtb_NOT = false; + rtb_eta_trim_deg_should_freeze = false; } rtb_Gain = A380PitchNormalLaw_rtP.Gain_Gain * *rtu_In_delta_eta_pos; @@ -1339,14 +1328,14 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In } if (A380PitchNormalLaw_B.in_flight > A380PitchNormalLaw_rtP.Saturation_UpperSat_c) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation_UpperSat_c; + rtb_Product_d = A380PitchNormalLaw_rtP.Saturation_UpperSat_c; } else if (A380PitchNormalLaw_B.in_flight < A380PitchNormalLaw_rtP.Saturation_LowerSat_n) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation_LowerSat_n; + rtb_Product_d = A380PitchNormalLaw_rtP.Saturation_LowerSat_n; } else { - rtb_Sum_ma = A380PitchNormalLaw_B.in_flight; + rtb_Product_d = A380PitchNormalLaw_B.in_flight; } - A380PitchNormalLaw_RateLimiter(rtb_Sum_ma, A380PitchNormalLaw_rtP.RateLimiterVariableTs_up, + A380PitchNormalLaw_RateLimiter(rtb_Product_d, A380PitchNormalLaw_rtP.RateLimiterVariableTs_up, A380PitchNormalLaw_rtP.RateLimiterVariableTs_lo, rtu_In_time_dt, A380PitchNormalLaw_rtP.RateLimiterVariableTs_InitialCondition, &rtb_Y_pa, &A380PitchNormalLaw_DWork.sf_RateLimiter); if (A380PitchNormalLaw_DWork.is_active_c6_A380PitchNormalLaw == 0) { @@ -1370,14 +1359,14 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In } if (rtb_in_flare > A380PitchNormalLaw_rtP.Saturation1_UpperSat) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation1_UpperSat; + rtb_Product_d = A380PitchNormalLaw_rtP.Saturation1_UpperSat; } else if (rtb_in_flare < A380PitchNormalLaw_rtP.Saturation1_LowerSat) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation1_LowerSat; + rtb_Product_d = A380PitchNormalLaw_rtP.Saturation1_LowerSat; } else { - rtb_Sum_ma = rtb_in_flare; + rtb_Product_d = rtb_in_flare; } - A380PitchNormalLaw_RateLimiter(rtb_Sum_ma, A380PitchNormalLaw_rtP.RateLimiterVariableTs1_up, + A380PitchNormalLaw_RateLimiter(rtb_Product_d, A380PitchNormalLaw_rtP.RateLimiterVariableTs1_up, A380PitchNormalLaw_rtP.RateLimiterVariableTs1_lo, rtu_In_time_dt, A380PitchNormalLaw_rtP.RateLimiterVariableTs1_InitialCondition, &rtb_Y_lv, &A380PitchNormalLaw_DWork.sf_RateLimiter_p); @@ -1391,142 +1380,123 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In &A380PitchNormalLaw_DWork.sf_RateLimiter_n); A380PitchNormalLaw_RateLimiter(static_cast(rtb_AND), A380PitchNormalLaw_rtP.RateLimiterVariableTs4_up, A380PitchNormalLaw_rtP.RateLimiterVariableTs4_lo, rtu_In_time_dt, - A380PitchNormalLaw_rtP.RateLimiterVariableTs4_InitialCondition, &rtb_ManualSwitch, - &A380PitchNormalLaw_DWork.sf_RateLimiter_l); - A380PitchNormalLaw_eta_trim_limit_lofreeze(rtu_In_eta_trim_deg, rtu_In_high_aoa_prot_active, &rtb_Y_m, + A380PitchNormalLaw_rtP.RateLimiterVariableTs4_InitialCondition, &rtb_Y_c, &A380PitchNormalLaw_DWork.sf_RateLimiter_l); + A380PitchNormalLaw_eta_trim_limit_lofreeze(rtu_In_eta_trim_deg, rtu_In_high_aoa_prot_active, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_eta_trim_limit_lofreeze); if (*rtu_In_high_aoa_prot_active) { - *rty_Out_eta_trim_limit_lo = rtb_Y_m; + *rty_Out_eta_trim_limit_lo = rtb_Y_k; } else { *rty_Out_eta_trim_limit_lo = A380PitchNormalLaw_rtP.Constant3_Value; } - A380PitchNormalLaw_eta_trim_limit_lofreeze(rtu_In_eta_trim_deg, rtu_In_high_speed_prot_active, &rtb_Y_m, + A380PitchNormalLaw_eta_trim_limit_lofreeze(rtu_In_eta_trim_deg, rtu_In_high_speed_prot_active, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_eta_trim_limit_upfreeze); if (*rtu_In_high_speed_prot_active) { - *rty_Out_eta_trim_limit_up = rtb_Y_m; + *rty_Out_eta_trim_limit_up = rtb_Y_k; } else { *rty_Out_eta_trim_limit_up = A380PitchNormalLaw_rtP.Constant2_Value; } - rtb_Gain1 = *rtu_In_V_ias_kn; - rtb_Gain_ot = *rtu_In_flaps_handle_index; - rtb_Gain_px = *rtu_In_VLS_kn; - if (rtb_Gain_ot == 5.0) { + if (*rtu_In_flaps_handle_index == 5.0) { rtb_in_flare = 25; } else { rtb_in_flare = 30; } - A380PitchNormalLaw_RateLimiter(static_cast(rtb_in_flare) - std::fmin(5.0, std::fmax(0.0, 5.0 - (rtb_Gain1 - - (rtb_Gain_px + 5.0)) * 0.25)), A380PitchNormalLaw_rtP.RateLimiterVariableTs6_up, + A380PitchNormalLaw_RateLimiter(static_cast(rtb_in_flare) - std::fmin(5.0, std::fmax(0.0, 5.0 - + (*rtu_In_V_ias_kn - (*rtu_In_VLS_kn + 5.0)) * 0.25)), A380PitchNormalLaw_rtP.RateLimiterVariableTs6_up, A380PitchNormalLaw_rtP.RateLimiterVariableTs6_lo, rtu_In_time_dt, - A380PitchNormalLaw_rtP.RateLimiterVariableTs6_InitialCondition, &rtb_Y_m, &A380PitchNormalLaw_DWork.sf_RateLimiter_o); + A380PitchNormalLaw_rtP.RateLimiterVariableTs6_InitialCondition, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_RateLimiter_o); rtb_Loaddemand2 = A380PitchNormalLaw_rtP.Gain1_Gain * *rtu_In_Theta_deg; - rtb_Gain1 = A380PitchNormalLaw_rtP.Gain1_Gain_c * *rtu_In_Theta_deg; - rtb_Cos = std::cos(rtb_Gain1); - rtb_Gain1 = A380PitchNormalLaw_rtP.Gain1_Gain_l * *rtu_In_Phi_deg; - rtb_Y_a = rtb_Cos / std::cos(rtb_Gain1); - rtb_Y_j = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.uDLookupTable_bp01Data, - A380PitchNormalLaw_rtP.uDLookupTable_tableData, 6U); - rtb_v_target = *rtu_In_V_tas_kn; - rtb_Gain1 = A380PitchNormalLaw_rtP.Gain1_Gain_e * *rtu_In_qk_deg_s; - rtb_Gain_av = *rtu_In_nz_g - rtb_Y_a; - rtb_Gain1_e = A380PitchNormalLaw_rtP.Gain2_Gain * rtb_Y_m - rtb_Loaddemand2; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation3_UpperSat) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_UpperSat; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation3_LowerSat) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_LowerSat; + rtb_Cos = std::cos(A380PitchNormalLaw_rtP.Gain1_Gain_c * *rtu_In_Theta_deg); + rtb_Y_d = rtb_Cos / std::cos(A380PitchNormalLaw_rtP.Gain1_Gain_l * *rtu_In_Phi_deg); + rtb_Y_g = A380PitchNormalLaw_rtP.Gain2_Gain * rtb_Y_k - rtb_Loaddemand2; + if (*rtu_In_V_tas_kn > A380PitchNormalLaw_rtP.Saturation3_UpperSat) { + rtb_Product_d = A380PitchNormalLaw_rtP.Saturation3_UpperSat; + } else if (*rtu_In_V_tas_kn < A380PitchNormalLaw_rtP.Saturation3_LowerSat) { + rtb_Product_d = A380PitchNormalLaw_rtP.Saturation3_LowerSat; + } else { + rtb_Product_d = *rtu_In_V_tas_kn; } - if (rtb_Gain1_e > A380PitchNormalLaw_rtP.Saturation1_UpperSat_i) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation1_UpperSat_i; - } else if (rtb_Gain1_e < A380PitchNormalLaw_rtP.Saturation1_LowerSat_h) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation1_LowerSat_h; + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation1_UpperSat_i) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation1_UpperSat_i; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation1_LowerSat_h) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation1_LowerSat_h; } - rtb_Y_k2 = (A380PitchNormalLaw_rtP.Gain_Gain_c * A380PitchNormalLaw_rtP.Vm_currentms_Value * rtb_Gain1 + rtb_Gain_av) - - (rtb_Y_j / (A380PitchNormalLaw_rtP.Gain5_Gain * rtb_v_target) + A380PitchNormalLaw_rtP.Bias_Bias) * ((rtb_Y_a + - look1_binlxpw(rtb_Gain1_e, A380PitchNormalLaw_rtP.Loaddemand1_bp01Data, A380PitchNormalLaw_rtP.Loaddemand1_tableData, - 2U)) - rtb_Y_a); - rtb_Y_j = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.PLUT_bp01Data, A380PitchNormalLaw_rtP.PLUT_tableData, - 1U); - rtb_Product1_dm = rtb_Y_k2 * rtb_Y_j; - rtb_Gain1 = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain * *rtu_In_qk_deg_s; - rtb_Divide = (rtb_Gain1 - A380PitchNormalLaw_DWork.Delay_DSTATE) / *rtu_In_time_dt; - rtb_Y_j = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data, A380PitchNormalLaw_rtP.DLUT_tableData, - 1U); - rtb_Gain_px = rtb_Y_k2 * rtb_Y_j * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain; - rtb_Divide_o = (rtb_Gain_px - A380PitchNormalLaw_DWork.Delay_DSTATE_n) / *rtu_In_time_dt; + rtb_Gain_g = *rtu_In_nz_g - rtb_Y_d; + rtb_Y_m = (A380PitchNormalLaw_rtP.Gain1_Gain_e * *rtu_In_qk_deg_s * (A380PitchNormalLaw_rtP.Gain_Gain_c * + A380PitchNormalLaw_rtP.Vm_currentms_Value) + rtb_Gain_g) - (look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.uDLookupTable_bp01Data, A380PitchNormalLaw_rtP.uDLookupTable_tableData, 6U) / + (A380PitchNormalLaw_rtP.Gain5_Gain * rtb_Product_d) + A380PitchNormalLaw_rtP.Bias_Bias) * ((rtb_Y_d + look1_binlxpw + (rtb_Y_g, A380PitchNormalLaw_rtP.Loaddemand1_bp01Data, A380PitchNormalLaw_rtP.Loaddemand1_tableData, 2U)) - rtb_Y_d); + rtb_ManualSwitch = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain * *rtu_In_qk_deg_s; + rtb_Gain_px = rtb_Y_m * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data, + A380PitchNormalLaw_rtP.DLUT_tableData, 1U) * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain; rtb_Gain_ot = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain * *rtu_In_V_tas_kn; - rtb_Divide_an = (rtb_Gain_ot - A380PitchNormalLaw_DWork.Delay_DSTATE_c) / *rtu_In_time_dt; - A380PitchNormalLaw_LagFilter(rtb_Divide_an, A380PitchNormalLaw_rtP.LagFilter_C1, rtu_In_time_dt, &rtb_Y_m, - &A380PitchNormalLaw_DWork.sf_LagFilter_k); - if (rtb_Y_m > A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat) { - rtb_Divide_bq = A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat; - } else if (rtb_Y_m < A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat) { - rtb_Divide_bq = A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat; - } else { - rtb_Divide_bq = rtb_Y_m; + A380PitchNormalLaw_LagFilter((rtb_Gain_ot - A380PitchNormalLaw_DWork.Delay_DSTATE_c) / *rtu_In_time_dt, + A380PitchNormalLaw_rtP.LagFilter_C1, rtu_In_time_dt, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_LagFilter_k); + if (rtb_Y_k > A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat) { + rtb_Y_k = A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat; + } else if (rtb_Y_k < A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat) { + rtb_Y_k = A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat; } - rtb_Gain5_gq = std::fmin(*rtu_In_spoilers_left_pos, *rtu_In_spoilers_right_pos); - A380PitchNormalLaw_WashoutFilter(rtb_Gain5_gq, A380PitchNormalLaw_rtP.WashoutFilter_C1, rtu_In_time_dt, &rtb_Y_m, + rtb_Sum1 = (((rtb_ManualSwitch - A380PitchNormalLaw_DWork.Delay_DSTATE) / *rtu_In_time_dt * + A380PitchNormalLaw_rtP.Gain3_Gain + rtb_Y_m * look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.PLUT_bp01Data, A380PitchNormalLaw_rtP.PLUT_tableData, 1U)) + (rtb_Gain_px - + A380PitchNormalLaw_DWork.Delay_DSTATE_n) / *rtu_In_time_dt) + A380PitchNormalLaw_rtP.Gain_Gain_l * rtb_Y_k; + rtb_Product_d = std::fmin(*rtu_In_spoilers_left_pos, *rtu_In_spoilers_right_pos); + A380PitchNormalLaw_WashoutFilter(rtb_Product_d, A380PitchNormalLaw_rtP.WashoutFilter_C1, rtu_In_time_dt, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_WashoutFilter_k); - rtb_Y_j = look1_binlxpw(*rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1, - A380PitchNormalLaw_rtP.ScheduledGain_Table, 3U); - if (rtb_Y_m > A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat) { - rtb_Y_m = A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat; - } else if (rtb_Y_m < A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat) { - rtb_Y_m = A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat; + if (rtb_Y_k > A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat) { + y = A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat; + } else if (rtb_Y_k < A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat) { + y = A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat; + } else { + y = rtb_Y_k; } - rtb_Product_kz = rtb_Y_m * rtb_Y_j; - rtb_Divide_an = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain_i * *rtu_In_qk_deg_s; - rtb_Divide_cq = (rtb_Divide_an - A380PitchNormalLaw_DWork.Delay_DSTATE_l) / *rtu_In_time_dt; - rtb_Gain1_ft = A380PitchNormalLaw_rtP.Gain1_Gain_o * *rtu_In_qk_deg_s; - rtb_Y_k2 = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_o, - A380PitchNormalLaw_rtP.uDLookupTable_tableData_e, 6U); - rtb_v_target = *rtu_In_V_tas_kn; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation3_UpperSat_a) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_UpperSat_a; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation3_LowerSat_l) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_LowerSat_l; + rtb_Gain_e = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain_i * *rtu_In_qk_deg_s; + if (*rtu_In_V_tas_kn > A380PitchNormalLaw_rtP.Saturation3_UpperSat_a) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_UpperSat_a; + } else if (*rtu_In_V_tas_kn < A380PitchNormalLaw_rtP.Saturation3_LowerSat_l) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_LowerSat_l; + } else { + rtb_Saturation_ix = *rtu_In_V_tas_kn; } - rtb_Y_k2 = (A380PitchNormalLaw_rtP.Gain_Gain_a * A380PitchNormalLaw_rtP.Vm_currentms_Value_e * rtb_Gain1_ft + - rtb_Gain_av) - (rtb_Y_k2 / (A380PitchNormalLaw_rtP.Gain5_Gain_d * rtb_v_target) + - A380PitchNormalLaw_rtP.Bias_Bias_a) * (rtb_Sum_ma - rtb_Y_a); - rtb_Y_j = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.PLUT_bp01Data_b, - A380PitchNormalLaw_rtP.PLUT_tableData_b, 1U); - rtb_Product1_ck = rtb_Y_k2 * rtb_Y_j; - rtb_Y_j = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_h, - A380PitchNormalLaw_rtP.DLUT_tableData_p, 1U); - rtb_Gain1_ft = rtb_Y_k2 * rtb_Y_j * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_j; - rtb_Divide_l = (rtb_Gain1_ft - A380PitchNormalLaw_DWork.Delay_DSTATE_k) / *rtu_In_time_dt; - rtb_Gain_bs = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_e * *rtu_In_V_tas_kn; - rtb_Sum_ma = (rtb_Gain_bs - A380PitchNormalLaw_DWork.Delay_DSTATE_d) / *rtu_In_time_dt; - A380PitchNormalLaw_LagFilter(rtb_Sum_ma, A380PitchNormalLaw_rtP.LagFilter_C1_p, rtu_In_time_dt, &rtb_Y_m, - &A380PitchNormalLaw_DWork.sf_LagFilter_g3); - if (rtb_Y_m > A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_j) { - rtb_Gain_f = A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_j; - } else if (rtb_Y_m < A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_e) { - rtb_Gain_f = A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_e; - } else { - rtb_Gain_f = rtb_Y_m; + rtb_Y_m = (A380PitchNormalLaw_rtP.Gain1_Gain_o * *rtu_In_qk_deg_s * (A380PitchNormalLaw_rtP.Gain_Gain_a * + A380PitchNormalLaw_rtP.Vm_currentms_Value_e) + rtb_Gain_g) - (look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_o, A380PitchNormalLaw_rtP.uDLookupTable_tableData_e, 6U) / + (A380PitchNormalLaw_rtP.Gain5_Gain_d * rtb_Saturation_ix) + A380PitchNormalLaw_rtP.Bias_Bias_a) * (rtb_Sum_ma - + rtb_Y_d); + rtb_Gain_ep = rtb_Y_m * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_h, + A380PitchNormalLaw_rtP.DLUT_tableData_p, 1U) * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_j; + rtb_Gain_a = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_e * *rtu_In_V_tas_kn; + A380PitchNormalLaw_LagFilter((rtb_Gain_a - A380PitchNormalLaw_DWork.Delay_DSTATE_d) / *rtu_In_time_dt, + A380PitchNormalLaw_rtP.LagFilter_C1_p, rtu_In_time_dt, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_LagFilter_g3); + if (rtb_Y_k > A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_j) { + rtb_Y_k = A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_j; + } else if (rtb_Y_k < A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_e) { + rtb_Y_k = A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_e; } - A380PitchNormalLaw_WashoutFilter(rtb_Gain5_gq, A380PitchNormalLaw_rtP.WashoutFilter_C1_n, rtu_In_time_dt, &rtb_Y_m, + rtb_Sum1_mw = (((rtb_Gain_e - A380PitchNormalLaw_DWork.Delay_DSTATE_l) / *rtu_In_time_dt * + A380PitchNormalLaw_rtP.Gain3_Gain_m + rtb_Y_m * look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.PLUT_bp01Data_b, A380PitchNormalLaw_rtP.PLUT_tableData_b, 1U)) + (rtb_Gain_ep - + A380PitchNormalLaw_DWork.Delay_DSTATE_k) / *rtu_In_time_dt) + A380PitchNormalLaw_rtP.Gain_Gain_j * rtb_Y_k; + A380PitchNormalLaw_WashoutFilter(rtb_Product_d, A380PitchNormalLaw_rtP.WashoutFilter_C1_n, rtu_In_time_dt, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_WashoutFilter_c); - rtb_Y_j = look1_binlxpw(*rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_n, - A380PitchNormalLaw_rtP.ScheduledGain_Table_b, 3U); - if (rtb_Y_m > A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_g) { - rtb_Y_m = A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_g; - } else if (rtb_Y_m < A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_j) { - rtb_Y_m = A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_j; + if (rtb_Y_k > A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_g) { + rtb_Gain_ch = A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_g; + } else if (rtb_Y_k < A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_j) { + rtb_Gain_ch = A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_j; + } else { + rtb_Gain_ch = rtb_Y_k; } - rtb_Product_n3 = rtb_Y_m * rtb_Y_j; A380PitchNormalLaw_RateLimiter_h(rtu_In_delta_eta_pos, A380PitchNormalLaw_rtP.RateLimiterVariableTs2_up_m, A380PitchNormalLaw_rtP.RateLimiterVariableTs2_lo_k, rtu_In_time_dt, A380PitchNormalLaw_rtP.RateLimiterVariableTs2_InitialCondition_f, &rtb_Sum_ma, @@ -1539,39 +1509,33 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In A380PitchNormalLaw_DWork.pY_not_empty = true; } - rtb_Y_m = *rtu_In_time_dt * A380PitchNormalLaw_rtP.LagFilter1_C1; - rtb_Sum_ma = rtb_Y_m + 2.0; - ca = rtb_Y_m / (rtb_Y_m + 2.0); - A380PitchNormalLaw_DWork.pY = (2.0 - rtb_Y_m) / (rtb_Y_m + 2.0) * A380PitchNormalLaw_DWork.pY + (*rtu_In_alpha_deg * + rtb_Y_k = *rtu_In_time_dt * A380PitchNormalLaw_rtP.LagFilter1_C1; + ca = rtb_Y_k / (rtb_Y_k + 2.0); + A380PitchNormalLaw_DWork.pY = (2.0 - rtb_Y_k) / (rtb_Y_k + 2.0) * A380PitchNormalLaw_DWork.pY + (*rtu_In_alpha_deg * ca + A380PitchNormalLaw_DWork.pU * ca); A380PitchNormalLaw_DWork.pU = *rtu_In_alpha_deg; - ca = A380PitchNormalLaw_DWork.pY - *rtu_In_alpha_prot; - rtb_y = std::fmax(std::fmax(0.0, *rtu_In_Theta_deg - 22.5), std::fmax(0.0, (std::abs(*rtu_In_Phi_deg) - 3.0) / 6.0)); - A380PitchNormalLaw_WashoutFilter(rtb_y, A380PitchNormalLaw_rtP.WashoutFilter_C1_b, rtu_In_time_dt, &rtb_Sum_ma, + A380PitchNormalLaw_WashoutFilter(std::fmax(std::fmax(0.0, *rtu_In_Theta_deg - 22.5), std::fmax(0.0, (std::abs + (*rtu_In_Phi_deg) - 3.0) / 6.0)), A380PitchNormalLaw_rtP.WashoutFilter_C1_b, rtu_In_time_dt, &rtb_Sum_ma, &A380PitchNormalLaw_DWork.sf_WashoutFilter_h); - rtb_Y_k2 = (rtb_y_c - ca) - rtb_Sum_ma; - rtb_y_c = A380PitchNormalLaw_rtP.Subsystem1_Gain * rtb_Y_k2; - ca = (rtb_y_c - A380PitchNormalLaw_DWork.Delay_DSTATE_f) / *rtu_In_time_dt; - rtb_Y_j = *rtu_In_time_dt * A380PitchNormalLaw_rtP.Subsystem1_C1; - rtb_Saturation_ix = rtb_Y_j + A380PitchNormalLaw_rtP.Constant_Value_f; - A380PitchNormalLaw_DWork.Delay1_DSTATE = 1.0 / rtb_Saturation_ix * (A380PitchNormalLaw_rtP.Constant_Value_f - rtb_Y_j) - * A380PitchNormalLaw_DWork.Delay1_DSTATE + (ca + A380PitchNormalLaw_DWork.Delay_DSTATE_g) * (rtb_Y_j / + rtb_Y_m = (rtb_y_c - (A380PitchNormalLaw_DWork.pY - *rtu_In_alpha_prot)) - rtb_Sum_ma; + rtb_y_c = A380PitchNormalLaw_rtP.Subsystem1_Gain * rtb_Y_m; + denom = (rtb_y_c - A380PitchNormalLaw_DWork.Delay_DSTATE_f) / *rtu_In_time_dt; + rtb_Y_g = *rtu_In_time_dt * A380PitchNormalLaw_rtP.Subsystem1_C1; + rtb_Saturation_ix = rtb_Y_g + A380PitchNormalLaw_rtP.Constant_Value_f; + A380PitchNormalLaw_DWork.Delay1_DSTATE = 1.0 / rtb_Saturation_ix * (A380PitchNormalLaw_rtP.Constant_Value_f - rtb_Y_g) + * A380PitchNormalLaw_DWork.Delay1_DSTATE + (denom + A380PitchNormalLaw_DWork.Delay_DSTATE_g) * (rtb_Y_g / rtb_Saturation_ix); - rtb_alpha_err_gain = A380PitchNormalLaw_rtP.alpha_err_gain_Gain * rtb_Y_k2; - rtb_y = A380PitchNormalLaw_rtP.Subsystem3_Gain * *rtu_In_V_ias_kn; - rtb_Divide_c = (rtb_y - A380PitchNormalLaw_DWork.Delay_DSTATE_j) / *rtu_In_time_dt; + rtb_alpha_err_gain = A380PitchNormalLaw_rtP.alpha_err_gain_Gain * rtb_Y_m; + ca = A380PitchNormalLaw_rtP.Subsystem3_Gain * *rtu_In_V_ias_kn; + rtb_Divide_nq = (ca - A380PitchNormalLaw_DWork.Delay_DSTATE_j) / *rtu_In_time_dt; rtb_Saturation_ix = *rtu_In_time_dt * A380PitchNormalLaw_rtP.Subsystem3_C1; - rtb_Y_k2 = rtb_Saturation_ix + A380PitchNormalLaw_rtP.Constant_Value_bb; - A380PitchNormalLaw_DWork.Delay1_DSTATE_i = 1.0 / rtb_Y_k2 * (A380PitchNormalLaw_rtP.Constant_Value_bb - - rtb_Saturation_ix) * A380PitchNormalLaw_DWork.Delay1_DSTATE_i + (rtb_Divide_c + - A380PitchNormalLaw_DWork.Delay_DSTATE_ca) * (rtb_Saturation_ix / rtb_Y_k2); - rtb_qk_gain = A380PitchNormalLaw_rtP.qk_gain_Gain * *rtu_In_qk_deg_s; - rtb_qk_dot_gain = A380PitchNormalLaw_rtP.qk_dot_gain_Gain * *rtu_In_qk_dot_deg_s2; - rtb_Y_j = *rtu_In_high_aoa_prot_active; - rtb_Sum_ma = A380PitchNormalLaw_rtP.RateLimiterVariableTs5_up * *rtu_In_time_dt; - rtb_Y_j = std::fmin(rtb_Y_j - A380PitchNormalLaw_DWork.Delay_DSTATE_e, rtb_Sum_ma); - rtb_Sum_ma = *rtu_In_time_dt * A380PitchNormalLaw_rtP.RateLimiterVariableTs5_lo; - A380PitchNormalLaw_DWork.Delay_DSTATE_e += std::fmax(rtb_Y_j, rtb_Sum_ma); + rtb_Y_m = rtb_Saturation_ix + A380PitchNormalLaw_rtP.Constant_Value_bb; + A380PitchNormalLaw_DWork.Delay1_DSTATE_i = 1.0 / rtb_Y_m * (A380PitchNormalLaw_rtP.Constant_Value_bb - + rtb_Saturation_ix) * A380PitchNormalLaw_DWork.Delay1_DSTATE_i + (rtb_Divide_nq + + A380PitchNormalLaw_DWork.Delay_DSTATE_ca) * (rtb_Saturation_ix / rtb_Y_m); + A380PitchNormalLaw_DWork.Delay_DSTATE_e += std::fmax(std::fmin(static_cast(*rtu_In_high_aoa_prot_active) - + A380PitchNormalLaw_DWork.Delay_DSTATE_e, A380PitchNormalLaw_rtP.RateLimiterVariableTs5_up * *rtu_In_time_dt), + *rtu_In_time_dt * A380PitchNormalLaw_rtP.RateLimiterVariableTs5_lo); if (A380PitchNormalLaw_DWork.Delay_DSTATE_e > A380PitchNormalLaw_rtP.Saturation_UpperSat_e) { rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation_UpperSat_e; } else if (A380PitchNormalLaw_DWork.Delay_DSTATE_e < A380PitchNormalLaw_rtP.Saturation_LowerSat_h) { @@ -1580,209 +1544,193 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In rtb_Sum_ma = A380PitchNormalLaw_DWork.Delay_DSTATE_e; } - rtb_v_target = (((A380PitchNormalLaw_rtP.precontrol_gain_Gain * A380PitchNormalLaw_DWork.Delay1_DSTATE + - rtb_alpha_err_gain) + A380PitchNormalLaw_rtP.v_dot_gain_Gain * - A380PitchNormalLaw_DWork.Delay1_DSTATE_i) + rtb_qk_gain) + rtb_qk_dot_gain; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation3_UpperSat_f) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_UpperSat_f; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation3_LowerSat_c) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_LowerSat_c; + rtb_Y_g = (((A380PitchNormalLaw_rtP.precontrol_gain_Gain * A380PitchNormalLaw_DWork.Delay1_DSTATE + rtb_alpha_err_gain) + + A380PitchNormalLaw_rtP.v_dot_gain_Gain * A380PitchNormalLaw_DWork.Delay1_DSTATE_i) + + A380PitchNormalLaw_rtP.qk_gain_Gain * *rtu_In_qk_deg_s) + A380PitchNormalLaw_rtP.qk_dot_gain_Gain * + *rtu_In_qk_dot_deg_s2; + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation3_UpperSat_f) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation3_UpperSat_f; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation3_LowerSat_c) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation3_LowerSat_c; } - rtb_Product_k = rtb_v_target * rtb_Sum_ma; - rtb_Sum1_n = A380PitchNormalLaw_rtP.Constant_Value_fe - rtb_Sum_ma; + rtb_Product_fu = rtb_Y_g * rtb_Sum_ma; + rtb_Sum1_c = A380PitchNormalLaw_rtP.Constant_Value_fe - rtb_Sum_ma; rtb_alpha_err_gain = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain_m * *rtu_In_qk_deg_s; - rtb_Divide_ho = (rtb_alpha_err_gain - A380PitchNormalLaw_DWork.Delay_DSTATE_kd) / *rtu_In_time_dt; - rtb_Gain1_e = A380PitchNormalLaw_rtP.Gain1_Gain_en * *rtu_In_qk_deg_s; - rtb_Sum_ma = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_b, - A380PitchNormalLaw_rtP.uDLookupTable_tableData_h, 6U); - rtb_v_target = *rtu_In_V_tas_kn; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation3_UpperSat_b) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_UpperSat_b; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation3_LowerSat_e) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_LowerSat_e; - } - - rtb_Bias_o = rtb_Sum_ma / (A380PitchNormalLaw_rtP.Gain5_Gain_e * rtb_v_target) + A380PitchNormalLaw_rtP.Bias_Bias_f; A380PitchNormalLaw_RateLimiter_h(rtu_In_ap_theta_c_deg, A380PitchNormalLaw_rtP.RateLimiterVariableTs1_up_d, A380PitchNormalLaw_rtP.RateLimiterVariableTs1_lo_g, rtu_In_time_dt, - A380PitchNormalLaw_rtP.RateLimiterVariableTs1_InitialCondition_l, &rtb_Y_j, + A380PitchNormalLaw_rtP.RateLimiterVariableTs1_InitialCondition_l, &rtb_Y_g, &A380PitchNormalLaw_DWork.sf_RateLimiter_d); - rtb_uDLookupTable = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_h, - A380PitchNormalLaw_rtP.ScheduledGain_Table_j, 6U); A380PitchNormalLaw_RateLimiter_h(rtu_In_delta_eta_pos, A380PitchNormalLaw_rtP.RateLimiterVariableTs_up_n, A380PitchNormalLaw_rtP.RateLimiterVariableTs_lo_c, rtu_In_time_dt, - A380PitchNormalLaw_rtP.RateLimiterVariableTs_InitialCondition_o, &rtb_Y_m, + A380PitchNormalLaw_rtP.RateLimiterVariableTs_InitialCondition_o, &rtb_Y_k, &A380PitchNormalLaw_DWork.sf_RateLimiter_c2); - rtb_Saturation_ix = *rtu_In_delta_eta_pos - A380PitchNormalLaw_DWork.Delay_DSTATE_b; - rtb_Y_k2 = A380PitchNormalLaw_rtP.RateLimiterVariableTs3_up_i * *rtu_In_time_dt; - rtb_Saturation_ix = std::fmin(rtb_Saturation_ix, rtb_Y_k2); - rtb_Y_k2 = *rtu_In_time_dt * A380PitchNormalLaw_rtP.RateLimiterVariableTs3_lo_b; - A380PitchNormalLaw_DWork.Delay_DSTATE_b += std::fmax(rtb_Saturation_ix, rtb_Y_k2); + A380PitchNormalLaw_DWork.Delay_DSTATE_b += std::fmax(std::fmin(*rtu_In_delta_eta_pos - + A380PitchNormalLaw_DWork.Delay_DSTATE_b, A380PitchNormalLaw_rtP.RateLimiterVariableTs3_up_i * *rtu_In_time_dt), + *rtu_In_time_dt * A380PitchNormalLaw_rtP.RateLimiterVariableTs3_lo_b); rtb_v_target = std::fmax((*rtu_In_high_speed_prot_low_kn - *rtu_In_high_speed_prot_high_kn) * A380PitchNormalLaw_DWork.Delay_DSTATE_b, 0.0) + *rtu_In_high_speed_prot_low_kn; - rtb_qk_gain = A380PitchNormalLaw_rtP.Subsystem2_Gain * rtb_v_target; - rtb_qk_dot_gain = (rtb_qk_gain - A380PitchNormalLaw_DWork.Delay_DSTATE_ku) / *rtu_In_time_dt; + rtb_Gain_b = A380PitchNormalLaw_rtP.Subsystem2_Gain * rtb_v_target; + rtb_Divide_ew = (rtb_Gain_b - A380PitchNormalLaw_DWork.Delay_DSTATE_ku) / *rtu_In_time_dt; rtb_Sum_ma = *rtu_In_time_dt * A380PitchNormalLaw_rtP.Subsystem2_C1; rtb_Saturation_ix = rtb_Sum_ma + A380PitchNormalLaw_rtP.Constant_Value_ja; A380PitchNormalLaw_DWork.Delay1_DSTATE_l = 1.0 / rtb_Saturation_ix * (A380PitchNormalLaw_rtP.Constant_Value_ja - - rtb_Sum_ma) * A380PitchNormalLaw_DWork.Delay1_DSTATE_l + (rtb_qk_dot_gain + A380PitchNormalLaw_DWork.Delay_DSTATE_gl) - * (rtb_Sum_ma / rtb_Saturation_ix); - rtb_Gain_ll = A380PitchNormalLaw_rtP.Subsystem_Gain * *rtu_In_V_ias_kn; - rtb_Divide_k = (rtb_Gain_ll - A380PitchNormalLaw_DWork.Delay_DSTATE_m) / *rtu_In_time_dt; + rtb_Sum_ma) * A380PitchNormalLaw_DWork.Delay1_DSTATE_l + (rtb_Divide_ew + A380PitchNormalLaw_DWork.Delay_DSTATE_gl) * + (rtb_Sum_ma / rtb_Saturation_ix); + rtb_Gain_fm = A380PitchNormalLaw_rtP.Subsystem_Gain * *rtu_In_V_ias_kn; + rtb_Divide_ox = (rtb_Gain_fm - A380PitchNormalLaw_DWork.Delay_DSTATE_m) / *rtu_In_time_dt; rtb_Sum_ma = *rtu_In_time_dt * A380PitchNormalLaw_rtP.Subsystem_C1; rtb_Saturation_ix = rtb_Sum_ma + A380PitchNormalLaw_rtP.Constant_Value_jj; A380PitchNormalLaw_DWork.Delay1_DSTATE_n = 1.0 / rtb_Saturation_ix * (A380PitchNormalLaw_rtP.Constant_Value_jj - - rtb_Sum_ma) * A380PitchNormalLaw_DWork.Delay1_DSTATE_n + (rtb_Divide_k + A380PitchNormalLaw_DWork.Delay_DSTATE_k2) * + rtb_Sum_ma) * A380PitchNormalLaw_DWork.Delay1_DSTATE_n + (rtb_Divide_ox + A380PitchNormalLaw_DWork.Delay_DSTATE_k2) * (rtb_Sum_ma / rtb_Saturation_ix); - rtb_in_flare = *rtu_In_high_speed_prot_active; - rtb_Y_k2 = A380PitchNormalLaw_rtP.RateLimiterVariableTs4_up_b * *rtu_In_time_dt; - rtb_Saturation_ix = std::fmin(static_cast(rtb_in_flare) - A380PitchNormalLaw_DWork.Delay_DSTATE_mz, rtb_Y_k2); - rtb_Y_k2 = *rtu_In_time_dt * A380PitchNormalLaw_rtP.RateLimiterVariableTs4_lo_o; - A380PitchNormalLaw_DWork.Delay_DSTATE_mz += std::fmax(rtb_Saturation_ix, rtb_Y_k2); + A380PitchNormalLaw_DWork.Delay_DSTATE_mz += std::fmax(std::fmin(static_cast(*rtu_In_high_speed_prot_active) - + A380PitchNormalLaw_DWork.Delay_DSTATE_mz, A380PitchNormalLaw_rtP.RateLimiterVariableTs4_up_b * *rtu_In_time_dt), + *rtu_In_time_dt * A380PitchNormalLaw_rtP.RateLimiterVariableTs4_lo_o); if (*rtu_In_any_ap_engaged) { - rtb_Sum_ma = rtb_Y_j - *rtu_In_Theta_deg; - rtb_Sum_ma *= rtb_uDLookupTable; + rtb_Sum_ma = (rtb_Y_g - *rtu_In_Theta_deg) * look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_h, A380PitchNormalLaw_rtP.ScheduledGain_Table_j, 6U); } else { - rtb_Y_m = look1_binlxpw(rtb_Y_m, A380PitchNormalLaw_rtP.Loaddemand_bp01Data, + rtb_Sum_ma = look1_binlxpw(rtb_Y_k, A380PitchNormalLaw_rtP.Loaddemand_bp01Data, A380PitchNormalLaw_rtP.Loaddemand_tableData, 2U); if (A380PitchNormalLaw_DWork.Delay_DSTATE_mz > A380PitchNormalLaw_rtP.Saturation_UpperSat) { - rtb_Y_j = A380PitchNormalLaw_rtP.Saturation_UpperSat; + rtb_Y_k = A380PitchNormalLaw_rtP.Saturation_UpperSat; } else if (A380PitchNormalLaw_DWork.Delay_DSTATE_mz < A380PitchNormalLaw_rtP.Saturation_LowerSat) { - rtb_Y_j = A380PitchNormalLaw_rtP.Saturation_LowerSat; + rtb_Y_k = A380PitchNormalLaw_rtP.Saturation_LowerSat; } else { - rtb_Y_j = A380PitchNormalLaw_DWork.Delay_DSTATE_mz; + rtb_Y_k = A380PitchNormalLaw_DWork.Delay_DSTATE_mz; } - if (rtb_in_flare > A380PitchNormalLaw_rtP.Switch2_Threshold) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.qk_dot_gain1_Gain * *rtu_In_qk_dot_deg_s2; - rtb_Y_k2 = A380PitchNormalLaw_rtP.qk_gain_HSP_Gain * *rtu_In_qk_deg_s; - rtb_v_target -= *rtu_In_V_ias_kn; - rtb_v_target = ((((A380PitchNormalLaw_rtP.precontrol_gain_HSP_Gain * A380PitchNormalLaw_DWork.Delay1_DSTATE_l + - A380PitchNormalLaw_rtP.Gain6_Gain * rtb_v_target) + A380PitchNormalLaw_rtP.v_dot_gain_HSP_Gain * - A380PitchNormalLaw_DWork.Delay1_DSTATE_n) + rtb_Y_k2) + rtb_Sum_ma) * - A380PitchNormalLaw_rtP.HSP_gain_Gain; - if (rtb_Y_m > A380PitchNormalLaw_rtP.Saturation8_UpperSat) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation8_UpperSat; - } else if (rtb_Y_m < A380PitchNormalLaw_rtP.Saturation8_LowerSat) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation8_LowerSat; + if (static_cast(*rtu_In_high_speed_prot_active) > A380PitchNormalLaw_rtP.Switch2_Threshold) { + rtb_Y_g = (((((rtb_v_target - *rtu_In_V_ias_kn) * A380PitchNormalLaw_rtP.Gain6_Gain + + A380PitchNormalLaw_rtP.precontrol_gain_HSP_Gain * A380PitchNormalLaw_DWork.Delay1_DSTATE_l) + + A380PitchNormalLaw_rtP.v_dot_gain_HSP_Gain * A380PitchNormalLaw_DWork.Delay1_DSTATE_n) + + A380PitchNormalLaw_rtP.qk_gain_HSP_Gain * *rtu_In_qk_deg_s) + A380PitchNormalLaw_rtP.qk_dot_gain1_Gain + * *rtu_In_qk_dot_deg_s2) * A380PitchNormalLaw_rtP.HSP_gain_Gain; + if (rtb_Sum_ma > A380PitchNormalLaw_rtP.Saturation8_UpperSat) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation8_UpperSat; + } else if (rtb_Sum_ma < A380PitchNormalLaw_rtP.Saturation8_LowerSat) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation8_LowerSat; } else { - rtb_Sum_ma = rtb_Y_m; + rtb_Saturation_ix = rtb_Sum_ma; } - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation4_UpperSat) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation4_UpperSat; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation4_LowerSat) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation4_LowerSat; + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation4_UpperSat) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation4_UpperSat; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation4_LowerSat) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation4_LowerSat; } - rtb_Sum_ma += rtb_v_target; + rtb_Y_g += rtb_Saturation_ix; } else { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Constant1_Value_g; + rtb_Y_g = A380PitchNormalLaw_rtP.Constant1_Value_g; } - rtb_Sum_ma = (A380PitchNormalLaw_rtP.Constant_Value_m - rtb_Y_j) * rtb_Y_m + rtb_Sum_ma * rtb_Y_j; + rtb_Sum_ma = (A380PitchNormalLaw_rtP.Constant_Value_m - rtb_Y_k) * rtb_Sum_ma + rtb_Y_g * rtb_Y_k; } - rtb_v_target = *rtu_In_Phi_deg; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation_UpperSat_f1) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_UpperSat_f1; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation_LowerSat_o1) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_LowerSat_o1; + if (*rtu_In_V_tas_kn > A380PitchNormalLaw_rtP.Saturation3_UpperSat_b) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_UpperSat_b; + } else if (*rtu_In_V_tas_kn < A380PitchNormalLaw_rtP.Saturation3_LowerSat_e) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_LowerSat_e; + } else { + rtb_Saturation_ix = *rtu_In_V_tas_kn; } - rtb_Sum_ma = (A380PitchNormalLaw_rtP.Gain_Gain_b * A380PitchNormalLaw_rtP.Vm_currentms_Value_h * rtb_Gain1_e + - rtb_Gain_av) - ((rtb_Cos / std::cos(A380PitchNormalLaw_rtP.Gain1_Gain_lm * rtb_v_target) + rtb_Sum_ma) - - rtb_Y_a) * rtb_Bias_o; - rtb_Saturation_ix = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.PLUT_bp01Data_f, - A380PitchNormalLaw_rtP.PLUT_tableData_k, 1U); - rtb_Y_j = rtb_Sum_ma * rtb_Saturation_ix; - rtb_Saturation_ix = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_m, - A380PitchNormalLaw_rtP.DLUT_tableData_a, 1U); - rtb_Cos = rtb_Sum_ma * rtb_Saturation_ix * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_b; - rtb_v_target = (rtb_Cos - A380PitchNormalLaw_DWork.Delay_DSTATE_jh) / *rtu_In_time_dt; - rtb_Y_m = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_c * *rtu_In_V_tas_kn; + if (*rtu_In_Phi_deg > A380PitchNormalLaw_rtP.Saturation_UpperSat_f1) { + rtb_Y_k = A380PitchNormalLaw_rtP.Saturation_UpperSat_f1; + } else if (*rtu_In_Phi_deg < A380PitchNormalLaw_rtP.Saturation_LowerSat_o1) { + rtb_Y_k = A380PitchNormalLaw_rtP.Saturation_LowerSat_o1; + } else { + rtb_Y_k = *rtu_In_Phi_deg; + } + + rtb_Sum_ma = (A380PitchNormalLaw_rtP.Gain1_Gain_en * *rtu_In_qk_deg_s * (A380PitchNormalLaw_rtP.Gain_Gain_b * + A380PitchNormalLaw_rtP.Vm_currentms_Value_h) + rtb_Gain_g) - ((rtb_Cos / std::cos + (A380PitchNormalLaw_rtP.Gain1_Gain_lm * rtb_Y_k) + rtb_Sum_ma) - rtb_Y_d) * (look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_b, A380PitchNormalLaw_rtP.uDLookupTable_tableData_h, 6U) / + (A380PitchNormalLaw_rtP.Gain5_Gain_e * rtb_Saturation_ix) + A380PitchNormalLaw_rtP.Bias_Bias_f); + rtb_Cos = rtb_Sum_ma * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_m, + A380PitchNormalLaw_rtP.DLUT_tableData_a, 1U) * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_b; + rtb_Y_g = ((rtb_alpha_err_gain - A380PitchNormalLaw_DWork.Delay_DSTATE_kd) / *rtu_In_time_dt * + A380PitchNormalLaw_rtP.Gain3_Gain_c + rtb_Sum_ma * look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.PLUT_bp01Data_f, A380PitchNormalLaw_rtP.PLUT_tableData_k, 1U)) + (rtb_Cos - + A380PitchNormalLaw_DWork.Delay_DSTATE_jh) / *rtu_In_time_dt; + rtb_Y_k = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_c * *rtu_In_V_tas_kn; rtb_Sum_ma = A380PitchNormalLaw_DWork.Delay_DSTATE_dy; - rtb_Y_k2 = (rtb_Y_m - A380PitchNormalLaw_DWork.Delay_DSTATE_dy) / *rtu_In_time_dt; - A380PitchNormalLaw_LagFilter(rtb_Y_k2, A380PitchNormalLaw_rtP.LagFilter_C1_pt, rtu_In_time_dt, &rtb_Sum_ma, - &A380PitchNormalLaw_DWork.sf_LagFilter_i); + A380PitchNormalLaw_LagFilter((rtb_Y_k - A380PitchNormalLaw_DWork.Delay_DSTATE_dy) / *rtu_In_time_dt, + A380PitchNormalLaw_rtP.LagFilter_C1_pt, rtu_In_time_dt, &rtb_Sum_ma, &A380PitchNormalLaw_DWork.sf_LagFilter_i); if (rtb_Sum_ma > A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_b) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_b; } else if (rtb_Sum_ma < A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_m) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_m; } - rtb_Y_k2 = A380PitchNormalLaw_rtP.Gain_Gain_f * rtb_Sum_ma; - A380PitchNormalLaw_WashoutFilter(rtb_Gain5_gq, A380PitchNormalLaw_rtP.WashoutFilter_C1_l, rtu_In_time_dt, &rtb_Sum_ma, + rtb_v_target = A380PitchNormalLaw_rtP.Gain_Gain_f * rtb_Sum_ma; + A380PitchNormalLaw_WashoutFilter(rtb_Product_d, A380PitchNormalLaw_rtP.WashoutFilter_C1_l, rtu_In_time_dt, &rtb_Sum_ma, &A380PitchNormalLaw_DWork.sf_WashoutFilter_l); - rtb_Saturation_ix = look1_binlxpw(*rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_c, - A380PitchNormalLaw_rtP.ScheduledGain_Table_g, 3U); if (rtb_Sum_ma > A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_o) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_o; } else if (rtb_Sum_ma < A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_jl) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_jl; } - rtb_v_target = (((A380PitchNormalLaw_rtP.Gain3_Gain_c * rtb_Divide_ho + rtb_Y_j) + rtb_v_target) + rtb_Y_k2) + - rtb_Sum_ma * rtb_Saturation_ix; - rtb_Y_j = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain_c * *rtu_In_qk_deg_s; - rtb_Y_k2 = (rtb_Y_j - A380PitchNormalLaw_DWork.Delay_DSTATE_e5) / *rtu_In_time_dt; - rtb_Divide_ho = A380PitchNormalLaw_rtP.Gain1_Gain_b * *rtu_In_qk_deg_s; - rtb_Sum_ma = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_a, - A380PitchNormalLaw_rtP.uDLookupTable_tableData_p, 6U); - rtb_Gain1_e = *rtu_In_V_tas_kn; - if (rtb_Gain1_e > A380PitchNormalLaw_rtP.Saturation3_UpperSat_n) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation3_UpperSat_n; - } else if (rtb_Gain1_e < A380PitchNormalLaw_rtP.Saturation3_LowerSat_a) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation3_LowerSat_a; + rtb_Y_g = (rtb_Y_g + rtb_v_target) + rtb_Sum_ma * look1_binlxpw(*rtu_In_H_radio_ft, + A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_c, A380PitchNormalLaw_rtP.ScheduledGain_Table_g, 3U); + rtb_v_target = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain_c * *rtu_In_qk_deg_s; + if (*rtu_In_V_tas_kn > A380PitchNormalLaw_rtP.Saturation3_UpperSat_n) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_UpperSat_n; + } else if (*rtu_In_V_tas_kn < A380PitchNormalLaw_rtP.Saturation3_LowerSat_a) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_LowerSat_a; + } else { + rtb_Saturation_ix = *rtu_In_V_tas_kn; } - rtb_Sum_ma = (A380PitchNormalLaw_rtP.Gain_Gain_p * A380PitchNormalLaw_rtP.Vm_currentms_Value_p * rtb_Divide_ho + - rtb_Gain_av) - (rtb_Sum_ma / (A380PitchNormalLaw_rtP.Gain5_Gain_n * rtb_Gain1_e) + - A380PitchNormalLaw_rtP.Bias_Bias_ai) * (rtb_Y_dd - rtb_Y_a); - rtb_Saturation_ix = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.PLUT_bp01Data_a, - A380PitchNormalLaw_rtP.PLUT_tableData_o, 1U); - rtb_Bias_o = rtb_Sum_ma * rtb_Saturation_ix; - rtb_Saturation_ix = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_k, - A380PitchNormalLaw_rtP.DLUT_tableData_e, 1U); - rtb_Y_dd = rtb_Sum_ma * rtb_Saturation_ix * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_p; - rtb_uDLookupTable = (rtb_Y_dd - A380PitchNormalLaw_DWork.Delay_DSTATE_gz) / *rtu_In_time_dt; - rtb_Divide_ho = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_a * *rtu_In_V_tas_kn; + rtb_Sum_ma = (A380PitchNormalLaw_rtP.Gain1_Gain_b * *rtu_In_qk_deg_s * (A380PitchNormalLaw_rtP.Gain_Gain_p * + A380PitchNormalLaw_rtP.Vm_currentms_Value_p) + rtb_Gain_g) - (look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_a, A380PitchNormalLaw_rtP.uDLookupTable_tableData_p, 6U) / + (A380PitchNormalLaw_rtP.Gain5_Gain_n * rtb_Saturation_ix) + A380PitchNormalLaw_rtP.Bias_Bias_ai) * (rtb_Y_dd - + rtb_Y_d); + rtb_Y_dd = rtb_Sum_ma * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_k, + A380PitchNormalLaw_rtP.DLUT_tableData_e, 1U) * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_p; + rtb_Y_m = ((rtb_v_target - A380PitchNormalLaw_DWork.Delay_DSTATE_e5) / *rtu_In_time_dt * + A380PitchNormalLaw_rtP.Gain3_Gain_b + rtb_Sum_ma * look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.PLUT_bp01Data_a, A380PitchNormalLaw_rtP.PLUT_tableData_o, 1U)) + (rtb_Y_dd - + A380PitchNormalLaw_DWork.Delay_DSTATE_gz) / *rtu_In_time_dt; + rtb_Gain_ct = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_a * *rtu_In_V_tas_kn; rtb_Sum_ma = A380PitchNormalLaw_DWork.Delay_DSTATE_lf; - rtb_Saturation_ix = (rtb_Divide_ho - A380PitchNormalLaw_DWork.Delay_DSTATE_lf) / *rtu_In_time_dt; - A380PitchNormalLaw_LagFilter(rtb_Saturation_ix, A380PitchNormalLaw_rtP.LagFilter_C1_l, rtu_In_time_dt, &rtb_Sum_ma, - &A380PitchNormalLaw_DWork.sf_LagFilter_g); + A380PitchNormalLaw_LagFilter((rtb_Gain_ct - A380PitchNormalLaw_DWork.Delay_DSTATE_lf) / *rtu_In_time_dt, + A380PitchNormalLaw_rtP.LagFilter_C1_l, rtu_In_time_dt, &rtb_Sum_ma, &A380PitchNormalLaw_DWork.sf_LagFilter_g); if (rtb_Sum_ma > A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_m) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_m; } else if (rtb_Sum_ma < A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_ek) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_ek; } - rtb_Gain_nu = A380PitchNormalLaw_rtP.Gain_Gain_k * rtb_Sum_ma; - A380PitchNormalLaw_WashoutFilter(rtb_Gain5_gq, A380PitchNormalLaw_rtP.WashoutFilter_C1_h, rtu_In_time_dt, &rtb_Sum_ma, + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Gain_Gain_k * rtb_Sum_ma; + A380PitchNormalLaw_WashoutFilter(rtb_Product_d, A380PitchNormalLaw_rtP.WashoutFilter_C1_h, rtu_In_time_dt, &rtb_Sum_ma, &A380PitchNormalLaw_DWork.sf_WashoutFilter_d); - rtb_Saturation_ix = look1_binlxpw(*rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_f, - A380PitchNormalLaw_rtP.ScheduledGain_Table_h, 3U); - rtb_Gain1_e = (((A380PitchNormalLaw_rtP.Gain3_Gain_m * rtb_Divide_cq + rtb_Product1_ck) + rtb_Divide_l) + - A380PitchNormalLaw_rtP.Gain_Gain_j * rtb_Gain_f) + rtb_Product_n3; + rtb_Gain_ch = rtb_Gain_ch * look1_binlxpw(*rtu_In_H_radio_ft, + A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_n, A380PitchNormalLaw_rtP.ScheduledGain_Table_b, 3U) + + rtb_Sum1_mw; if (rtb_Sum_ma > A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_h) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_h; } else if (rtb_Sum_ma < A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_l) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_l; } - rtb_Sum_ma = (((A380PitchNormalLaw_rtP.Gain3_Gain_b * rtb_Y_k2 + rtb_Bias_o) + rtb_uDLookupTable) + rtb_Gain_nu) + - rtb_Sum_ma * rtb_Saturation_ix; - if (rtb_Gain1_e > A380PitchNormalLaw_rtP.Saturation_UpperSat_hc) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation_UpperSat_hc; - } else if (rtb_Gain1_e < A380PitchNormalLaw_rtP.Saturation_LowerSat_a) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation_LowerSat_a; + rtb_Sum_ma = (rtb_Y_m + rtb_Saturation_ix) + rtb_Sum_ma * look1_binlxpw(*rtu_In_H_radio_ft, + A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_f, A380PitchNormalLaw_rtP.ScheduledGain_Table_h, 3U); + if (rtb_Gain_ch > A380PitchNormalLaw_rtP.Saturation_UpperSat_hc) { + rtb_Gain_ch = A380PitchNormalLaw_rtP.Saturation_UpperSat_hc; + } else if (rtb_Gain_ch < A380PitchNormalLaw_rtP.Saturation_LowerSat_a) { + rtb_Gain_ch = A380PitchNormalLaw_rtP.Saturation_LowerSat_a; } - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation_UpperSat_k) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_UpperSat_k; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation_LowerSat_p1) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_LowerSat_p1; + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation_UpperSat_k) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_UpperSat_k; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation_LowerSat_p1) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_LowerSat_p1; } if (rtb_Sum_ma > A380PitchNormalLaw_rtP.Saturation_UpperSat_j) { @@ -1791,89 +1739,81 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation_LowerSat_d; } - A380PitchNormalLaw_VoterAttitudeProtection(rtb_Gain1_e, rtb_Product_k + rtb_Sum1_n * rtb_v_target, rtb_Sum_ma, - &rtb_Y_k2); - rtb_Divide_cq = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain_k * *rtu_In_qk_deg_s; - rtb_Product1_ck = (rtb_Divide_cq - A380PitchNormalLaw_DWork.Delay_DSTATE_h) / *rtu_In_time_dt; - rtb_Divide_l = A380PitchNormalLaw_rtP.Gain1_Gain_lk * *rtu_In_qk_deg_s; - rtb_Sum_ma = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_m, - A380PitchNormalLaw_rtP.uDLookupTable_tableData_a, 6U); - rtb_v_target = *rtu_In_V_tas_kn; - rtb_Gain1_e = A380PitchNormalLaw_rtP.Gain3_Gain_g * A380PitchNormalLaw_rtP.Theta_max3_Value - rtb_Loaddemand2; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation3_UpperSat_e) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_UpperSat_e; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation3_LowerSat_k) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation3_LowerSat_k; + A380PitchNormalLaw_VoterAttitudeProtection(rtb_Gain_ch, rtb_Product_fu + rtb_Sum1_c * rtb_Y_g, rtb_Sum_ma, &rtb_Y_m); + rtb_Sum1_mw = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs1_Gain_k * *rtu_In_qk_deg_s; + rtb_Y_g = A380PitchNormalLaw_rtP.Gain3_Gain_g * A380PitchNormalLaw_rtP.Theta_max3_Value - rtb_Loaddemand2; + if (*rtu_In_V_tas_kn > A380PitchNormalLaw_rtP.Saturation3_UpperSat_e) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_UpperSat_e; + } else if (*rtu_In_V_tas_kn < A380PitchNormalLaw_rtP.Saturation3_LowerSat_k) { + rtb_Saturation_ix = A380PitchNormalLaw_rtP.Saturation3_LowerSat_k; + } else { + rtb_Saturation_ix = *rtu_In_V_tas_kn; } - if (rtb_Gain1_e > A380PitchNormalLaw_rtP.Saturation2_UpperSat) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation2_UpperSat; - } else if (rtb_Gain1_e < A380PitchNormalLaw_rtP.Saturation2_LowerSat) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation2_LowerSat; + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation2_UpperSat) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation2_UpperSat; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation2_LowerSat) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation2_LowerSat; } - rtb_Sum_ma = (A380PitchNormalLaw_rtP.Gain_Gain_jq * A380PitchNormalLaw_rtP.Vm_currentms_Value_b * rtb_Divide_l + - rtb_Gain_av) - (rtb_Sum_ma / (A380PitchNormalLaw_rtP.Gain5_Gain_m * rtb_v_target) + - A380PitchNormalLaw_rtP.Bias_Bias_m) * ((rtb_Y_a + look1_binlxpw(rtb_Gain1_e, - A380PitchNormalLaw_rtP.Loaddemand2_bp01Data, A380PitchNormalLaw_rtP.Loaddemand2_tableData, 2U)) - rtb_Y_a); - rtb_Saturation_ix = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.PLUT_bp01Data_e, - A380PitchNormalLaw_rtP.PLUT_tableData_g, 1U); - rtb_Y_a = rtb_Sum_ma * rtb_Saturation_ix; - rtb_Saturation_ix = look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_hw, - A380PitchNormalLaw_rtP.DLUT_tableData_l, 1U); - rtb_Loaddemand2 = rtb_Sum_ma * rtb_Saturation_ix * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_c; - rtb_Divide_l = (rtb_Loaddemand2 - A380PitchNormalLaw_DWork.Delay_DSTATE_ds) / *rtu_In_time_dt; - rtb_Gain_av = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_p * *rtu_In_V_tas_kn; + rtb_Sum_ma = (A380PitchNormalLaw_rtP.Gain1_Gain_lk * *rtu_In_qk_deg_s * (A380PitchNormalLaw_rtP.Gain_Gain_jq * + A380PitchNormalLaw_rtP.Vm_currentms_Value_b) + rtb_Gain_g) - (look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_m, A380PitchNormalLaw_rtP.uDLookupTable_tableData_a, 6U) / + (A380PitchNormalLaw_rtP.Gain5_Gain_m * rtb_Saturation_ix) + A380PitchNormalLaw_rtP.Bias_Bias_m) * ((rtb_Y_d + + look1_binlxpw(rtb_Y_g, A380PitchNormalLaw_rtP.Loaddemand2_bp01Data, A380PitchNormalLaw_rtP.Loaddemand2_tableData, 2U)) + - rtb_Y_d); + rtb_Loaddemand2 = rtb_Sum_ma * look1_binlxpw(*rtu_In_V_tas_kn, A380PitchNormalLaw_rtP.DLUT_bp01Data_hw, + A380PitchNormalLaw_rtP.DLUT_tableData_l, 1U) * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_c; + rtb_Y_d = ((rtb_Sum1_mw - A380PitchNormalLaw_DWork.Delay_DSTATE_h) / *rtu_In_time_dt * + A380PitchNormalLaw_rtP.Gain3_Gain_n + rtb_Sum_ma * look1_binlxpw(*rtu_In_V_tas_kn, + A380PitchNormalLaw_rtP.PLUT_bp01Data_e, A380PitchNormalLaw_rtP.PLUT_tableData_g, 1U)) + (rtb_Loaddemand2 - + A380PitchNormalLaw_DWork.Delay_DSTATE_ds) / *rtu_In_time_dt; + rtb_Gain_g = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs2_Gain_p * *rtu_In_V_tas_kn; rtb_Sum_ma = A380PitchNormalLaw_DWork.Delay_DSTATE_jt; - rtb_v_target = (rtb_Gain_av - A380PitchNormalLaw_DWork.Delay_DSTATE_jt) / *rtu_In_time_dt; - A380PitchNormalLaw_LagFilter(rtb_v_target, A380PitchNormalLaw_rtP.LagFilter_C1_f, rtu_In_time_dt, &rtb_Sum_ma, - &A380PitchNormalLaw_DWork.sf_LagFilter); + A380PitchNormalLaw_LagFilter((rtb_Gain_g - A380PitchNormalLaw_DWork.Delay_DSTATE_jt) / *rtu_In_time_dt, + A380PitchNormalLaw_rtP.LagFilter_C1_f, rtu_In_time_dt, &rtb_Sum_ma, &A380PitchNormalLaw_DWork.sf_LagFilter); if (rtb_Sum_ma > A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_j2) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationV_dot_UpperSat_j2; } else if (rtb_Sum_ma < A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_n) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationV_dot_LowerSat_n; } - rtb_Gain_f = A380PitchNormalLaw_rtP.Gain_Gain_l0 * rtb_Sum_ma; - A380PitchNormalLaw_WashoutFilter(rtb_Gain5_gq, A380PitchNormalLaw_rtP.WashoutFilter_C1_j, rtu_In_time_dt, &rtb_Sum_ma, + rtb_Gain_ch = A380PitchNormalLaw_rtP.Gain_Gain_l0 * rtb_Sum_ma; + A380PitchNormalLaw_WashoutFilter(rtb_Product_d, A380PitchNormalLaw_rtP.WashoutFilter_C1_j, rtu_In_time_dt, &rtb_Sum_ma, &A380PitchNormalLaw_DWork.sf_WashoutFilter); rtb_Saturation_ix = look1_binlxpw(*rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_b, A380PitchNormalLaw_rtP.ScheduledGain_Table_e, 3U); - rtb_v_target = (((A380PitchNormalLaw_rtP.Gain3_Gain * rtb_Divide + rtb_Product1_dm) + rtb_Divide_o) + - A380PitchNormalLaw_rtP.Gain_Gain_l * rtb_Divide_bq) + rtb_Product_kz; + rtb_Y_g = y * look1_binlxpw(*rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1, + A380PitchNormalLaw_rtP.ScheduledGain_Table, 3U) + rtb_Sum1; if (rtb_Sum_ma > A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_m) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationSpoilers_UpperSat_m; } else if (rtb_Sum_ma < A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_d) { rtb_Sum_ma = A380PitchNormalLaw_rtP.SaturationSpoilers_LowerSat_d; } - rtb_Gain1_e = (((A380PitchNormalLaw_rtP.Gain3_Gain_n * rtb_Product1_ck + rtb_Y_a) + rtb_Divide_l) + rtb_Gain_f) + - rtb_Sum_ma * rtb_Saturation_ix; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation_UpperSat_h) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_UpperSat_h; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation_LowerSat_o) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_LowerSat_o; + rtb_Gain_ch = (rtb_Y_d + rtb_Gain_ch) + rtb_Sum_ma * rtb_Saturation_ix; + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation_UpperSat_h) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_UpperSat_h; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation_LowerSat_o) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_LowerSat_o; } - if (rtb_Gain1_e > A380PitchNormalLaw_rtP.Saturation_UpperSat_a) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation_UpperSat_a; - } else if (rtb_Gain1_e < A380PitchNormalLaw_rtP.Saturation_LowerSat_k) { - rtb_Gain1_e = A380PitchNormalLaw_rtP.Saturation_LowerSat_k; + if (rtb_Gain_ch > A380PitchNormalLaw_rtP.Saturation_UpperSat_a) { + rtb_Gain_ch = A380PitchNormalLaw_rtP.Saturation_UpperSat_a; + } else if (rtb_Gain_ch < A380PitchNormalLaw_rtP.Saturation_LowerSat_k) { + rtb_Gain_ch = A380PitchNormalLaw_rtP.Saturation_LowerSat_k; } - A380PitchNormalLaw_VoterAttitudeProtection(rtb_v_target, rtb_Y_k2, rtb_Gain1_e, &rtb_Saturation_ix); - rtb_Sum_ma = look1_binlxpw(*rtu_In_V_ias_kn, A380PitchNormalLaw_rtP.ScheduledGain1_BreakpointsForDimension1, - A380PitchNormalLaw_rtP.ScheduledGain1_Table, 4U); - rtb_Y_a = rtb_Saturation_ix * rtb_Sum_ma; - rtb_Sum_ma = look1_binlxpw(*rtu_In_time_dt, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_d, - A380PitchNormalLaw_rtP.ScheduledGain_Table_hh, 5U); - rtb_Sum_ma = rtb_Y_a * rtb_Sum_ma * A380PitchNormalLaw_rtP.DiscreteTimeIntegratorVariableTs_Gain * *rtu_In_time_dt; - rtb_Y_a = *rtu_In_eta_deg - rtb_Sum_ma; - rtb_AND = ((rtb_Y_pa == 0.0) || (rtb_ManualSwitch == A380PitchNormalLaw_rtP.CompareToConstant_const) || - (*rtu_In_tracking_mode_on)); - A380PitchNormalLaw_DWork.icLoad = (rtb_AND || A380PitchNormalLaw_DWork.icLoad); + A380PitchNormalLaw_VoterAttitudeProtection(rtb_Y_g, rtb_Y_m, rtb_Gain_ch, &rtb_Saturation_ix); + rtb_Sum_ma = rtb_Saturation_ix * look1_binlxpw(*rtu_In_V_ias_kn, + A380PitchNormalLaw_rtP.ScheduledGain1_BreakpointsForDimension1, A380PitchNormalLaw_rtP.ScheduledGain1_Table, 4U) * + look1_binlxpw(*rtu_In_time_dt, A380PitchNormalLaw_rtP.ScheduledGain_BreakpointsForDimension1_d, + A380PitchNormalLaw_rtP.ScheduledGain_Table_hh, 5U) * + A380PitchNormalLaw_rtP.DiscreteTimeIntegratorVariableTs_Gain * *rtu_In_time_dt; + A380PitchNormalLaw_DWork.icLoad = ((rtb_Y_pa == 0.0) || (rtb_Y_c == A380PitchNormalLaw_rtP.CompareToConstant_const) || + (*rtu_In_tracking_mode_on) || A380PitchNormalLaw_DWork.icLoad); if (A380PitchNormalLaw_DWork.icLoad) { - A380PitchNormalLaw_DWork.Delay_DSTATE_o = rtb_Y_a; + A380PitchNormalLaw_DWork.Delay_DSTATE_o = *rtu_In_eta_deg - rtb_Sum_ma; } A380PitchNormalLaw_DWork.Delay_DSTATE_o += rtb_Sum_ma; @@ -1884,13 +1824,13 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In A380PitchNormalLaw_DWork.Delay_DSTATE_o = A380PitchNormalLaw_rtP.DiscreteTimeIntegratorVariableTs_LowerLimit; } - if (rtb_NOT == A380PitchNormalLaw_rtP.CompareToConstant_const_d) { - rtb_Sum_ma = A380PitchNormalLaw_rtP.Constant_Value_b; + if (rtb_eta_trim_deg_should_freeze == A380PitchNormalLaw_rtP.CompareToConstant_const_d) { + rtb_Product_d = A380PitchNormalLaw_rtP.Constant_Value_b; } else { - rtb_Sum_ma = A380PitchNormalLaw_DWork.Delay_DSTATE_o; + rtb_Product_d = A380PitchNormalLaw_DWork.Delay_DSTATE_o; } - rtb_Sum_ma *= A380PitchNormalLaw_rtP.Gain_Gain_cy; + rtb_Sum_ma = A380PitchNormalLaw_rtP.Gain_Gain_cy * rtb_Product_d; if (rtb_Sum_ma > rtb_eta_trim_deg_rate_limit_up_deg_s) { *rty_Out_eta_trim_dot_deg_s = rtb_eta_trim_deg_rate_limit_up_deg_s; } else if (rtb_Sum_ma < rtb_eta_trim_deg_rate_limit_lo_deg_s) { @@ -1907,49 +1847,42 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In rtb_Sum_ma = rtb_Y_pa; } - rtb_Product1_dm = A380PitchNormalLaw_DWork.Delay_DSTATE_o * rtb_Sum_ma; - rtb_Divide = A380PitchNormalLaw_rtP.Constant_Value_o1 - rtb_Sum_ma; + rtb_Product_d = A380PitchNormalLaw_DWork.Delay_DSTATE_o * rtb_Sum_ma; + rtb_Sum1 = A380PitchNormalLaw_rtP.Constant_Value_o1 - rtb_Sum_ma; A380PitchNormalLaw_RateLimiter_h(rtu_In_delta_eta_pos, A380PitchNormalLaw_rtP.RateLimiterVariableTs_up_na, A380PitchNormalLaw_rtP.RateLimiterVariableTs_lo_i, rtu_In_time_dt, - A380PitchNormalLaw_rtP.RateLimiterVariableTs_InitialCondition_m, &rtb_Y_a, + A380PitchNormalLaw_rtP.RateLimiterVariableTs_InitialCondition_m, &rtb_Y_d, &A380PitchNormalLaw_DWork.sf_RateLimiter_ct); - rtb_Sum_ma = look2_binlxpw(*rtu_In_Theta_deg, *rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_l, - A380PitchNormalLaw_rtP.uDLookupTable_bp02Data, A380PitchNormalLaw_rtP.uDLookupTable_tableData_e5, - A380PitchNormalLaw_rtP.uDLookupTable_maxIndex, 5U); - rtb_Saturation_ix = *rtu_In_tailstrike_protection_on; - if (rtb_Y_a > A380PitchNormalLaw_rtP.Saturation3_UpperSat_l) { - rtb_Y_k2 = A380PitchNormalLaw_rtP.Saturation3_UpperSat_l; - } else if (rtb_Y_a < A380PitchNormalLaw_rtP.Saturation3_LowerSat_h) { - rtb_Y_k2 = A380PitchNormalLaw_rtP.Saturation3_LowerSat_h; + if (rtb_Y_d > A380PitchNormalLaw_rtP.Saturation3_UpperSat_l) { + rtb_Y_m = A380PitchNormalLaw_rtP.Saturation3_UpperSat_l; + } else if (rtb_Y_d < A380PitchNormalLaw_rtP.Saturation3_LowerSat_h) { + rtb_Y_m = A380PitchNormalLaw_rtP.Saturation3_LowerSat_h; } else { - rtb_Y_k2 = rtb_Y_a; + rtb_Y_m = rtb_Y_d; } - rtb_Sum_ma = look1_binlxpw(rtb_Saturation_ix * rtb_Sum_ma * rtb_Y_k2 + rtb_Y_a, - A380PitchNormalLaw_rtP.PitchRateDemand_bp01Data, A380PitchNormalLaw_rtP.PitchRateDemand_tableData, 2U); + rtb_Sum_ma = look1_binlxpw(static_cast(*rtu_In_tailstrike_protection_on) * look2_binlxpw(*rtu_In_Theta_deg, + *rtu_In_H_radio_ft, A380PitchNormalLaw_rtP.uDLookupTable_bp01Data_l, A380PitchNormalLaw_rtP.uDLookupTable_bp02Data, + A380PitchNormalLaw_rtP.uDLookupTable_tableData_e5, A380PitchNormalLaw_rtP.uDLookupTable_maxIndex, 5U) * rtb_Y_m + + rtb_Y_d, A380PitchNormalLaw_rtP.PitchRateDemand_bp01Data, A380PitchNormalLaw_rtP.PitchRateDemand_tableData, 2U); rtb_eta_trim_deg_rate_limit_up_deg_s = A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_j3 * rtb_Sum_ma; - rtb_Y_a = (rtb_eta_trim_deg_rate_limit_up_deg_s - A380PitchNormalLaw_DWork.Delay_DSTATE_ej) / *rtu_In_time_dt; rtb_Saturation_ix = *rtu_In_qk_deg_s - rtb_Sum_ma; - rtb_Divide_o = A380PitchNormalLaw_rtP.Gain_Gain_pt * rtb_Saturation_ix; + rtb_Y_d = A380PitchNormalLaw_rtP.Gain_Gain_pt * rtb_Saturation_ix; rtb_eta_trim_deg_rate_limit_lo_deg_s = A380PitchNormalLaw_rtP.Gain1_Gain_d * rtb_Saturation_ix * A380PitchNormalLaw_rtP.DiscreteDerivativeVariableTs_Gain_g; rtb_Saturation_ix = A380PitchNormalLaw_DWork.Delay_DSTATE_e4; - rtb_Divide_bq = (rtb_eta_trim_deg_rate_limit_lo_deg_s - A380PitchNormalLaw_DWork.Delay_DSTATE_e4) / *rtu_In_time_dt; - rtb_Gain5_gq = A380PitchNormalLaw_rtP.Gain5_Gain_h * *rtu_In_qk_dot_deg_s2; - rtb_Gain5_gq += *rtu_In_qk_deg_s; - A380PitchNormalLaw_LagFilter(rtb_Gain5_gq, A380PitchNormalLaw_rtP.LagFilter_C1_k, rtu_In_time_dt, &rtb_Saturation_ix, - &A380PitchNormalLaw_DWork.sf_LagFilter_f); - rtb_Gain5_gq = A380PitchNormalLaw_rtP.Gain6_Gain_g * *rtu_In_qk_dot_deg_s2; - rtb_Y_a = (((rtb_Divide_o + rtb_Divide_bq) * A380PitchNormalLaw_rtP.Gain1_Gain_a + A380PitchNormalLaw_rtP.Gain3_Gain_e - * rtb_Y_a) + (rtb_Saturation_ix - rtb_Sum_ma) * A380PitchNormalLaw_rtP.Gain4_Gain) + rtb_Gain5_gq; - rtb_Sum_ma = look1_binlxpw(*rtu_In_V_ias_kn, A380PitchNormalLaw_rtP.ScheduledGain1_BreakpointsForDimension1_h, - A380PitchNormalLaw_rtP.ScheduledGain1_Table_c, 4U); - rtb_Sum_ma = (A380PitchNormalLaw_rtP.Constant2_Value_k - rtb_Y_pa) * (rtb_Y_a * rtb_Sum_ma) * + A380PitchNormalLaw_LagFilter(*rtu_In_qk_deg_s + A380PitchNormalLaw_rtP.Gain5_Gain_h * *rtu_In_qk_dot_deg_s2, + A380PitchNormalLaw_rtP.LagFilter_C1_k, rtu_In_time_dt, &rtb_Saturation_ix, &A380PitchNormalLaw_DWork.sf_LagFilter_f); + rtb_Sum_ma = (((((rtb_eta_trim_deg_rate_limit_lo_deg_s - A380PitchNormalLaw_DWork.Delay_DSTATE_e4) / *rtu_In_time_dt + + rtb_Y_d) * A380PitchNormalLaw_rtP.Gain1_Gain_a + (rtb_eta_trim_deg_rate_limit_up_deg_s - + A380PitchNormalLaw_DWork.Delay_DSTATE_ej) / *rtu_In_time_dt * A380PitchNormalLaw_rtP.Gain3_Gain_e) + + (rtb_Saturation_ix - rtb_Sum_ma) * A380PitchNormalLaw_rtP.Gain4_Gain) + + A380PitchNormalLaw_rtP.Gain6_Gain_g * *rtu_In_qk_dot_deg_s2) * look1_binlxpw(*rtu_In_V_ias_kn, + A380PitchNormalLaw_rtP.ScheduledGain1_BreakpointsForDimension1_h, A380PitchNormalLaw_rtP.ScheduledGain1_Table_c, 4U) + * (A380PitchNormalLaw_rtP.Constant2_Value_k - rtb_Y_pa) * A380PitchNormalLaw_rtP.DiscreteTimeIntegratorVariableTs_Gain_j * *rtu_In_time_dt; - rtb_NOT = (*rtu_In_delta_eta_pos <= A380PitchNormalLaw_rtP.Constant_Value_o); - rtb_NOT = (rtb_NOT && (*rtu_In_on_ground)); - rtb_NOT = (rtb_NOT || (rtb_Y_lv == 0.0) || (*rtu_In_tracking_mode_on)); - A380PitchNormalLaw_DWork.icLoad_p = (rtb_NOT || A380PitchNormalLaw_DWork.icLoad_p); + A380PitchNormalLaw_DWork.icLoad_p = (((*rtu_In_delta_eta_pos <= A380PitchNormalLaw_rtP.Constant_Value_o) && + (*rtu_In_on_ground)) || (rtb_Y_lv == 0.0) || (*rtu_In_tracking_mode_on) || A380PitchNormalLaw_DWork.icLoad_p); if (A380PitchNormalLaw_DWork.icLoad_p) { A380PitchNormalLaw_DWork.Delay_DSTATE_cl = A380PitchNormalLaw_rtP.Constant_Value_jk - rtb_Sum_ma; } @@ -1984,61 +1917,60 @@ void A380PitchNormalLaw::step(const real_T *rtu_In_time_dt, const real_T *rtu_In } rtb_Gain = (A380PitchNormalLaw_rtP.Constant_Value_h - rtb_Sum_ma) * rtb_Gain + rtb_Y_pa * rtb_Sum_ma; - if (rtb_ManualSwitch > A380PitchNormalLaw_rtP.Saturation_UpperSat_p) { + if (rtb_Y_c > A380PitchNormalLaw_rtP.Saturation_UpperSat_p) { rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation_UpperSat_p; - } else if (rtb_ManualSwitch < A380PitchNormalLaw_rtP.Saturation_LowerSat_hs) { + } else if (rtb_Y_c < A380PitchNormalLaw_rtP.Saturation_LowerSat_hs) { rtb_Sum_ma = A380PitchNormalLaw_rtP.Saturation_LowerSat_hs; } else { - rtb_Sum_ma = rtb_ManualSwitch; + rtb_Sum_ma = rtb_Y_c; } A380PitchNormalLaw_RateLimiter_h(rtu_In_delta_eta_pos, A380PitchNormalLaw_rtP.RateLimiterVariableTs_up_i, A380PitchNormalLaw_rtP.RateLimiterVariableTs_lo_f, rtu_In_time_dt, - A380PitchNormalLaw_rtP.RateLimiterVariableTs_InitialCondition_c, &rtb_Y_k2, + A380PitchNormalLaw_rtP.RateLimiterVariableTs_InitialCondition_c, &rtb_Y_m, &A380PitchNormalLaw_DWork.sf_RateLimiter_h); - rtb_ManualSwitch = A380PitchNormalLaw_rtP.Gain1_Gain_h * *rtu_In_qk_deg_s; - rtb_Y_lv = *rtu_In_nz_g + A380PitchNormalLaw_rtP.Bias_Bias_d; - rtb_v_target = A380PitchNormalLaw_rtP.Gain2_Gain_n * rtb_Y_lv + rtb_ManualSwitch; - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation_UpperSat_g) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_UpperSat_g; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation_LowerSat_kf) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_LowerSat_kf; + rtb_Y_g = (*rtu_In_nz_g + A380PitchNormalLaw_rtP.Bias_Bias_d) * A380PitchNormalLaw_rtP.Gain2_Gain_n + + A380PitchNormalLaw_rtP.Gain1_Gain_h * *rtu_In_qk_deg_s; + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation_UpperSat_g) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_UpperSat_g; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation_LowerSat_kf) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_LowerSat_kf; } - rtb_v_target = (A380PitchNormalLaw_rtP.Gain_Gain_m * rtb_Y_k2 + rtb_v_target) * rtb_Sum_ma + (rtb_Divide * rtb_Gain + - rtb_Product1_dm) * (A380PitchNormalLaw_rtP.Constant_Value_fw - rtb_Sum_ma); - if (rtb_v_target > A380PitchNormalLaw_rtP.Saturation_UpperSat_kp) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_UpperSat_kp; - } else if (rtb_v_target < A380PitchNormalLaw_rtP.Saturation_LowerSat_a4) { - rtb_v_target = A380PitchNormalLaw_rtP.Saturation_LowerSat_a4; + rtb_Y_g = (A380PitchNormalLaw_rtP.Gain_Gain_m * rtb_Y_m + rtb_Y_g) * rtb_Sum_ma + (rtb_Sum1 * rtb_Gain + rtb_Product_d) + * (A380PitchNormalLaw_rtP.Constant_Value_fw - rtb_Sum_ma); + if (rtb_Y_g > A380PitchNormalLaw_rtP.Saturation_UpperSat_kp) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_UpperSat_kp; + } else if (rtb_Y_g < A380PitchNormalLaw_rtP.Saturation_LowerSat_a4) { + rtb_Y_g = A380PitchNormalLaw_rtP.Saturation_LowerSat_a4; } - A380PitchNormalLaw_RateLimiter(rtb_v_target, A380PitchNormalLaw_rtP.RateLimitereta_up, + A380PitchNormalLaw_RateLimiter(rtb_Y_g, A380PitchNormalLaw_rtP.RateLimitereta_up, A380PitchNormalLaw_rtP.RateLimitereta_lo, rtu_In_time_dt, A380PitchNormalLaw_rtP.RateLimitereta_InitialCondition, rty_Out_eta_deg, &A380PitchNormalLaw_DWork.sf_RateLimiter_b); - A380PitchNormalLaw_DWork.Delay_DSTATE = rtb_Gain1; + A380PitchNormalLaw_DWork.Delay_DSTATE = rtb_ManualSwitch; A380PitchNormalLaw_DWork.Delay_DSTATE_n = rtb_Gain_px; A380PitchNormalLaw_DWork.Delay_DSTATE_c = rtb_Gain_ot; - A380PitchNormalLaw_DWork.Delay_DSTATE_l = rtb_Divide_an; - A380PitchNormalLaw_DWork.Delay_DSTATE_k = rtb_Gain1_ft; - A380PitchNormalLaw_DWork.Delay_DSTATE_d = rtb_Gain_bs; + A380PitchNormalLaw_DWork.Delay_DSTATE_l = rtb_Gain_e; + A380PitchNormalLaw_DWork.Delay_DSTATE_k = rtb_Gain_ep; + A380PitchNormalLaw_DWork.Delay_DSTATE_d = rtb_Gain_a; A380PitchNormalLaw_DWork.Delay_DSTATE_f = rtb_y_c; - A380PitchNormalLaw_DWork.Delay_DSTATE_g = ca; - A380PitchNormalLaw_DWork.Delay_DSTATE_j = rtb_y; - A380PitchNormalLaw_DWork.Delay_DSTATE_ca = rtb_Divide_c; + A380PitchNormalLaw_DWork.Delay_DSTATE_g = denom; + A380PitchNormalLaw_DWork.Delay_DSTATE_j = ca; + A380PitchNormalLaw_DWork.Delay_DSTATE_ca = rtb_Divide_nq; A380PitchNormalLaw_DWork.Delay_DSTATE_kd = rtb_alpha_err_gain; - A380PitchNormalLaw_DWork.Delay_DSTATE_ku = rtb_qk_gain; - A380PitchNormalLaw_DWork.Delay_DSTATE_gl = rtb_qk_dot_gain; - A380PitchNormalLaw_DWork.Delay_DSTATE_m = rtb_Gain_ll; - A380PitchNormalLaw_DWork.Delay_DSTATE_k2 = rtb_Divide_k; + A380PitchNormalLaw_DWork.Delay_DSTATE_ku = rtb_Gain_b; + A380PitchNormalLaw_DWork.Delay_DSTATE_gl = rtb_Divide_ew; + A380PitchNormalLaw_DWork.Delay_DSTATE_m = rtb_Gain_fm; + A380PitchNormalLaw_DWork.Delay_DSTATE_k2 = rtb_Divide_ox; A380PitchNormalLaw_DWork.Delay_DSTATE_jh = rtb_Cos; - A380PitchNormalLaw_DWork.Delay_DSTATE_dy = rtb_Y_m; - A380PitchNormalLaw_DWork.Delay_DSTATE_e5 = rtb_Y_j; + A380PitchNormalLaw_DWork.Delay_DSTATE_dy = rtb_Y_k; + A380PitchNormalLaw_DWork.Delay_DSTATE_e5 = rtb_v_target; A380PitchNormalLaw_DWork.Delay_DSTATE_gz = rtb_Y_dd; - A380PitchNormalLaw_DWork.Delay_DSTATE_lf = rtb_Divide_ho; - A380PitchNormalLaw_DWork.Delay_DSTATE_h = rtb_Divide_cq; + A380PitchNormalLaw_DWork.Delay_DSTATE_lf = rtb_Gain_ct; + A380PitchNormalLaw_DWork.Delay_DSTATE_h = rtb_Sum1_mw; A380PitchNormalLaw_DWork.Delay_DSTATE_ds = rtb_Loaddemand2; - A380PitchNormalLaw_DWork.Delay_DSTATE_jt = rtb_Gain_av; + A380PitchNormalLaw_DWork.Delay_DSTATE_jt = rtb_Gain_g; A380PitchNormalLaw_DWork.icLoad = false; A380PitchNormalLaw_DWork.Delay_DSTATE_ej = rtb_eta_trim_deg_rate_limit_up_deg_s; A380PitchNormalLaw_DWork.Delay_DSTATE_e4 = rtb_eta_trim_deg_rate_limit_lo_deg_s; diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_data.cpp b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_data.cpp index 4ea84c19852..8176e098449 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_data.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_data.cpp @@ -3434,8 +3434,8 @@ A380PrimComputer::Parameters_A380PrimComputer_T A380PrimComputer::A380PrimComput -1.0, - { 8.7, 8.7, 6.4, 6.4, 13.6, 13.6, 13.6, 13.6, 13.6, 13.6, 13.6, 13.6, 14.2, 14.2, 14.2, 14.2, 13.1, 13.1, 13.1, 13.1, - 13.0, 13.0, 13.0, 13.0 }, + { 11.0, 11.0, 11.0, 11.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 14.0, 14.0, 14.0, 14.0, 13.4, 13.4, 13.4, + 13.4, 13.4, 13.4, 13.4, 13.4 }, { 0.0, 0.5, 0.9, 1.0 }, @@ -3444,8 +3444,8 @@ A380PrimComputer::Parameters_A380PrimComputer_T A380PrimComputer::A380PrimComput { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }, - { 6.5, 6.5, 4.6, 4.6, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.7, 11.9, 11.9, 11.9, 11.9, 11.0, 11.0, 11.0, 11.0, - 10.6, 10.6, 10.6, 10.6 }, + { 9.0, 9.0, 9.0, 9.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 12.0, 12.0, 12.0, 12.0, 11.3, 11.3, 11.3, 11.3, + 11.3, 11.3, 11.3, 11.3 }, { 0.0, 0.5, 0.9, 1.0 }, diff --git a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_types.h b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_types.h index 5945f725f44..67e9eae30fc 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_types.h +++ b/fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_types.h @@ -30,49 +30,6 @@ enum class SignStatusMatrix #endif -#ifndef DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_ -#define DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_ - -struct base_prim_discrete_inputs -{ - boolean_T prim_overhead_button_pressed; - boolean_T is_unit_1; - boolean_T is_unit_2; - boolean_T is_unit_3; - boolean_T capt_priority_takeover_pressed; - boolean_T fo_priority_takeover_pressed; - boolean_T ap_1_pushbutton_pressed; - boolean_T ap_2_pushbutton_pressed; - boolean_T fcu_healthy; - boolean_T athr_pushbutton; - boolean_T ir_3_on_capt; - boolean_T ir_3_on_fo; - boolean_T adr_3_on_capt; - boolean_T adr_3_on_fo; - boolean_T rat_deployed; - boolean_T rat_contactor_closed; - boolean_T pitch_trim_up_pressed; - boolean_T pitch_trim_down_pressed; - boolean_T green_low_pressure; - boolean_T yellow_low_pressure; -}; - -#endif - -#ifndef DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_ -#define DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_ - -struct base_prim_pitch_surface_positions -{ - real_T left_inboard_elevator_deg; - real_T right_inboard_elevator_deg; - real_T left_outboard_elevator_deg; - real_T right_outboard_elevator_deg; - real_T ths_deg; -}; - -#endif - #ifndef DEFINED_TYPEDEF_FOR_base_arinc_429_ #define DEFINED_TYPEDEF_FOR_base_arinc_429_ @@ -182,15 +139,16 @@ struct base_prim_out_bus #endif -#ifndef DEFINED_TYPEDEF_FOR_base_lgciu_bus_ -#define DEFINED_TYPEDEF_FOR_base_lgciu_bus_ +#ifndef DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_ +#define DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_ -struct base_lgciu_bus +struct base_prim_pitch_surface_positions { - base_arinc_429 discrete_word_1; - base_arinc_429 discrete_word_2; - base_arinc_429 discrete_word_3; - base_arinc_429 discrete_word_4; + real_T left_inboard_elevator_deg; + real_T right_inboard_elevator_deg; + real_T left_outboard_elevator_deg; + real_T right_outboard_elevator_deg; + real_T ths_deg; }; #endif @@ -221,6 +179,35 @@ struct base_sim_data #endif +#ifndef DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_ +#define DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_ + +struct base_prim_discrete_inputs +{ + boolean_T prim_overhead_button_pressed; + boolean_T is_unit_1; + boolean_T is_unit_2; + boolean_T is_unit_3; + boolean_T capt_priority_takeover_pressed; + boolean_T fo_priority_takeover_pressed; + boolean_T ap_1_pushbutton_pressed; + boolean_T ap_2_pushbutton_pressed; + boolean_T fcu_healthy; + boolean_T athr_pushbutton; + boolean_T ir_3_on_capt; + boolean_T ir_3_on_fo; + boolean_T adr_3_on_capt; + boolean_T adr_3_on_fo; + boolean_T rat_deployed; + boolean_T rat_contactor_closed; + boolean_T pitch_trim_up_pressed; + boolean_T pitch_trim_down_pressed; + boolean_T green_low_pressure; + boolean_T yellow_low_pressure; +}; + +#endif + #ifndef DEFINED_TYPEDEF_FOR_base_prim_analog_inputs_ #define DEFINED_TYPEDEF_FOR_base_prim_analog_inputs_ @@ -345,6 +332,19 @@ struct base_sfcc_bus #endif +#ifndef DEFINED_TYPEDEF_FOR_base_lgciu_bus_ +#define DEFINED_TYPEDEF_FOR_base_lgciu_bus_ + +struct base_lgciu_bus +{ + base_arinc_429 discrete_word_1; + base_arinc_429 discrete_word_2; + base_arinc_429 discrete_word_3; + base_arinc_429 discrete_word_4; +}; + +#endif + #ifndef DEFINED_TYPEDEF_FOR_base_prim_bus_inputs_ #define DEFINED_TYPEDEF_FOR_base_prim_bus_inputs_ From b4e8a2c3d3148a278ae50b606f561769e1e9287c Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Thu, 2 Jan 2025 07:25:32 +0100 Subject: [PATCH 05/11] implement simple FCDC --- .../instruments/src/PFD/SpeedIndicator.tsx | 9 ++ .../src/PFD/shared/ArincValueProvider.ts | 64 +++++++++- .../src/PFD/shared/PFDSimvarPublisher.tsx | 12 ++ .../systems/FlightWarningSystem/FwsCore.ts | 16 --- .../wasm/fbw_a380/src/FlyByWireInterface.cpp | 110 +++++++----------- .../wasm/fbw_a380/src/FlyByWireInterface.h | 12 +- fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.cpp | 99 ++++++++++++++++ fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h | 45 +++++++ 8 files changed, 271 insertions(+), 96 deletions(-) create mode 100644 fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.cpp create mode 100644 fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h diff --git a/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx b/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx index 6bc9d971b96..f15b42e9c02 100644 --- a/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx +++ b/fbw-a380x/src/systems/instruments/src/PFD/SpeedIndicator.tsx @@ -1491,6 +1491,15 @@ class VProtBug extends DisplayComponent<{ bus: EventBus }> { .handle((vm) => { this.Vmax = vm; + this.handleVProtBugDisplay(); + }); + + sub + .on('fcdcDiscreteWord1') + .whenChanged() + .handle((dw) => { + this.fcdcWord1 = dw; + this.handleVProtBugDisplay(); }); } diff --git a/fbw-a380x/src/systems/instruments/src/PFD/shared/ArincValueProvider.ts b/fbw-a380x/src/systems/instruments/src/PFD/shared/ArincValueProvider.ts index 9fe82bb60c2..06551f9d391 100644 --- a/fbw-a380x/src/systems/instruments/src/PFD/shared/ArincValueProvider.ts +++ b/fbw-a380x/src/systems/instruments/src/PFD/shared/ArincValueProvider.ts @@ -24,6 +24,8 @@ export interface Arinc429Values { fcdcDiscreteWord1: Arinc429Word; fcdc1DiscreteWord1: Arinc429Word; fcdc2DiscreteWord1: Arinc429Word; + fcdc1DiscreteWord2: Arinc429Word; + fcdc2DiscreteWord2: Arinc429Word; facToUse: number; vAlphaMax: Arinc429Word; vAlphaProt: Arinc429Word; @@ -82,6 +84,16 @@ export class ArincValueProvider implements Instrument { private staticPressure = new Arinc429Word(0); + private fcdc1DiscreteWord1 = new Arinc429Word(0); + + private fcdc2DiscreteWord1 = new Arinc429Word(0); + + private fcdc1DiscreteWord2 = new Arinc429Word(0); + + private fcdc2DiscreteWord2 = new Arinc429Word(0); + + private fcdcToUse = 0; + private fac1Healthy = false; private fac2Healthy = false; @@ -399,12 +411,33 @@ export class ArincValueProvider implements Instrument { publisher.pub('lgciuDiscreteWord1', this.lgciuDiscreteWord1); }); - // Word with Normal Operation status indicating that pitch and roll are in normal law. To be replaced by proper FCDC implementation. - const pitchRollNormalLawNOWord = 14076346368; + subscriber.on('fcdc1DiscreteWord1Raw').handle((discreteWord1) => { + this.fcdc1DiscreteWord1 = new Arinc429Word(discreteWord1); + this.fcdcToUse = this.determineFcdcToUse(); + publisher.pub('fcdc1DiscreteWord1', this.fcdc1DiscreteWord1); + if (this.fcdcToUse === 1) { + publisher.pub('fcdcDiscreteWord1', this.fcdc1DiscreteWord1); + } + }); + + subscriber.on('fcdc2DiscreteWord1Raw').handle((discreteWord1) => { + this.fcdc2DiscreteWord1 = new Arinc429Word(discreteWord1); + this.fcdcToUse = this.determineFcdcToUse(); + publisher.pub('fcdc2DiscreteWord1', this.fcdc2DiscreteWord1); + if (this.fcdcToUse === 2) { + publisher.pub('fcdcDiscreteWord1', this.fcdc2DiscreteWord1); + } + }); + + subscriber.on('fcdc1DiscreteWord2Raw').handle((discreteWord2) => { + this.fcdc1DiscreteWord2 = new Arinc429Word(discreteWord2); + publisher.pub('fcdc1DiscreteWord2', this.fcdc1DiscreteWord2); + }); - publisher.pub('fcdcDiscreteWord1', new Arinc429Word(pitchRollNormalLawNOWord)); - publisher.pub('fcdc1DiscreteWord1', new Arinc429Word(pitchRollNormalLawNOWord)); - publisher.pub('fcdc2DiscreteWord1', new Arinc429Word(pitchRollNormalLawNOWord)); + subscriber.on('fcdc2DiscreteWord2Raw').handle((discreteWord2) => { + this.fcdc2DiscreteWord2 = new Arinc429Word(discreteWord2); + publisher.pub('fcdc2DiscreteWord2', this.fcdc2DiscreteWord2); + }); this.fm1Subs.push( subscriber.on('fm1EisDiscrete2Raw').handle((raw) => publisher.pub('fmEisDiscreteWord2Raw', raw), true), @@ -509,6 +542,27 @@ export class ArincValueProvider implements Instrument { } } + private determineFcdcToUse() { + if (getDisplayIndex() === 1) { + if ( + (this.fcdc1DiscreteWord1.isFailureWarning() && !this.fcdc2DiscreteWord1.isFailureWarning()) || + (!this.fcdc1DiscreteWord1.bitValueOr(24, false) && this.fcdc2DiscreteWord1.bitValueOr(24, false)) + ) { + return 2; + } + return 1; + } + if ( + !( + (!this.fcdc1DiscreteWord1.isFailureWarning() && this.fcdc2DiscreteWord1.isFailureWarning()) || + (this.fcdc1DiscreteWord1.bitValueOr(24, false) && !this.fcdc2DiscreteWord1.bitValueOr(24, false)) + ) + ) { + return 2; + } + return 1; + } + // Determine which FAC bus to use for FE function. If FAC HEALTHY discrete is low or any word is coded FW, // declare FAC as invalid. For simplicty reasons, only check SSM of words that use the same data, so all failure cases are // handled while minimizing the words that have to be checked. diff --git a/fbw-a380x/src/systems/instruments/src/PFD/shared/PFDSimvarPublisher.tsx b/fbw-a380x/src/systems/instruments/src/PFD/shared/PFDSimvarPublisher.tsx index de69cc28db8..0013e326eac 100644 --- a/fbw-a380x/src/systems/instruments/src/PFD/shared/PFDSimvarPublisher.tsx +++ b/fbw-a380x/src/systems/instruments/src/PFD/shared/PFDSimvarPublisher.tsx @@ -113,6 +113,10 @@ export interface PFDSimvars { autoBrakeDecel: boolean; fpaRaw: number; daRaw: number; + fcdc1DiscreteWord1Raw: number; + fcdc2DiscreteWord1Raw: number; + fcdc1DiscreteWord2Raw: number; + fcdc2DiscreteWord2Raw: number; ls1Button: boolean; ls2Button: boolean; xtk: number; @@ -280,6 +284,10 @@ export enum PFDVars { autoBrakeDecel = 'L:A32NX_AUTOBRAKES_DECEL_LIGHT', fpaRaw = 'L:A32NX_ADIRS_IR_1_FLIGHT_PATH_ANGLE', daRaw = 'L:A32NX_ADIRS_IR_1_DRIFT_ANGLE', + fcdc1DiscreteWord1Raw = 'L:A32NX_FCDC_1_DISCRETE_WORD_1', + fcdc2DiscreteWord1Raw = 'L:A32NX_FCDC_2_DISCRETE_WORD_1', + fcdc1DiscreteWord2Raw = 'L:A32NX_FCDC_1_DISCRETE_WORD_2', + fcdc2DiscreteWord2Raw = 'L:A32NX_FCDC_2_DISCRETE_WORD_2', ls1Button = 'L:A380X_EFIS_L_LS_BUTTON_IS_ON', ls2Button = 'L:A380X_EFIS_R_LS_BUTTON_IS_ON', xtk = 'L:A32NX_FG_CROSS_TRACK_ERROR', @@ -446,6 +454,10 @@ export class PFDSimvarPublisher extends UpdatableSimVarPublisher { ['autoBrakeDecel', { name: PFDVars.autoBrakeDecel, type: SimVarValueType.Bool }], ['fpaRaw', { name: PFDVars.fpaRaw, type: SimVarValueType.Number }], ['daRaw', { name: PFDVars.daRaw, type: SimVarValueType.Number }], + ['fcdc1DiscreteWord1Raw', { name: PFDVars.fcdc1DiscreteWord1Raw, type: SimVarValueType.Number }], + ['fcdc2DiscreteWord1Raw', { name: PFDVars.fcdc2DiscreteWord1Raw, type: SimVarValueType.Number }], + ['fcdc1DiscreteWord2Raw', { name: PFDVars.fcdc1DiscreteWord2Raw, type: SimVarValueType.Number }], + ['fcdc2DiscreteWord2Raw', { name: PFDVars.fcdc2DiscreteWord2Raw, type: SimVarValueType.Number }], ['ls1Button', { name: PFDVars.ls1Button, type: SimVarValueType.Bool }], ['ls2Button', { name: PFDVars.ls2Button, type: SimVarValueType.Bool }], ['xtk', { name: PFDVars.xtk, type: SimVarValueType.NM }], diff --git a/fbw-a380x/src/systems/systems-host/systems/FlightWarningSystem/FwsCore.ts b/fbw-a380x/src/systems/systems-host/systems/FlightWarningSystem/FwsCore.ts index 9d4cf36fa3b..999693be6d5 100644 --- a/fbw-a380x/src/systems/systems-host/systems/FlightWarningSystem/FwsCore.ts +++ b/fbw-a380x/src/systems/systems-host/systems/FlightWarningSystem/FwsCore.ts @@ -1680,22 +1680,6 @@ export class FwsCore { healthInjector(): void { SimVar.SetSimVarValue('L:A32NX_NO_SMOKING_MEMO', SimVarValueType.Bool, true); SimVar.SetSimVarValue('L:A32NX_CABIN_READY', SimVarValueType.Bool, true); - - [1, 2].forEach((i) => { - const dw = Arinc429Register.empty(); - dw.setSsm(Arinc429SignStatusMatrix.NormalOperation); - dw.setBitValue(11, true); - dw.setBitValue(16, true); - Arinc429Word.toSimVarValue(`L:A32NX_FCDC_${i}_DISCRETE_WORD_1`, dw.value, dw.ssm); - dw.setValue(0); - Arinc429Word.toSimVarValue(`L:A32NX_FCDC_${i}_DISCRETE_WORD_2`, dw.value, dw.ssm); - [11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25].forEach((i) => dw.setBitValue(i, true)); - Arinc429Word.toSimVarValue(`L:A32NX_FCDC_${i}_DISCRETE_WORD_3`, dw.value, dw.ssm); - dw.setValue(0); - dw.setBitValue(27, SimVar.GetSimVarValue('L:A32NX_SPOILERS_ARMED', SimVarValueType.Bool)); - Arinc429Word.toSimVarValue(`L:A32NX_FCDC_${i}_DISCRETE_WORD_4`, dw.value, dw.ssm); - Arinc429Word.toSimVarValue(`L:A32NX_FCDC_${i}_DISCRETE_WORD_5`, dw.value, dw.ssm); - }); } mapOrder(array, order): [] { diff --git a/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.cpp b/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.cpp index 5850fa32186..1f37c2cb39f 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.cpp +++ b/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.cpp @@ -139,9 +139,9 @@ bool FlyByWireInterface::update(double sampleTime) { result &= updateFac(calculatedSampleTime, i); } - // for (int i = 0; i < 2; i++) { - // result &= updateFcdc(calculatedSampleTime, i); - // } + for (int i = 0; i < 2; i++) { + result &= updateFcdc(calculatedSampleTime, i); + } result &= updateServoSolenoidStatus(); @@ -1684,71 +1684,45 @@ bool FlyByWireInterface::updateSec(double sampleTime, int secIndex) { return true; } -// bool FlyByWireInterface::updateFcdc(double sampleTime, int fcdcIndex) { -// const int oppFcdcIndex = fcdcIndex == 0 ? 1 : 0; -// -// fcdcs[fcdcIndex].discreteInputs.elac1Off = !idElacPushbuttonPressed[0]->get(); -// fcdcs[fcdcIndex].discreteInputs.elac1Valid = elacsDiscreteOutputs[0].digital_output_validated; -// fcdcs[fcdcIndex].discreteInputs.elac2Valid = elacsDiscreteOutputs[1].digital_output_validated; -// fcdcs[fcdcIndex].discreteInputs.sec1Off = !idSecPushbuttonPressed[0]->get(); -// fcdcs[fcdcIndex].discreteInputs.sec1Valid = !secsDiscreteOutputs[0].sec_failed; -// fcdcs[fcdcIndex].discreteInputs.sec2Valid = !secsDiscreteOutputs[1].sec_failed; -// fcdcs[fcdcIndex].discreteInputs.eng1NotOnGroundAndNotLowOilPress = false; -// fcdcs[fcdcIndex].discreteInputs.eng2NotOnGroundAndNotLowOilPress = false; -// fcdcs[fcdcIndex].discreteInputs.noseGearPressed = idLgciuNoseGearCompressed[0]->get(); -// fcdcs[fcdcIndex].discreteInputs.oppFcdcFailed = !fcdcsDiscreteOutputs[oppFcdcIndex].fcdcValid; -// fcdcs[fcdcIndex].discreteInputs.sec3Off = !idSecPushbuttonPressed[2]->get(); -// fcdcs[fcdcIndex].discreteInputs.sec3Valid = !secsDiscreteOutputs[2].sec_failed; -// fcdcs[fcdcIndex].discreteInputs.elac2Off = !idElacPushbuttonPressed[1]->get(); -// fcdcs[fcdcIndex].discreteInputs.sec2Off = !idSecPushbuttonPressed[1]->get(); -// -// fcdcs[fcdcIndex].busInputs.elac1 = elacsBusOutputs[0]; -// fcdcs[fcdcIndex].busInputs.sec1 = secsBusOutputs[0]; -// fcdcs[fcdcIndex].busInputs.fcdcOpp = fcdcsBusOutputs[oppFcdcIndex]; -// fcdcs[fcdcIndex].busInputs.elac2 = elacsBusOutputs[1]; -// fcdcs[fcdcIndex].busInputs.sec2 = secsBusOutputs[1]; -// fcdcs[fcdcIndex].busInputs.sec3 = secsBusOutputs[2]; -// -// fcdcs[fcdcIndex].update(sampleTime, failuresConsumer.isActive(fcdcIndex == 0 ? Failures::Fcdc1 : Failures::Fcdc2), -// fcdcIndex == 0 ? idElecDcEssShedBusPowered->get() : idElecDcBus2Powered->get()); -// -// fcdcsDiscreteOutputs[fcdcIndex] = fcdcs[fcdcIndex].getDiscreteOutputs(); -// FcdcBus bus = fcdcs[fcdcIndex].getBusOutputs(); -// fcdcsBusOutputs[fcdcIndex] = *reinterpret_cast(&bus); -// -// idFcdcDiscreteWord1[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].efcs_status_word_1)); -// idFcdcDiscreteWord2[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].efcs_status_word_2)); -// idFcdcDiscreteWord3[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].efcs_status_word_3)); -// idFcdcDiscreteWord4[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].efcs_status_word_4)); -// idFcdcDiscreteWord5[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].efcs_status_word_5)); -// idFcdcCaptRollCommand[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].capt_roll_command_deg)); -// idFcdcFoRollCommand[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].fo_roll_command_deg)); -// idFcdcCaptPitchCommand[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].capt_pitch_command_deg)); -// idFcdcFoPitchCommand[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].fo_pitch_command_deg)); -// idFcdcRudderPedalPos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].rudder_pedal_position_deg)); -// idFcdcAileronLeftPos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].aileron_left_pos_deg)); -// idFcdcElevatorLeftPos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].elevator_left_pos_deg)); -// idFcdcAileronRightPos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].aileron_right_pos_deg)); -// idFcdcElevatorRightPos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].elevator_right_pos_deg)); -// idFcdcElevatorTrimPos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].horiz_stab_trim_pos_deg)); -// idFcdcSpoilerLeft1Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_1_left_pos_deg)); -// idFcdcSpoilerLeft2Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_2_left_pos_deg)); -// idFcdcSpoilerLeft3Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_3_left_pos_deg)); -// idFcdcSpoilerLeft4Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_4_left_pos_deg)); -// idFcdcSpoilerLeft5Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_5_left_pos_deg)); -// idFcdcSpoilerRight1Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_1_right_pos_deg)); -// idFcdcSpoilerRight2Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_2_right_pos_deg)); -// idFcdcSpoilerRight3Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_3_right_pos_deg)); -// idFcdcSpoilerRight4Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_4_right_pos_deg)); -// idFcdcSpoilerRight5Pos[fcdcIndex]->set(Arinc429Utils::toSimVar(fcdcsBusOutputs[fcdcIndex].spoiler_5_right_pos_deg)); -// -// idFcdcPriorityCaptGreen[fcdcIndex]->set(fcdcsDiscreteOutputs[fcdcIndex].captGreenPriorityLightOn); -// idFcdcPriorityCaptRed[fcdcIndex]->set(fcdcsDiscreteOutputs[fcdcIndex].captRedPriorityLightOn); -// idFcdcPriorityFoGreen[fcdcIndex]->set(fcdcsDiscreteOutputs[fcdcIndex].foGreenPriorityLightOn); -// idFcdcPriorityFoRed[fcdcIndex]->set(fcdcsDiscreteOutputs[fcdcIndex].foRedPriorityLightOn); -// -// return true; -// } +bool FlyByWireInterface::updateFcdc(double sampleTime, int fcdcIndex) { + // do not further process when active pause is on + if (simConnectInterface.isSimInActivePause()) { + return true; + } + + const int oppFcdcIndex = fcdcIndex == 0 ? 1 : 0; + + // Phase 1 of refactoring: Populate FCDC discrete words as per a32nx spec, disregarding the obvious differences. + // Target: Should behave unsuspiciously in normal ops + // Select master PRIM, use it for population of FCDC discrete words + int masterPrim = -1; + for (int i = 0; i < 3; i++) { + if (primsDiscreteOutputs[i].prim_healthy) { + masterPrim = i; + break; + } + } + + FcdcBus output = {}; + + if (masterPrim == -1) { + output.efcsStatus1.setSsm(Arinc429SignStatus::FailureWarning); + output.efcsStatus2.setSsm(Arinc429SignStatus::FailureWarning); + output.efcsStatus3.setSsm(Arinc429SignStatus::FailureWarning); + output.efcsStatus4.setSsm(Arinc429SignStatus::FailureWarning); + output.efcsStatus5.setSsm(Arinc429SignStatus::FailureWarning); + } else { + output = fcdcs[fcdcIndex].update(primsBusOutputs[masterPrim], spoilersHandler->getIsArmed() ? true : false); + } + + idFcdcDiscreteWord1[fcdcIndex]->set(output.efcsStatus1.toSimVar()); + idFcdcDiscreteWord2[fcdcIndex]->set(output.efcsStatus2.toSimVar()); + idFcdcDiscreteWord3[fcdcIndex]->set(output.efcsStatus3.toSimVar()); + idFcdcDiscreteWord4[fcdcIndex]->set(output.efcsStatus4.toSimVar()); + idFcdcDiscreteWord5[fcdcIndex]->set(output.efcsStatus5.toSimVar()); + + return true; +} bool FlyByWireInterface::updateFac(double sampleTime, int facIndex) { // do not further process when active pause is on diff --git a/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.h b/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.h index cb3bd784941..303865b2823 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.h +++ b/fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.h @@ -12,14 +12,14 @@ #include "ThrottleAxisMapping.h" #include "fac/Fac.h" #include "failures/FailuresConsumer.h" +#include "fcdc/Fcdc.h" #include "interface/SimConnectInterface.h" #include "model/AutopilotLaws.h" #include "model/AutopilotStateMachine.h" #include "model/Autothrust.h" +#include "prim/Prim.h" #include "recording/FlightDataRecorder.h" #include "recording/RecordingDataTypes.h" -// #include "fcdc/Fcdc.h" -#include "prim/Prim.h" #include "sec/Sec.h" #include "utils/HysteresisNode.h" @@ -142,10 +142,8 @@ class FlyByWireInterface { base_sec_discrete_outputs secsDiscreteOutputs[3] = {}; base_sec_analog_outputs secsAnalogOutputs[3] = {}; base_sec_out_bus secsBusOutputs[3] = {}; - // - // Fcdc fcdcs[2] = {Fcdc(true), Fcdc(false)}; - // FcdcDiscreteOutputs fcdcsDiscreteOutputs[2] = {}; - // base_fcdc_bus fcdcsBusOutputs[2] = {}; + + Fcdc fcdcs[2] = {Fcdc(true), Fcdc(false)}; Fac facs[2] = {Fac(true), Fac(false)}; base_fac_discrete_outputs facsDiscreteOutputs[2] = {}; @@ -588,7 +586,7 @@ class FlyByWireInterface { bool updateSec(double sampleTime, int secIndex); - // bool updateFcdc(double sampleTime, int fcdcIndex); + bool updateFcdc(double sampleTime, int fcdcIndex); bool updateFac(double sampleTime, int facIndex); diff --git a/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.cpp b/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.cpp new file mode 100644 index 00000000000..f99d812801d --- /dev/null +++ b/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.cpp @@ -0,0 +1,99 @@ +#include "Fcdc.h" +#include + +using namespace Arinc429Utils; + +Fcdc::Fcdc(bool isUnit1) : isUnit1(isUnit1) {} + +FcdcBus Fcdc::update(base_prim_out_bus primsBusOutputs, bool spoilersArmed) { + FcdcBus output = {}; + + LateralLaw systemLateralLaw = getLateralLawStatusFromBits(bitFromValue(primsBusOutputs.fctl_law_status_word, 19), + bitFromValue(primsBusOutputs.fctl_law_status_word, 20)); + + PitchLaw systemPitchLaw = getPitchLawStatusFromBits(bitFromValue(primsBusOutputs.fctl_law_status_word, 16), + bitFromValue(primsBusOutputs.fctl_law_status_word, 17), + bitFromValue(primsBusOutputs.fctl_law_status_word, 18)); + + output.efcsStatus1.setData(0); + output.efcsStatus1.setSsm(Arinc429SignStatus::NormalOperation); + output.efcsStatus1.setBit(11, systemPitchLaw == PitchLaw::NormalLaw); + output.efcsStatus1.setBit(12, systemPitchLaw == PitchLaw::AlternateLaw1A || systemPitchLaw == PitchLaw::AlternateLaw1B || + systemPitchLaw == PitchLaw::AlternateLaw1C); + output.efcsStatus1.setBit(13, systemPitchLaw == PitchLaw::AlternateLaw2); + output.efcsStatus1.setBit(15, systemPitchLaw == PitchLaw::DirectLaw); + output.efcsStatus1.setBit(16, systemLateralLaw == LateralLaw::NormalLaw); + output.efcsStatus1.setBit(17, systemLateralLaw == LateralLaw::DirectLaw); + + output.efcsStatus2.setData(0); + output.efcsStatus2.setSsm(Arinc429SignStatus::NormalOperation); + + output.efcsStatus3.setData(0); + output.efcsStatus3.setSsm(Arinc429SignStatus::NormalOperation); + output.efcsStatus3.setBit(11, bitFromValue(primsBusOutputs.aileron_status_word, 11)); + output.efcsStatus3.setBit(12, bitFromValue(primsBusOutputs.aileron_status_word, 11)); + output.efcsStatus3.setBit(13, bitFromValue(primsBusOutputs.aileron_status_word, 14)); + output.efcsStatus3.setBit(14, bitFromValue(primsBusOutputs.aileron_status_word, 14)); + output.efcsStatus3.setBit(15, bitFromValue(primsBusOutputs.elevator_status_word, 11)); + output.efcsStatus3.setBit(16, bitFromValue(primsBusOutputs.elevator_status_word, 11)); + output.efcsStatus3.setBit(17, bitFromValue(primsBusOutputs.elevator_status_word, 14)); + output.efcsStatus3.setBit(18, bitFromValue(primsBusOutputs.elevator_status_word, 14)); + output.efcsStatus3.setBit(21, bitFromValue(primsBusOutputs.spoiler_status_word, 11)); + output.efcsStatus3.setBit(22, bitFromValue(primsBusOutputs.spoiler_status_word, 11)); + output.efcsStatus3.setBit(23, bitFromValue(primsBusOutputs.spoiler_status_word, 11)); + output.efcsStatus3.setBit(24, bitFromValue(primsBusOutputs.spoiler_status_word, 11)); + output.efcsStatus3.setBit(25, bitFromValue(primsBusOutputs.spoiler_status_word, 11)); + + output.efcsStatus4.setData(0); + output.efcsStatus4.setSsm(Arinc429SignStatus::NormalOperation); + output.efcsStatus4.setBit(11, valueOr(primsBusOutputs.left_spoiler_1_command_deg, 0) > 0); + output.efcsStatus4.setBit(12, valueOr(primsBusOutputs.right_spoiler_1_command_deg, 0) > 0); + output.efcsStatus4.setBit(13, valueOr(primsBusOutputs.left_spoiler_2_command_deg, 0) > 0); + output.efcsStatus4.setBit(14, valueOr(primsBusOutputs.right_spoiler_2_command_deg, 0) > 0); + output.efcsStatus4.setBit(15, valueOr(primsBusOutputs.left_spoiler_3_command_deg, 0) > 0); + output.efcsStatus4.setBit(16, valueOr(primsBusOutputs.right_spoiler_3_command_deg, 0) > 0); + output.efcsStatus4.setBit(17, valueOr(primsBusOutputs.left_spoiler_4_command_deg, 0) > 0); + output.efcsStatus4.setBit(18, valueOr(primsBusOutputs.right_spoiler_4_command_deg, 0) > 0); + output.efcsStatus4.setBit(19, valueOr(primsBusOutputs.left_spoiler_5_command_deg, 0) > 0); + output.efcsStatus4.setBit(20, valueOr(primsBusOutputs.right_spoiler_5_command_deg, 0) > 0); + output.efcsStatus4.setBit(21, true); + output.efcsStatus4.setBit(22, true); + output.efcsStatus4.setBit(23, true); + output.efcsStatus4.setBit(24, true); + output.efcsStatus4.setBit(25, true); + output.efcsStatus4.setBit(26, valueOr(primsBusOutputs.left_spoiler_1_command_deg, 0) > 10); + output.efcsStatus4.setBit(27, spoilersArmed); + + output.efcsStatus5.setData(0); + output.efcsStatus5.setSsm(Arinc429SignStatus::NormalOperation); + + return output; +} + +PitchLaw Fcdc::getPitchLawStatusFromBits(bool bit1, bool bit2, bool bit3) { + if (!bit1 && !bit2 && bit3) { + return PitchLaw::NormalLaw; + } else if (!bit1 && bit2 && !bit3) { + return PitchLaw::AlternateLaw1A; + } else if (!bit1 && bit2 && bit3) { + return PitchLaw::AlternateLaw1B; + } else if (bit1 && !bit2 && !bit3) { + return PitchLaw::AlternateLaw1C; + } else if (bit1 && !bit2 && bit3) { + return PitchLaw::AlternateLaw2; + } else if (bit1 && bit2 && !bit3) { + return PitchLaw::DirectLaw; + } else { + return PitchLaw::None; + } +} + +LateralLaw Fcdc::getLateralLawStatusFromBits(bool bit1, bool bit2) { + if (bit1) { + return LateralLaw::NormalLaw; + } else if (bit2) { + return LateralLaw::DirectLaw; + } else { + return LateralLaw::None; + } +} diff --git a/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h b/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h new file mode 100644 index 00000000000..1e7c3fb4e1e --- /dev/null +++ b/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h @@ -0,0 +1,45 @@ +#pragma once + +#include "../Arinc429Utils.h" +#include "../model/A380PrimComputer.h" + +struct FcdcBus { + // Label 040 + Arinc429DiscreteWord efcsStatus1; + // Label 041 + Arinc429DiscreteWord efcsStatus2; + // Label 042 + Arinc429DiscreteWord efcsStatus3; + // Label 043 + Arinc429DiscreteWord efcsStatus4; + // Label 044 + Arinc429DiscreteWord efcsStatus5; +}; + +enum class LateralLaw { + NormalLaw, + DirectLaw, + None, +}; + +enum class PitchLaw { + NormalLaw, + AlternateLaw1A, + AlternateLaw1B, + AlternateLaw1C, + AlternateLaw2, + DirectLaw, + None, +}; + +class Fcdc { + public: + Fcdc(bool isUnit1); + + FcdcBus update(base_prim_out_bus primsBusOutputs, bool spoilersArmed); + + private: + PitchLaw getPitchLawStatusFromBits(bool bit1, bool bit2, bool bit3); + + LateralLaw getLateralLawStatusFromBits(bool bit1, bool bit2); +}; From 41e5ec63f26fd0918f95f09b16418ed1df0fcfe1 Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:53:41 +0100 Subject: [PATCH 06/11] fix FCDC build --- fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt | 1 + fbw-a380x/src/wasm/fbw_a380/build.sh | 2 ++ fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h | 3 +++ 3 files changed, 6 insertions(+) diff --git a/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt b/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt index b9d0ac01e0c..fae88cd5acd 100644 --- a/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt +++ b/fbw-a380x/src/wasm/fbw_a380/CMakeLists.txt @@ -43,6 +43,7 @@ add_executable(flybywire-a380x-fbw src/SpoilersHandler.cpp src/fac/Fac.cpp src/failures/FailuresConsumer.cpp + src/fcdc/Fcdc.cpp src/interface/SimConnectInterface.cpp src/model/A380FacComputer_data.cpp src/model/A380FacComputer.cpp diff --git a/fbw-a380x/src/wasm/fbw_a380/build.sh b/fbw-a380x/src/wasm/fbw_a380/build.sh index 5c7e761741e..128037c4fe5 100755 --- a/fbw-a380x/src/wasm/fbw_a380/build.sh +++ b/fbw-a380x/src/wasm/fbw_a380/build.sh @@ -101,6 +101,8 @@ clang++ \ "${DIR}/src/fac/Fac.cpp" \ -I "${DIR}/src/failures" \ "${DIR}/src/failures/FailuresConsumer.cpp" \ + -I "${DIR}/src/fcdc" \ + "${DIR}/src/fcdc/Fcdc.cpp" \ -I "${DIR}/src/utils" \ "${DIR}/src/utils/ConfirmNode.cpp" \ "${DIR}/src/utils/SRFlipFLop.cpp" \ diff --git a/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h b/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h index 1e7c3fb4e1e..276d5ffe5aa 100644 --- a/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h +++ b/fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h @@ -1,5 +1,6 @@ #pragma once +#include "../Arinc429.h" #include "../Arinc429Utils.h" #include "../model/A380PrimComputer.h" @@ -42,4 +43,6 @@ class Fcdc { PitchLaw getPitchLawStatusFromBits(bool bit1, bool bit2, bool bit3); LateralLaw getLateralLawStatusFromBits(bool bit1, bool bit2); + + const bool isUnit1; }; From c4d27c00e5468bc47c949a3ff2e34b0fabf4eda8 Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:54:07 +0100 Subject: [PATCH 07/11] fix VfeN and vMax in A380OperatingSpeeds --- .../systems/shared/src/OperatingSpeeds.tsx | 55 +++---------------- 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/fbw-a380x/src/systems/shared/src/OperatingSpeeds.tsx b/fbw-a380x/src/systems/shared/src/OperatingSpeeds.tsx index f5fcd90d7c3..e72ee81fbe4 100644 --- a/fbw-a380x/src/systems/shared/src/OperatingSpeeds.tsx +++ b/fbw-a380x/src/systems/shared/src/OperatingSpeeds.tsx @@ -7,8 +7,7 @@ // TODO: Weight interpolation is different for the two CG extremes, one formula might be too inaccurate. import { Feet, Knots } from 'msfs-geo'; -import { MathUtils } from '@flybywiresim/fbw-sdk'; -import { Mmo, VfeF1, VfeF1F, VfeF2, VfeF3, VfeFF, Vmcl, Vmo } from '@shared/PerformanceConstants'; +import { VfeF1, VfeF1F, VfeF2, VfeF3, VfeFF, Vmcl, Vmo } from '@shared/PerformanceConstants'; import { FmgcFlightPhase } from '@shared/flightphase'; import { LerpLookupTable } from '@microsoft/msfs-sdk'; @@ -348,11 +347,12 @@ const vmcg = [ * Vfe for Flaps/Slats */ const vfeFS = [ + Vmo, + VfeF1, // Config 1 VfeF1F, // Config 1 + F VfeF2, // Config 2 VfeF3, // Config 3 VfeFF, // Config Full - VfeF1, // Config 1 ]; /** @@ -386,47 +386,6 @@ function getdiffAngle(a: number, b: number): number { return 180 - Math.abs(Math.abs(a - b) - 180); } -/** - * Get next flaps index for vfeFS table - * @returns vfeFS table index - * @private - */ -function getVfeNIdx(fi: number): number { - switch (fi) { - case 0: - return 4; - case 5: - return 1; - default: - return fi; - } -} - -/** - * Convert degrees Celsius into Kelvin - * @param T degrees Celsius - * @returns degrees Kelvin - */ -function convertCtoK(T: number): number { - return T + 273.15; -} - -/** - * Get correct Vmax for Vmo and Mmo in knots - * @returns Min(Vmo, Mmo) - * @private - */ -function getVmo() { - return Math.min( - Vmo, - MathUtils.convertMachToKCas( - Mmo, - convertCtoK(Simplane.getAmbientTemperature()), - SimVar.GetSimVarValue('AMBIENT PRESSURE', 'millibar'), - ), - ); -} - export class A380OperatingSpeeds { public vs1g: number; @@ -471,17 +430,21 @@ export class A380OperatingSpeeds { if (fPos === 0) { this.vls = SpeedsLookupTables.VLS_CONF_0.get(altitude, m); + this.vmax = Vmo; + this.vfeN = vfeFS[1]; } else if (fPos === 1 && calibratedAirSpeed > 212) { this.vls = SpeedsLookupTables.getApproachVls(ApproachConf.CONF_1, cg, m); + this.vmax = vfeFS[1]; + this.vfeN = vfeFS[2]; } else { this.vls = SpeedsLookupTables.getApproachVls(fPos + 1, cg, m); + this.vmax = vfeFS[fPos + 1]; + this.vfeN = fPos === 4 ? 0 : vfeFS[fPos + 2]; } this.vapp = this.vls + addWindComponent(wind); this.vref = this.vls = SpeedsLookupTables.getApproachVls(ApproachConf.CONF_FULL, cg, m); this.gd = SpeedsLookupTables.GREEN_DOT.get(altitude, m); - this.vmax = fPos === 0 ? getVmo() : vfeFS[fPos - 1]; - this.vfeN = fPos === 4 ? 0 : vfeFS[getVfeNIdx(fPos)]; this.vs1g = this.vls / 1.23; this.vls = Math.max(1.23 * this.vs1g, Vmcl); From 9583e06e30db9614f307d17002fd984797bf5618 Mon Sep 17 00:00:00 2001 From: flogross89 <63071941+flogross89@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:29:00 +0100 Subject: [PATCH 08/11] add direct law PFD indications --- .../src/PFD/AttitudeIndicatorFixed.tsx | 26 ++- .../src/PFD/AttitudeIndicatorHorizon.tsx | 38 +++- .../src/systems/instruments/src/PFD/FMA.tsx | 26 ++- .../instruments/src/PFD/SpeedIndicator.tsx | 76 ++++---- .../wasm/fbw_a380/src/FlyByWireInterface.cpp | 32 ++-- .../wasm/fbw_a380/src/FlyByWireInterface.h | 3 + fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.cpp | 174 ++++++++++++++---- fbw-a380x/src/wasm/fbw_a380/src/fcdc/Fcdc.h | 40 +++- 8 files changed, 299 insertions(+), 116 deletions(-) diff --git a/fbw-a380x/src/systems/instruments/src/PFD/AttitudeIndicatorFixed.tsx b/fbw-a380x/src/systems/instruments/src/PFD/AttitudeIndicatorFixed.tsx index d7c775cf227..5db0fa26552 100644 --- a/fbw-a380x/src/systems/instruments/src/PFD/AttitudeIndicatorFixed.tsx +++ b/fbw-a380x/src/systems/instruments/src/PFD/AttitudeIndicatorFixed.tsx @@ -1,6 +1,6 @@ import { DisplayComponent, EventBus, FSComponent, Subject, Subscribable, VNode } from '@microsoft/msfs-sdk'; import { getDisplayIndex } from 'instruments/src/PFD/PFD'; -import { Arinc429Word } from '@flybywiresim/fbw-sdk'; +import { Arinc429ConsumerSubject, Arinc429Word } from '@flybywiresim/fbw-sdk'; import { FlightPathDirector } from './FlightPathDirector'; import { FlightPathVector } from './FlightPathVector'; import { Arinc429Values } from './shared/ArincValueProvider'; @@ -11,18 +11,22 @@ interface AttitudeIndicatorFixedUpperProps { } export class AttitudeIndicatorFixedUpper extends DisplayComponent { + private readonly sub = this.props.bus.getSubscriber(); + private roll = new Arinc429Word(0); private pitch = new Arinc429Word(0); private visibilitySub = Subject.create('hidden'); + private readonly fcdcDiscreteWord1 = Arinc429ConsumerSubject.create(this.sub.on('fcdcDiscreteWord1')); + + private readonly isNormalLawActive = this.fcdcDiscreteWord1.map((dw) => dw.bitValue(11) && !dw.isFailureWarning()); + onAfterRender(node: VNode): void { super.onAfterRender(node); - const sub = this.props.bus.getSubscriber(); - - sub.on('rollAr').handle((roll) => { + this.sub.on('rollAr').handle((roll) => { this.roll = roll; if (!this.roll.isNormalOperation()) { this.visibilitySub.set('hidden'); @@ -31,7 +35,7 @@ export class AttitudeIndicatorFixedUpper extends DisplayComponent { + this.sub.on('pitchAr').handle((pitch) => { this.pitch = pitch; if (!this.pitch.isNormalOperation()) { this.visibilitySub.set('hidden'); @@ -44,11 +48,19 @@ export class AttitudeIndicatorFixedUpper extends DisplayComponent - + (nl ? 'block' : 'none')) }} + > - - + (nl ? 'inherit' : 'none')) }} + > -