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 fmi1_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 FMI1_IMPORT_CONVENIENCE_H_
26 #define FMI1_IMPORT_CONVENIENCE_H_
28 #include <FMI/fmi_import_context.h>
34 \addtogroup fmi1_import
36 \addtogroup fmi1_import_convenience Convenience functions.
38 \addtogroup fmi1_import_convenience Convenience functions.
39 \brief The functions in this module are provided for convenience. The functionality
40 * 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 parameters */
52 unsigned int num_parameters;
54 /** \brief Number of discrete variables */
55 unsigned int num_discrete;
56 /** \brief Number of continuous variables */
57 unsigned int num_continuous;
59 /** \brief Number of inputs */
60 unsigned int num_inputs;
61 /** \brief Number of outputs */
62 unsigned int num_outputs;
63 /** \brief Number of internal variables */
64 unsigned int num_internal;
65 /** \brief Number of variables with causality 'none'*/
66 unsigned int num_causality_none;
68 /** \brief Number of real variables*/
69 unsigned int num_real_vars;
\r
70 /** \brief Number of integer variables*/
71 unsigned int num_integer_vars;
\r
72 /** \brief Number of enumeration variables*/
73 unsigned int num_enum_vars;
\r
74 /** \brief Number of boolean variables*/
75 unsigned int num_bool_vars;
\r
76 /** \brief Number of string variables*/
77 unsigned int num_string_vars;
\r
78 } fmi1_import_model_counts_t;
81 \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi1_import_model_counts_t struct.
\r
82 \param fmu - An fmu object as returned by fmi1_import_parse_xml().
\r
83 \param counts - a pointer to a preallocated struct.
\r
86 void fmi1_import_collect_model_counts(fmi1_import_t* fmu, fmi1_import_model_counts_t* counts);
89 \brief Print msgIn into msgOut by expanding variable references of the form #\<Type\>\<VR\># into variable names
\r
90 and replacing '##' with a single #.
\r
91 \param fmu - An fmu object as returned by fmi1_import_parse_xml().
\r
92 \param msgIn - Log message as produced by an FMU.
\r
93 \param msgOut - Output message buffer.
\r
94 \param maxMsgSize - maximum message size
\r
97 void fmi1_import_expand_variable_references(fmi1_import_t* fmu, const char* msgIn, char* msgOut, size_t maxMsgSize);
\r
101 \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure.
103 The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then
104 forwards the message to the logger connected to the particular ::fmi1_import_t struct. The function is called by the FMU.
105 The FMU must be loaded with non-zero registerGlobally parameter of fmi1_import_create_dllfmu() in order to work.
106 If no matching ::fmi1_import_t struct is found on the global list then jm_get_default_callbacks() is used to get the default logger.
107 Note that this function is not thread safe due to the use of the global list.
110 void fmi1_log_forwarding(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...);
113 \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure.
115 See fmi1_log_forwarding() for more information.
118 void fmi1_log_forwarding_v(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, va_list args);
121 /** \brief Default FMI 1.0 logger may be used when instantiating FMUs */
123 void fmi1_default_callback_logger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...);
125 /** \brief Given ::fmi1_callback_functions_t logger (fmi1_logger), the ::jm_callbacks logger may be setup to redirect the messages to the fmi1_logger.
127 The functions sets up the redirection. Note that the context field in ::jm_callbacks is set to point to the provided ::fmi1_callback_functions_t.
128 \param cb FMI Library callbacks
129 \param fmiCallbacks FMI 1.0 standard callbacks
132 void fmi1_import_init_logger(jm_callbacks* cb, fmi1_callback_functions_t* fmiCallbacks);
142 #endif /* FMI1_IMPORT_CONVENIENCE_H_ */