Skip to content

Commit 91d1a17

Browse files
committed
Add generated code
0 parents  commit 91d1a17

9 files changed

+1934
-0
lines changed

ert_main.c

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Academic License - for use in teaching, academic research, and meeting
3+
* course requirements at degree granting institutions only. Not for
4+
* government, commercial, or other organizational use.
5+
*
6+
* File: ert_main.c
7+
*
8+
* Code generated for Simulink model 'tv'.
9+
*
10+
* Model version : 1.19
11+
* Simulink Coder version : 24.1 (R2024a) 19-Nov-2023
12+
* C/C++ source code generated on : Mon Jun 17 15:23:14 2024
13+
*
14+
* Target selection: ert.tlc
15+
* Embedded hardware selection: Intel->x86-64 (Windows64)
16+
* Code generation objectives: Unspecified
17+
* Validation result: Not run
18+
*/
19+
20+
#include <stddef.h>
21+
#include <stdio.h> /* This example main program uses printf/fflush */
22+
#include "tv.h" /* Model header file */
23+
24+
/*
25+
* Associating rt_OneStep with a real-time clock or interrupt service routine
26+
* is what makes the generated code "real-time". The function rt_OneStep is
27+
* always associated with the base rate of the model. Subrates are managed
28+
* by the base rate from inside the generated code. Enabling/disabling
29+
* interrupts and floating point context switches are target specific. This
30+
* example code indicates where these should take place relative to executing
31+
* the generated code step function. Overrun behavior should be tailored to
32+
* your application needs. This example simply sets an error status in the
33+
* real-time model and returns from rt_OneStep.
34+
*/
35+
void rt_OneStep(void);
36+
void rt_OneStep(void)
37+
{
38+
static boolean_T OverrunFlag = false;
39+
40+
/* Disable interrupts here */
41+
42+
/* Check for overrun */
43+
if (OverrunFlag)
44+
{
45+
rtmSetErrorStatus(tv_M, "Overrun");
46+
return;
47+
}
48+
49+
OverrunFlag = true;
50+
51+
/* Save FPU context here (if necessary) */
52+
/* Re-enable timer or interrupt here */
53+
/* Set model inputs here */
54+
55+
/* Step the model */
56+
tv_step();
57+
58+
/* Get model outputs here */
59+
60+
/* Indicate task complete */
61+
OverrunFlag = false;
62+
63+
/* Disable interrupts here */
64+
/* Restore FPU context here (if necessary) */
65+
/* Enable interrupts here */
66+
}
67+
68+
/*
69+
* The example main function illustrates what is required by your
70+
* application code to initialize, execute, and terminate the generated code.
71+
* Attaching rt_OneStep to a real-time clock is target specific. This example
72+
* illustrates how you do this relative to initializing the model.
73+
*/
74+
int_T main(int_T argc, const char *argv[])
75+
{
76+
/* Unused arguments */
77+
(void)(argc);
78+
(void)(argv);
79+
80+
/* Initialize model */
81+
tv_initialize();
82+
83+
/* Simulating the model step behavior (in non real-time) to
84+
* simulate model behavior at stop time.
85+
*/
86+
while (rtmGetErrorStatus(tv_M) == (NULL) && !rtmGetStopRequested(tv_M))
87+
{
88+
rt_OneStep();
89+
printf("Trq_FL_Value: %f\n", tv_B.Trq_FL);
90+
printf("Trq_FR_Value: %f\n", tv_B.Trq_FR);
91+
printf("Trq_RL_Value: %f\n", tv_B.Trq_RL);
92+
printf("Trq_RR_Value: %f\n", tv_B.Trq_RR);
93+
}
94+
95+
/* Terminate model */
96+
tv_terminate();
97+
return 0;
98+
}
99+
100+
/*
101+
* File trailer for generated code.
102+
*
103+
* [EOF]
104+
*/

