2 Copyright (C) 2012 Modelon AB
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the BSD style license.
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.
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>.
18 /** \file fmi2_import_convenience.h
19 * \brief Public interface to the FMI import C-library. Convenience functions.
21 * The functions in this file are provided for convenience. The functionality
22 * is already available via other lower level functions.
25 #ifndef FMI2_IMPORT_CONVENIENCE_H_
26 #define FMI2_IMPORT_CONVENIENCE_H_
28 #include <FMI/fmi_import_context.h>
29 #include <FMI2/fmi2_functions.h>
35 \addtogroup fmi2_import
37 \addtogroup fmi2_import_convenience Convenience functions.
39 \addtogroup fmi2_import_convenience Convenience functions.
40 \brief The functions in this module are provided for convenience. The functionality
41 * is already available via other lower level functions.
46 \brief Collection of counters providing model information.
49 /** \brief Number of constants */
50 unsigned int num_constants;
51 /** \brief Number of fixed */
52 unsigned int num_fixed;
53 /** \brief Number of tunable */
54 unsigned int num_tunable;
55 /** \brief Number of discrete variables */
56 unsigned int num_discrete;
57 /** \brief Number of continuous variables */
58 unsigned int num_continuous;
60 /** \brief Number of parameters*/
61 unsigned int num_parameters;
62 /** \brief Number of calculated parameters*/
63 unsigned int num_calculated_parameters;
64 /** \brief Number of inputs */
65 unsigned int num_inputs;
66 /** \brief Number of outputs */
67 unsigned int num_outputs;
68 /** \brief Number of local variables */
69 unsigned int num_local;
70 /** \brief Number of independent variables */
71 unsigned int num_independent;
73 /** \brief Number of real variables*/
74 unsigned int num_real_vars;
\r
75 /** \brief Number of integer variables*/
76 unsigned int num_integer_vars;
\r
77 /** \brief Number of enumeration variables*/
78 unsigned int num_enum_vars;
\r
79 /** \brief Number of boolean variables*/
80 unsigned int num_bool_vars;
\r
81 /** \brief Number of string variables*/
82 unsigned int num_string_vars;
\r
83 } fmi2_import_model_counts_t;
86 \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi2_import_model_counts_t struct.
\r
87 \param fmu - An fmu object as returned by fmi2_import_parse_xml().
\r
88 \param counts - a pointer to a preallocated struct.
\r
91 void fmi2_import_collect_model_counts(fmi2_import_t* fmu, fmi2_import_model_counts_t* counts);
94 \brief Print msgIn into msgOut by expanding variable references of the form #\<Type\>\<VR\># into variable names
\r
95 and replacing '##' with a single #.
\r
96 \param fmu - An fmu object as returned by fmi2_import_parse_xml().
\r
97 \param msgIn - Log message as produced by an FMU.
\r
98 \param msgOut - Output message buffer.
\r
99 \param maxMsgSize - maximum message size
\r
102 void fmi2_import_expand_variable_references(fmi2_import_t* fmu, const char* msgIn, char* msgOut, size_t maxMsgSize);
\r
106 \brief An implementation of FMI 2.0 logger that forwards the messages to logger function inside ::jm_callbacks structure.
108 The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then
109 forwards the message to the logger connected to the particular ::fmi2_import_t struct. The function is called by the FMU.
110 The FMU must be loaded with non-zero registerGlobally parameter of fmi2_import_create_dllfmu() in order to work.
111 If no matching ::fmi2_import_t struct is found on the global list then jm_get_default_callbacks() is used to get the default logger.
112 Note that this function is not thread safe due to the use of the global list.
115 void fmi2_log_forwarding(fmi2_component_t c, fmi2_string_t instanceName, fmi2_status_t status, fmi2_string_t category, fmi2_string_t message, ...);
118 \brief An implementation of FMI 2.0 logger that forwards the messages to logger function inside ::jm_callbacks structure.
120 See fmi2_log_forwarding() for more information.
123 void fmi2_log_forwarding_v(fmi2_component_t c, fmi2_string_t instanceName, fmi2_status_t status, fmi2_string_t category, fmi2_string_t message, va_list args);
126 /** \brief Default FMI 2.0 logger may be used when instantiating FMUs */
128 void fmi2_default_callback_logger(fmi2_component_t c, fmi2_string_t instanceName, fmi2_status_t status, fmi2_string_t category, fmi2_string_t message, ...);
130 /** \brief Given ::fmi2_callback_functions_t logger (fmi2_logger), the ::jm_callbacks logger may be setup to redirect the messages to the fmi2_logger.
132 The functions sets up the redirection. Note that the context field in ::jm_callbacks is set to point to the provided ::fmi2_callback_functions_t.
133 \param cb FMI Library callbacks
134 \param fmiCallbacks FMI 2.0 standard callbacks
137 void fmi2_import_init_logger(jm_callbacks* cb, fmi2_callback_functions_t* fmiCallbacks);
147 #endif /* FMI2_IMPORT_CONVENIENCE_H_ */