]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI1/fmi1_import_variable.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Import / include / FMI1 / fmi1_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 fmi1_import_variable.h
19 *  \brief Public interface to the FMI import C-library. Handling of model variables.
20 */
21
22 #ifndef FMI1_IMPORT_VARIABLE_H_
23 #define FMI1_IMPORT_VARIABLE_H_
24
25 #include <FMI/fmi_import_context.h>
26
27 #include "fmi1_import_type.h"
28 #include "fmi1_import_unit.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33                 /**
34         \addtogroup fmi1_import
35         @{
36         \addtogroup fmi1_import_variables Functions for handling variable definitions.
37         @}
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().
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 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
64 /**@} */\r
65
66 /**\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
71 */\r
72 FMILIB_EXPORT fmi1_import_variable_t* fmi1_import_get_variable_by_name(fmi1_import_t* fmu, const char* name);\r
73 \r
74 /**\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
80 */\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
82
83
84 /** \brief Get the variable name */
85 FMILIB_EXPORT const char* fmi1_import_get_variable_name(fmi1_import_variable_t*);
86
87 /** \brief Get variable description. 
88         @return Description string or empty string ("") if no description in the XML file was given.
89 */
90 FMILIB_EXPORT const char* fmi1_import_get_variable_description(fmi1_import_variable_t*);
91
92 /** \brief Get variable value reference */
93 FMILIB_EXPORT fmi1_value_reference_t fmi1_import_get_variable_vr(fmi1_import_variable_t*);
94
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.
97 */
98 FMILIB_EXPORT fmi1_import_variable_typedef_t* fmi1_import_get_variable_declared_type(fmi1_import_variable_t*);
99
100 /** \brief Get variable base type */
101 FMILIB_EXPORT fmi1_base_type_enu_t fmi1_import_get_variable_base_type(fmi1_import_variable_t*);
102
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*);
107
108 /** \brief Get variability attribute */
109 FMILIB_EXPORT fmi1_variability_enu_t fmi1_import_get_variability(fmi1_import_variable_t*);
110
111 /** \brief Get causality attribute */
112 FMILIB_EXPORT fmi1_causality_enu_t fmi1_import_get_causality(fmi1_import_variable_t*);
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 fmi1_import_real_variable_t* fmi1_import_get_variable_as_real(fmi1_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 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 
126         
127         @return Typed object or NULL if base type does not match
128 */
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 
131         
132         @return Typed object or NULL if base type does not match
133 */
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 
136         
137         @return Typed object or NULL if base type does not match
138 */
139 FMILIB_EXPORT fmi1_import_bool_variable_t* fmi1_import_get_variable_as_boolean(fmi1_import_variable_t*);
140
141 /** 
142         \brief Get the variable start attribute. 
143
144         @return The "start" attriburte as specified in the XML file or variable nominal value.
145 */
146 FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_start(fmi1_import_real_variable_t* v);
147
148 /** \brief Get maximum value for the variable
149
150         @return Either the value specified in the XML file or DBL_MAX as defined in <float.h>
151 */
152 FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_max(fmi1_import_real_variable_t* v);
153
154 /** \brief Get minimal value for the variable.
155
156         @return Either the value specified in the XML file or negated DBL_MAX as defined in <float.h>
157 */
158 FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_min(fmi1_import_real_variable_t* v);
159
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);
162
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);
165
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);
168
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);
171
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);
174
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);
181
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);
188
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*);
191
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);
194
195 /** @} */
196
197 #ifdef __cplusplus
198 }
199 #endif
200 #endif