2 Copyright (C) 2012 Modelon AB
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the BSD style license.
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.
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>.
18 /** \file fmi2_import_variable.h
19 * \brief Public interface to the FMI import C-library. Handling of model variables.
22 #ifndef FMI2_IMPORT_VARIABLE_H_
23 #define FMI2_IMPORT_VARIABLE_H_
25 #include <FMI/fmi_import_context.h>
27 #include "fmi2_import_type.h"
28 #include "fmi2_import_unit.h"
34 \addtogroup fmi2_import
36 \addtogroup fmi2_import_variables Functions for handling variable definitions.
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().
44 /**@name Scalar variable types */
\r
46 /** \brief General variable type.
\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
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
67 /** \brief Get the variable name */
68 FMILIB_EXPORT const char* fmi2_import_get_variable_name(fmi2_import_variable_t*);
70 /** \brief Get variable description.
71 @return Description string or empty string ("") if no description in the XML file was given.
73 FMILIB_EXPORT const char* fmi2_import_get_variable_description(fmi2_import_variable_t*);
75 /** \brief Get variable value reference */
76 FMILIB_EXPORT fmi2_value_reference_t fmi2_import_get_variable_vr(fmi2_import_variable_t*);
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.
81 FMILIB_EXPORT fmi2_import_variable_typedef_t* fmi2_import_get_variable_declared_type(fmi2_import_variable_t*);
83 /** \brief Get variable base type */
84 FMILIB_EXPORT fmi2_base_type_enu_t fmi2_import_get_variable_base_type(fmi2_import_variable_t*);
86 /** \brief Check if the variable has "start" attribute */
87 FMILIB_EXPORT int fmi2_import_get_variable_has_start(fmi2_import_variable_t*);
89 /** \brief Get variability attribute */
90 FMILIB_EXPORT fmi2_variability_enu_t fmi2_import_get_variability(fmi2_import_variable_t*);
92 /** \brief Get causality attribute */
93 FMILIB_EXPORT fmi2_causality_enu_t fmi2_import_get_causality(fmi2_import_variable_t*);
95 /** \brief Get initial attribute */
96 FMILIB_EXPORT fmi2_initial_enu_t fmi2_import_get_initial(fmi2_import_variable_t* );
99 \brief Get the variable that holds the previous value of this variable, if defined.
101 @return If this variable is a discrete-time state, return the variable holds its previous value;
104 FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_previous(fmi2_import_variable_t* v);
106 /** \brief Get the canHandleMultipleSetPerTimeInstant flag for a variable.
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.
112 FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_canHandleMultipleSetPerTimeInstant(fmi2_import_variable_t* v);
114 /** \brief Cast general variable to a one with the specific type
116 @return Typed object or NULL if base type does not match
118 FMILIB_EXPORT fmi2_import_real_variable_t* fmi2_import_get_variable_as_real(fmi2_import_variable_t*);
120 /** \brief Cast general variable to a one with the specific type
122 @return Typed object or NULL if base type does not match
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
127 @return Typed object or NULL if base type does not match
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
132 @return Typed object or NULL if base type does not match
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
137 @return Typed object or NULL if base type does not match
139 FMILIB_EXPORT fmi2_import_bool_variable_t* fmi2_import_get_variable_as_boolean(fmi2_import_variable_t*);
142 \brief Get the variable start attribute.
144 @return The "start" attribute as specified in the XML file or variable nominal value.
146 FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_start(fmi2_import_real_variable_t* v);
149 \brief Get the variable that this is a derivative of, if defined.
151 @return If this variable is a derivative, return the variable that it is a derivative of;
154 FMILIB_EXPORT fmi2_import_real_variable_t* fmi2_import_get_real_variable_derivative_of(fmi2_import_real_variable_t* v);
156 /** \brief Get the reinit flag for a real variable.
158 @return True if the real variable may change value at events.
160 FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_real_variable_reinit(fmi2_import_real_variable_t* v);
162 /** \brief Get maximum value for the variable
164 @return Either the value specified in the XML file or DBL_MAX as defined in <float.h>
166 FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_max(fmi2_import_real_variable_t* v);
168 /** \brief Get minimal value for the variable.
170 @return Either the value specified in the XML file or negated DBL_MAX as defined in <float.h>
172 FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_min(fmi2_import_real_variable_t* v);
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);
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);
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);
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);
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);
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);
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);
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*);
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);