]> gerrit.simantics Code Review - simantics/fmil.git/blobdiff - org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Import / include / FMI2 / fmi2_import.h
diff --git a/org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import.h b/org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import.h
new file mode 100644 (file)
index 0000000..1794a46
--- /dev/null
@@ -0,0 +1,357 @@
+/*\r
+    Copyright (C) 2012 Modelon AB\r
+\r
+    This program is free software: you can redistribute it and/or modify\r
+    it under the terms of the BSD style license.\r
+\r
+    This program is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    FMILIB_License.txt file for more details.\r
+\r
+    You should have received a copy of the FMILIB_License.txt file\r
+    along with this program. If not, contact Modelon AB <http://www.modelon.com>.\r
+*/\r
+\r
+/** \file fmi2_import.h\r
+*  \brief Public interface to the FMI import C-library.\r
+*/\r
+\r
+#ifndef FMI2_IMPORT_H_\r
+#define FMI2_IMPORT_H_\r
+\r
+#include <stddef.h>\r
+#include <fmilib_config.h>\r
+#include <JM/jm_callbacks.h>\r
+#include <FMI/fmi_import_util.h>\r
+#include <FMI/fmi_import_context.h>\r
+/* #include <FMI2/fmi2_xml_model_description.h> */\r
+\r
+#include <FMI2/fmi2_types.h>\r
+#include <FMI2/fmi2_functions.h>\r
+#include <FMI2/fmi2_enums.h>\r
+\r
+#include "fmi2_import_type.h"\r
+#include "fmi2_import_unit.h"\r
+#include "fmi2_import_variable.h"\r
+#include "fmi2_import_variable_list.h"\r
+\r
+#include "fmi2_import_capi.h"\r
+#include "fmi2_import_convenience.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+ * \addtogroup  fmi2_import FMI 2.0 import interface\r
+ *  All the structures used in the interfaces are intended to\r
+ *  be treated as opaque objects by the client code.\r
+ @{ \r
+ */\r
+\r
+/**    \addtogroup fmi2_import_init Constuction, destruction and error handling\r
+ *     \addtogroup fmi2_import_gen General information retrieval\r
+ *     \addtogroup fmi2_import_capi Interface to the standard FMI 2.0 "C" API\r
+ *  \brief Convenient functions for calling the FMI functions. This interface wrappes the "C" API. \r
+ */\r
+ /** @} */\r
+ /** @} */\r
+\r
+/** \addtogroup fmi2_import_init Constuction, destruction and error handling\r
+@{\r
+*/\r
+\r
+/**\r
+* \brief Retrieve the last error message.\r
+*\r
+* Error handling:\r
+*\r
+*  Many functions in the library return pointers to struct. An error is indicated by returning NULL/0-pointer.\r
+*  If error is returned than fmi2_import_get_last_error() functions can be used to retrieve the error message.\r
+*  If logging callbacks were specified then the same information is reported via logger.\r
+*  Memory for the error string is allocated and deallocated in the module.\r
+*  Client code should not store the pointer to the string since it can become invalid.\r
+*    @param fmu An FMU object as returned by fmi2_import_parse_xml().\r
+*    @return NULL-terminated string with an error message.\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_last_error(fmi2_import_t* fmu);\r
+\r
+/**\r
+\brief Clear the error message.\r
+* @param fmu An FMU object as returned by fmi2_import_parse_xml().\r
+* @return 0 if further processing is possible. If it returns 1 then the \r
+*      error was not recoverable. The \p fmu object should then be freed and recreated.\r
+*/\r
+FMILIB_EXPORT int fmi2_import_clear_last_error(fmi2_import_t* fmu);\r
+\r
+/**\r
+\brief Release the memory allocated\r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT void fmi2_import_free(fmi2_import_t* fmu);\r
+/** @}\r
+\addtogroup fmi2_import_gen\r
+ * \brief Functions for retrieving general model information. Memory for the strings is allocated and deallocated in the module.\r
+ *   All the functions take an FMU object as returned by fmi2_import_parse_xml() as a parameter. \r
+ *   The information is retrieved from the XML file.\r
+ * @{\r
+*/\r
+/** \r
+\brief Get model name. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_model_name(fmi2_import_t* fmu);\r
+\r
+/** \brief Retrieve capability flags by ID. */\r
+FMILIB_EXPORT unsigned int fmi2_import_get_capability(fmi2_import_t* , fmi2_capabilities_enu_t id);\r
+\r
+/** \r
+\brief Get model identifier for ModelExchange. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_model_identifier_ME(fmi2_import_t* fmu);\r
+\r
+/** \r
+\brief Get model identifier for CoSimulation. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_model_identifier_CS(fmi2_import_t* fmu);\r
+\r
+/** \r
+\brief Get FMU GUID. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_GUID(fmi2_import_t* fmu);\r
+\r
+/** \r
+\brief Get FMU description.\r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_description(fmi2_import_t* fmu);\r
+\r
+/** \r
+\brief Get FMU author. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_author(fmi2_import_t* fmu);\r
+\r
+/** \r
+\brief Get FMU copyright information. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_copyright(fmi2_import_t* fmu);\r
+\r
+/** \r
+\brief Get FMU license information. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_license(fmi2_import_t* fmu);\r
+\r
+/** \brief Get FMU version.\r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_model_version(fmi2_import_t* fmu);\r
+\r
+/** \brief Get FMI standard version (always 2.0). \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_model_standard_version(fmi2_import_t* fmu);\r
+\r
+/** \brief Get FMU generation tool. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_generation_tool(fmi2_import_t* fmu);\r
+\r
+/** \brief Get FMU generation date and time. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT const char* fmi2_import_get_generation_date_and_time(fmi2_import_t* fmu);\r
+\r
+/** \brief Get variable naming convention used. \r
+@param fmu An fmu object as returned by fmi2_import_parse_xml().\r
+*/\r
+FMILIB_EXPORT fmi2_variable_naming_convension_enu_t fmi2_import_get_naming_convention(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the number of continuous states. \r
+*/\r
+FMILIB_EXPORT size_t fmi2_import_get_number_of_continuous_states(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the number of event indicators. */\r
+FMILIB_EXPORT size_t fmi2_import_get_number_of_event_indicators(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the start time for default experiment as specified in the XML file. */\r
+FMILIB_EXPORT double fmi2_import_get_default_experiment_start(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the stop time for default experiment as specified in the XML file. */\r
+FMILIB_EXPORT double fmi2_import_get_default_experiment_stop(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the tolerance for default experiment as specified in the XML file. */\r
+FMILIB_EXPORT double fmi2_import_get_default_experiment_tolerance(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the step size for default experiment as specified in the XML file. */\r
+FMILIB_EXPORT double fmi2_import_get_default_experiment_step(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the type of the FMU (model exchange or co-simulation) */\r
+FMILIB_EXPORT fmi2_fmu_kind_enu_t fmi2_import_get_fmu_kind(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the list of all the type definitions in the model*/\r
+FMILIB_EXPORT fmi2_import_type_definitions_t* fmi2_import_get_type_definitions(fmi2_import_t* );\r
+\r
+/** \brief Get a list of all the unit definitions in the model. */\r
+FMILIB_EXPORT fmi2_import_unit_definitions_t* fmi2_import_get_unit_definitions(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the variable with the same value reference that is not an alias*/\r
+FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_variable_alias_base(fmi2_import_t* fmu,fmi2_import_variable_t*);\r
+\r
+/**\r
+    Get the list of all the variables aliased to the given one (including the base one).\r
+\r
+    Note that the list is ordered: base variable, aliases, negated aliases.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_get_variable_aliases(fmi2_import_t* fmu,fmi2_import_variable_t*);\r
+\r
+/** \brief Get the list of all the variables in the model.\r
+* @param fmu An FMU object as returned by fmi2_import_parse_xml().\r
+* @param sortOrder Specifies the order of the variables in the list: \r
+               0 - original order as found in the XML file; 1 - sorted alfabetically by variable name; 2 sorted by types/value references.\r
+* @return a variable list with all the variables in the model.\r
+*\r
+* Note that variable lists are allocated dynamically and must be freed when not needed any longer.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_get_variable_list(fmi2_import_t* fmu, int sortOrder);\r
+\r
+/** \brief Create a variable list with a single variable.\r
+  \r
+\param fmu An FMU object that this variable list will reference.\r
+\param v A variable.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_create_var_list(fmi2_import_t* fmu,fmi2_import_variable_t* v);\r
+\r
+/** \brief Get the number of vendors that had annotations in the XML*/\r
+FMILIB_EXPORT size_t fmi2_import_get_vendors_num(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the name of the vendor with that had annotations in the XML by index */\r
+FMILIB_EXPORT const char* fmi2_import_get_vendor_name(fmi2_import_t* fmu, size_t index);\r
+\r
+/** \brief Get the number of log categories defined in the XML */\r
+FMILIB_EXPORT size_t fmi2_import_get_log_categories_num(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the log category by index */\r
+FMILIB_EXPORT const char* fmi2_import_get_log_category(fmi2_import_t* fmu, size_t index);\r
+\r
+/** \brief Get the log category description by index */\r
+FMILIB_EXPORT const char* fmi2_import_get_log_category_description(fmi2_import_t* fmu, size_t index);\r
+\r
+/** \brief Get the number of source files for ME defined in the XML */\r
+FMILIB_EXPORT size_t fmi2_import_get_source_files_me_num(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the ME source file by index */\r
+FMILIB_EXPORT const char* fmi2_import_get_source_file_me(fmi2_import_t* fmu, size_t index);\r
+\r
+/** \brief Get the number of source files for CS defined in the XML */\r
+FMILIB_EXPORT size_t fmi2_import_get_source_files_cs_num(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the CS source file by index */\r
+FMILIB_EXPORT const char* fmi2_import_get_source_file_cs(fmi2_import_t* fmu, size_t index);\r
+\r
+/**\r
+       \brief Get variable by variable name.\r
+       \param fmu - An fmu object as returned by fmi2_import_parse_xml().\r
+       \param name - variable name\r
+       \return variable pointer.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_variable_by_name(fmi2_import_t* fmu, const char* name);\r
+\r
+/**\r
+       \brief Get variable by value reference.\r
+       \param fmu - An fmu object as returned by fmi2_import_parse_xml().\r
+       \param baseType - basic data type\r
+       \param vr - value reference\r
+       \return variable pointer.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_variable_by_vr(fmi2_import_t* fmu, fmi2_base_type_enu_t baseType, fmi2_value_reference_t vr);\r
+\r
+/** \brief Get the list of all the output variables in the model.\r
+* @param fmu An FMU object as returned by fmi2_import_parse_xml().\r
+* @return a variable list with all the output variables in the model.\r
+*\r
+* Note that variable lists are allocated dynamically and must be freed when not needed any longer.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_get_outputs_list(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the list of all the derivative variables in the model.\r
+* @param fmu An FMU object as returned by fmi2_import_parse_xml().\r
+* @return a variable list with all the continuous state derivatives in the model.\r
+*\r
+* Note that variable lists are allocated dynamically and must be freed when not needed any longer.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_get_derivatives_list(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the list of all the discrete state variables in the model.\r
+* @param fmu An FMU object as returned by fmi2_import_parse_xml().\r
+* @return a variable list with all the discrete state variables in the model.\r
+*\r
+* Note that variable lists are allocated dynamically and must be freed when not needed any longer.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_get_discrete_states_list(fmi2_import_t* fmu);\r
+\r
+/** \brief Get the list of all the initial unknown variables in the model.\r
+* @param fmu An FMU object as returned by fmi2_import_parse_xml().\r
+* @return a variable list with all the initial unknowns in the model.\r
+*\r
+* Note that variable lists are allocated dynamically and must be freed when not needed any longer.\r
+*/\r
+FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_get_initial_unknowns_list(fmi2_import_t* fmu);\r
+\r
+/** \brief Get dependency information in row-compressed format. \r
+ * @param fmu An FMU object as returned by fmi2_import_parse_xml(). \r
+ * @param startIndex - outputs a pointer to an array of start indices (size of array is number of outputs + 1).\r
+ *                     First element is zero, last is equal to the number of elements in the dependency and factor arrays. \r
+ *                     NULL pointer is returned if no dependency information was provided in the XML. \r
+ * @param dependency - outputs a pointer to the dependency index data. Indices are 1-based. Index equals to zero  \r
+ *                     means "depends on all" (no information in the XML). \r
+ * @param factorKind - outputs a pointer to the factor kind data. The values can be converted to ::fmi2_dependency_factor_kind_enu_t \r
+ */ \r
+FMILIB_EXPORT void fmi2_import_get_outputs_dependencies(fmi2_import_t* fmu, size_t** startIndex, size_t** dependency, char** factorKind);\r
\r
+/** \brief Get dependency information in row-compressed format. \r
+ * @param fmu An FMU object as returned by fmi2_import_parse_xml(). \r
+ * @param startIndex - outputs a pointer to an array of start indices (size of array is number of derivatives + 1).\r
+ *                     First element is zero, last is equal to the number of elements in the dependency and factor arrays. \r
+ *                     NULL pointer is returned if no dependency information was provided in the XML. \r
+ * @param dependency - outputs a pointer to the dependency index data. Indices are 1-based. Index equals to zero  \r
+ *                     means "depends on all" (no information in the XML). \r
+ * @param factorKind - outputs a pointer to the factor kind data. The values can be converted to ::fmi2_dependency_factor_kind_enu_t \r
+ */ \r
+FMILIB_EXPORT void fmi2_import_get_derivatives_dependencies(fmi2_import_t* fmu, size_t** startIndex, size_t** dependency, char** factorKind);\r
+\r
+/** \brief Get dependency information in row-compressed format. \r
+ * @param fmu An FMU object as returned by fmi2_import_parse_xml(). \r
+ * @param startIndex - outputs a pointer to an array of start indices (size of array is number of discrete states + 1).\r
+ *                     First element is zero, last is equal to the number of elements in the dependency and factor arrays. \r
+ *                     NULL pointer is returned if no dependency information was provided in the XML. \r
+ * @param dependency - outputs a pointer to the dependency index data. Indices are 1-based. Index equals to zero  \r
+ *                     means "depends on all" (no information in the XML). \r
+ * @param factorKind - outputs a pointer to the factor kind data. The values can be converted to ::fmi2_dependency_factor_kind_enu_t \r
+ */ \r
+FMILIB_EXPORT void fmi2_import_get_discrete_states_dependencies(fmi2_import_t* fmu, size_t** startIndex, size_t** dependency, char** factorKind);\r
\r
+/** \brief Get dependency information in row-compressed format. \r
+ * @param fmu An FMU object as returned by fmi2_import_parse_xml(). \r
+ * @param startIndex - outputs a pointer to an array of start indices (size of array is number of initial unknowns + 1).\r
+ *                     First element is zero, last is equal to the number of elements in the dependency and factor arrays. \r
+ *                     NULL pointer is returned if no dependency information was provided in the XML. \r
+ * @param dependency - outputs a pointer to the dependency index data. Indices are 1-based. Index equals to zero  \r
+ *                     means "depends on all" (no information in the XML). \r
+ * @param factorKind - outputs a pointer to the factor kind data. The values can be converted to ::fmi2_dependency_factor_kind_enu_t \r
+ */ \r
+FMILIB_EXPORT void fmi2_import_get_initial_unknowns_dependencies(fmi2_import_t* fmu, size_t** startIndex, size_t** dependency, char** factorKind);\r
\r
+/**@} */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r