1 | /* |
2 | * File: ert_main.c |
3 | * |
4 | * Code generated for Simulink model 'ManageVehicleStates_sil_sil_ec'. |
5 | * |
6 | * Model version : 1.2 |
7 | * Simulink Coder version : 9.0 (R2018b) 24-May-2018 |
8 | * C/C++ source code generated on : Tue Oct 29 09:38:21 2019 |
9 | * |
10 | * Target selection: ert.tlc |
11 | * Embedded hardware selection: Intel->x86-64 (Windows64) |
12 | * Code generation objectives: |
13 | * 1. Execution efficiency |
14 | * 2. RAM efficiency |
15 | * Validation result: Not run |
16 | */ |
17 | |
18 | #include <stddef.h> |
19 | #include <stdio.h> /* This ert_main.c example uses printf/fflush */ |
20 | #include "ManageVehicleStates_sil_sil_ec.h" /* Model's header file */ |
21 | #include "rtwtypes.h" |
22 | |
23 | /* |
24 | * Associating rt_OneStep with a real-time clock or interrupt service routine |
25 | * is what makes the generated code "real-time". The function rt_OneStep is |
26 | * always associated with the base rate of the model. Subrates are managed |
27 | * by the base rate from inside the generated code. Enabling/disabling |
28 | * interrupts and floating point context switches are target specific. This |
29 | * example code indicates where these should take place relative to executing |
30 | * the generated code step function. Overrun behavior should be tailored to |
31 | * your application needs. This example simply sets an error status in the |
32 | * real-time model and returns from rt_OneStep. |
33 | */ |
34 | void rt_OneStep(void); |
35 | void rt_OneStep(void) |
36 | { |
37 | static boolean_T OverrunFlag = false; |
38 | |
39 | /* Disable interrupts here */ |
40 | |
41 | /* Check for overrun */ |
42 | if (OverrunFlag) { |
43 | rtmSetErrorStatus(rtM, "Overrun"); |
44 | return; |
45 | } |
46 | |
47 | OverrunFlag = true; |
48 | |
49 | /* Save FPU context here (if necessary) */ |
50 | /* Re-enable timer or interrupt here */ |
51 | /* Set model inputs here */ |
52 | |
53 | /* Step the model */ |
54 | ManageVehicleStates_sil_sil_ec_step(); |
55 | |
56 | /* Get model outputs here */ |
57 | |
58 | /* Indicate task complete */ |
59 | OverrunFlag = false; |
60 | |
61 | /* Disable interrupts here */ |
62 | /* Restore FPU context here (if necessary) */ |
63 | /* Enable interrupts here */ |
64 | } |
65 | |
66 | /* |
67 | * The example "main" function illustrates what is required by your |
68 | * application code to initialize, execute, and terminate the generated code. |
69 | * Attaching rt_OneStep to a real-time clock is target specific. This example |
70 | * illustrates how you do this relative to initializing the model. |
71 | */ |
72 | int_T main(int_T argc, const char *argv[]) |
73 | { |
74 | /* Unused arguments */ |
75 | (void)(argc); |
76 | (void)(argv); |
77 | |
78 | /* Initialize model */ |
79 | ManageVehicleStates_sil_sil_ec_initialize(); |
80 | |
81 | /* Attach rt_OneStep to a timer or interrupt service routine with |
82 | * period 0.05 seconds (the model's base sample time) here. The |
83 | * call syntax for rt_OneStep is |
84 | * |
85 | * rt_OneStep(); |
86 | */ |
87 | printf("Warning: The simulation will run forever. " |
88 | "Generated ERT main won't simulate model step behavior. " |
89 | "To change this behavior select the 'MAT-file logging' option.\n"); |
90 | fflush((NULL)); |
91 | while (rtmGetErrorStatus(rtM) == (NULL)) { |
92 | /* Perform other application tasks here */ |
93 | } |
94 | |
95 | /* Disable rt_OneStep() here */ |
96 | |
97 | /* Terminate model */ |
98 | ManageVehicleStates_sil_sil_ec_terminate(); |
99 | return 0; |
100 | } |
101 | |
102 | /* |
103 | * File trailer for generated code. |
104 | * |
105 | * [EOF] |
106 | */ |
107 | |