1//
2// Trial License - for use to evaluate programs for possible purchase as
3// an end-user only.
4//
5// File: ert_main.cpp
6//
7// Code generated for Simulink model 'ImportTest'.
8//
9// Model version : 1.2
10// Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
11// C/C++ source code generated on : Wed Jun 27 14:38:01 2018
12//
13// Target selection: ert.tlc
14// Embedded hardware selection: Intel->x86-64 (Windows64)
15// Code generation objectives: Unspecified
16// Validation result: Not run
17//
18#include <stddef.h>
19#include <stdio.h> // This ert_main.c example uses printf/fflush
20#include "ImportTest.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//
34void rt_OneStep(void);
35void 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(ImportTest_M, "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 ImportTest_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//
72int_T main(int_T argc, const char *argv[])
73{
74 // Unused arguments
75 (void)(argc);
76 (void)(argv);
77
78 // Initialize model
79 ImportTest_initialize();
80
81 // Attach rt_OneStep to a timer or interrupt service routine with
82 // period 0.2 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(ImportTest_M) == (NULL)) {
92 // Perform other application tasks here
93 }
94
95 // Disable rt_OneStep() here
96
97 // Terminate model
98 ImportTest_terminate();
99 return 0;
100}
101
102//
103// File trailer for generated code.
104//
105// [EOF]
106//
107