1 | /* |
2 | * RaspberryMagmanModelTest.c |
3 | * |
4 | * Classroom License -- for classroom instructional use only. Not for |
5 | * government, commercial, academic research, or other organizational use. |
6 | * |
7 | * Code generation for model "RaspberryMagmanModelTest". |
8 | * |
9 | * Model version : 1.19 |
10 | * Simulink Coder version : 8.11 (R2016b) 25-Aug-2016 |
11 | * C source code generated on : Wed Dec 21 17:46:56 2016 |
12 | * |
13 | * Target selection: ert.tlc |
14 | * Note: GRT includes extra infrastructure and instrumentation for prototyping |
15 | * Embedded hardware selection: ARM Compatible->ARM Cortex |
16 | * Code generation objectives: Unspecified |
17 | * Validation result: Not run |
18 | */ |
19 | |
20 | #include "RaspberryMagmanModelTest.h" |
21 | #include "RaspberryMagmanModelTest_private.h" |
22 | #include "RaspberryMagmanModelTest_dt.h" |
23 | |
24 | /* Block signals (auto storage) */ |
25 | B_RaspberryMagmanModelTest_T RaspberryMagmanModelTest_B; |
26 | |
27 | /* Block states (auto storage) */ |
28 | DW_RaspberryMagmanModelTest_T RaspberryMagmanModelTest_DW; |
29 | |
30 | /* Real-time model */ |
31 | RT_MODEL_RaspberryMagmanModel_T RaspberryMagmanModelTest_M_; |
32 | RT_MODEL_RaspberryMagmanModel_T *const RaspberryMagmanModelTest_M = |
33 | &RaspberryMagmanModelTest_M_; |
34 | |
35 | /* |
36 | * Output and update for atomic system: |
37 | * '<S1>/Position transformation1' |
38 | * '<S4>/Position transformation' |
39 | */ |
40 | void Raspber_Positiontransformation1(real_T rtu_x, real_T rtu_y, const real_T |
41 | rtu_km4[9], B_Positiontransformation1_Ras_T *localB) |
42 | { |
43 | /* MATLAB Function 'Camera position/Position transformation1': '<S6>:1' */ |
44 | /* out=km2*[x;y;x^2;y^2;x*y;1]; */ |
45 | /* '<S6>:1:4' xa = [x,y]; */ |
46 | /* '<S6>:1:5' H = km4(:); */ |
47 | /* '<S6>:1:6' xa = [xa,ones(size(xa,1),1)]; */ |
48 | /* homogeneous coordinates */ |
49 | /* '<S6>:1:7' out = [ (xa*H(1:3))./(xa*H(7:9)), (xa*H(4:6))./(xa*H(7:9)) ]; */ |
50 | /* '<S6>:1:9' X=out(1); */ |
51 | localB->X = ((rtu_x * rtu_km4[0] + rtu_y * rtu_km4[1]) + rtu_km4[2]) / ((rtu_x |
52 | * rtu_km4[6] + rtu_y * rtu_km4[7]) + rtu_km4[8]); |
53 | |
54 | /* '<S6>:1:10' Y=out(2); */ |
55 | localB->Y = ((rtu_x * rtu_km4[3] + rtu_y * rtu_km4[4]) + rtu_km4[5]) / ((rtu_x |
56 | * rtu_km4[6] + rtu_y * rtu_km4[7]) + rtu_km4[8]); |
57 | } |
58 | |
59 | real_T rt_powd_snf(real_T u0, real_T u1) |
60 | { |
61 | real_T y; |
62 | real_T tmp; |
63 | real_T tmp_0; |
64 | if (rtIsNaN(u0) || rtIsNaN(u1)) { |
65 | y = (rtNaN); |
66 | } else { |
67 | tmp = fabs(u0); |
68 | tmp_0 = fabs(u1); |
69 | if (rtIsInf(u1)) { |
70 | if (tmp == 1.0) { |
71 | y = (rtNaN); |
72 | } else if (tmp > 1.0) { |
73 | if (u1 > 0.0) { |
74 | y = (rtInf); |
75 | } else { |
76 | y = 0.0; |
77 | } |
78 | } else if (u1 > 0.0) { |
79 | y = 0.0; |
80 | } else { |
81 | y = (rtInf); |
82 | } |
83 | } else if (tmp_0 == 0.0) { |
84 | y = 1.0; |
85 | } else if (tmp_0 == 1.0) { |
86 | if (u1 > 0.0) { |
87 | y = u0; |
88 | } else { |
89 | y = 1.0 / u0; |
90 | } |
91 | } else if (u1 == 2.0) { |
92 | y = u0 * u0; |
93 | } else if ((u1 == 0.5) && (u0 >= 0.0)) { |
94 | y = sqrt(u0); |
95 | } else if ((u0 < 0.0) && (u1 > floor(u1))) { |
96 | y = (rtNaN); |
97 | } else { |
98 | y = pow(u0, u1); |
99 | } |
100 | } |
101 | |
102 | return y; |
103 | } |
104 | |
105 | /* Model step function */ |
106 | void RaspberryMagmanModelTest_step(void) |
107 | { |
108 | int32_T k; |
109 | int32_T cnt2; |
110 | real_T c_a; |
111 | real_T d_a; |
112 | real_T rtb_Step; |
113 | real_T rtb_F_idx_0; |
114 | real_T rtb_F_idx_1; |
115 | |
116 | /* Step: '<Root>/Step' */ |
117 | if (RaspberryMagmanModelTest_M->Timing.t[0] < |
118 | RaspberryMagmanModelTest_P.Step_Time) { |
119 | rtb_Step = RaspberryMagmanModelTest_P.Step_Y0; |
120 | } else { |
121 | rtb_Step = RaspberryMagmanModelTest_P.Step_YFinal; |
122 | } |
123 | |
124 | /* End of Step: '<Root>/Step' */ |
125 | |
126 | /* Switch: '<Root>/Switch' incorporates: |
127 | * Constant: '<Root>/Coil excitation factors' |
128 | * Constant: '<Root>/Coil excitation factors1' |
129 | */ |
130 | if (rtb_Step > RaspberryMagmanModelTest_P.Switch_Threshold) { |
131 | memcpy(&RaspberryMagmanModelTest_B.Switch[0], |
132 | &RaspberryMagmanModelTest_P.Coilexcitationfactors_Value[0], sizeof |
133 | (real_T) << 4U); |
134 | } else { |
135 | memcpy(&RaspberryMagmanModelTest_B.Switch[0], |
136 | &RaspberryMagmanModelTest_P.Coilexcitationfactors1_Value[0], sizeof |
137 | (real_T) << 4U); |
138 | } |
139 | |
140 | /* End of Switch: '<Root>/Switch' */ |
141 | |
142 | /* S-Function (sfcn_getFoilCheck): '<S4>/MagMan Foil with error' */ |
143 | sfcn_getFoilCheck_Outputs_wrapper |
144 | ( &RaspberryMagmanModelTest_B.MagManFoilwitherror_o1, |
145 | &RaspberryMagmanModelTest_B.MagManFoilwitherror_o2, |
146 | &RaspberryMagmanModelTest_B.MagManFoilwitherror_o3, |
147 | &RaspberryMagmanModelTest_B.MagManFoilwitherror_o4, |
148 | &RaspberryMagmanModelTest_DW.MagManFoilwitherror_DSTATE); |
149 | |
150 | /* MATLAB Function: '<S4>/Position transformation' incorporates: |
151 | * Constant: '<S4>/Sentinel Calibration matrix' |
152 | */ |
153 | Raspber_Positiontransformation1 |
154 | (RaspberryMagmanModelTest_B.MagManFoilwitherror_o1, |
155 | RaspberryMagmanModelTest_B.MagManFoilwitherror_o2, |
156 | RaspberryMagmanModelTest_P.km4pi, |
157 | &RaspberryMagmanModelTest_B.sf_Positiontransformation); |
158 | |
159 | /* S-Function (sfcn_posread_shm): '<S5>/Shared memory camera position' */ |
160 | sfcn_posread_shm_Outputs_wrapper |
161 | ( &RaspberryMagmanModelTest_B.Sharedmemorycameraposition_o1, |
162 | &RaspberryMagmanModelTest_B.Sharedmemorycameraposition_o2, |
163 | &RaspberryMagmanModelTest_DW.Sharedmemorycameraposition_DSTA); |
164 | |
165 | /* DataTypeConversion: '<S5>/Data Type Conversion1' */ |
166 | RaspberryMagmanModelTest_B.DataTypeConversion1 = |
167 | RaspberryMagmanModelTest_B.Sharedmemorycameraposition_o1; |
168 | |
169 | /* DataTypeConversion: '<S5>/Data Type Conversion2' */ |
170 | RaspberryMagmanModelTest_B.DataTypeConversion2 = |
171 | RaspberryMagmanModelTest_B.Sharedmemorycameraposition_o2; |
172 | |
173 | /* MATLAB Function: '<S1>/Position transformation1' incorporates: |
174 | * Constant: '<S1>/Sentinel Calibration matrix1' |
175 | */ |
176 | Raspber_Positiontransformation1(RaspberryMagmanModelTest_B.DataTypeConversion1, |
177 | RaspberryMagmanModelTest_B.DataTypeConversion2, |
178 | RaspberryMagmanModelTest_P.km4piCam, |
179 | &RaspberryMagmanModelTest_B.sf_Positiontransformation1); |
180 | |
181 | /* DiscreteStateSpace: '<Root>/Discrete State-Space' */ |
182 | { |
183 | RaspberryMagmanModelTest_B.DiscreteStateSpace[0] = |
184 | (RaspberryMagmanModelTest_P.DiscreteStateSpace_C[0])* |
185 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[1]; |
186 | RaspberryMagmanModelTest_B.DiscreteStateSpace[1] = |
187 | (RaspberryMagmanModelTest_P.DiscreteStateSpace_C[1])* |
188 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[3]; |
189 | } |
190 | |
191 | /* MATLAB Function: '<Root>/Currents to PWM' */ |
192 | /* MATLAB Function 'Currents to PWM': '<S3>:1' */ |
193 | /* conversion from scaling factor to duty cycle of PWM */ |
194 | /* '<S3>:1:3' Currents = max(0, min(1,Currents) ); */ |
195 | /* limits */ |
196 | /* '<S3>:1:4' i = 0.18515*Currents + 0.069587*Currents.^3 + 0.19285*Currents.^(1/3); */ |
197 | /* ratio to current conversion */ |
198 | /* '<S3>:1:5' PWM = i/0.455/2; */ |
199 | /* '<S3>:1:6' PWM(PWM>0.05) = PWM(PWM>0.05) + 0.5; */ |
200 | /* '<S3>:1:7' PWM(PWM<0.5) = 0; */ |
201 | for (k = 0; k < 16; k++) { |
202 | if ((1.0 <= RaspberryMagmanModelTest_B.Switch[k]) || rtIsNaN |
203 | (RaspberryMagmanModelTest_B.Switch[k])) { |
204 | rtb_Step = 1.0; |
205 | } else { |
206 | rtb_Step = RaspberryMagmanModelTest_B.Switch[k]; |
207 | } |
208 | |
209 | if ((0.0 >= rtb_Step) || rtIsNaN(rtb_Step)) { |
210 | RaspberryMagmanModelTest_B.PWM[k] = 0.0; |
211 | } else { |
212 | RaspberryMagmanModelTest_B.PWM[k] = rtb_Step; |
213 | } |
214 | |
215 | RaspberryMagmanModelTest_B.PWM[k] = ((0.18515 * |
216 | RaspberryMagmanModelTest_B.PWM[k] + 0.069587 * rt_powd_snf |
217 | (RaspberryMagmanModelTest_B.PWM[k], 3.0)) + 0.19285 * rt_powd_snf |
218 | (RaspberryMagmanModelTest_B.PWM[k], 0.33333333333333331)) / 0.455 / 2.0; |
219 | if (RaspberryMagmanModelTest_B.PWM[k] > 0.05) { |
220 | RaspberryMagmanModelTest_B.PWM[k] += 0.5; |
221 | } |
222 | |
223 | if (RaspberryMagmanModelTest_B.PWM[k] < 0.5) { |
224 | RaspberryMagmanModelTest_B.PWM[k] = 0.0; |
225 | } |
226 | } |
227 | |
228 | /* End of MATLAB Function: '<Root>/Currents to PWM' */ |
229 | |
230 | /* S-Function (sfcn_setPlatform): '<Root>/MagMan Coils' */ |
231 | sfcn_setPlatform_Outputs_wrapper(&RaspberryMagmanModelTest_B.PWM[0], |
232 | &RaspberryMagmanModelTest_DW.MagManCoils_DSTATE); |
233 | |
234 | /* MATLAB Function: '<S2>/Nonlinearity of magnetic force' */ |
235 | /* MATLAB Function 'Currents to Force/Nonlinearity of magnetic force': '<S7>:1' */ |
236 | /* function F = fcn(u,xmes) */ |
237 | /* Computes vector of magnetic force exerted on the ball in x- and */ |
238 | /* y-direction. Input arguments are excitation factors of coils and measured */ |
239 | /* position of the ball. Contributions of the coils are superposed to get */ |
240 | /* the overall force. */ |
241 | /* Note, that this function only models nonlinearity of the magnetic force, */ |
242 | /* it is not any kind of feedback control. */ |
243 | /* '<S7>:1:10' umin = 1; */ |
244 | /* index of the 1st actuator in one dim */ |
245 | /* '<S7>:1:11' umax = 4; */ |
246 | /* index of tohe last actuator in one dim */ |
247 | /* '<S7>:1:13' F = [0;0]; */ |
248 | rtb_F_idx_0 = 0.0; |
249 | rtb_F_idx_1 = 0.0; |
250 | |
251 | /* '<S7>:1:15' u = abs(u); */ |
252 | for (k = 0; k < 16; k++) { |
253 | RaspberryMagmanModelTest_B.minval[k] = fabs |
254 | (RaspberryMagmanModelTest_B.Switch[k]); |
255 | } |
256 | |
257 | /* '<S7>:1:16' for cnt = umin:umax */ |
258 | for (k = 0; k < 4; k++) { |
259 | /* '<S7>:1:17' for cnt2 = umin:umax */ |
260 | for (cnt2 = 0; cnt2 < 4; cnt2++) { |
261 | /* '<S7>:1:18' F = F + [dxfce(cnt,cnt2,xmes(1),xmes(2));... */ |
262 | /* '<S7>:1:19' dyfce(cnt,cnt2,xmes(1),xmes(2))] * u(cnt2-umin+1,cnt-umin+1); */ |
263 | /* Compute x-component of force from coil [m,n] exerted on the ball at */ |
264 | /* position [x,y] */ |
265 | /* '<S7>:1:27' out = -48.282*(x-m)./( (x-m).^2 + (y-n).^2 + 0.3303).^3; */ |
266 | rtb_Step = RaspberryMagmanModelTest_B.DiscreteStateSpace[0] - (1.0 + |
267 | (real_T)k); |
268 | RaspberryMagmanModelTest_B.b_a = |
269 | RaspberryMagmanModelTest_B.DiscreteStateSpace[1] - (1.0 + (real_T)cnt2); |
270 | |
271 | /* Compute y-component of force from coil [m,n] exerted on the ball at */ |
272 | /* position [x,y] */ |
273 | /* '<S7>:1:33' out = -48.282*(y-n)./( (x-m).^2 + (y-n).^2 + 0.3303).^3; */ |
274 | c_a = RaspberryMagmanModelTest_B.DiscreteStateSpace[0] - (1.0 + (real_T)k); |
275 | d_a = RaspberryMagmanModelTest_B.DiscreteStateSpace[1] - (1.0 + (real_T) |
276 | cnt2); |
277 | rtb_F_idx_0 += (RaspberryMagmanModelTest_B.DiscreteStateSpace[0] - (1.0 + |
278 | (real_T)k)) * -48.282 / rt_powd_snf((rtb_Step * rtb_Step + |
279 | RaspberryMagmanModelTest_B.b_a * RaspberryMagmanModelTest_B.b_a) + |
280 | 0.3303, 3.0) * RaspberryMagmanModelTest_B.minval[(k << 2) + cnt2]; |
281 | rtb_F_idx_1 += (RaspberryMagmanModelTest_B.DiscreteStateSpace[1] - (1.0 + |
282 | (real_T)cnt2)) * -48.282 / rt_powd_snf((c_a * c_a + d_a * d_a) + 0.3303, |
283 | 3.0) * RaspberryMagmanModelTest_B.minval[(k << 2) + cnt2]; |
284 | } |
285 | } |
286 | |
287 | /* End of MATLAB Function: '<S2>/Nonlinearity of magnetic force' */ |
288 | |
289 | /* Gain: '<S2>/Gain' */ |
290 | RaspberryMagmanModelTest_B.Gain[0] = RaspberryMagmanModelTest_P.Gain_Gain * |
291 | rtb_F_idx_0; |
292 | RaspberryMagmanModelTest_B.Gain[1] = RaspberryMagmanModelTest_P.Gain_Gain * |
293 | rtb_F_idx_1; |
294 | |
295 | /* S-Function "sfcn_getFoilCheck_wrapper" Block: <S4>/MagMan Foil with error */ |
296 | sfcn_getFoilCheck_Update_wrapper |
297 | ( &RaspberryMagmanModelTest_B.MagManFoilwitherror_o1, |
298 | &RaspberryMagmanModelTest_B.MagManFoilwitherror_o2, |
299 | &RaspberryMagmanModelTest_B.MagManFoilwitherror_o3, |
300 | &RaspberryMagmanModelTest_B.MagManFoilwitherror_o4, |
301 | &RaspberryMagmanModelTest_DW.MagManFoilwitherror_DSTATE); |
302 | |
303 | /* S-Function "sfcn_posread_shm_wrapper" Block: <S5>/Shared memory camera position */ |
304 | sfcn_posread_shm_Update_wrapper |
305 | ( &RaspberryMagmanModelTest_B.Sharedmemorycameraposition_o1, |
306 | &RaspberryMagmanModelTest_B.Sharedmemorycameraposition_o2, |
307 | &RaspberryMagmanModelTest_DW.Sharedmemorycameraposition_DSTA); |
308 | |
309 | /* Update for DiscreteStateSpace: '<Root>/Discrete State-Space' */ |
310 | { |
311 | real_T xnew[4]; |
312 | xnew[0] = (RaspberryMagmanModelTest_P.DiscreteStateSpace_A[0])* |
313 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[0]; |
314 | xnew[0] += (RaspberryMagmanModelTest_P.DiscreteStateSpace_B[0])* |
315 | RaspberryMagmanModelTest_B.Gain[0]; |
316 | xnew[1] = (RaspberryMagmanModelTest_P.DiscreteStateSpace_A[1])* |
317 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[0] |
318 | + (RaspberryMagmanModelTest_P.DiscreteStateSpace_A[2])* |
319 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[1]; |
320 | xnew[1] += (RaspberryMagmanModelTest_P.DiscreteStateSpace_B[1])* |
321 | RaspberryMagmanModelTest_B.Gain[0]; |
322 | xnew[2] = (RaspberryMagmanModelTest_P.DiscreteStateSpace_A[3])* |
323 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[2]; |
324 | xnew[2] += (RaspberryMagmanModelTest_P.DiscreteStateSpace_B[2])* |
325 | RaspberryMagmanModelTest_B.Gain[1]; |
326 | xnew[3] = (RaspberryMagmanModelTest_P.DiscreteStateSpace_A[4])* |
327 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[2] |
328 | + (RaspberryMagmanModelTest_P.DiscreteStateSpace_A[5])* |
329 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[3]; |
330 | xnew[3] += (RaspberryMagmanModelTest_P.DiscreteStateSpace_B[3])* |
331 | RaspberryMagmanModelTest_B.Gain[1]; |
332 | (void) memcpy(&RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[0], |
333 | xnew, |
334 | sizeof(real_T)*4); |
335 | } |
336 | |
337 | /* S-Function "sfcn_setPlatform_wrapper" Block: <Root>/MagMan Coils */ |
338 | sfcn_setPlatform_Update_wrapper(&RaspberryMagmanModelTest_B.PWM[0], |
339 | &RaspberryMagmanModelTest_DW.MagManCoils_DSTATE); |
340 | |
341 | /* External mode */ |
342 | rtExtModeUploadCheckTrigger(2); |
343 | |
344 | { /* Sample time: [0.0s, 0.0s] */ |
345 | rtExtModeUpload(0, RaspberryMagmanModelTest_M->Timing.t[0]); |
346 | } |
347 | |
348 | { /* Sample time: [0.02s, 0.0s] */ |
349 | rtExtModeUpload(1, (((RaspberryMagmanModelTest_M->Timing.clockTick1+ |
350 | RaspberryMagmanModelTest_M->Timing.clockTickH1* |
351 | 4294967296.0)) * 0.02)); |
352 | } |
353 | |
354 | /* signal main to stop simulation */ |
355 | { /* Sample time: [0.0s, 0.0s] */ |
356 | if ((rtmGetTFinal(RaspberryMagmanModelTest_M)!=-1) && |
357 | !((rtmGetTFinal(RaspberryMagmanModelTest_M)- |
358 | RaspberryMagmanModelTest_M->Timing.t[0]) > |
359 | RaspberryMagmanModelTest_M->Timing.t[0] * (DBL_EPSILON))) { |
360 | rtmSetErrorStatus(RaspberryMagmanModelTest_M, "Simulation finished"); |
361 | } |
362 | |
363 | if (rtmGetStopRequested(RaspberryMagmanModelTest_M)) { |
364 | rtmSetErrorStatus(RaspberryMagmanModelTest_M, "Simulation finished"); |
365 | } |
366 | } |
367 | |
368 | /* Update absolute time for base rate */ |
369 | /* The "clockTick0" counts the number of times the code of this task has |
370 | * been executed. The absolute time is the multiplication of "clockTick0" |
371 | * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not |
372 | * overflow during the application lifespan selected. |
373 | * Timer of this task consists of two 32 bit unsigned integers. |
374 | * The two integers represent the low bits Timing.clockTick0 and the high bits |
375 | * Timing.clockTickH0. When the low bit overflows to 0, the high bits increment. |
376 | */ |
377 | if (!(++RaspberryMagmanModelTest_M->Timing.clockTick0)) { |
378 | ++RaspberryMagmanModelTest_M->Timing.clockTickH0; |
379 | } |
380 | |
381 | RaspberryMagmanModelTest_M->Timing.t[0] = |
382 | RaspberryMagmanModelTest_M->Timing.clockTick0 * |
383 | RaspberryMagmanModelTest_M->Timing.stepSize0 + |
384 | RaspberryMagmanModelTest_M->Timing.clockTickH0 * |
385 | RaspberryMagmanModelTest_M->Timing.stepSize0 * 4294967296.0; |
386 | |
387 | { |
388 | /* Update absolute timer for sample time: [0.02s, 0.0s] */ |
389 | /* The "clockTick1" counts the number of times the code of this task has |
390 | * been executed. The resolution of this integer timer is 0.02, which is the step size |
391 | * of the task. Size of "clockTick1" ensures timer will not overflow during the |
392 | * application lifespan selected. |
393 | * Timer of this task consists of two 32 bit unsigned integers. |
394 | * The two integers represent the low bits Timing.clockTick1 and the high bits |
395 | * Timing.clockTickH1. When the low bit overflows to 0, the high bits increment. |
396 | */ |
397 | RaspberryMagmanModelTest_M->Timing.clockTick1++; |
398 | if (!RaspberryMagmanModelTest_M->Timing.clockTick1) { |
399 | RaspberryMagmanModelTest_M->Timing.clockTickH1++; |
400 | } |
401 | } |
402 | } |
403 | |
404 | /* Model initialize function */ |
405 | void RaspberryMagmanModelTest_initialize(void) |
406 | { |
407 | /* Registration code */ |
408 | |
409 | /* initialize non-finites */ |
410 | rt_InitInfAndNaN(sizeof(real_T)); |
411 | |
412 | /* initialize real-time model */ |
413 | (void) memset((void *)RaspberryMagmanModelTest_M, 0, |
414 | sizeof(RT_MODEL_RaspberryMagmanModel_T)); |
415 | |
416 | { |
417 | /* Setup solver object */ |
418 | rtsiSetSimTimeStepPtr(&RaspberryMagmanModelTest_M->solverInfo, |
419 | &RaspberryMagmanModelTest_M->Timing.simTimeStep); |
420 | rtsiSetTPtr(&RaspberryMagmanModelTest_M->solverInfo, &rtmGetTPtr |
421 | (RaspberryMagmanModelTest_M)); |
422 | rtsiSetStepSizePtr(&RaspberryMagmanModelTest_M->solverInfo, |
423 | &RaspberryMagmanModelTest_M->Timing.stepSize0); |
424 | rtsiSetErrorStatusPtr(&RaspberryMagmanModelTest_M->solverInfo, |
425 | (&rtmGetErrorStatus(RaspberryMagmanModelTest_M))); |
426 | rtsiSetRTModelPtr(&RaspberryMagmanModelTest_M->solverInfo, |
427 | RaspberryMagmanModelTest_M); |
428 | } |
429 | |
430 | rtsiSetSimTimeStep(&RaspberryMagmanModelTest_M->solverInfo, MAJOR_TIME_STEP); |
431 | rtsiSetSolverName(&RaspberryMagmanModelTest_M->solverInfo,"FixedStepDiscrete"); |
432 | rtmSetTPtr(RaspberryMagmanModelTest_M, |
433 | &RaspberryMagmanModelTest_M->Timing.tArray[0]); |
434 | rtmSetTFinal(RaspberryMagmanModelTest_M, 5.0); |
435 | RaspberryMagmanModelTest_M->Timing.stepSize0 = 0.02; |
436 | |
437 | /* External mode info */ |
438 | RaspberryMagmanModelTest_M->Sizes.checksums[0] = (4954737U); |
439 | RaspberryMagmanModelTest_M->Sizes.checksums[1] = (1382723365U); |
440 | RaspberryMagmanModelTest_M->Sizes.checksums[2] = (2628527957U); |
441 | RaspberryMagmanModelTest_M->Sizes.checksums[3] = (259820833U); |
442 | |
443 | { |
444 | static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE; |
445 | static RTWExtModeInfo rt_ExtModeInfo; |
446 | static const sysRanDType *systemRan[5]; |
447 | RaspberryMagmanModelTest_M->extModeInfo = (&rt_ExtModeInfo); |
448 | rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan); |
449 | systemRan[0] = &rtAlwaysEnabled; |
450 | systemRan[1] = &rtAlwaysEnabled; |
451 | systemRan[2] = &rtAlwaysEnabled; |
452 | systemRan[3] = &rtAlwaysEnabled; |
453 | systemRan[4] = &rtAlwaysEnabled; |
454 | rteiSetModelMappingInfoPtr(RaspberryMagmanModelTest_M->extModeInfo, |
455 | &RaspberryMagmanModelTest_M->SpecialInfo.mappingInfo); |
456 | rteiSetChecksumsPtr(RaspberryMagmanModelTest_M->extModeInfo, |
457 | RaspberryMagmanModelTest_M->Sizes.checksums); |
458 | rteiSetTPtr(RaspberryMagmanModelTest_M->extModeInfo, rtmGetTPtr |
459 | (RaspberryMagmanModelTest_M)); |
460 | } |
461 | |
462 | /* block I/O */ |
463 | (void) memset(((void *) &RaspberryMagmanModelTest_B), 0, |
464 | sizeof(B_RaspberryMagmanModelTest_T)); |
465 | |
466 | /* states (dwork) */ |
467 | (void) memset((void *)&RaspberryMagmanModelTest_DW, 0, |
468 | sizeof(DW_RaspberryMagmanModelTest_T)); |
469 | |
470 | /* data type transition information */ |
471 | { |
472 | static DataTypeTransInfo dtInfo; |
473 | (void) memset((char_T *) &dtInfo, 0, |
474 | sizeof(dtInfo)); |
475 | RaspberryMagmanModelTest_M->SpecialInfo.mappingInfo = (&dtInfo); |
476 | dtInfo.numDataTypes = 14; |
477 | dtInfo.dataTypeSizes = &rtDataTypeSizes[0]; |
478 | dtInfo.dataTypeNames = &rtDataTypeNames[0]; |
479 | |
480 | /* Block I/O transition table */ |
481 | dtInfo.BTransTable = &rtBTransTable; |
482 | |
483 | /* Parameters transition table */ |
484 | dtInfo.PTransTable = &rtPTransTable; |
485 | } |
486 | |
487 | /* S-Function Block: <S4>/MagMan Foil with error */ |
488 | { |
489 | real_T initVector[1] = { 0 }; |
490 | |
491 | { |
492 | int_T i1; |
493 | for (i1=0; i1 < 1; i1++) { |
494 | RaspberryMagmanModelTest_DW.MagManFoilwitherror_DSTATE = initVector[0]; |
495 | } |
496 | } |
497 | } |
498 | |
499 | /* S-Function Block: <S5>/Shared memory camera position */ |
500 | { |
501 | real_T initVector[1] = { 0 }; |
502 | |
503 | { |
504 | int_T i1; |
505 | for (i1=0; i1 < 1; i1++) { |
506 | RaspberryMagmanModelTest_DW.Sharedmemorycameraposition_DSTA = |
507 | initVector[0]; |
508 | } |
509 | } |
510 | } |
511 | |
512 | /* InitializeConditions for DiscreteStateSpace: '<Root>/Discrete State-Space' */ |
513 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[0] = |
514 | (RaspberryMagmanModelTest_P.DiscreteStateSpace_X0[0]); |
515 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[1] = |
516 | (RaspberryMagmanModelTest_P.DiscreteStateSpace_X0[1]); |
517 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[2] = |
518 | (RaspberryMagmanModelTest_P.DiscreteStateSpace_X0[2]); |
519 | RaspberryMagmanModelTest_DW.DiscreteStateSpace_DSTATE[3] = |
520 | (RaspberryMagmanModelTest_P.DiscreteStateSpace_X0[3]); |
521 | |
522 | /* S-Function Block: <Root>/MagMan Coils */ |
523 | { |
524 | real_T initVector[1] = { 0 }; |
525 | |
526 | { |
527 | int_T i1; |
528 | for (i1=0; i1 < 1; i1++) { |
529 | RaspberryMagmanModelTest_DW.MagManCoils_DSTATE = initVector[0]; |
530 | } |
531 | } |
532 | } |
533 | } |
534 | |
535 | /* Model terminate function */ |
536 | void RaspberryMagmanModelTest_terminate(void) |
537 | { |
538 | /* (no terminate code required) */ |
539 | } |
540 | |