]> gerrit.simantics Code Review - simantics/fmil.git/blobdiff - org.simantics.fmil.core/native/FMILibrary/src/XML/include/FMI2/fmi2_xml_model_description.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / XML / include / FMI2 / fmi2_xml_model_description.h
diff --git a/org.simantics.fmil.core/native/FMILibrary/src/XML/include/FMI2/fmi2_xml_model_description.h b/org.simantics.fmil.core/native/FMILibrary/src/XML/include/FMI2/fmi2_xml_model_description.h
new file mode 100644 (file)
index 0000000..2fd47d2
--- /dev/null
@@ -0,0 +1,267 @@
+/*\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
+\r
+\r
+/** \file fmi2_xml_model_description.h\r
+*  \brief Public interface to the FMI XML C-library.\r
+*/\r
+\r
+#ifndef FMI2_XML_MODELDESCRIPTION_H_\r
+#define FMI2_XML_MODELDESCRIPTION_H_\r
+\r
+#include <stddef.h>\r
+#include <JM/jm_callbacks.h>\r
+#include <JM/jm_named_ptr.h>\r
+#include <FMI/fmi_xml_context.h>\r
+#include <FMI2/fmi2_types.h>\r
+#include <FMI2/fmi2_enums.h>\r
+#include <FMI2/fmi2_xml_callbacks.h>\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+/**\r
+\addtogroup fmi_xml\r
+  @{\r
+       \addtogroup fmi2_xml\r
+  @}\r
+*/\r
+/**\r
+  \addtogroup fmi2_xml FMI 2.0 XML parsing library.\r
+   \brief The FMI 2.0 XML parsing library supports processing of model description XML files.\r
+   @{\r
+  \name Declarations of structs used in the interface.\r
+  \brief All the structures used in the interfaces are intended to\r
+   be treated as opaque objects by the client code.\r
+  @{  */\r
+\r
+/** \brief Model structure object */\r
+typedef struct fmi2_xml_model_structure_t fmi2_xml_model_structure_t;\r
+\r
+/**\name  Type definitions supporting structures\r
+@{ */\r
+typedef struct fmi2_xml_real_typedef_t fmi2_xml_real_typedef_t;\r
+typedef struct fmi2_xml_integer_typedef_t fmi2_xml_integer_typedef_t;\r
+typedef struct fmi2_xml_enumeration_typedef_t fmi2_xml_enumeration_typedef_t;\r
+typedef struct fmi2_xml_variable_typedef_t fmi2_xml_variable_typedef_t;\r
+\r
+typedef struct fmi2_xml_type_definitions_t fmi2_xml_type_definitions_t;\r
+/** @} */\r
+\r
+/**\name Scalar Variable types */\r
+/** @{ */\r
+/**General variable type is convenien to unify all the variable list operations */\r
+typedef struct fmi2_xml_variable_t fmi2_xml_variable_t;\r
+\r
+/**Typed variables are needed to support specific attributes */\r
+typedef struct fmi2_xml_real_variable_t fmi2_xml_real_variable_t;\r
+typedef struct fmi2_xml_integer_variable_t fmi2_xml_integer_variable_t;\r
+typedef struct fmi2_xml_string_variable_t fmi2_xml_string_variable_t;\r
+typedef struct fmi2_xml_enum_variable_t fmi2_xml_enum_variable_t;\r
+typedef struct fmi2_xml_bool_variable_t fmi2_xml_bool_variable_t;\r
+/** @} */\r
+\r
+/**\name Structures encapsulating unit information */\r
+/**@{ */\r
+typedef struct fmi2_xml_unit_t fmi2_xml_unit_t;\r
+typedef struct fmi2_xml_display_unit_t fmi2_xml_display_unit_t;\r
+typedef struct fmi2_xml_unit_definitions_t fmi2_xml_unit_definitions_t;\r
+/**@} */\r
+\r
+/**\name FMU capabilities flags */\r
+/**@{ */\r
+typedef struct fmi2_xml_capabilities_t fmi2_xml_capabilities_t;\r
+/**@} */\r
+/**    \addtogroup fmi2_xml_gen General information retrieval*/\r
+/**    \addtogroup fmi2_xml_init  Constuction, destruction and error checking */\r
+\r
+/** @} */\r
+\r
+/**    \addtogroup fmi2_xml_init\r
+@{ */\r
+/**\r
+   \brief Allocate the ModelDescription structure and initialize as empty model.\r
+   @return NULL pointer is returned if memory allocation fails.\r
+   @param callbacks - Standard FMI callbacks may be sent into the module. The argument is optional (pointer can be zero).\r
+*/\r
+fmi2_xml_model_description_t* fmi2_xml_allocate_model_description( jm_callbacks* callbacks);\r
+\r
+/**\r
+    \brief If this configuration option is set, the model description will be\r
+    checked to follow the variable naming conventions. Variables not following\r
+    the convention will be logged.\r
+*/\r
+#define FMI2_XML_NAME_CHECK 1\r
+\r
+/**\r
+   \brief Parse XML file\r
+   Repeaded calls invalidate the data structures created with the previous call to fmiParseXML,\r
+   i.e., fmiClearModelDescrition is automatically called before reading in the new file.\r
+\r
+    @param md A model description object as returned by fmi2_xml_allocate_model_description.\r
+    @param fileName A name (full path) of the XML file name with model definition.\r
+       @param xml_callbacks Callbacks to use for processing annotations (may be NULL).\r
+    @param configuration Specifies how to parse the model description, 0 is\r
+           default. Other possible configuration is FMI_XML_NAME_CHECK.\r
+   @return 0 if parsing was successfull. Non-zero value indicates an error.\r
+*/\r
+int fmi2_xml_parse_model_description( fmi2_xml_model_description_t* md,\r
+                                      const char* fileName,\r
+                                      fmi2_xml_callbacks_t* xml_callbacks,\r
+                                      int configuration);\r
+\r
+/**\r
+   Clears the data associated with the model description. This is useful if the same object\r
+   instance is used repeatedly to work with different XML files.\r
+    @param md A model description object as returned by fmi2_xml_allocate_model_description.\r
+*/\r
+void fmi2_xml_clear_model_description( fmi2_xml_model_description_t* md);\r
+\r
+/*\r
+*    @param md A model description object as returned by fmi2_xml_allocate_model_description.\r
+*    @return 1 if model description is empty and 0 if there is some content associated.\r
+*/\r
+int fmi2_xml_is_model_description_empty(fmi2_xml_model_description_t* md);\r
+\r
+/**Error handling:\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 fmiGetLastError() 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 md A model description object as returned by fmi2_xml_allocate_model_description.\r
+*    @return NULL-terminated string with an error message.\r
+*/\r
+const char* fmi2_xml_get_last_error(fmi2_xml_model_description_t* md);\r
+\r
+/**\r
+fmiClearLastError clears the error message .\r
+*/\r
+void fmi2_xml_clear_last_error(fmi2_xml_model_description_t* md);\r
+\r
+/**Release the memory allocated\r
+@param md A model description object as returned by fmi2_xml_allocate_model_description.\r
+*/\r
+void fmi2_xml_free_model_description(fmi2_xml_model_description_t* md);\r
+\r
+/** @} */\r
+/** \addtogroup fmi2_xml_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 a model description object as returned by fmi2_xml_allocate_model_description() as a parameter. \r
+ *   The information is retrieved from the XML file.\r
+ * @{\r
+*/\r
+const char* fmi2_xml_get_model_name(fmi2_xml_model_description_t* md);\r
+\r
+const char* fmi2_xml_get_model_identifier_ME(fmi2_xml_model_description_t* md);\r
+\r
+const char* fmi2_xml_get_model_identifier_CS(fmi2_xml_model_description_t* md);\r
+\r
+const char* fmi2_xml_get_GUID(fmi2_xml_model_description_t* md);\r
+\r
+const char* fmi2_xml_get_description(fmi2_xml_model_description_t* md);\r
+\r
+const char* fmi2_xml_get_author(fmi2_xml_model_description_t* md);\r
+const char* fmi2_xml_get_license(fmi2_xml_model_description_t* md);\r
+\r
+const char* fmi2_xml_get_copyright(fmi2_xml_model_description_t* md);\r
+\r
+const char* fmi2_xml_get_model_version(fmi2_xml_model_description_t* md);\r
+const char* fmi2_xml_get_model_standard_version(fmi2_xml_model_description_t* md);\r
+const char* fmi2_xml_get_generation_tool(fmi2_xml_model_description_t* md);\r
+const char* fmi2_xml_get_generation_date_and_time(fmi2_xml_model_description_t* md);\r
+\r
+fmi2_variable_naming_convension_enu_t fmi2_xml_get_naming_convention(fmi2_xml_model_description_t* md);\r
+\r
+size_t fmi2_xml_get_number_of_continuous_states(fmi2_xml_model_description_t* md);\r
+\r
+size_t fmi2_xml_get_number_of_event_indicators(fmi2_xml_model_description_t* md);\r
+\r
+double fmi2_xml_get_default_experiment_start(fmi2_xml_model_description_t* md);\r
+\r
+double fmi2_xml_get_default_experiment_stop(fmi2_xml_model_description_t* md);\r
+\r
+double fmi2_xml_get_default_experiment_tolerance(fmi2_xml_model_description_t* md);\r
+\r
+double fmi2_xml_get_default_experiment_step(fmi2_xml_model_description_t* md);\r
+\r
+fmi2_fmu_kind_enu_t fmi2_xml_get_fmu_kind(fmi2_xml_model_description_t* md);\r
+\r
+/** \brief Get a pointer to the internal capabilities array */\r
+unsigned int* fmi2_xml_get_capabilities(fmi2_xml_model_description_t* md);\r
+\r
+/** \brief Get a capability flag by ID */\r
+unsigned int fmi2_xml_get_capability(fmi2_xml_model_description_t* , fmi2_capabilities_enu_t id);\r
+\r
+jm_vector(jm_voidp)* fmi2_xml_get_variables_original_order(fmi2_xml_model_description_t* md);\r
+\r
+jm_vector(jm_named_ptr)* fmi2_xml_get_variables_alphabetical_order(fmi2_xml_model_description_t* md);\r
+\r
+jm_vector(jm_voidp)* fmi2_xml_get_variables_vr_order(fmi2_xml_model_description_t* md);\r
+\r
+/**\r
+       \brief Get variable by variable name.\r
+       \param md - the model description\r
+       \param name - variable name\r
+       \return variable pointer.\r
+*/\r
+fmi2_xml_variable_t* fmi2_xml_get_variable_by_name(fmi2_xml_model_description_t* md, const char* name);\r
+\r
+/**\r
+       \brief Get variable by value reference.\r
+       \param md - the model description\r
+       \param baseType - basic data type\r
+       \param vr - value reference\r
+       \return variable pointer.\r
+*/\r
+fmi2_xml_variable_t* fmi2_xml_get_variable_by_vr(fmi2_xml_model_description_t* md, fmi2_base_type_enu_t baseType, fmi2_value_reference_t vr);\r
+\r
+/** \brief Get the number of vendors that had annotations in the XML*/\r
+size_t fmi2_xml_get_vendors_num(fmi2_xml_model_description_t* md);\r
+\r
+/** \brief Get the name of the vendor with that had annotations in the XML by index */\r
+const char* fmi2_xml_get_vendor_name(fmi2_xml_model_description_t* md, size_t  index);\r
+\r
+/** \brief Get the log categories defined in the XML */\r
+jm_vector(jm_string)* fmi2_xml_get_log_categories(fmi2_xml_model_description_t* md);\r
+\r
+/** \brief Get descriptions for the log categories defined in the XML */\r
+jm_vector(jm_string)* fmi2_xml_get_log_category_descriptions(fmi2_xml_model_description_t* md);\r
+\r
+/** \brief Get the source files for ME defined in the XML */\r
+jm_vector(jm_string)* fmi2_xml_get_source_files_me(fmi2_xml_model_description_t* md);\r
+\r
+/** \brief Get the source files for CS defined in the XML */\r
+jm_vector(jm_string)* fmi2_xml_get_source_files_cs(fmi2_xml_model_description_t* md);\r
+\r
+/** \brief Get the model structure pointer. NULL pointer means there was no information present in the XML */\r
+fmi2_xml_model_structure_t* fmi2_xml_get_model_structure(fmi2_xml_model_description_t* md);\r
+\r
+void fmi2_check_variable_naming_conventions(fmi2_xml_model_description_t *md);\r
+\r
+/** @} */\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#include "fmi2_xml_type.h"\r
+#include "fmi2_xml_unit.h"\r
+#include "fmi2_xml_variable.h"\r
+#include "fmi2_xml_capabilities.h"\r
+#include "fmi2_xml_cosim.h"\r
+#include "fmi2_xml_model_structure.h"\r
+\r
+#endif\r