rtw_continuous.h

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/* Copyright 1990-2022 The MathWorks, Inc. */
2+
3+
/*
4+
* File: rtw_continuous.h
5+
*
6+
* Abstract:
7+
* Type definitions for continuous-time support.
8+
*
9+
*/
10+
11+
#ifndef RTW_CONTINUOUS_H__
12+
#define RTW_CONTINUOUS_H__
13+
14+
#ifdef MATLAB_MEX_FILE
15+
#include "tmwtypes.h"
16+
#else
17+
#include "rtwtypes.h"
18+
#endif
19+
20+
/* For models registering MassMatrix */
21+
typedef enum {
22+
SS_MATRIX_NONE,
23+
SS_MATRIX_CONSTANT,
24+
SS_MATRIX_TIMEDEP,
25+
SS_MATRIX_STATEDEP
26+
} ssMatrixType;
27+
28+
typedef enum {
29+
SOLVER_MODE_AUTO, /* only occurs in
30+
mdlInitializeSizes/mdlInitializeSampleTimes */
31+
SOLVER_MODE_SINGLETASKING,
32+
SOLVER_MODE_MULTITASKING
33+
} SolverMode;
34+
35+
typedef enum { MINOR_TIME_STEP, MAJOR_TIME_STEP } SimTimeStep;
36+
37+
/* =============================================================================
38+
* Model methods object
39+
* =============================================================================
40+
*/
41+
typedef void (*rtMdlInitializeSizesFcn)(void* rtModel);
42+
typedef void (*rtMdlInitializeSampleTimesFcn)(void* rtModel);
43+
typedef void (*rtMdlStartFcn)(void* rtModel);
44+
typedef void (*rtMdlOutputsFcn)(void* rtModel, int_T tid);
45+
typedef void (*rtMdlUpdateFcn)(void* rtModel, int_T tid);
46+
typedef void (*rtMdlDerivativesFcn)(void* rtModel);
47+
typedef void (*rtMdlProjectionFcn)(void* rtModel);
48+
typedef void (*rtMdlMassMatrixFcn)(void* rtModel);
49+
typedef void (*rtMdlForcingFunctionFcn)(void* rtModel);
50+
typedef void (*rtMdlTerminateFcn)(void* rtModel);
51+
#ifdef RT_MALLOC
52+
typedef real_T (*rtMdlDiscreteEventsFcn)(void* pModel,
53+
int_T rtmNumSampTimes,
54+
void* rtmTimingData,
55+
int_T* rtmSampleHitPtr,
56+
int_T* rtmPerTaskSampleHits);
57+
#endif
58+
59+
typedef struct _RTWRTModelMethodsInfo_tag {
60+
void* rtModelPtr;
61+
rtMdlInitializeSizesFcn rtmInitSizesFcn;
62+
rtMdlInitializeSampleTimesFcn rtmInitSampTimesFcn;
63+
rtMdlStartFcn rtmStartFcn;
64+
rtMdlOutputsFcn rtmOutputsFcn;
65+
rtMdlUpdateFcn rtmUpdateFcn;
66+
rtMdlDerivativesFcn rtmDervisFcn;
67+
rtMdlProjectionFcn rtmProjectionFcn;
68+
rtMdlMassMatrixFcn rtmMassMatrixFcn;
69+
rtMdlForcingFunctionFcn rtmForcingFunctionFcn;
70+
rtMdlTerminateFcn rtmTerminateFcn;
71+
#ifdef RT_MALLOC
72+
rtMdlDiscreteEventsFcn rtmDiscreteEventsFcn;
73+
#endif
74+
} RTWRTModelMethodsInfo;
75+
76+
#define rtmiSetRTModelPtr(M, rtmp) ((M).rtModelPtr = (rtmp))
77+
#define rtmiGetRTModelPtr(M) (M).rtModelPtr
78+
79+
#define rtmiSetInitSizesFcn(M, fp) ((M).rtmInitSizesFcn = ((rtMdlInitializeSizesFcn)(fp)))
80+
#define rtmiSetInitSampTimesFcn(M, fp) \
81+
((M).rtmInitSampTimesFcn = ((rtMdlInitializeSampleTimesFcn)(fp)))
82+
#define rtmiSetStartFcn(M, fp) ((M).rtmStartFcn = ((rtMdlStartFcn)(fp)))
83+
#define rtmiSetOutputsFcn(M, fp) ((M).rtmOutputsFcn = ((rtMdlOutputsFcn)(fp)))
84+
#define rtmiSetUpdateFcn(M, fp) ((M).rtmUpdateFcn = ((rtMdlUpdateFcn)(fp)))
85+
#define rtmiSetDervisFcn(M, fp) ((M).rtmDervisFcn = ((rtMdlDerivativesFcn)(fp)))
86+
#define rtmiSetProjectionFcn(M, fp) ((M).rtmProjectionFcn = ((rtMdlProjectionFcn)(fp)))
87+
#define rtmiSetMassMatrixFcn(M, fp) ((M).rtmMassMatrixFcn = ((rtMdlMassMatrixFcn)(fp)))
88+
#define rtmiSetForcingFunctionFcn(M, fp) \
89+
((M).rtmForcingFunctionFcn = ((rtMdlForcingFunctionFcn)(fp)))
90+
#define rtmiSetTerminateFcn(M, fp) ((M).rtmTerminateFcn = ((rtMdlTerminateFcn)(fp)))
91+
#ifdef RT_MALLOC
92+
#define rtmiSetDiscreteEventsFcn(M, fp) ((M).rtmDiscreteEventsFcn = ((rtMdlDiscreteEventsFcn)(fp)))
93+
#endif
94+
95+
#define rtmiInitializeSizes(M) ((*(M).rtmInitSizesFcn)((M).rtModelPtr))
96+
#define rtmiInitializeSampleTimes(M) ((*(M).rtmInitSampTimesFcn)((M).rtModelPtr))
97+
#define rtmiStart(M) ((*(M).rtmStartFcn)((M).rtModelPtr))
98+
#define rtmiOutputs(M, tid) ((*(M).rtmOutputsFcn)((M).rtModelPtr, tid))
99+
#define rtmiUpdate(M, tid) ((*(M).rtmUpdateFcn)((M).rtModelPtr, tid))
100+
#define rtmiDerivatives(M) ((*(M).rtmDervisFcn)((M).rtModelPtr))
101+
#define rtmiProjection(M) ((*(M).rtmProjectionFcn)((M).rtModelPtr))
102+
#define rtmiMassMatrix(M) ((*(M).rtmMassMatrixFcn)((M).rtModelPtr))
103+
#define rtmiForcingFunction(M) ((*(M).rtmForcingFunctionFcn)((M).rtModelPtr))
104+
#define rtmiTerminate(M) ((*(M).rtmTerminateFcn)((M).rtModelPtr))
105+
#ifdef RT_MALLOC
106+
#define rtmiDiscreteEvents(M, x1, x2, x3, x4) \
107+
((*(M).rtmDiscreteEventsFcn)((M).rtModelPtr, (x1), (x2), (x3), (x4)))
108+
#endif
109+
#endif /* __RTW_CONTINUOUS_H__ */

0 commit comments

Comments
 (0)