]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/src/Util/include/FMI2/fmi2_enums.h
Switch to full JavaSE-11+ compatibility
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Util / include / FMI2 / fmi2_enums.h
1 /*
2     Copyright (C) 2012 Modelon AB
3
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the BSD style license.
6
7      This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10     FMILIB_License.txt file for more details.
11
12     You should have received a copy of the FMILIB_License.txt file
13     along with this program. If not, contact Modelon AB <http://www.modelon.com>.
14 */\r
15 \r
16 #ifndef FMI2_ENUMS_H_\r
17 #define FMI2_ENUMS_H_\r
18 \r
19 #include <fmilib_config.h>\r
20 \r
21 #ifdef __cplusplus\r
22 extern "C" {\r
23 #endif\r
24 \r
25 /** \file fmi2_enums.h \r
26         \brief Definions the enum types used with FMI 2.0 libs\r
27 */\r
28 \r
29 /**     \addtogroup fmi2_utils\r
30         @{\r
31         \addtogroup fmi2_enums\r
32         @}\r
33 */
34 /** \addtogroup fmi2_enums Enum types used with FMI 2.0 libs\r
35         @{\r
36 */\r
37 /** \brief Naming convention for the variables in XML file*/\r
38 typedef enum fmi2_variable_naming_convension_enu_t\r
39\r
40         fmi2_naming_enu_flat,\r
41         fmi2_naming_enu_structured,\r
42         fmi2_naming_enu_unknown\r
43 } fmi2_variable_naming_convension_enu_t;\r
44 \r
45 /** \brief Convert a #fmi2_variable_naming_convension_enu_t constant into string */\r
46 FMILIB_EXPORT const char* fmi2_naming_convention_to_string(fmi2_variable_naming_convension_enu_t convention);\r
47 \r
48 /**  \brief FMU 2.0 kinds */\r
49 typedef enum fmi2_fmu_kind_enu_t\r
50 {\r
51                 fmi2_fmu_kind_unknown = 0,\r
52         fmi2_fmu_kind_me = 1,\r
53         fmi2_fmu_kind_cs = 2,\r
54         fmi2_fmu_kind_me_and_cs = 3 /* defined to be equal to (fmi2_fmu_kind_me|fmi2_fmu_kind_cs) */\r
55 } fmi2_fmu_kind_enu_t;\r
56 \r
57 /** \brief Convert a #fmi2_fmu_kind_enu_t constant into string  */\r
58 FMILIB_EXPORT const char* fmi2_fmu_kind_to_string(fmi2_fmu_kind_enu_t kind);\r
59 \r
60 /**  \brief Variability property for variables */\r
61 typedef enum fmi2_variability_enu_t {
62         fmi2_variability_enu_constant = 0,
63         fmi2_variability_enu_fixed  = 1,
64         fmi2_variability_enu_tunable  = 2,
65         fmi2_variability_enu_discrete  = 3,
66         fmi2_variability_enu_continuous  = 4,
67                 fmi2_variability_enu_unknown  = 5
68 } fmi2_variability_enu_t;
69
70 /** \brief Convert a #fmi2_variability_enu_t constant into string  */
71 FMILIB_EXPORT const char* fmi2_variability_to_string(fmi2_variability_enu_t v);
72
73 /**  \brief Causality property for variables */
74 typedef enum fmi2_causality_enu_t {
75         fmi2_causality_enu_parameter = 0,
76         fmi2_causality_enu_calculated_parameter = 1,
77         fmi2_causality_enu_input  = 2,
78         fmi2_causality_enu_output  = 3,
79         fmi2_causality_enu_local  = 4,
80         fmi2_causality_enu_independent = 5,
81         fmi2_causality_enu_unknown = 6
82 } fmi2_causality_enu_t;
83
84 /** \brief Convert a #fmi2_causality_enu_t constant into string  */
85 FMILIB_EXPORT const char* fmi2_causality_to_string(fmi2_causality_enu_t c);
86 \r
87 /**  \brief Initial property for variables */
88 typedef enum fmi2_initial_enu_t {
89         fmi2_initial_enu_exact,
90         fmi2_initial_enu_approx,
91         fmi2_initial_enu_calculated,
92         fmi2_initial_enu_unknown /* must be last*/
93 } fmi2_initial_enu_t;
94
95 /** \brief Convert a #fmi2_initial_enu_t constant into string  */
96 FMILIB_EXPORT const char* fmi2_initial_to_string(fmi2_initial_enu_t c);
97 \r
98 /** \r
99         \brief Get default initial attribute value for the given variability and causality combination.\r
100         \return The default initial attribute or fmi2_initial_enu_unknown if combination of causality\r
101                         and variability is not valid.\r
102 */\r
103 FMILIB_EXPORT fmi2_initial_enu_t fmi2_get_default_initial(fmi2_variability_enu_t v, fmi2_causality_enu_t c);\r
104 \r
105 /** \r
106         \brief Check if the combination of variability, causality and initial is valid.\r
107         \return Same initial as submitted if the combination is valid. Otherwise, same as fmi2_get_default_initial.\r
108 */\r
109 FMILIB_EXPORT fmi2_initial_enu_t fmi2_get_valid_initial(fmi2_variability_enu_t v, fmi2_causality_enu_t c, fmi2_initial_enu_t i);\r
110 \r
111 /** \brief Alias property for variables */\r
112 typedef enum fmi2_variable_alias_kind_enu_t {
113     fmi2_variable_is_not_alias = 0,
114     fmi2_variable_is_alias = 1
115 } fmi2_variable_alias_kind_enu_t;
116
117 /** \brief Base types used in type definitions */
118 typedef enum fmi2_base_type_enu_t
119 {
120         fmi2_base_type_real,
121         fmi2_base_type_int,
122         fmi2_base_type_bool,
123         fmi2_base_type_str,
124         fmi2_base_type_enum
125 } fmi2_base_type_enu_t;
126
127 /**  \brief Convert base type constant to string 
128         \param bt Base type identifier.
129         \return Corresponding base type name.
130         */
131 FMILIB_EXPORT const char* fmi2_base_type_to_string(fmi2_base_type_enu_t bt);
132
133 /** \brief List of capability flags for ModelExchange */
134 #define FMI2_ME_CAPABILITIES(H) \
135         H(needsExecutionTool) \\r
136         H(completedIntegratorStepNotNeeded) \\r
137         H(canBeInstantiatedOnlyOncePerProcess) \\r
138         H(canNotUseMemoryManagementFunctions) \\r
139         H(canGetAndSetFMUstate) \\r
140         H(canSerializeFMUstate) \\r
141         H(providesDirectionalDerivatives)\\r
142         H(completedEventIterationIsProvided)\r
143
144 /** \brief List of capability flags for CoSimulation */
145 #define FMI2_CS_CAPABILITIES(H) \
146         H(needsExecutionTool) \\r
147         H(canHandleVariableCommunicationStepSize) \\r
148         H(canInterpolateInputs) \\r
149         H(maxOutputDerivativeOrder) \\r
150         H(canRunAsynchronuously) \\r
151         H(canBeInstantiatedOnlyOncePerProcess) \\r
152         H(canNotUseMemoryManagementFunctions) \\r
153         H(canGetAndSetFMUstate) \\r
154         H(canSerializeFMUstate) \\r
155         H(providesDirectionalDerivatives)\r
156
157 /** \brief Capability flags for ModelExchange and CoSimulation */
158 typedef enum fmi2_capabilities_enu_t {
159 #define FMI2_EXPAND_ME_CAPABILITIES_ENU(c) fmi2_me_ ## c,
160 #define FMI2_EXPAND_CS_CAPABILITIES_ENU(c) fmi2_cs_ ## c,
161         FMI2_ME_CAPABILITIES(FMI2_EXPAND_ME_CAPABILITIES_ENU)
162         FMI2_CS_CAPABILITIES(FMI2_EXPAND_CS_CAPABILITIES_ENU)
163         fmi2_capabilities_Num
164 } fmi2_capabilities_enu_t;
165
166 /** \brief Convert capability flag to a string 
167         \param id Capability flag ID.
168         \return Name of the flag or Unknown if the id is out of range.
169 */
170 FMILIB_EXPORT const char * fmi2_capability_to_string(fmi2_capabilities_enu_t id);
171
172 /** \brief List of SI base units used in Unit defitions*/
173 #define FMI2_SI_BASE_UNITS(H) \
174         H(kg) H(m) H(s) H(A) H(K) H(mol) H(cd) H(rad)
175
176 /** \brief SI base units used in Unit defitions*/
177 typedef enum fmi2_SI_base_units_enu_t {
178 #define FMI2_EXPAND_SI_BASE_UNIT_ENU(c) fmi2_SI_base_unit_ ## c,
179         FMI2_SI_BASE_UNITS(FMI2_EXPAND_SI_BASE_UNIT_ENU)
180         fmi2_SI_base_units_Num
181 } fmi2_SI_base_units_enu_t;
182
183 /** \brief Convert SI base unit ID a string 
184         \param id SI base unit ID.
185         \return Name of the base unit or "unknown" if the id is out of range.
186 */
187 FMILIB_EXPORT const char * fmi2_SI_base_unit_to_string(fmi2_SI_base_units_enu_t id);
188
189 /** \brief Convert a list of SI base unit exponents (corresponding to the IDs from  fmi2_SI_base_units_enu_t)
190         to a string of the form kg*m^2/s^2. Prints '-' if all the exponents are zero.
191         \param exp An array of SI base units exponents.
192         \param bufSize Size of the buffer to store the string. 
193         \param buf Buffer to store the string
194         \return Required size of the buffer to store the string. This most likely be under [8*fmi2_SI_base_units_Num].
195         If the return value is larger or equal than bufSize than the string could not be fitted in the buffer. 
196 */
197 FMILIB_EXPORT size_t fmi2_SI_base_unit_exp_to_string(const int exp[fmi2_SI_base_units_Num], size_t bufSize, char buf[]);
198
199
200 /** \brief Dependency factor kinds are used as part of ModelStructure definition */
201 typedef enum fmi2_dependency_factor_kind_enu_t
202 {
203         fmi2_dependency_factor_kind_dependent = 0,
204         fmi2_dependency_factor_kind_constant,
205         fmi2_dependency_factor_kind_fixed,
206         fmi2_dependency_factor_kind_tunable,
207         fmi2_dependency_factor_kind_discrete,
208         fmi2_dependency_factor_kind_num
209 } fmi2_dependency_factor_kind_enu_t;
210
211 /**  \brief Convert dependency factor kind constant to string 
212         \param fc Dependency factor kind identifier.
213         \return Corresponding factor kind as string.
214         */
215 FMILIB_EXPORT const char* fmi2_dependency_factor_kind_to_string(fmi2_dependency_factor_kind_enu_t fc);
216 /**     \r
217  @}\r
218 */
219 #ifdef __cplusplus\r
220 }\r
221 #endif\r
222
223 #endif /* End of header file FMI2_ENUMS_H_ */