You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
410 lines
13 KiB
410 lines
13 KiB
/*
|
|
* WindModeltestfinal.c
|
|
*
|
|
* Code generation for model "WindModeltestfinal".
|
|
*
|
|
* Model version : 1.86
|
|
* Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
|
|
* C source code generated on : Wed Apr 9 14:29:01 2025
|
|
*
|
|
* Target selection: grt.tlc
|
|
* Note: GRT includes extra infrastructure and instrumentation for prototyping
|
|
* Embedded hardware selection: Intel->x86-64 (Windows64)
|
|
* Code generation objectives: Unspecified
|
|
* Validation result: Not run
|
|
*/
|
|
|
|
#include "WindModeltestfinal.h"
|
|
#include "WindModeltestfinal_private.h"
|
|
#include<string.h>
|
|
/* Block states (default storage) */
|
|
DW_WindModeltestfinal_T WindModeltestfinal_DW;
|
|
|
|
/* External inputs (root inport signals with default storage) */
|
|
ExtU_WindModeltestfinal_T WindModeltestfinal_U;
|
|
|
|
/* External outputs (root outports fed by signals with default storage) */
|
|
ExtY_WindModeltestfinal_T WindModeltestfinal_Y;
|
|
|
|
/* Real-time model */
|
|
static RT_MODEL_WindModeltestfinal_T WindModeltestfinal_M_;
|
|
RT_MODEL_WindModeltestfinal_T *const WindModeltestfinal_M =
|
|
&WindModeltestfinal_M_;
|
|
|
|
/* Model step function */
|
|
void WindModeltestfinal_step(void)
|
|
{
|
|
float rtb_Sum_c;
|
|
int32_T tmp;
|
|
int32_T tmp_0;
|
|
int32_T tmp_1;
|
|
int32_T tmp_2;
|
|
int32_T tmp_3;
|
|
boolean_T rtb_LogicalOperator_f;
|
|
boolean_T rtb_Switch_i;
|
|
|
|
/* Switch: '<S6>/Switch' incorporates:
|
|
* Constant: '<S1>/WindSpeedMinC'
|
|
* Constant: '<S1>/WindSpeedUpperHystC'
|
|
* Inport: '<Root>/WindSpeedFMSSide'
|
|
* Memory: '<S6>/Memory'
|
|
* RelationalOperator: '<S6>/Relational Operator'
|
|
* RelationalOperator: '<S6>/Relational Operator1'
|
|
*/
|
|
/*
|
|
if (WindModeltestfinal_DW.Memory_PreviousInput) {
|
|
rtb_Switch_i = (WindModeltestfinal_U.WindSpeedFMSSide >=
|
|
WindModeltestfinal_P.WindSpeedMinC_Value);
|
|
} else {
|
|
rtb_Switch_i = (WindModeltestfinal_U.WindSpeedFMSSide >
|
|
WindModeltestfinal_P.WindSpeedUpperHystC_Value);
|
|
}
|
|
* */
|
|
|
|
|
|
/* End of Switch: '<S6>/Switch' */
|
|
|
|
/* RelationalOperator: '<S3>/Relational Operator1' incorporates:
|
|
* Inport: '<Root>/DuConfig'
|
|
*/
|
|
tmp_3 = WindModeltestfinal_U.DuConfig;
|
|
if (WindModeltestfinal_U.DuConfig < 0) {
|
|
tmp_3 = 0;
|
|
}
|
|
|
|
/* Switch: '<S3>/Switch' incorporates:
|
|
* Constant: '<S3>/AFDConfigurationType PFD'
|
|
* Constant: '<S3>/MFDMenuType'
|
|
* Constant: '<S3>/MFDModeType = PLAN'
|
|
* Constant: '<S3>/MFDModeType = TCAS'
|
|
* Constant: '<S3>/MFDModeType= BLANK'
|
|
* Constant: '<S3>/MFDModeType=PPSN'
|
|
* Constant: '<S3>/PFDMenuType'
|
|
* Inport: '<Root>/TrueRefHeadingIsValid'
|
|
* Inport: '<Root>/UnusualAttitude'
|
|
* Inport: '<Root>/WindDirectionTrueFMSSideIsValid'
|
|
* Inport: '<Root>/WindSpeedFMSSideIsValid'
|
|
* Logic: '<S3>/Logical Operator'
|
|
* Logic: '<S3>/Logical Operator1'
|
|
* Logic: '<S3>/Logical Operator2'
|
|
* Logic: '<S3>/Logical Operator3'
|
|
* Logic: '<S3>/Logical Operator4'
|
|
* RelationalOperator: '<S3>/Relational Operator'
|
|
* RelationalOperator: '<S3>/Relational Operator1'
|
|
* RelationalOperator: '<S3>/Relational Operator2'
|
|
* RelationalOperator: '<S3>/Relational Operator3'
|
|
* RelationalOperator: '<S3>/Relational Operator4'
|
|
* RelationalOperator: '<S3>/Relational Operator5'
|
|
* RelationalOperator: '<S3>/Relational Operator6'
|
|
*/
|
|
if ((uint32_T)tmp_3 == WindModeltestfinal_P.AFDConfigurationTypePFD_Value) {
|
|
/* RelationalOperator: '<S3>/Relational Operator' incorporates:
|
|
* Inport: '<Root>/PFDActiveMenu'
|
|
*/
|
|
tmp_3 = WindModeltestfinal_U.PFDActiveMenu;
|
|
if (WindModeltestfinal_U.PFDActiveMenu < 0) {
|
|
tmp_3 = 0;
|
|
}
|
|
|
|
rtb_LogicalOperator_f = ((WindModeltestfinal_U.TrueRefHeadingIsValid != 0) &&
|
|
(WindModeltestfinal_U.WindDirectionTrueFMSSideIsValid != 0) &&
|
|
(WindModeltestfinal_U.WindSpeedFMSSideIsValid != 0) &&
|
|
(WindModeltestfinal_U.UnusualAttitude == 0) && ((uint32_T)tmp_3 ==
|
|
WindModeltestfinal_P.PFDMenuType_Value));
|
|
} else {
|
|
/* RelationalOperator: '<S3>/Relational Operator2' incorporates:
|
|
* Inport: '<Root>/MFDActiveLowerMenu'
|
|
*/
|
|
tmp_3 = WindModeltestfinal_U.MFDActiveLowerMenu;
|
|
if (WindModeltestfinal_U.MFDActiveLowerMenu < 0) {
|
|
tmp_3 = 0;
|
|
}
|
|
|
|
/* RelationalOperator: '<S3>/Relational Operator3' incorporates:
|
|
* Inport: '<Root>/MFDMode2'
|
|
*/
|
|
tmp = WindModeltestfinal_U.MFDMode2;
|
|
if (WindModeltestfinal_U.MFDMode2 < 0) {
|
|
tmp = 0;
|
|
}
|
|
|
|
/* RelationalOperator: '<S3>/Relational Operator4' incorporates:
|
|
* Inport: '<Root>/MFDMode2'
|
|
*/
|
|
tmp_0 = WindModeltestfinal_U.MFDMode2;
|
|
if (WindModeltestfinal_U.MFDMode2 < 0) {
|
|
tmp_0 = 0;
|
|
}
|
|
|
|
/* RelationalOperator: '<S3>/Relational Operator5' incorporates:
|
|
* Inport: '<Root>/MFDMode2'
|
|
*/
|
|
tmp_1 = WindModeltestfinal_U.MFDMode2;
|
|
if (WindModeltestfinal_U.MFDMode2 < 0) {
|
|
tmp_1 = 0;
|
|
}
|
|
|
|
/* RelationalOperator: '<S3>/Relational Operator6' incorporates:
|
|
* Inport: '<Root>/MFDMode2'
|
|
*/
|
|
tmp_2 = WindModeltestfinal_U.MFDMode2;
|
|
if (WindModeltestfinal_U.MFDMode2 < 0) {
|
|
tmp_2 = 0;
|
|
}
|
|
|
|
rtb_LogicalOperator_f = ((WindModeltestfinal_U.WindSpeedFMSSideIsValid != 0)
|
|
&& ((WindModeltestfinal_U.TrueRefHeadingIsValid != 0) &&
|
|
(WindModeltestfinal_U.WindDirectionTrueFMSSideIsValid != 0)) &&
|
|
((uint32_T)tmp_3 == WindModeltestfinal_P.MFDMenuType_Value) && (((uint32_T)
|
|
tmp == WindModeltestfinal_P.MFDModeTypeBLANK_Value) || ((uint32_T)tmp_0 ==
|
|
WindModeltestfinal_P.MFDModeTypePPSN_Value) || ((uint32_T)tmp_1 ==
|
|
WindModeltestfinal_P.MFDModeTypePLAN_Value) || ((uint32_T)tmp_2 ==
|
|
WindModeltestfinal_P.MFDModeTypeTCAS_Value)));
|
|
}
|
|
|
|
/* End of Switch: '<S3>/Switch' */
|
|
|
|
/* Logic: '<S6>/Logical Operator' incorporates:
|
|
* DataTypeConversion: '<S3>/Data Type Conversion'
|
|
*/
|
|
rtb_LogicalOperator_f = (rtb_Switch_i && rtb_LogicalOperator_f);
|
|
|
|
/* Outport: '<Root>/WindVisible' incorporates:
|
|
* DataTypeConversion: '<S2>/Data Type Conversion'
|
|
*/
|
|
WindModeltestfinal_Y.WindVisible = rtb_LogicalOperator_f;
|
|
|
|
/* Sum: '<S7>/Sum' incorporates:
|
|
* Inport: '<Root>/TrueRefHeading'
|
|
* Inport: '<Root>/WindDirectionTrueFMSSide'
|
|
*/
|
|
rtb_Sum_c = WindModeltestfinal_U.WindDirectionTrueFMSSide -
|
|
WindModeltestfinal_U.TrueRefHeading;
|
|
|
|
/* Switch: '<S7>/Switch' incorporates:
|
|
* Abs: '<S7>/Abs'
|
|
* Constant: '<S7>/180'
|
|
* RelationalOperator: '<S7>/Relational Operator'
|
|
*/
|
|
if (!(fabs(rtb_Sum_c) <= WindModeltestfinal_P.u80_Value)) {
|
|
/* Switch: '<S7>/Switch1' incorporates:
|
|
* Constant: '<S7>/0'
|
|
* Constant: '<S7>/360'
|
|
* Constant: '<S7>/360 '
|
|
* RelationalOperator: '<S7>/Relational Operator1'
|
|
* Sum: '<S7>/Sum1'
|
|
* Sum: '<S7>/Sum2'
|
|
*/
|
|
if (rtb_Sum_c > WindModeltestfinal_P.u_Value) {
|
|
rtb_Sum_c -= WindModeltestfinal_P.u60_Value;
|
|
} else {
|
|
rtb_Sum_c += WindModeltestfinal_P.u60_Value_c;
|
|
}
|
|
|
|
/* End of Switch: '<S7>/Switch1' */
|
|
}
|
|
|
|
/* End of Switch: '<S7>/Switch' */
|
|
|
|
/* Sum: '<S8>/Sum' incorporates:
|
|
* Constant: '<S4>/Constant'
|
|
*/
|
|
rtb_Sum_c -= WindModeltestfinal_P.Constant_Value;
|
|
|
|
/* Switch: '<S8>/Switch' incorporates:
|
|
* Abs: '<S8>/Abs'
|
|
* Constant: '<S8>/180'
|
|
* RelationalOperator: '<S8>/Relational Operator'
|
|
*/
|
|
if (!(fabs(rtb_Sum_c) <= WindModeltestfinal_P.u80_Value_e)) {
|
|
/* Switch: '<S8>/Switch1' incorporates:
|
|
* Constant: '<S8>/0'
|
|
* Constant: '<S8>/360'
|
|
* Constant: '<S8>/360 '
|
|
* RelationalOperator: '<S8>/Relational Operator1'
|
|
* Sum: '<S8>/Sum1'
|
|
* Sum: '<S8>/Sum2'
|
|
*/
|
|
if (rtb_Sum_c > WindModeltestfinal_P.u_Value_l) {
|
|
rtb_Sum_c -= WindModeltestfinal_P.u60_Value_g;
|
|
} else {
|
|
rtb_Sum_c += WindModeltestfinal_P.u60_Value_e;
|
|
}
|
|
|
|
/* End of Switch: '<S8>/Switch1' */
|
|
}
|
|
|
|
/* End of Switch: '<S8>/Switch' */
|
|
|
|
/* Switch: '<S9>/Switch' incorporates:
|
|
* Constant: '<S9>/0 double'
|
|
* RelationalOperator: '<S9>/Relational Operator'
|
|
*/
|
|
if (rtb_Sum_c >= WindModeltestfinal_P.udouble_Value) {
|
|
/* Outport: '<Root>/WindDirection' incorporates:
|
|
* Abs: '<S9>/Abs'
|
|
* Constant: '<S1>/WindDirectionResC'
|
|
* Constant: '<S9>/0.5 double'
|
|
* Product: '<S9>/Divide'
|
|
* Product: '<S9>/Product'
|
|
* Rounding: '<S9>/Rounding Function'
|
|
* Sum: '<S9>/Sum'
|
|
*/
|
|
WindModeltestfinal_Y.WindDirection = floor(fabs(rtb_Sum_c /
|
|
WindModeltestfinal_P.WindDirectionResC_Value) +
|
|
WindModeltestfinal_P.u5double_Value) *
|
|
WindModeltestfinal_P.WindDirectionResC_Value;
|
|
} else {
|
|
/* Outport: '<Root>/WindDirection' incorporates:
|
|
* Abs: '<S9>/Abs'
|
|
* Constant: '<S1>/WindDirectionResC'
|
|
* Constant: '<S9>/0.5 double'
|
|
* Product: '<S9>/Divide'
|
|
* Product: '<S9>/Product'
|
|
* Rounding: '<S9>/Rounding Function'
|
|
* Sum: '<S9>/Sum'
|
|
* UnaryMinus: '<S9>/Unary Minus'
|
|
*/
|
|
WindModeltestfinal_Y.WindDirection = -(floor(fabs(rtb_Sum_c /
|
|
WindModeltestfinal_P.WindDirectionResC_Value) +
|
|
WindModeltestfinal_P.u5double_Value) *
|
|
WindModeltestfinal_P.WindDirectionResC_Value);
|
|
}
|
|
|
|
/* End of Switch: '<S9>/Switch' */
|
|
|
|
/* Switch: '<S10>/Switch' incorporates:
|
|
* Abs: '<S10>/Abs'
|
|
* Constant: '<S10>/0 double'
|
|
* Constant: '<S10>/0.5 double'
|
|
* Constant: '<S1>/WindSpeedResC'
|
|
* Inport: '<Root>/WindSpeedFMSSide'
|
|
* Product: '<S10>/Divide'
|
|
* Product: '<S10>/Product'
|
|
* RelationalOperator: '<S10>/Relational Operator'
|
|
* Rounding: '<S10>/Rounding Function'
|
|
* Sum: '<S10>/Sum'
|
|
* UnaryMinus: '<S10>/Unary Minus'
|
|
*/
|
|
if (WindModeltestfinal_U.WindSpeedFMSSide >=
|
|
WindModeltestfinal_P.udouble_Value_c) {
|
|
rtb_Sum_c = floor(fabs(WindModeltestfinal_U.WindSpeedFMSSide /
|
|
WindModeltestfinal_P.WindSpeedResC_Value) +
|
|
WindModeltestfinal_P.u5double_Value_c) *
|
|
WindModeltestfinal_P.WindSpeedResC_Value;
|
|
} else {
|
|
rtb_Sum_c = -(floor(fabs(WindModeltestfinal_U.WindSpeedFMSSide /
|
|
WindModeltestfinal_P.WindSpeedResC_Value) +
|
|
WindModeltestfinal_P.u5double_Value_c) *
|
|
WindModeltestfinal_P.WindSpeedResC_Value);
|
|
}
|
|
|
|
/* End of Switch: '<S10>/Switch' */
|
|
|
|
/* Switch: '<S5>/Switch' incorporates:
|
|
* Constant: '<S1>/WindSpeedMaxC'
|
|
* RelationalOperator: '<S5>/Relational Operator'
|
|
*/
|
|
if (rtb_Sum_c >= WindModeltestfinal_P.WindSpeedMaxC_Value) {
|
|
/* Outport: '<Root>/WindSpeed' */
|
|
WindModeltestfinal_Y.WindSpeed = WindModeltestfinal_P.WindSpeedMaxC_Value;
|
|
} else {
|
|
/* Outport: '<Root>/WindSpeed' */
|
|
WindModeltestfinal_Y.WindSpeed = rtb_Sum_c;
|
|
}
|
|
|
|
/* End of Switch: '<S5>/Switch' */
|
|
|
|
/* Outport: '<Root>/WindDirectionColor' incorporates:
|
|
* Inport: '<Root>/FMSColor'
|
|
*/
|
|
WindModeltestfinal_Y.WindDirectionColor = WindModeltestfinal_U.FMSColor;
|
|
|
|
/* Outport: '<Root>/WindSpeedColor' incorporates:
|
|
* Inport: '<Root>/FMSColor'
|
|
*/
|
|
WindModeltestfinal_Y.WindSpeedColor = WindModeltestfinal_U.FMSColor;
|
|
|
|
/* Update for Memory: '<S6>/Memory' */
|
|
// WindModeltestfinal_DW.Memory_PreviousInput = rtb_Switch_i;
|
|
|
|
/* Matfile logging */
|
|
|
|
/* signal main to stop simulation */
|
|
{ /* Sample time: [0.1s, 0.0s] */
|
|
if ((rtmGetTFinal(WindModeltestfinal_M)!=-1) &&
|
|
!((rtmGetTFinal(WindModeltestfinal_M)-
|
|
WindModeltestfinal_M->Timing.taskTime0) >
|
|
WindModeltestfinal_M->Timing.taskTime0 * (DBL_EPSILON))) {
|
|
rtmSetErrorStatus(WindModeltestfinal_M, "Simulation finished");
|
|
}
|
|
}
|
|
|
|
/* Update absolute time for base rate */
|
|
/* The "clockTick0" counts the number of times the code of this task has
|
|
* been executed. The absolute time is the multiplication of "clockTick0"
|
|
* and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
|
|
* overflow during the application lifespan selected.
|
|
* Timer of this task consists of two 32 bit unsigned integers.
|
|
* The two integers represent the low bits Timing.clockTick0 and the high bits
|
|
* Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
|
|
*/
|
|
if (!(++WindModeltestfinal_M->Timing.clockTick0)) {
|
|
++WindModeltestfinal_M->Timing.clockTickH0;
|
|
}
|
|
|
|
WindModeltestfinal_M->Timing.taskTime0 =
|
|
WindModeltestfinal_M->Timing.clockTick0 *
|
|
WindModeltestfinal_M->Timing.stepSize0 +
|
|
WindModeltestfinal_M->Timing.clockTickH0 *
|
|
WindModeltestfinal_M->Timing.stepSize0 * 4294967296.0;
|
|
}
|
|
|
|
/* Model initialize function */
|
|
void WindModeltestfinal_initialize(void)
|
|
{
|
|
/* Registration code */
|
|
|
|
/* initialize non-finites */
|
|
rt_InitInfAndNaN(sizeof(float));
|
|
|
|
/* initialize real-time model */
|
|
(void) memset((void *)WindModeltestfinal_M, 0,
|
|
sizeof(RT_MODEL_WindModeltestfinal_T));
|
|
rtmSetTFinal(WindModeltestfinal_M, 100.0);
|
|
WindModeltestfinal_M->Timing.stepSize0 = 0.1;
|
|
|
|
|
|
|
|
/* Setup for data logging */
|
|
|
|
|
|
/*
|
|
* Set pointers to the data and signal info for each output
|
|
*/
|
|
|
|
|
|
/* states (dwork) */
|
|
memset(&WindModeltestfinal_DW, 0,sizeof(DW_WindModeltestfinal_T));
|
|
|
|
/* external inputs */
|
|
memset(&WindModeltestfinal_U, 0, sizeof(ExtU_WindModeltestfinal_T));
|
|
|
|
/* external outputs */
|
|
(void) memset((void *)&WindModeltestfinal_Y, 0,
|
|
sizeof(ExtY_WindModeltestfinal_T));
|
|
|
|
/* Matfile logging */
|
|
|
|
|
|
/* InitializeConditions for Memory: '<S6>/Memory' */
|
|
// WindModeltestfinal_DW.Memory_PreviousInput =
|
|
// WindModeltestfinal_P.Memory_InitialCondition;
|
|
}
|
|
|
|
/* Model terminate function */
|
|
void WindModeltestfinal_terminate(void)
|
|
{
|
|
/* (no terminate code required) */
|
|
}
|