22 #include "config_test.h" 31 printf(
"module = %s, log level = %d: %s\n", module, log_level, message);
36 printf(
"Press 'Enter' to exit\n");
53 printf(
"No type definition\n");
64 printf(
"Quantity: %s\n", quan);
75 printf(
"Min %g, max %g, nominal %g\n", min, max, nom);
81 printf(
"Display unit: %s, gain: %g, offset: %g, is relative: %s",
95 printf(
"Min %d, max %d\n", min, max);
108 printf(
"Min %d, max %d\n", min, max);
115 printf(
"There are %u items \n",(
unsigned)ni);
116 for(i = 0; i < ni; i++) {
123 printf(
"Error in fmiGetBaseType()\n");
138 printf(
"Searching by name worked fine\n");
142 printf(
"Searching by vr failed for variable '%s'\n", a_name);
154 printf(
"Searching by vr worked fine\n");
204 printf(
"Error in fmiGetBaseType()\n");
208 printf(
"The variable is aliased to %s\n",
212 printf(
"The variable is not an alias\n");
217 unsigned i = (unsigned)n;
220 printf(
"Listing aliases: \n");
235 printf(
"Listing direct dependencies: \n");
256 int main(
int argc,
char *argv[])
267 printf(
"Usage: %s <path to a dir with modelDescription.xml>\n", argv[0]);
273 callbacks.
malloc = malloc;
274 callbacks.
calloc = calloc;
276 callbacks.
free = free;
281 #ifdef FMILIB_GENERATE_BUILD_STAMP 282 printf(
"Library build stamp:\n%s\n", fmilib_get_build_stamp());
291 printf(
"Error parsing XML, exiting\n");
298 t = (double) (stop-start)/CLOCKS_PER_SEC;
300 printf(
"Parsing took %g seconds\n", t);
319 printf(
"Default experiment start = %g, end = %g, tolerance = %g\n",
329 printf(
"There are %u tool annotation records \n", (
unsigned)nv);
330 for( i = 0; i < nv; i++) {
333 printf(
"Error getting vendor for index %u\n", (
unsigned)i);
340 for(j = 0; j< na; j++) {
356 printf(
"There are %d different units used \n", nu);
358 for(i = 0; i < nu; i++) {
375 printf(
"There are %d defs\n", ntd);
376 for(i = 0; i < ntd; i++) {
398 printf(
"There are %u variables in total \n",(
unsigned)nv);
399 for(i = 0; i < nv; i++) {
402 printf(
"Something wrong with variable %d \n",i);
416 printf(
"Everything seems to be OK since you got this far=)!\n");
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.
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.
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.
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.
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.
FMILIB_EXPORT fmi1_import_unit_t * fmi1_import_get_real_variable_unit(fmi1_import_real_variable_t *v)
Get associated "unit" object if any.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.