]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import_variable.h
Switch to full JavaSE-11+ compatibility
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Import / include / FMI2 / fmi2_import_variable.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 */
15
16
17
18 /** \file fmi2_import_variable.h
19 *  \brief Public interface to the FMI import C-library. Handling of model variables.
20 */
21
22 #ifndef FMI2_IMPORT_VARIABLE_H_
23 #define FMI2_IMPORT_VARIABLE_H_
24
25 #include <FMI/fmi_import_context.h>
26
27 #include "fmi2_import_type.h"
28 #include "fmi2_import_unit.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33                 /**
34         \addtogroup fmi2_import
35         @{
36         \addtogroup fmi2_import_variables Functions for handling variable definitions.
37         @}
38         \addtogroup fmi2_import_variables Functions for handling variable definitions.
39         \brief All the functions in this group take a pointer to ::fmi2_import_variable_t as a parameter.
40         A variable pointer may be obtained via a \ref fmi2_import_varlist module or via functions
41         fmi2_import_get_variable_by_name() and fmi2_import_get_variable_by_vr().
42         @{
43         */
44         /**@name Scalar variable types */\r
45 /**@{ */\r
46 /** \brief General variable type. \r
47 *\r
48 * This type is convenient to unify all the variable list operations. \r
49 *       However, typed variables are needed to support specific attributes.\r
50 */\r
51 typedef struct fmi2_xml_variable_t fmi2_import_variable_t;\r
52 /** \brief  Opaque real variable */\r
53 typedef struct fmi2_xml_real_variable_t fmi2_import_real_variable_t;\r
54 /** \brief Opaque integer variable */\r
55 typedef struct fmi2_xml_integer_variable_t fmi2_import_integer_variable_t;\r
56 /** \brief Opaque string variable */\r
57 typedef struct fmi2_xml_string_variable_t fmi2_import_string_variable_t;\r
58 /** \brief Opaque enumeration variable */\r
59 typedef struct fmi2_xml_enum_variable_t fmi2_import_enum_variable_t;\r
60 /** \brief Opaque boolean variable */\r
61 typedef struct fmi2_xml_bool_variable_t fmi2_import_bool_variable_t;\r
62 /** \brief List of variables */\r
63 typedef struct fmi2_import_variable_list_t fmi2_import_variable_list_t;\r
64 /**@} */\r
65
66
67 /** \brief Get the variable name */
68 FMILIB_EXPORT const char* fmi2_import_get_variable_name(fmi2_import_variable_t*);
69
70 /** \brief Get variable description. 
71         @return Description string or empty string ("") if no description in the XML file was given.
72 */
73 FMILIB_EXPORT const char* fmi2_import_get_variable_description(fmi2_import_variable_t*);
74
75 /** \brief Get variable value reference */
76 FMILIB_EXPORT fmi2_value_reference_t fmi2_import_get_variable_vr(fmi2_import_variable_t*);
77
78 /**   \brief For scalar variable gives the type definition is present
79         @return Pointer of a type #fmi2_import_variable_typedef_t object or NULL of not present.
80 */
81 FMILIB_EXPORT fmi2_import_variable_typedef_t* fmi2_import_get_variable_declared_type(fmi2_import_variable_t*);
82
83 /** \brief Get variable base type */
84 FMILIB_EXPORT fmi2_base_type_enu_t fmi2_import_get_variable_base_type(fmi2_import_variable_t*);
85
86 /** \brief Check if the variable has "start" attribute */
87 FMILIB_EXPORT int   fmi2_import_get_variable_has_start(fmi2_import_variable_t*);
88
89 /** \brief Get variability attribute */
90 FMILIB_EXPORT fmi2_variability_enu_t fmi2_import_get_variability(fmi2_import_variable_t*);
91
92 /** \brief Get causality attribute */
93 FMILIB_EXPORT fmi2_causality_enu_t fmi2_import_get_causality(fmi2_import_variable_t*);
94
95 /** \brief Get initial attribute */
96 FMILIB_EXPORT fmi2_initial_enu_t fmi2_import_get_initial(fmi2_import_variable_t* );
97
98 /** 
99     \brief Get the variable that holds the previous value of this variable, if defined.
100
101     @return If this variable is a discrete-time state, return the variable holds its previous value;
102             NULL otherwise.
103 */
104 FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_previous(fmi2_import_variable_t* v);
105
106 /** \brief Get the canHandleMultipleSetPerTimeInstant flag for a variable.
107
108         @return For inputs: If false, then only one fmiSetXXX call is allowed at
109     one super dense time instant. In other words, this input is not allowed to
110     appear in an algebraic loop.
111 */
112 FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_canHandleMultipleSetPerTimeInstant(fmi2_import_variable_t* v);
113
114 /** \brief Cast general variable to a one with the specific type 
115         
116         @return Typed object or NULL if base type does not match
117 */
118 FMILIB_EXPORT fmi2_import_real_variable_t* fmi2_import_get_variable_as_real(fmi2_import_variable_t*);
119
120 /** \brief Cast general variable to a one with the specific type 
121         
122         @return Typed object or NULL if base type does not match
123 */
124 FMILIB_EXPORT fmi2_import_integer_variable_t* fmi2_import_get_variable_as_integer(fmi2_import_variable_t*);
125 /** \brief Cast general variable to a one with the specific type 
126         
127         @return Typed object or NULL if base type does not match
128 */
129 FMILIB_EXPORT fmi2_import_enum_variable_t* fmi2_import_get_variable_as_enum(fmi2_import_variable_t*);
130 /** \brief Cast general variable to a one with the specific type 
131         
132         @return Typed object or NULL if base type does not match
133 */
134 FMILIB_EXPORT fmi2_import_string_variable_t* fmi2_import_get_variable_as_string(fmi2_import_variable_t*);
135 /** \brief Cast general variable to a one with the specific type 
136         
137         @return Typed object or NULL if base type does not match
138 */
139 FMILIB_EXPORT fmi2_import_bool_variable_t* fmi2_import_get_variable_as_boolean(fmi2_import_variable_t*);
140
141 /** 
142         \brief Get the variable start attribute. 
143
144         @return The "start" attribute as specified in the XML file or variable nominal value.
145 */
146 FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_start(fmi2_import_real_variable_t* v);
147
148 /** 
149     \brief Get the variable that this is a derivative of, if defined.
150
151     @return If this variable is a derivative, return the variable that it is a derivative of;
152             NULL otherwise.
153 */
154 FMILIB_EXPORT fmi2_import_real_variable_t* fmi2_import_get_real_variable_derivative_of(fmi2_import_real_variable_t* v);
155
156 /** \brief Get the reinit flag for a real variable.
157
158         @return True if the real variable may change value at events.
159 */
160 FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_real_variable_reinit(fmi2_import_real_variable_t* v);
161
162 /** \brief Get maximum value for the variable
163
164         @return Either the value specified in the XML file or DBL_MAX as defined in <float.h>
165 */
166 FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_max(fmi2_import_real_variable_t* v);
167
168 /** \brief Get minimal value for the variable.
169
170         @return Either the value specified in the XML file or negated DBL_MAX as defined in <float.h>
171 */
172 FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_min(fmi2_import_real_variable_t* v);
173
174 /** \brief Get nominal value for the variable*/
175 FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_nominal(fmi2_import_real_variable_t* v);
176
177 /** \brief Get associated "unit" object if any */
178 FMILIB_EXPORT fmi2_import_unit_t* fmi2_import_get_real_variable_unit(fmi2_import_real_variable_t* v);
179
180 /** \brief Get associated "display unit" object if any */
181 FMILIB_EXPORT fmi2_import_display_unit_t* fmi2_import_get_real_variable_display_unit(fmi2_import_real_variable_t* v);
182
183 /** \brief Get start value for the variable */
184 FMILIB_EXPORT const char* fmi2_import_get_string_variable_start(fmi2_import_string_variable_t* v);
185
186 /** \brief Get start value for the variable */
187 FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_boolean_variable_start(fmi2_import_bool_variable_t* v);
188
189 /** \brief Get start value for the variable*/
190 FMILIB_EXPORT int fmi2_import_get_integer_variable_start(fmi2_import_integer_variable_t* v);
191 /** \brief Get minimal value for the variable */
192 FMILIB_EXPORT int fmi2_import_get_integer_variable_min(fmi2_import_integer_variable_t* v);
193 /** \brief Get max value for the variable */
194 FMILIB_EXPORT int fmi2_import_get_integer_variable_max(fmi2_import_integer_variable_t* v);
195
196 /** \brief Get start value for the variable*/
197 FMILIB_EXPORT int fmi2_import_get_enum_variable_start(fmi2_import_enum_variable_t* v);
198 /** \brief Get minimal value for the variable */
199 FMILIB_EXPORT int fmi2_import_get_enum_variable_min(fmi2_import_enum_variable_t* v);
200 /** \brief Get max value for the variable */
201 FMILIB_EXPORT int fmi2_import_get_enum_variable_max(fmi2_import_enum_variable_t* v);
202
203 /** \brief Get the variable alias kind*/
204 FMILIB_EXPORT fmi2_variable_alias_kind_enu_t fmi2_import_get_variable_alias_kind(fmi2_import_variable_t*);
205
206 /** \brief Get the original index in xml of the variable */
207 FMILIB_EXPORT size_t fmi2_import_get_variable_original_order(fmi2_import_variable_t* v);
208
209 /** @} */
210
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif