-
Notifications
You must be signed in to change notification settings - Fork 0
/
xxmodel.h
120 lines (100 loc) · 3.21 KB
/
xxmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**********************************************************
* This file is generated by 20-sim ANSI-C Code Generator
*
* file: src\xxmodel.h
* subm: MassSpringDamper1
* model: MassSpringDamper
* expmt: MassSpringDamper
* date: April 3, 2017
* time: 11:26:28 AM
* user: INTO-CPS
* from: 20-sim 4.6 Professional Single
* build: 4.6.3.7711
**********************************************************/
/* This file describes the model functions
that are supplied for computation.
The model itself is the xxmodel.c file
*/
#ifndef XX_MODEL_H
#define XX_MODEL_H
/* Our own include files */
#include "xxtypes.h"
#include "fmi2Functions.h"
/* the chosen integration method */
#define RungeKutta4_METHOD
/* Model size constants */
#define xx_constants_count 0
#define xx_parameter_count 3
#define xx_initialvalue_count 2
#define xx_variable_count 1
#define xx_state_count 2
typedef struct xx_ModelInstance
{
/* Global pointer to co-simulator callback functions */
const fmi2CallbackFunctions* fmiCallbackFunctions;
/* FMU */
fmi2String instanceName;
/* Store the path to the extracted resource folder location provided by the
* co-simulation engine for this model instance
*/
const char* resourceLocation;
/* Simulation variables */
XXDouble start_time;
XXDouble finish_time;
XXBoolean m_use_finish_time;
XXDouble step_size;
XXDouble time;
XXInteger steps;
XXBoolean initialize;
XXBoolean major;
XXBoolean stop_simulation;
/* Model state */
XXDouble MEMORY[
xx_parameter_count +
xx_initialvalue_count +
xx_variable_count +
xx_state_count /* states */ +
xx_state_count /* rates */ +
1
];
/* Integration method intermediate variables */
#ifdef RungeKutta2_METHOD
XXDouble q0[xx_state_count];
#endif
#ifdef RungeKutta4_METHOD
XXDouble q0[xx_state_count];
XXDouble q1[xx_state_count];
XXDouble q2[xx_state_count];
XXDouble q3[xx_state_count];
XXDouble q4[xx_state_count];
#endif
/* Memory offset pointers */
XXDouble* P; /* parameters */
XXDouble* I; /* initial values */
XXDouble* V; /* variables */
XXDouble* s; /* states */
XXDouble* R; /* rates (or new states) */
} xx_ModelInstance;
/* Variable arrays */
#define xx_P model_instance->P
#define xx_I model_instance->I
#define xx_V model_instance->V
#define xx_s model_instance->s
#define xx_R model_instance->R
#define xx_time model_instance->time
#define xx_step_size model_instance->step_size
#define xx_initialize model_instance->initialize
#define xx_major model_instance->major
#define xx_start_time model_instance->start_time
#define xx_finish_time model_instance->finish_time
/* Initialization methods */
void XXModelInitialize (xx_ModelInstance* model_instance);
void XXModelTerminate (xx_ModelInstance* model_instance);
/* Computation methods */
void XXCalculateInitial (xx_ModelInstance* model_instance);
void XXCalculateStatic (xx_ModelInstance* model_instance);
void XXCalculateInput (xx_ModelInstance* model_instance);
void XXCalculateDynamic (xx_ModelInstance* model_instance);
void XXCalculateOutput (xx_ModelInstance* model_instance);
void XXCalculateFinal (xx_ModelInstance* model_instance);
#endif