]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI1/fmi1_import_convenience.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Import / include / FMI1 / fmi1_import_convenience.h
1 /*
2     Copyright (C) 2012 Modelon AB
3
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the BSD style license.
6
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.
11
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>.
14 */
15
16
17
18 /** \file fmi1_import_convenience.h
19 *  \brief Public interface to the FMI import C-library. Convenience functions.
20 *
21 *  The functions in this file are provided for convenience. The functionality
22 *  is already available via other lower level functions.
23 */
24
25 #ifndef FMI1_IMPORT_CONVENIENCE_H_
26 #define FMI1_IMPORT_CONVENIENCE_H_
27
28 #include <FMI/fmi_import_context.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33                 /**
34         \addtogroup fmi1_import
35         @{
36         \addtogroup fmi1_import_convenience Convenience functions.
37         @}
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.
41
42         @{
43         */
44         
45 /** 
46 \brief Collection of counters providing model information.
47         */
48 typedef struct {
49         /** \brief Number of constants */
50         unsigned int num_constants;
51         /** \brief  Number of parameters */
52         unsigned int num_parameters;
53
54         /** \brief  Number of discrete variables */
55         unsigned int num_discrete;
56         /** \brief  Number of continuous variables */
57         unsigned int num_continuous;
58
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;
67
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;
79
80 /**\r
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
84 */\r
85 FMILIB_EXPORT 
86 void fmi1_import_collect_model_counts(fmi1_import_t* fmu, fmi1_import_model_counts_t* counts);
87
88 /**\r
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
95    */\r
96 FMILIB_EXPORT \r
97 void fmi1_import_expand_variable_references(fmi1_import_t* fmu, const char* msgIn, char* msgOut, size_t maxMsgSize);\r
98 \r
99
100 /**
101         \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure.
102         
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.
108 */
109 FMILIB_EXPORT 
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, ...);
111
112 /**
113         \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure.
114         
115         See fmi1_log_forwarding() for more information.
116 */
117 FMILIB_EXPORT 
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);
119
120
121 /** \brief  Default FMI 1.0 logger may be used when instantiating FMUs */
122 FMILIB_EXPORT
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, ...);
124
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.
126
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
130 */
131 FMILIB_EXPORT
132 void fmi1_import_init_logger(jm_callbacks* cb, fmi1_callback_functions_t* fmiCallbacks);
133 /**     @}\r
134 */
135
136
137 /** @} */
138
139 #ifdef __cplusplus
140 }
141 #endif
142 #endif /* FMI1_IMPORT_CONVENIENCE_H_ */