2 Copyright (C) 2012 Modelon AB
\r
4 This program is free software: you can redistribute it and/or modify
\r
5 it under the terms of the BSD style license.
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
10 FMILIB_License.txt file for more details.
\r
12 You should have received a copy of the FMILIB_License.txt file
\r
13 along with this program. If not, contact Modelon AB <http://www.modelon.com>.
\r
16 /** \file fmi1_import.h
\r
17 * \brief Public interface to the FMI import C-library.
\r
20 #ifndef FMI1_IMPORT_H_
\r
21 #define FMI1_IMPORT_H_
\r
24 #include <fmilib_config.h>
\r
25 #include <JM/jm_callbacks.h>
\r
26 #include <FMI/fmi_import_util.h>
\r
27 #include <FMI/fmi_import_context.h>
\r
28 /* #include <FMI1/fmi1_xml_model_description.h> */
\r
30 #include <FMI1/fmi1_types.h>
31 #include <FMI1/fmi1_functions.h>
32 #include <FMI1/fmi1_enums.h>
\r
34 #include "fmi1_import_type.h"
\r
35 #include "fmi1_import_unit.h"
\r
36 #include "fmi1_import_variable.h"
\r
37 #include "fmi1_import_vendor_annotations.h"
\r
38 #include "fmi1_import_capabilities.h"
\r
39 #include "fmi1_import_variable_list.h"
\r
41 #include "fmi1_import_capi.h"
\r
42 #include "fmi1_import_convenience.h"
\r
43 #include "fmi1_import_cosim.h"
\r
50 * \addtogroup fmi1_import FMI 1.0 import interface
\r
51 * All the structures used in the interfaces are intended to
\r
52 * be treated as opaque objects by the client code.
\r
56 /** \addtogroup fmi1_import_init Constuction, destruction and error handling
\r
57 * \addtogroup fmi1_import_gen General information retrieval
\r
58 * \addtogroup fmi1_import_capi Interface to the standard FMI 1.0 "C" API
\r
59 * \brief Convenient functions for calling the FMI functions. This interface wrappes the "C" API.
\r
64 /** \addtogroup fmi1_import_init Constuction, destruction and error handling
\r
68 \brief Create ::fmi1_import_t structure and parse the XML file.
\r
70 @param context A context data strucutre is used to propagate the callbacks for memory handling and logging.
\r
71 @param dirPath A directory name (full path) of a directory where the FMU was unzipped.
\r
72 @return The new structure if parsing was successfull. 0-pointer is returned on error.
\r
74 FMILIB_EXPORT fmi1_import_t* fmi1_import_parse_xml( fmi_import_context_t* context, const char* dirPath);
\r
77 * \brief Retrieve the last error message.
\r
81 * Many functions in the library return pointers to struct. An error is indicated by returning NULL/0-pointer.
\r
82 * If error is returned than fmi1_import_get_last_error() functions can be used to retrieve the error message.
\r
83 * If logging callbacks were specified then the same information is reported via logger.
\r
84 * Memory for the error string is allocated and deallocated in the module.
\r
85 * Client code should not store the pointer to the string since it can become invalid.
\r
86 * @param fmu An FMU object as returned by fmi1_import_parse_xml().
\r
87 * @return NULL-terminated string with an error message.
\r
89 FMILIB_EXPORT const char* fmi1_import_get_last_error(fmi1_import_t* fmu);
\r
92 \brief Clear the error message.
\r
93 * @param fmu An FMU object as returned by fmi1_import_parse_xml().
\r
94 * @return 0 if further processing is possible. If it returns 1 then the
\r
95 * error was not recoverable. The \p fmu object should then be freed and recreated.
\r
97 FMILIB_EXPORT int fmi1_import_clear_last_error(fmi1_import_t* fmu);
\r
100 \brief Release the memory allocated
\r
101 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
103 FMILIB_EXPORT void fmi1_import_free(fmi1_import_t* fmu);
\r
105 \addtogroup fmi1_import_gen
\r
106 * \brief Functions for retrieving general model information. Memory for the strings is allocated and deallocated in the module.
\r
107 * All the functions take an FMU object as returned by fmi1_import_parse_xml() as a parameter.
\r
108 * The information is retrieved from the XML file.
\r
112 \brief Get model name.
\r
113 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
115 FMILIB_EXPORT const char* fmi1_import_get_model_name(fmi1_import_t* fmu);
\r
118 \brief Get model identifier.
\r
119 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
121 FMILIB_EXPORT const char* fmi1_import_get_model_identifier(fmi1_import_t* fmu);
\r
124 \brief Get FMU GUID.
\r
125 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
127 FMILIB_EXPORT const char* fmi1_import_get_GUID(fmi1_import_t* fmu);
\r
130 \brief Get FMU description.
\r
131 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
133 FMILIB_EXPORT const char* fmi1_import_get_description(fmi1_import_t* fmu);
\r
136 \brief Get FMU author.
\r
137 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
139 FMILIB_EXPORT const char* fmi1_import_get_author(fmi1_import_t* fmu);
\r
141 /** \brief Get FMU version.
\r
142 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
144 FMILIB_EXPORT const char* fmi1_import_get_model_version(fmi1_import_t* fmu);
\r
146 /** \brief Get FMI standard version (always 1.0).
\r
147 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
149 FMILIB_EXPORT const char* fmi1_import_get_model_standard_version(fmi1_import_t* fmu);
\r
151 /** \brief Get FMU generation tool.
\r
152 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
154 FMILIB_EXPORT const char* fmi1_import_get_generation_tool(fmi1_import_t* fmu);
\r
156 /** \brief Get FMU generation date and time.
\r
157 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
159 FMILIB_EXPORT const char* fmi1_import_get_generation_date_and_time(fmi1_import_t* fmu);
\r
161 /** \brief Get variable naming convention used.
\r
162 @param fmu An fmu object as returned by fmi1_import_parse_xml().
\r
164 FMILIB_EXPORT fmi1_variable_naming_convension_enu_t fmi1_import_get_naming_convention(fmi1_import_t* fmu);
\r
166 /** \brief Get the number of contnuous states. */
\r
167 FMILIB_EXPORT unsigned int fmi1_import_get_number_of_continuous_states(fmi1_import_t* fmu);
\r
169 /** \brief Get the number of event indicators. */
\r
170 FMILIB_EXPORT unsigned int fmi1_import_get_number_of_event_indicators(fmi1_import_t* fmu);
\r
172 /** \brief Get the start time for default experiment as specified in the XML file. */
\r
173 FMILIB_EXPORT double fmi1_import_get_default_experiment_start(fmi1_import_t* fmu);
\r
175 /** \brief Get the stop time for default experiment as specified in the XML file. */
\r
176 FMILIB_EXPORT double fmi1_import_get_default_experiment_stop(fmi1_import_t* fmu);
\r
178 /** \brief Get the tolerance default experiment as specified in the XML file. */
\r
179 FMILIB_EXPORT double fmi1_import_get_default_experiment_tolerance(fmi1_import_t* fmu);
\r
181 /** \brief Get the type of the FMU (model exchange or co-simulation) */
\r
182 FMILIB_EXPORT fmi1_fmu_kind_enu_t fmi1_import_get_fmu_kind(fmi1_import_t* fmu);
\r
184 /** \brief Get the structure with capability flags.
\r
185 @return A pointer to the fmi1_import_capabilities_t allocated within the library.
\r
186 Note that for model exchange FMUs the values of all the flags are always default.
\r
188 FMILIB_EXPORT fmi1_import_capabilities_t* fmi1_import_get_capabilities(fmi1_import_t* fmu);
\r
190 /** \brief Get the list of all the type definitions in the model*/
191 FMILIB_EXPORT fmi1_import_type_definitions_t* fmi1_import_get_type_definitions(fmi1_import_t* );
193 /** \brief Get a list of all the unit definitions in the model. */
194 FMILIB_EXPORT fmi1_import_unit_definitions_t* fmi1_import_get_unit_definitions(fmi1_import_t* fmu);
197 \brief Get the direct dependency information
199 @return A variable list is returned for variables with causality Output. Null pointer for others. */
200 FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_get_direct_dependency(fmi1_import_t* fmu, fmi1_import_variable_t*);
202 /** \brief Get the variable with the same value reference that is not an alias*/
203 FMILIB_EXPORT fmi1_import_variable_t* fmi1_import_get_variable_alias_base(fmi1_import_t* fmu,fmi1_import_variable_t*);
206 Get the list of all the variables aliased to the given one (including the base one).
208 Note that the list is ordered: base variable, aliases, negated aliases.
210 FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_get_variable_aliases(fmi1_import_t* fmu,fmi1_import_variable_t*);
212 /** \brief Get the list of all the variables in the model.
\r
213 * @param fmu An FMU object as returned by fmi1_import_parse_xml().
\r
214 * @return a variable list with all the variables in the model.
\r
216 * Note that variable lists are allocated dynamically and must be freed when not needed any longer.
\r
218 FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_get_variable_list(fmi1_import_t* fmu);
\r
220 /** \brief Get the list of all the variables in the model in alphabetical order.
\r
221 * @param fmu An FMU object as returned by fmi1_import_parse_xml().
\r
222 * @return a variable list with all the variables in the model sorted in alphabetical order.
\r
224 * Note that variable lists are allocated dynamically and must be freed when not needed any longer.
\r
226 FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_get_variable_list_alphabetical_order(fmi1_import_t* fmu);
\r
228 /** \brief Create a variable list with a single variable.
\r
230 \param fmu An FMU object that this variable list will reference.
\r
231 \param v A variable.
\r
233 FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_create_var_list(fmi1_import_t* fmu,fmi1_import_variable_t* v);
\r