FMI Library: part of JModelica.org
fmi_import_xml_test.c
Go to the documentation of this file.
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 #include <stdio.h>
17 #include <stdlib.h>
18 #include <stdarg.h>
19 #include <assert.h>
20 #include <time.h>
21 
22 #include "config_test.h"
23 
24 #include <FMI/fmi_import_context.h>
25 
26 #include <FMI1/fmi1_import.h>
27 
28 
29 void mylogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
30 {
31  printf("module = %s, log level = %d: %s\n", module, log_level, message);
32 }
33 
34 void do_exit(int code)
35 {
36  printf("Press 'Enter' to exit\n");
37 /* getchar(); */
38  exit(code);
39 }
40 
41 void print_int(int i,void* data) {
42  printf("%d\n", i);
43 }
44 
45 void print_dbl(double d,void* data) {
46  printf("%g\n", d);
47 }
48 
50  const char* quan;
51 
52  if(!vt) {
53  printf("No type definition\n");
54  return;
55  }
56 
58 
59  printf("Type %s\n description: %s\n", fmi1_import_get_type_name(vt), fmi1_import_get_type_description(vt));
60 
61  printf("Base type: %s\n", fmi1_base_type_to_string(fmi1_import_get_base_type(vt)));
62 
63  if(quan) {
64  printf("Quantity: %s\n", quan);
65  }
66  switch(fmi1_import_get_base_type(vt)) {
67  case fmi1_base_type_real: {
69  fmi1_real_t min = fmi1_import_get_real_type_min(rt);
70  fmi1_real_t max = fmi1_import_get_real_type_max(rt);
71  fmi1_real_t nom = fmi1_import_get_real_type_nominal(rt);
74 
75  printf("Min %g, max %g, nominal %g\n", min, max, nom);
76 
77  if(u) {
78  printf("Unit: %s\n", fmi1_import_get_unit_name(u));
79  }
80  if(du) {
81  printf("Display unit: %s, gain: %g, offset: %g, is relative: %s",
86  );
87  }
88 
89  break;
90  }
91  case fmi1_base_type_int:{
95  printf("Min %d, max %d\n", min, max);
96  break;
97  }
98  case fmi1_base_type_bool:{
99  break;
100  }
101  case fmi1_base_type_str:{
102  break;
103  }
104  case fmi1_base_type_enum:{
106  int min = fmi1_import_get_enum_type_min(et);
107  int max = fmi1_import_get_enum_type_max(et);
108  printf("Min %d, max %d\n", min, max);
109  {
110  size_t ni;
111  unsigned i;
113  i = (unsigned)(ni);
114  assert( i == ni);
115  printf("There are %u items \n",(unsigned)ni);
116  for(i = 0; i < ni; i++) {
117  printf("[%u] %s (%s) \n", (unsigned)i+1, fmi1_import_get_enum_type_item_name(et, i), fmi1_import_get_enum_type_item_description(et, i));
118  }
119  }
120  break;
121  }
122  default:
123  printf("Error in fmiGetBaseType()\n");
124  }
125 
126 }
127 
130 
131  const char * a_name = fmi1_import_get_variable_name(v);
133  if(found != v) {
134  printf("Searching by name %s found var %s\n", a_name, found?fmi1_import_get_variable_name(found):"nothing");
135  do_exit(1);
136  }
137  else {
138  printf("Searching by name worked fine\n");
139  }
141  if(!found) {
142  printf("Searching by vr failed for variable '%s'\n", a_name);
143  do_exit(1);
144  }
146  printf("Searching %s found var %s", a_name, fmi1_import_get_variable_name(found));
147  do_exit(1);
148  }
150  printf("Searching %s found var %s", a_name, fmi1_import_get_variable_name(found));
151  do_exit(1);
152  }
153  else {
154  printf("Searching by vr worked fine\n");
155  }
156 }
157 
161  printf("Variable name: %s\n", fmi1_import_get_variable_name(v));
162  printf("Description: %s\n", fmi1_import_get_variable_description(v));
163  printf("VR: %d\n", fmi1_import_get_variable_vr(v));
164  printf("Variability: %s\n", fmi1_variability_to_string(fmi1_import_get_variability(v)));
165  printf("Causality: %s\n", fmi1_causality_to_string(fmi1_import_get_causality(v)));
166 
168  printf("Base type: %s\n", fmi1_base_type_to_string(bt));
169 
171  if(bt == fmi1_base_type_real) {
175  printf("Unit: %s, display unit: %s\n", u ? fmi1_import_get_unit_name(u):0, du?fmi1_import_get_display_unit_name(du):0);
176  }
177 
179  printf("There is a start value, fixed attribute is '%s'\n", (fmi1_import_get_variable_is_fixed(v))?"true":"false");
180 
182  case fmi1_base_type_real: {
184  printf("start =%g\n", fmi1_import_get_real_variable_start(rv));
185  break;
186  }
187  case fmi1_base_type_int:{
189  break;
190  }
191  case fmi1_base_type_bool:{
193  break;
194  }
195  case fmi1_base_type_str:{
197  break;
198  }
199  case fmi1_base_type_enum:{
201  break;
202  }
203  default:
204  printf("Error in fmiGetBaseType()\n");
205  }
206  }
208  printf("The variable is aliased to %s\n",
210  }
211  else {
212  printf("The variable is not an alias\n");
213  }
214  {
216  size_t n = fmi1_import_get_variable_list_size(vl);
217  unsigned i = (unsigned)n;
218  assert( n == i);
219  if(n>1) {
220  printf("Listing aliases: \n");
221  for(i = 0;i<n;i++)
223  }
225  }
226  {
228  size_t n = 0;
229  unsigned i;
230  if(vl)
232  i = (unsigned)n;
233  assert( n == i);
234  if(vl) {
235  printf("Listing direct dependencies: \n");
236  for(i = 0;i<n;i++)
238  }
240  }
241 }
242 
244  printf("canHandleVariableCommunicationStepSize = %u\n", fmi1_import_get_canHandleVariableCommunicationStepSize(capabilities ));
245  printf("canHandleEvents = %u\n", fmi1_import_get_canHandleEvents(capabilities ));
246  printf("canRejectSteps = %u\n", fmi1_import_get_canRejectSteps(capabilities ));
247  printf("canInterpolateInputs = %u\n", fmi1_import_get_canInterpolateInputs(capabilities ));
248  printf("maxOutputDerivativeOrder = %u\n", fmi1_import_get_maxOutputDerivativeOrder(capabilities ));
249  printf("canRunAsynchronuously = %u\n", fmi1_import_get_canRunAsynchronuously(capabilities ));
250  printf("canSignalEvents = %u\n", fmi1_import_get_canSignalEvents(capabilities ));
251  printf("canBeInstantiatedOnlyOncePerProcess = %u\n", fmi1_import_get_canBeInstantiatedOnlyOncePerProcess(capabilities ));
252  printf("canNotUseMemoryManagementFunctions = %u\n", fmi1_import_get_canNotUseMemoryManagementFunctions(capabilities ));
253 }
254 
255 
256 int main(int argc, char *argv[])
257 {
258  clock_t start, stop;
259  double t = 0.0;
260  const char* tmpPath;
262  fmi_import_context_t* context;
263 
265 
266  if(argc < 2) {
267  printf("Usage: %s <path to a dir with modelDescription.xml>\n", argv[0]);
268  do_exit(1);
269  }
270 
271  tmpPath = argv[1];
272 
273  callbacks.malloc = malloc;
274  callbacks.calloc = calloc;
275  callbacks.realloc = realloc;
276  callbacks.free = free;
277  callbacks.logger = mylogger;
278  callbacks.context = 0;
279  callbacks.log_level = jm_log_level_debug;
280 
281 #ifdef FMILIB_GENERATE_BUILD_STAMP
282  printf("Library build stamp:\n%s\n", fmilib_get_build_stamp());
283 #endif
284 
285  context = fmi_import_allocate_context(&callbacks);
286 
287  start = clock();
288  fmu = fmi1_import_parse_xml(context, tmpPath);
289 
290  if(!fmu) {
291  printf("Error parsing XML, exiting\n");
292  fmi_import_free_context(context);
293  do_exit(1);
294  }
295 
296  /* Stop timer */
297  stop = clock();
298  t = (double) (stop-start)/CLOCKS_PER_SEC;
299 
300  printf("Parsing took %g seconds\n", t);
301  printf("Model name: %s\n", fmi1_import_get_model_name(fmu));
302  printf("Model identifier: %s\n", fmi1_import_get_model_identifier(fmu));
303  printf("Model GUID: %s\n", fmi1_import_get_GUID(fmu));
304  printf("FMU kind: %s\n", fmi1_fmu_kind_to_string(fmi1_import_get_fmu_kind(fmu)));
305  printf("Description: %s\n", fmi1_import_get_description(fmu));
306  printf("Author: %s\n", fmi1_import_get_author(fmu));
307  printf("FMI Version: %s\n", fmi1_import_get_model_standard_version(fmu));
308  printf("Generation tool: %s\n", fmi1_import_get_generation_tool(fmu));
309  printf("Generation date and time: %s\n", fmi1_import_get_generation_date_and_time(fmu));
310  printf("Version: %s\n", fmi1_import_get_model_version(fmu));
312 
315 
316  printf("NumberOfContinuousStates = %d\n", fmi1_import_get_number_of_continuous_states(fmu));
317  printf("NumberOfEventIndicators = %d\n", fmi1_import_get_number_of_event_indicators(fmu));
318 
319  printf("Default experiment start = %g, end = %g, tolerance = %g\n",
323  {
325  size_t nv = fmi1_import_get_number_of_vendors(vl);
326  unsigned i;
327  i = (unsigned)nv;
328  assert( nv == i);
329  printf("There are %u tool annotation records \n", (unsigned)nv);
330  for( i = 0; i < nv; i++) {
332  if(!vendor) {
333  printf("Error getting vendor for index %u\n", (unsigned)i);
334  break;
335  }
336  printf("Vendor name [%d] %s", i, fmi1_import_get_vendor_name(vendor));
337  {
338  unsigned j, na = fmi1_import_get_number_of_vendor_annotations(vendor);
339 
340  for(j = 0; j< na; j++) {
342  if(!a) {
343  printf("Error getting vendor for index %d (%s)\n", j, fmi1_import_get_last_error(fmu));
344  break;
345  }
346 
347  printf("Annotation: %s = %s", fmi1_import_get_annotation_name(a), fmi1_import_get_annotation_value(a));
348  }
349  }
350  }
351  }
352  {
354  if(ud) {
355  unsigned i, nu = fmi1_import_get_unit_definitions_number(ud);
356  printf("There are %d different units used \n", nu);
357 
358  for(i = 0; i < nu; i++) {
360  if(!u) {
361  printf("Error getting unit for index %d (%s)\n", i, fmi1_import_get_last_error(fmu));
362  break;
363  }
364  printf("Unit [%d] is %s, it has %d display units\n", i, fmi1_import_get_unit_name(u), fmi1_import_get_unit_display_unit_number(u));
365  }
366  }
367  else
368  printf("Error getting unit definitions (%s)\n", fmi1_import_get_last_error(fmu));
369  }
370  {
372  if(td) {
373  {
374  unsigned i, ntd = (unsigned)fmi1_import_get_type_definition_number(td);
375  printf("There are %d defs\n", ntd);
376  for(i = 0; i < ntd; i++) {
378  if(!vt) {
379  printf("Error getting vartype for index %d (%s)\n", i, fmi1_import_get_last_error(fmu));
380  break;
381  }
382  printTypeInfo(vt);
383  }
384  }
385  }
386  else
387  printf("Error getting type definitions (%s)\n", fmi1_import_get_last_error(fmu));
388  }
389  {
390  size_t nv;
391  unsigned i;
393 
394  assert(vl);
396  i = (unsigned)nv;
397  assert(i == nv);
398  printf("There are %u variables in total \n",(unsigned)nv);
399  for(i = 0; i < nv; i++) {
401  if(!var) {
402  printf("Something wrong with variable %d \n",i);
403  do_exit(1);
404  }
405  else {
406  printVariableInfo(fmu, var);
407  testVariableSearch(fmu, var);
408  }
409  }
411  }
412 
413  fmi1_import_free(fmu);
414  fmi_import_free_context(context);
415 
416  printf("Everything seems to be OK since you got this far=)!\n");
417 
418  do_exit(0);
419 }
420 
421 
FMILIB_EXPORT const char * fmi1_import_get_GUID(fmi1_import_t *fmu)
Get FMU GUID.
FMILIB_EXPORT const char * fmi1_import_get_vendor_name(fmi1_import_vendor_t *)
Get the vendor name.
FMILIB_EXPORT fmi1_import_integer_variable_t * fmi1_import_get_variable_as_integer(fmi1_import_variable_t *)
Cast general variable to a one with the specific type.
FMILIB_EXPORT fmi1_causality_enu_t fmi1_import_get_causality(fmi1_import_variable_t *)
Get causality attribute.
FMILIB_EXPORT const char * fmi1_import_get_type_quantity(fmi1_import_variable_typedef_t *)
Get the quantity associated with the type definition.
FMILIB_EXPORT unsigned int fmi1_import_get_number_of_event_indicators(fmi1_import_t *fmu)
Get the number of event indicators.
struct fmi1_xml_vendor_list_t fmi1_import_vendor_list_t
Opaque list of vendor annotations.
FMILIB_EXPORT fmi1_import_unit_t * fmi1_import_get_unit(fmi1_import_unit_definitions_t *, unsigned int index)
Get a unit definition.
FMILIB_EXPORT const char * fmi1_import_get_model_name(fmi1_import_t *fmu)
Get model name.
FMILIB_EXPORT unsigned int fmi1_import_get_maxOutputDerivativeOrder(fmi1_import_capabilities_t *)
Retrieve maxOutputDerivativeOrder.
jm_calloc_f calloc
Allocate zero initialized memory.
Definition: jm_callbacks.h:77
struct fmi1_xml_unit_t fmi1_import_unit_t
A variable unit defined with a unit defition.
FMILIB_EXPORT int fmi1_import_get_canRejectSteps(fmi1_import_capabilities_t *)
Retrieve canRejectSteps flag.
FMILIB_EXPORT const char * fmi1_import_get_variable_name(fmi1_import_variable_t *)
Get the variable name.
size_t jm_callbacks * c
FMILIB_EXPORT fmi1_import_real_variable_t * fmi1_import_get_variable_as_real(fmi1_import_variable_t *)
Cast general variable to a one with the specific type.
FMILIB_EXPORT int fmi1_import_get_enum_variable_start(fmi1_import_enum_variable_t *v)
Get start value for the variable.
Import context is the entry point to the library. It is used to initialize, unzip, get FMI version and start parsing.
FMILIB_EXPORT int fmi1_import_get_canInterpolateInputs(fmi1_import_capabilities_t *)
Retrieve canInterpolateInputs flag.
FMILIB_EXPORT fmi1_import_bool_variable_t * fmi1_import_get_variable_as_boolean(fmi1_import_variable_t *)
Cast general variable to a one with the specific type.
int main(int argc, char *argv[])
void printVariableInfo(fmi1_import_t *fmu, fmi1_import_variable_t *v)
struct fmi1_import_variable_list_t fmi1_import_variable_list_t
List of variables.
FMILIB_EXPORT const char * fmi1_import_get_enum_type_item_name(fmi1_import_enumeration_typedef_t *, unsigned int item)
Get an enumeration item name by index.
FMILIB_EXPORT const char * fmi1_import_get_model_version(fmi1_import_t *fmu)
Get FMU version.
struct fmi1_xml_integer_typedef_t fmi1_import_integer_typedef_t
Opaque integer type definition object.
FMILIB_EXPORT fmi1_base_type_enu_t fmi1_import_get_base_type(fmi1_import_variable_typedef_t *)
Get base type used for the type definition.
FMILIB_EXPORT unsigned int fmi1_import_get_enum_type_size(fmi1_import_enumeration_typedef_t *)
Get the number of elements in the enum.
FMILIB_EXPORT unsigned int fmi1_import_get_enum_type_max(fmi1_import_enumeration_typedef_t *)
Get maximum value for the type.
FMILIB_EXPORT unsigned int fmi1_import_get_number_of_vendor_annotations(fmi1_import_vendor_t *)
Get the number of annotations provided for the vendor.
FMILIB_EXPORT fmi1_real_t fmi1_import_get_display_unit_offset(fmi1_import_display_unit_t *)
Get the "offset" associated with the display unit.
FMILIB_EXPORT double fmi1_import_get_default_experiment_stop(fmi1_import_t *fmu)
Get the stop time for default experiment as specified in the XML file.
FMILIB_EXPORT int fmi1_import_get_canNotUseMemoryManagementFunctions(fmi1_import_capabilities_t *)
Retrieve canNotUseMemoryManagementFunctions flag.
FMILIB_EXPORT fmi1_import_unit_t * fmi1_import_get_real_type_unit(fmi1_import_real_typedef_t *)
Get the unit object associated with the type definition if any.
FMILIB_EXPORT const char * fmi1_import_get_description(fmi1_import_t *fmu)
Get FMU description.
FMILIB_EXPORT fmi1_real_t fmi1_import_get_display_unit_gain(fmi1_import_display_unit_t *)
Get the "gain" associated with the display unit.
FMILIB_EXPORT fmi1_import_enum_variable_t * fmi1_import_get_variable_as_enum(fmi1_import_variable_t *)
Cast general variable to a one with the specific type.
FMILIB_EXPORT const char * fmi1_import_get_unit_name(fmi1_import_unit_t *)
Get a unit name.
FMILIB_EXPORT int fmi1_import_get_canSignalEvents(fmi1_import_capabilities_t *)
Deprecated since 1.0.1, do not use.
jm_log_level_enu_t
Log levels supported via the logger functions in jm_callbacks.
Definition: jm_types.h:51
FMILIB_EXPORT fmi1_fmu_kind_enu_t fmi1_import_get_fmu_kind(fmi1_import_t *fmu)
Get the type of the FMU (model exchange or co-simulation)
FMILIB_EXPORT fmi1_import_variable_t * fmi1_import_get_variable_alias_base(fmi1_import_t *fmu, fmi1_import_variable_t *)
Get the variable with the same value reference that is not an alias.
struct fmi1_xml_annotation_t fmi1_import_annotation_t
Opaque annotation object.
FMILIB_EXPORT int fmi1_import_get_integer_variable_start(fmi1_import_integer_variable_t *v)
Get start value for the variable.
return v
FMILIB_EXPORT int fmi1_import_get_integer_type_max(fmi1_import_integer_typedef_t *)
Get maximum value for the type.
struct fmi1_xml_variable_t fmi1_import_variable_t
General variable type.
struct fmi1_xml_vendor_t fmi1_import_vendor_t
Opaque vendor object.
FMILIB_EXPORT double fmi1_import_get_real_type_min(fmi1_import_real_typedef_t *)
Get minimal value for the type.
struct fmi1_xml_capabilities_t fmi1_import_capabilities_t
A container for all the capability flags.
FMILIB_EXPORT double fmi1_import_get_real_type_nominal(fmi1_import_real_typedef_t *)
Get the nominal value associated with the type definition.
FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_start(fmi1_import_real_variable_t *v)
Get the variable start attribute.
FMILIB_EXPORT fmi1_variable_alias_kind_enu_t fmi1_import_get_variable_alias_kind(fmi1_import_variable_t *)
Get the variable alias kind.
FMILIB_EXPORT int fmi1_import_get_canHandleVariableCommunicationStepSize(fmi1_import_capabilities_t *)
Retrieve canHandleVariableCommunicationStepSize flag.
FMILIB_EXPORT int fmi1_import_get_variable_has_start(fmi1_import_variable_t *)
Check if the variable has "start" attribute.
jm_log_level_enu_t log_level
Logging level.
Definition: jm_callbacks.h:85
FMILIB_EXPORT fmi1_import_unit_t * fmi1_import_get_real_variable_unit(fmi1_import_real_variable_t *v)
Get associated "unit" object if any.
v callbacks
FMILIB_EXPORT fmi1_import_variable_list_t * fmi1_import_get_variable_list(fmi1_import_t *fmu)
Get the list of all the variables in the model.
fmi1_capi_t * fmu
FMILIB_EXPORT const char * fmi1_naming_convention_to_string(fmi1_variable_naming_convension_enu_t convention)
Convert a fmi1_variable_naming_convension_enu_t constant into string.
FMILIB_EXPORT const char * fmi1_causality_to_string(fmi1_causality_enu_t c)
Convert a fmi1_causality_enu_t constant into string.
FMILIB_EXPORT fmi1_import_variable_list_t * fmi1_import_get_direct_dependency(fmi1_import_t *fmu, fmi1_import_variable_t *)
Get the direct dependency information.
FMILIB_EXPORT unsigned int fmi1_import_get_number_of_continuous_states(fmi1_import_t *fmu)
Get the number of contnuous states.
FMILIB_EXPORT double fmi1_import_get_default_experiment_tolerance(fmi1_import_t *fmu)
Get the tolerance default experiment as specified in the XML file.
FMILIB_EXPORT int fmi1_import_get_canHandleEvents(fmi1_import_capabilities_t *)
Retrieve canHandleEvents flag.
FMILIB_EXPORT int fmi1_import_get_real_type_is_relative_quantity(fmi1_import_real_typedef_t *)
Get the relativeQuantity flag.
FMILIB_EXPORT fmi1_import_t * fmi1_import_parse_xml(fmi_import_context_t *c, const char *dirName)
Parse FMI 1.0 XML file found in the directory dirName.
FMILIB_EXPORT const char * fmi1_import_get_model_identifier(fmi1_import_t *fmu)
Get model identifier.
struct fmi1_xml_type_definitions_t fmi1_import_type_definitions_t
Opaque list of the type definitions in the model.
FMILIB_EXPORT unsigned int fmi1_import_get_enum_type_min(fmi1_import_enumeration_typedef_t *)
Get minimal value for the type.
FMILIB_EXPORT fmi1_import_integer_typedef_t * fmi1_import_get_type_as_int(fmi1_import_variable_typedef_t *)
Cast the general type definition object to an object with a specific base type.
Verbose messages.
Definition: jm_types.h:58
struct fmi1_xml_unit_definitions_t fmi1_import_unit_definitions_t
The list of all the unit definitions in the model.
FMILIB_EXPORT const char * fmi1_import_get_annotation_name(fmi1_import_annotation_t *)
Get the name of the annotation.
FMILIB_EXPORT const char * fmi1_fmu_kind_to_string(fmi1_fmu_kind_enu_t kind)
Convert a fmi1_fmu_kind_enu_t constant into string.
jm_malloc_f malloc
Allocate non-initialized memory.
Definition: jm_callbacks.h:75
FMILIB_EXPORT int fmi1_import_get_variable_is_fixed(fmi1_import_variable_t *)
Get the variable "fixed" attribute.
jm_voidp context
Arbitrary context pointer passed to the logger function.
Definition: jm_callbacks.h:87
FMILIB_EXPORT fmi1_import_display_unit_t * fmi1_import_get_type_display_unit(fmi1_import_real_typedef_t *)
Get associated display unit for a type defition if any.
const char * jm_string
A constant string.
Definition: jm_types.h:33
FMILIB_EXPORT fmi1_import_annotation_t * fmi1_import_get_vendor_annotation(fmi1_import_vendor_t *, unsigned int index)
Get an annotation object for the vendor by index.
FMILIB_EXPORT fmi1_import_variable_t * fmi1_import_get_variable_by_vr(fmi1_import_t *fmu, fmi1_base_type_enu_t baseType, fmi1_value_reference_t vr)
Get variable by value reference.
struct fmi1_xml_variable_typedef_t fmi1_import_variable_typedef_t
Opaque general variable type definition object.
FMILIB_EXPORT const char * fmi1_import_get_last_error(fmi1_import_t *fmu)
Retrieve the last error message.
FMILIB_EXPORT const char * fmi1_import_get_annotation_value(fmi1_import_annotation_t *)
Get the value for the annotation.
The callbacks struct is sent to all the modules in the library.
Definition: jm_callbacks.h:73
void print_dbl(double d, void *data)
FMILIB_EXPORT const char * fmi1_import_get_model_standard_version(fmi1_import_t *fmu)
Get FMI standard version (always 1.0).
void mylogger(jm_callbacks *c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
struct fmi_xml_context_t fmi_import_context_t
FMI version independent library context. Opaque struct returned from fmi_import_allocate_context() ...
FMILIB_EXPORT fmi1_import_real_typedef_t * fmi1_import_get_type_as_real(fmi1_import_variable_typedef_t *)
Cast the general type definition object to an object with a specific base type.
FMILIB_EXPORT fmi1_import_display_unit_t * fmi1_import_get_real_variable_display_unit(fmi1_import_real_variable_t *v)
Get associated "display unit" object if any.
FMILIB_EXPORT fmi_import_context_t * fmi_import_allocate_context(jm_callbacks *callbacks)
Create fmi_import_context_t structure.
FMILIB_EXPORT fmi1_base_type_enu_t fmi1_import_get_variable_base_type(fmi1_import_variable_t *)
Get variable base type.
fmi1_base_type_enu_t
Base types used in type definitions.
Definition: fmi1_enums.h:92
FMILIB_EXPORT const char * fmi1_import_get_type_description(fmi1_import_variable_typedef_t *)
Get type description.
FMILIB_EXPORT fmi1_boolean_t fmi1_import_get_boolean_variable_start(fmi1_import_bool_variable_t *v)
Get start value for the variable.
FMILIB_EXPORT fmi1_import_unit_definitions_t * fmi1_import_get_unit_definitions(fmi1_import_t *fmu)
Get a list of all the unit definitions in the model.
struct fmi1_import_t fmi1_import_t
FMU version 1.0 object.
FMILIB_EXPORT fmi1_import_vendor_list_t * fmi1_import_get_vendor_list(fmi1_import_t *fmu)
Get the list of all the vendor annotations present in the XML file.
struct fmi1_xml_display_unit_t fmi1_import_display_unit_t
A display unit.
void printCapabilitiesInfo(fmi1_import_capabilities_t *capabilities)
struct fmi1_xml_real_typedef_t fmi1_import_real_typedef_t
Opaque type definition object.
FMILIB_EXPORT fmi1_value_reference_t fmi1_import_get_variable_vr(fmi1_import_variable_t *)
Get variable value reference.
FMILIB_EXPORT const char * fmi1_variability_to_string(fmi1_variability_enu_t v)
Convert a fmi1_variability_enu_t constant into string.
FMILIB_EXPORT size_t fmi1_import_get_variable_list_size(fmi1_import_variable_list_t *vl)
Get number of variables in a list.
FMILIB_EXPORT unsigned int fmi1_import_get_unit_display_unit_number(fmi1_import_unit_t *)
Get the number of display units associated with this unit.
FMILIB_EXPORT int fmi1_import_get_canBeInstantiatedOnlyOncePerProcess(fmi1_import_capabilities_t *)
Retrieve canBeInstantiatedOnlyOncePerProcess flag.
FMILIB_EXPORT size_t fmi1_import_get_type_definition_number(fmi1_import_type_definitions_t *td)
Get the number of available type definitions.
void do_exit(int code)
struct fmi1_xml_enumeration_typedef_t fmi1_import_enumeration_typedef_t
Opaque enumeration type definition object.
FMILIB_EXPORT const char * fmi1_base_type_to_string(fmi1_base_type_enu_t bt)
Convert base type constant to string.
FMILIB_EXPORT unsigned int fmi1_import_get_number_of_vendors(fmi1_import_vendor_list_t *)
Get the number of different vendors.
FMILIB_EXPORT int fmi1_import_get_integer_type_min(fmi1_import_integer_typedef_t *)
Get minimal value for the type.
FMILIB_EXPORT fmi1_import_vendor_t * fmi1_import_get_vendor(fmi1_import_vendor_list_t *, unsigned int index)
Get the annotations associated with vendor specified by the index.
FMILIB_EXPORT fmi1_import_string_variable_t * fmi1_import_get_variable_as_string(fmi1_import_variable_t *)
Cast general variable to a one with the specific type.
struct fmi1_xml_real_variable_t fmi1_import_real_variable_t
Opaque real variable.
FMILIB_EXPORT fmi1_import_enumeration_typedef_t * fmi1_import_get_type_as_enum(fmi1_import_variable_typedef_t *)
Cast the general type definition object to an object with a specific base type.
FMILIB_EXPORT fmi1_import_variable_t * fmi1_import_get_variable_by_name(fmi1_import_t *fmu, const char *name)
Get variable by variable name.
FMILIB_EXPORT const char * fmi1_import_get_variable_description(fmi1_import_variable_t *)
Get variable description.
FMILIB_EXPORT void fmi_import_free_context(fmi_import_context_t *c)
Free memory allocated for the library context.
jm_realloc_f realloc
Re-allocate memory.
Definition: jm_callbacks.h:79
FMILIB_EXPORT fmi1_import_variable_t * fmi1_import_get_variable(fmi1_import_variable_list_t *vl, unsigned int index)
Get a single variable from the list.
FMILIB_EXPORT const char * fmi1_import_get_generation_tool(fmi1_import_t *fmu)
Get FMU generation tool.
void printTypeInfo(fmi1_import_variable_typedef_t *vt)
FMILIB_EXPORT unsigned int fmi1_import_get_unit_definitions_number(fmi1_import_unit_definitions_t *)
Get the number of unit definitions.
void print_int(int i, void *data)
FMILIB_EXPORT fmi1_import_capabilities_t * fmi1_import_get_capabilities(fmi1_import_t *fmu)
Get the structure with capability flags.
FMILIB_EXPORT void fmi1_import_free(fmi1_import_t *fmu)
Release the memory allocated.
FMILIB_EXPORT fmi1_import_variable_list_t * fmi1_import_get_variable_aliases(fmi1_import_t *fmu, fmi1_import_variable_t *)
jm_free_f free
Free-allocated memory.
Definition: jm_callbacks.h:81
Public interface to the FMI import C-library.
FMILIB_EXPORT fmi1_variability_enu_t fmi1_import_get_variability(fmi1_import_variable_t *)
Get variability attribute.
FMILIB_EXPORT const char * fmi1_import_get_display_unit_name(fmi1_import_display_unit_t *)
Get display unit name.
FMILIB_EXPORT const char * fmi1_import_get_type_name(fmi1_import_variable_typedef_t *)
Get the type name.
FMILIB_EXPORT fmi1_import_type_definitions_t * fmi1_import_get_type_definitions(fmi1_import_t *)
Get the list of all the type definitions in the model.
jm_logger_f logger
Logging callback.
Definition: jm_callbacks.h:83
FMILIB_EXPORT const char * fmi1_import_get_enum_type_item_description(fmi1_import_enumeration_typedef_t *, unsigned int item)
Get an enumeration item description by index.
void testVariableSearch(fmi1_import_t *fmu, fmi1_import_variable_t *v)
FMILIB_EXPORT fmi1_import_variable_typedef_t * fmi1_import_get_variable_declared_type(fmi1_import_variable_t *)
For scalar variable gives the type definition is present.
FMILIB_EXPORT double fmi1_import_get_default_experiment_start(fmi1_import_t *fmu)
Get the start time for default experiment as specified in the XML file.
FMILIB_EXPORT const char * fmi1_import_get_generation_date_and_time(fmi1_import_t *fmu)
Get FMU generation date and time.
FMILIB_EXPORT void fmi1_import_free_variable_list(fmi1_import_variable_list_t *vl)
Free a variable list. Note that variable lists are allocated dynamically and must be freed when not n...
FMILIB_EXPORT double fmi1_import_get_real_type_max(fmi1_import_real_typedef_t *)
Get maximum value for the type.
FMILIB_EXPORT const char * fmi1_import_get_author(fmi1_import_t *fmu)
Get FMU author.
FMILIB_EXPORT fmi1_variable_naming_convension_enu_t fmi1_import_get_naming_convention(fmi1_import_t *fmu)
Get variable naming convention used.
FMILIB_EXPORT int fmi1_import_get_canRunAsynchronuously(fmi1_import_capabilities_t *)
Retrieve canRunAsynchronuously flag.
FMILIB_EXPORT const char * fmi1_import_get_string_variable_start(fmi1_import_string_variable_t *v)
Get start value for the variable.
FMILIB_EXPORT fmi1_import_variable_typedef_t * fmi1_import_get_typedef(fmi1_import_type_definitions_t *td, unsigned int index)
Get a type definition specified by the index.