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 fmi1_import_variable.h
19 * \brief Public interface to the FMI import C-library. Handling of model variables.
22 #ifndef FMI1_IMPORT_VARIABLE_H_
23 #define FMI1_IMPORT_VARIABLE_H_
25 #include <FMI/fmi_import_context.h>
27 #include "fmi1_import_type.h"
28 #include "fmi1_import_unit.h"
34 \addtogroup fmi1_import
36 \addtogroup fmi1_import_variables Functions for handling variable definitions.
38 \addtogroup fmi1_import_variables Functions for handling variable definitions.
39 \brief All the functions in this group take a pointer to ::fmi1_import_variable_t as a parameter.
40 A variable pointer may be obtained via a \ref fmi1_import_varlist module or via functions
41 fmi1_import_get_variable_by_name() and fmi1_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 fmi1_xml_variable_t fmi1_import_variable_t;
\r
52 /** \brief Opaque real variable */
\r
53 typedef struct fmi1_xml_real_variable_t fmi1_import_real_variable_t;
\r
54 /** \brief Opaque integer variable */
\r
55 typedef struct fmi1_xml_integer_variable_t fmi1_import_integer_variable_t;
\r
56 /** \brief Opaque string variable */
\r
57 typedef struct fmi1_xml_string_variable_t fmi1_import_string_variable_t;
\r
58 /** \brief Opaque enumeration variable */
\r
59 typedef struct fmi1_xml_enum_variable_t fmi1_import_enum_variable_t;
\r
60 /** \brief Opaque boolean variable */
\r
61 typedef struct fmi1_xml_bool_variable_t fmi1_import_bool_variable_t;
\r
62 /** \brief List of variables */
\r
63 typedef struct fmi1_import_variable_list_t fmi1_import_variable_list_t;
\r
67 \brief Get variable by variable name.
\r
68 \param fmu - An fmu object as returned by fmi1_import_parse_xml().
\r
69 \param name - variable name
\r
70 \return variable pointer.
\r
72 FMILIB_EXPORT fmi1_import_variable_t* fmi1_import_get_variable_by_name(fmi1_import_t* fmu, const char* name);
\r
75 \brief Get variable by value reference.
\r
76 \param fmu - An fmu object as returned by fmi1_import_parse_xml().
\r
77 \param baseType - basic data type
\r
78 \param vr - value reference
\r
79 \return variable pointer.
\r
81 FMILIB_EXPORT fmi1_import_variable_t* fmi1_import_get_variable_by_vr(fmi1_import_t* fmu, fmi1_base_type_enu_t baseType, fmi1_value_reference_t vr);
\r
84 /** \brief Get the variable name */
85 FMILIB_EXPORT const char* fmi1_import_get_variable_name(fmi1_import_variable_t*);
87 /** \brief Get variable description.
88 @return Description string or empty string ("") if no description in the XML file was given.
90 FMILIB_EXPORT const char* fmi1_import_get_variable_description(fmi1_import_variable_t*);
92 /** \brief Get variable value reference */
93 FMILIB_EXPORT fmi1_value_reference_t fmi1_import_get_variable_vr(fmi1_import_variable_t*);
95 /** \brief For scalar variable gives the type definition is present
96 @return Pointer of a type #fmi1_import_variable_typedef_t object or NULL of not present.
98 FMILIB_EXPORT fmi1_import_variable_typedef_t* fmi1_import_get_variable_declared_type(fmi1_import_variable_t*);
100 /** \brief Get variable base type */
101 FMILIB_EXPORT fmi1_base_type_enu_t fmi1_import_get_variable_base_type(fmi1_import_variable_t*);
103 /** \brief Check if the variable has "start" attribute */
104 FMILIB_EXPORT int fmi1_import_get_variable_has_start(fmi1_import_variable_t*);
105 /** \brief Get the variable "fixed" attribute */
106 FMILIB_EXPORT int fmi1_import_get_variable_is_fixed(fmi1_import_variable_t*);
108 /** \brief Get variability attribute */
109 FMILIB_EXPORT fmi1_variability_enu_t fmi1_import_get_variability(fmi1_import_variable_t*);
111 /** \brief Get causality attribute */
112 FMILIB_EXPORT fmi1_causality_enu_t fmi1_import_get_causality(fmi1_import_variable_t*);
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 fmi1_import_real_variable_t* fmi1_import_get_variable_as_real(fmi1_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 fmi1_import_integer_variable_t* fmi1_import_get_variable_as_integer(fmi1_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 fmi1_import_enum_variable_t* fmi1_import_get_variable_as_enum(fmi1_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 fmi1_import_string_variable_t* fmi1_import_get_variable_as_string(fmi1_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 fmi1_import_bool_variable_t* fmi1_import_get_variable_as_boolean(fmi1_import_variable_t*);
142 \brief Get the variable start attribute.
144 @return The "start" attriburte as specified in the XML file or variable nominal value.
146 FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_start(fmi1_import_real_variable_t* v);
148 /** \brief Get maximum value for the variable
150 @return Either the value specified in the XML file or DBL_MAX as defined in <float.h>
152 FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_max(fmi1_import_real_variable_t* v);
154 /** \brief Get minimal value for the variable.
156 @return Either the value specified in the XML file or negated DBL_MAX as defined in <float.h>
158 FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_min(fmi1_import_real_variable_t* v);
160 /** \brief Get nominal value for the variable*/
161 FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_nominal(fmi1_import_real_variable_t* v);
163 /** \brief Get associated "unit" object if any */
164 FMILIB_EXPORT fmi1_import_unit_t* fmi1_import_get_real_variable_unit(fmi1_import_real_variable_t* v);
166 /** \brief Get associated "display unit" object if any */
167 FMILIB_EXPORT fmi1_import_display_unit_t* fmi1_import_get_real_variable_display_unit(fmi1_import_real_variable_t* v);
169 /** \brief Get start value for the variable */
170 FMILIB_EXPORT const char* fmi1_import_get_string_variable_start(fmi1_import_string_variable_t* v);
172 /** \brief Get start value for the variable */
173 FMILIB_EXPORT fmi1_boolean_t fmi1_import_get_boolean_variable_start(fmi1_import_bool_variable_t* v);
175 /** \brief Get start value for the variable*/
176 FMILIB_EXPORT int fmi1_import_get_integer_variable_start(fmi1_import_integer_variable_t* v);
177 /** \brief Get minimal value for the variable */
178 FMILIB_EXPORT int fmi1_import_get_integer_variable_min(fmi1_import_integer_variable_t* v);
179 /** \brief Get max value for the variable */
180 FMILIB_EXPORT int fmi1_import_get_integer_variable_max(fmi1_import_integer_variable_t* v);
182 /** \brief Get start value for the variable*/
183 FMILIB_EXPORT int fmi1_import_get_enum_variable_start(fmi1_import_enum_variable_t* v);
184 /** \brief Get minimal value for the variable */
185 FMILIB_EXPORT int fmi1_import_get_enum_variable_min(fmi1_import_enum_variable_t* v);
186 /** \brief Get max value for the variable */
187 FMILIB_EXPORT int fmi1_import_get_enum_variable_max(fmi1_import_enum_variable_t* v);
189 /** \brief Get the variable alias kind*/
190 FMILIB_EXPORT fmi1_variable_alias_kind_enu_t fmi1_import_get_variable_alias_kind(fmi1_import_variable_t*);
192 /** \brief Get the original index in xml of the variable */
193 size_t fmi1_import_get_variable_original_order(fmi1_import_variable_t* v);