1
|
#include <stdlib.h>
|
2
|
#include <assert.h>
|
3
|
#include "ALT_2.lustrec.h"
|
4
|
|
5
|
/* C code generated by lustrec
|
6
|
SVN version number 342
|
7
|
Code is C99 compliant */
|
8
|
|
9
|
/* Imported nodes declarations */
|
10
|
|
11
|
/* Global constants (definitions) */
|
12
|
|
13
|
void top_reset (struct top_mem *self) {
|
14
|
AltitudeControl_reset(&self->ni_0);
|
15
|
return;
|
16
|
}
|
17
|
|
18
|
void top_step (_Bool AltEng, double AltCmd, double Altitude, double gskts,
|
19
|
double hdot, double hdotChgRate,
|
20
|
_Bool (*obs),
|
21
|
struct top_mem *self) {
|
22
|
double altgammaCmd;
|
23
|
double tempAlt;
|
24
|
|
25
|
tempAlt = (AltEng?(1.):(0.));
|
26
|
AltitudeControl_step (tempAlt, AltCmd, Altitude, gskts, hdot, hdotChgRate, &altgammaCmd, &self->ni_0);
|
27
|
*obs = (altgammaCmd == 0.);
|
28
|
return;
|
29
|
}
|
30
|
|
31
|
void AltitudeControl_reset (struct AltitudeControl_mem *self) {
|
32
|
VariableRateLimit_reset(&self->ni_1);
|
33
|
return;
|
34
|
}
|
35
|
|
36
|
void AltitudeControl_step (double AntEng_Out1_19, double AltCmd_Out1_29,
|
37
|
double Alt_Out1_39, double GsKts_Out1_49,
|
38
|
double hdot_Out1_59, double hdotChgRate_Out1_69,
|
39
|
double (*altgammacmd_In1_661),
|
40
|
struct AltitudeControl_mem *self) {
|
41
|
double Abs_Out1_144;
|
42
|
double Kh_Out1_193;
|
43
|
_Bool Logical_Operator_In1_197;
|
44
|
_Bool Logical_Operator_Out1_198;
|
45
|
double Saturation1_Out1_213;
|
46
|
double Sum3_Out1_296;
|
47
|
double Sum_Out1_286;
|
48
|
_Bool Switch1_In2_312;
|
49
|
double Switch1_Out1_314;
|
50
|
_Bool Switch_In2_303;
|
51
|
double Switch_Out1_305;
|
52
|
double Variable_Limit_Saturation_0_Out1_509;
|
53
|
double Variable__Rate_Limit_Out1_324;
|
54
|
_Bool __AltitudeControl_1;
|
55
|
_Bool __AltitudeControl_2;
|
56
|
double k_Out1_585;
|
57
|
double kts2fps_Out1_594;
|
58
|
double r2d_Out1_603;
|
59
|
|
60
|
__AltitudeControl_1 = (hdot_Out1_59 < 0.);
|
61
|
Abs_Out1_144 = (__AltitudeControl_1?((- hdot_Out1_59)):(hdot_Out1_59));
|
62
|
Sum3_Out1_296 = (Abs_Out1_144 + 10.);
|
63
|
k_Out1_585 = (- Sum3_Out1_296);
|
64
|
__AltitudeControl_2 = (AntEng_Out1_19 == 0.);
|
65
|
Logical_Operator_In1_197 = (__AltitudeControl_2?(0):(1));
|
66
|
Logical_Operator_Out1_198 = (!Logical_Operator_In1_197);
|
67
|
Switch_In2_303 = (__AltitudeControl_2?(0):(1));
|
68
|
Sum_Out1_286 = (AltCmd_Out1_29 + (- Alt_Out1_39));
|
69
|
Kh_Out1_193 = (0.08 * Sum_Out1_286);
|
70
|
Switch_Out1_305 = (Switch_In2_303?(Kh_Out1_193):(0.));
|
71
|
VariableLimitSaturation_step (Sum3_Out1_296, Switch_Out1_305, k_Out1_585, &Variable_Limit_Saturation_0_Out1_509);
|
72
|
VariableRateLimit_step (hdotChgRate_Out1_69, Variable_Limit_Saturation_0_Out1_509, Logical_Operator_Out1_198, hdot_Out1_59, &Variable__Rate_Limit_Out1_324, &self->ni_1);
|
73
|
r2d_Out1_603 = (57.2958 * Variable__Rate_Limit_Out1_324);
|
74
|
kts2fps_Out1_594 = (1.6878 * GsKts_Out1_49);
|
75
|
Switch1_In2_312 = (__AltitudeControl_2?(0):(1));
|
76
|
Switch1_Out1_314 = (Switch1_In2_312?(r2d_Out1_603):(0.));
|
77
|
*altgammacmd_In1_661 = Switch1_Out1_314;
|
78
|
Saturation_step (kts2fps_Out1_594, &Saturation1_Out1_213);
|
79
|
return;
|
80
|
}
|
81
|
|
82
|
void VariableRateLimit_reset (struct VariableRateLimit_mem *self) {
|
83
|
_arrow_reset(&self->ni_3);
|
84
|
integrator_reset_reset(&self->ni_2);
|
85
|
return;
|
86
|
}
|
87
|
|
88
|
void VariableRateLimit_step (double ratelim_Out1_334, double input_Out1_344,
|
89
|
_Bool ICtrig_Out1_354, double IC_Out1_364,
|
90
|
double (*output_In1_489),
|
91
|
struct VariableRateLimit_mem *self) {
|
92
|
double Gain1_Out1_382;
|
93
|
double Gain_Out1_373;
|
94
|
double Integrator1_Out1_391;
|
95
|
double Sum2_Out1_401;
|
96
|
double Variable_Limit_Saturation_Out1_410;
|
97
|
_Bool __VariableRateLimit_1;
|
98
|
double __VariableRateLimit_2;
|
99
|
|
100
|
_arrow_step (1, 0, &__VariableRateLimit_1, &self->ni_3);
|
101
|
Integrator1_Out1_391 = (__VariableRateLimit_1?(IC_Out1_364):(self->_reg.__VariableRateLimit_3));
|
102
|
*output_In1_489 = Integrator1_Out1_391;
|
103
|
Gain1_Out1_382 = (- ratelim_Out1_334);
|
104
|
Sum2_Out1_401 = (input_Out1_344 + (- Integrator1_Out1_391));
|
105
|
Gain_Out1_373 = (20. * Sum2_Out1_401);
|
106
|
VariableLimitSaturation_step (ratelim_Out1_334, Gain_Out1_373, Gain1_Out1_382, &Variable_Limit_Saturation_Out1_410);
|
107
|
integrator_reset_step (Variable_Limit_Saturation_Out1_410, ICtrig_Out1_354, IC_Out1_364, &__VariableRateLimit_2, &self->ni_2);
|
108
|
self->_reg.__VariableRateLimit_3 = __VariableRateLimit_2;
|
109
|
return;
|
110
|
}
|
111
|
|
112
|
void Saturation_step (double Signal,
|
113
|
double (*s_out)
|
114
|
) {
|
115
|
_Bool __Saturation_1;
|
116
|
_Bool __Saturation_2;
|
117
|
double enforce_lo_lim;
|
118
|
|
119
|
__Saturation_1 = (0.0001 >= Signal);
|
120
|
enforce_lo_lim = (__Saturation_1?(0.0001):(Signal));
|
121
|
__Saturation_2 = (1000. <= enforce_lo_lim);
|
122
|
*s_out = (__Saturation_2?(1000.):(enforce_lo_lim));
|
123
|
return;
|
124
|
}
|
125
|
|
126
|
void integrator_reset_reset (struct integrator_reset_mem *self) {
|
127
|
_arrow_reset(&self->ni_4);
|
128
|
return;
|
129
|
}
|
130
|
|
131
|
void integrator_reset_step (double Fx, _Bool ResetLevel, double x0,
|
132
|
double (*ir_out),
|
133
|
struct integrator_reset_mem *self) {
|
134
|
_Bool __integrator_reset_1;
|
135
|
|
136
|
_arrow_step (1, 0, &__integrator_reset_1, &self->ni_4);
|
137
|
*ir_out = (__integrator_reset_1?(x0):((ResetLevel?(x0):(((Fx * 1.) + self->_reg.__integrator_reset_2)))));
|
138
|
self->_reg.__integrator_reset_2 = *ir_out;
|
139
|
return;
|
140
|
}
|
141
|
|
142
|
void VariableLimitSaturation_step (double up_lim, double Signal,
|
143
|
double lo_lim,
|
144
|
double (*out)
|
145
|
) {
|
146
|
_Bool __VariableLimitSaturation_1;
|
147
|
_Bool __VariableLimitSaturation_2;
|
148
|
double enforce_lo_lim;
|
149
|
|
150
|
__VariableLimitSaturation_1 = (Signal >= lo_lim);
|
151
|
enforce_lo_lim = (__VariableLimitSaturation_1?(Signal):(lo_lim));
|
152
|
__VariableLimitSaturation_2 = (enforce_lo_lim <= up_lim);
|
153
|
*out = (__VariableLimitSaturation_2?(enforce_lo_lim):(up_lim));
|
154
|
return;
|
155
|
}
|
156
|
|