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
17 /** \file fmi_import_context.h
\r
18 * \brief Import context is the entry point to the library. It is used to initialize, unzip, get FMI version and start parsing.
\r
21 #ifndef FMI_IMPORT_CONTEXT_H_
\r
22 #define FMI_IMPORT_CONTEXT_H_
\r
25 #include <fmilib_config.h>
\r
26 #include <JM/jm_callbacks.h>
\r
27 #include <FMI2/fmi2_xml_callbacks.h>
\r
28 #include <FMI/fmi_version.h>
\r
29 #include <FMI1/fmi1_types.h>
\r
30 #include <FMI1/fmi1_enums.h>
\r
31 #include <FMI2/fmi2_types.h>
\r
32 #include <FMI2/fmi2_enums.h>
\r
40 \addtogroup fmi_import FMI import library
\r
42 \addtogroup fmi_import_context Library initialization
\r
43 Interaction with an FMU by means of the FMI Library starts with allocation of
\r
44 an ::fmi_import_context_t structure. This is done with a call to fmi_import_allocate_context().
\r
45 The next step is detection of FMI standard used in the specific FMU. This is achieved by
\r
46 calling fmi_import_get_fmi_version() function. When the standard is known a standard
\r
47 specific function for processing model description XML should be called to create an
\r
48 opaque FMU structure. This is done by calling either fmi1_import_parse_xml() or fmi2_import_parse_xml().
\r
49 With the FMU structure available one can proceed by loading the FMU binary
\r
50 (fmi1_import_create_dllfmu() or fmi2_import_create_dllfmu()). After that
\r
51 the code is able to interact with the FMU by means of the methonds presented
\r
52 in \ref fmi1_import_capi and \ref fmi2_import_capi.
\r
54 \addtogroup fmi1_import
\r
55 \addtogroup fmi2_import
\r
56 \addtogroup fmi_import_utils
\r
58 \addtogroup fmi_import_context
\r
62 /** \brief FMI version independent library context.
\r
63 Opaque struct returned from fmi_import_allocate_context()
\r
65 typedef struct fmi_xml_context_t fmi_import_context_t ;
\r
67 /** \brief Create fmi_import_context_t structure.
\r
68 @param callbacks - a pointer to the library callbacks for memory management and logging. May be NULL if defaults are utilized.
\r
69 @return A new structure if memory allocation was successful.
\r
71 FMILIB_EXPORT fmi_import_context_t* fmi_import_allocate_context( jm_callbacks* callbacks);
\r
74 \brief Free memory allocated for the library context.
\r
75 @param c - library context allocated by fmi_import_allocate_context()
\r
77 FMILIB_EXPORT void fmi_import_free_context( fmi_import_context_t* c);
\r
80 \brief If this configuration option is set, the model description will be
\r
81 checked to follow the variable naming conventions. Variables not following
\r
82 the convention will be logged.
\r
84 #define FMI_IMPORT_NAME_CHECK 1
\r
87 \brief Sets advanced configuration, if zero is passed default configuration
\r
88 is set. Currently only one non default configuration is available:
\r
89 FMI_IMPORT_XML_NAME_CHECK.
\r
90 @param conf - specifies the configuration to use
\r
92 FMILIB_EXPORT void fmi_import_set_configuration( fmi_import_context_t* c, int conf);
\r
95 \brief Unzip an FMU specified by the fileName into directory dirName and parse XML to get FMI standard version.
\r
96 @param c - library context.
\r
97 @param fileName - an FMU file name.
\r
98 @param dirName - a directory name where the FMU should be unpacked
\r
100 FMILIB_EXPORT fmi_version_enu_t fmi_import_get_fmi_version( fmi_import_context_t* c, const char* fileName, const char* dirName);
\r
103 \brief FMU version 1.0 object
\r
105 typedef struct fmi1_import_t fmi1_import_t;
\r
108 \brief FMU version 2.0 object
\r
110 typedef struct fmi2_import_t fmi2_import_t;
\r
113 \brief Parse FMI 1.0 XML file found in the directory dirName.
\r
114 \param c - library context.
\r
115 \param dirName - a directory where the FMU was unpacked and XML file is present.
\r
116 \return fmi1_import_t:: opaque object pointer
\r
118 FMILIB_EXPORT fmi1_import_t* fmi1_import_parse_xml( fmi_import_context_t* c, const char* dirName);
\r
121 \brief Create ::fmi2_import_t structure and parse the FMI 2.0 XML file found in the directory dirName.
\r
122 \param context - library context.
\r
123 \param dirPath - a directory where the FMU was unpacked and XML file is present.
\r
124 \param xml_callbacks Callbacks to use for processing of annotations (may be NULL).
\r
125 \return fmi2_import_t:: opaque object pointer
\r
127 FMILIB_EXPORT fmi2_import_t* fmi2_import_parse_xml( fmi_import_context_t* context, const char* dirPath, fmi2_xml_callbacks_t* xml_callbacks);
\r