From fc8d2ebdaefdaee65c9d22e450857f3c50d5fb44 Mon Sep 17 00:00:00 2001 From: Robin Andersson Date: Wed, 5 Apr 2023 10:51:31 -0400 Subject: [PATCH] Replaces all tabs with spaces (#33) * Replaces all tabs with spaces in all .c and .h files in dirs src and Test * Replaced tabs with spaces in all .cmake files and CMakeLists.txt --- CMakeLists.txt | 321 ++-- Config.cmake/Minizip/CMakeLists.txt | 13 +- Config.cmake/config_fmilib.c.cmake | 10 +- Config.cmake/config_fmilib.h.cmake | 30 +- Config.cmake/config_stamp.cmake | 4 +- Config.cmake/fmicapi.cmake | 12 +- Config.cmake/fmiimport.cmake | 156 +- Config.cmake/fmixml.cmake | 80 +- Config.cmake/fmizip.cmake | 12 +- Config.cmake/jmutil.cmake | 6 +- Config.cmake/mergestaticlibs.cmake | 176 +- Config.cmake/test_fmi1.cmake | 64 +- Test/FMI1/compress_test_fmu_zip.c | 46 +- Test/FMI1/fmi1_capi_cs_test.c | 910 ++++----- Test/FMI1/fmi1_capi_me_test.c | 882 ++++----- Test/FMI1/fmi1_import_test.c | 66 +- Test/FMI1/fmi1_logger_test.c | 300 +-- Test/FMI1/fmi_import_cs_test.c | 306 ++-- Test/FMI1/fmi_import_me_test.c | 418 ++--- Test/FMI1/fmi_import_xml_test.c | 160 +- Test/FMI1/fmi_total_test.c | 128 +- Test/FMI1/fmi_zip_unzip_test.c | 30 +- Test/FMI1/fmi_zip_zip_test.c | 36 +- Test/FMI1/fmu_dummy/fmu1_model.c | 966 +++++----- Test/FMI1/fmu_dummy/fmu1_model.h | 464 ++--- Test/FMI1/fmu_dummy/fmu1_model_cs.c | 50 +- Test/FMI1/fmu_dummy/fmu1_model_defines.h | 52 +- Test/FMI1/fmu_dummy/fmu1_model_me.c | 48 +- Test/FMI1/jm_vector_test.c | 22 +- Test/FMI2/fmi2_import_cs_test.c | 278 +-- Test/FMI2/fmi2_import_me_test.c | 342 ++-- Test/FMI2/fmi2_import_test.c | 110 +- Test/FMI2/fmu_dummy/fmu2_model.c | 870 ++++----- Test/FMI2/fmu_dummy/fmu2_model.h | 354 ++-- Test/FMI2/fmu_dummy/fmu2_model_cs.c | 46 +- Test/FMI2/fmu_dummy/fmu2_model_defines.h | 46 +- Test/FMI2/fmu_dummy/fmu2_model_me.c | 40 +- Test/FMI3/fmu_dummy/fmu3_model_defines.h | 48 +- Test/compress_test_fmu_zip.c | 54 +- Test/fmi_import_test.c | 82 +- Test/fmi_zip_unzip_test.c | 30 +- Test/fmi_zip_zip_test.c | 36 +- Test/jm_vector_test.c | 22 +- Test/main.cpp | 2 - src/CAPI/include/FMI1/fmi1_capi.h | 592 +++--- src/CAPI/include/FMI3/fmi3_capi.h | 24 +- src/CAPI/src/FMI1/fmi1_capi.c | 396 ++-- src/CAPI/src/FMI1/fmi1_capi_cs.c | 38 +- src/CAPI/src/FMI1/fmi1_capi_impl.h | 116 +- src/CAPI/src/FMI1/fmi1_capi_me.c | 86 +- src/CAPI/src/FMI2/fmi2_capi.c | 378 ++-- src/CAPI/src/FMI2/fmi2_capi_cs.c | 20 +- src/CAPI/src/FMI2/fmi2_capi_impl.h | 112 +- src/CAPI/src/FMI2/fmi2_capi_me.c | 36 +- src/CAPI/src/FMI3/fmi3_capi_me.c | 48 +- src/Import/include/FMI/fmi_import_context.h | 42 +- src/Import/include/FMI/fmi_import_util.h | 34 +- src/Import/include/FMI1/fmi1_import.h | 10 +- .../include/FMI1/fmi1_import_capabilities.h | 46 +- src/Import/include/FMI1/fmi1_import_capi.h | 20 +- .../include/FMI1/fmi1_import_convenience.h | 116 +- src/Import/include/FMI1/fmi1_import_cosim.h | 46 +- src/Import/include/FMI1/fmi1_import_type.h | 48 +- src/Import/include/FMI1/fmi1_import_unit.h | 42 +- .../include/FMI1/fmi1_import_variable.h | 80 +- .../include/FMI1/fmi1_import_variable_list.h | 6 +- .../FMI1/fmi1_import_vendor_annotations.h | 10 +- src/Import/include/FMI2/fmi2_import.h | 22 +- src/Import/include/FMI2/fmi2_import_capi.h | 18 +- .../include/FMI2/fmi2_import_convenience.h | 124 +- src/Import/include/FMI2/fmi2_import_type.h | 48 +- src/Import/include/FMI2/fmi2_import_unit.h | 56 +- .../include/FMI2/fmi2_import_variable.h | 70 +- .../include/FMI2/fmi2_import_variable_list.h | 6 +- src/Import/include/FMI3/fmi3_import.h | 28 +- src/Import/include/FMI3/fmi3_import_capi.h | 14 +- .../include/FMI3/fmi3_import_convenience.h | 164 +- .../include/FMI3/fmi3_import_dimension_list.h | 2 +- src/Import/include/FMI3/fmi3_import_type.h | 84 +- src/Import/include/FMI3/fmi3_import_unit.h | 72 +- .../include/FMI3/fmi3_import_variable.h | 98 +- .../include/FMI3/fmi3_import_variable_list.h | 6 +- src/Import/src/FMI/fmi_import_context.c | 46 +- src/Import/src/FMI/fmi_import_context_impl.h | 4 +- src/Import/src/FMI/fmi_import_util.c | 56 +- src/Import/src/FMI1/fmi1_import.c | 410 ++--- src/Import/src/FMI1/fmi1_import_capi.c | 402 ++-- src/Import/src/FMI1/fmi1_import_convenience.c | 470 ++--- src/Import/src/FMI1/fmi1_import_cosim.c | 4 +- src/Import/src/FMI1/fmi1_import_impl.h | 20 +- src/Import/src/FMI1/fmi1_import_type.c | 44 +- src/Import/src/FMI1/fmi1_import_unit.c | 14 +- src/Import/src/FMI1/fmi1_import_variable.c | 98 +- .../src/FMI1/fmi1_import_variable_list.c | 66 +- .../src/FMI1/fmi1_import_variable_list_impl.h | 2 +- .../src/FMI1/fmi1_import_vendor_annotations.c | 8 +- src/Import/src/FMI2/fmi2_import.c | 362 ++-- src/Import/src/FMI2/fmi2_import_capi.c | 324 ++-- src/Import/src/FMI2/fmi2_import_convenience.c | 462 ++--- src/Import/src/FMI2/fmi2_import_impl.h | 18 +- src/Import/src/FMI2/fmi2_import_type.c | 50 +- src/Import/src/FMI2/fmi2_import_unit.c | 36 +- src/Import/src/FMI2/fmi2_import_variable.c | 92 +- .../src/FMI2/fmi2_import_variable_list.c | 38 +- .../src/FMI2/fmi2_import_variable_list_impl.h | 2 +- .../src/FMI3/fmi3_import_dimension_list.c | 14 +- .../FMI3/fmi3_import_dimension_list_impl.h | 2 +- src/Import/src/FMI3/fmi3_import_impl.h | 14 +- src/Import/src/FMI3/fmi3_import_priv.c | 10 +- src/Import/src/FMI3/fmi3_import_type.c | 32 +- src/Import/src/FMI3/fmi3_import_unit.c | 36 +- src/Import/src/FMI3/fmi3_import_variable.c | 194 +- .../src/FMI3/fmi3_import_variable_list.c | 38 +- .../src/FMI3/fmi3_import_variable_list_impl.h | 2 +- src/Util/include/FMI/fmi_util.h | 20 +- src/Util/include/FMI/fmi_version.h | 16 +- src/Util/include/FMI1/fmi1_enums.h | 34 +- src/Util/include/FMI1/fmi1_functions.h | 136 +- src/Util/include/FMI1/fmi1_types.h | 26 +- src/Util/include/FMI2/fmi2_function_types.h | 32 +- src/Util/include/FMI2/fmi2_types.h | 24 +- src/Util/include/FMI2/fmi2_xml_callbacks.h | 22 +- src/Util/include/FMI3/fmi3_types.h | 26 +- src/Util/include/FMI3/fmi3_xml_callbacks.h | 22 +- src/Util/include/JM/jm_callbacks.h | 62 +- src/Util/include/JM/jm_named_ptr.h | 10 +- src/Util/include/JM/jm_portability.h | 56 +- src/Util/include/JM/jm_stack.h | 34 +- src/Util/include/JM/jm_string_set.h | 22 +- src/Util/include/JM/jm_types.h | 30 +- src/Util/include/JM/jm_vector.h | 20 +- src/Util/src/FMI/fmi_util.c | 58 +- src/Util/src/FMI/fmi_version.c | 12 +- src/Util/src/FMI1/fmi1_enums.c | 40 +- src/Util/src/JM/jm_callbacks.c | 88 +- src/Util/src/JM/jm_named_ptr.c | 4 +- src/Util/src/JM/jm_portability.c | 474 ++--- src/XML/include/FMI/fmi_xml_context.h | 16 +- src/XML/include/FMI1/fmi1_xml_capabilities.h | 44 +- .../include/FMI1/fmi1_xml_model_description.h | 26 +- src/XML/include/FMI1/fmi1_xml_type.h | 16 +- src/XML/include/FMI1/fmi1_xml_unit.h | 18 +- src/XML/include/FMI1/fmi1_xml_variable.h | 16 +- src/XML/include/FMI2/fmi2_xml_capabilities.h | 34 +- .../include/FMI2/fmi2_xml_model_description.h | 28 +- .../include/FMI2/fmi2_xml_model_structure.h | 2 +- src/XML/include/FMI2/fmi2_xml_type.h | 16 +- src/XML/include/FMI2/fmi2_xml_unit.h | 32 +- src/XML/include/FMI2/fmi2_xml_variable.h | 16 +- src/XML/include/FMI3/fmi3_xml_capabilities.h | 34 +- .../include/FMI3/fmi3_xml_model_description.h | 28 +- .../include/FMI3/fmi3_xml_model_structure.h | 2 +- src/XML/include/FMI3/fmi3_xml_type.h | 16 +- src/XML/include/FMI3/fmi3_xml_unit.h | 32 +- src/XML/include/FMI3/fmi3_xml_variable.h | 16 +- .../src-gen/FMI1/fmi1_xml_variable_name_lex.h | 86 +- .../FMI1/fmi1_xml_variable_name_parser.tab.c | 248 +-- src/XML/src-gen/FMI1/lex.yyfmi1.c | 1606 ++++++++-------- .../src-gen/FMI2/fmi2_xml_variable_name_lex.h | 86 +- .../FMI2/fmi2_xml_variable_name_parser.tab.c | 248 +-- src/XML/src-gen/FMI2/lex.yyfmi2.c | 1604 ++++++++-------- .../src-gen/FMI3/fmi3_xml_variable_name_lex.h | 82 +- .../FMI3/fmi3_xml_variable_name_parser.tab.c | 248 +-- src/XML/src-gen/FMI3/lex.yyfmi3.c | 1620 ++++++++--------- src/XML/src/FMI/fmi_xml_context.c | 120 +- src/XML/src/FMI/fmi_xml_context_impl.h | 4 +- src/XML/src/FMI1/fmi1_xml_cosim.c | 2 +- src/XML/src/FMI1/fmi1_xml_model_description.c | 112 +- .../FMI1/fmi1_xml_model_description_impl.h | 8 +- src/XML/src/FMI1/fmi1_xml_parser.c | 128 +- src/XML/src/FMI1/fmi1_xml_parser.h | 16 +- src/XML/src/FMI1/fmi1_xml_query.c | 378 ++-- src/XML/src/FMI1/fmi1_xml_query.h | 42 +- src/XML/src/FMI1/fmi1_xml_type.c | 20 +- src/XML/src/FMI1/fmi1_xml_type_impl.h | 4 +- src/XML/src/FMI1/fmi1_xml_unit.c | 12 +- src/XML/src/FMI1/fmi1_xml_variable_impl.h | 6 +- .../src/FMI1/fmi1_xml_vendor_annotations.c | 6 +- src/XML/src/FMI2/fmi2_xml_model_description.c | 290 +-- .../FMI2/fmi2_xml_model_description_impl.h | 10 +- src/XML/src/FMI2/fmi2_xml_model_structure.c | 128 +- .../src/FMI2/fmi2_xml_model_structure_impl.h | 28 +- src/XML/src/FMI2/fmi2_xml_parser.c | 304 ++-- src/XML/src/FMI2/fmi2_xml_parser.h | 58 +- src/XML/src/FMI2/fmi2_xml_query.c | 378 ++-- src/XML/src/FMI2/fmi2_xml_query.h | 42 +- src/XML/src/FMI2/fmi2_xml_type.c | 126 +- src/XML/src/FMI2/fmi2_xml_type_impl.h | 22 +- src/XML/src/FMI2/fmi2_xml_unit.c | 92 +- src/XML/src/FMI2/fmi2_xml_unit_impl.h | 6 +- src/XML/src/FMI2/fmi2_xml_variable_impl.h | 10 +- .../src/FMI2/fmi2_xml_vendor_annotations.c | 60 +- .../FMI3/fmi3_xml_model_description_impl.h | 12 +- src/XML/src/FMI3/fmi3_xml_model_structure.c | 128 +- .../src/FMI3/fmi3_xml_model_structure_impl.h | 28 +- src/XML/src/FMI3/fmi3_xml_parser.c | 292 +-- src/XML/src/FMI3/fmi3_xml_parser.h | 62 +- src/XML/src/FMI3/fmi3_xml_query.c | 378 ++-- src/XML/src/FMI3/fmi3_xml_query.h | 42 +- src/XML/src/FMI3/fmi3_xml_type_impl.h | 22 +- src/XML/src/FMI3/fmi3_xml_unit.c | 92 +- src/XML/src/FMI3/fmi3_xml_unit_impl.h | 6 +- src/XML/src/FMI3/fmi3_xml_variable_impl.h | 10 +- .../src/FMI3/fmi3_xml_vendor_annotations.c | 60 +- src/ZIP/include/FMI/fmi_zip_zip.h | 2 +- src/ZIP/src/fmi_zip_unzip.c | 100 +- src/ZIP/src/fmi_zip_zip.c | 106 +- 207 files changed, 12946 insertions(+), 12950 deletions(-) delete mode 100644 Test/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c67ae71..6ca908ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,24 +44,24 @@ set(FMILIB_FMI_STANDARD_HEADERS ${FMILIB_THIRDPARTYLIBS}/FMI/default CACHE PATH option (FMILIB_DEFAULT_BUILD_TYPE_RELEASE "Default build-type used for Makefile generation is 'Release'. Can be overwritten by CMAKE_BUILD_TYPE command line switch." ON) if(MSVC) - option (FMILIB_BUILD_WITH_STATIC_RTLIB "Use static run-time libraries (/MT or /MTd linker flags)" OFF) + option (FMILIB_BUILD_WITH_STATIC_RTLIB "Use static run-time libraries (/MT or /MTd linker flags)" OFF) endif() -option(FMILIB_BUILD_STATIC_LIB "Build the library as static." ON) -option(FMILIB_BUILD_SHARED_LIB "Build the library as shared (dll/so/dylib)." ON) -option(FMILIB_INSTALL_SUBLIBS "Install sub-libraries (fmicapi. fmixml, jmutil, fmiimport, fmizip)" OFF) +option(FMILIB_BUILD_STATIC_LIB "Build the library as static." ON) +option(FMILIB_BUILD_SHARED_LIB "Build the library as shared (dll/so/dylib)." ON) +option(FMILIB_INSTALL_SUBLIBS "Install sub-libraries (fmicapi. fmixml, jmutil, fmiimport, fmizip)" OFF) IF(NOT (WIN32 OR CYGWIN OR APPLE)) # On LINUX position independent code (-fPIC) must be used on all files to be linked into .so # On other systems this is not needed (either is default or relocation is done) - if(NOT FMILIB_BUILD_SHARED_LIB) - option(FMILIB_BUILD_FOR_SHARED_LIBS "The static library 'fmilib' can be linked into shared libraries. Mostly needed on Linux." ON) - else() - set(FMILIB_BUILD_FOR_SHARED_LIBS ON CACHE INTERNAL "The static library 'fmilib' can be linked into shared libraries. Mostly needed on Linux." FORCE) - endif() + if(NOT FMILIB_BUILD_SHARED_LIB) + option(FMILIB_BUILD_FOR_SHARED_LIBS "The static library 'fmilib' can be linked into shared libraries. Mostly needed on Linux." ON) + else() + set(FMILIB_BUILD_FOR_SHARED_LIBS ON CACHE INTERNAL "The static library 'fmilib' can be linked into shared libraries. Mostly needed on Linux." FORCE) + endif() else() - set(FMILIB_BUILD_FOR_SHARED_LIBS OFF CACHE INTERNAL "The static library 'fmilib' can be linked into shared libraries. Mostly needed on Linux." FORCE) + set(FMILIB_BUILD_FOR_SHARED_LIBS OFF CACHE INTERNAL "The static library 'fmilib' can be linked into shared libraries. Mostly needed on Linux." FORCE) endif() option (FMILIB_GENERATE_DOXYGEN_DOC "Generate doxygen doc target" ON) @@ -77,32 +77,32 @@ option(FMILIB_TEST_LOCALE "Perform testing related to setting locales ( mark_as_advanced(FMILIB_PRINT_DEBUG_MESSAGES FMILIB_DEBUG_TRACE) if(NOT FMILIB_BUILD_SHARED_LIB AND NOT FMILIB_BUILD_STATIC_LIB) - message(FATAL_ERROR "Either shared or static library build must be chosen") + message(FATAL_ERROR "Either shared or static library build must be chosen") endif() if(FMILIB_BUILD_STATIC_LIB AND NOT FMILIB_BUILD_SHARED_LIB) - set(FMILIB_STATIC_LIB_ONLY ON) + set(FMILIB_STATIC_LIB_ONLY ON) else() - set(FMILIB_STATIC_LIB_ONLY OFF) + set(FMILIB_STATIC_LIB_ONLY OFF) endif() if(FMILIB_DEFAULT_BUILD_TYPE_RELEASE) - set (FMILIB_DEFAULT_BUILD_TYPE "Release") + set (FMILIB_DEFAULT_BUILD_TYPE "Release") else() - set (FMILIB_DEFAULT_BUILD_TYPE "Debug") + set (FMILIB_DEFAULT_BUILD_TYPE "Debug") endif() IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE ${FMILIB_DEFAULT_BUILD_TYPE}) + SET(CMAKE_BUILD_TYPE ${FMILIB_DEFAULT_BUILD_TYPE}) ENDIF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_INSTALL_PREFIX ${FMILIB_INSTALL_PREFIX} CACHE INTERNAL "Prefix prepended to install directories" FORCE) # debug_message is used to trace the build script function(debug_message) - if(FMILIB_PRINT_DEBUG_MESSAGES) - message(STATUS "${ARGV}") - endif() + if(FMILIB_PRINT_DEBUG_MESSAGES) + message(STATUS "${ARGV}") + endif() endfunction() IF(NOT CMAKE_CFG_INTDIR) @@ -110,64 +110,64 @@ IF(NOT CMAKE_CFG_INTDIR) ENDIF(NOT CMAKE_CFG_INTDIR) if(MSVC) - # With C89 we're forced to use non-secure functions - # TODO: We're now using C99, and this can be cleaned up - ADD_DEFINITIONS (/D _CRT_SECURE_NO_WARNINGS) - - # Set the run-time library flag as controlled by the FMILIB_BUILD_WITH_STATIC_RTLIB option - if(FMILIB_BUILD_WITH_STATIC_RTLIB) - set(replace_from "/MD") - set(replace_to "/MT") - else() - set(replace_from "/MT") - set(replace_to "/MD") - endif(FMILIB_BUILD_WITH_STATIC_RTLIB) - - foreach(flag_var + # With C89 we're forced to use non-secure functions + # TODO: We're now using C99, and this can be cleaned up + ADD_DEFINITIONS (/D _CRT_SECURE_NO_WARNINGS) + + # Set the run-time library flag as controlled by the FMILIB_BUILD_WITH_STATIC_RTLIB option + if(FMILIB_BUILD_WITH_STATIC_RTLIB) + set(replace_from "/MD") + set(replace_to "/MT") + else() + set(replace_from "/MT") + set(replace_to "/MD") + endif(FMILIB_BUILD_WITH_STATIC_RTLIB) + + foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) # Replace flags for static/shared lib - if(${${flag_var}} MATCHES "${replace_from}") - string(REPLACE "${replace_from}" "${replace_to}" tmp "${${flag_var}}") - set(${flag_var} ${tmp} CACHE STRING "compiler flags" FORCE) - endif() + if(${${flag_var}} MATCHES "${replace_from}") + string(REPLACE "${replace_from}" "${replace_to}" tmp "${${flag_var}}") + set(${flag_var} ${tmp} CACHE STRING "compiler flags" FORCE) + endif() - endforeach(flag_var) + endforeach(flag_var) endif(MSVC) IF(CMAKE_COMPILER_IS_GNUCC) SET(SAVED_C_DEFAULT_FLAGS "${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic -Wall -Wno-unused-function") if(NOT MSYS) - include(CheckCCompilerFlag) - CHECK_C_COMPILER_FLAG("-fvisibility=hidden" SUPPORT_VISIBILITY) - if(SUPPORT_VISIBILITY) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") - endif() + include(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG("-fvisibility=hidden" SUPPORT_VISIBILITY) + if(SUPPORT_VISIBILITY) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") + endif() endif() ENDIF(CMAKE_COMPILER_IS_GNUCC) # The config files will end up in the binary dir include_directories("${FMILibrary_BINARY_DIR}") -if(FMILIB_BUILD_FOR_SHARED_LIBS) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS}") - SET(WITH_PIC ON) # this is used in MERGE_LIBRARIES below +if(FMILIB_BUILD_FOR_SHARED_LIBS) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS}") + SET(WITH_PIC ON) # this is used in MERGE_LIBRARIES below endif() # prefix each element of list by ${prefix}element macro(PREFIXLIST list_name prefix) # create empty list - necessary? - SET(${list_name}_TMP) + SET(${list_name}_TMP) # prefix and suffix elements foreach(l IN LISTS ${list_name}) list(APPEND ${list_name}_TMP ${prefix}${l}${suffix} ) endforeach() - + # replace list by tmp list SET(${list_name} ${${list_name}_TMP}) UNSET(${list_name}_TMP) @@ -175,21 +175,21 @@ endmacro(PREFIXLIST) # For MSVC define source groups. Does not work for MSVC 8. MSVC 9 not tested. if(MSVC AND (${CMAKE_GENERATOR} MATCHES "Visual Studio 10")) - source_group("Source files\\FMI1" REGULAR_EXPRESSION "fmi1_.*.c") - source_group("Source files\\FMI2" REGULAR_EXPRESSION "fmi2_.*.c") - source_group("Source files\\FMI3" REGULAR_EXPRESSION "fmi3_.*.c") - source_group("Header files\\FMI1" REGULAR_EXPRESSION "fmi1_.*.h") - source_group("Header files\\FMI2" REGULAR_EXPRESSION "fmi2_.*.h") - source_group("Header files\\FMI3" REGULAR_EXPRESSION "fmi3_.*.h") - source_group("Private headers" REGULAR_EXPRESSION "fmi_.*impl.h") - source_group("Private headers\\FMI1" REGULAR_EXPRESSION "fmi1_.*impl.h") - source_group("Private headers\\FMI2" REGULAR_EXPRESSION "fmi2_.*impl.h") - source_group("Private headers\\FMI3" REGULAR_EXPRESSION "fmi3_.*impl.h") + source_group("Source files\\FMI1" REGULAR_EXPRESSION "fmi1_.*.c") + source_group("Source files\\FMI2" REGULAR_EXPRESSION "fmi2_.*.c") + source_group("Source files\\FMI3" REGULAR_EXPRESSION "fmi3_.*.c") + source_group("Header files\\FMI1" REGULAR_EXPRESSION "fmi1_.*.h") + source_group("Header files\\FMI2" REGULAR_EXPRESSION "fmi2_.*.h") + source_group("Header files\\FMI3" REGULAR_EXPRESSION "fmi3_.*.h") + source_group("Private headers" REGULAR_EXPRESSION "fmi_.*impl.h") + source_group("Private headers\\FMI1" REGULAR_EXPRESSION "fmi1_.*impl.h") + source_group("Private headers\\FMI2" REGULAR_EXPRESSION "fmi2_.*impl.h") + source_group("Private headers\\FMI3" REGULAR_EXPRESSION "fmi3_.*impl.h") endif() set(FMILIBKIND STATIC) if(NOT FMILIB_STATIC_LIB_ONLY) - add_definitions(-DFMILIB_BUILDING_LIBRARY) + add_definitions(-DFMILIB_BUILDING_LIBRARY) endif() include(CheckSymbolExists) @@ -228,9 +228,9 @@ include(fmiimport) #Cmake variables set in config files. if(WIN32) - set(FMI_FILE_SEP "\\\\") + set(FMI_FILE_SEP "\\\\") else(WIN32) - set(FMI_FILE_SEP "/") + set(FMI_FILE_SEP "/") endif(WIN32) set(FMILIB_FMI_PLATFORM_DOC "FMI platform defines the subdirectory within FMU where binary is located") @@ -238,67 +238,67 @@ set(FMILIB_FMI_PLATFORM ”unknown” CACHE STRING ${FMILIB_FMI_PLATFORM_DOC}) if(FMILIB_FMI_PLATFORM MATCHES ”unknown”) include(fmiplatform) fmi_platform(FMI_PLATFORM) - set(FMILIB_FMI_PLATFORM ${FMI_PLATFORM} CACHE STRING ${FMILIB_FMI_PLATFORM_DOC} FORCE) + set(FMILIB_FMI_PLATFORM ${FMI_PLATFORM} CACHE STRING ${FMILIB_FMI_PLATFORM_DOC} FORCE) else() - set(FMI_PLATFORM ${FMILIB_FMI_PLATFORM}) + set(FMI_PLATFORM ${FMILIB_FMI_PLATFORM}) endif() configure_file ( "${FMILibrary_SOURCE_DIR}/Config.cmake/config_fmilib.h.cmake" "${FMILibrary_BINARY_DIR}/fmilib_config.h" - ) + ) set(FMILIB_SHARED_SUBLIBS ${FMIXML_LIBRARIES} ${FMIZIP_LIBRARIES} ${FMICAPI_LIBRARIES} expat minizip zlib c99snprintf) set(FMILIB_SUBLIBS ${FMIIMPORT_LIBRARIES} ${JMUTIL_LIBRARIES} ${FMILIB_SHARED_SUBLIBS}) set(FMILIB_SHARED_SRC ${FMIIMPORTSOURCE} ${JMUTILSOURCE} ${FMIIMPORTHEADERS}) if(FMILIB_GENERATE_BUILD_STAMP) - debug_message("FMILIB_SUBLIBS= ${FMILIB_SUBLIBS}") + debug_message("FMILIB_SUBLIBS= ${FMILIB_SUBLIBS}") add_custom_command( - OUTPUT ${FMILibrary_BINARY_DIR}/config_fmilib.c - COMMAND "${CMAKE_COMMAND}" - -D FMILIBRARYHOME="${FMILIBRARYHOME}" -D FMILIBRARYBUILD="${FMILIBRARYBUILD}" - -P ${FMILIBRARYHOME}/Config.cmake/config_stamp.cmake - COMMAND ${CMAKE_COMMAND} -E touch ${FMILibrary_BINARY_DIR}/config_fmilib.c - DEPENDS ${FMILIB_SUBLIBS} - ) - add_library(fmilib_timestamp STATIC ${FMILibrary_BINARY_DIR}/config_fmilib.c "${FMILibrary_BINARY_DIR}/fmilib_config.h") -# add_dependencies(fmilib_timestamp ${FMILIB_SUBLIBS} expat minizip zlib ${FMILIBRARYHOME}/Config.cmake/config_stamp.cmake) - - set(FMILIB_SUBLIBS ${FMILIB_SUBLIBS} fmilib_timestamp) - set(FMILIB_SHARED_SRC ${FMILIB_SHARED_SRC} ${FMILibrary_BINARY_DIR}/config_fmilib.c) + OUTPUT ${FMILibrary_BINARY_DIR}/config_fmilib.c + COMMAND "${CMAKE_COMMAND}" + -D FMILIBRARYHOME="${FMILIBRARYHOME}" -D FMILIBRARYBUILD="${FMILIBRARYBUILD}" + -P ${FMILIBRARYHOME}/Config.cmake/config_stamp.cmake + COMMAND ${CMAKE_COMMAND} -E touch ${FMILibrary_BINARY_DIR}/config_fmilib.c + DEPENDS ${FMILIB_SUBLIBS} + ) + add_library(fmilib_timestamp STATIC ${FMILibrary_BINARY_DIR}/config_fmilib.c "${FMILibrary_BINARY_DIR}/fmilib_config.h") +# add_dependencies(fmilib_timestamp ${FMILIB_SUBLIBS} expat minizip zlib ${FMILIBRARYHOME}/Config.cmake/config_stamp.cmake) + + set(FMILIB_SUBLIBS ${FMILIB_SUBLIBS} fmilib_timestamp) + set(FMILIB_SHARED_SRC ${FMILIB_SHARED_SRC} ${FMILibrary_BINARY_DIR}/config_fmilib.c) endif() set_target_properties( - ${FMILIB_SUBLIBS} + ${FMILIB_SUBLIBS} PROPERTIES FOLDER "Sublibs") - + if(FMILIB_INSTALL_SUBLIBS) - set(FMILIB_TARGETS fmiimport jmutils fmizip fmixml fmicapi) + set(FMILIB_TARGETS fmiimport jmutils fmizip fmixml fmicapi) endif() - + if(FMILIB_BUILD_STATIC_LIB) - include(mergestaticlibs) - if(WIN32) - merge_static_libs(fmilib ${FMILIB_SUBLIBS}) + include(mergestaticlibs) + if(WIN32) + merge_static_libs(fmilib ${FMILIB_SUBLIBS}) target_link_libraries(fmilib Shlwapi) foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - set(flags "") - string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) - get_target_property(flags fmilib ${PROPNAME}) - set_target_properties(fmilib PROPERTIES ${PROPNAME} "${flags} Shlwapi.lib") - endforeach() - else() - merge_static_libs(fmilib ${FMILIB_SUBLIBS} ) - endif(WIN32) - if(UNIX) - target_link_libraries(fmilib dl) - endif(UNIX) - set(FMILIB_TARGETS ${FMILIB_TARGETS} fmilib) + set(flags "") + string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) + get_target_property(flags fmilib ${PROPNAME}) + set_target_properties(fmilib PROPERTIES ${PROPNAME} "${flags} Shlwapi.lib") + endforeach() + else() + merge_static_libs(fmilib ${FMILIB_SUBLIBS} ) + endif(WIN32) + if(UNIX) + target_link_libraries(fmilib dl) + endif(UNIX) + set(FMILIB_TARGETS ${FMILIB_TARGETS} fmilib) endif() if(FMILIB_BUILD_SHARED_LIB) - add_library(fmilib_shared SHARED ${FMILIB_SHARED_SRC}) + add_library(fmilib_shared SHARED ${FMILIB_SHARED_SRC}) # Even if fmilib_shared is built from source files, it's still necessary that e.g. # fmiimport's dependencies such as generated code is built first. @@ -308,100 +308,100 @@ if(FMILIB_BUILD_SHARED_LIB) target_compile_definitions(fmilib_shared PRIVATE -D_GNU_SOURCE) endif() - target_link_libraries(fmilib_shared ${FMILIB_SHARED_SUBLIBS}) - set(FMILIB_TARGETS ${FMILIB_TARGETS} fmilib_shared) + target_link_libraries(fmilib_shared ${FMILIB_SHARED_SUBLIBS}) + set(FMILIB_TARGETS ${FMILIB_TARGETS} fmilib_shared) endif() if(FMILIB_BUILD_TESTS) - include(runtime_test) - configure_file ( - "${FMILibrary_SOURCE_DIR}/Config.cmake/config_test.h.cmake" - "${FMILibrary_BINARY_DIR}/config_test.h" - ) + include(runtime_test) + configure_file ( + "${FMILibrary_SOURCE_DIR}/Config.cmake/config_test.h.cmake" + "${FMILibrary_BINARY_DIR}/config_test.h" + ) endif() file(COPY "${FMILIBRARYHOME}/Config.cmake/fmilib.h" DESTINATION "${FMILibrary_BINARY_DIR}") install(TARGETS ${FMILIB_TARGETS} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION lib ) -install(FILES - "${FMILIBRARYHOME}/FMILIB_Readme.txt" - "${FMILIBRARYHOME}/FMILIB_License.txt" - "${FMILIBRARYHOME}/FMILIB_Acknowledgements.txt" - DESTINATION doc) - -install(FILES - "${FMILibrary_BINARY_DIR}/fmilib_config.h" - "${FMILibrary_BINARY_DIR}/fmilib.h" - DESTINATION include) - -install(DIRECTORY - ${FMIIMPORTDIR}/include - ${JMUTILDIR}/include - DESTINATION . +install(FILES + "${FMILIBRARYHOME}/FMILIB_Readme.txt" + "${FMILIBRARYHOME}/FMILIB_License.txt" + "${FMILIBRARYHOME}/FMILIB_Acknowledgements.txt" + DESTINATION doc) + +install(FILES + "${FMILibrary_BINARY_DIR}/fmilib_config.h" + "${FMILibrary_BINARY_DIR}/fmilib.h" + DESTINATION include) + +install(DIRECTORY + ${FMIIMPORTDIR}/include + ${JMUTILDIR}/include + DESTINATION . FILES_MATCHING PATTERN "*.h") if(FMILIB_INSTALL_SUBLIBS) - install(DIRECTORY - ${FMICAPIDIR}/include - ${FMIXMLDIR}/include - ${FMIZIPDIR}/include - DESTINATION . + install(DIRECTORY + ${FMICAPIDIR}/include + ${FMIXMLDIR}/include + ${FMIZIPDIR}/include + DESTINATION . FILES_MATCHING PATTERN "*.h") endif() -install(DIRECTORY - ${FMILIB_FMI_STANDARD_HEADERS}/FMI1 - ${FMILIB_FMI_STANDARD_HEADERS}/FMI2 - ${FMILIB_FMI_STANDARD_HEADERS}/FMI3 - DESTINATION include +install(DIRECTORY + ${FMILIB_FMI_STANDARD_HEADERS}/FMI1 + ${FMILIB_FMI_STANDARD_HEADERS}/FMI2 + ${FMILIB_FMI_STANDARD_HEADERS}/FMI3 + DESTINATION include FILES_MATCHING PATTERN "*.h") function(append_file_context file_out file_in) - #file(APPEND filename "message to write"... ) - #file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX]) - file(READ "${file_in}" text) - string(REGEX REPLACE "%.*%" " " text "${text}") - file(APPEND ${file_out} "${text}") - set(text "") + #file(APPEND filename "message to write"... ) + #file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX]) + file(READ "${file_in}" text) + string(REGEX REPLACE "%.*%" " " text "${text}") + file(APPEND ${file_out} "${text}") + set(text "") endfunction() if(FMILIB_GENERATE_DOXYGEN_DOC) - file(MAKE_DIRECTORY "${FMILIB_INSTALL_PREFIX}/doc") + file(MAKE_DIRECTORY "${FMILIB_INSTALL_PREFIX}/doc") + + set(DOXYFILE_IN ${FMILIBRARYHOME}/Config.cmake/fmilib_doxydoc.conf CACHE INTERNAL "Doxygen config file") + set(DOXYFILE_IMAGE_DIR "${FMILIBRARYHOME}/images" CACHE INTERNAL "Doxygen images" FORCE) - set(DOXYFILE_IN ${FMILIBRARYHOME}/Config.cmake/fmilib_doxydoc.conf CACHE INTERNAL "Doxygen config file") - set(DOXYFILE_IMAGE_DIR "${FMILIBRARYHOME}/images" CACHE INTERNAL "Doxygen images" FORCE) + file(MAKE_DIRECTORY ${FMILIBRARYBUILD}/doc) - file(MAKE_DIRECTORY ${FMILIBRARYBUILD}/doc) - - file(COPY - "${FMILIBRARYHOME}/Config.cmake/fmilib.h" - "${FMILibrary_BINARY_DIR}/fmilib_config.h" - DESTINATION ${FMILIBRARYBUILD}/doc) + file(COPY + "${FMILIBRARYHOME}/Config.cmake/fmilib.h" + "${FMILibrary_BINARY_DIR}/fmilib_config.h" + DESTINATION ${FMILIBRARYBUILD}/doc) - set(fmilib_mainpage_h "${FMILIBRARYBUILD}/doc/fmilib_mainpage.h") - file(WRITE ${fmilib_mainpage_h} "/** @file fmilib_mainpage.h \n @brief Autogenerated file with documentation. \n ") - append_file_context(${fmilib_mainpage_h} "${FMILIBRARYHOME}/FMILIB_Readme.txt" ) - append_file_context(${fmilib_mainpage_h} "${FMILIBRARYHOME}/FMILIB_License.txt" ) - append_file_context(${fmilib_mainpage_h} "${FMILIBRARYHOME}/FMILIB_Acknowledgements.txt" ) - file(APPEND ${fmilib_mainpage_h} "*/") + set(fmilib_mainpage_h "${FMILIBRARYBUILD}/doc/fmilib_mainpage.h") + file(WRITE ${fmilib_mainpage_h} "/** @file fmilib_mainpage.h \n @brief Autogenerated file with documentation. \n ") + append_file_context(${fmilib_mainpage_h} "${FMILIBRARYHOME}/FMILIB_Readme.txt" ) + append_file_context(${fmilib_mainpage_h} "${FMILIBRARYHOME}/FMILIB_License.txt" ) + append_file_context(${fmilib_mainpage_h} "${FMILIBRARYHOME}/FMILIB_Acknowledgements.txt" ) + file(APPEND ${fmilib_mainpage_h} "*/") - set(DOXYFILE_SOURCE_DIR "${FMILIBRARYBUILD}/doc" CACHE INTERNAL "Doxygen default source dir" FORCE) - set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${FMILIBRARYHOME}/Test\"") + set(DOXYFILE_SOURCE_DIR "${FMILIBRARYBUILD}/doc" CACHE INTERNAL "Doxygen default source dir" FORCE) + set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${FMILIBRARYHOME}/Test\"") - set(DOXYFILE_OUTPUT_DIR "${FMILIB_INSTALL_PREFIX}/doc") + set(DOXYFILE_OUTPUT_DIR "${FMILIB_INSTALL_PREFIX}/doc") - set(DOXYFILE_STRIP_FROM_PATH "${FMILIBRARYHOME}") + set(DOXYFILE_STRIP_FROM_PATH "${FMILIBRARYHOME}") - SET(CMAKE_MODULE_PATH ${FMILIB_THIRDPARTYLIBS}/CMakeModules) - - include(UseDoxygen/UseDoxygen) + SET(CMAKE_MODULE_PATH ${FMILIB_THIRDPARTYLIBS}/CMakeModules) + + include(UseDoxygen/UseDoxygen) endif(FMILIB_GENERATE_DOXYGEN_DOC) # Debug only: prints the final value of all the non-environment variables @@ -412,4 +412,3 @@ if (FMILIB_DEBUG_PRINT_VARIABLES_ONLY) message(STATUS "${_variableName}=${${_variableName}}") endforeach() endif() - diff --git a/Config.cmake/Minizip/CMakeLists.txt b/Config.cmake/Minizip/CMakeLists.txt index 94529156..cc141b64 100644 --- a/Config.cmake/Minizip/CMakeLists.txt +++ b/Config.cmake/Minizip/CMakeLists.txt @@ -6,12 +6,12 @@ set(BUILD_SHARED_LIBS OFF) set(SKIP_INSTALL_HEADERS ON) set(SKIP_INSTALL_FILES ON) if(NOT FMILIB_INSTALL_SUBLIBS) - set(SKIP_INSTALL_LIBRARIES ON) + set(SKIP_INSTALL_LIBRARIES ON) endif() add_subdirectory("${FMILIB_THIRDPARTYLIBS}/Zlib/zlib-1.2.6" "${FMILibrary_BINARY_DIR}/zlib") if(CMAKE_CL_64) - set_target_properties(zlib PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") + set_target_properties(zlib PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") endif() if(CMAKE_HOST_APPLE) @@ -46,7 +46,7 @@ endif(WIN32) set(HEADERS ${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/crypt.h - ${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/ioapi.h + ${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/ioapi.h ${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/miniunz.h #${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/mztools.h ${FMILIB_THIRDPARTYLIBS}/Minizip/minizip/unzip.h @@ -61,9 +61,8 @@ add_library(minizip ${SOURCE} ${HEADERS}) target_link_libraries(minizip zlib) if(FMILIB_INSTALL_SUBLIBS) - install(TARGETS minizip + install(TARGETS minizip ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - ) + LIBRARY DESTINATION lib + ) endif() - diff --git a/Config.cmake/config_fmilib.c.cmake b/Config.cmake/config_fmilib.c.cmake index af76ee53..d1a3ce55 100644 --- a/Config.cmake/config_fmilib.c.cmake +++ b/Config.cmake/config_fmilib.c.cmake @@ -16,11 +16,11 @@ #include "fmilib_config.h" const char * fmilib_build_stamp = - "Built on: " __DATE__ " " __TIME__ "\n" - "Last changed on: @FMILibrary_WC_LAST_CHANGED_DATE@\n" - "Revision: @FMILibrary_WC_REVISION@"; + "Built on: " __DATE__ " " __TIME__ "\n" + "Last changed on: @FMILibrary_WC_LAST_CHANGED_DATE@\n" + "Revision: @FMILibrary_WC_REVISION@"; - + const char* fmilib_get_build_stamp(void) { - return fmilib_build_stamp; + return fmilib_build_stamp; } \ No newline at end of file diff --git a/Config.cmake/config_fmilib.h.cmake b/Config.cmake/config_fmilib.h.cmake index 8203f419..ef40196f 100644 --- a/Config.cmake/config_fmilib.h.cmake +++ b/Config.cmake/config_fmilib.h.cmake @@ -17,14 +17,14 @@ #define CONFIG_FMILIB_H_ /** \file fmilib_config.h - \brief Library configuration file generated by the build system. + \brief Library configuration file generated by the build system. */ #ifndef WIN32 #cmakedefine WIN32 #ifdef WIN32 /** \def WIN32 - \brief WIN32 is used to identify Windows OS (set on both Win32 and Win64) + \brief WIN32 is used to identify Windows OS (set on both Win32 and Win64) */ #endif #endif @@ -32,20 +32,20 @@ #cmakedefine MINGW #ifdef MINGW /** \def MINGW - \brief MINGW is used to identify MSYS/MinGW environment + \brief MINGW is used to identify MSYS/MinGW environment */ #endif #ifndef CMAKE_INTDIR #define CMAKE_INTDIR "." /** \def CMAKE_INTDIR - \brief The macro #CMAKE_INTDIR gives intermediate directory for the current configuration (Debug/Release). + \brief The macro #CMAKE_INTDIR gives intermediate directory for the current configuration (Debug/Release). It is redefined to "." for Makefile based build environments. Otherwise is set by MSVC. */ #endif /** \brief Platform folder separator */ -#define FMI_FILE_SEP "@FMI_FILE_SEP@" +#define FMI_FILE_SEP "@FMI_FILE_SEP@" /** \brief DLL file name suffix(.so, .dll, ...) */ #define FMI_DLL_EXT "@CMAKE_SHARED_LIBRARY_SUFFIX@" @@ -71,14 +71,14 @@ It is redefined to "." for Makefile based build environments. Otherwise is set b #if 0 /* defined(__GNUC__) MSYS currently does not support visibility attribute */ #define FMILIB_EXPORT __attribute__ ((dllexport)) #else - /* Note: actually gcc seems to also supports this syntax. */ + /* Note: actually gcc seems to also supports this syntax. */ #define FMILIB_EXPORT __declspec(dllexport) #endif #else #if 0 /* defined(__GNUC__) MSYS currently does not support visibility attribute */ #define FMILIB_EXPORT __attribute__ ((dllimport)) #else - /* Note: actually gcc seems to also supports this syntax. */ + /* Note: actually gcc seems to also supports this syntax. */ #define FMILIB_EXPORT __declspec(dllimport) #endif #endif @@ -103,9 +103,9 @@ It is redefined to "." for Makefile based build environments. Otherwise is set b #endif /** \def FMILIB_EXPORT - \brief Used to declare the public API of the library needed for dynamic linking. - \def FMILIB_PRIVATE - \brief Intended for declaration of the private library functions. + \brief Used to declare the public API of the library needed for dynamic linking. + \def FMILIB_PRIVATE + \brief Intended for declaration of the private library functions. */ #cmakedefine FMILIB_ENABLE_LOG_LEVEL_DEBUG @@ -120,9 +120,9 @@ It is redefined to "." for Makefile based build environments. Otherwise is set b */ #if defined _MSC_VER - #define FMILIB_SIZET_FORMAT "%Iu" + #define FMILIB_SIZET_FORMAT "%Iu" #else - #define FMILIB_SIZET_FORMAT "%zu" + #define FMILIB_SIZET_FORMAT "%zu" #endif #cmakedefine FMILIB_GENERATE_BUILD_STAMP @@ -142,9 +142,9 @@ extern "C" { #endif /** \brief Get the library build stamp. - \return A string giving SVN revision and build time for the library. - - The function is only active if the library was configured with #FMILIB_GENERATE_BUILD_STAMP ON + \return A string giving SVN revision and build time for the library. + + The function is only active if the library was configured with #FMILIB_GENERATE_BUILD_STAMP ON */ FMILIB_EXPORT const char* fmilib_get_build_stamp(void); #ifdef __cplusplus diff --git a/Config.cmake/config_stamp.cmake b/Config.cmake/config_stamp.cmake index 02537b82..7f8b441b 100644 --- a/Config.cmake/config_stamp.cmake +++ b/Config.cmake/config_stamp.cmake @@ -3,6 +3,6 @@ Subversion_WC_INFO(${FMILIBRARYHOME} FMILibrary) message(STATUS "Generating build timestamp in ${FMILIBRARYBUILD}/config_fmilib.c") configure_file ( - "${FMILIBRARYHOME}/Config.cmake/config_fmilib.c.cmake" - "${FMILIBRARYBUILD}/config_fmilib.c" + "${FMILIBRARYHOME}/Config.cmake/config_fmilib.c.cmake" + "${FMILIBRARYBUILD}/config_fmilib.c" ) diff --git a/Config.cmake/fmicapi.cmake b/Config.cmake/fmicapi.cmake index a6a608ba..fd21e019 100644 --- a/Config.cmake/fmicapi.cmake +++ b/Config.cmake/fmicapi.cmake @@ -34,12 +34,12 @@ set(FMICAPISOURCE src/FMI3/fmi3_capi.c ) set(FMICAPIHEADERS - include/FMI1/fmi1_capi.h - src/FMI1/fmi1_capi_impl.h - include/FMI2/fmi2_capi.h - src/FMI2/fmi2_capi_impl.h - include/FMI3/fmi3_capi.h - src/FMI3/fmi3_capi_impl.h + include/FMI1/fmi1_capi.h + src/FMI1/fmi1_capi_impl.h + include/FMI2/fmi2_capi.h + src/FMI2/fmi2_capi_impl.h + include/FMI3/fmi3_capi.h + src/FMI3/fmi3_capi_impl.h ) include_directories(${FMILIB_FMI_STANDARD_HEADERS}) diff --git a/Config.cmake/fmiimport.cmake b/Config.cmake/fmiimport.cmake index 7166d777..8b0977e7 100644 --- a/Config.cmake/fmiimport.cmake +++ b/Config.cmake/fmiimport.cmake @@ -30,95 +30,95 @@ include_directories( set(FMIIMPORT_LIBRARIES fmiimport) set(FMIIMPORT_PUBHEADERS - include/FMI1/fmi1_import.h - include/FMI1/fmi1_import_capi.h - include/FMI1/fmi1_import_capabilities.h - include/FMI1/fmi1_import_cosim.h - include/FMI1/fmi1_import_type.h - include/FMI1/fmi1_import_unit.h - include/FMI1/fmi1_import_variable.h - include/FMI1/fmi1_import_variable_list.h - include/FMI1/fmi1_import_vendor_annotations.h - include/FMI1/fmi1_import_convenience.h - - include/FMI2/fmi2_import.h - include/FMI2/fmi2_import_capi.h - include/FMI2/fmi2_import_type.h - include/FMI2/fmi2_import_unit.h - include/FMI2/fmi2_import_variable.h - include/FMI2/fmi2_import_variable_list.h - include/FMI2/fmi2_import_convenience.h - - include/FMI3/fmi3_import.h - include/FMI3/fmi3_import_capi.h - include/FMI3/fmi3_import_type.h - include/FMI3/fmi3_import_unit.h - include/FMI3/fmi3_import_variable.h - include/FMI3/fmi3_import_variable_list.h - include/FMI3/fmi3_import_dimension.h - include/FMI3/fmi3_import_dimension_list.h - include/FMI3/fmi3_import_convenience.h - - include/FMI/fmi_import_context.h - include/FMI/fmi_import_options.h - include/FMI/fmi_import_util.h + include/FMI1/fmi1_import.h + include/FMI1/fmi1_import_capi.h + include/FMI1/fmi1_import_capabilities.h + include/FMI1/fmi1_import_cosim.h + include/FMI1/fmi1_import_type.h + include/FMI1/fmi1_import_unit.h + include/FMI1/fmi1_import_variable.h + include/FMI1/fmi1_import_variable_list.h + include/FMI1/fmi1_import_vendor_annotations.h + include/FMI1/fmi1_import_convenience.h + + include/FMI2/fmi2_import.h + include/FMI2/fmi2_import_capi.h + include/FMI2/fmi2_import_type.h + include/FMI2/fmi2_import_unit.h + include/FMI2/fmi2_import_variable.h + include/FMI2/fmi2_import_variable_list.h + include/FMI2/fmi2_import_convenience.h + + include/FMI3/fmi3_import.h + include/FMI3/fmi3_import_capi.h + include/FMI3/fmi3_import_type.h + include/FMI3/fmi3_import_unit.h + include/FMI3/fmi3_import_variable.h + include/FMI3/fmi3_import_variable_list.h + include/FMI3/fmi3_import_dimension.h + include/FMI3/fmi3_import_dimension_list.h + include/FMI3/fmi3_import_convenience.h + + include/FMI/fmi_import_context.h + include/FMI/fmi_import_options.h + include/FMI/fmi_import_util.h ) set(FMIIMPORT_PRIVHEADERS - src/FMI1/fmi1_import_impl.h - src/FMI1/fmi1_import_variable_list_impl.h + src/FMI1/fmi1_import_impl.h + src/FMI1/fmi1_import_variable_list_impl.h - src/FMI2/fmi2_import_impl.h - src/FMI2/fmi2_import_variable_list_impl.h + src/FMI2/fmi2_import_impl.h + src/FMI2/fmi2_import_variable_list_impl.h - src/FMI3/fmi3_import_impl.h - src/FMI3/fmi3_import_priv.h - src/FMI3/fmi3_import_variable_list_impl.h - src/FMI3/fmi3_import_dimension_list_impl.h + src/FMI3/fmi3_import_impl.h + src/FMI3/fmi3_import_priv.h + src/FMI3/fmi3_import_variable_list_impl.h + src/FMI3/fmi3_import_dimension_list_impl.h ) PREFIXLIST(FMIIMPORT_PRIVHEADERS ${FMIIMPORTDIR}/) PREFIXLIST(FMIIMPORT_PUBHEADERS ${FMIIMPORTDIR}/) set(FMIIMPORTHEADERS - ${FMIIMPORT_PUBHEADERS} ${FMIIMPORT_PRIVHEADERS} + ${FMIIMPORT_PUBHEADERS} ${FMIIMPORT_PRIVHEADERS} ) set(FMIIMPORTSOURCE - src/FMI/fmi_import_context.c - src/FMI/fmi_import_options.c - src/FMI/fmi_import_util.c - - src/FMI1/fmi1_import_cosim.c - src/FMI1/fmi1_import_capi.c - src/FMI1/fmi1_import_type.c - src/FMI1/fmi1_import_unit.c - src/FMI1/fmi1_import_variable.c - src/FMI1/fmi1_import_variable_list.c - src/FMI1/fmi1_import_vendor_annotations.c - src/FMI1/fmi1_import.c - src/FMI1/fmi1_import_capabilities.c - src/FMI1/fmi1_import_convenience.c - - src/FMI2/fmi2_import_capi.c - src/FMI2/fmi2_import_type.c - src/FMI2/fmi2_import_unit.c - src/FMI2/fmi2_import_variable.c - src/FMI2/fmi2_import_variable_list.c - src/FMI2/fmi2_import.c - src/FMI2/fmi2_import_convenience.c - - src/FMI3/fmi3_import_capi.c - src/FMI3/fmi3_import_type.c - src/FMI3/fmi3_import_unit.c - src/FMI3/fmi3_import_variable.c - src/FMI3/fmi3_import_variable_list.c - src/FMI3/fmi3_import_dimension.c - src/FMI3/fmi3_import_dimension_list.c - src/FMI3/fmi3_import.c - src/FMI3/fmi3_import_priv.c - src/FMI3/fmi3_import_convenience.c - ) + src/FMI/fmi_import_context.c + src/FMI/fmi_import_options.c + src/FMI/fmi_import_util.c + + src/FMI1/fmi1_import_cosim.c + src/FMI1/fmi1_import_capi.c + src/FMI1/fmi1_import_type.c + src/FMI1/fmi1_import_unit.c + src/FMI1/fmi1_import_variable.c + src/FMI1/fmi1_import_variable_list.c + src/FMI1/fmi1_import_vendor_annotations.c + src/FMI1/fmi1_import.c + src/FMI1/fmi1_import_capabilities.c + src/FMI1/fmi1_import_convenience.c + + src/FMI2/fmi2_import_capi.c + src/FMI2/fmi2_import_type.c + src/FMI2/fmi2_import_unit.c + src/FMI2/fmi2_import_variable.c + src/FMI2/fmi2_import_variable_list.c + src/FMI2/fmi2_import.c + src/FMI2/fmi2_import_convenience.c + + src/FMI3/fmi3_import_capi.c + src/FMI3/fmi3_import_type.c + src/FMI3/fmi3_import_unit.c + src/FMI3/fmi3_import_variable.c + src/FMI3/fmi3_import_variable_list.c + src/FMI3/fmi3_import_dimension.c + src/FMI3/fmi3_import_dimension_list.c + src/FMI3/fmi3_import.c + src/FMI3/fmi3_import_priv.c + src/FMI3/fmi3_import_convenience.c + ) PREFIXLIST(FMIIMPORTSOURCE ${FMIIMPORTDIR}/) @@ -130,8 +130,8 @@ add_dependencies(fmiimport generate_functions_import) #add_library(fmiimport_shared SHARED ${FMIIMPORTSOURCE} ${FMIIMPORTHEADERS} ) #target_link_libraries(fmiimport_shared fmiimport ${JMUTIL_LIBRARIES} ${FMIXML_LIBRARIES} ${FMIZIP_LIBRARIES} ${FMICAPI_LIBRARIES}) #install(TARGETS fmiimport_shared -# ARCHIVE DESTINATION lib -# LIBRARY DESTINATION lib -# RUNTIME DESTINATION lib +# ARCHIVE DESTINATION lib +# LIBRARY DESTINATION lib +# RUNTIME DESTINATION lib #) endif(NOT FMIIMPORTDIR) diff --git a/Config.cmake/fmixml.cmake b/Config.cmake/fmixml.cmake index 0db443f5..d895c384 100644 --- a/Config.cmake/fmixml.cmake +++ b/Config.cmake/fmixml.cmake @@ -44,10 +44,10 @@ set(FMIXMLGENDIR ${FMIXMLDIR}/src-gen) #Build BISON files set(USE_DEVELOPER_BUILD FALSE) #Enable/disable developer(debug) build if (${USE_DEVELOPER_BUILD}) - set(BISON_FMIX_COMMAND_DEBUG -v -t) - set(BISON_FMI3_OUT_DEBUG ${FMIXMLGENDIR}/FMI3/fmi3_xml_variable_name_parser.output) - set(BISON_FMI2_OUT_DEBUG ${FMIXMLGENDIR}/FMI2/fmi2_xml_variable_name_parser.output) - set(BISON_FMI1_OUT_DEBUG ${FMIXMLGENDIR}/FMI1/fmi1_xml_variable_name_parser.output) + set(BISON_FMIX_COMMAND_DEBUG -v -t) + set(BISON_FMI3_OUT_DEBUG ${FMIXMLGENDIR}/FMI3/fmi3_xml_variable_name_parser.output) + set(BISON_FMI2_OUT_DEBUG ${FMIXMLGENDIR}/FMI2/fmi2_xml_variable_name_parser.output) + set(BISON_FMI1_OUT_DEBUG ${FMIXMLGENDIR}/FMI1/fmi1_xml_variable_name_parser.output) endif() set(BISON_FMI3_SRC ${FMIXMLDIR}/src/FMI3/fmi3_xml_variable_name_parser.y) set(BISON_FMI2_SRC ${FMIXMLDIR}/src/FMI2/fmi2_xml_variable_name_parser.y) @@ -62,9 +62,9 @@ set(BISON_FMI3_OUT ${BISON_FMI3_OUT_SRC} ${BISON_FMI3_OUT_HEADERS} ${BISON_FMI3_ set(BISON_FMI2_OUT ${BISON_FMI2_OUT_SRC} ${BISON_FMI2_OUT_HEADERS} ${BISON_FMI2_OUT_DEBUG}) set(BISON_FMI1_OUT ${BISON_FMI1_OUT_SRC} ${BISON_FMI1_OUT_HEADERS} ${BISON_FMI1_OUT_DEBUG}) if (${FMILIB_BUILD_LEX_AND_PARSER_FILES}) - add_custom_command(OUTPUT ${BISON_FMI3_OUT} COMMAND ${BISON_COMMAND} ${BISON_FMIX_COMMAND_DEBUG} --no-lines -Dapi.prefix=yyfmi3 -d ${BISON_FMI3_SRC} DEPENDS ${BISON_FMI3_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI3) - add_custom_command(OUTPUT ${BISON_FMI2_OUT} COMMAND ${BISON_COMMAND} ${BISON_FMIX_COMMAND_DEBUG} --no-lines -Dapi.prefix=yyfmi2 -d ${BISON_FMI2_SRC} DEPENDS ${BISON_FMI2_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI2) - add_custom_command(OUTPUT ${BISON_FMI1_OUT} COMMAND ${BISON_COMMAND} ${BISON_FMIX_COMMAND_DEBUG} --no-lines -Dapi.prefix=yyfmi1 -d ${BISON_FMI1_SRC} DEPENDS ${BISON_FMI1_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI1) + add_custom_command(OUTPUT ${BISON_FMI3_OUT} COMMAND ${BISON_COMMAND} ${BISON_FMIX_COMMAND_DEBUG} --no-lines -Dapi.prefix=yyfmi3 -d ${BISON_FMI3_SRC} DEPENDS ${BISON_FMI3_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI3) + add_custom_command(OUTPUT ${BISON_FMI2_OUT} COMMAND ${BISON_COMMAND} ${BISON_FMIX_COMMAND_DEBUG} --no-lines -Dapi.prefix=yyfmi2 -d ${BISON_FMI2_SRC} DEPENDS ${BISON_FMI2_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI2) + add_custom_command(OUTPUT ${BISON_FMI1_OUT} COMMAND ${BISON_COMMAND} ${BISON_FMIX_COMMAND_DEBUG} --no-lines -Dapi.prefix=yyfmi1 -d ${BISON_FMI1_SRC} DEPENDS ${BISON_FMI1_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI1) endif() #Build FLEX files @@ -82,14 +82,14 @@ set(FLEX_FMI2_OPT_ARG --noline --header-file=${FLEX_FMI2_OUT_HEADERS} -Pyyfmi2) set(FLEX_FMI1_OPT_ARG --noline --header-file=${FLEX_FMI1_OUT_HEADERS} -Pyyfmi1) if (CMAKE_HOST_WIN32) - set(FLEX_FMI3_OPT_ARG ${FLEX_FMI3_OPT_ARG}) - set(FLEX_FMI2_OPT_ARG ${FLEX_FMI2_OPT_ARG}) - set(FLEX_FMI1_OPT_ARG ${FLEX_FMI1_OPT_ARG}) + set(FLEX_FMI3_OPT_ARG ${FLEX_FMI3_OPT_ARG}) + set(FLEX_FMI2_OPT_ARG ${FLEX_FMI2_OPT_ARG}) + set(FLEX_FMI1_OPT_ARG ${FLEX_FMI1_OPT_ARG}) endif() if (${FMILIB_BUILD_LEX_AND_PARSER_FILES}) - add_custom_command(OUTPUT ${FLEX_FMI3_OUT_SRC} ${FLEX_FMI3_OUT_HEADERS} COMMAND ${FLEX_COMMAND} ${FLEX_FMI3_OPT_ARG} ${FLEX_FMI3_SRC} DEPENDS ${BISON_FMI3_OUT} ${FLEX_FMI3_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI3) - add_custom_command(OUTPUT ${FLEX_FMI2_OUT_SRC} ${FLEX_FMI2_OUT_HEADERS} COMMAND ${FLEX_COMMAND} ${FLEX_FMI2_OPT_ARG} ${FLEX_FMI2_SRC} DEPENDS ${BISON_FMI2_OUT} ${FLEX_FMI2_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI2) - add_custom_command(OUTPUT ${FLEX_FMI1_OUT_SRC} ${FLEX_FMI1_OUT_HEADERS} COMMAND ${FLEX_COMMAND} ${FLEX_FMI1_OPT_ARG} ${FLEX_FMI1_SRC} DEPENDS ${BISON_FMI1_OUT} ${FLEX_FMI1_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI1) + add_custom_command(OUTPUT ${FLEX_FMI3_OUT_SRC} ${FLEX_FMI3_OUT_HEADERS} COMMAND ${FLEX_COMMAND} ${FLEX_FMI3_OPT_ARG} ${FLEX_FMI3_SRC} DEPENDS ${BISON_FMI3_OUT} ${FLEX_FMI3_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI3) + add_custom_command(OUTPUT ${FLEX_FMI2_OUT_SRC} ${FLEX_FMI2_OUT_HEADERS} COMMAND ${FLEX_COMMAND} ${FLEX_FMI2_OPT_ARG} ${FLEX_FMI2_SRC} DEPENDS ${BISON_FMI2_OUT} ${FLEX_FMI2_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI2) + add_custom_command(OUTPUT ${FLEX_FMI1_OUT_SRC} ${FLEX_FMI1_OUT_HEADERS} COMMAND ${FLEX_COMMAND} ${FLEX_FMI1_OPT_ARG} ${FLEX_FMI1_SRC} DEPENDS ${BISON_FMI1_OUT} ${FLEX_FMI1_SRC} WORKING_DIRECTORY ${FMIXMLGENDIR}/FMI1) endif() if(WIN32) @@ -106,8 +106,8 @@ set(FMIXML_LIBRARIES fmixml) set(FMIXML_EXPAT_DIR "${FMILIB_THIRDPARTYLIBS}/Expat/expat-2.4.8") set(FMIXMLHEADERS - include/FMI/fmi_xml_context.h - src/FMI/fmi_xml_context_impl.h + include/FMI/fmi_xml_context.h + src/FMI/fmi_xml_context_impl.h include/FMI1/fmi1_xml_model_description.h src/FMI1/fmi1_xml_model_description_impl.h @@ -151,7 +151,7 @@ set(FMIXMLHEADERS ) set(FMIXMLSOURCE - src/FMI/fmi_xml_context.c + src/FMI/fmi_xml_context.c src/FMI1/fmi1_xml_parser.c src/FMI1/fmi1_xml_model_description.c @@ -167,17 +167,17 @@ set(FMIXMLSOURCE src/FMI2/fmi2_xml_model_structure.c src/FMI2/fmi2_xml_type.c src/FMI2/fmi2_xml_unit.c - src/FMI2/fmi2_xml_vendor_annotations.c - src/FMI2/fmi2_xml_variable.c + src/FMI2/fmi2_xml_vendor_annotations.c + src/FMI2/fmi2_xml_variable.c src/FMI3/fmi3_xml_parser.c src/FMI3/fmi3_xml_model_description.c src/FMI3/fmi3_xml_model_structure.c src/FMI3/fmi3_xml_type.c src/FMI3/fmi3_xml_unit.c - src/FMI3/fmi3_xml_vendor_annotations.c - src/FMI3/fmi3_xml_variable.c - src/FMI3/fmi3_xml_dimension.c + src/FMI3/fmi3_xml_vendor_annotations.c + src/FMI3/fmi3_xml_variable.c + src/FMI3/fmi3_xml_dimension.c ) include(ExternalProject) @@ -207,24 +207,24 @@ set(EXPAT_SETTINGS ) ExternalProject_Add( - expatex - PREFIX "${FMIXML_EXPAT_DIR}" - SOURCE_DIR "${FMIXML_EXPAT_DIR}" - CMAKE_CACHE_ARGS ${EXPAT_SETTINGS} - BINARY_DIR ${CMAKE_BINARY_DIR}/ExpatEx - INSTALL_DIR ${CMAKE_BINARY_DIR}/ExpatEx/install - TMP_DIR ${CMAKE_BINARY_DIR}/ExpatEx/tmp + expatex + PREFIX "${FMIXML_EXPAT_DIR}" + SOURCE_DIR "${FMIXML_EXPAT_DIR}" + CMAKE_CACHE_ARGS ${EXPAT_SETTINGS} + BINARY_DIR ${CMAKE_BINARY_DIR}/ExpatEx + INSTALL_DIR ${CMAKE_BINARY_DIR}/ExpatEx/install + TMP_DIR ${CMAKE_BINARY_DIR}/ExpatEx/tmp STAMP_DIR ${CMAKE_BINARY_DIR}/ExpatEx/stamp ) ExternalProject_Add_Step( - expatex dependent_reconfigure - DEPENDEES configure - DEPENDERS build - COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_COMMAND} -G \"${CMAKE_GENERATOR}\" ${EXPAT_SETTINGS} ${FMIXML_EXPAT_DIR}" - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${EXPAT_SETTINGS} "${FMIXML_EXPAT_DIR}" - DEPENDS ${CMAKE_BINARY_DIR}/CMakeCache.txt - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ExpatEx + expatex dependent_reconfigure + DEPENDEES configure + DEPENDERS build + COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_COMMAND} -G \"${CMAKE_GENERATOR}\" ${EXPAT_SETTINGS} ${FMIXML_EXPAT_DIR}" + COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${EXPAT_SETTINGS} "${FMIXML_EXPAT_DIR}" + DEPENDS ${CMAKE_BINARY_DIR}/CMakeCache.txt + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ExpatEx ) add_dependencies(expatex ${CMAKE_BINARY_DIR}/CMakeCache.txt ${FMILIBRARYHOME}/CMakeLists.txt) @@ -242,16 +242,16 @@ set(expatlib "${CMAKE_BINARY_DIR}/ExpatEx/${CMAKE_CFG_INTDIR}/${EXPAT_LIB_PREFIX add_library(expat STATIC IMPORTED) set_target_properties( - expat PROPERTIES - IMPORTED_LOCATION "${expatlib}" + expat PROPERTIES + IMPORTED_LOCATION "${expatlib}" ) add_dependencies(expat expatex) if(FMILIB_INSTALL_SUBLIBS) - install(FILES - "${CMAKE_BINARY_DIR}/ExpatEx/install/lib/${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}" - DESTINATION lib) + install(FILES + "${CMAKE_BINARY_DIR}/ExpatEx/install/lib/${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}" + DESTINATION lib) endif() set(EXPAT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ExpatEx/install/include) diff --git a/Config.cmake/fmizip.cmake b/Config.cmake/fmizip.cmake index 091fc4d8..6026ccf1 100644 --- a/Config.cmake/fmizip.cmake +++ b/Config.cmake/fmizip.cmake @@ -13,16 +13,16 @@ if(NOT FMIZIPDIR) set(FMIZIPDIR ${FMILIBRARYHOME}/src/ZIP) - + include(jmutil) - - # set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${FMIZIPDIR}/include\"") + + # set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${FMIZIPDIR}/include\"") set(FMIZIP_LIBRARIES fmizip) - + add_subdirectory(Config.cmake/Minizip) - - include_directories("${FMIZIPDIR}/include" "${FMILIB_THIRDPARTYLIBS}/Minizip/minizip" "${FMILIB_THIRDPARTYLIBS}/FMI" "${FMILIB_THIRDPARTYLIBS}/Zlib/zlib-1.2.6" "${FMILibrary_BINARY_DIR}/zlib") + + include_directories("${FMIZIPDIR}/include" "${FMILIB_THIRDPARTYLIBS}/Minizip/minizip" "${FMILIB_THIRDPARTYLIBS}/FMI" "${FMILIB_THIRDPARTYLIBS}/Zlib/zlib-1.2.6" "${FMILibrary_BINARY_DIR}/zlib") set(FMIZIPSOURCE ${FMIZIPDIR}/src/fmi_zip_unzip.c diff --git a/Config.cmake/jmutil.cmake b/Config.cmake/jmutil.cmake index 91daea88..94e1e033 100644 --- a/Config.cmake/jmutil.cmake +++ b/Config.cmake/jmutil.cmake @@ -15,7 +15,7 @@ if(NOT JMUTILDIR) set(JMUTILDIR ${FMILIBRARYHOME}/src/Util/) set(JMUTIL_LIBRARIES jmutils) include_directories ("${JMUTILDIR}/include" "${FMILIB_FMI_STANDARD_HEADERS}") - set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${JMUTILDIR}/include\"") + set(DOXYFILE_EXTRA_SOURCES "${DOXYFILE_EXTRA_SOURCES} \"${JMUTILDIR}/include\"") set(JMUTILSOURCE JM/jm_callbacks.c @@ -86,10 +86,10 @@ if(UNIX AND NOT APPLE) endif() if(UNIX) - target_link_libraries(jmutils dl) + target_link_libraries(jmutils dl) endif(UNIX) if(WIN32) - target_link_libraries(jmutils Shlwapi) + target_link_libraries(jmutils Shlwapi) endif(WIN32) endif(NOT JMUTILDIR) diff --git a/Config.cmake/mergestaticlibs.cmake b/Config.cmake/mergestaticlibs.cmake index 28ed287e..966f73b1 100644 --- a/Config.cmake/mergestaticlibs.cmake +++ b/Config.cmake/mergestaticlibs.cmake @@ -14,116 +14,116 @@ # Merge_static_libs(outlib lib1 lib2 ... libn) merges a number of static # libs into a single static library function(merge_static_libs outlib ) - set(libs ${ARGV}) - list(REMOVE_AT libs 0) + set(libs ${ARGV}) + list(REMOVE_AT libs 0) # Create a dummy file that the target will depend on - set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/${outlib}_dummy.c) - file(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";") - - add_library(${outlib} STATIC ${dummyfile}) + set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/${outlib}_dummy.c) + file(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";") + + add_library(${outlib} STATIC ${dummyfile}) - if("${CMAKE_CFG_INTDIR}" STREQUAL ".") - set(multiconfig FALSE) - else() - set(multiconfig TRUE) - endif() - -# First get the file names of the libraries to be merged - foreach(lib ${libs}) - get_target_property(libtype ${lib} TYPE) - if(NOT libtype STREQUAL "STATIC_LIBRARY") - message(FATAL_ERROR "Merge_static_libs can only process static libraries") - endif() - if(multiconfig) - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - get_target_property("libfile_${CONFIG_TYPE}" ${lib} "LOCATION_${CONFIG_TYPE}") - list(APPEND libfiles_${CONFIG_TYPE} ${libfile_${CONFIG_TYPE}}) - endforeach() - else() - get_target_property(libfile ${lib} LOCATION) - list(APPEND libfiles "${libfile}") - endif(multiconfig) - endforeach() - message(STATUS "will be merging ${libfiles}") + if("${CMAKE_CFG_INTDIR}" STREQUAL ".") + set(multiconfig FALSE) + else() + set(multiconfig TRUE) + endif() + +# First get the file names of the libraries to be merged + foreach(lib ${libs}) + get_target_property(libtype ${lib} TYPE) + if(NOT libtype STREQUAL "STATIC_LIBRARY") + message(FATAL_ERROR "Merge_static_libs can only process static libraries") + endif() + if(multiconfig) + foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + get_target_property("libfile_${CONFIG_TYPE}" ${lib} "LOCATION_${CONFIG_TYPE}") + list(APPEND libfiles_${CONFIG_TYPE} ${libfile_${CONFIG_TYPE}}) + endforeach() + else() + get_target_property(libfile ${lib} LOCATION) + list(APPEND libfiles "${libfile}") + endif(multiconfig) + endforeach() + message(STATUS "will be merging ${libfiles}") # Just to be sure: cleanup from duplicates - if(multiconfig) - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - list(REMOVE_DUPLICATES libfiles_${CONFIG_TYPE}) - set(libfiles ${libfiles} ${libfiles_${CONFIG_TYPE}}) - endforeach() - endif() - list(REMOVE_DUPLICATES libfiles) + if(multiconfig) + foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + list(REMOVE_DUPLICATES libfiles_${CONFIG_TYPE}) + set(libfiles ${libfiles} ${libfiles_${CONFIG_TYPE}}) + endforeach() + endif() + list(REMOVE_DUPLICATES libfiles) # Now the easy part for MSVC and for MAC if(MSVC) # lib.exe does the merging of libraries just need to conver the list into string - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - set(flags "") - foreach(lib ${libfiles_${CONFIG_TYPE}}) - set(flags "${flags} ${lib}") - endforeach() - string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) - set_target_properties(${outlib} PROPERTIES ${PROPNAME} "${flags}") - endforeach() - + foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + set(flags "") + foreach(lib ${libfiles_${CONFIG_TYPE}}) + set(flags "${flags} ${lib}") + endforeach() + string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) + set_target_properties(${outlib} PROPERTIES ${PROPNAME} "${flags}") + endforeach() + elseif(APPLE) # Use OSX's libtool to merge archives - if(multiconfig) - message(FATAL_ERROR "Multiple configurations are not supported") - endif() - get_target_property(outfile ${outlib} LOCATION) - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND rm ${outfile} - COMMAND /usr/bin/libtool -static -o ${outfile} - ${libfiles} - ) + if(multiconfig) + message(FATAL_ERROR "Multiple configurations are not supported") + endif() + get_target_property(outfile ${outlib} LOCATION) + add_custom_command(TARGET ${outlib} POST_BUILD + COMMAND rm ${outfile} + COMMAND /usr/bin/libtool -static -o ${outfile} + ${libfiles} + ) else() # general UNIX - need to "ar -x" and then "ar -ru" - if(multiconfig) - message(FATAL_ERROR "Multiple configurations are not supported") - endif() - get_target_property(outfile ${outlib} LOCATION) - message(STATUS "outfile location is ${outfile}") - foreach(lib ${libfiles}) + if(multiconfig) + message(FATAL_ERROR "Multiple configurations are not supported") + endif() + get_target_property(outfile ${outlib} LOCATION) + message(STATUS "outfile location is ${outfile}") + foreach(lib ${libfiles}) # objlistfile will contain the list of object files for the library - set(objlistfile ${lib}.objlist) - set(objdir ${lib}.objdir) - set(objlistcmake ${objlistfile}.cmake) + set(objlistfile ${lib}.objlist) + set(objdir ${lib}.objdir) + set(objlistcmake ${objlistfile}.cmake) # we only need to extract files once - if(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake.check_cache IS_NEWER_THAN ${objlistcmake}) -#--------------------------------- - FILE(WRITE ${objlistcmake} + if(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake.check_cache IS_NEWER_THAN ${objlistcmake}) +#--------------------------------- + FILE(WRITE ${objlistcmake} "# Extract object files from the library message(STATUS \"Extracting object files from ${lib}\") EXECUTE_PROCESS(COMMAND ${CMAKE_AR} -x ${lib} WORKING_DIRECTORY ${objdir}) # save the list of object files EXECUTE_PROCESS(COMMAND ls . - OUTPUT_FILE ${objlistfile} + OUTPUT_FILE ${objlistfile} WORKING_DIRECTORY ${objdir})") -#--------------------------------- - file(MAKE_DIRECTORY ${objdir}) - add_custom_command( - OUTPUT ${objlistfile} - COMMAND ${CMAKE_COMMAND} -P ${objlistcmake} - DEPENDS ${lib}) - endif() - list(APPEND extrafiles "${objlistfile}") - # relative path is needed by ar under MSYS - file(RELATIVE_PATH objlistfilerpath ${objdir} ${objlistfile}) - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_AR} ru ${outfile} @${objlistfilerpath}" - COMMAND ${CMAKE_AR} ru "${outfile}" @"${objlistfilerpath}" - WORKING_DIRECTORY ${objdir}) - endforeach() - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_RANLIB} ${outfile}" - COMMAND ${CMAKE_RANLIB} ${outfile}) +#--------------------------------- + file(MAKE_DIRECTORY ${objdir}) + add_custom_command( + OUTPUT ${objlistfile} + COMMAND ${CMAKE_COMMAND} -P ${objlistcmake} + DEPENDS ${lib}) + endif() + list(APPEND extrafiles "${objlistfile}") + # relative path is needed by ar under MSYS + file(RELATIVE_PATH objlistfilerpath ${objdir} ${objlistfile}) + add_custom_command(TARGET ${outlib} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_AR} ru ${outfile} @${objlistfilerpath}" + COMMAND ${CMAKE_AR} ru "${outfile}" @"${objlistfilerpath}" + WORKING_DIRECTORY ${objdir}) + endforeach() + add_custom_command(TARGET ${outlib} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_RANLIB} ${outfile}" + COMMAND ${CMAKE_RANLIB} ${outfile}) endif() file(WRITE ${dummyfile}.base "const char* ${outlib}_sublibs=\"${libs}\";") add_custom_command( - OUTPUT ${dummyfile} - COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile} - DEPENDS ${libs} ${extrafiles}) + OUTPUT ${dummyfile} + COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile} + DEPENDS ${libs} ${extrafiles}) endfunction() \ No newline at end of file diff --git a/Config.cmake/test_fmi1.cmake b/Config.cmake/test_fmi1.cmake index 564876a5..7ab623a3 100644 --- a/Config.cmake/test_fmi1.cmake +++ b/Config.cmake/test_fmi1.cmake @@ -56,9 +56,9 @@ to_native_c_path("\"${SHARED_LIBRARY_ME_PATH}\"" DLL_OUTPUT_PATH_ME_DEFINE) to_native_c_path("\"${SHARED_LIBRARY_CS_PATH}\"" DLL_OUTPUT_PATH_CS_DEFINE) to_native_c_path("\"${CMAKE_CURRENT_BINARY_DIR}/\" CMAKE_INTDIR \"/${CMAKE_SHARED_LIBRARY_PREFIX}fmu1_dll_me${CMAKE_SHARED_LIBRARY_SUFFIX}\"" - FMU1_DLL_ME_PATH) + FMU1_DLL_ME_PATH) to_native_c_path("\"${CMAKE_CURRENT_BINARY_DIR}/\" CMAKE_INTDIR \"/${CMAKE_SHARED_LIBRARY_PREFIX}fmu1_dll_cs${CMAKE_SHARED_LIBRARY_SUFFIX}\"" - FMU1_DLL_CS_PATH) + FMU1_DLL_CS_PATH) #function(compress_fmu OUTPUT_FOLDER MODEL_IDENTIFIER FILE_NAME_CS_ME_EXT TARGET_NAME XML_PATH SHARED_LIBRARY_PATH) compress_fmu("${TEST_OUTPUT_FOLDER}" "${FMU_DUMMY_MF_MODEL_IDENTIFIER}" "mf" "fmu1_dll_me" "${XML_MF_PATH}" "${SHARED_LIBRARY_ME_PATH}") @@ -134,26 +134,26 @@ if(NOT CMAKE_GENERATOR STREQUAL "MSYS Makefiles") PROPERTIES DEPENDS ctest_fmi1_logger_test_run ) - # 'ctest_build_all' must also skip memcheck, but it needs to run before all - # other tests, so just calling it first by name in the linux makefile wrapper - SET_TESTS_PROPERTIES ( - ctest_fmi1_logger_test_check - PROPERTIES LABELS skip_memcheck - ) - - SET_TESTS_PROPERTIES ( - ctest_fmi1_logger_test_check - PROPERTIES DEPENDS ctest_fmi1_logger_test_run - ) + # 'ctest_build_all' must also skip memcheck, but it needs to run before all + # other tests, so just calling it first by name in the linux makefile wrapper + SET_TESTS_PROPERTIES ( + ctest_fmi1_logger_test_check + PROPERTIES LABELS skip_memcheck + ) + + SET_TESTS_PROPERTIES ( + ctest_fmi1_logger_test_check + PROPERTIES DEPENDS ctest_fmi1_logger_test_run + ) endif() set_target_properties( - fmi_import_me_test - fmi_import_cs_test - fmi_import_xml_test - fmi1_capi_cs_test - fmi1_capi_me_test - fmi1_logger_test + fmi_import_me_test + fmi_import_cs_test + fmi_import_xml_test + fmi1_capi_cs_test + fmi1_capi_me_test + fmi1_logger_test fmi1_xml_parsing_test fmi1_import_default_experiment_test fmi1_import_options_test @@ -164,22 +164,22 @@ set_target_properties( if(FMILIB_BUILD_BEFORE_TESTS) - SET_TESTS_PROPERTIES ( - ctest_fmi_import_me_test - ctest_fmi_import_cs_test - ctest_fmi_import_xml_test - ctest_fmi_import_xml_test_empty - ctest_fmi_import_xml_test_mf - ctest_fmi1_capi_cs_test - ctest_fmi1_capi_me_test - ctest_fmi1_logger_test_run - ctest_fmi1_xml_parsing_test + SET_TESTS_PROPERTIES ( + ctest_fmi_import_me_test + ctest_fmi_import_cs_test + ctest_fmi_import_xml_test + ctest_fmi_import_xml_test_empty + ctest_fmi_import_xml_test_mf + ctest_fmi1_capi_cs_test + ctest_fmi1_capi_me_test + ctest_fmi1_logger_test_run + ctest_fmi1_xml_parsing_test ctest_fmi1_type_definitions_test ctest_fmi1_variable_bad_type_variability_test - PROPERTIES DEPENDS ctest_build_all) + PROPERTIES DEPENDS ctest_build_all) endif() SET_TESTS_PROPERTIES ( - ctest_fmi_import_xml_test - PROPERTIES DEPENDS ctest_fmi_import_cs_test + ctest_fmi_import_xml_test + PROPERTIES DEPENDS ctest_fmi_import_cs_test ) diff --git a/Test/FMI1/compress_test_fmu_zip.c b/Test/FMI1/compress_test_fmu_zip.c index 58e1f2f8..a05e2298 100644 --- a/Test/FMI1/compress_test_fmu_zip.c +++ b/Test/FMI1/compress_test_fmu_zip.c @@ -26,38 +26,38 @@ static void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t l int main(int argc, char *argv[]) { - jm_status_enu_t status; - jm_callbacks callbacks; - char* output_name; - const char** files_to_zip; - int n_files_to_zip; + jm_status_enu_t status; + jm_callbacks callbacks; + char* output_name; + const char** files_to_zip; + int n_files_to_zip; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; - if (argc < 3) { - printf("Not enought input arguments\n"); - return 1; - } + if (argc < 3) { + printf("Not enought input arguments\n"); + return 1; + } - output_name = argv[1]; - files_to_zip = &argv[2]; - n_files_to_zip = argc - 2; + output_name = argv[1]; + files_to_zip = &argv[2]; + n_files_to_zip = argc - 2; - status = fmi_zip_zip(output_name, n_files_to_zip, files_to_zip, &callbacks); + status = fmi_zip_zip(output_name, n_files_to_zip, files_to_zip, &callbacks); - if (status == jm_status_error) { - printf("Failed to compress the file\n"); - return 1; - } else { - printf("Succesfully compressed the file\n"); - return 0; - } - + if (status == jm_status_error) { + printf("Failed to compress the file\n"); + return 1; + } else { + printf("Succesfully compressed the file\n"); + return 0; + } + } \ No newline at end of file diff --git a/Test/FMI1/fmi1_capi_cs_test.c b/Test/FMI1/fmi1_capi_cs_test.c index b4a25824..acba64e5 100644 --- a/Test/FMI1/fmi1_capi_cs_test.c +++ b/Test/FMI1/fmi1_capi_cs_test.c @@ -32,7 +32,7 @@ #define MODEL_IDENTIFIER FMU_DUMMY_CS_MODEL_IDENTIFIER /* #define PRINT_VERBOSE */ -#define INSTANCE_NAME "Test Model" +#define INSTANCE_NAME "Test Model" fmi1_capi_t* fmu; /* Pointer to the C-API struct that is used in all tests */ @@ -45,12 +45,12 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve /* Logger function used by the FMU internally */ void fmilogger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...) { - char msg[BUFFER]; + char msg[BUFFER]; int len; - va_list argp; - va_start(argp, message); - len=jm_vsnprintf(msg, BUFFER, message, argp); - printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); + va_list argp; + va_start(argp, message); + len=jm_vsnprintf(msg, BUFFER, message, argp); + printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); if(len > BUFFER) { printf("Warning: message was trancated"); } @@ -59,9 +59,9 @@ void fmilogger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t sta /* Pause and exit function. Useally called when an error occured */ void do_exit(int code) { - printf("Press any key to exit\n"); - /* getchar(); */ - exit(code); + printf("Press any key to exit\n"); + /* getchar(); */ + exit(code); } jm_callbacks* callbacks = 0; @@ -72,12 +72,12 @@ jm_callbacks* callbacks = 0; */ int test_create_dllfmu() { - fmi1_callback_functions_t callBackFunctions; - fmi1_fmu_kind_enu_t standard = fmi1_fmu_kind_enu_cs_standalone; + fmi1_callback_functions_t callBackFunctions; + fmi1_fmu_kind_enu_t standard = fmi1_fmu_kind_enu_cs_standalone; - callbacks = calloc(1, sizeof(jm_callbacks)); + callbacks = calloc(1, sizeof(jm_callbacks)); - callbacks->malloc = malloc; + callbacks->malloc = malloc; callbacks->calloc = calloc; callbacks->realloc = realloc; callbacks->free = free; @@ -85,19 +85,19 @@ int test_create_dllfmu() callbacks->log_level = jm_log_level_debug; callbacks->context = 0; - callBackFunctions.logger = fmilogger; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; - - printf("fmi1_capi_create_dllfmu: "); - fmu = fmi1_capi_create_dllfmu(callbacks, FMU1_DLL_CS_PATH, MODEL_IDENTIFIER_STR, callBackFunctions, standard); - if (fmu == NULL) { - printf("An error occured while fmi1_capi_create_dllfmu was called, an error message should been printed.\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + callBackFunctions.logger = fmilogger; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; + + printf("fmi1_capi_create_dllfmu: "); + fmu = fmi1_capi_create_dllfmu(callbacks, FMU1_DLL_CS_PATH, MODEL_IDENTIFIER_STR, callBackFunctions, standard); + if (fmu == NULL) { + printf("An error occured while fmi1_capi_create_dllfmu was called, an error message should been printed.\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -108,15 +108,15 @@ int test_load_dll() { jm_status_enu_t status; - printf("fmi1_capi_load_dll: "); - status = fmi1_capi_load_dll(fmu); - if (status == jm_status_error) { - printf("Error in fmi1_capi_load_dll: %s\n", jm_get_last_error(callbacks)); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + printf("fmi1_capi_load_dll: "); + status = fmi1_capi_load_dll(fmu); + if (status == jm_status_error) { + printf("Error in fmi1_capi_load_dll: %s\n", jm_get_last_error(callbacks)); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -125,18 +125,18 @@ int test_load_dll() */ int test_load_dll_fcn() { - jm_status_enu_t status; - - printf("fmi1_capi_load_fcn: "); - status = fmi1_capi_load_fcn(fmu); - if (status == jm_status_error) { - printf("\n"); - printf("Error in fmi1_capi_load_fcn: %s\n", "fmi1_capi_get_last_error(fmu)"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + jm_status_enu_t status; + + printf("fmi1_capi_load_fcn: "); + status = fmi1_capi_load_fcn(fmu); + if (status == jm_status_error) { + printf("\n"); + printf("Error in fmi1_capi_load_fcn: %s\n", "fmi1_capi_get_last_error(fmu)"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -145,16 +145,16 @@ int test_load_dll_fcn() */ int test_fmi_get_version() { - const char* version = fmi1_capi_get_version(fmu); - - printf("fmi1_capi_get_version: "); - if (strcmp(FMI_VERSION, version) != 0) { - printf("Expected \"%s\" but returned \"%s\"", FMI_VERSION, version); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + const char* version = fmi1_capi_get_version(fmu); + + printf("fmi1_capi_get_version: "); + if (strcmp(FMI_VERSION, version) != 0) { + printf("Expected \"%s\" but returned \"%s\"", FMI_VERSION, version); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -163,16 +163,16 @@ int test_fmi_get_version() */ int test_get_types_platform() { - const char* platformtype = fmi1_capi_get_types_platform(fmu); - - printf("fmi1_capi_get_types_platform: "); - if (strcmp(FMI_PLATFORM_TYPE, platformtype) != 0) { - printf("Expected \"%s\" but returned \"%s\"", FMI_PLATFORM_TYPE, platformtype); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + const char* platformtype = fmi1_capi_get_types_platform(fmu); + + printf("fmi1_capi_get_types_platform: "); + if (strcmp(FMI_PLATFORM_TYPE, platformtype) != 0) { + printf("Expected \"%s\" but returned \"%s\"", FMI_PLATFORM_TYPE, platformtype); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -181,27 +181,27 @@ int test_get_types_platform() */ int test_instantiate_slave() { - fmi1_string_t fmuLocation; - fmi1_string_t mimeType; - fmi1_real_t timeout; - fmi1_boolean_t visible; - fmi1_boolean_t interactive; - fmi1_boolean_t loggingOn; - - fmuLocation = ""; - mimeType = ""; - timeout = 0; - visible = fmi1_false; - interactive = fmi1_false; - loggingOn = fmi1_true; - - if (fmi1_capi_instantiate_slave(fmu, INSTANCE_NAME, FMI_GUID, fmuLocation, mimeType, timeout, visible, interactive, loggingOn) == NULL) { - printf("fmi1_capi_instantiate_slave: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_instantiate_slave: Success\n"); - } - return 0; + fmi1_string_t fmuLocation; + fmi1_string_t mimeType; + fmi1_real_t timeout; + fmi1_boolean_t visible; + fmi1_boolean_t interactive; + fmi1_boolean_t loggingOn; + + fmuLocation = ""; + mimeType = ""; + timeout = 0; + visible = fmi1_false; + interactive = fmi1_false; + loggingOn = fmi1_true; + + if (fmi1_capi_instantiate_slave(fmu, INSTANCE_NAME, FMI_GUID, fmuLocation, mimeType, timeout, visible, interactive, loggingOn) == NULL) { + printf("fmi1_capi_instantiate_slave: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_instantiate_slave: Success\n"); + } + return 0; } /** @@ -211,22 +211,22 @@ int test_instantiate_slave() int test_initialize_slave() { fmi1_status_t status; - fmi1_real_t tStart; - fmi1_real_t tStop; - fmi1_boolean_t StopTimeDefined; - - tStart = 0; - tStop = 10; - StopTimeDefined = fmi1_false; - - status = fmi1_capi_initialize_slave(fmu, tStart, StopTimeDefined, tStop); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_initialize_slave: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_initialize_slave: Success\n"); - } - return 0; + fmi1_real_t tStart; + fmi1_real_t tStop; + fmi1_boolean_t StopTimeDefined; + + tStart = 0; + tStop = 10; + StopTimeDefined = fmi1_false; + + status = fmi1_capi_initialize_slave(fmu, tStart, StopTimeDefined, tStop); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_initialize_slave: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_initialize_slave: Success\n"); + } + return 0; } /** @@ -236,14 +236,14 @@ int test_initialize_slave() int test_set_debug_logging() { fmi1_status_t status; - status = fmi1_capi_set_debug_logging(fmu, fmi1_true); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_debug_logging: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_debug_logging: Success\n"); - } - return 0; + status = fmi1_capi_set_debug_logging(fmu, fmi1_true); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_debug_logging: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_debug_logging: Success\n"); + } + return 0; } /** @@ -253,14 +253,14 @@ int test_set_debug_logging() int test_cancel_step() { fmi1_status_t status; - status = fmi1_capi_cancel_step(fmu); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_cancel_step: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_cancel_step: Success\n"); - } - return 0; + status = fmi1_capi_cancel_step(fmu); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_cancel_step: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_cancel_step: Success\n"); + } + return 0; } /** @@ -270,21 +270,21 @@ int test_cancel_step() int test_do_step() { fmi1_status_t status; - fmi1_real_t currentCommunicationPoint; - fmi1_real_t communicationStepSize; - fmi1_boolean_t newStep; - - currentCommunicationPoint = 0; - communicationStepSize = 0.1; - newStep = fmi1_true; - status = fmi1_capi_do_step(fmu, currentCommunicationPoint, communicationStepSize, newStep); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_do_step: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_do_step: Success\n"); - } - return 0; + fmi1_real_t currentCommunicationPoint; + fmi1_real_t communicationStepSize; + fmi1_boolean_t newStep; + + currentCommunicationPoint = 0; + communicationStepSize = 0.1; + newStep = fmi1_true; + status = fmi1_capi_do_step(fmu, currentCommunicationPoint, communicationStepSize, newStep); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_do_step: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_do_step: Success\n"); + } + return 0; } /** @@ -294,18 +294,18 @@ int test_do_step() int test_get_status() { fmi1_status_t status; - fmi1_status_kind_t statuskind; - fmi1_status_t statusvalue; - - statuskind = fmi1_do_step_status; - status = fmi1_capi_get_status(fmu, statuskind, &statusvalue); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_status: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_status: Success\n"); - } - return 0; + fmi1_status_kind_t statuskind; + fmi1_status_t statusvalue; + + statuskind = fmi1_do_step_status; + status = fmi1_capi_get_status(fmu, statuskind, &statusvalue); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_status: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_status: Success\n"); + } + return 0; } /** @@ -315,17 +315,17 @@ int test_get_status() int test_get_real_status() { fmi1_status_t status; - fmi1_status_kind_t statuskind = fmi1_last_successful_time; - fmi1_real_t real; - - status = fmi1_capi_get_real_status(fmu, statuskind, &real); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_real_status: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_real_status: Success\n"); - } - return 0; + fmi1_status_kind_t statuskind = fmi1_last_successful_time; + fmi1_real_t real; + + status = fmi1_capi_get_real_status(fmu, statuskind, &real); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_real_status: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_real_status: Success\n"); + } + return 0; } /** @@ -335,17 +335,17 @@ int test_get_real_status() int test_get_integer_status() { fmi1_status_t status; - fmi1_status_kind_t statuskind = fmi1_last_successful_time; - fmi1_integer_t integer; - - status = fmi1_capi_get_integer_status(fmu, statuskind, &integer); - if (status != fmi1_status_discard) { - printf("fmi1_capi_get_integer_status: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_integer_status: Success\n"); - } - return 0; + fmi1_status_kind_t statuskind = fmi1_last_successful_time; + fmi1_integer_t integer; + + status = fmi1_capi_get_integer_status(fmu, statuskind, &integer); + if (status != fmi1_status_discard) { + printf("fmi1_capi_get_integer_status: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_integer_status: Success\n"); + } + return 0; } /** @@ -355,17 +355,17 @@ int test_get_integer_status() int test_get_boolean_status() { fmi1_status_t status; - fmi1_status_kind_t statuskind = fmi1_last_successful_time; - fmi1_boolean_t boolean; - - status = fmi1_capi_get_boolean_status(fmu, statuskind, &boolean); - if (status != fmi1_status_discard) { - printf("fmi1_capi_get_boolean_status: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_boolean_status: Success\n"); - } - return 0; + fmi1_status_kind_t statuskind = fmi1_last_successful_time; + fmi1_boolean_t boolean; + + status = fmi1_capi_get_boolean_status(fmu, statuskind, &boolean); + if (status != fmi1_status_discard) { + printf("fmi1_capi_get_boolean_status: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_boolean_status: Success\n"); + } + return 0; } /** @@ -375,17 +375,17 @@ int test_get_boolean_status() int test_get_string_status() { fmi1_status_t status; - fmi1_status_kind_t statuskind = fmi1_pending_status; - fmi1_string_t string; - - status = fmi1_capi_get_string_status(fmu, statuskind, &string); - if (status != fmi1_status_discard) { - printf("fmi1_capi_get_string_status: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_string_status: Success\n"); - } - return 0; + fmi1_status_kind_t statuskind = fmi1_pending_status; + fmi1_string_t string; + + status = fmi1_capi_get_string_status(fmu, statuskind, &string); + if (status != fmi1_status_discard) { + printf("fmi1_capi_get_string_status: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_string_status: Success\n"); + } + return 0; } /** @@ -395,42 +395,42 @@ int test_get_string_status() int test_set_get_string() { fmi1_status_t status; - fmi1_value_reference_t vrs[N_STRING]; - fmi1_string_t values[N_STRING]; - fmi1_string_t values_ref[N_STRING]; - size_t k; - - for (k = 0; k < N_STRING; k++) { - vrs[k] = (fmi1_value_reference_t)k; - values[k] = "hej"; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_string */ - status = fmi1_capi_set_string(fmu, vrs, N_STRING, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_string: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_string: Success\n"); - } - - /* Test fmi1_capi_get_string */ - status = fmi1_capi_get_string(fmu, vrs, N_STRING, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_string: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - for (k = 0; k < N_STRING; k++) { - if (strcmp(values_ref[k], values[k]) != 0) { - printf("fmi1_capi_get_string returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k], values_ref[k]); - do_exit(CTEST_RETURN_FAIL);; - } - } - printf("fmi1_capi_get_string: Success\n"); - } - - return 0; + fmi1_value_reference_t vrs[N_STRING]; + fmi1_string_t values[N_STRING]; + fmi1_string_t values_ref[N_STRING]; + size_t k; + + for (k = 0; k < N_STRING; k++) { + vrs[k] = (fmi1_value_reference_t)k; + values[k] = "hej"; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_string */ + status = fmi1_capi_set_string(fmu, vrs, N_STRING, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_string: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_string: Success\n"); + } + + /* Test fmi1_capi_get_string */ + status = fmi1_capi_get_string(fmu, vrs, N_STRING, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_string: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + for (k = 0; k < N_STRING; k++) { + if (strcmp(values_ref[k], values[k]) != 0) { + printf("fmi1_capi_get_string returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k], values_ref[k]); + do_exit(CTEST_RETURN_FAIL);; + } + } + printf("fmi1_capi_get_string: Success\n"); + } + + return 0; } /** @@ -440,42 +440,42 @@ int test_set_get_string() int test_set_get_integer() { fmi1_status_t status; - fmi1_value_reference_t vrs[N_INTEGER]; - fmi1_integer_t values[N_INTEGER]; - fmi1_integer_t values_ref[N_INTEGER]; - int k; - - for (k = 0; k < N_INTEGER; k++) { - vrs[k] = (fmi1_value_reference_t)k; - values[k] = (k + 1) * 12; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_integer */ - status = fmi1_capi_set_integer(fmu, vrs, N_INTEGER, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_integer: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_integer: Success\n"); - } - - /* Test fmi1_capi_get_integer */ - status = fmi1_capi_get_integer(fmu, vrs, N_INTEGER, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_integer: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - for (k = 0; k < N_INTEGER; k++) { - if (values_ref[k] != values[k]) { - printf("fmi1_capi_get_integer returned values[%d] = \"%d\" expected \"%d\"\n", k, values[k], values_ref[k]); - do_exit(CTEST_RETURN_FAIL); - } - } - printf("fmi1_capi_get_integer: Success\n"); - } - - return 0; + fmi1_value_reference_t vrs[N_INTEGER]; + fmi1_integer_t values[N_INTEGER]; + fmi1_integer_t values_ref[N_INTEGER]; + int k; + + for (k = 0; k < N_INTEGER; k++) { + vrs[k] = (fmi1_value_reference_t)k; + values[k] = (k + 1) * 12; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_integer */ + status = fmi1_capi_set_integer(fmu, vrs, N_INTEGER, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_integer: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_integer: Success\n"); + } + + /* Test fmi1_capi_get_integer */ + status = fmi1_capi_get_integer(fmu, vrs, N_INTEGER, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_integer: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + for (k = 0; k < N_INTEGER; k++) { + if (values_ref[k] != values[k]) { + printf("fmi1_capi_get_integer returned values[%d] = \"%d\" expected \"%d\"\n", k, values[k], values_ref[k]); + do_exit(CTEST_RETURN_FAIL); + } + } + printf("fmi1_capi_get_integer: Success\n"); + } + + return 0; } /** @@ -485,42 +485,42 @@ int test_set_get_integer() int test_set_get_boolean() { fmi1_status_t status; - fmi1_value_reference_t vrs[N_BOOLEAN]; - fmi1_boolean_t values[N_BOOLEAN]; - fmi1_boolean_t values_ref[N_BOOLEAN]; - size_t k; - - for (k = 0; k < N_INTEGER; k++) { - vrs[k] = (fmi1_value_reference_t)k; - values[k] = fmi1_true; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_boolean */ - status = fmi1_capi_set_boolean(fmu, vrs, N_BOOLEAN, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_boolean: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("fmi1_capi_set_boolean: Success\n"); - } - - /* Test fmi1_capi_get_boolean */ - status = fmi1_capi_get_boolean(fmu, vrs, N_BOOLEAN, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_boolean: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - for (k = 0; k < N_BOOLEAN; k++) { - if (values_ref[k] != values[k]) { - printf("fmi1_capi_get_boolean returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k] ? "fmiTrue" : "fmiFalse", values_ref[k] ? "fmiTrue" : "fmiFalse"); - do_exit(CTEST_RETURN_FAIL); - } - } - printf("fmi1_capi_get_boolean: Success\n"); - } - - return 0; + fmi1_value_reference_t vrs[N_BOOLEAN]; + fmi1_boolean_t values[N_BOOLEAN]; + fmi1_boolean_t values_ref[N_BOOLEAN]; + size_t k; + + for (k = 0; k < N_INTEGER; k++) { + vrs[k] = (fmi1_value_reference_t)k; + values[k] = fmi1_true; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_boolean */ + status = fmi1_capi_set_boolean(fmu, vrs, N_BOOLEAN, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_boolean: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("fmi1_capi_set_boolean: Success\n"); + } + + /* Test fmi1_capi_get_boolean */ + status = fmi1_capi_get_boolean(fmu, vrs, N_BOOLEAN, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_boolean: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + for (k = 0; k < N_BOOLEAN; k++) { + if (values_ref[k] != values[k]) { + printf("fmi1_capi_get_boolean returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k] ? "fmiTrue" : "fmiFalse", values_ref[k] ? "fmiTrue" : "fmiFalse"); + do_exit(CTEST_RETURN_FAIL); + } + } + printf("fmi1_capi_get_boolean: Success\n"); + } + + return 0; } /** @@ -530,42 +530,42 @@ int test_set_get_boolean() int test_set_get_real() { fmi1_status_t status; - fmi1_value_reference_t vrs[N_REAL]; - fmi1_real_t values[N_REAL]; - fmi1_real_t values_ref[N_REAL]; - size_t k; - - for (k = 0; k < N_REAL; k++) { - vrs[k] = (fmi1_value_reference_t)(N_STATES + k); - values[k] = (fmi1_real_t)(k + 1) * 12; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_real */ - status = fmi1_capi_set_real(fmu, vrs, N_REAL, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_real: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("fmi1_capi_set_real: Success\n"); - } - - /* Test fmi1_capi_get_real */ - status = fmi1_capi_get_real(fmu, vrs, N_REAL, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_real: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - for (k = 0; k < N_REAL; k++) { - if (values_ref[k] != values[k]) { - printf("fmi1_capi_get_real returned values[%u] = \"%f\" expected \"%f\"\n", (unsigned)k, values[k], values_ref[k]); - do_exit(CTEST_RETURN_FAIL); - } - } - printf("fmi1_capi_get_real: Success\n"); - } - - return 0; + fmi1_value_reference_t vrs[N_REAL]; + fmi1_real_t values[N_REAL]; + fmi1_real_t values_ref[N_REAL]; + size_t k; + + for (k = 0; k < N_REAL; k++) { + vrs[k] = (fmi1_value_reference_t)(N_STATES + k); + values[k] = (fmi1_real_t)(k + 1) * 12; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_real */ + status = fmi1_capi_set_real(fmu, vrs, N_REAL, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_real: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("fmi1_capi_set_real: Success\n"); + } + + /* Test fmi1_capi_get_real */ + status = fmi1_capi_get_real(fmu, vrs, N_REAL, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_real: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + for (k = 0; k < N_REAL; k++) { + if (values_ref[k] != values[k]) { + printf("fmi1_capi_get_real returned values[%u] = \"%f\" expected \"%f\"\n", (unsigned)k, values[k], values_ref[k]); + do_exit(CTEST_RETURN_FAIL); + } + } + printf("fmi1_capi_get_real: Success\n"); + } + + return 0; } /** @@ -575,14 +575,14 @@ int test_set_get_real() int test_reset_slave() { fmi1_status_t status; - status = fmi1_capi_reset_slave(fmu); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_reset_slave: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("fmi1_capi_reset_slave: Success\n"); - } - return 0; + status = fmi1_capi_reset_slave(fmu); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_reset_slave: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("fmi1_capi_reset_slave: Success\n"); + } + return 0; } /** @@ -592,28 +592,28 @@ int test_reset_slave() int test_set_real_input_derivatives() { fmi1_status_t status; - fmi1_value_reference_t vrs [N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER]; - fmi1_real_t values [N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER]; - fmi1_integer_t order [N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER]; - int k, p; - - for (k = 0; k < N_INPUT_REAL_MAX_ORDER; k++) { - for (p = 0; p < N_INPUT_REAL; p++) - { - vrs [p + k * N_INPUT_REAL] = (fmi1_value_reference_t)p; - values [p + k * N_INPUT_REAL] = MAGIC_TEST_VALUE; /* This value is tested in the DLL to be exakt MAGIC_TEST_VALUE */ - order [p + k * N_INPUT_REAL] = k + 1; - } - } - - status = fmi1_capi_set_real_input_derivatives(fmu, vrs, N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER, order, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_real_input_derivatives: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("fmi1_capi_set_real_input_derivatives: Success\n"); - } - return 0; + fmi1_value_reference_t vrs [N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER]; + fmi1_real_t values [N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER]; + fmi1_integer_t order [N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER]; + int k, p; + + for (k = 0; k < N_INPUT_REAL_MAX_ORDER; k++) { + for (p = 0; p < N_INPUT_REAL; p++) + { + vrs [p + k * N_INPUT_REAL] = (fmi1_value_reference_t)p; + values [p + k * N_INPUT_REAL] = MAGIC_TEST_VALUE; /* This value is tested in the DLL to be exakt MAGIC_TEST_VALUE */ + order [p + k * N_INPUT_REAL] = k + 1; + } + } + + status = fmi1_capi_set_real_input_derivatives(fmu, vrs, N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER, order, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_real_input_derivatives: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("fmi1_capi_set_real_input_derivatives: Success\n"); + } + return 0; } /** @@ -623,44 +623,44 @@ int test_set_real_input_derivatives() int test_get_real_output_derivatives() { fmi1_status_t status; - fmi1_value_reference_t vrs [N_OUTPUT_REAL * N_OUTPUT_REAL_MAX_ORDER]; - fmi1_real_t values [N_OUTPUT_REAL * N_OUTPUT_REAL_MAX_ORDER]; - fmi1_integer_t order [N_OUTPUT_REAL * N_OUTPUT_REAL_MAX_ORDER]; - size_t k, p; - - for (k = 0; k < N_OUTPUT_REAL_MAX_ORDER; k++) { - for (p = 0; p < N_OUTPUT_REAL; p++) - { - vrs [p + k * N_OUTPUT_REAL] = (fmi1_value_reference_t)p; - values [p + k * N_OUTPUT_REAL] = -1; - order [p + k * N_OUTPUT_REAL] = (fmi1_integer_t)k + 1; - } - } - - status = fmi1_capi_get_real_output_derivatives(fmu, vrs, N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER, order, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_real_output_derivatives: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("fmi1_capi_get_real_output_derivatives: Success\n"); - - for (k = 0; k < N_OUTPUT_REAL_MAX_ORDER; k++) { - for (p = 0; p < N_OUTPUT_REAL; p++) - { - fmi1_real_t value = values[p + k * N_OUTPUT_REAL]; - if (value != MAGIC_TEST_VALUE) { /* This value is set in DLL to be exakt MAGIC_TEST_VALUE */ - printf("fmi1_capi_get_real_output_derivatives: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } + fmi1_value_reference_t vrs [N_OUTPUT_REAL * N_OUTPUT_REAL_MAX_ORDER]; + fmi1_real_t values [N_OUTPUT_REAL * N_OUTPUT_REAL_MAX_ORDER]; + fmi1_integer_t order [N_OUTPUT_REAL * N_OUTPUT_REAL_MAX_ORDER]; + size_t k, p; + + for (k = 0; k < N_OUTPUT_REAL_MAX_ORDER; k++) { + for (p = 0; p < N_OUTPUT_REAL; p++) + { + vrs [p + k * N_OUTPUT_REAL] = (fmi1_value_reference_t)p; + values [p + k * N_OUTPUT_REAL] = -1; + order [p + k * N_OUTPUT_REAL] = (fmi1_integer_t)k + 1; + } + } + + status = fmi1_capi_get_real_output_derivatives(fmu, vrs, N_INPUT_REAL * N_INPUT_REAL_MAX_ORDER, order, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_real_output_derivatives: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("fmi1_capi_get_real_output_derivatives: Success\n"); + + for (k = 0; k < N_OUTPUT_REAL_MAX_ORDER; k++) { + for (p = 0; p < N_OUTPUT_REAL; p++) + { + fmi1_real_t value = values[p + k * N_OUTPUT_REAL]; + if (value != MAGIC_TEST_VALUE) { /* This value is set in DLL to be exakt MAGIC_TEST_VALUE */ + printf("fmi1_capi_get_real_output_derivatives: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } #ifdef PRINT_VERBOSE - fmi1_integer_t ord = k + 1; - printf("value[%d][%d] = %f \n", p, ord, value); + fmi1_integer_t ord = k + 1; + printf("value[%d][%d] = %f \n", p, ord, value); #endif - } - } - } - return 0; + } + } + } + return 0; } /** @@ -670,14 +670,14 @@ int test_get_real_output_derivatives() int test_terminate_slave() { fmi1_status_t status; - status = fmi1_capi_terminate_slave(fmu); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_terminate_slave: Failed\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("fmi1_capi_terminate_slave: Success\n"); - } - return 0; + status = fmi1_capi_terminate_slave(fmu); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_terminate_slave: Failed\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("fmi1_capi_terminate_slave: Success\n"); + } + return 0; } /** @@ -686,9 +686,9 @@ int test_terminate_slave() */ int test_free_slave_instance() { - fmi1_capi_free_slave_instance(fmu); - printf("fmi1_capi_free_slave_instance: Success\n"); - return 0; + fmi1_capi_free_slave_instance(fmu); + printf("fmi1_capi_free_slave_instance: Success\n"); + return 0; } /** @@ -697,9 +697,9 @@ int test_free_slave_instance() */ int test_free_dll() { - fmi1_capi_free_dll(fmu); - printf("fmi1_capi_free_dll: Success\n"); - return 0; + fmi1_capi_free_dll(fmu); + printf("fmi1_capi_free_dll: Success\n"); + return 0; } /** @@ -708,9 +708,9 @@ int test_free_dll() */ int test_destroy_dllfmu() { - fmi1_capi_destroy_dllfmu(fmu); - printf("fmi1_capi_destroy_dllfmu: Success\n"); - return 0; + fmi1_capi_destroy_dllfmu(fmu); + printf("fmi1_capi_destroy_dllfmu: Success\n"); + return 0; } /** @@ -720,44 +720,44 @@ int test_destroy_dllfmu() */ int main(int argc, char *argv[]) { - /* Test CAPI constructor functions */ - test_create_dllfmu(); - test_load_dll(); - test_load_dll_fcn(); - - /* FMI CS 1.0 functions */ - test_instantiate_slave(); - test_get_types_platform(); - test_initialize_slave(); - test_cancel_step(); - test_do_step(); - test_get_status(); - test_get_real_status(); - test_get_integer_status(); - test_get_boolean_status(); - test_get_string_status(); - test_reset_slave(); - test_set_real_input_derivatives(); - test_get_real_output_derivatives(); - - test_fmi_get_version(); - test_set_get_string(); - test_set_get_boolean(); - test_set_get_integer(); - test_set_get_real(); - test_set_debug_logging(); - - test_terminate_slave(); - test_free_slave_instance(); - - /* Test CAPI destructor functions */ - test_free_dll(); - test_destroy_dllfmu(); - free(callbacks); - printf("\n"); - printf("Everything seems to be ok!\n"); - printf("\n"); - do_exit(CTEST_RETURN_SUCCESS); + /* Test CAPI constructor functions */ + test_create_dllfmu(); + test_load_dll(); + test_load_dll_fcn(); + + /* FMI CS 1.0 functions */ + test_instantiate_slave(); + test_get_types_platform(); + test_initialize_slave(); + test_cancel_step(); + test_do_step(); + test_get_status(); + test_get_real_status(); + test_get_integer_status(); + test_get_boolean_status(); + test_get_string_status(); + test_reset_slave(); + test_set_real_input_derivatives(); + test_get_real_output_derivatives(); + + test_fmi_get_version(); + test_set_get_string(); + test_set_get_boolean(); + test_set_get_integer(); + test_set_get_real(); + test_set_debug_logging(); + + test_terminate_slave(); + test_free_slave_instance(); + + /* Test CAPI destructor functions */ + test_free_dll(); + test_destroy_dllfmu(); + free(callbacks); + printf("\n"); + printf("Everything seems to be ok!\n"); + printf("\n"); + do_exit(CTEST_RETURN_SUCCESS); return 0; } diff --git a/Test/FMI1/fmi1_capi_me_test.c b/Test/FMI1/fmi1_capi_me_test.c index ae391ea0..47bd0322 100644 --- a/Test/FMI1/fmi1_capi_me_test.c +++ b/Test/FMI1/fmi1_capi_me_test.c @@ -34,7 +34,7 @@ #define MODEL_IDENTIFIER FMU_DUMMY_ME_MODEL_IDENTIFIER /* #define PRINT_VERBOSE */ -#define INSTANCE_NAME "Test Model" +#define INSTANCE_NAME "Test Model" fmi1_capi_t* fmu; /* Pointer to the C-API struct that is used in all tests */ @@ -47,12 +47,12 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve /* Logger function used by the FMU internally */ void fmilogger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...) { - char msg[BUFFER]; + char msg[BUFFER]; int len; - va_list argp; - va_start(argp, message); - len = jm_vsnprintf(msg, BUFFER, message, argp); - printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); + va_list argp; + va_start(argp, message); + len = jm_vsnprintf(msg, BUFFER, message, argp); + printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); if(len > BUFFER) { printf("Warning: Message was truncated"); } @@ -61,9 +61,9 @@ void fmilogger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t sta /* Pause and exit function. Useally called when an error occured */ void do_exit(int code) { - printf("Press any key to exit\n"); - /* getchar(); */ - exit(code); + printf("Press any key to exit\n"); + /* getchar(); */ + exit(code); } jm_callbacks* callbacks; @@ -74,31 +74,31 @@ jm_callbacks* callbacks; */ int test_create_dllfmu() { - fmi1_callback_functions_t callBackFunctions; - fmi1_fmu_kind_enu_t standard = fmi1_fmu_kind_enu_me; + fmi1_callback_functions_t callBackFunctions; + fmi1_fmu_kind_enu_t standard = fmi1_fmu_kind_enu_me; - callbacks = calloc(1, sizeof(jm_callbacks)); + callbacks = calloc(1, sizeof(jm_callbacks)); - callbacks->malloc = malloc; + callbacks->malloc = malloc; callbacks->calloc = calloc; callbacks->realloc = realloc; callbacks->free = free; callbacks->logger = importlogger; callbacks->context = 0; - callBackFunctions.logger = fmilogger; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; - - printf("fmi1_capi_create_dllfmu: "); - fmu = fmi1_capi_create_dllfmu(callbacks, FMU1_DLL_ME_PATH, MODEL_IDENTIFIER_STR, callBackFunctions, standard); - if (fmu == NULL) { - printf("An error occured while fmi1_capi_create_dllfmu was called, an error message should been printed.\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + callBackFunctions.logger = fmilogger; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; + + printf("fmi1_capi_create_dllfmu: "); + fmu = fmi1_capi_create_dllfmu(callbacks, FMU1_DLL_ME_PATH, MODEL_IDENTIFIER_STR, callBackFunctions, standard); + if (fmu == NULL) { + printf("An error occured while fmi1_capi_create_dllfmu was called, an error message should been printed.\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -107,17 +107,17 @@ int test_create_dllfmu() */ int test_load_dll() { - jm_status_enu_t status; - - printf("fmi1_capi_load_dll: "); - status = fmi1_capi_load_dll(fmu); - if (status == jm_status_error) { - printf("Error in fmi1_capi_load_dll: %s\n", "fmi1_capi_get_last_error(fmu)"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + jm_status_enu_t status; + + printf("fmi1_capi_load_dll: "); + status = fmi1_capi_load_dll(fmu); + if (status == jm_status_error) { + printf("Error in fmi1_capi_load_dll: %s\n", "fmi1_capi_get_last_error(fmu)"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -126,18 +126,18 @@ int test_load_dll() */ int test_load_dll_fcn() { - jm_status_enu_t status; - - printf("fmi1_capi_load_fcn: "); - status = fmi1_capi_load_fcn(fmu); - if (status == jm_status_error) { - printf("\n"); - printf("Error in fmi1_capi_load_fcn: %s\n", "fmi1_capi_get_last_error(fmu)"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + jm_status_enu_t status; + + printf("fmi1_capi_load_fcn: "); + status = fmi1_capi_load_fcn(fmu); + if (status == jm_status_error) { + printf("\n"); + printf("Error in fmi1_capi_load_fcn: %s\n", "fmi1_capi_get_last_error(fmu)"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -146,16 +146,16 @@ int test_load_dll_fcn() */ int test_fmi_get_version() { - const char* version = fmi1_capi_get_version(fmu); - - printf("fmi1_capi_get_version: "); - if (strcmp(FMI_VERSION, version) != 0) { - printf("Expected \"%s\" but returned \"%s\"", FMI_VERSION, version); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + const char* version = fmi1_capi_get_version(fmu); + + printf("fmi1_capi_get_version: "); + if (strcmp(FMI_VERSION, version) != 0) { + printf("Expected \"%s\" but returned \"%s\"", FMI_VERSION, version); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -164,16 +164,16 @@ int test_fmi_get_version() */ int test_fmi_get_model_types_platform() { - const char* platformtype = fmi1_capi_get_model_types_platform(fmu); - - printf("fmi1_capi_get_model_types_platform: "); - if (strcmp(FMI_PLATFORM_TYPE, platformtype) != 0) { - printf("Expected \"%s\" but returned \"%s\"", FMI_PLATFORM_TYPE, platformtype); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("Success\n"); - } - return 0; + const char* platformtype = fmi1_capi_get_model_types_platform(fmu); + + printf("fmi1_capi_get_model_types_platform: "); + if (strcmp(FMI_PLATFORM_TYPE, platformtype) != 0) { + printf("Expected \"%s\" but returned \"%s\"", FMI_PLATFORM_TYPE, platformtype); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("Success\n"); + } + return 0; } /** @@ -182,15 +182,15 @@ int test_fmi_get_model_types_platform() */ int test_instantiate_model() { - fmi1_boolean_t loggingOn = fmi1_true; - - if (fmi1_capi_instantiate_model(fmu, INSTANCE_NAME, FMI_GUID, loggingOn) == NULL) { - printf("fmi1_capi_instantiate_model: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_instantiate_model: Success\n"); - } - return 0; + fmi1_boolean_t loggingOn = fmi1_true; + + if (fmi1_capi_instantiate_model(fmu, INSTANCE_NAME, FMI_GUID, loggingOn) == NULL) { + printf("fmi1_capi_instantiate_model: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_instantiate_model: Success\n"); + } + return 0; } /** @@ -199,15 +199,15 @@ int test_instantiate_model() */ int test_fmi_set_time() { - fmi1_status_t status; - status = fmi1_capi_set_time(fmu, 0.1); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_time: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_time: Success\n"); - } - return 0; + fmi1_status_t status; + status = fmi1_capi_set_time(fmu, 0.1); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_time: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_time: Success\n"); + } + return 0; } /** @@ -216,27 +216,27 @@ int test_fmi_set_time() */ int test_set_continuous_states() { - fmi1_status_t status; - size_t k; - fmi1_real_t states[N_STATES]; - - for (k = 0; k < N_STATES; k++) { - states[k] = (fmi1_real_t)(k + 1) * 12; - } - - status = fmi1_capi_set_continuous_states(fmu, states, N_STATES); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_continuous_states: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_continuous_states: Success\n"); + fmi1_status_t status; + size_t k; + fmi1_real_t states[N_STATES]; + + for (k = 0; k < N_STATES; k++) { + states[k] = (fmi1_real_t)(k + 1) * 12; + } + + status = fmi1_capi_set_continuous_states(fmu, states, N_STATES); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_continuous_states: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_continuous_states: Success\n"); #ifdef PRINT_VERBOSE - for (k=0; k < N_STATES; k++) { - printf("\t x[%d] = %f\n",k, states[k]); - } + for (k=0; k < N_STATES; k++) { + printf("\t x[%d] = %f\n",k, states[k]); + } #endif - } - return 0; + } + return 0; } /** @@ -245,29 +245,29 @@ int test_set_continuous_states() */ int test_initialize() { - fmi1_status_t status; - fmi1_boolean_t toleranceControlled; - fmi1_real_t relativeTolerance; - fmi1_event_info_t eventInfo; - - relativeTolerance = 1e-5; - toleranceControlled = fmi1_true; - status = fmi1_capi_initialize(fmu, toleranceControlled, relativeTolerance, &eventInfo); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_initialize: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_initialize: Success\n"); + fmi1_status_t status; + fmi1_boolean_t toleranceControlled; + fmi1_real_t relativeTolerance; + fmi1_event_info_t eventInfo; + + relativeTolerance = 1e-5; + toleranceControlled = fmi1_true; + status = fmi1_capi_initialize(fmu, toleranceControlled, relativeTolerance, &eventInfo); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_initialize: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_initialize: Success\n"); #ifdef PRINT_VERBOSE - printf("\t fmiEventInfo.iterationConverged = %s\n", eventInfo.iterationConverged ? "True" : "False"); - printf("\t fmiEventInfo.stateValueReferencesChanged = %s\n", eventInfo.stateValueReferencesChanged ? "True" : "False"); - printf("\t fmiEventInfo.stateValuesChanged = %s\n", eventInfo.stateValuesChanged ? "True" : "False"); - printf("\t fmiEventInfo.terminateSimulation = %s\n", eventInfo.terminateSimulation ? "True" : "False"); - printf("\t fmiEventInfo.upcomingTimeEvent = %s\n", eventInfo.upcomingTimeEvent ? "True" : "False"); - printf("\t fmiEventInfo.nextEventTime = %f\n", eventInfo.nextEventTime); + printf("\t fmiEventInfo.iterationConverged = %s\n", eventInfo.iterationConverged ? "True" : "False"); + printf("\t fmiEventInfo.stateValueReferencesChanged = %s\n", eventInfo.stateValueReferencesChanged ? "True" : "False"); + printf("\t fmiEventInfo.stateValuesChanged = %s\n", eventInfo.stateValuesChanged ? "True" : "False"); + printf("\t fmiEventInfo.terminateSimulation = %s\n", eventInfo.terminateSimulation ? "True" : "False"); + printf("\t fmiEventInfo.upcomingTimeEvent = %s\n", eventInfo.upcomingTimeEvent ? "True" : "False"); + printf("\t fmiEventInfo.nextEventTime = %f\n", eventInfo.nextEventTime); #endif - } - return 0; + } + return 0; } /** @@ -276,20 +276,20 @@ int test_initialize() */ int test_completed_integrator_step() { - fmi1_status_t status; - fmi1_boolean_t callEventUpdate; - - status = fmi1_capi_completed_integrator_step(fmu, &callEventUpdate); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_completed_integrator_step: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_completed_integrator_step: Success\n"); + fmi1_status_t status; + fmi1_boolean_t callEventUpdate; + + status = fmi1_capi_completed_integrator_step(fmu, &callEventUpdate); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_completed_integrator_step: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_completed_integrator_step: Success\n"); #ifdef PRINT_VERBOSE - printf("\t callEventUpdate = %s\n", callEventUpdate ? "True" : "False"); + printf("\t callEventUpdate = %s\n", callEventUpdate ? "True" : "False"); #endif - } - return 0; + } + return 0; } /** @@ -298,44 +298,44 @@ int test_completed_integrator_step() */ int test_get_derivatives() { - fmi1_status_t status; + fmi1_status_t status; - fmi1_real_t dstates[N_STATES]; + fmi1_real_t dstates[N_STATES]; - status = fmi1_capi_get_derivatives(fmu, dstates, N_STATES); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_derivatives: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_derivatives: Success\n"); + status = fmi1_capi_get_derivatives(fmu, dstates, N_STATES); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_derivatives: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_derivatives: Success\n"); #ifdef PRINT_VERBOSE - for (k=0; k < N_STATES; k++) { - printf("\t dx[%d] = %f\n", k, dstates[k]); - } + for (k=0; k < N_STATES; k++) { + printf("\t dx[%d] = %f\n", k, dstates[k]); + } #endif - } - return 0; + } + return 0; } int test_get_event_indicators() { - fmi1_status_t status; + fmi1_status_t status; - fmi1_real_t zerocrossing[N_EVENT_INDICATORS]; + fmi1_real_t zerocrossing[N_EVENT_INDICATORS]; - status = fmi1_capi_get_event_indicators(fmu, zerocrossing, N_EVENT_INDICATORS); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_event_indicators: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_event_indicators: Success\n"); + status = fmi1_capi_get_event_indicators(fmu, zerocrossing, N_EVENT_INDICATORS); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_event_indicators: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_event_indicators: Success\n"); #ifdef PRINT_VERBOSE - for (k=0; k < N_EVENT_INDICATORS; k++) { - printf("\t nz[%d] = %f\n",k, zerocrossing[k]); - } + for (k=0; k < N_EVENT_INDICATORS; k++) { + printf("\t nz[%d] = %f\n",k, zerocrossing[k]); + } #endif - } - return 0; + } + return 0; } /** @@ -344,26 +344,26 @@ int test_get_event_indicators() */ int test_event_update() { - fmi1_status_t status; - fmi1_boolean_t intermediateResults = fmi1_false; - fmi1_event_info_t eventInfo; - - status = fmi1_capi_eventUpdate(fmu, intermediateResults, &eventInfo); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_eventUpdate: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_eventUpdate: Success\n"); + fmi1_status_t status; + fmi1_boolean_t intermediateResults = fmi1_false; + fmi1_event_info_t eventInfo; + + status = fmi1_capi_eventUpdate(fmu, intermediateResults, &eventInfo); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_eventUpdate: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_eventUpdate: Success\n"); #ifdef PRINT_VERBOSE - printf("\t fmiEventInfo.iterationConverged = %s\n", eventInfo.iterationConverged ? "True" : "False"); - printf("\t fmiEventInfo.stateValueReferencesChanged = %s\n", eventInfo.stateValueReferencesChanged ? "True" : "False"); - printf("\t fmiEventInfo.stateValuesChanged = %s\n", eventInfo.stateValuesChanged ? "True" : "False"); - printf("\t fmiEventInfo.terminateSimulation = %s\n", eventInfo.terminateSimulation ? "True" : "False"); - printf("\t fmiEventInfo.upcomingTimeEvent = %s\n", eventInfo.upcomingTimeEvent ? "True" : "False"); - printf("\t fmiEventInfo.nextEventTime = %f\n", eventInfo.nextEventTime); + printf("\t fmiEventInfo.iterationConverged = %s\n", eventInfo.iterationConverged ? "True" : "False"); + printf("\t fmiEventInfo.stateValueReferencesChanged = %s\n", eventInfo.stateValueReferencesChanged ? "True" : "False"); + printf("\t fmiEventInfo.stateValuesChanged = %s\n", eventInfo.stateValuesChanged ? "True" : "False"); + printf("\t fmiEventInfo.terminateSimulation = %s\n", eventInfo.terminateSimulation ? "True" : "False"); + printf("\t fmiEventInfo.upcomingTimeEvent = %s\n", eventInfo.upcomingTimeEvent ? "True" : "False"); + printf("\t fmiEventInfo.nextEventTime = %f\n", eventInfo.nextEventTime); #endif - } - return 0; + } + return 0; } /** @@ -372,23 +372,23 @@ int test_event_update() */ int test_get_continuous_states() { - fmi1_status_t status; - fmi1_real_t states[N_STATES]; + fmi1_status_t status; + fmi1_real_t states[N_STATES]; - status = fmi1_capi_get_continuous_states(fmu, states, N_STATES); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_continuous_states: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_continuous_states: Success\n"); + status = fmi1_capi_get_continuous_states(fmu, states, N_STATES); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_continuous_states: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_continuous_states: Success\n"); #ifdef PRINT_VERBOSE - for (k = 0; k < N_STATES; k++) { - printf("\t x[%d] = %f\n",k, states[k]); - } + for (k = 0; k < N_STATES; k++) { + printf("\t x[%d] = %f\n",k, states[k]); + } #endif - } - return 0; + } + return 0; } /** @@ -397,23 +397,23 @@ int test_get_continuous_states() */ int test_get_nominal_continuous_states() { - fmi1_status_t status; - - fmi1_real_t states[N_STATES]; - - status = fmi1_capi_get_nominal_continuous_states(fmu, states, N_STATES); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_nominal_continuous_states: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_nominal_continuous_states: Success\n"); + fmi1_status_t status; + + fmi1_real_t states[N_STATES]; + + status = fmi1_capi_get_nominal_continuous_states(fmu, states, N_STATES); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_nominal_continuous_states: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_nominal_continuous_states: Success\n"); #ifdef PRINT_VERBOSE - for (k = 0; k < N_STATES; k++) { - printf("\t x[%d] = %f\n",k, states[k]); - } + for (k = 0; k < N_STATES; k++) { + printf("\t x[%d] = %f\n",k, states[k]); + } #endif - } - return 0; + } + return 0; } /** @@ -422,23 +422,23 @@ int test_get_nominal_continuous_states() */ int test_get_state_value_references() { - fmi1_status_t status; - - fmi1_value_reference_t vrs[N_STATES]; - - status = fmi1_capi_get_state_value_references(fmu, vrs, N_STATES); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_state_value_references: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_get_state_value_references: Success\n"); + fmi1_status_t status; + + fmi1_value_reference_t vrs[N_STATES]; + + status = fmi1_capi_get_state_value_references(fmu, vrs, N_STATES); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_state_value_references: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_get_state_value_references: Success\n"); #ifdef PRINT_VERBOSE - for (k=0; k < N_STATES; k++) { - printf("\t vrs[%u] = %u\n", k, vrs[k]); - } + for (k=0; k < N_STATES; k++) { + printf("\t vrs[%u] = %u\n", k, vrs[k]); + } #endif - } - return 0; + } + return 0; } /** @@ -447,15 +447,15 @@ int test_get_state_value_references() */ int test_set_debug_logging() { - fmi1_status_t status; - status = fmi1_capi_set_debug_logging(fmu, fmi1_true); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_debug_logging: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_debug_logging: Success\n"); - } - return 0; + fmi1_status_t status; + status = fmi1_capi_set_debug_logging(fmu, fmi1_true); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_debug_logging: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_debug_logging: Success\n"); + } + return 0; } /** @@ -464,43 +464,43 @@ int test_set_debug_logging() */ int test_set_get_string() { - fmi1_status_t status; - fmi1_value_reference_t vrs[N_STRING]; - fmi1_string_t values[N_STRING]; - fmi1_string_t values_ref[N_STRING]; - size_t k; - - for (k = 0; k < N_STRING; k++) { - vrs[k] = (fmi1_value_reference_t)k; - values[k] = "hej"; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_string */ - status = fmi1_capi_set_string(fmu, vrs, N_STRING, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_string: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_string: Success\n"); - } - - /* Test fmi1_capi_get_string */ - status = fmi1_capi_get_string(fmu, vrs, N_STRING, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_string: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - for (k = 0; k < N_STRING; k++) { - if (strcmp(values_ref[k], values[k]) != 0) { - printf("fmi1_capi_get_string returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k], values_ref[k]); - do_exit(CTEST_RETURN_FAIL);; - } - } - printf("fmi1_capi_get_string: Success\n"); - } - - return 0; + fmi1_status_t status; + fmi1_value_reference_t vrs[N_STRING]; + fmi1_string_t values[N_STRING]; + fmi1_string_t values_ref[N_STRING]; + size_t k; + + for (k = 0; k < N_STRING; k++) { + vrs[k] = (fmi1_value_reference_t)k; + values[k] = "hej"; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_string */ + status = fmi1_capi_set_string(fmu, vrs, N_STRING, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_string: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_string: Success\n"); + } + + /* Test fmi1_capi_get_string */ + status = fmi1_capi_get_string(fmu, vrs, N_STRING, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_string: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + for (k = 0; k < N_STRING; k++) { + if (strcmp(values_ref[k], values[k]) != 0) { + printf("fmi1_capi_get_string returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k], values_ref[k]); + do_exit(CTEST_RETURN_FAIL);; + } + } + printf("fmi1_capi_get_string: Success\n"); + } + + return 0; } /** @@ -509,43 +509,43 @@ int test_set_get_string() */ int test_set_get_integer() { - fmi1_status_t status; - fmi1_value_reference_t vrs[N_INTEGER]; - fmi1_integer_t values[N_INTEGER]; - fmi1_integer_t values_ref[N_INTEGER]; - int k; - - for (k = 0; k < N_INTEGER; k++) { - vrs[k] = (fmi1_value_reference_t)k; - values[k] = (k + 1) * 12; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_integer */ - status = fmi1_capi_set_integer(fmu, vrs, N_INTEGER, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_integer: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_integer: Success\n"); - } - - /* Test fmi1_capi_get_integer */ - status = fmi1_capi_get_integer(fmu, vrs, N_INTEGER, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_integer: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - for (k = 0; k < N_INTEGER; k++) { - if (values_ref[k] != values[k]) { - printf("fmi1_capi_get_integer returned values[%d] = \"%d\" expected \"%d\"\n", k, values[k], values_ref[k]); - do_exit(CTEST_RETURN_FAIL);; - } - } - printf("fmi1_capi_get_integer: Success\n"); - } - - return 0; + fmi1_status_t status; + fmi1_value_reference_t vrs[N_INTEGER]; + fmi1_integer_t values[N_INTEGER]; + fmi1_integer_t values_ref[N_INTEGER]; + int k; + + for (k = 0; k < N_INTEGER; k++) { + vrs[k] = (fmi1_value_reference_t)k; + values[k] = (k + 1) * 12; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_integer */ + status = fmi1_capi_set_integer(fmu, vrs, N_INTEGER, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_integer: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_integer: Success\n"); + } + + /* Test fmi1_capi_get_integer */ + status = fmi1_capi_get_integer(fmu, vrs, N_INTEGER, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_integer: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + for (k = 0; k < N_INTEGER; k++) { + if (values_ref[k] != values[k]) { + printf("fmi1_capi_get_integer returned values[%d] = \"%d\" expected \"%d\"\n", k, values[k], values_ref[k]); + do_exit(CTEST_RETURN_FAIL);; + } + } + printf("fmi1_capi_get_integer: Success\n"); + } + + return 0; } /** @@ -554,43 +554,43 @@ int test_set_get_integer() */ int test_set_get_boolean() { - fmi1_status_t status; - fmi1_value_reference_t vrs[N_BOOLEAN]; - fmi1_boolean_t values[N_BOOLEAN]; - fmi1_boolean_t values_ref[N_BOOLEAN]; - size_t k; - - for (k = 0; k < N_INTEGER; k++) { - vrs[k] = (fmi1_value_reference_t)k; - values[k] = fmi1_true; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_boolean */ - status = fmi1_capi_set_boolean(fmu, vrs, N_BOOLEAN, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_boolean: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_boolean: Success\n"); - } - - /* Test fmi1_capi_get_boolean */ - status = fmi1_capi_get_boolean(fmu, vrs, N_BOOLEAN, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_boolean: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - for (k = 0; k < N_BOOLEAN; k++) { - if (values_ref[k] != values[k]) { - printf("fmi1_capi_get_boolean returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k] ? "fmiTrue" : "fmiFalse", values_ref[k] ? "fmiTrue" : "fmiFalse"); - do_exit(CTEST_RETURN_FAIL);; - } - } - printf("fmi1_capi_get_boolean: Success\n"); - } - - return 0; + fmi1_status_t status; + fmi1_value_reference_t vrs[N_BOOLEAN]; + fmi1_boolean_t values[N_BOOLEAN]; + fmi1_boolean_t values_ref[N_BOOLEAN]; + size_t k; + + for (k = 0; k < N_INTEGER; k++) { + vrs[k] = (fmi1_value_reference_t)k; + values[k] = fmi1_true; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_boolean */ + status = fmi1_capi_set_boolean(fmu, vrs, N_BOOLEAN, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_boolean: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_boolean: Success\n"); + } + + /* Test fmi1_capi_get_boolean */ + status = fmi1_capi_get_boolean(fmu, vrs, N_BOOLEAN, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_boolean: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + for (k = 0; k < N_BOOLEAN; k++) { + if (values_ref[k] != values[k]) { + printf("fmi1_capi_get_boolean returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k] ? "fmiTrue" : "fmiFalse", values_ref[k] ? "fmiTrue" : "fmiFalse"); + do_exit(CTEST_RETURN_FAIL);; + } + } + printf("fmi1_capi_get_boolean: Success\n"); + } + + return 0; } /** @@ -599,44 +599,44 @@ int test_set_get_boolean() */ int test_set_get_real() { - fmi1_status_t status; - fmi1_value_reference_t vrs[N_REAL]; - fmi1_real_t values[N_REAL]; - fmi1_real_t values_ref[N_REAL]; - size_t k; - - for (k = 0; k < N_REAL; k++) { - vrs[k] = (fmi1_value_reference_t)(N_STATES + k); - values[k] = (fmi1_real_t)(k + 1) * 12; - values_ref[k] = values[k]; - } - - /* Test fmi1_capi_set_real */ - status = fmi1_capi_set_real(fmu, vrs, N_REAL, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_set_real: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_set_real: Success\n"); - } - - /* Test fmi1_capi_get_real */ - status = fmi1_capi_get_real(fmu, vrs, N_REAL, values); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_get_real: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - for (k = 0; k < N_REAL; k++) { - if (values_ref[k] != values[k]) { - printf("%f\n",12.0); - printf("fmi1_capi_get_real returned values[%u] = \"%f\" expected \"%f\"\n", (unsigned)k, (double)values[k], (double)values_ref[k]); - do_exit(CTEST_RETURN_FAIL);; - } - } - printf("fmi1_capi_get_real: Success\n"); - } - - return 0; + fmi1_status_t status; + fmi1_value_reference_t vrs[N_REAL]; + fmi1_real_t values[N_REAL]; + fmi1_real_t values_ref[N_REAL]; + size_t k; + + for (k = 0; k < N_REAL; k++) { + vrs[k] = (fmi1_value_reference_t)(N_STATES + k); + values[k] = (fmi1_real_t)(k + 1) * 12; + values_ref[k] = values[k]; + } + + /* Test fmi1_capi_set_real */ + status = fmi1_capi_set_real(fmu, vrs, N_REAL, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_set_real: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_set_real: Success\n"); + } + + /* Test fmi1_capi_get_real */ + status = fmi1_capi_get_real(fmu, vrs, N_REAL, values); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_get_real: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + for (k = 0; k < N_REAL; k++) { + if (values_ref[k] != values[k]) { + printf("%f\n",12.0); + printf("fmi1_capi_get_real returned values[%u] = \"%f\" expected \"%f\"\n", (unsigned)k, (double)values[k], (double)values_ref[k]); + do_exit(CTEST_RETURN_FAIL);; + } + } + printf("fmi1_capi_get_real: Success\n"); + } + + return 0; } /** @@ -645,16 +645,16 @@ int test_set_get_real() */ int test_terminate() { - fmi1_status_t status; - - status = fmi1_capi_terminate(fmu); - if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_terminate: Failed\n"); - do_exit(CTEST_RETURN_FAIL);; - } else { - printf("fmi1_capi_terminate: Success\n"); - } - return 0; + fmi1_status_t status; + + status = fmi1_capi_terminate(fmu); + if (status == fmi1_status_error || status == fmi1_status_fatal) { + printf("fmi1_capi_terminate: Failed\n"); + do_exit(CTEST_RETURN_FAIL);; + } else { + printf("fmi1_capi_terminate: Success\n"); + } + return 0; } /** @@ -663,9 +663,9 @@ int test_terminate() */ int test_free_model_instance() { - fmi1_capi_free_model_instance(fmu); - printf("fmi1_capi_instantiate_model: Success\n"); - return 0; + fmi1_capi_free_model_instance(fmu); + printf("fmi1_capi_instantiate_model: Success\n"); + return 0; } /** @@ -674,9 +674,9 @@ int test_free_model_instance() */ int test_free_dll() { - fmi1_capi_free_dll(fmu); - printf("fmi1_capi_free_dll: Success\n"); - return 0; + fmi1_capi_free_dll(fmu); + printf("fmi1_capi_free_dll: Success\n"); + return 0; } /** @@ -685,9 +685,9 @@ int test_free_dll() */ int test_destroy_dllfmu() { - fmi1_capi_destroy_dllfmu(fmu); - printf("fmi1_capi_destroy_dllfmu: Success\n"); - return 0; + fmi1_capi_destroy_dllfmu(fmu); + printf("fmi1_capi_destroy_dllfmu: Success\n"); + return 0; } /** @@ -697,44 +697,44 @@ int test_destroy_dllfmu() */ int main(int argc, char *argv[]) { - /* Test CAPI constructor functions */ - test_create_dllfmu(); - test_load_dll(); - test_load_dll_fcn(); - - /* FMI ME 1.0 functions */ - test_fmi_get_model_types_platform(); - test_instantiate_model(); - test_fmi_set_time(); - test_set_continuous_states(); - test_initialize(); - test_completed_integrator_step(); - test_get_derivatives(); - test_get_event_indicators(); - test_event_update(); - test_get_continuous_states(); - test_get_nominal_continuous_states(); - test_get_state_value_references(); - - test_fmi_get_version(); - test_set_get_string(); - test_set_get_boolean(); - test_set_get_integer(); - test_set_get_real(); - test_set_debug_logging(); - - test_terminate(); - test_free_model_instance(); - - /* Test CAPI destructor functions */ - test_free_dll(); - test_destroy_dllfmu(); - free(callbacks); - printf("\n"); - printf("Everything seems to be ok!\n"); - printf("\n"); - do_exit(CTEST_RETURN_SUCCESS); - return 0; + /* Test CAPI constructor functions */ + test_create_dllfmu(); + test_load_dll(); + test_load_dll_fcn(); + + /* FMI ME 1.0 functions */ + test_fmi_get_model_types_platform(); + test_instantiate_model(); + test_fmi_set_time(); + test_set_continuous_states(); + test_initialize(); + test_completed_integrator_step(); + test_get_derivatives(); + test_get_event_indicators(); + test_event_update(); + test_get_continuous_states(); + test_get_nominal_continuous_states(); + test_get_state_value_references(); + + test_fmi_get_version(); + test_set_get_string(); + test_set_get_boolean(); + test_set_get_integer(); + test_set_get_real(); + test_set_debug_logging(); + + test_terminate(); + test_free_model_instance(); + + /* Test CAPI destructor functions */ + test_free_dll(); + test_destroy_dllfmu(); + free(callbacks); + printf("\n"); + printf("Everything seems to be ok!\n"); + printf("\n"); + do_exit(CTEST_RETURN_SUCCESS); + return 0; } diff --git a/Test/FMI1/fmi1_import_test.c b/Test/FMI1/fmi1_import_test.c index 98e4e89d..49173986 100644 --- a/Test/FMI1/fmi1_import_test.c +++ b/Test/FMI1/fmi1_import_test.c @@ -27,55 +27,55 @@ static void fmi1logger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...) { int len; - char msg[BUFFER]; - va_list argp; - va_start(argp, message); - len = jm_vsnprintf(msg, BUFFER, message, argp); - printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); + char msg[BUFFER]; + va_list argp; + va_start(argp, message); + len = jm_vsnprintf(msg, BUFFER, message, argp); + printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); } - + int fmi1_test(fmi_import_context_t* context, const char* dirPath) { - fmi1_callback_functions_t callBackFunctions; - const char* modelIdentifier; - const char* modelName; - const char* GUID; - jm_status_enu_t status; + fmi1_callback_functions_t callBackFunctions; + const char* modelIdentifier; + const char* modelName; + const char* GUID; + jm_status_enu_t status; - fmi1_import_t* fmu; + fmi1_import_t* fmu; - callBackFunctions.logger = fmi1logger; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; + callBackFunctions.logger = fmi1logger; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; - fmu = fmi1_import_parse_xml(context, dirPath); + fmu = fmi1_import_parse_xml(context, dirPath); - if(!fmu) { - printf("Error parsing XML, exiting\n"); - return (CTEST_RETURN_FAIL); - } - modelIdentifier = fmi1_import_get_model_identifier(fmu); - modelName = fmi1_import_get_model_name(fmu); - GUID = fmi1_import_get_GUID(fmu); + if(!fmu) { + printf("Error parsing XML, exiting\n"); + return (CTEST_RETURN_FAIL); + } + modelIdentifier = fmi1_import_get_model_identifier(fmu); + modelName = fmi1_import_get_model_name(fmu); + GUID = fmi1_import_get_GUID(fmu); - printf("Model name: %s\n", modelName); + printf("Model name: %s\n", modelName); printf("Model identifier: %s\n", modelIdentifier); printf("Model GUID: %s\n", GUID); - status = fmi1_import_create_dllfmu(fmu, callBackFunctions, 0); - if (status == jm_status_error) { - printf("Could not create the DLL loading mechanism(C-API).\n"); - return(CTEST_RETURN_FAIL); - } + status = fmi1_import_create_dllfmu(fmu, callBackFunctions, 0); + if (status == jm_status_error) { + printf("Could not create the DLL loading mechanism(C-API).\n"); + return(CTEST_RETURN_FAIL); + } - printf("Version returned from FMU: %s\n", fmi1_import_get_version(fmu)); + printf("Version returned from FMU: %s\n", fmi1_import_get_version(fmu)); - fmi1_import_destroy_dllfmu(fmu); + fmi1_import_destroy_dllfmu(fmu); - fmi1_import_free(fmu); + fmi1_import_free(fmu); - return (CTEST_RETURN_SUCCESS); + return (CTEST_RETURN_SUCCESS); } diff --git a/Test/FMI1/fmi1_logger_test.c b/Test/FMI1/fmi1_logger_test.c index 1b44c260..9ed59b33 100644 --- a/Test/FMI1/fmi1_logger_test.c +++ b/Test/FMI1/fmi1_logger_test.c @@ -26,193 +26,193 @@ FILE* logFile; void logger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message) { - char buf[10000]; - const char* loadingstr = "Loading '"; - /* need to replace platform specific message with a standard one */ - if( (log_level == jm_log_level_info) && - (strcmp(module, "FMILIB") == 0) && - (strncmp(message, "Loading '", strlen(loadingstr)) == 0) - ) - { - jm_snprintf(buf, 10000, "[INFO][FMILIB] Loading '-----' binary with '------' platform types\n"); - } - else - jm_snprintf(buf, 10000, "[%s][%s] %s\n", jm_log_level_to_string(log_level), module, message); - printf("%s", buf); - fprintf(logFile, "%s", buf); + char buf[10000]; + const char* loadingstr = "Loading '"; + /* need to replace platform specific message with a standard one */ + if( (log_level == jm_log_level_info) && + (strcmp(module, "FMILIB") == 0) && + (strncmp(message, "Loading '", strlen(loadingstr)) == 0) + ) + { + jm_snprintf(buf, 10000, "[INFO][FMILIB] Loading '-----' binary with '------' platform types\n"); + } + else + jm_snprintf(buf, 10000, "[%s][%s] %s\n", jm_log_level_to_string(log_level), module, message); + printf("%s", buf); + fprintf(logFile, "%s", buf); } void do_exit(int code) { - /* getchar();*/ - exit(code); + /* getchar();*/ + exit(code); } int test_logger(fmi1_import_t* fmu) { - fmi1_status_t fmistatus; - jm_status_enu_t jmstatus; - - jmstatus = fmi1_import_instantiate_model(fmu, "LoggerTesting"); - if (jmstatus == jm_status_error) { - printf("fmi1_import_instantiate_model failed\n"); - do_exit(CTEST_RETURN_FAIL); - } - - /* Logger message to print: */ - { - fmi1_value_reference_t* vr; - size_t n; - size_t k; - const char* str[] = { - "###### Reals ######", - "OK HEIGHT = #r0#", /* HEIGHT */ - "OK HEIGHT_SPEED = #r1#", /* HEIGHT_SPEED */ - "OK GRAVITY = #r2#", /* GRAVITY */ - "OK BOUNCE_COF = #r3#", /* BOUNCE_COF */ - "Bad reference #r0", - "Bad reference #r-0", - "Bad reference #r-1", - "Bad reference #r100#", - "###### Integers ######", - "OK LOGGER_TEST_INTEGER = #i0#", /* LOGGER_TEST_INTEGER */ - "Bad reference #i0", - "Bad reference #i-0", - "Bad reference #i-1", - "Bad reference #i100#", - "###### Booleans ######", - "OK LOGGER_TEST_BOOLEAN = #b0#", /* LOGGER_TEST_BOOLEAN */ - "Bad reference #b0", - "Bad reference #b-0", - "Bad reference #b-1", - "Bad reference #b100#", - "###### Strings ######", - "OK LOGGER_TEST = #s0#", /* LOGGER_TEST */ - "Bad reference #s0", - "Bad reference #s-0", - "Bad reference #s-1", - "Bad reference #s100#" - }; - - n = sizeof(str)/sizeof(*str); - vr = calloc(n, sizeof(fmi1_value_reference_t)); - for (k = 0; k < n; k++) { - vr[k] = VAR_S_LOGGER_TEST; - } - - fmistatus = fmi1_import_set_string(fmu, vr, n, str); + fmi1_status_t fmistatus; + jm_status_enu_t jmstatus; + + jmstatus = fmi1_import_instantiate_model(fmu, "LoggerTesting"); + if (jmstatus == jm_status_error) { + printf("fmi1_import_instantiate_model failed\n"); + do_exit(CTEST_RETURN_FAIL); + } + + /* Logger message to print: */ + { + fmi1_value_reference_t* vr; + size_t n; + size_t k; + const char* str[] = { + "###### Reals ######", + "OK HEIGHT = #r0#", /* HEIGHT */ + "OK HEIGHT_SPEED = #r1#", /* HEIGHT_SPEED */ + "OK GRAVITY = #r2#", /* GRAVITY */ + "OK BOUNCE_COF = #r3#", /* BOUNCE_COF */ + "Bad reference #r0", + "Bad reference #r-0", + "Bad reference #r-1", + "Bad reference #r100#", + "###### Integers ######", + "OK LOGGER_TEST_INTEGER = #i0#", /* LOGGER_TEST_INTEGER */ + "Bad reference #i0", + "Bad reference #i-0", + "Bad reference #i-1", + "Bad reference #i100#", + "###### Booleans ######", + "OK LOGGER_TEST_BOOLEAN = #b0#", /* LOGGER_TEST_BOOLEAN */ + "Bad reference #b0", + "Bad reference #b-0", + "Bad reference #b-1", + "Bad reference #b100#", + "###### Strings ######", + "OK LOGGER_TEST = #s0#", /* LOGGER_TEST */ + "Bad reference #s0", + "Bad reference #s-0", + "Bad reference #s-1", + "Bad reference #s100#" + }; + + n = sizeof(str)/sizeof(*str); + vr = calloc(n, sizeof(fmi1_value_reference_t)); + for (k = 0; k < n; k++) { + vr[k] = VAR_S_LOGGER_TEST; + } + + fmistatus = fmi1_import_set_string(fmu, vr, n, str); if(fmistatus != fmi1_status_ok) { abort(); } - { /* Print a really big message */ + { /* Print a really big message */ #define MESSAGE_SIZE_TO_EXPAND_AND_PRINT 3000 /* Using fixed size since the log message is printed to a file and compared */ #if JM_MAX_ERROR_MESSAGE_SIZE + 200 > MESSAGE_SIZE_TO_EXPAND_AND_PRINT #error This test triggers the logger function to allocate more memory than the default size JM_MAX_ERROR_MESSAGE_SIZE. If you change JM_MAX_ERROR_MESSAGE_SIZE, please update this test. #endif - char longmessage[MESSAGE_SIZE_TO_EXPAND_AND_PRINT]; - const char* str[1]; - - str[0] = (const char*)&longmessage; - { - fmi1_value_reference_t vr = VAR_S_LOGGER_TEST; - int k; - char repmsg[] = "#r0# "; /* HEIGHT */ - for (k = 0; k < sizeof(longmessage)/sizeof(*longmessage) - 1; k++) { - longmessage[k] = repmsg[k%(sizeof(repmsg)/sizeof(*repmsg) - 1)]; - } - longmessage[k] = '\0'; - - fmistatus = fmi1_import_set_string(fmu, &vr, 1, str); - if(fmistatus != fmi1_status_ok) { - abort(); - } - } - } - - free(vr); - } - - - fmi1_import_free_model_instance(fmu); - return 0; + char longmessage[MESSAGE_SIZE_TO_EXPAND_AND_PRINT]; + const char* str[1]; + + str[0] = (const char*)&longmessage; + { + fmi1_value_reference_t vr = VAR_S_LOGGER_TEST; + int k; + char repmsg[] = "#r0# "; /* HEIGHT */ + for (k = 0; k < sizeof(longmessage)/sizeof(*longmessage) - 1; k++) { + longmessage[k] = repmsg[k%(sizeof(repmsg)/sizeof(*repmsg) - 1)]; + } + longmessage[k] = '\0'; + + fmistatus = fmi1_import_set_string(fmu, &vr, 1, str); + if(fmistatus != fmi1_status_ok) { + abort(); + } + } + } + + free(vr); + } + + + fmi1_import_free_model_instance(fmu); + return 0; } int main(int argc, char *argv[]) { - fmi1_callback_functions_t callBackFunctions; - const char* FMUPath; - const char* tmpPath; - jm_callbacks callbacks; - fmi_import_context_t* context; - fmi_version_enu_t version; - jm_status_enu_t status; - int register_active_fmu; - fmi1_import_t* fmu; - char* outfile; - - if(argc < 4) { - printf("Usage: %s \n", argv[0]); - do_exit(CTEST_RETURN_FAIL); - } - - FMUPath = argv[1]; - tmpPath = argv[2]; - outfile = argv[3]; - - logFile = fopen(outfile, "wb"); - - if(!logFile) { - printf("Could not open output file %s\n", outfile); - do_exit(CTEST_RETURN_FAIL); - } - - callbacks.malloc = malloc; + fmi1_callback_functions_t callBackFunctions; + const char* FMUPath; + const char* tmpPath; + jm_callbacks callbacks; + fmi_import_context_t* context; + fmi_version_enu_t version; + jm_status_enu_t status; + int register_active_fmu; + fmi1_import_t* fmu; + char* outfile; + + if(argc < 4) { + printf("Usage: %s \n", argv[0]); + do_exit(CTEST_RETURN_FAIL); + } + + FMUPath = argv[1]; + tmpPath = argv[2]; + outfile = argv[3]; + + logFile = fopen(outfile, "wb"); + + if(!logFile) { + printf("Could not open output file %s\n", outfile); + do_exit(CTEST_RETURN_FAIL); + } + + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = logger; - callbacks.log_level = jm_log_level_info; + callbacks.log_level = jm_log_level_info; callbacks.context = 0; - callBackFunctions.logger = fmi1_log_forwarding; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; + callBackFunctions.logger = fmi1_log_forwarding; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; #ifdef FMILIB_GENERATE_BUILD_STAMP - printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); + printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); #endif - context = fmi_import_allocate_context(&callbacks); + context = fmi_import_allocate_context(&callbacks); - version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); + version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); - if(version != fmi_version_1_enu) { - printf("Only version 1.0 is supported so far\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(version != fmi_version_1_enu) { + printf("Only version 1.0 is supported so far\n"); + do_exit(CTEST_RETURN_FAIL); + } - fmu = fmi1_import_parse_xml(context, tmpPath); + fmu = fmi1_import_parse_xml(context, tmpPath); - if(!fmu) { - printf("Error parsing XML, exiting\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(!fmu) { + printf("Error parsing XML, exiting\n"); + do_exit(CTEST_RETURN_FAIL); + } - register_active_fmu = 1; /* Must be used to use our logger. (jm standard prints to strerr which does not generate out put test file) */ - status = fmi1_import_create_dllfmu(fmu, callBackFunctions, register_active_fmu); - if (status == jm_status_error) { - printf("Could not create the DLL loading mechanism(C-API test).\n"); - do_exit(CTEST_RETURN_FAIL); - } + register_active_fmu = 1; /* Must be used to use our logger. (jm standard prints to strerr which does not generate out put test file) */ + status = fmi1_import_create_dllfmu(fmu, callBackFunctions, register_active_fmu); + if (status == jm_status_error) { + printf("Could not create the DLL loading mechanism(C-API test).\n"); + do_exit(CTEST_RETURN_FAIL); + } - test_logger(fmu); + test_logger(fmu); - fmi1_import_destroy_dllfmu(fmu); + fmi1_import_destroy_dllfmu(fmu); - fmi1_import_free(fmu); - fmi_import_free_context(context); - fclose(logFile); - return 0; + fmi1_import_free(fmu); + fmi_import_free_context(context); + fclose(logFile); + return 0; } diff --git a/Test/FMI1/fmi_import_cs_test.c b/Test/FMI1/fmi_import_cs_test.c index 31b48df0..a5788e49 100644 --- a/Test/FMI1/fmi_import_cs_test.c +++ b/Test/FMI1/fmi_import_cs_test.c @@ -34,19 +34,19 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve void fmilogger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...) { - /* char msg[BUFFER];*/ - va_list argp; - va_start(argp, message); - /* vsnprintf(msg, BUFFER, message, argp); */ - fmi1_log_forwarding_v(c, instanceName, status, category, message, argp); - va_end(argp); + /* char msg[BUFFER];*/ + va_list argp; + va_start(argp, message); + /* vsnprintf(msg, BUFFER, message, argp); */ + fmi1_log_forwarding_v(c, instanceName, status, category, message, argp); + va_end(argp); } void do_exit(int code) { - printf("Press 'Enter' to exit\n"); - /* getchar(); */ - exit(code); + printf("Press 'Enter' to exit\n"); + /* getchar(); */ + exit(code); } /* Testing "...Test\FMI1\fmu_dummy\modelDescription_cs_tc.xml" */ @@ -156,14 +156,14 @@ void test_xml_modelDescription_cs_tc(const char* xmlFileName, fmi1_import_t* fmu } typedef struct { - const char* filename; - int performTest; - void (*fcn)(const char* xmlFileName, fmi1_import_t* fmu); + const char* filename; + int performTest; + void (*fcn)(const char* xmlFileName, fmi1_import_t* fmu); } xml_test_files_t; xml_test_files_t xml_test_files[] = { - {"modelDescription_cs_tc.xml", 1, test_xml_modelDescription_cs_tc}, - {"modelDescription_cs.xml", 0, NULL} + {"modelDescription_cs_tc.xml", 1, test_xml_modelDescription_cs_tc}, + {"modelDescription_cs.xml", 0, NULL} }; void test_xml(const char* xmlFileName, fmi1_import_t* fmu) @@ -190,182 +190,182 @@ void test_xml(const char* xmlFileName, fmi1_import_t* fmu) int test_simulate_cs(fmi1_import_t* fmu) { - fmi1_status_t fmistatus; - jm_status_enu_t jmstatus; - - fmi1_string_t instanceName = "Test CS model instance"; - fmi1_string_t fmuGUID; - fmi1_string_t fmuLocation = ""; - fmi1_string_t mimeType = ""; - fmi1_real_t timeout = 0.0; - fmi1_boolean_t visible = fmi1_false; - fmi1_boolean_t interactive = fmi1_false; -/* fmi1_boolean_t loggingOn = fmi1_true; */ - - /* fmi1_real_t simulation_results[] = {-0.001878, -1.722275}; */ - fmi1_real_t simulation_results[] = {0.0143633, -1.62417}; - fmi1_value_reference_t compare_real_variables_vr[] = {0, 1}; - size_t k; - - fmi1_real_t tstart = 0.0; - fmi1_real_t tcur = tstart; - fmi1_real_t hstep = 0.1; - fmi1_real_t tend = 2.0; - fmi1_boolean_t StopTimeDefined = fmi1_false; - - if (sizeof(compare_real_variables_vr)/sizeof(fmi1_value_reference_t) != sizeof(simulation_results)/sizeof(fmi1_real_t)) { - printf("Number of simulation values and reference values are different\n"); - do_exit(CTEST_RETURN_FAIL); - } - - printf("Version returned from FMU: %s\n", fmi1_import_get_version(fmu)); - printf("Platform type returned: %s\n", fmi1_import_get_types_platform(fmu)); - - fmuGUID = fmi1_import_get_GUID(fmu); + fmi1_status_t fmistatus; + jm_status_enu_t jmstatus; + + fmi1_string_t instanceName = "Test CS model instance"; + fmi1_string_t fmuGUID; + fmi1_string_t fmuLocation = ""; + fmi1_string_t mimeType = ""; + fmi1_real_t timeout = 0.0; + fmi1_boolean_t visible = fmi1_false; + fmi1_boolean_t interactive = fmi1_false; +/* fmi1_boolean_t loggingOn = fmi1_true; */ + + /* fmi1_real_t simulation_results[] = {-0.001878, -1.722275}; */ + fmi1_real_t simulation_results[] = {0.0143633, -1.62417}; + fmi1_value_reference_t compare_real_variables_vr[] = {0, 1}; + size_t k; + + fmi1_real_t tstart = 0.0; + fmi1_real_t tcur = tstart; + fmi1_real_t hstep = 0.1; + fmi1_real_t tend = 2.0; + fmi1_boolean_t StopTimeDefined = fmi1_false; + + if (sizeof(compare_real_variables_vr)/sizeof(fmi1_value_reference_t) != sizeof(simulation_results)/sizeof(fmi1_real_t)) { + printf("Number of simulation values and reference values are different\n"); + do_exit(CTEST_RETURN_FAIL); + } + + printf("Version returned from FMU: %s\n", fmi1_import_get_version(fmu)); + printf("Platform type returned: %s\n", fmi1_import_get_types_platform(fmu)); + + fmuGUID = fmi1_import_get_GUID(fmu); printf("GUID: %s\n", fmuGUID); - jmstatus = fmi1_import_instantiate_slave(fmu, instanceName, fmuLocation, mimeType, timeout, visible, interactive); - if (jmstatus == jm_status_error) { - printf("fmi1_import_instantiate_model failed\n"); - do_exit(CTEST_RETURN_FAIL); - } + jmstatus = fmi1_import_instantiate_slave(fmu, instanceName, fmuLocation, mimeType, timeout, visible, interactive); + if (jmstatus == jm_status_error) { + printf("fmi1_import_instantiate_model failed\n"); + do_exit(CTEST_RETURN_FAIL); + } - fmistatus = fmi1_import_initialize_slave(fmu, tstart, StopTimeDefined, tend); + fmistatus = fmi1_import_initialize_slave(fmu, tstart, StopTimeDefined, tend); if(fmistatus != fmi1_status_ok) { printf("fmi1_import_initialize_slave failed\n"); - do_exit(CTEST_RETURN_FAIL); + do_exit(CTEST_RETURN_FAIL); } - tcur = tstart; - printf("%10s %10s\n", "Ball height", "Ball speed"); - while (tcur < tend) { - fmi1_boolean_t newStep = fmi1_true; + tcur = tstart; + printf("%10s %10s\n", "Ball height", "Ball speed"); + while (tcur < tend) { + fmi1_boolean_t newStep = fmi1_true; #if 0 /* Prints a real value.. */ - fmi1_real_t rvalue; - fmi1_value_reference_t vr = 0; + fmi1_real_t rvalue; + fmi1_value_reference_t vr = 0; - fmistatus = fmi1_import_get_real(fmu, &vr, 1, &rvalue); - printf("rvalue = %f\n", rvalue); + fmistatus = fmi1_import_get_real(fmu, &vr, 1, &rvalue); + printf("rvalue = %f\n", rvalue); #endif - fmistatus = fmi1_import_do_step(fmu, tcur, hstep, newStep); - - for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi1_value_reference_t); k++) { - fmi1_value_reference_t vr = compare_real_variables_vr[k]; - fmi1_real_t rvalue; - fmistatus = fmi1_import_get_real(fmu, &vr, 1, &rvalue); - } - { - fmi1_real_t val[2]; - fmi1_import_get_real(fmu, compare_real_variables_vr, 2, val); - printf("%10g %10g\n", val[0],val[1]); - } - - tcur += hstep; - } - - printf("Simulation finished. Checking results\n"); - - /* Validate result */ - for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi1_value_reference_t); k++) { - fmi1_value_reference_t vr = compare_real_variables_vr[k]; - fmi1_real_t rvalue; - fmi1_real_t res; - fmistatus = fmi1_import_get_real(fmu, &vr, 1, &rvalue); - res = rvalue - simulation_results[k]; - res = res > 0 ? res: -res; /* Take abs */ - if (res > 3e-3) { - printf("Simulation results is wrong!\n"); - printf("State [%u] %g != %g, |res| = %g\n", (unsigned)k, rvalue, simulation_results[k], res); - printf("\n"); - do_exit(CTEST_RETURN_FAIL); - } - } - - fmistatus = fmi1_import_terminate_slave(fmu); - - fmi1_import_free_slave_instance(fmu); - - return 0; + fmistatus = fmi1_import_do_step(fmu, tcur, hstep, newStep); + + for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi1_value_reference_t); k++) { + fmi1_value_reference_t vr = compare_real_variables_vr[k]; + fmi1_real_t rvalue; + fmistatus = fmi1_import_get_real(fmu, &vr, 1, &rvalue); + } + { + fmi1_real_t val[2]; + fmi1_import_get_real(fmu, compare_real_variables_vr, 2, val); + printf("%10g %10g\n", val[0],val[1]); + } + + tcur += hstep; + } + + printf("Simulation finished. Checking results\n"); + + /* Validate result */ + for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi1_value_reference_t); k++) { + fmi1_value_reference_t vr = compare_real_variables_vr[k]; + fmi1_real_t rvalue; + fmi1_real_t res; + fmistatus = fmi1_import_get_real(fmu, &vr, 1, &rvalue); + res = rvalue - simulation_results[k]; + res = res > 0 ? res: -res; /* Take abs */ + if (res > 3e-3) { + printf("Simulation results is wrong!\n"); + printf("State [%u] %g != %g, |res| = %g\n", (unsigned)k, rvalue, simulation_results[k], res); + printf("\n"); + do_exit(CTEST_RETURN_FAIL); + } + } + + fmistatus = fmi1_import_terminate_slave(fmu); + + fmi1_import_free_slave_instance(fmu); + + return 0; } int main(int argc, char *argv[]) { - fmi1_callback_functions_t callBackFunctions; - const char* FMUPath; - const char* tmpPath; - const char* xmlFileName; - jm_callbacks callbacks; - fmi_import_context_t* context; - fmi_version_enu_t version; - jm_status_enu_t status; - int k; - - fmi1_import_t* fmu; - - if(argc < 4) { - printf("Usage: %s \n", argv[0]); - do_exit(CTEST_RETURN_FAIL); - } - for (k = 0; k < argc; k ++) - printf("argv[%d] = %s\n", k, argv[k]); - - FMUPath = argv[1]; - tmpPath = argv[2]; - xmlFileName = argv[3]; - - callbacks.malloc = malloc; + fmi1_callback_functions_t callBackFunctions; + const char* FMUPath; + const char* tmpPath; + const char* xmlFileName; + jm_callbacks callbacks; + fmi_import_context_t* context; + fmi_version_enu_t version; + jm_status_enu_t status; + int k; + + fmi1_import_t* fmu; + + if(argc < 4) { + printf("Usage: %s \n", argv[0]); + do_exit(CTEST_RETURN_FAIL); + } + for (k = 0; k < argc; k ++) + printf("argv[%d] = %s\n", k, argv[k]); + + FMUPath = argv[1]; + tmpPath = argv[2]; + xmlFileName = argv[3]; + + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; - callBackFunctions.logger = fmi1_log_forwarding; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; + callBackFunctions.logger = fmi1_log_forwarding; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; #ifdef FMILIB_GENERATE_BUILD_STAMP - printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); + printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); #endif - context = fmi_import_allocate_context(&callbacks); + context = fmi_import_allocate_context(&callbacks); - version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); + version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); - if(version != fmi_version_1_enu) { - printf("Only version 1.0 is supported so far\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(version != fmi_version_1_enu) { + printf("Only version 1.0 is supported so far\n"); + do_exit(CTEST_RETURN_FAIL); + } - fmu = fmi1_import_parse_xml(context, tmpPath); + fmu = fmi1_import_parse_xml(context, tmpPath); - if(!fmu) { - printf("Error parsing XML, exiting\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(!fmu) { + printf("Error parsing XML, exiting\n"); + do_exit(CTEST_RETURN_FAIL); + } - status = fmi1_import_create_dllfmu(fmu, callBackFunctions, 1); - if (status == jm_status_error) { - printf("Could not create the DLL loading mechanism(C-API) (error: %s).\n", fmi1_import_get_last_error(fmu)); - do_exit(CTEST_RETURN_FAIL); - } + status = fmi1_import_create_dllfmu(fmu, callBackFunctions, 1); + if (status == jm_status_error) { + printf("Could not create the DLL loading mechanism(C-API) (error: %s).\n", fmi1_import_get_last_error(fmu)); + do_exit(CTEST_RETURN_FAIL); + } - test_simulate_cs(fmu); - test_xml(xmlFileName, fmu); + test_simulate_cs(fmu); + test_xml(xmlFileName, fmu); - fmi1_import_destroy_dllfmu(fmu); + fmi1_import_destroy_dllfmu(fmu); - fmi1_import_free(fmu); - fmi_import_free_context(context); + fmi1_import_free(fmu); + fmi_import_free_context(context); - printf("Everything seems to be OK since you got this far=)!\n"); + printf("Everything seems to be OK since you got this far=)!\n"); - do_exit(CTEST_RETURN_SUCCESS); + do_exit(CTEST_RETURN_SUCCESS); - return 0; + return 0; } diff --git a/Test/FMI1/fmi_import_me_test.c b/Test/FMI1/fmi_import_me_test.c index 69e8a83d..9b7b61f9 100644 --- a/Test/FMI1/fmi_import_me_test.c +++ b/Test/FMI1/fmi_import_me_test.c @@ -24,252 +24,252 @@ void do_exit(int code) { - printf("Press 'Enter' to exit\n"); - /* getchar(); */ - exit(code); + printf("Press 'Enter' to exit\n"); + /* getchar(); */ + exit(code); } int test_simulate_me(fmi1_import_t* fmu) { - fmi1_status_t fmistatus; - jm_status_enu_t jmstatus; - fmi1_real_t tstart = 0.0; - fmi1_real_t tcur; - fmi1_real_t hcur; - fmi1_real_t hdef = 0.1; - fmi1_real_t tend = 2.0; - size_t n_states; - size_t n_event_indicators; - fmi1_real_t* states; - fmi1_real_t states_end_results[] = {0.362000, -3.962000}; - fmi1_real_t* states_der; - fmi1_real_t* event_indicators; - fmi1_real_t* event_indicators_prev; - fmi1_boolean_t callEventUpdate; - fmi1_boolean_t toleranceControlled = fmi1_true; - fmi1_real_t relativeTolerance = 0.001; - fmi1_event_info_t eventInfo; - fmi1_boolean_t intermediateResults = fmi1_false; - size_t k; - - printf("Version returned from FMU: %s\n", fmi1_import_get_version(fmu)); - printf("Platform type returned: %s\n", fmi1_import_get_model_types_platform(fmu)); - - n_states = fmi1_import_get_number_of_continuous_states(fmu); - n_event_indicators = fmi1_import_get_number_of_event_indicators(fmu); - - if (sizeof(states_end_results)/sizeof(fmi1_real_t) != n_states) { - printf("Number of states and results have different length n_states = %u n_results = %u\n", (unsigned)n_states, (unsigned)sizeof(states_end_results)); - do_exit(CTEST_RETURN_FAIL); - } - - states = calloc(n_states, sizeof(double)); - states_der = calloc(n_states, sizeof(double)); - event_indicators = calloc(n_event_indicators, sizeof(double)); - event_indicators_prev = calloc(n_event_indicators, sizeof(double)); - - jmstatus = fmi1_import_instantiate_model(fmu, "Test ME model instance"); - if (jmstatus == jm_status_error) { - printf("fmi1_import_instantiate_model failed\n"); - do_exit(CTEST_RETURN_FAIL); - } - - fmistatus = fmi1_import_set_time(fmu, tstart); - - fmistatus = fmi1_import_initialize(fmu, toleranceControlled, relativeTolerance, &eventInfo); - - fmistatus = fmi1_import_get_continuous_states(fmu, states, n_states); - fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators_prev, n_event_indicators); - - fmistatus = fmi1_import_set_debug_logging(fmu, fmi1_false); - printf("fmi1_import_set_debug_logging: %s\n", fmi1_status_to_string(fmistatus)); - fmi1_import_set_debug_logging(fmu, fmi1_true); - - tcur = tstart; - hcur = hdef; - callEventUpdate = fmi1_false; - - while (tcur < tend) { - size_t k; - int zero_crossning_event = 0; - - fmistatus = fmi1_import_set_time(fmu, tcur); - fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators, n_event_indicators); - - /* Check if an event inidcator has triggered */ - for (k = 0; k < n_event_indicators; k++) { - if (event_indicators[k]*event_indicators_prev[k] < 0) { - zero_crossning_event = 1; - break; - } - } - - /* Handle any events */ - if (callEventUpdate || zero_crossning_event || (eventInfo.upcomingTimeEvent && tcur == eventInfo.nextEventTime)) { - fmistatus = fmi1_import_eventUpdate(fmu, intermediateResults, &eventInfo); - fmistatus = fmi1_import_get_continuous_states(fmu, states, n_states); - fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators, n_event_indicators); - fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators_prev, n_event_indicators); - } - - /* Updated next time step */ - if (eventInfo.upcomingTimeEvent) { - if (tcur + hdef < eventInfo.nextEventTime) { - hcur = hdef; - } else { - hcur = eventInfo.nextEventTime - tcur; - } - } else { - hcur = hdef; - } - tcur += hcur; - if(tcur > tend - hcur/1e16) { - tcur -= hcur; - hcur = (tend - tcur); - tcur = tend; - } - /* Integrate a step */ - fmistatus = fmi1_import_get_derivatives(fmu, states_der, n_states); - for (k = 0; k < n_states; k++) { - states[k] = states[k] + hcur*states_der[k]; - if (k == 0) printf("Ball HEIGHT state[%u] = %f\n", (unsigned)k, states[k]); - } - - /* Set states */ - fmistatus = fmi1_import_set_continuous_states(fmu, states, n_states); - /* Step is complete */ - fmistatus = fmi1_import_completed_integrator_step(fmu, &callEventUpdate); - } - - /* Validate result */ - for (k = 0; k < n_states; k++) { - fmi1_real_t res = states[k] - states_end_results[k]; - res = res > 0 ? res: -res; /* Take abs */ - if (res > 1e-10) { - printf("Simulation results is wrong states[%u] %f != %f, |res| = %f\n", (unsigned)k, states[k], states_end_results[k], res); - do_exit(CTEST_RETURN_FAIL); - } - } - - - fmistatus = fmi1_import_terminate(fmu); - - fmi1_import_free_model_instance(fmu); - - free(states); - free(states_der); - free(event_indicators); - free(event_indicators_prev); - - return 0; + fmi1_status_t fmistatus; + jm_status_enu_t jmstatus; + fmi1_real_t tstart = 0.0; + fmi1_real_t tcur; + fmi1_real_t hcur; + fmi1_real_t hdef = 0.1; + fmi1_real_t tend = 2.0; + size_t n_states; + size_t n_event_indicators; + fmi1_real_t* states; + fmi1_real_t states_end_results[] = {0.362000, -3.962000}; + fmi1_real_t* states_der; + fmi1_real_t* event_indicators; + fmi1_real_t* event_indicators_prev; + fmi1_boolean_t callEventUpdate; + fmi1_boolean_t toleranceControlled = fmi1_true; + fmi1_real_t relativeTolerance = 0.001; + fmi1_event_info_t eventInfo; + fmi1_boolean_t intermediateResults = fmi1_false; + size_t k; + + printf("Version returned from FMU: %s\n", fmi1_import_get_version(fmu)); + printf("Platform type returned: %s\n", fmi1_import_get_model_types_platform(fmu)); + + n_states = fmi1_import_get_number_of_continuous_states(fmu); + n_event_indicators = fmi1_import_get_number_of_event_indicators(fmu); + + if (sizeof(states_end_results)/sizeof(fmi1_real_t) != n_states) { + printf("Number of states and results have different length n_states = %u n_results = %u\n", (unsigned)n_states, (unsigned)sizeof(states_end_results)); + do_exit(CTEST_RETURN_FAIL); + } + + states = calloc(n_states, sizeof(double)); + states_der = calloc(n_states, sizeof(double)); + event_indicators = calloc(n_event_indicators, sizeof(double)); + event_indicators_prev = calloc(n_event_indicators, sizeof(double)); + + jmstatus = fmi1_import_instantiate_model(fmu, "Test ME model instance"); + if (jmstatus == jm_status_error) { + printf("fmi1_import_instantiate_model failed\n"); + do_exit(CTEST_RETURN_FAIL); + } + + fmistatus = fmi1_import_set_time(fmu, tstart); + + fmistatus = fmi1_import_initialize(fmu, toleranceControlled, relativeTolerance, &eventInfo); + + fmistatus = fmi1_import_get_continuous_states(fmu, states, n_states); + fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators_prev, n_event_indicators); + + fmistatus = fmi1_import_set_debug_logging(fmu, fmi1_false); + printf("fmi1_import_set_debug_logging: %s\n", fmi1_status_to_string(fmistatus)); + fmi1_import_set_debug_logging(fmu, fmi1_true); + + tcur = tstart; + hcur = hdef; + callEventUpdate = fmi1_false; + + while (tcur < tend) { + size_t k; + int zero_crossning_event = 0; + + fmistatus = fmi1_import_set_time(fmu, tcur); + fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators, n_event_indicators); + + /* Check if an event inidcator has triggered */ + for (k = 0; k < n_event_indicators; k++) { + if (event_indicators[k]*event_indicators_prev[k] < 0) { + zero_crossning_event = 1; + break; + } + } + + /* Handle any events */ + if (callEventUpdate || zero_crossning_event || (eventInfo.upcomingTimeEvent && tcur == eventInfo.nextEventTime)) { + fmistatus = fmi1_import_eventUpdate(fmu, intermediateResults, &eventInfo); + fmistatus = fmi1_import_get_continuous_states(fmu, states, n_states); + fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators, n_event_indicators); + fmistatus = fmi1_import_get_event_indicators(fmu, event_indicators_prev, n_event_indicators); + } + + /* Updated next time step */ + if (eventInfo.upcomingTimeEvent) { + if (tcur + hdef < eventInfo.nextEventTime) { + hcur = hdef; + } else { + hcur = eventInfo.nextEventTime - tcur; + } + } else { + hcur = hdef; + } + tcur += hcur; + if(tcur > tend - hcur/1e16) { + tcur -= hcur; + hcur = (tend - tcur); + tcur = tend; + } + /* Integrate a step */ + fmistatus = fmi1_import_get_derivatives(fmu, states_der, n_states); + for (k = 0; k < n_states; k++) { + states[k] = states[k] + hcur*states_der[k]; + if (k == 0) printf("Ball HEIGHT state[%u] = %f\n", (unsigned)k, states[k]); + } + + /* Set states */ + fmistatus = fmi1_import_set_continuous_states(fmu, states, n_states); + /* Step is complete */ + fmistatus = fmi1_import_completed_integrator_step(fmu, &callEventUpdate); + } + + /* Validate result */ + for (k = 0; k < n_states; k++) { + fmi1_real_t res = states[k] - states_end_results[k]; + res = res > 0 ? res: -res; /* Take abs */ + if (res > 1e-10) { + printf("Simulation results is wrong states[%u] %f != %f, |res| = %f\n", (unsigned)k, states[k], states_end_results[k], res); + do_exit(CTEST_RETURN_FAIL); + } + } + + + fmistatus = fmi1_import_terminate(fmu); + + fmi1_import_free_model_instance(fmu); + + free(states); + free(states_der); + free(event_indicators); + free(event_indicators_prev); + + return 0; } typedef struct { - fmi1_import_t* fmu; - fmi_import_context_t* context; - jm_callbacks* callbacks; - fmi1_callback_functions_t callBackFunctions; + fmi1_import_t* fmu; + fmi_import_context_t* context; + jm_callbacks* callbacks; + fmi1_callback_functions_t callBackFunctions; } fmul_t; fmul_t load(int argc, char *argv[]) { - fmi1_callback_functions_t callBackFunctions; - const char* FMUPath; - const char* tmpPath; - jm_callbacks* callbacks; - fmi_import_context_t* context; - fmi_version_enu_t version; - jm_status_enu_t status; - static int isunzipped; + fmi1_callback_functions_t callBackFunctions; + const char* FMUPath; + const char* tmpPath; + jm_callbacks* callbacks; + fmi_import_context_t* context; + fmi_version_enu_t version; + jm_status_enu_t status; + static int isunzipped; - fmi1_import_t* fmu; + fmi1_import_t* fmu; - if(argc < 3) { - printf("Usage: %s \n", argv[0]); - do_exit(CTEST_RETURN_FAIL); - } + if(argc < 3) { + printf("Usage: %s \n", argv[0]); + do_exit(CTEST_RETURN_FAIL); + } - FMUPath = argv[1]; - tmpPath = argv[2]; + FMUPath = argv[1]; + tmpPath = argv[2]; - callbacks = (jm_callbacks*)malloc(sizeof(jm_callbacks)); - callbacks->malloc = malloc; + callbacks = (jm_callbacks*)malloc(sizeof(jm_callbacks)); + callbacks->malloc = malloc; callbacks->calloc = calloc; callbacks->realloc = realloc; callbacks->free = free; callbacks->logger = jm_default_logger; - callbacks->log_level = jm_log_level_debug; + callbacks->log_level = jm_log_level_debug; callbacks->context = 0; - callBackFunctions.logger = fmi1_log_forwarding; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; + callBackFunctions.logger = fmi1_log_forwarding; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; #ifdef FMILIB_GENERATE_BUILD_STAMP - printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); + printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); #endif - context = fmi_import_allocate_context(callbacks); - - if (isunzipped == 0) { /* Unzip the FMU only once. Overwriting the dll/so file may cause a segfault. */ - version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); - if(version != fmi_version_1_enu) { - printf("Only version 1.0 is supported so far\n"); - do_exit(CTEST_RETURN_FAIL); - } - isunzipped = 1; - } - - fmu = fmi1_import_parse_xml(context, tmpPath); - - if(!fmu) { - printf("Error parsing XML, exiting\n"); - do_exit(CTEST_RETURN_FAIL); - } - - status = fmi1_import_create_dllfmu(fmu, callBackFunctions, 1); - if (status == jm_status_error) { - printf("Could not create the DLL loading mechanism(C-API test).\n"); - do_exit(CTEST_RETURN_FAIL); - } - - test_simulate_me(fmu); - - printf("Everything seems to be OK since you got this far=)!\n"); - { - fmul_t fmus; - fmus.callBackFunctions = callBackFunctions; - fmus.callbacks = callbacks; - fmus.context = context; - fmus.fmu = fmu; - return fmus; - } + context = fmi_import_allocate_context(callbacks); + + if (isunzipped == 0) { /* Unzip the FMU only once. Overwriting the dll/so file may cause a segfault. */ + version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); + if(version != fmi_version_1_enu) { + printf("Only version 1.0 is supported so far\n"); + do_exit(CTEST_RETURN_FAIL); + } + isunzipped = 1; + } + + fmu = fmi1_import_parse_xml(context, tmpPath); + + if(!fmu) { + printf("Error parsing XML, exiting\n"); + do_exit(CTEST_RETURN_FAIL); + } + + status = fmi1_import_create_dllfmu(fmu, callBackFunctions, 1); + if (status == jm_status_error) { + printf("Could not create the DLL loading mechanism(C-API test).\n"); + do_exit(CTEST_RETURN_FAIL); + } + + test_simulate_me(fmu); + + printf("Everything seems to be OK since you got this far=)!\n"); + { + fmul_t fmus; + fmus.callBackFunctions = callBackFunctions; + fmus.callbacks = callbacks; + fmus.context = context; + fmus.fmu = fmu; + return fmus; + } } void destroy(fmul_t* fmus) { - fmi1_import_destroy_dllfmu(fmus->fmu); - fmi1_import_free(fmus->fmu); - fmi_import_free_context(fmus->context); - free(fmus->callbacks); - memset(fmus, 0, sizeof(fmul_t)); + fmi1_import_destroy_dllfmu(fmus->fmu); + fmi1_import_free(fmus->fmu); + fmi_import_free_context(fmus->context); + free(fmus->callbacks); + memset(fmus, 0, sizeof(fmul_t)); } /* Load and simulate 150 FMUs. Destroy and free all memory last. Usefull testing speciall for the registerGlobally functionality. */ #define NUMBER_OF_TESTS 150 int main(int argc, char *argv[]) { - fmul_t fmul[NUMBER_OF_TESTS]; - int k; + fmul_t fmul[NUMBER_OF_TESTS]; + int k; - for (k=0;k1) { printf("Listing aliases: \n"); for(i = 0;i\n", argv[0]); - do_exit(1); - } + if(argc < 2) { + printf("Usage: %s \n", argv[0]); + do_exit(1); + } - tmpPath = argv[1]; + tmpPath = argv[1]; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = mylogger; callbacks.context = 0; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; #ifdef FMILIB_GENERATE_BUILD_STAMP - printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); + printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); #endif - context = fmi_import_allocate_context(&callbacks); + context = fmi_import_allocate_context(&callbacks); - start = clock(); - fmu = fmi1_import_parse_xml(context, tmpPath); + start = clock(); + fmu = fmi1_import_parse_xml(context, tmpPath); - if(!fmu) { - printf("Error parsing XML, exiting\n"); + if(!fmu) { + printf("Error parsing XML, exiting\n"); fmi_import_free_context(context); - do_exit(1); - } + do_exit(1); + } - /* Stop timer */ + /* Stop timer */ stop = clock(); t = (double) (stop-start)/CLOCKS_PER_SEC; @@ -323,9 +323,9 @@ int main(int argc, char *argv[]) { fmi1_import_vendor_list_t* vl = fmi1_import_get_vendor_list(fmu); size_t nv = fmi1_import_get_number_of_vendors(vl); - unsigned i; - i = (unsigned)nv; - assert( nv == i); + unsigned i; + i = (unsigned)nv; + assert( nv == i); printf("There are %u tool annotation records \n", (unsigned)nv); for( i = 0; i < nv; i++) { fmi1_import_vendor_t* vendor = fmi1_import_get_vendor(vl, i); @@ -388,34 +388,34 @@ int main(int argc, char *argv[]) } { size_t nv; - unsigned i; + unsigned i; fmi1_import_variable_list_t* vl = fmi1_import_get_variable_list(fmu); assert(vl); nv = fmi1_import_get_variable_list_size(vl); - i = (unsigned)nv; - assert(i == nv); - printf("There are %u variables in total \n",(unsigned)nv); + i = (unsigned)nv; + assert(i == nv); + printf("There are %u variables in total \n",(unsigned)nv); for(i = 0; i < nv; i++) { fmi1_import_variable_t* var = fmi1_import_get_variable(vl, i); if(!var) { - printf("Something wrong with variable %d \n",i); - do_exit(1); - } + printf("Something wrong with variable %d \n",i); + do_exit(1); + } else { printVariableInfo(fmu, var); - testVariableSearch(fmu, var); - } + testVariableSearch(fmu, var); + } } fmi1_import_free_variable_list(vl); } - fmi1_import_free(fmu); - fmi_import_free_context(context); - - printf("Everything seems to be OK since you got this far=)!\n"); + fmi1_import_free(fmu); + fmi_import_free_context(context); + + printf("Everything seems to be OK since you got this far=)!\n"); - do_exit(0); + do_exit(0); } diff --git a/Test/FMI1/fmi_total_test.c b/Test/FMI1/fmi_total_test.c index 6c664b4a..f40bcd46 100644 --- a/Test/FMI1/fmi_total_test.c +++ b/Test/FMI1/fmi_total_test.c @@ -28,57 +28,57 @@ void mylogger(fmiComponent c, fmiString instanceName, fmiStatus status, fmiString category, fmiString message, ...) { - char msg[2024]; - va_list argp; - va_start(argp, message); - vsprintf(msg, message, argp); - if (!instanceName) instanceName = "?"; - if (!category) category = "?"; - printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); + char msg[2024]; + va_list argp; + va_start(argp, message); + vsprintf(msg, message, argp); + if (!instanceName) instanceName = "?"; + if (!category) category = "?"; + printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg); } void do_pause() { #ifdef _MSC_VER - system("PAUSE"); + system("PAUSE"); #elif #endif } int main(int argc, char *argv[]) { - fmiCallbackFunctions callBackFunctions; - fmi_dll_t* fmu; - const char* FMUPath = "C:\\P510-JModelica\\FMIToolbox\\trunk\\src\\wrapperfolder\\Furuta.fmu"; - const char* tmpPath = "C:\\Documents and Settings\\p418_baa\\Desktop\\XMLtest\\temporaryfolder"; - const char* dllPath; - const char* modelIdentifier; - const char* modelName; - const char* model_description_path; - const char* instanceName; - const char* GUID; - fmi_dll_standard_enu_t standard = FMI_ME1; /* or FMI_CS1 */ + fmiCallbackFunctions callBackFunctions; + fmi_dll_t* fmu; + const char* FMUPath = "C:\\P510-JModelica\\FMIToolbox\\trunk\\src\\wrapperfolder\\Furuta.fmu"; + const char* tmpPath = "C:\\Documents and Settings\\p418_baa\\Desktop\\XMLtest\\temporaryfolder"; + const char* dllPath; + const char* modelIdentifier; + const char* modelName; + const char* model_description_path; + const char* instanceName; + const char* GUID; + fmi_dll_standard_enu_t standard = FMI_ME1; /* or FMI_CS1 */ - fmiBoolean loggingOn = fmiTrue; - fmi1_xml_model_description_t* md; - jm_status_enu_t status; + fmiBoolean loggingOn = fmiTrue; + fmi1_xml_model_description_t* md; + jm_status_enu_t status; - PRINT_MY_DEBUG; + PRINT_MY_DEBUG; - if (jm_status_error == fmi_zip_unzip(FMUPath, tmpPath)) { - printf("Failed to unzip the FMU file\n"); - abort(); - } + if (jm_status_error == fmi_zip_unzip(FMUPath, tmpPath)) { + printf("Failed to unzip the FMU file\n"); + abort(); + } - callBackFunctions.logger = mylogger; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; + callBackFunctions.logger = mylogger; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; - model_description_path = fmi_import_get_model_description_path(tmpPath, callBackFunctions); + model_description_path = fmi_import_get_model_description_path(tmpPath, callBackFunctions); - md = fmi1_xml_allocate_model_description(0); + md = fmi1_xml_allocate_model_description(0); if(!md) abort(); @@ -86,54 +86,54 @@ int main(int argc, char *argv[]) printf("Error parsing XML file %s:%s\n", FMUPath, fmi1_xml_get_last_error(md)); fmi1_xml_free_model_description(md); abort(); - } + } + - printf("Model name: %s\n", fmi1_xml_get_model_name(md)); printf("Model identifier: %s\n", fmi1_xml_get_model_identifier(md)); printf("Model GUID: %s\n", fmi1_xml_get_GUID(md)); - modelIdentifier = fmi1_xml_get_model_identifier(md); - modelName = fmi1_xml_get_model_name(md); - GUID = fmi1_xml_get_GUID(md); + modelIdentifier = fmi1_xml_get_model_identifier(md); + modelName = fmi1_xml_get_model_name(md); + GUID = fmi1_xml_get_GUID(md); + + modelIdentifier = fmi1_xml_get_model_identifier(md); - modelIdentifier = fmi1_xml_get_model_identifier(md); - - dllPath = fmi_import_get_dll_path(tmpPath, modelIdentifier, callBackFunctions); + dllPath = fmi_import_get_dll_path(tmpPath, modelIdentifier, callBackFunctions); - fmu = fmi_dll_common_create_dllfmu(dllPath, modelIdentifier, callBackFunctions, standard); - if (fmu == NULL) { - printf("An error occured while fmi_dll_common_create_dllfmu was called, an error message should been printed.\n"); - do_pause(); - return 0; - } + fmu = fmi_dll_common_create_dllfmu(dllPath, modelIdentifier, callBackFunctions, standard); + if (fmu == NULL) { + printf("An error occured while fmi_dll_common_create_dllfmu was called, an error message should been printed.\n"); + do_pause(); + return 0; + } - status = fmi_dll_common_load_dll(fmu); - if (status == jm_status_error) { - printf("Error in fmi_dll_common_load_dll: %s\n", fmi_dll_common_get_last_error(fmu)); - do_pause(); - return 0; - } + status = fmi_dll_common_load_dll(fmu); + if (status == jm_status_error) { + printf("Error in fmi_dll_common_load_dll: %s\n", fmi_dll_common_get_last_error(fmu)); + do_pause(); + return 0; + } - status = fmi_dll_common_load_fcn(fmu); - if (status == jm_status_error) { - printf("Error in fmi_dll_common_load_fcn: %s\n", fmi_dll_common_get_last_error(fmu)); - do_pause(); - return 0; - } + status = fmi_dll_common_load_fcn(fmu); + if (status == jm_status_error) { + printf("Error in fmi_dll_common_load_fcn: %s\n", fmi_dll_common_get_last_error(fmu)); + do_pause(); + return 0; + } - printf("fmi_dll_1_0_me_get_version: %s\n", fmi_dll_1_0_me_get_version(fmu)); + printf("fmi_dll_1_0_me_get_version: %s\n", fmi_dll_1_0_me_get_version(fmu)); - fmi_dll_common_free_dll(fmu); - fmi_dll_common_destroy_dllfmu(fmu); + fmi_dll_common_free_dll(fmu); + fmi_dll_common_destroy_dllfmu(fmu); - fmi1_xml_free_model_description(md); + fmi1_xml_free_model_description(md); - printf("Everything seems to be OK since you got this far=)!\n"); + printf("Everything seems to be OK since you got this far=)!\n"); - do_pause(); + do_pause(); } diff --git a/Test/FMI1/fmi_zip_unzip_test.c b/Test/FMI1/fmi_zip_unzip_test.c index c493ac0c..87231202 100644 --- a/Test/FMI1/fmi_zip_unzip_test.c +++ b/Test/FMI1/fmi_zip_unzip_test.c @@ -27,9 +27,9 @@ void do_exit(int code) { - printf("Press any key to exit\n"); - /* getchar(); */ - exit(code); + printf("Press any key to exit\n"); + /* getchar(); */ + exit(code); } /* Logger function */ @@ -44,26 +44,26 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve */ int main(int argc, char *argv[]) { - jm_callbacks callbacks; - jm_status_enu_t status; + jm_callbacks callbacks; + jm_status_enu_t status; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; - status = fmi_zip_unzip(UNCOMPRESSED_DUMMY_FILE_PATH_SRC, UNCOMPRESSED_DUMMY_FOLDER_PATH_DIST, &callbacks); + status = fmi_zip_unzip(UNCOMPRESSED_DUMMY_FILE_PATH_SRC, UNCOMPRESSED_DUMMY_FOLDER_PATH_DIST, &callbacks); - if (status == jm_status_error) { - printf("Failed to uncompress the file\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("Succesfully uncompressed the file\n"); - do_exit(CTEST_RETURN_SUCCESS); - } + if (status == jm_status_error) { + printf("Failed to uncompress the file\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("Succesfully uncompressed the file\n"); + do_exit(CTEST_RETURN_SUCCESS); + } return 0; } diff --git a/Test/FMI1/fmi_zip_zip_test.c b/Test/FMI1/fmi_zip_zip_test.c index 3dc1fa1f..bf3ccc73 100644 --- a/Test/FMI1/fmi_zip_zip_test.c +++ b/Test/FMI1/fmi_zip_zip_test.c @@ -27,9 +27,9 @@ void do_exit(int code) { - printf("Press any key to exit\n"); - /* getchar(); */ - exit(code); + printf("Press any key to exit\n"); + /* getchar(); */ + exit(code); } /* Logger function */ @@ -44,30 +44,30 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve */ int main(int argc, char *argv[]) { - jm_status_enu_t status; - jm_callbacks callbacks; - - const char* files_to_zip[] = {COMPRESS_DUMMY_FILE_PATH_SRC}; - int n_files_to_zip = 1; + jm_status_enu_t status; + jm_callbacks callbacks; - callbacks.malloc = malloc; + const char* files_to_zip[] = {COMPRESS_DUMMY_FILE_PATH_SRC}; + int n_files_to_zip = 1; + + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; - status = fmi_zip_zip(COMPRESS_DUMMY_FILE_PATH_DIST, n_files_to_zip, files_to_zip, &callbacks); + status = fmi_zip_zip(COMPRESS_DUMMY_FILE_PATH_DIST, n_files_to_zip, files_to_zip, &callbacks); - if (status == jm_status_error) { - printf("Failed to compress the file\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("Succesfully compressed the file\n"); - do_exit(CTEST_RETURN_SUCCESS); - } + if (status == jm_status_error) { + printf("Failed to compress the file\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("Succesfully compressed the file\n"); + do_exit(CTEST_RETURN_SUCCESS); + } return 0; } diff --git a/Test/FMI1/fmu_dummy/fmu1_model.c b/Test/FMI1/fmu_dummy/fmu1_model.c index 1133ac17..b1694597 100644 --- a/Test/FMI1/fmu_dummy/fmu1_model.c +++ b/Test/FMI1/fmu_dummy/fmu1_model.c @@ -22,226 +22,226 @@ along with this program. If not, contact Modelon AB . /* Model calculation functions */ static int calc_initialize(component_ptr_t comp) { - comp->states[VAR_R_HEIGHT] = 1.0; - comp->states[VAR_R_HEIGHT_SPEED] = 4; - comp->reals [VAR_R_GRATIVY] = -9.81; - comp->reals [VAR_R_BOUNCE_CONF] = 0.5; - if(comp->loggingOn) { - comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "###### Initializing component ######"); - comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g", VAR_R_HEIGHT, comp->states[VAR_R_HEIGHT]); - comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g",VAR_R_HEIGHT_SPEED, comp->states[VAR_R_HEIGHT_SPEED]); - comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g",VAR_R_GRATIVY, comp->reals [VAR_R_GRATIVY]); - comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g",VAR_R_BOUNCE_CONF, comp->reals [VAR_R_BOUNCE_CONF]); - comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #r-1#"); - comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #r1"); - comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #t1#"); - comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #r10#"); - } - return 0; + comp->states[VAR_R_HEIGHT] = 1.0; + comp->states[VAR_R_HEIGHT_SPEED] = 4; + comp->reals [VAR_R_GRATIVY] = -9.81; + comp->reals [VAR_R_BOUNCE_CONF] = 0.5; + if(comp->loggingOn) { + comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "###### Initializing component ######"); + comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g", VAR_R_HEIGHT, comp->states[VAR_R_HEIGHT]); + comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g",VAR_R_HEIGHT_SPEED, comp->states[VAR_R_HEIGHT_SPEED]); + comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g",VAR_R_GRATIVY, comp->reals [VAR_R_GRATIVY]); + comp->functions.logger(comp, comp->instanceName, fmiOK, "INFO", "Init #r%d#=%g",VAR_R_BOUNCE_CONF, comp->reals [VAR_R_BOUNCE_CONF]); + comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #r-1#"); + comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #r1"); + comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #t1#"); + comp->functions.logger(comp, comp->instanceName, fmiOK, "ERROR", "Bad reference: #r10#"); + } + return 0; } static int calc_get_derivatives(component_ptr_t comp) { - comp->states_der[VAR_R_HEIGHT] = comp->states[VAR_R_HEIGHT_SPEED]; - comp->states_der[VAR_R_HEIGHT_SPEED] = comp->reals[VAR_R_GRATIVY]; - return 0; + comp->states_der[VAR_R_HEIGHT] = comp->states[VAR_R_HEIGHT_SPEED]; + comp->states_der[VAR_R_HEIGHT_SPEED] = comp->reals[VAR_R_GRATIVY]; + return 0; } static int calc_get_event_indicators(component_ptr_t comp) { - fmiReal event_tol = 1e-16; - comp->event_indicators[EVENT_HEIGHT] = comp->states[VAR_R_HEIGHT] + (comp->states[VAR_R_HEIGHT] >= 0 ? event_tol : -event_tol); - return 0; + fmiReal event_tol = 1e-16; + comp->event_indicators[EVENT_HEIGHT] = comp->states[VAR_R_HEIGHT] + (comp->states[VAR_R_HEIGHT] >= 0 ? event_tol : -event_tol); + return 0; } static int calc_event_update(component_ptr_t comp) { - if (comp->states[VAR_R_HEIGHT] < 0) { - comp->states[VAR_R_HEIGHT_SPEED] = - comp->reals[VAR_R_BOUNCE_CONF] * comp->states[VAR_R_HEIGHT_SPEED]; - comp->states[VAR_R_HEIGHT] = 0; + if (comp->states[VAR_R_HEIGHT] < 0) { + comp->states[VAR_R_HEIGHT_SPEED] = - comp->reals[VAR_R_BOUNCE_CONF] * comp->states[VAR_R_HEIGHT_SPEED]; + comp->states[VAR_R_HEIGHT] = 0; - comp->eventInfo.iterationConverged = fmiTrue; - comp->eventInfo.stateValueReferencesChanged = fmiFalse; - comp->eventInfo.stateValuesChanged = fmiTrue; - comp->eventInfo.terminateSimulation = fmiFalse; - comp->eventInfo.upcomingTimeEvent = fmiFalse; - comp->eventInfo.nextEventTime = -0.0; - return 0; - } else { - return 1; /* Should not call the event update */ - } + comp->eventInfo.iterationConverged = fmiTrue; + comp->eventInfo.stateValueReferencesChanged = fmiFalse; + comp->eventInfo.stateValuesChanged = fmiTrue; + comp->eventInfo.terminateSimulation = fmiFalse; + comp->eventInfo.upcomingTimeEvent = fmiFalse; + comp->eventInfo.nextEventTime = -0.0; + return 0; + } else { + return 1; /* Should not call the event update */ + } } /* FMI 1.0 Common Functions */ const char* fmi_get_version() { - return FMI_VERSION; + return FMI_VERSION; } fmiStatus fmi_set_debug_logging(fmiComponent c, fmiBoolean loggingOn) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - comp->loggingOn = loggingOn; - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + comp->loggingOn = loggingOn; + return fmiOK; + } } fmiStatus fmi_get_real(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - fmiValueReference cvr = vr[k]; - if (cvr < N_STATES) { - value[k] = comp->states[cvr]; - } - else { - value[k] = comp->reals[cvr]; - } - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + fmiValueReference cvr = vr[k]; + if (cvr < N_STATES) { + value[k] = comp->states[cvr]; + } + else { + value[k] = comp->reals[cvr]; + } + } + return fmiOK; + } } fmiStatus fmi_get_integer(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->integers[vr[k]]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + value[k] = comp->integers[vr[k]]; + } + return fmiOK; + } } fmiStatus fmi_get_boolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->booleans[vr[k]]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + value[k] = comp->booleans[vr[k]]; + } + return fmiOK; + } } fmiStatus fmi_get_string(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->strings[vr[k]]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + value[k] = comp->strings[vr[k]]; + } + return fmiOK; + } } fmiStatus fmi_set_real(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - fmiValueReference cvr = vr[k]; - if (cvr < N_STATES) { - comp->states[cvr] = value[k]; - } - else { - comp->reals[cvr] = value[k]; - } - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + fmiValueReference cvr = vr[k]; + if (cvr < N_STATES) { + comp->states[cvr] = value[k]; + } + else { + comp->reals[cvr] = value[k]; + } + } + return fmiOK; + } } fmiStatus fmi_set_integer(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - comp->integers[vr[k]] = value[k]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + comp->integers[vr[k]] = value[k]; + } + return fmiOK; + } } fmiStatus fmi_set_boolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - comp->booleans[vr[k]] = value[k]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + comp->booleans[vr[k]] = value[k]; + } + return fmiOK; + } } fmiStatus fmi_set_string(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - size_t len; - fmiString s_dist; - fmiString s_src = value[k]; - - len = strlen((char*)s_src) + 1; - s_dist = comp->functions.allocateMemory(len, sizeof(char)); - if (s_dist == NULL) { - return fmiFatal; - } - strcpy((char*)s_dist, (char*)s_src); - if(comp->strings[vr[k]]) { - comp->functions.freeMemory((void*)comp->strings[vr[k]]); - } - comp->strings[vr[k]] = s_dist; - } - - /******* Logger test *******/ - if(comp->loggingOn == fmiTrue) { - for (k = 0; k < nvr; k++) { - fmiValueReference cvr = vr[k]; - if (cvr == VAR_S_LOGGER_TEST) { - comp->functions.logger(comp, comp->instanceName, fmiFatal, "INFO", "%s",value[k]); - } - } - } - /******* End of logger test *******/ - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + size_t len; + fmiString s_dist; + fmiString s_src = value[k]; + + len = strlen((char*)s_src) + 1; + s_dist = comp->functions.allocateMemory(len, sizeof(char)); + if (s_dist == NULL) { + return fmiFatal; + } + strcpy((char*)s_dist, (char*)s_src); + if(comp->strings[vr[k]]) { + comp->functions.freeMemory((void*)comp->strings[vr[k]]); + } + comp->strings[vr[k]] = s_dist; + } + + /******* Logger test *******/ + if(comp->loggingOn == fmiTrue) { + for (k = 0; k < nvr; k++) { + fmiValueReference cvr = vr[k]; + if (cvr == VAR_S_LOGGER_TEST) { + comp->functions.logger(comp, comp->instanceName, fmiFatal, "INFO", "%s",value[k]); + } + } + } + /******* End of logger test *******/ + return fmiOK; + } } /* FMI 1.0 ME Functions */ const char* fmi_get_model_types_platform() { - return FMI_PLATFORM_TYPE; + return FMI_PLATFORM_TYPE; } #define FMI_TEST_LOGGER_TEST_RESULT_FILE "C:\\P510-JModelica\\FMIToolbox\\trunk\\external\\FMIL\\build\\testfolder\\" @@ -253,459 +253,459 @@ const char* fmi_get_model_types_platform() fmiComponent fmi_instantiate_model(fmiString instanceName, fmiString GUID, fmiCallbackFunctions functions, fmiBoolean loggingOn) { - component_ptr_t comp; - int k, p; - - comp = (component_ptr_t)functions.allocateMemory(1, sizeof(component_t)); - if (comp == NULL) { - return NULL; - } else if (strcmp(GUID, FMI_GUID) != 0) { - return NULL; - } else { - sprintf(comp->instanceName, "%s", instanceName); - sprintf(comp->GUID, "%s",GUID); - comp->functions = functions; - comp->loggingOn = loggingOn; - - comp->callEventUpdate = fmiFalse; - - /* Set default values */ - for (k = 0; k < N_STATES; k++) comp->states[k] = 0.0; - for (k = 0; k < N_STATES; k++) comp->states_prev[k] = 0.0; /* Used in CS only */ - for (k = 0; k < N_STATES; k++) comp->states_nom[k] = 1.0; - for (k = 0; k < N_STATES; k++) comp->states_vr[k] = k; - for (k = 0; k < N_STATES; k++) comp->states_der[k] = 0.0; - for (k = 0; k < N_EVENT_INDICATORS; k++) comp->event_indicators[k] = 1e10; - for (k = 0; k < N_REAL; k++) comp->reals[k] = 0.0; - for (k = 0; k < N_INTEGER; k++) comp->integers[k] = 0; - for (k = 0; k < N_BOOLEAN; k++) comp->booleans[k] = fmiFalse; - for (k = 0; k < N_STRING; k++) comp->strings[k] = NULL; - - /* Used in CS only */ - for (k = 0; k < N_INPUT_REAL; k++) { - for (p = 0; p < N_INPUT_REAL_MAX_ORDER + 1; p++) { - comp->input_real[k][p] = 0.0; - } - } - - /* Used in CS only */ - for (k = 0; k < N_OUTPUT_REAL; k++) { - for (p = 0; p < N_OUTPUT_REAL_MAX_ORDER + 1; p++) { - comp->output_real[k][p] = MAGIC_TEST_VALUE; - } - } - - return comp; - } + component_ptr_t comp; + int k, p; + + comp = (component_ptr_t)functions.allocateMemory(1, sizeof(component_t)); + if (comp == NULL) { + return NULL; + } else if (strcmp(GUID, FMI_GUID) != 0) { + return NULL; + } else { + sprintf(comp->instanceName, "%s", instanceName); + sprintf(comp->GUID, "%s",GUID); + comp->functions = functions; + comp->loggingOn = loggingOn; + + comp->callEventUpdate = fmiFalse; + + /* Set default values */ + for (k = 0; k < N_STATES; k++) comp->states[k] = 0.0; + for (k = 0; k < N_STATES; k++) comp->states_prev[k] = 0.0; /* Used in CS only */ + for (k = 0; k < N_STATES; k++) comp->states_nom[k] = 1.0; + for (k = 0; k < N_STATES; k++) comp->states_vr[k] = k; + for (k = 0; k < N_STATES; k++) comp->states_der[k] = 0.0; + for (k = 0; k < N_EVENT_INDICATORS; k++) comp->event_indicators[k] = 1e10; + for (k = 0; k < N_REAL; k++) comp->reals[k] = 0.0; + for (k = 0; k < N_INTEGER; k++) comp->integers[k] = 0; + for (k = 0; k < N_BOOLEAN; k++) comp->booleans[k] = fmiFalse; + for (k = 0; k < N_STRING; k++) comp->strings[k] = NULL; + + /* Used in CS only */ + for (k = 0; k < N_INPUT_REAL; k++) { + for (p = 0; p < N_INPUT_REAL_MAX_ORDER + 1; p++) { + comp->input_real[k][p] = 0.0; + } + } + + /* Used in CS only */ + for (k = 0; k < N_OUTPUT_REAL; k++) { + for (p = 0; p < N_OUTPUT_REAL_MAX_ORDER + 1; p++) { + comp->output_real[k][p] = MAGIC_TEST_VALUE; + } + } + + return comp; + } } void fmi_free_model_instance(fmiComponent c) { - int i; - component_ptr_t comp = (fmiComponent)c; - for(i = 0; i < N_STRING; i++) { - comp->functions.freeMemory((void*)(comp->strings[i])); - comp->strings[i] = 0; - } - comp->functions.freeMemory(c); + int i; + component_ptr_t comp = (fmiComponent)c; + for(i = 0; i < N_STRING; i++) { + comp->functions.freeMemory((void*)(comp->strings[i])); + comp->strings[i] = 0; + } + comp->functions.freeMemory(c); } fmiStatus fmi_set_time(fmiComponent c, fmiReal fmitime) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - comp->fmitime = fmitime; - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + comp->fmitime = fmitime; + return fmiOK; + } } fmiStatus fmi_set_continuous_states(fmiComponent c, const fmiReal x[], size_t nx) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nx; k++) { - comp->states[k] = x[k]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nx; k++) { + comp->states[k] = x[k]; + } + return fmiOK; + } } fmiStatus fmi_completed_integrator_step(fmiComponent c, fmiBoolean* callEventUpdate) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - *callEventUpdate = comp->callEventUpdate; - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + *callEventUpdate = comp->callEventUpdate; + return fmiOK; + } } fmiStatus fmi_initialize(fmiComponent c, fmiBoolean toleranceControlled, fmiReal relativeTolerance, fmiEventInfo* eventInfo) { - component_ptr_t comp = (fmiComponent)c; + component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - comp->eventInfo.iterationConverged = fmiFalse; - comp->eventInfo.stateValueReferencesChanged = fmiFalse; - comp->eventInfo.stateValuesChanged = fmiFalse; - comp->eventInfo.terminateSimulation = fmiFalse; - comp->eventInfo.upcomingTimeEvent = fmiFalse; - comp->eventInfo.nextEventTime = -0.0; + if (comp == NULL) { + return fmiFatal; + } else { + comp->eventInfo.iterationConverged = fmiFalse; + comp->eventInfo.stateValueReferencesChanged = fmiFalse; + comp->eventInfo.stateValuesChanged = fmiFalse; + comp->eventInfo.terminateSimulation = fmiFalse; + comp->eventInfo.upcomingTimeEvent = fmiFalse; + comp->eventInfo.nextEventTime = -0.0; - comp->toleranceControlled = toleranceControlled; - comp->relativeTolerance = relativeTolerance; + comp->toleranceControlled = toleranceControlled; + comp->relativeTolerance = relativeTolerance; - calc_initialize(comp); + calc_initialize(comp); - *eventInfo = comp->eventInfo; + *eventInfo = comp->eventInfo; - return fmiOK; - } + return fmiOK; + } } fmiStatus fmi_get_derivatives(fmiComponent c, fmiReal derivatives[] , size_t nx) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; - calc_get_derivatives(comp); + calc_get_derivatives(comp); - for (k = 0; k < nx; k++) { - derivatives[k] = comp->states_der[k]; - } - return fmiOK; - } + for (k = 0; k < nx; k++) { + derivatives[k] = comp->states_der[k]; + } + return fmiOK; + } } fmiStatus fmi_get_event_indicators(fmiComponent c, fmiReal eventIndicators[], size_t ni) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; - calc_get_event_indicators(comp); + calc_get_event_indicators(comp); - for (k = 0; k < ni; k++) { - eventIndicators[k] = comp->event_indicators[k]; - } - return fmiOK; - } + for (k = 0; k < ni; k++) { + eventIndicators[k] = comp->event_indicators[k]; + } + return fmiOK; + } } fmiStatus fmi_event_update(fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - calc_event_update(comp); + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + calc_event_update(comp); - *eventInfo = comp->eventInfo; - return fmiOK; - } + *eventInfo = comp->eventInfo; + return fmiOK; + } } fmiStatus fmi_get_continuous_states(fmiComponent c, fmiReal states[], size_t nx) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; - for (k = 0; k < nx; k++) { - states[k] = comp->states[k]; - } - return fmiOK; - } + for (k = 0; k < nx; k++) { + states[k] = comp->states[k]; + } + return fmiOK; + } } fmiStatus fmi_get_nominal_continuousstates(fmiComponent c, fmiReal x_nominal[], size_t nx) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nx; k++) { - x_nominal[k] = comp->states_nom[k]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nx; k++) { + x_nominal[k] = comp->states_nom[k]; + } + return fmiOK; + } } fmiStatus fmi_get_state_value_references(fmiComponent c, fmiValueReference vrx[], size_t nx) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - size_t k; - for (k = 0; k < nx; k++) { - vrx[k] = comp->states_vr[k]; - } - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + size_t k; + for (k = 0; k < nx; k++) { + vrx[k] = comp->states_vr[k]; + } + return fmiOK; + } } fmiStatus fmi_terminate(fmiComponent c) { - component_ptr_t comp = (fmiComponent)c; - if (comp == NULL) { - return fmiFatal; - } else { - return fmiOK; - } + component_ptr_t comp = (fmiComponent)c; + if (comp == NULL) { + return fmiFatal; + } else { + return fmiOK; + } } /* FMI 1.0 CS Functions */ const char* fmi_get_types_platform() { - return FMI_PLATFORM_TYPE; + return FMI_PLATFORM_TYPE; } fmiComponent fmi_instantiate_slave(fmiString instanceName, fmiString fmuGUID, fmiString fmuLocation, fmiString mimeType, fmiReal timeout, fmiBoolean visible, fmiBoolean interactive, fmiCallbackFunctions functions, fmiBoolean loggingOn) { - component_ptr_t comp; + component_ptr_t comp; - comp = fmi_instantiate_model(instanceName, fmuGUID, functions, loggingOn); - if (comp == NULL) { - return NULL; - } else if (strcmp(fmuGUID, FMI_GUID) != 0) { - return NULL; - } else { - sprintf(comp->fmuLocation, "%s",fmuLocation); - sprintf(comp->mimeType, "%s",mimeType); - comp->timeout = timeout; - comp->visible = visible; - comp->interactive = interactive; - return comp; - } + comp = fmi_instantiate_model(instanceName, fmuGUID, functions, loggingOn); + if (comp == NULL) { + return NULL; + } else if (strcmp(fmuGUID, FMI_GUID) != 0) { + return NULL; + } else { + sprintf(comp->fmuLocation, "%s",fmuLocation); + sprintf(comp->mimeType, "%s",mimeType); + comp->timeout = timeout; + comp->visible = visible; + comp->interactive = interactive; + return comp; + } } fmiStatus fmi_initialize_slave(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop) { - component_ptr_t comp = (fmiComponent)c; - fmiReal relativeTolerance; - fmiEventInfo eventInfo; - fmiBoolean toleranceControlled; + component_ptr_t comp = (fmiComponent)c; + fmiReal relativeTolerance; + fmiEventInfo eventInfo; + fmiBoolean toleranceControlled; - comp->tStart = tStart; - comp->StopTimeDefined = StopTimeDefined; - comp->tStop = tStop; + comp->tStart = tStart; + comp->StopTimeDefined = StopTimeDefined; + comp->tStop = tStop; - toleranceControlled = fmiTrue; - relativeTolerance = 1e-4; + toleranceControlled = fmiTrue; + relativeTolerance = 1e-4; - return fmi_initialize((fmiComponent)comp, toleranceControlled, relativeTolerance, &eventInfo); + return fmi_initialize((fmiComponent)comp, toleranceControlled, relativeTolerance, &eventInfo); } fmiStatus fmi_terminate_slave(fmiComponent c) { - return fmi_terminate(c); + return fmi_terminate(c); } fmiStatus fmi_reset_slave(fmiComponent c) { - return fmiOK; + return fmiOK; } void fmi_free_slave_instance(fmiComponent c) { - fmi_free_model_instance(c); + fmi_free_model_instance(c); } fmiStatus fmi_set_real_input_derivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger order[], const fmiReal value[]) { - component_ptr_t comp = (fmiComponent)c; - size_t k; + component_ptr_t comp = (fmiComponent)c; + size_t k; - for (k = 0; k < nvr; k++) { - comp->input_real[vr[k]][order[k]] = value[k]; - if (value[k] != MAGIC_TEST_VALUE) {/* Tests that the value is set to MAGIC_TEST_VALUE */ - return fmiFatal; - } - } + for (k = 0; k < nvr; k++) { + comp->input_real[vr[k]][order[k]] = value[k]; + if (value[k] != MAGIC_TEST_VALUE) {/* Tests that the value is set to MAGIC_TEST_VALUE */ + return fmiFatal; + } + } - return fmiOK; + return fmiOK; } fmiStatus fmi_get_real_output_derivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger order[], fmiReal value[]) { - component_ptr_t comp = (fmiComponent)c; - size_t k; + component_ptr_t comp = (fmiComponent)c; + size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->output_real[vr[k]][order[k]]; - } + for (k = 0; k < nvr; k++) { + value[k] = comp->output_real[vr[k]][order[k]]; + } - return fmiOK; + return fmiOK; } fmiStatus fmi_cancel_step(fmiComponent c) { - return fmiOK; + return fmiOK; } fmiStatus fmi_do_step(fmiComponent c, fmiReal currentCommunicationPoint, fmiReal communicationStepSize, fmiBoolean newStep) { - component_ptr_t comp = (fmiComponent)c; - - if (comp == NULL) { - return fmiFatal; - } else { - fmiReal tstart = currentCommunicationPoint; - fmiReal tcur; - fmiReal tend = currentCommunicationPoint + communicationStepSize; - fmiReal hcur; - fmiReal hdef = 0.01; /* Default time step length */ - fmiReal z_cur[N_EVENT_INDICATORS]; - fmiReal z_pre[N_EVENT_INDICATORS]; - fmiReal states[N_STATES]; - fmiReal states_der[N_STATES]; - fmiEventInfo eventInfo; - fmiBoolean callEventUpdate; - fmiBoolean intermediateResults = fmiFalse; - fmiStatus fmistatus; - size_t k; - size_t counter = 0; - - fmi_get_continuous_states(comp, states, N_STATES); - fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); - - tcur = tstart; - hcur = hdef; - callEventUpdate = fmiFalse; - eventInfo = comp->eventInfo; - - while (tcur < tend && counter < 100) { - size_t k; - int zero_crossning_event = 0; - counter++; - - fmi_set_time(comp, tcur); - fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); - - /* Check if an event inidcator has triggered */ - for (k = 0; k < N_EVENT_INDICATORS; k++) { - if (z_cur[k]*z_pre[k] < 0) { - zero_crossning_event = 1; - break; - } - } - - /* Handle any events */ - if (callEventUpdate || zero_crossning_event || (eventInfo.upcomingTimeEvent && tcur == eventInfo.nextEventTime)) { - fmistatus = fmi_event_update(comp, intermediateResults, &eventInfo); - fmistatus = fmi_get_continuous_states(comp, states, N_STATES); - fmistatus = fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); - fmistatus = fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); - } - - /* Updated next time step */ - if (eventInfo.upcomingTimeEvent) { - if (tcur + hdef < eventInfo.nextEventTime) { - hcur = hdef; - } else { - hcur = eventInfo.nextEventTime - tcur; - } - } else { - hcur = hdef; - } - - { - double t_full = tcur + hcur; - if(t_full > tend) { - hcur = (tend - tcur); - tcur = tend; - } - else - tcur = t_full; - } - - /* Integrate a step */ - fmistatus = fmi_get_derivatives(comp, states_der, N_STATES); - for (k = 0; k < N_STATES; k++) { - states[k] = states[k] + hcur*states_der[k]; - /* if (k == 0) printf("states[%u] = %f states_der[k] = %f hcur =%f\n", k, states[k], states_der[k], hcur); */ - } - - /* Set states */ - fmistatus = fmi_set_continuous_states(comp, states, N_STATES); - /* Step is complete */ - fmistatus = fmi_completed_integrator_step(comp, &callEventUpdate); + component_ptr_t comp = (fmiComponent)c; + + if (comp == NULL) { + return fmiFatal; + } else { + fmiReal tstart = currentCommunicationPoint; + fmiReal tcur; + fmiReal tend = currentCommunicationPoint + communicationStepSize; + fmiReal hcur; + fmiReal hdef = 0.01; /* Default time step length */ + fmiReal z_cur[N_EVENT_INDICATORS]; + fmiReal z_pre[N_EVENT_INDICATORS]; + fmiReal states[N_STATES]; + fmiReal states_der[N_STATES]; + fmiEventInfo eventInfo; + fmiBoolean callEventUpdate; + fmiBoolean intermediateResults = fmiFalse; + fmiStatus fmistatus; + size_t k; + size_t counter = 0; + + fmi_get_continuous_states(comp, states, N_STATES); + fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); + + tcur = tstart; + hcur = hdef; + callEventUpdate = fmiFalse; + eventInfo = comp->eventInfo; + + while (tcur < tend && counter < 100) { + size_t k; + int zero_crossning_event = 0; + counter++; + + fmi_set_time(comp, tcur); + fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); + + /* Check if an event inidcator has triggered */ + for (k = 0; k < N_EVENT_INDICATORS; k++) { + if (z_cur[k]*z_pre[k] < 0) { + zero_crossning_event = 1; + break; + } + } + + /* Handle any events */ + if (callEventUpdate || zero_crossning_event || (eventInfo.upcomingTimeEvent && tcur == eventInfo.nextEventTime)) { + fmistatus = fmi_event_update(comp, intermediateResults, &eventInfo); + fmistatus = fmi_get_continuous_states(comp, states, N_STATES); + fmistatus = fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); + fmistatus = fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); + } + + /* Updated next time step */ + if (eventInfo.upcomingTimeEvent) { + if (tcur + hdef < eventInfo.nextEventTime) { + hcur = hdef; + } else { + hcur = eventInfo.nextEventTime - tcur; + } + } else { + hcur = hdef; + } + + { + double t_full = tcur + hcur; + if(t_full > tend) { + hcur = (tend - tcur); + tcur = tend; + } + else + tcur = t_full; + } + + /* Integrate a step */ + fmistatus = fmi_get_derivatives(comp, states_der, N_STATES); + for (k = 0; k < N_STATES; k++) { + states[k] = states[k] + hcur*states_der[k]; + /* if (k == 0) printf("states[%u] = %f states_der[k] = %f hcur =%f\n", k, states[k], states_der[k], hcur); */ + } + + /* Set states */ + fmistatus = fmi_set_continuous_states(comp, states, N_STATES); + /* Step is complete */ + fmistatus = fmi_completed_integrator_step(comp, &callEventUpdate); if(fmistatus != fmiOK) break; - } - for (k = 0; k < N_STATES; k++) { /* Update states */ - comp->reals[k] = comp->states[k]; - } - return fmiOK; - } + } + for (k = 0; k < N_STATES; k++) { /* Update states */ + comp->reals[k] = comp->states[k]; + } + return fmiOK; + } } fmiStatus fmi_get_status(fmiComponent c, const fmiStatusKind s, fmiStatus* value) { - switch (s) { - case fmiDoStepStatus: - /* Return fmiPending if we are waiting. Otherwise the result from fmiDoStep */ - *value = fmiOK; - return fmiOK; - default: /* Not defined for status for this function */ - return fmiDiscard; - } + switch (s) { + case fmiDoStepStatus: + /* Return fmiPending if we are waiting. Otherwise the result from fmiDoStep */ + *value = fmiOK; + return fmiOK; + default: /* Not defined for status for this function */ + return fmiDiscard; + } } fmiStatus fmi_get_real_status(fmiComponent c, const fmiStatusKind s, fmiReal* value) { - switch (s) { - case fmiLastSuccessfulTime: - /* Return fmiPending if we are waiting. Otherwise return end time for last call to fmiDoStep */ - *value = 0.01; - return fmiOK; - default: /* Not defined for status for this function */ - return fmiDiscard; - } + switch (s) { + case fmiLastSuccessfulTime: + /* Return fmiPending if we are waiting. Otherwise return end time for last call to fmiDoStep */ + *value = 0.01; + return fmiOK; + default: /* Not defined for status for this function */ + return fmiDiscard; + } } fmiStatus fmi_get_integer_status(fmiComponent c, const fmiStatusKind s, fmiInteger* value) { - switch (s) { - default: /* Not defined for status for this function */ - return fmiDiscard; - } + switch (s) { + default: /* Not defined for status for this function */ + return fmiDiscard; + } } fmiStatus fmi_get_boolean_status(fmiComponent c, const fmiStatusKind s, fmiBoolean* value) { - switch (s) { - default: /* Not defined for status for this function */ - return fmiDiscard; - } + switch (s) { + default: /* Not defined for status for this function */ + return fmiDiscard; + } } fmiStatus fmi_get_string_status(fmiComponent c, const fmiStatusKind s, fmiString* value) { - switch (s) { - case fmiPendingStatus: - *value = "Did fmiDoStep really return with fmiPending? Then its time to implement this function"; - return fmiDiscard; - default: /* Not defined for status for this function */ - return fmiDiscard; - } + switch (s) { + case fmiPendingStatus: + *value = "Did fmiDoStep really return with fmiPending? Then its time to implement this function"; + return fmiDiscard; + default: /* Not defined for status for this function */ + return fmiDiscard; + } } diff --git a/Test/FMI1/fmu_dummy/fmu1_model.h b/Test/FMI1/fmu_dummy/fmu1_model.h index 261e0466..0b730ae0 100644 --- a/Test/FMI1/fmu_dummy/fmu1_model.h +++ b/Test/FMI1/fmu_dummy/fmu1_model.h @@ -21,250 +21,250 @@ along with this program. If not, contact Modelon AB . #include typedef struct { - /*************** FMI ME 1.0 ****************/ - fmiReal states [N_STATES]; - fmiReal states_nom [N_STATES]; - fmiValueReference states_vr [N_STATES]; - fmiReal states_der [N_STATES]; - fmiReal event_indicators[N_EVENT_INDICATORS]; - fmiReal reals [N_REAL]; - fmiInteger integers [N_INTEGER]; - fmiBoolean booleans [N_BOOLEAN]; - fmiString strings [N_STRING]; - - /* fmiInstantiateModel */ - fmiBoolean loggingOn; - char instanceName [BUFFER]; - char GUID [BUFFER]; - fmiCallbackFunctions functions; - - /* fmiSetTime */ - fmiReal fmitime; - - /* fmiCompletedIntegratorStep */ - fmiBoolean callEventUpdate; - - /* fmiInitialize */ - fmiBoolean toleranceControlled; - fmiReal relativeTolerance; - fmiEventInfo eventInfo; - - /*************** FMI CS 1.0. Depends on the ME fields above and functions ****************/ - fmiReal states_prev [N_STATES]; - - /* fmiInstantiateSlave */ - char fmuLocation [BUFFER]; - char mimeType [BUFFER]; - fmiReal timeout; - fmiBoolean visible; - fmiBoolean interactive; - - /* fmiInitializeSlave */ - fmiReal tStart; - fmiBoolean StopTimeDefined; - fmiReal tStop; - - /* fmiSetRealInputDerivatives */ - fmiReal input_real [N_INPUT_REAL][N_INPUT_REAL_MAX_ORDER + 1]; - - /* fmiGetRealOutputDerivatives */ - fmiReal output_real [N_OUTPUT_REAL][N_OUTPUT_REAL_MAX_ORDER + 1]; + /*************** FMI ME 1.0 ****************/ + fmiReal states [N_STATES]; + fmiReal states_nom [N_STATES]; + fmiValueReference states_vr [N_STATES]; + fmiReal states_der [N_STATES]; + fmiReal event_indicators[N_EVENT_INDICATORS]; + fmiReal reals [N_REAL]; + fmiInteger integers [N_INTEGER]; + fmiBoolean booleans [N_BOOLEAN]; + fmiString strings [N_STRING]; + + /* fmiInstantiateModel */ + fmiBoolean loggingOn; + char instanceName [BUFFER]; + char GUID [BUFFER]; + fmiCallbackFunctions functions; + + /* fmiSetTime */ + fmiReal fmitime; + + /* fmiCompletedIntegratorStep */ + fmiBoolean callEventUpdate; + + /* fmiInitialize */ + fmiBoolean toleranceControlled; + fmiReal relativeTolerance; + fmiEventInfo eventInfo; + + /*************** FMI CS 1.0. Depends on the ME fields above and functions ****************/ + fmiReal states_prev [N_STATES]; + + /* fmiInstantiateSlave */ + char fmuLocation [BUFFER]; + char mimeType [BUFFER]; + fmiReal timeout; + fmiBoolean visible; + fmiBoolean interactive; + + /* fmiInitializeSlave */ + fmiReal tStart; + fmiBoolean StopTimeDefined; + fmiReal tStop; + + /* fmiSetRealInputDerivatives */ + fmiReal input_real [N_INPUT_REAL][N_INPUT_REAL_MAX_ORDER + 1]; + + /* fmiGetRealOutputDerivatives */ + fmiReal output_real [N_OUTPUT_REAL][N_OUTPUT_REAL_MAX_ORDER + 1]; } component_t; typedef component_t* component_ptr_t; /* FMI 1.0 Common Functions */ -const char* fmi_get_version(); - -fmiStatus fmi_set_debug_logging( - fmiComponent c, - fmiBoolean loggingOn); - -fmiStatus fmi_get_real( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, fmiReal value[]); - -fmiStatus fmi_get_integer( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - fmiInteger value[]); -fmiStatus fmi_get_boolean( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - fmiBoolean value[]); - -fmiStatus fmi_get_string( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - fmiString value[]); - -fmiStatus fmi_set_real( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - const fmiReal value[]); -fmiStatus fmi_set_integer( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - const fmiInteger value[]); - -fmiStatus fmi_set_boolean( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - const fmiBoolean value[]); - -fmiStatus fmi_set_string( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - const fmiString value[]); +const char* fmi_get_version(); + +fmiStatus fmi_set_debug_logging( + fmiComponent c, + fmiBoolean loggingOn); + +fmiStatus fmi_get_real( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, fmiReal value[]); + +fmiStatus fmi_get_integer( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + fmiInteger value[]); +fmiStatus fmi_get_boolean( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + fmiBoolean value[]); + +fmiStatus fmi_get_string( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + fmiString value[]); + +fmiStatus fmi_set_real( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + const fmiReal value[]); +fmiStatus fmi_set_integer( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + const fmiInteger value[]); + +fmiStatus fmi_set_boolean( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + const fmiBoolean value[]); + +fmiStatus fmi_set_string( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + const fmiString value[]); /* FMI 1.0 ME Functions */ -const char* fmi_get_model_types_platform(); - -fmiComponent fmi_instantiate_model( - fmiString instanceName, - fmiString GUID, - fmiCallbackFunctions functions, - fmiBoolean loggingOn); - -void fmi_free_model_instance( - fmiComponent c); - -fmiStatus fmi_set_time( - fmiComponent c, - fmiReal fmitime); - -fmiStatus fmi_set_continuous_states( - fmiComponent c, - const fmiReal x[], - size_t nx); - -fmiStatus fmi_completed_integrator_step( - fmiComponent c, - fmiBoolean* callEventUpdate); - -fmiStatus fmi_initialize( - fmiComponent c, - fmiBoolean toleranceControlled, - fmiReal relativeTolerance, - fmiEventInfo* eventInfo); - -fmiStatus fmi_get_derivatives( - fmiComponent c, - fmiReal derivatives[], - size_t nx); - -fmiStatus fmi_get_event_indicators( - fmiComponent c, - fmiReal eventIndicators[], - size_t ni); - -fmiStatus fmi_event_update( - fmiComponent c, - fmiBoolean intermediateResults, - fmiEventInfo* eventInfo); -fmiStatus fmi_get_continuous_states( - fmiComponent c, - fmiReal states[], - size_t nx); - -fmiStatus fmi_get_nominal_continuousstates( - fmiComponent c, - fmiReal x_nominal[], - size_t nx); - -fmiStatus fmi_get_state_value_references( - fmiComponent c, - fmiValueReference vrx[], - size_t nx); - -fmiStatus fmi_terminate(fmiComponent c); +const char* fmi_get_model_types_platform(); + +fmiComponent fmi_instantiate_model( + fmiString instanceName, + fmiString GUID, + fmiCallbackFunctions functions, + fmiBoolean loggingOn); + +void fmi_free_model_instance( + fmiComponent c); + +fmiStatus fmi_set_time( + fmiComponent c, + fmiReal fmitime); + +fmiStatus fmi_set_continuous_states( + fmiComponent c, + const fmiReal x[], + size_t nx); + +fmiStatus fmi_completed_integrator_step( + fmiComponent c, + fmiBoolean* callEventUpdate); + +fmiStatus fmi_initialize( + fmiComponent c, + fmiBoolean toleranceControlled, + fmiReal relativeTolerance, + fmiEventInfo* eventInfo); + +fmiStatus fmi_get_derivatives( + fmiComponent c, + fmiReal derivatives[], + size_t nx); + +fmiStatus fmi_get_event_indicators( + fmiComponent c, + fmiReal eventIndicators[], + size_t ni); + +fmiStatus fmi_event_update( + fmiComponent c, + fmiBoolean intermediateResults, + fmiEventInfo* eventInfo); +fmiStatus fmi_get_continuous_states( + fmiComponent c, + fmiReal states[], + size_t nx); + +fmiStatus fmi_get_nominal_continuousstates( + fmiComponent c, + fmiReal x_nominal[], + size_t nx); + +fmiStatus fmi_get_state_value_references( + fmiComponent c, + fmiValueReference vrx[], + size_t nx); + +fmiStatus fmi_terminate(fmiComponent c); /* FMI 1.0 CS Functions */ #ifdef fmiFunctions_h -const char* fmi_get_types_platform(); - -fmiComponent fmi_instantiate_slave( - fmiString instanceName, - fmiString fmuGUID, - fmiString fmuLocation, - fmiString mimeType, - fmiReal timeout, - fmiBoolean visible, - fmiBoolean interactive, - fmiCallbackFunctions functions, - fmiBoolean loggingOn); - -fmiStatus fmi_initialize_slave( - fmiComponent c, - fmiReal tStart, - fmiBoolean StopTimeDefined, - fmiReal tStop); - -fmiStatus fmi_terminate_slave( - fmiComponent c); - -fmiStatus fmi_reset_slave( - fmiComponent c); - -void fmi_free_slave_instance( - fmiComponent c); - -fmiStatus fmi_set_real_input_derivatives( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - const fmiInteger order[], - const fmiReal value[]); - -fmiStatus fmi_get_real_output_derivatives( - fmiComponent c, - const fmiValueReference vr[], - size_t nvr, - const fmiInteger order[], - fmiReal value[]); - -fmiStatus fmi_cancel_step( - fmiComponent c); -fmiStatus fmi_do_step( - fmiComponent c, - fmiReal currentCommunicationPoint, - fmiReal communicationStepSize, - fmiBoolean newStep); - -fmiStatus fmi_get_status( - fmiComponent c, - const fmiStatusKind s, - fmiStatus* value); - -fmiStatus fmi_get_real_status( - fmiComponent c, - const fmiStatusKind s, - fmiReal* value); - -fmiStatus fmi_get_integer_status( - fmiComponent c, - const fmiStatusKind s, - fmiInteger* value); - -fmiStatus fmi_get_boolean_status( - fmiComponent c, - const fmiStatusKind s, - fmiBoolean* value); - -fmiStatus fmi_get_string_status( - fmiComponent c, - const fmiStatusKind s, - fmiString* value); +const char* fmi_get_types_platform(); + +fmiComponent fmi_instantiate_slave( + fmiString instanceName, + fmiString fmuGUID, + fmiString fmuLocation, + fmiString mimeType, + fmiReal timeout, + fmiBoolean visible, + fmiBoolean interactive, + fmiCallbackFunctions functions, + fmiBoolean loggingOn); + +fmiStatus fmi_initialize_slave( + fmiComponent c, + fmiReal tStart, + fmiBoolean StopTimeDefined, + fmiReal tStop); + +fmiStatus fmi_terminate_slave( + fmiComponent c); + +fmiStatus fmi_reset_slave( + fmiComponent c); + +void fmi_free_slave_instance( + fmiComponent c); + +fmiStatus fmi_set_real_input_derivatives( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + const fmiInteger order[], + const fmiReal value[]); + +fmiStatus fmi_get_real_output_derivatives( + fmiComponent c, + const fmiValueReference vr[], + size_t nvr, + const fmiInteger order[], + fmiReal value[]); + +fmiStatus fmi_cancel_step( + fmiComponent c); +fmiStatus fmi_do_step( + fmiComponent c, + fmiReal currentCommunicationPoint, + fmiReal communicationStepSize, + fmiBoolean newStep); + +fmiStatus fmi_get_status( + fmiComponent c, + const fmiStatusKind s, + fmiStatus* value); + +fmiStatus fmi_get_real_status( + fmiComponent c, + const fmiStatusKind s, + fmiReal* value); + +fmiStatus fmi_get_integer_status( + fmiComponent c, + const fmiStatusKind s, + fmiInteger* value); + +fmiStatus fmi_get_boolean_status( + fmiComponent c, + const fmiStatusKind s, + fmiBoolean* value); + +fmiStatus fmi_get_string_status( + fmiComponent c, + const fmiStatusKind s, + fmiString* value); #endif /* End of fmiFunctions_h */ #endif /* End of header FM1_MODEL_H_ */ \ No newline at end of file diff --git a/Test/FMI1/fmu_dummy/fmu1_model_cs.c b/Test/FMI1/fmu_dummy/fmu1_model_cs.c index 96ef0613..beccfcb9 100644 --- a/Test/FMI1/fmu_dummy/fmu1_model_cs.c +++ b/Test/FMI1/fmu_dummy/fmu1_model_cs.c @@ -38,126 +38,126 @@ along with this program. If not, contact Modelon AB . /* FMI 1.0 Common Functions */ DllExport const char* fmiGetVersion() { - return fmi_get_version(); + return fmi_get_version(); } DllExport fmiStatus fmiSetDebugLogging(fmiComponent c, fmiBoolean loggingOn) { - return fmi_set_debug_logging(c, loggingOn); + return fmi_set_debug_logging(c, loggingOn); } DllExport fmiStatus fmiGetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]) { - return fmi_get_real(c, vr, nvr, value); + return fmi_get_real(c, vr, nvr, value); } DllExport fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]) { - return fmi_get_integer(c, vr, nvr, value); + return fmi_get_integer(c, vr, nvr, value); } DllExport fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]) { - return fmi_get_boolean(c, vr, nvr, value); + return fmi_get_boolean(c, vr, nvr, value); } DllExport fmiStatus fmiGetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]) { - return fmi_get_string(c, vr, nvr, value); + return fmi_get_string(c, vr, nvr, value); } DllExport fmiStatus fmiSetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]) { - return fmi_set_real(c, vr, nvr, value); + return fmi_set_real(c, vr, nvr, value); } DllExport fmiStatus fmiSetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]) { - return fmi_set_integer(c, vr, nvr, value); + return fmi_set_integer(c, vr, nvr, value); } DllExport fmiStatus fmiSetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]) { - return fmi_set_boolean(c, vr, nvr, value); + return fmi_set_boolean(c, vr, nvr, value); } DllExport fmiStatus fmiSetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]) { - return fmi_set_string(c, vr, nvr, value); + return fmi_set_string(c, vr, nvr, value); } /* FMI 1.0 CS Functions */ DllExport const char* fmiGetTypesPlatform() { - return fmi_get_types_platform(); + return fmi_get_types_platform(); } DllExport fmiComponent fmiInstantiateSlave(fmiString instanceName, fmiString fmuGUID, fmiString fmuLocation, fmiString mimeType, fmiReal timeout, fmiBoolean visible, fmiBoolean interactive, fmiCallbackFunctions functions, fmiBoolean loggingOn) { - return fmi_instantiate_slave(instanceName, fmuGUID, fmuLocation, mimeType, timeout, visible, interactive, functions, loggingOn); + return fmi_instantiate_slave(instanceName, fmuGUID, fmuLocation, mimeType, timeout, visible, interactive, functions, loggingOn); } DllExport fmiStatus fmiInitializeSlave(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop) { - return fmi_initialize_slave(c, tStart, StopTimeDefined, tStop); + return fmi_initialize_slave(c, tStart, StopTimeDefined, tStop); } DllExport fmiStatus fmiTerminateSlave(fmiComponent c) { - return fmi_terminate_slave(c); + return fmi_terminate_slave(c); } DllExport fmiStatus fmiResetSlave(fmiComponent c) { - return fmi_reset_slave(c); + return fmi_reset_slave(c); } DllExport void fmiFreeSlaveInstance(fmiComponent c) { - fmi_free_slave_instance(c); + fmi_free_slave_instance(c); } DllExport fmiStatus fmiSetRealInputDerivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger order[], const fmiReal value[]) { - return fmi_set_real_input_derivatives(c, vr, nvr, order, value); + return fmi_set_real_input_derivatives(c, vr, nvr, order, value); } DllExport fmiStatus fmiGetRealOutputDerivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger order[], fmiReal value[]) { - return fmi_get_real_output_derivatives(c, vr, nvr, order, value); + return fmi_get_real_output_derivatives(c, vr, nvr, order, value); } DllExport fmiStatus fmiCancelStep(fmiComponent c) { - return fmi_cancel_step(c); + return fmi_cancel_step(c); } DllExport fmiStatus fmiDoStep(fmiComponent c, fmiReal currentCommunicationPoint, fmiReal communicationStepSize, fmiBoolean newStep) { - return fmi_do_step(c, currentCommunicationPoint, communicationStepSize, newStep); + return fmi_do_step(c, currentCommunicationPoint, communicationStepSize, newStep); } DllExport fmiStatus fmiGetStatus(fmiComponent c, const fmiStatusKind s, fmiStatus* value) { - return fmi_get_status(c, s, value); + return fmi_get_status(c, s, value); } DllExport fmiStatus fmiGetRealStatus(fmiComponent c, const fmiStatusKind s, fmiReal* value) { - return fmi_get_real_status(c, s, value); + return fmi_get_real_status(c, s, value); } DllExport fmiStatus fmiGetIntegerStatus(fmiComponent c, const fmiStatusKind s, fmiInteger* value) { - return fmi_get_integer_status(c, s, value); + return fmi_get_integer_status(c, s, value); } DllExport fmiStatus fmiGetBooleanStatus(fmiComponent c, const fmiStatusKind s, fmiBoolean* value) { - return fmi_get_boolean_status(c, s, value); + return fmi_get_boolean_status(c, s, value); } DllExport fmiStatus fmiGetStringStatus(fmiComponent c, const fmiStatusKind s, fmiString* value) { - return fmi_get_string_status(c, s, value); + return fmi_get_string_status(c, s, value); } diff --git a/Test/FMI1/fmu_dummy/fmu1_model_defines.h b/Test/FMI1/fmu_dummy/fmu1_model_defines.h index dc3e49ad..af3ddcf7 100644 --- a/Test/FMI1/fmu_dummy/fmu1_model_defines.h +++ b/Test/FMI1/fmu_dummy/fmu1_model_defines.h @@ -18,53 +18,53 @@ along with this program. If not, contact Modelon AB . /* This header is used to generate the FMU test DLL and in the C API test that uses the DLL */ #ifndef FMU1_MODEL_DEFINES_H_ -#define STRINGIFY(a) #a -#define STRINGIFY2(a) STRINGIFY(a) -#define MODEL_IDENTIFIER_STR STRINGIFY2(MODEL_IDENTIFIER) +#define STRINGIFY(a) #a +#define STRINGIFY2(a) STRINGIFY(a) +#define MODEL_IDENTIFIER_STR STRINGIFY2(MODEL_IDENTIFIER) -#define BUFFER 1024 -#define MAGIC_TEST_VALUE 13.0 /* A test value for some functions */ +#define BUFFER 1024 +#define MAGIC_TEST_VALUE 13.0 /* A test value for some functions */ /* BouncingBall model with redundant values */ /* ValueReferences for the variables and parameters in the model */ /* States */ -#define VAR_R_HEIGHT 0 -#define VAR_R_HEIGHT_SPEED 1 +#define VAR_R_HEIGHT 0 +#define VAR_R_HEIGHT_SPEED 1 /* Real */ -#define VAR_R_GRATIVY 2 -#define VAR_R_BOUNCE_CONF 3 +#define VAR_R_GRATIVY 2 +#define VAR_R_BOUNCE_CONF 3 /* Event indicators */ -#define EVENT_HEIGHT 0 +#define EVENT_HEIGHT 0 /* Event indicators */ -#define VAR_S_LOGGER_TEST 0 +#define VAR_S_LOGGER_TEST 0 /* Sizes */ -#define N_STATES 2 -#define N_EVENT_INDICATORS 1 -#define N_REAL 4 -#define N_INTEGER 4 -#define N_BOOLEAN 4 -#define N_STRING 4 +#define N_STATES 2 +#define N_EVENT_INDICATORS 1 +#define N_REAL 4 +#define N_INTEGER 4 +#define N_BOOLEAN 4 +#define N_STRING 4 -#define N_INPUT_REAL 2 /* CS only */ -#define N_INPUT_REAL_MAX_ORDER 2 /* CS only */ -#define N_OUTPUT_REAL 2 /* CS only */ -#define N_OUTPUT_REAL_MAX_ORDER 2 /* CS only */ +#define N_INPUT_REAL 2 /* CS only */ +#define N_INPUT_REAL_MAX_ORDER 2 /* CS only */ +#define N_OUTPUT_REAL 2 /* CS only */ +#define N_OUTPUT_REAL_MAX_ORDER 2 /* CS only */ -#define FMI_VERSION "1.0" +#define FMI_VERSION "1.0" #if defined(FMI1_TYPES_H_) -#define FMI_PLATFORM_TYPE fmi1_get_platform() +#define FMI_PLATFORM_TYPE fmi1_get_platform() #elif defined(fmiModelTypesPlatform) -#define FMI_PLATFORM_TYPE fmiModelTypesPlatform +#define FMI_PLATFORM_TYPE fmiModelTypesPlatform #elif defined(fmiPlatform) -#define FMI_PLATFORM_TYPE fmiPlatform +#define FMI_PLATFORM_TYPE fmiPlatform #else #error "Either fmiPlatform or fmiModelTypesPlatform must be defined" #endif -#define FMI_GUID "123" +#define FMI_GUID "123" #endif /* End of header FMU1_MODEL_DEFINES_H_ */ \ No newline at end of file diff --git a/Test/FMI1/fmu_dummy/fmu1_model_me.c b/Test/FMI1/fmu_dummy/fmu1_model_me.c index 231b8ce4..4e9aef26 100644 --- a/Test/FMI1/fmu_dummy/fmu1_model_me.c +++ b/Test/FMI1/fmu_dummy/fmu1_model_me.c @@ -38,121 +38,121 @@ along with this program. If not, contact Modelon AB . /* FMI 1.0 Common Functions */ DllExport const char* fmiGetVersion() { - return fmi_get_version(); + return fmi_get_version(); } DllExport fmiStatus fmiSetDebugLogging(fmiComponent c, fmiBoolean loggingOn) { - return fmi_set_debug_logging(c, loggingOn); + return fmi_set_debug_logging(c, loggingOn); } DllExport fmiStatus fmiGetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]) { - return fmi_get_real(c, vr, nvr, value); + return fmi_get_real(c, vr, nvr, value); } DllExport fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]) { - return fmi_get_integer(c, vr, nvr, value); + return fmi_get_integer(c, vr, nvr, value); } DllExport fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]) { - return fmi_get_boolean(c, vr, nvr, value); + return fmi_get_boolean(c, vr, nvr, value); } DllExport fmiStatus fmiGetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]) { - return fmi_get_string(c, vr, nvr, value); + return fmi_get_string(c, vr, nvr, value); } DllExport fmiStatus fmiSetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]) { - return fmi_set_real(c, vr, nvr, value); + return fmi_set_real(c, vr, nvr, value); } DllExport fmiStatus fmiSetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]) { - return fmi_set_integer(c, vr, nvr, value); + return fmi_set_integer(c, vr, nvr, value); } DllExport fmiStatus fmiSetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]) { - return fmi_set_boolean(c, vr, nvr, value); + return fmi_set_boolean(c, vr, nvr, value); } DllExport fmiStatus fmiSetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]) { - return fmi_set_string(c, vr, nvr, value); + return fmi_set_string(c, vr, nvr, value); } /* FMI 1.0 ME Functions */ DllExport const char* fmiGetModelTypesPlatform() { - return fmi_get_model_types_platform(); + return fmi_get_model_types_platform(); } DllExport fmiComponent fmiInstantiateModel(fmiString instanceName, fmiString GUID, fmiCallbackFunctions functions, fmiBoolean loggingOn) { - return fmi_instantiate_model(instanceName, GUID, functions, loggingOn); + return fmi_instantiate_model(instanceName, GUID, functions, loggingOn); } DllExport void fmiFreeModelInstance(fmiComponent c) { - fmi_free_model_instance(c); + fmi_free_model_instance(c); } DllExport fmiStatus fmiSetTime(fmiComponent c, fmiReal fmitime) { - return fmi_set_time(c, fmitime); + return fmi_set_time(c, fmitime); } DllExport fmiStatus fmiSetContinuousStates(fmiComponent c, const fmiReal x[], size_t nx) { - return fmi_set_continuous_states(c, x, nx); + return fmi_set_continuous_states(c, x, nx); } DllExport fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate) { - return fmi_completed_integrator_step(c, callEventUpdate); + return fmi_completed_integrator_step(c, callEventUpdate); } DllExport fmiStatus fmiInitialize(fmiComponent c, fmiBoolean toleranceControlled, fmiReal relativeTolerance, fmiEventInfo* eventInfo) { - return fmi_initialize(c, toleranceControlled, relativeTolerance, eventInfo); + return fmi_initialize(c, toleranceControlled, relativeTolerance, eventInfo); } DllExport fmiStatus fmiGetDerivatives(fmiComponent c, fmiReal derivatives[] , size_t nx) { - return fmi_get_derivatives(c, derivatives, nx); + return fmi_get_derivatives(c, derivatives, nx); } DllExport fmiStatus fmiGetEventIndicators(fmiComponent c, fmiReal eventIndicators[], size_t ni) { - return fmi_get_event_indicators(c, eventIndicators, ni); + return fmi_get_event_indicators(c, eventIndicators, ni); } DllExport fmiStatus fmiEventUpdate(fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo) { - return fmi_event_update(c, intermediateResults, eventInfo); + return fmi_event_update(c, intermediateResults, eventInfo); } DllExport fmiStatus fmiGetContinuousStates(fmiComponent c, fmiReal states[], size_t nx) { - return fmi_get_continuous_states(c, states, nx); + return fmi_get_continuous_states(c, states, nx); } DllExport fmiStatus fmiGetNominalContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx) { - return fmi_get_nominal_continuousstates(c, x_nominal, nx); + return fmi_get_nominal_continuousstates(c, x_nominal, nx); } DllExport fmiStatus fmiGetStateValueReferences(fmiComponent c, fmiValueReference vrx[], size_t nx) { - return fmi_get_state_value_references(c, vrx, nx); + return fmi_get_state_value_references(c, vrx, nx); } DllExport fmiStatus fmiTerminate(fmiComponent c) { - return fmi_terminate(c); + return fmi_terminate(c); } diff --git a/Test/FMI1/jm_vector_test.c b/Test/FMI1/jm_vector_test.c index f0c1c54a..347a968e 100644 --- a/Test/FMI1/jm_vector_test.c +++ b/Test/FMI1/jm_vector_test.c @@ -21,11 +21,11 @@ int compar_int(int* a, int* b) { int return_code = CTEST_RETURN_SUCCESS; void log_error(const char* fmt, ...) { - va_list args; + va_list args; va_start (args, fmt); vprintf(fmt, args); va_end (args); - return_code = CTEST_RETURN_FAIL; + return_code = CTEST_RETURN_FAIL; } #define TESTVAL 49 @@ -44,19 +44,19 @@ int main() { jm_vector_set_item(int)(v, 2, TESTVAL); for( i = 0; i < 32; i++) { int x = i+TESTVAL; - int top; + int top; jm_vector_push_back(int)(v,x); jm_stack_push(double)(s,x); - top = (int)jm_stack_top(double)(s); + top = (int)jm_stack_top(double)(s); printf("pushed item %d=%d (stack top %g), vector size: %d, capacity: %d\n", i, x, jm_stack_top(double)(s), jm_vector_get_size(int)(v), jm_vector_reserve(int)(v,0)); - if(top != x) log_error("Stack top does not match the pushed value \n"); - if(jm_vector_get_size(int)(v) != VINIT_SIZE+i+1) log_error("Vector size %d is not as expected %d\n", jm_vector_get_size(int)(v), VINIT_SIZE+i+1); + if(top != x) log_error("Stack top does not match the pushed value \n"); + if(jm_vector_get_size(int)(v) != VINIT_SIZE+i+1) log_error("Vector size %d is not as expected %d\n", jm_vector_get_size(int)(v), VINIT_SIZE+i+1); + } + { + size_t index = jm_vector_find_index(int)(v, &k,jm_compare_int); + k = TESTVAL; + if( index != 2) log_error("Index of '%d' should be '2' but got %d\n", TESTVAL, k ); } - { - size_t index = jm_vector_find_index(int)(v, &k,jm_compare_int); - k = TESTVAL; - if( index != 2) log_error("Index of '%d' should be '2' but got %d\n", TESTVAL, k ); - } for( i = 0; i < 22; i++) { jm_stack_pop(double)(s); } diff --git a/Test/FMI2/fmi2_import_cs_test.c b/Test/FMI2/fmi2_import_cs_test.c index db951bec..7ce8e9bf 100644 --- a/Test/FMI2/fmi2_import_cs_test.c +++ b/Test/FMI2/fmi2_import_cs_test.c @@ -32,51 +32,51 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve void do_exit(int code) { - printf("Press 'Enter' to exit\n"); - /* getchar(); */ - exit(code); + printf("Press 'Enter' to exit\n"); + /* getchar(); */ + exit(code); } int test_simulate_cs(fmi2_import_t* fmu) { - fmi2_status_t fmistatus; - jm_status_enu_t jmstatus; - - fmi2_string_t instanceName = "Test CS model instance"; - fmi2_string_t fmuGUID; - fmi2_string_t fmuLocation = ""; - fmi2_boolean_t visible = fmi2_false; - fmi2_real_t relativeTol = 1e-4; -/* fmi2_boolean_t loggingOn = fmi2_true; */ - - /* fmi2_real_t simulation_results[] = {-0.001878, -1.722275}; */ - fmi2_real_t simulation_results[] = {0.0143633, -1.62417}; - fmi2_value_reference_t compare_real_variables_vr[] = {0, 1}; - size_t k; - - fmi2_real_t tstart = 0.0; - fmi2_real_t tcur = tstart; - fmi2_real_t hstep = 0.1; - fmi2_real_t tend = 2.0; - fmi2_boolean_t StopTimeDefined = fmi2_false; - - if (sizeof(compare_real_variables_vr)/sizeof(fmi2_value_reference_t) != sizeof(simulation_results)/sizeof(fmi2_real_t)) { - printf("Number of simulation values and reference values are different\n"); - do_exit(CTEST_RETURN_FAIL); - } - - printf("Version returned from FMU: %s\n", fmi2_import_get_version(fmu)); - printf("Platform type returned: %s\n", fmi2_import_get_types_platform(fmu)); - - fmuGUID = fmi2_import_get_GUID(fmu); + fmi2_status_t fmistatus; + jm_status_enu_t jmstatus; + + fmi2_string_t instanceName = "Test CS model instance"; + fmi2_string_t fmuGUID; + fmi2_string_t fmuLocation = ""; + fmi2_boolean_t visible = fmi2_false; + fmi2_real_t relativeTol = 1e-4; +/* fmi2_boolean_t loggingOn = fmi2_true; */ + + /* fmi2_real_t simulation_results[] = {-0.001878, -1.722275}; */ + fmi2_real_t simulation_results[] = {0.0143633, -1.62417}; + fmi2_value_reference_t compare_real_variables_vr[] = {0, 1}; + size_t k; + + fmi2_real_t tstart = 0.0; + fmi2_real_t tcur = tstart; + fmi2_real_t hstep = 0.1; + fmi2_real_t tend = 2.0; + fmi2_boolean_t StopTimeDefined = fmi2_false; + + if (sizeof(compare_real_variables_vr)/sizeof(fmi2_value_reference_t) != sizeof(simulation_results)/sizeof(fmi2_real_t)) { + printf("Number of simulation values and reference values are different\n"); + do_exit(CTEST_RETURN_FAIL); + } + + printf("Version returned from FMU: %s\n", fmi2_import_get_version(fmu)); + printf("Platform type returned: %s\n", fmi2_import_get_types_platform(fmu)); + + fmuGUID = fmi2_import_get_GUID(fmu); printf("GUID: %s\n", fmuGUID); jmstatus = fmi2_import_instantiate(fmu, instanceName, fmi2_cosimulation, fmuLocation, visible); - if (jmstatus == jm_status_error) { - printf("fmi2_import_instantiate failed\n"); - do_exit(CTEST_RETURN_FAIL); - } + if (jmstatus == jm_status_error) { + printf("fmi2_import_instantiate failed\n"); + do_exit(CTEST_RETURN_FAIL); + } fmistatus = fmi2_import_setup_experiment(fmu, fmi2_true, relativeTol, tstart, StopTimeDefined, tend); @@ -97,138 +97,138 @@ int test_simulate_cs(fmi2_import_t* fmu) do_exit(CTEST_RETURN_FAIL); } - tcur = tstart; - printf("%10s %10s\n", "Ball height", "Ball speed"); - while (tcur < tend) { - fmi2_boolean_t newStep = fmi2_true; + tcur = tstart; + printf("%10s %10s\n", "Ball height", "Ball speed"); + while (tcur < tend) { + fmi2_boolean_t newStep = fmi2_true; #if 0 /* Prints a real value.. */ - fmi2_real_t rvalue; - fmi2_value_reference_t vr = 0; + fmi2_real_t rvalue; + fmi2_value_reference_t vr = 0; - fmistatus = fmi2_import_get_real(fmu, &vr, 1, &rvalue); - printf("rvalue = %f\n", rvalue); + fmistatus = fmi2_import_get_real(fmu, &vr, 1, &rvalue); + printf("rvalue = %f\n", rvalue); #endif - fmistatus = fmi2_import_do_step(fmu, tcur, hstep, newStep); - - for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi2_value_reference_t); k++) { - fmi2_value_reference_t vr = compare_real_variables_vr[k]; - fmi2_real_t rvalue; - fmistatus = fmi2_import_get_real(fmu, &vr, 1, &rvalue); - } - { - fmi2_real_t val[2]; - fmi2_import_get_real(fmu, compare_real_variables_vr, 2, val); - printf("%10g %10g\n", val[0],val[1]); - } - - tcur += hstep; - } - - printf("Simulation finished. Checking results\n"); - - /* Validate result */ - for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi2_value_reference_t); k++) { - fmi2_value_reference_t vr = compare_real_variables_vr[k]; - fmi2_real_t rvalue; - fmi2_real_t res; - fmistatus = fmi2_import_get_real(fmu, &vr, 1, &rvalue); - res = rvalue - simulation_results[k]; - res = res > 0 ? res: -res; /* Take abs */ - if (res > 3e-3) { - printf("Simulation results is wrong!\n"); - printf("State [%u] %g != %g, |res| = %g\n", (unsigned)k, rvalue, simulation_results[k], res); - printf("\n"); - do_exit(CTEST_RETURN_FAIL); - } - } - - fmistatus = fmi2_import_terminate(fmu); - - fmi2_import_free_instance(fmu); - - return 0; + fmistatus = fmi2_import_do_step(fmu, tcur, hstep, newStep); + + for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi2_value_reference_t); k++) { + fmi2_value_reference_t vr = compare_real_variables_vr[k]; + fmi2_real_t rvalue; + fmistatus = fmi2_import_get_real(fmu, &vr, 1, &rvalue); + } + { + fmi2_real_t val[2]; + fmi2_import_get_real(fmu, compare_real_variables_vr, 2, val); + printf("%10g %10g\n", val[0],val[1]); + } + + tcur += hstep; + } + + printf("Simulation finished. Checking results\n"); + + /* Validate result */ + for (k = 0; k < sizeof(compare_real_variables_vr)/sizeof(fmi2_value_reference_t); k++) { + fmi2_value_reference_t vr = compare_real_variables_vr[k]; + fmi2_real_t rvalue; + fmi2_real_t res; + fmistatus = fmi2_import_get_real(fmu, &vr, 1, &rvalue); + res = rvalue - simulation_results[k]; + res = res > 0 ? res: -res; /* Take abs */ + if (res > 3e-3) { + printf("Simulation results is wrong!\n"); + printf("State [%u] %g != %g, |res| = %g\n", (unsigned)k, rvalue, simulation_results[k], res); + printf("\n"); + do_exit(CTEST_RETURN_FAIL); + } + } + + fmistatus = fmi2_import_terminate(fmu); + + fmi2_import_free_instance(fmu); + + return 0; } int main(int argc, char *argv[]) { - fmi2_callback_functions_t callBackFunctions; - const char* FMUPath; - const char* tmpPath; - jm_callbacks callbacks; - fmi_import_context_t* context; - fmi_version_enu_t version; - jm_status_enu_t status; - int k; - - fmi2_import_t* fmu; - - if(argc < 3) { - printf("Usage: %s \n", argv[0]); - do_exit(CTEST_RETURN_FAIL); - } - for (k = 0; k < argc; k ++) - printf("argv[%d] = %s\n", k, argv[k]); + fmi2_callback_functions_t callBackFunctions; + const char* FMUPath; + const char* tmpPath; + jm_callbacks callbacks; + fmi_import_context_t* context; + fmi_version_enu_t version; + jm_status_enu_t status; + int k; + + fmi2_import_t* fmu; + + if(argc < 3) { + printf("Usage: %s \n", argv[0]); + do_exit(CTEST_RETURN_FAIL); + } + for (k = 0; k < argc; k ++) + printf("argv[%d] = %s\n", k, argv[k]); - FMUPath = argv[1]; - tmpPath = argv[2]; + FMUPath = argv[1]; + tmpPath = argv[2]; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; #ifdef FMILIB_GENERATE_BUILD_STAMP - printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); + printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); #endif - context = fmi_import_allocate_context(&callbacks); + context = fmi_import_allocate_context(&callbacks); - version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); + version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); - if(version != fmi_version_2_0_enu) { - printf("The code only supports version 2.0\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(version != fmi_version_2_0_enu) { + printf("The code only supports version 2.0\n"); + do_exit(CTEST_RETURN_FAIL); + } - fmu = fmi2_import_parse_xml(context, tmpPath, 0); + fmu = fmi2_import_parse_xml(context, tmpPath, 0); - if(!fmu) { - printf("Error parsing XML, exiting\n"); - do_exit(CTEST_RETURN_FAIL); - } - - if(fmi2_import_get_fmu_kind(fmu) == fmi2_fmu_kind_me) { - printf("Only CS 2.0 is supported by this code\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(!fmu) { + printf("Error parsing XML, exiting\n"); + do_exit(CTEST_RETURN_FAIL); + } + + if(fmi2_import_get_fmu_kind(fmu) == fmi2_fmu_kind_me) { + printf("Only CS 2.0 is supported by this code\n"); + do_exit(CTEST_RETURN_FAIL); + } - callBackFunctions.logger = fmi2_log_forwarding; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; - callBackFunctions.componentEnvironment = fmu; + callBackFunctions.logger = fmi2_log_forwarding; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; + callBackFunctions.componentEnvironment = fmu; - status = fmi2_import_create_dllfmu(fmu, fmi2_fmu_kind_cs, &callBackFunctions); - if (status == jm_status_error) { - printf("Could not create the DLL loading mechanism(C-API) (error: %s).\n", fmi2_import_get_last_error(fmu)); - do_exit(CTEST_RETURN_FAIL); - } + status = fmi2_import_create_dllfmu(fmu, fmi2_fmu_kind_cs, &callBackFunctions); + if (status == jm_status_error) { + printf("Could not create the DLL loading mechanism(C-API) (error: %s).\n", fmi2_import_get_last_error(fmu)); + do_exit(CTEST_RETURN_FAIL); + } - test_simulate_cs(fmu); + test_simulate_cs(fmu); - fmi2_import_destroy_dllfmu(fmu); + fmi2_import_destroy_dllfmu(fmu); - fmi2_import_free(fmu); - fmi_import_free_context(context); - - printf("Everything seems to be OK since you got this far=)!\n"); + fmi2_import_free(fmu); + fmi_import_free_context(context); + + printf("Everything seems to be OK since you got this far=)!\n"); - do_exit(CTEST_RETURN_SUCCESS); + do_exit(CTEST_RETURN_SUCCESS); - return 0; + return 0; } diff --git a/Test/FMI2/fmi2_import_me_test.c b/Test/FMI2/fmi2_import_me_test.c index ff55b493..37cad321 100644 --- a/Test/FMI2/fmi2_import_me_test.c +++ b/Test/FMI2/fmi2_import_me_test.c @@ -24,9 +24,9 @@ void do_exit(int code) { - printf("Press 'Enter' to exit\n"); - /* getchar(); */ - exit(code); + printf("Press 'Enter' to exit\n"); + /* getchar(); */ + exit(code); } void do_event_iteration(fmi2_import_t *fmu, fmi2_event_info_t *eventInfo) @@ -58,55 +58,55 @@ int test_parsed_all_varialbes(fmi2_import_t* fmu) return 0; } - + int test_simulate_me(fmi2_import_t* fmu) -{ - fmi2_status_t fmistatus; - jm_status_enu_t jmstatus; - fmi2_real_t tstart = 0.0; - fmi2_real_t tcur; - fmi2_real_t hcur; - fmi2_real_t hdef = 0.1; - fmi2_real_t tend = 2.0; - size_t n_states; - size_t n_event_indicators; - fmi2_real_t* states; - fmi2_real_t states_end_results[] = {0.362000, -3.962000}; - fmi2_real_t* states_der; - fmi2_real_t* event_indicators; - fmi2_real_t* event_indicators_prev; - fmi2_boolean_t callEventUpdate; - fmi2_boolean_t terminateSimulation = fmi2_false; - fmi2_boolean_t toleranceControlled = fmi2_true; - fmi2_real_t relativeTolerance = 0.001; - fmi2_event_info_t eventInfo; - size_t k; - - printf("Version returned from FMU: %s\n", fmi2_import_get_version(fmu)); - printf("Platform type returned: %s\n", fmi2_import_get_types_platform(fmu)); - - n_states = fmi2_import_get_number_of_continuous_states(fmu); - n_event_indicators = fmi2_import_get_number_of_event_indicators(fmu); - - if (sizeof(states_end_results)/sizeof(fmi2_real_t) != n_states) { - printf("Number of states and results have different length n_states = %u n_results = %u\n", (unsigned)n_states, (unsigned)sizeof(states_end_results)); - do_exit(CTEST_RETURN_FAIL); - } - - states = calloc(n_states, sizeof(double)); - states_der = calloc(n_states, sizeof(double)); - event_indicators = calloc(n_event_indicators, sizeof(double)); - event_indicators_prev = calloc(n_event_indicators, sizeof(double)); - - jmstatus = fmi2_import_instantiate(fmu, "Test ME model instance",fmi2_model_exchange,0,0); - if (jmstatus == jm_status_error) { - printf("fmi2_import_instantiate failed\n"); - do_exit(CTEST_RETURN_FAIL); - } - - fmistatus = fmi2_import_set_debug_logging(fmu, fmi2_false,0,0); - printf("fmi2_import_set_debug_logging: %s\n", fmi2_status_to_string(fmistatus)); - fmi2_import_set_debug_logging(fmu, fmi2_true, 0, 0); +{ + fmi2_status_t fmistatus; + jm_status_enu_t jmstatus; + fmi2_real_t tstart = 0.0; + fmi2_real_t tcur; + fmi2_real_t hcur; + fmi2_real_t hdef = 0.1; + fmi2_real_t tend = 2.0; + size_t n_states; + size_t n_event_indicators; + fmi2_real_t* states; + fmi2_real_t states_end_results[] = {0.362000, -3.962000}; + fmi2_real_t* states_der; + fmi2_real_t* event_indicators; + fmi2_real_t* event_indicators_prev; + fmi2_boolean_t callEventUpdate; + fmi2_boolean_t terminateSimulation = fmi2_false; + fmi2_boolean_t toleranceControlled = fmi2_true; + fmi2_real_t relativeTolerance = 0.001; + fmi2_event_info_t eventInfo; + size_t k; + + printf("Version returned from FMU: %s\n", fmi2_import_get_version(fmu)); + printf("Platform type returned: %s\n", fmi2_import_get_types_platform(fmu)); + + n_states = fmi2_import_get_number_of_continuous_states(fmu); + n_event_indicators = fmi2_import_get_number_of_event_indicators(fmu); + + if (sizeof(states_end_results)/sizeof(fmi2_real_t) != n_states) { + printf("Number of states and results have different length n_states = %u n_results = %u\n", (unsigned)n_states, (unsigned)sizeof(states_end_results)); + do_exit(CTEST_RETURN_FAIL); + } + + states = calloc(n_states, sizeof(double)); + states_der = calloc(n_states, sizeof(double)); + event_indicators = calloc(n_event_indicators, sizeof(double)); + event_indicators_prev = calloc(n_event_indicators, sizeof(double)); + + jmstatus = fmi2_import_instantiate(fmu, "Test ME model instance",fmi2_model_exchange,0,0); + if (jmstatus == jm_status_error) { + printf("fmi2_import_instantiate failed\n"); + do_exit(CTEST_RETURN_FAIL); + } + + fmistatus = fmi2_import_set_debug_logging(fmu, fmi2_false,0,0); + printf("fmi2_import_set_debug_logging: %s\n", fmi2_status_to_string(fmistatus)); + fmi2_import_set_debug_logging(fmu, fmi2_true, 0, 0); fmistatus = fmi2_import_setup_experiment(fmu, toleranceControlled, relativeTolerance, tstart, fmi2_false, 0.0); @@ -114,186 +114,186 @@ int test_simulate_me(fmi2_import_t* fmu) fmistatus = fmi2_import_enter_initialization_mode(fmu); fmistatus = fmi2_import_exit_initialization_mode(fmu); - tcur = tstart; - hcur = hdef; - callEventUpdate = fmi2_false; + tcur = tstart; + hcur = hdef; + callEventUpdate = fmi2_false; - eventInfo.newDiscreteStatesNeeded = fmi2_false; - eventInfo.terminateSimulation = fmi2_false; - eventInfo.nominalsOfContinuousStatesChanged = fmi2_false; - eventInfo.valuesOfContinuousStatesChanged = fmi2_true; - eventInfo.nextEventTimeDefined = fmi2_false; - eventInfo.nextEventTime = -0.0; + eventInfo.newDiscreteStatesNeeded = fmi2_false; + eventInfo.terminateSimulation = fmi2_false; + eventInfo.nominalsOfContinuousStatesChanged = fmi2_false; + eventInfo.valuesOfContinuousStatesChanged = fmi2_true; + eventInfo.nextEventTimeDefined = fmi2_false; + eventInfo.nextEventTime = -0.0; /* fmiExitInitializationMode leaves FMU in event mode */ do_event_iteration(fmu, &eventInfo); fmi2_import_enter_continuous_time_mode(fmu); - fmistatus = fmi2_import_get_continuous_states(fmu, states, n_states); - fmistatus = fmi2_import_get_event_indicators(fmu, event_indicators, n_event_indicators); + fmistatus = fmi2_import_get_continuous_states(fmu, states, n_states); + fmistatus = fmi2_import_get_event_indicators(fmu, event_indicators, n_event_indicators); - while ((tcur < tend) && (!(eventInfo.terminateSimulation || terminateSimulation))) { - size_t k; + while ((tcur < tend) && (!(eventInfo.terminateSimulation || terminateSimulation))) { + size_t k; fmi2_real_t tlast; - int zero_crossing_event = 0; + int zero_crossing_event = 0; - fmistatus = fmi2_import_set_time(fmu, tcur); + fmistatus = fmi2_import_set_time(fmu, tcur); { /* Swap event_indicators and event_indicators_prev so that we can get new indicators */ fmi2_real_t *temp = event_indicators; event_indicators = event_indicators_prev; event_indicators_prev = temp; } - fmistatus = fmi2_import_get_event_indicators(fmu, event_indicators, n_event_indicators); - - /* Check if an event indicator has triggered */ - for (k = 0; k < n_event_indicators; k++) { - if ((event_indicators[k] > 0) != (event_indicators_prev[k] > 0)) { - zero_crossing_event = 1; - break; - } - } - - /* Handle any events */ - if (callEventUpdate || zero_crossing_event || - (eventInfo.nextEventTimeDefined && tcur == eventInfo.nextEventTime)) { + fmistatus = fmi2_import_get_event_indicators(fmu, event_indicators, n_event_indicators); + + /* Check if an event indicator has triggered */ + for (k = 0; k < n_event_indicators; k++) { + if ((event_indicators[k] > 0) != (event_indicators_prev[k] > 0)) { + zero_crossing_event = 1; + break; + } + } + + /* Handle any events */ + if (callEventUpdate || zero_crossing_event || + (eventInfo.nextEventTimeDefined && tcur == eventInfo.nextEventTime)) { fmistatus = fmi2_import_enter_event_mode(fmu); do_event_iteration(fmu, &eventInfo); fmistatus = fmi2_import_enter_continuous_time_mode(fmu); - fmistatus = fmi2_import_get_continuous_states(fmu, states, n_states); - fmistatus = fmi2_import_get_event_indicators(fmu, event_indicators, n_event_indicators); - } + fmistatus = fmi2_import_get_continuous_states(fmu, states, n_states); + fmistatus = fmi2_import_get_event_indicators(fmu, event_indicators, n_event_indicators); + } - /* Calculate next time step */ + /* Calculate next time step */ tlast = tcur; tcur += hdef; - if (eventInfo.nextEventTimeDefined && (tcur >= eventInfo.nextEventTime)) { + if (eventInfo.nextEventTimeDefined && (tcur >= eventInfo.nextEventTime)) { tcur = eventInfo.nextEventTime; - } + } hcur = tcur - tlast; - if(tcur > tend - hcur/1e16) { - tcur = tend; - hcur = tcur - tlast; - } - - /* Integrate a step */ - fmistatus = fmi2_import_get_derivatives(fmu, states_der, n_states); - for (k = 0; k < n_states; k++) { - states[k] = states[k] + hcur*states_der[k]; - if (k == 0) printf("Ball height state[%u] = %f\n", (unsigned)k, states[k]); - } - - /* Set states */ - fmistatus = fmi2_import_set_continuous_states(fmu, states, n_states); - /* Step is complete */ - fmistatus = fmi2_import_completed_integrator_step(fmu, fmi2_true, &callEventUpdate, - &terminateSimulation); - } + if(tcur > tend - hcur/1e16) { + tcur = tend; + hcur = tcur - tlast; + } - /* Validate result */ - for (k = 0; k < n_states; k++) { - fmi2_real_t res = states[k] - states_end_results[k]; - res = res > 0 ? res: -res; /* Take abs */ - if (res > 1e-10) { - printf("Simulation results is wrong states[%u] %f != %f, |res| = %f\n", (unsigned)k, states[k], states_end_results[k], res); - do_exit(CTEST_RETURN_FAIL); - } - } - + /* Integrate a step */ + fmistatus = fmi2_import_get_derivatives(fmu, states_der, n_states); + for (k = 0; k < n_states; k++) { + states[k] = states[k] + hcur*states_der[k]; + if (k == 0) printf("Ball height state[%u] = %f\n", (unsigned)k, states[k]); + } - fmistatus = fmi2_import_terminate(fmu); + /* Set states */ + fmistatus = fmi2_import_set_continuous_states(fmu, states, n_states); + /* Step is complete */ + fmistatus = fmi2_import_completed_integrator_step(fmu, fmi2_true, &callEventUpdate, + &terminateSimulation); + } + + /* Validate result */ + for (k = 0; k < n_states; k++) { + fmi2_real_t res = states[k] - states_end_results[k]; + res = res > 0 ? res: -res; /* Take abs */ + if (res > 1e-10) { + printf("Simulation results is wrong states[%u] %f != %f, |res| = %f\n", (unsigned)k, states[k], states_end_results[k], res); + do_exit(CTEST_RETURN_FAIL); + } + } + + + fmistatus = fmi2_import_terminate(fmu); - fmi2_import_free_instance(fmu); + fmi2_import_free_instance(fmu); - free(states); - free(states_der); - free(event_indicators); - free(event_indicators_prev); + free(states); + free(states_der); + free(event_indicators); + free(event_indicators_prev); - return 0; + return 0; } int main(int argc, char *argv[]) { - fmi2_callback_functions_t callBackFunctions; - const char* FMUPath; - const char* tmpPath; - jm_callbacks callbacks; - fmi_import_context_t* context; - fmi_version_enu_t version; - jm_status_enu_t status; - - fmi2_import_t* fmu; - - if(argc < 3) { - printf("Usage: %s \n", argv[0]); - do_exit(CTEST_RETURN_FAIL); - } + fmi2_callback_functions_t callBackFunctions; + const char* FMUPath; + const char* tmpPath; + jm_callbacks callbacks; + fmi_import_context_t* context; + fmi_version_enu_t version; + jm_status_enu_t status; + + fmi2_import_t* fmu; + + if(argc < 3) { + printf("Usage: %s \n", argv[0]); + do_exit(CTEST_RETURN_FAIL); + } - FMUPath = argv[1]; - tmpPath = argv[2]; + FMUPath = argv[1]; + tmpPath = argv[2]; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = jm_default_logger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; #ifdef FMILIB_GENERATE_BUILD_STAMP - printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); + printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); #endif - context = fmi_import_allocate_context(&callbacks); + context = fmi_import_allocate_context(&callbacks); - version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); + version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); - if(version != fmi_version_2_0_enu) { - printf("Only version 2.0 is supported by this code\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(version != fmi_version_2_0_enu) { + printf("Only version 2.0 is supported by this code\n"); + do_exit(CTEST_RETURN_FAIL); + } - fmu = fmi2_import_parse_xml(context, tmpPath,0); + fmu = fmi2_import_parse_xml(context, tmpPath,0); - if(!fmu) { - printf("Error parsing XML, exiting\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(!fmu) { + printf("Error parsing XML, exiting\n"); + do_exit(CTEST_RETURN_FAIL); + } - if(fmi2_import_get_fmu_kind(fmu) == fmi2_fmu_kind_cs) { - printf("Only ME 2.0 is supported by this code\n"); - do_exit(CTEST_RETURN_FAIL); - } + if(fmi2_import_get_fmu_kind(fmu) == fmi2_fmu_kind_cs) { + printf("Only ME 2.0 is supported by this code\n"); + do_exit(CTEST_RETURN_FAIL); + } - callBackFunctions.logger = fmi2_log_forwarding; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; - callBackFunctions.componentEnvironment = fmu; + callBackFunctions.logger = fmi2_log_forwarding; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; + callBackFunctions.componentEnvironment = fmu; - status = fmi2_import_create_dllfmu(fmu, fmi2_fmu_kind_me, &callBackFunctions); - if (status == jm_status_error) { - printf("Could not create the DLL loading mechanism(C-API test).\n"); - do_exit(CTEST_RETURN_FAIL); - } + status = fmi2_import_create_dllfmu(fmu, fmi2_fmu_kind_me, &callBackFunctions); + if (status == jm_status_error) { + printf("Could not create the DLL loading mechanism(C-API test).\n"); + do_exit(CTEST_RETURN_FAIL); + } test_parsed_all_varialbes(fmu); - test_simulate_me(fmu); + test_simulate_me(fmu); - fmi2_import_destroy_dllfmu(fmu); + fmi2_import_destroy_dllfmu(fmu); - fmi2_import_free(fmu); - fmi_import_free_context(context); - - printf("Everything seems to be OK since you got this far=)!\n"); + fmi2_import_free(fmu); + fmi_import_free_context(context); + + printf("Everything seems to be OK since you got this far=)!\n"); - do_exit(CTEST_RETURN_SUCCESS); + do_exit(CTEST_RETURN_SUCCESS); - return 0; + return 0; } diff --git a/Test/FMI2/fmi2_import_test.c b/Test/FMI2/fmi2_import_test.c index 9d706ca2..90946255 100644 --- a/Test/FMI2/fmi2_import_test.c +++ b/Test/FMI2/fmi2_import_test.c @@ -27,73 +27,73 @@ static void fmi2logger(fmi2_component_environment_t env, fmi2_string_t instanceName, fmi2_status_t status, fmi2_string_t category, fmi2_string_t message, ...) { int len; - char msg[BUFFER]; - va_list argp; - va_start(argp, message); - len = jm_vsnprintf(msg, BUFFER, message, argp); - printf("fmiStatus = %s; %s (%s): %s\n", fmi2_status_to_string(status), instanceName, category, msg); + char msg[BUFFER]; + va_list argp; + va_start(argp, message); + len = jm_vsnprintf(msg, BUFFER, message, argp); + printf("fmiStatus = %s; %s (%s): %s\n", fmi2_status_to_string(status), instanceName, category, msg); } static void stepFinished(fmi2_component_environment_t env, fmi2_status_t status) { - printf("stepFinished is called wiht fmiStatus = %s\n", fmi2_status_to_string(status)); + printf("stepFinished is called wiht fmiStatus = %s\n", fmi2_status_to_string(status)); } - + int fmi2_test(fmi_import_context_t* context, const char* dirPath) { - fmi2_callback_functions_t callBackFunctions; - const char* modelIdentifier; - const char* modelName; - const char* GUID; - jm_status_enu_t status; - - fmi2_import_t* fmu; - fmi2_fmu_kind_enu_t fmukind; - - callBackFunctions.logger = fmi2logger; - callBackFunctions.allocateMemory = calloc; - callBackFunctions.freeMemory = free; - callBackFunctions.stepFinished = stepFinished; - callBackFunctions.componentEnvironment = 0; - - fmu = fmi2_import_parse_xml(context, dirPath, 0); - - if(!fmu) { - printf("Error parsing XML, exiting\n"); - return (CTEST_RETURN_FAIL); - } - modelName = fmi2_import_get_model_name(fmu); - GUID = fmi2_import_get_GUID(fmu); - - printf("Model name: %s\n", modelName); - if(fmi2_import_get_fmu_kind(fmu) != fmi2_fmu_kind_cs) { - modelIdentifier = fmi2_import_get_model_identifier_ME(fmu); - printf("Model identifier for ME: %s\n", modelIdentifier); - fmukind = fmi2_fmu_kind_me; - } - else if(fmi2_import_get_fmu_kind(fmu) != fmi2_fmu_kind_me) { - modelIdentifier = fmi2_import_get_model_identifier_CS(fmu); - printf("Model identifier for CS: %s\n", modelIdentifier); - fmukind = fmi2_fmu_kind_cs; - } - else { - printf("Unxepected FMU kind, exiting\n"); - return (CTEST_RETURN_FAIL); - } + fmi2_callback_functions_t callBackFunctions; + const char* modelIdentifier; + const char* modelName; + const char* GUID; + jm_status_enu_t status; + + fmi2_import_t* fmu; + fmi2_fmu_kind_enu_t fmukind; + + callBackFunctions.logger = fmi2logger; + callBackFunctions.allocateMemory = calloc; + callBackFunctions.freeMemory = free; + callBackFunctions.stepFinished = stepFinished; + callBackFunctions.componentEnvironment = 0; + + fmu = fmi2_import_parse_xml(context, dirPath, 0); + + if(!fmu) { + printf("Error parsing XML, exiting\n"); + return (CTEST_RETURN_FAIL); + } + modelName = fmi2_import_get_model_name(fmu); + GUID = fmi2_import_get_GUID(fmu); + + printf("Model name: %s\n", modelName); + if(fmi2_import_get_fmu_kind(fmu) != fmi2_fmu_kind_cs) { + modelIdentifier = fmi2_import_get_model_identifier_ME(fmu); + printf("Model identifier for ME: %s\n", modelIdentifier); + fmukind = fmi2_fmu_kind_me; + } + else if(fmi2_import_get_fmu_kind(fmu) != fmi2_fmu_kind_me) { + modelIdentifier = fmi2_import_get_model_identifier_CS(fmu); + printf("Model identifier for CS: %s\n", modelIdentifier); + fmukind = fmi2_fmu_kind_cs; + } + else { + printf("Unxepected FMU kind, exiting\n"); + return (CTEST_RETURN_FAIL); + } printf("Model GUID: %s\n", GUID); - status = fmi2_import_create_dllfmu(fmu, fmukind, &callBackFunctions); - if (status == jm_status_error) { - printf("Could not create the DLL loading mechanism(C-API).\n"); - return(CTEST_RETURN_FAIL); - } + status = fmi2_import_create_dllfmu(fmu, fmukind, &callBackFunctions); + if (status == jm_status_error) { + printf("Could not create the DLL loading mechanism(C-API).\n"); + return(CTEST_RETURN_FAIL); + } - printf("Version returned from FMU: %s\n", fmi2_import_get_version(fmu)); + printf("Version returned from FMU: %s\n", fmi2_import_get_version(fmu)); - fmi2_import_destroy_dllfmu(fmu); + fmi2_import_destroy_dllfmu(fmu); - fmi2_import_free(fmu); + fmi2_import_free(fmu); - return (CTEST_RETURN_SUCCESS); + return (CTEST_RETURN_SUCCESS); } diff --git a/Test/FMI2/fmu_dummy/fmu2_model.c b/Test/FMI2/fmu_dummy/fmu2_model.c index cf5d9770..74946e3e 100644 --- a/Test/FMI2/fmu_dummy/fmu2_model.c +++ b/Test/FMI2/fmu_dummy/fmu2_model.c @@ -22,36 +22,36 @@ along with this program. If not, contact Modelon AB . /* Model calculation functions */ static int calc_initialize(component_ptr_t comp) { - comp->states[VAR_R_HEIGHT] = 1.0; - comp->states[VAR_R_HEIGHT_SPEED] = 4; - comp->reals [VAR_R_GRATIVY] = -9.81; - comp->reals [VAR_R_BOUNCE_CONF] = 0.5; - if(comp->loggingOn) { - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "###### Initializing component ######"); - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g", VAR_R_HEIGHT, comp->states[VAR_R_HEIGHT]); - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g",VAR_R_HEIGHT_SPEED, comp->states[VAR_R_HEIGHT_SPEED]); - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g",VAR_R_GRATIVY, comp->reals [VAR_R_GRATIVY]); - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g",VAR_R_BOUNCE_CONF, comp->reals [VAR_R_BOUNCE_CONF]); -/* comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #r-1#"); - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #r1"); - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #t1#"); - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #r10#");*/ - } - return 0; + comp->states[VAR_R_HEIGHT] = 1.0; + comp->states[VAR_R_HEIGHT_SPEED] = 4; + comp->reals [VAR_R_GRATIVY] = -9.81; + comp->reals [VAR_R_BOUNCE_CONF] = 0.5; + if(comp->loggingOn) { + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "###### Initializing component ######"); + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g", VAR_R_HEIGHT, comp->states[VAR_R_HEIGHT]); + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g",VAR_R_HEIGHT_SPEED, comp->states[VAR_R_HEIGHT_SPEED]); + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g",VAR_R_GRATIVY, comp->reals [VAR_R_GRATIVY]); + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "INFO", "Init #r%d#=%g",VAR_R_BOUNCE_CONF, comp->reals [VAR_R_BOUNCE_CONF]); +/* comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #r-1#"); + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #r1"); + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #t1#"); + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2OK, "ERROR", "Bad reference: #r10#");*/ + } + return 0; } static int calc_get_derivatives(component_ptr_t comp) { - comp->states_der[VAR_R_HEIGHT] = comp->states[VAR_R_HEIGHT_SPEED]; - comp->states_der[VAR_R_HEIGHT_SPEED] = comp->reals[VAR_R_GRATIVY]; - return 0; + comp->states_der[VAR_R_HEIGHT] = comp->states[VAR_R_HEIGHT_SPEED]; + comp->states_der[VAR_R_HEIGHT_SPEED] = comp->reals[VAR_R_GRATIVY]; + return 0; } static int calc_get_event_indicators(component_ptr_t comp) { - fmi2Real event_tol = 1e-16; - comp->event_indicators[EVENT_HEIGHT] = comp->states[VAR_R_HEIGHT] + (comp->states[VAR_R_HEIGHT] >= 0 ? event_tol : -event_tol); - return 0; + fmi2Real event_tol = 1e-16; + comp->event_indicators[EVENT_HEIGHT] = comp->states[VAR_R_HEIGHT] + (comp->states[VAR_R_HEIGHT] >= 0 ? event_tol : -event_tol); + return 0; } static int calc_event_update(component_ptr_t comp) @@ -61,196 +61,196 @@ static int calc_event_update(component_ptr_t comp) comp->eventInfo.nominalsOfContinuousStatesChanged = fmi2False; comp->eventInfo.nextEventTimeDefined = fmi2False; comp->eventInfo.nextEventTime = -0.0; - if ((comp->states[VAR_R_HEIGHT] < 0) && (comp->states[VAR_R_HEIGHT_SPEED] < 0)) { - comp->states[VAR_R_HEIGHT_SPEED] = - comp->reals[VAR_R_BOUNCE_CONF] * comp->states[VAR_R_HEIGHT_SPEED]; - comp->states[VAR_R_HEIGHT] = 0; + if ((comp->states[VAR_R_HEIGHT] < 0) && (comp->states[VAR_R_HEIGHT_SPEED] < 0)) { + comp->states[VAR_R_HEIGHT_SPEED] = - comp->reals[VAR_R_BOUNCE_CONF] * comp->states[VAR_R_HEIGHT_SPEED]; + comp->states[VAR_R_HEIGHT] = 0; comp->eventInfo.valuesOfContinuousStatesChanged = fmi2True; - return 0; - } else { + return 0; + } else { comp->eventInfo.valuesOfContinuousStatesChanged = fmi2False; - return 1; /* Should not call the event update */ - } + return 1; /* Should not call the event update */ + } } /* FMI 2.0 Common Functions */ const char* fmi_get_version() { - return FMI_VERSION; + return FMI_VERSION; } fmi2Status fmi_set_debug_logging(fmi2Component c, fmi2Boolean loggingOn) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - comp->loggingOn = loggingOn; - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + comp->loggingOn = loggingOn; + return fmi2OK; + } } fmi2Status fmi_get_real(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - fmi2ValueReference cvr = vr[k]; - if (cvr < N_STATES) { - value[k] = comp->states[cvr]; - } - else if(cvr == 4) { - calc_get_derivatives(comp); - value[k] = comp->states_der[1]; - } - else { - value[k] = comp->reals[cvr]; - } - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + fmi2ValueReference cvr = vr[k]; + if (cvr < N_STATES) { + value[k] = comp->states[cvr]; + } + else if(cvr == 4) { + calc_get_derivatives(comp); + value[k] = comp->states_der[1]; + } + else { + value[k] = comp->reals[cvr]; + } + } + return fmi2OK; + } } fmi2Status fmi_get_integer(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->integers[vr[k]]; - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + value[k] = comp->integers[vr[k]]; + } + return fmi2OK; + } } fmi2Status fmi_get_boolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->booleans[vr[k]]; - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + value[k] = comp->booleans[vr[k]]; + } + return fmi2OK; + } } fmi2Status fmi_get_string(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->strings[vr[k]]; - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + value[k] = comp->strings[vr[k]]; + } + return fmi2OK; + } } fmi2Status fmi_set_real(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - fmi2ValueReference cvr = vr[k]; - if (cvr < N_STATES) { - comp->states[cvr] = value[k]; - } - else if(cvr == 4) { - comp->functions->logger(c, comp->instanceName,fmi2Warning, "WARNING", "Cannot set acceleration value (calculated)"); - return fmi2Error; - } - else { - comp->reals[cvr] = value[k]; - } - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + fmi2ValueReference cvr = vr[k]; + if (cvr < N_STATES) { + comp->states[cvr] = value[k]; + } + else if(cvr == 4) { + comp->functions->logger(c, comp->instanceName,fmi2Warning, "WARNING", "Cannot set acceleration value (calculated)"); + return fmi2Error; + } + else { + comp->reals[cvr] = value[k]; + } + } + return fmi2OK; + } } fmi2Status fmi_set_integer(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - comp->integers[vr[k]] = value[k]; - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + comp->integers[vr[k]] = value[k]; + } + return fmi2OK; + } } fmi2Status fmi_set_boolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - comp->booleans[vr[k]] = value[k]; - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + comp->booleans[vr[k]] = value[k]; + } + return fmi2OK; + } } fmi2Status fmi_set_string(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[]) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nvr; k++) { - size_t len; - fmi2String s_dist; - fmi2String s_src = value[k]; - - len = strlen((char*)s_src) + 1; - s_dist = comp->functions->allocateMemory(len, sizeof(char)); - if (s_dist == NULL) { - return fmi2Fatal; - } - strcpy((char*)s_dist, (char*)s_src); - if(comp->strings[vr[k]]) { - comp->functions->freeMemory((void*)comp->strings[vr[k]]); - } - comp->strings[vr[k]] = s_dist; - } - - /******* Logger test *******/ - if(comp->loggingOn == fmi2True) { - for (k = 0; k < nvr; k++) { - fmi2ValueReference cvr = vr[k]; - if (cvr == VAR_S_LOGGER_TEST) { - comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2Fatal, "INFO", "%s",value[k]); - } - } - } - /******* End of logger test *******/ - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nvr; k++) { + size_t len; + fmi2String s_dist; + fmi2String s_src = value[k]; + + len = strlen((char*)s_src) + 1; + s_dist = comp->functions->allocateMemory(len, sizeof(char)); + if (s_dist == NULL) { + return fmi2Fatal; + } + strcpy((char*)s_dist, (char*)s_src); + if(comp->strings[vr[k]]) { + comp->functions->freeMemory((void*)comp->strings[vr[k]]); + } + comp->strings[vr[k]] = s_dist; + } + + /******* Logger test *******/ + if(comp->loggingOn == fmi2True) { + for (k = 0; k < nvr; k++) { + fmi2ValueReference cvr = vr[k]; + if (cvr == VAR_S_LOGGER_TEST) { + comp->functions->logger(comp->functions->componentEnvironment, comp->instanceName, fmi2Fatal, "INFO", "%s",value[k]); + } + } + } + /******* End of logger test *******/ + return fmi2OK; + } } /* FMI 2.0 ME Functions */ const char* fmi_get_model_types_platform() { - return fmi2TypesPlatform; + return fmi2TypesPlatform; } /* static FILE* find_string(FILE* fp, char* str, int len) { @@ -262,62 +262,62 @@ fmi2Component fmi_instantiate(fmi2String instanceName, fmi2Type fmuType, const fmi2CallbackFunctions *functions, fmi2Boolean visible, fmi2Boolean loggingOn) { - component_ptr_t comp; - int k, p; - - comp = (component_ptr_t)functions->allocateMemory(1, sizeof(component_t)); - if (comp == NULL) { - return NULL; - } else if (strcmp(fmuGUID, FMI_GUID) != 0) { - return NULL; - } else { - sprintf(comp->instanceName, "%s", instanceName); - sprintf(comp->GUID, "%s",fmuGUID); - comp->functions = functions; - /*comp->functions->allocateMemory = functions->allocateMemory;*/ - - comp->loggingOn = loggingOn; - - /* Set default values */ - for (k = 0; k < N_STATES; k++) comp->states[k] = 0.0; - for (k = 0; k < N_STATES; k++) comp->states_prev[k] = 0.0; /* Used in CS only */ - for (k = 0; k < N_STATES; k++) comp->states_nom[k] = 1.0; - for (k = 0; k < N_STATES; k++) comp->states_der[k] = 0.0; - for (k = 0; k < N_EVENT_INDICATORS; k++) comp->event_indicators[k] = 1e10; - for (k = 0; k < N_REAL; k++) comp->reals[k] = 0.0; - for (k = 0; k < N_INTEGER; k++) comp->integers[k] = 0; - for (k = 0; k < N_BOOLEAN; k++) comp->booleans[k] = fmi2False; - for (k = 0; k < N_STRING; k++) comp->strings[k] = NULL; - - /* Used in CS only */ - for (k = 0; k < N_INPUT_REAL; k++) { - for (p = 0; p < N_INPUT_REAL_MAX_ORDER + 1; p++) { - comp->input_real[k][p] = 0.0; - } - } - - /* Used in CS only */ - for (k = 0; k < N_OUTPUT_REAL; k++) { - for (p = 0; p < N_OUTPUT_REAL_MAX_ORDER + 1; p++) { - comp->output_real[k][p] = MAGIC_TEST_VALUE; - } - } - - sprintf(comp->fmuLocation, "%s",fmuLocation); - comp->visible = visible; - return comp; - } + component_ptr_t comp; + int k, p; + + comp = (component_ptr_t)functions->allocateMemory(1, sizeof(component_t)); + if (comp == NULL) { + return NULL; + } else if (strcmp(fmuGUID, FMI_GUID) != 0) { + return NULL; + } else { + sprintf(comp->instanceName, "%s", instanceName); + sprintf(comp->GUID, "%s",fmuGUID); + comp->functions = functions; + /*comp->functions->allocateMemory = functions->allocateMemory;*/ + + comp->loggingOn = loggingOn; + + /* Set default values */ + for (k = 0; k < N_STATES; k++) comp->states[k] = 0.0; + for (k = 0; k < N_STATES; k++) comp->states_prev[k] = 0.0; /* Used in CS only */ + for (k = 0; k < N_STATES; k++) comp->states_nom[k] = 1.0; + for (k = 0; k < N_STATES; k++) comp->states_der[k] = 0.0; + for (k = 0; k < N_EVENT_INDICATORS; k++) comp->event_indicators[k] = 1e10; + for (k = 0; k < N_REAL; k++) comp->reals[k] = 0.0; + for (k = 0; k < N_INTEGER; k++) comp->integers[k] = 0; + for (k = 0; k < N_BOOLEAN; k++) comp->booleans[k] = fmi2False; + for (k = 0; k < N_STRING; k++) comp->strings[k] = NULL; + + /* Used in CS only */ + for (k = 0; k < N_INPUT_REAL; k++) { + for (p = 0; p < N_INPUT_REAL_MAX_ORDER + 1; p++) { + comp->input_real[k][p] = 0.0; + } + } + + /* Used in CS only */ + for (k = 0; k < N_OUTPUT_REAL; k++) { + for (p = 0; p < N_OUTPUT_REAL_MAX_ORDER + 1; p++) { + comp->output_real[k][p] = MAGIC_TEST_VALUE; + } + } + + sprintf(comp->fmuLocation, "%s",fmuLocation); + comp->visible = visible; + return comp; + } } void fmi_free_instance(fmi2Component c) { - int i; - component_ptr_t comp = (fmi2Component)c; - for(i = 0; i < N_STRING; i++) { - comp->functions->freeMemory((void*)(comp->strings[i])); - comp->strings[i] = 0; - } - comp->functions->freeMemory(c); + int i; + component_ptr_t comp = (fmi2Component)c; + for(i = 0; i < N_STRING; i++) { + comp->functions->freeMemory((void*)(comp->strings[i])); + comp->strings[i] = 0; + } + comp->functions->freeMemory(c); } fmi2Status fmi_setup_experiment(fmi2Component c, fmi2Boolean toleranceDefined, @@ -363,15 +363,15 @@ fmi2Status fmi_enter_event_mode(fmi2Component c) fmi2Status fmi_new_discrete_states(fmi2Component c, fmi2EventInfo* eventInfo) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - calc_event_update(comp); + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + calc_event_update(comp); - *eventInfo = comp->eventInfo; - return fmi2OK; - } + *eventInfo = comp->eventInfo; + return fmi2OK; + } } fmi2Status fmi_enter_continuous_time_mode(fmi2Component c) @@ -381,306 +381,306 @@ fmi2Status fmi_enter_continuous_time_mode(fmi2Component c) fmi2Status fmi_set_time(fmi2Component c, fmi2Real fmitime) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - comp->fmitime = fmitime; - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + comp->fmitime = fmitime; + return fmi2OK; + } } fmi2Status fmi_set_continuous_states(fmi2Component c, const fmi2Real x[], size_t nx) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nx; k++) { - comp->states[k] = x[k]; - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nx; k++) { + comp->states[k] = x[k]; + } + return fmi2OK; + } } fmi2Status fmi_completed_integrator_step(fmi2Component c, fmi2Boolean noSetFMUStatePriorToCurrentPoint, fmi2Boolean* enterEventMode, fmi2Boolean* terminateSimulation) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - *enterEventMode = fmi2False; - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + *enterEventMode = fmi2False; + return fmi2OK; + } } fmi2Status fmi_get_derivatives(fmi2Component c, fmi2Real derivatives[] , size_t nx) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; - calc_get_derivatives(comp); + calc_get_derivatives(comp); - for (k = 0; k < nx; k++) { - derivatives[k] = comp->states_der[k]; - } - return fmi2OK; - } + for (k = 0; k < nx; k++) { + derivatives[k] = comp->states_der[k]; + } + return fmi2OK; + } } fmi2Status fmi_get_event_indicators(fmi2Component c, fmi2Real eventIndicators[], size_t ni) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; - calc_get_event_indicators(comp); + calc_get_event_indicators(comp); - for (k = 0; k < ni; k++) { - eventIndicators[k] = comp->event_indicators[k]; - } - return fmi2OK; - } + for (k = 0; k < ni; k++) { + eventIndicators[k] = comp->event_indicators[k]; + } + return fmi2OK; + } } fmi2Status fmi_get_continuous_states(fmi2Component c, fmi2Real states[], size_t nx) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; - for (k = 0; k < nx; k++) { - states[k] = comp->states[k]; - } - return fmi2OK; - } + for (k = 0; k < nx; k++) { + states[k] = comp->states[k]; + } + return fmi2OK; + } } fmi2Status fmi_get_nominals_of_continuousstates(fmi2Component c, fmi2Real x_nominal[], size_t nx) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - size_t k; - for (k = 0; k < nx; k++) { - x_nominal[k] = comp->states_nom[k]; - } - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + size_t k; + for (k = 0; k < nx; k++) { + x_nominal[k] = comp->states_nom[k]; + } + return fmi2OK; + } } fmi2Status fmi_terminate(fmi2Component c) { - component_ptr_t comp = (fmi2Component)c; - if (comp == NULL) { - return fmi2Fatal; - } else { - return fmi2OK; - } + component_ptr_t comp = (fmi2Component)c; + if (comp == NULL) { + return fmi2Fatal; + } else { + return fmi2OK; + } } /* FMI 2.0 CS Functions */ const char* fmi_get_types_platform() { - return fmi2TypesPlatform; + return fmi2TypesPlatform; } fmi2Status fmi_reset(fmi2Component c) { - return fmi2OK; + return fmi2OK; } fmi2Status fmi_set_real_input_derivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer order[], const fmi2Real value[]) { - component_ptr_t comp = (fmi2Component)c; - size_t k; + component_ptr_t comp = (fmi2Component)c; + size_t k; - for (k = 0; k < nvr; k++) { - comp->input_real[vr[k]][order[k]] = value[k]; - if (value[k] != MAGIC_TEST_VALUE) {/* Tests that the value is set to MAGIC_TEST_VALUE */ - return fmi2Fatal; - } - } + for (k = 0; k < nvr; k++) { + comp->input_real[vr[k]][order[k]] = value[k]; + if (value[k] != MAGIC_TEST_VALUE) {/* Tests that the value is set to MAGIC_TEST_VALUE */ + return fmi2Fatal; + } + } - return fmi2OK; + return fmi2OK; } fmi2Status fmi_get_real_output_derivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer order[], fmi2Real value[]) { - component_ptr_t comp = (fmi2Component)c; - size_t k; + component_ptr_t comp = (fmi2Component)c; + size_t k; - for (k = 0; k < nvr; k++) { - value[k] = comp->output_real[vr[k]][order[k]]; - } + for (k = 0; k < nvr; k++) { + value[k] = comp->output_real[vr[k]][order[k]]; + } - return fmi2OK; + return fmi2OK; } fmi2Status fmi_cancel_step(fmi2Component c) { - return fmi2OK; + return fmi2OK; } fmi2Status fmi_do_step(fmi2Component c, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean newStep) { - component_ptr_t comp = (fmi2Component)c; - - if (comp == NULL) { - return fmi2Fatal; - } else { - fmi2Real tstart = currentCommunicationPoint; - fmi2Real tcur; - fmi2Real tend = currentCommunicationPoint + communicationStepSize; - fmi2Real hcur; - fmi2Real hdef = 0.01; /* Default time step length */ - fmi2Real z_cur[N_EVENT_INDICATORS]; - fmi2Real z_pre[N_EVENT_INDICATORS]; - fmi2Real states[N_STATES]; - fmi2Real states_der[N_STATES]; - fmi2EventInfo eventInfo; - fmi2Boolean callEventUpdate; - fmi2Boolean terminateSimulation; - fmi2Status fmi2Status; - size_t k; - size_t counter = 0; - - fmi_get_continuous_states(comp, states, N_STATES); - fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); - - tcur = tstart; - hcur = hdef; - callEventUpdate = fmi2False; - eventInfo = comp->eventInfo; - - while (tcur < tend && counter < 100) { - size_t k; - int zero_crossning_event = 0; - counter++; - - fmi_set_time(comp, tcur); - fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); - - /* Check if an event inidcator has triggered */ - for (k = 0; k < N_EVENT_INDICATORS; k++) { - if (z_cur[k]*z_pre[k] < 0) { - zero_crossning_event = 1; - break; - } - } - - /* Handle any events */ - if (callEventUpdate || zero_crossning_event || - (eventInfo.nextEventTimeDefined && tcur == eventInfo.nextEventTime)) { - fmi2Status = fmi_new_discrete_states(comp, &eventInfo); - fmi2Status = fmi_get_continuous_states(comp, states, N_STATES); - fmi2Status = fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); - fmi2Status = fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); - } - - /* Updated next time step */ - if (eventInfo.nextEventTimeDefined) { - if (tcur + hdef < eventInfo.nextEventTime) { - hcur = hdef; - } else { - hcur = eventInfo.nextEventTime - tcur; - } - } else { - hcur = hdef; - } - - { - double t_full = tcur + hcur; - if(t_full > tend) { - hcur = (tend - tcur); - tcur = tend; - } - else - tcur = t_full; - } - - /* Integrate a step */ - fmi2Status = fmi_get_derivatives(comp, states_der, N_STATES); - for (k = 0; k < N_STATES; k++) { - states[k] = states[k] + hcur*states_der[k]; - /* if (k == 0) printf("states[%u] = %f states_der[k] = %f hcur =%f\n", k, states[k], states_der[k], hcur); */ - } - - /* Set states */ - fmi2Status = fmi_set_continuous_states(comp, states, N_STATES); - /* Step is complete */ - fmi2Status = fmi_completed_integrator_step(comp, fmi2True, + component_ptr_t comp = (fmi2Component)c; + + if (comp == NULL) { + return fmi2Fatal; + } else { + fmi2Real tstart = currentCommunicationPoint; + fmi2Real tcur; + fmi2Real tend = currentCommunicationPoint + communicationStepSize; + fmi2Real hcur; + fmi2Real hdef = 0.01; /* Default time step length */ + fmi2Real z_cur[N_EVENT_INDICATORS]; + fmi2Real z_pre[N_EVENT_INDICATORS]; + fmi2Real states[N_STATES]; + fmi2Real states_der[N_STATES]; + fmi2EventInfo eventInfo; + fmi2Boolean callEventUpdate; + fmi2Boolean terminateSimulation; + fmi2Status fmi2Status; + size_t k; + size_t counter = 0; + + fmi_get_continuous_states(comp, states, N_STATES); + fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); + + tcur = tstart; + hcur = hdef; + callEventUpdate = fmi2False; + eventInfo = comp->eventInfo; + + while (tcur < tend && counter < 100) { + size_t k; + int zero_crossning_event = 0; + counter++; + + fmi_set_time(comp, tcur); + fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); + + /* Check if an event inidcator has triggered */ + for (k = 0; k < N_EVENT_INDICATORS; k++) { + if (z_cur[k]*z_pre[k] < 0) { + zero_crossning_event = 1; + break; + } + } + + /* Handle any events */ + if (callEventUpdate || zero_crossning_event || + (eventInfo.nextEventTimeDefined && tcur == eventInfo.nextEventTime)) { + fmi2Status = fmi_new_discrete_states(comp, &eventInfo); + fmi2Status = fmi_get_continuous_states(comp, states, N_STATES); + fmi2Status = fmi_get_event_indicators(comp, z_cur, N_EVENT_INDICATORS); + fmi2Status = fmi_get_event_indicators(comp, z_pre, N_EVENT_INDICATORS); + } + + /* Updated next time step */ + if (eventInfo.nextEventTimeDefined) { + if (tcur + hdef < eventInfo.nextEventTime) { + hcur = hdef; + } else { + hcur = eventInfo.nextEventTime - tcur; + } + } else { + hcur = hdef; + } + + { + double t_full = tcur + hcur; + if(t_full > tend) { + hcur = (tend - tcur); + tcur = tend; + } + else + tcur = t_full; + } + + /* Integrate a step */ + fmi2Status = fmi_get_derivatives(comp, states_der, N_STATES); + for (k = 0; k < N_STATES; k++) { + states[k] = states[k] + hcur*states_der[k]; + /* if (k == 0) printf("states[%u] = %f states_der[k] = %f hcur =%f\n", k, states[k], states_der[k], hcur); */ + } + + /* Set states */ + fmi2Status = fmi_set_continuous_states(comp, states, N_STATES); + /* Step is complete */ + fmi2Status = fmi_completed_integrator_step(comp, fmi2True, &callEventUpdate, &terminateSimulation); if(fmi2Status != fmi2OK) break; - } - for (k = 0; k < N_STATES; k++) { /* Update states */ - comp->reals[k] = comp->states[k]; - } - return fmi2OK; - } + } + for (k = 0; k < N_STATES; k++) { /* Update states */ + comp->reals[k] = comp->states[k]; + } + return fmi2OK; + } } fmi2Status fmi_get_status(fmi2Component c, const fmi2StatusKind s, fmi2Status* value) { - switch (s) { - case fmi2DoStepStatus: - /* Return fmiPending if we are waiting. Otherwise the result from fmiDoStep */ - *value = fmi2OK; - return fmi2OK; - default: /* Not defined for status for this function */ - return fmi2Discard; - } + switch (s) { + case fmi2DoStepStatus: + /* Return fmiPending if we are waiting. Otherwise the result from fmiDoStep */ + *value = fmi2OK; + return fmi2OK; + default: /* Not defined for status for this function */ + return fmi2Discard; + } } fmi2Status fmi_get_real_status(fmi2Component c, const fmi2StatusKind s, fmi2Real* value) { - switch (s) { - case fmi2LastSuccessfulTime: - /* Return fmiPending if we are waiting. Otherwise return end time for last call to fmiDoStep */ - *value = 0.01; - return fmi2OK; - default: /* Not defined for status for this function */ - return fmi2Discard; - } + switch (s) { + case fmi2LastSuccessfulTime: + /* Return fmiPending if we are waiting. Otherwise return end time for last call to fmiDoStep */ + *value = 0.01; + return fmi2OK; + default: /* Not defined for status for this function */ + return fmi2Discard; + } } fmi2Status fmi_get_integer_status(fmi2Component c, const fmi2StatusKind s, fmi2Integer* value) { - switch (s) { - default: /* Not defined for status for this function */ - return fmi2Discard; - } + switch (s) { + default: /* Not defined for status for this function */ + return fmi2Discard; + } } fmi2Status fmi_get_boolean_status(fmi2Component c, const fmi2StatusKind s, fmi2Boolean* value) { - switch (s) { - default: /* Not defined for status for this function */ - return fmi2Discard; - } + switch (s) { + default: /* Not defined for status for this function */ + return fmi2Discard; + } } fmi2Status fmi_get_string_status(fmi2Component c, const fmi2StatusKind s, fmi2String* value) { - switch (s) { - case fmi2PendingStatus: - *value = "Did fmi2DoStep really return with fmi2Pending? Then its time to implement this function"; - return fmi2Discard; - default: /* Not defined for status for this function */ - return fmi2Discard; - } + switch (s) { + case fmi2PendingStatus: + *value = "Did fmi2DoStep really return with fmi2Pending? Then its time to implement this function"; + return fmi2Discard; + default: /* Not defined for status for this function */ + return fmi2Discard; + } } diff --git a/Test/FMI2/fmu_dummy/fmu2_model.h b/Test/FMI2/fmu_dummy/fmu2_model.h index c0c7cd27..22900347 100644 --- a/Test/FMI2/fmu_dummy/fmu2_model.h +++ b/Test/FMI2/fmu_dummy/fmu2_model.h @@ -21,61 +21,61 @@ along with this program. If not, contact Modelon AB . #include #ifndef FMI2_Export - #define FMI2_Export DllExport + #define FMI2_Export DllExport #endif typedef struct { - /*************** FMI ME 2.0 ****************/ - fmi2Real states [N_STATES]; - fmi2Real states_nom [N_STATES]; - fmi2Real states_der [N_STATES]; - fmi2Real event_indicators[N_EVENT_INDICATORS]; - fmi2Real reals [N_REAL]; - fmi2Integer integers [N_INTEGER]; - fmi2Boolean booleans [N_BOOLEAN]; - fmi2String strings [N_STRING]; - - /* fmiInstantiateModel */ - fmi2Boolean loggingOn; - char instanceName [BUFFER]; - char GUID [BUFFER]; - const fmi2CallbackFunctions* functions; - - /* fmiSetTime */ - fmi2Real fmitime; - - /* fmiInitializeModel */ - fmi2Boolean toleranceControlled; - fmi2Real relativeTolerance; - fmi2EventInfo eventInfo; - - /*************** FMI CS 2.0. Depends on the ME fields above and functions ****************/ - fmi2Real states_prev [N_STATES]; - - /* fmiInstantiateSlave */ - char fmuLocation [BUFFER]; - fmi2Boolean visible; - - /* fmiInitializeSlave */ - fmi2Real tStart; - fmi2Boolean StopTimeDefined; - fmi2Real tStop; - - /* fmiSetRealInputDerivatives */ - fmi2Real input_real [N_INPUT_REAL][N_INPUT_REAL_MAX_ORDER + 1]; - - /* fmiGetRealOutputDerivatives */ - fmi2Real output_real [N_OUTPUT_REAL][N_OUTPUT_REAL_MAX_ORDER + 1]; + /*************** FMI ME 2.0 ****************/ + fmi2Real states [N_STATES]; + fmi2Real states_nom [N_STATES]; + fmi2Real states_der [N_STATES]; + fmi2Real event_indicators[N_EVENT_INDICATORS]; + fmi2Real reals [N_REAL]; + fmi2Integer integers [N_INTEGER]; + fmi2Boolean booleans [N_BOOLEAN]; + fmi2String strings [N_STRING]; + + /* fmiInstantiateModel */ + fmi2Boolean loggingOn; + char instanceName [BUFFER]; + char GUID [BUFFER]; + const fmi2CallbackFunctions* functions; + + /* fmiSetTime */ + fmi2Real fmitime; + + /* fmiInitializeModel */ + fmi2Boolean toleranceControlled; + fmi2Real relativeTolerance; + fmi2EventInfo eventInfo; + + /*************** FMI CS 2.0. Depends on the ME fields above and functions ****************/ + fmi2Real states_prev [N_STATES]; + + /* fmiInstantiateSlave */ + char fmuLocation [BUFFER]; + fmi2Boolean visible; + + /* fmiInitializeSlave */ + fmi2Real tStart; + fmi2Boolean StopTimeDefined; + fmi2Real tStop; + + /* fmiSetRealInputDerivatives */ + fmi2Real input_real [N_INPUT_REAL][N_INPUT_REAL_MAX_ORDER + 1]; + + /* fmiGetRealOutputDerivatives */ + fmi2Real output_real [N_OUTPUT_REAL][N_OUTPUT_REAL_MAX_ORDER + 1]; } component_t; typedef component_t* component_ptr_t; /* FMI 2.0 Common Functions */ -const char* fmi_get_version(); +const char* fmi_get_version(); -fmi2Status fmi_set_debug_logging( - fmi2Component c, - fmi2Boolean loggingOn); +fmi2Status fmi_set_debug_logging( + fmi2Component c, + fmi2Boolean loggingOn); fmi2Component fmi_instantiate ( fmi2String instanceName, @@ -93,156 +93,156 @@ fmi2Status fmi_setup_experiment(fmi2Component c, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime); -fmi2Status fmi_enter_initialization_mode(fmi2Component c); -fmi2Status fmi_exit_initialization_mode(fmi2Component c); - -fmi2Status fmi_terminate(fmi2Component c); - -fmi2Status fmi_reset( - fmi2Component c); - - -fmi2Status fmi_get_real( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, fmi2Real value[]); - -fmi2Status fmi_get_integer( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - fmi2Integer value[]); -fmi2Status fmi_get_boolean( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - fmi2Boolean value[]); - -fmi2Status fmi_get_string( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - fmi2String value[]); - -fmi2Status fmi_set_real( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - const fmi2Real value[]); -fmi2Status fmi_set_integer( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - const fmi2Integer value[]); - -fmi2Status fmi_set_boolean( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - const fmi2Boolean value[]); - -fmi2Status fmi_set_string( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - const fmi2String value[]); +fmi2Status fmi_enter_initialization_mode(fmi2Component c); +fmi2Status fmi_exit_initialization_mode(fmi2Component c); + +fmi2Status fmi_terminate(fmi2Component c); + +fmi2Status fmi_reset( + fmi2Component c); + + +fmi2Status fmi_get_real( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, fmi2Real value[]); + +fmi2Status fmi_get_integer( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + fmi2Integer value[]); +fmi2Status fmi_get_boolean( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + fmi2Boolean value[]); + +fmi2Status fmi_get_string( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + fmi2String value[]); + +fmi2Status fmi_set_real( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + const fmi2Real value[]); +fmi2Status fmi_set_integer( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + const fmi2Integer value[]); + +fmi2Status fmi_set_boolean( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + const fmi2Boolean value[]); + +fmi2Status fmi_set_string( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + const fmi2String value[]); /* FMI 2.0 ME Functions */ -const char* fmi_get_model_types_platform(); +const char* fmi_get_model_types_platform(); -fmi2Status fmi_enter_event_mode(fmi2Component c); -fmi2Status fmi_new_discrete_states(fmi2Component c, fmi2EventInfo* eventInfo); -fmi2Status fmi_enter_continuous_time_mode(fmi2Component c); +fmi2Status fmi_enter_event_mode(fmi2Component c); +fmi2Status fmi_new_discrete_states(fmi2Component c, fmi2EventInfo* eventInfo); +fmi2Status fmi_enter_continuous_time_mode(fmi2Component c); -fmi2Status fmi_set_time( - fmi2Component c, - fmi2Real fmitime); +fmi2Status fmi_set_time( + fmi2Component c, + fmi2Real fmitime); -fmi2Status fmi_set_continuous_states( - fmi2Component c, - const fmi2Real x[], - size_t nx); +fmi2Status fmi_set_continuous_states( + fmi2Component c, + const fmi2Real x[], + size_t nx); fmi2Status fmi_completed_integrator_step( fmi2Component c, fmi2Boolean noSetFMUStatePriorToCurrentPoint, fmi2Boolean* enterEventMode, fmi2Boolean* terminateSimulation); -fmi2Status fmi_get_derivatives( - fmi2Component c, - fmi2Real derivatives[], - size_t nx); +fmi2Status fmi_get_derivatives( + fmi2Component c, + fmi2Real derivatives[], + size_t nx); -fmi2Status fmi_get_event_indicators( - fmi2Component c, - fmi2Real eventIndicators[], - size_t ni); +fmi2Status fmi_get_event_indicators( + fmi2Component c, + fmi2Real eventIndicators[], + size_t ni); -fmi2Status fmi_get_continuous_states( - fmi2Component c, - fmi2Real states[], - size_t nx); +fmi2Status fmi_get_continuous_states( + fmi2Component c, + fmi2Real states[], + size_t nx); -fmi2Status fmi_get_nominals_of_continuousstates( - fmi2Component c, - fmi2Real x_nominal[], - size_t nx); +fmi2Status fmi_get_nominals_of_continuousstates( + fmi2Component c, + fmi2Real x_nominal[], + size_t nx); /* FMI 2.0 CS Functions */ #ifdef fmi2Functions_h -const char* fmi_get_types_platform(); - -void fmi_free_slave_instance( - fmi2Component c); - -fmi2Status fmi_set_real_input_derivatives( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - const fmi2Integer order[], - const fmi2Real value[]); - -fmi2Status fmi_get_real_output_derivatives( - fmi2Component c, - const fmi2ValueReference vr[], - size_t nvr, - const fmi2Integer order[], - fmi2Real value[]); - -fmi2Status fmi_cancel_step( - fmi2Component c); -fmi2Status fmi_do_step( - fmi2Component c, - fmi2Real currentCommunicationPoint, - fmi2Real communicationStepSize, - fmi2Boolean newStep); - -fmi2Status fmi_get_status( - fmi2Component c, - const fmi2StatusKind s, - fmi2Status* value); - -fmi2Status fmi_get_real_status( - fmi2Component c, - const fmi2StatusKind s, - fmi2Real* value); - -fmi2Status fmi_get_integer_status( - fmi2Component c, - const fmi2StatusKind s, - fmi2Integer* value); - -fmi2Status fmi_get_boolean_status( - fmi2Component c, - const fmi2StatusKind s, - fmi2Boolean* value); - -fmi2Status fmi_get_string_status( - fmi2Component c, - const fmi2StatusKind s, - fmi2String* value); +const char* fmi_get_types_platform(); + +void fmi_free_slave_instance( + fmi2Component c); + +fmi2Status fmi_set_real_input_derivatives( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + const fmi2Integer order[], + const fmi2Real value[]); + +fmi2Status fmi_get_real_output_derivatives( + fmi2Component c, + const fmi2ValueReference vr[], + size_t nvr, + const fmi2Integer order[], + fmi2Real value[]); + +fmi2Status fmi_cancel_step( + fmi2Component c); +fmi2Status fmi_do_step( + fmi2Component c, + fmi2Real currentCommunicationPoint, + fmi2Real communicationStepSize, + fmi2Boolean newStep); + +fmi2Status fmi_get_status( + fmi2Component c, + const fmi2StatusKind s, + fmi2Status* value); + +fmi2Status fmi_get_real_status( + fmi2Component c, + const fmi2StatusKind s, + fmi2Real* value); + +fmi2Status fmi_get_integer_status( + fmi2Component c, + const fmi2StatusKind s, + fmi2Integer* value); + +fmi2Status fmi_get_boolean_status( + fmi2Component c, + const fmi2StatusKind s, + fmi2Boolean* value); + +fmi2Status fmi_get_string_status( + fmi2Component c, + const fmi2StatusKind s, + fmi2String* value); #endif /* End of fmi2Functions_h */ #endif /* End of header FMU2_MODEL_H_ */ diff --git a/Test/FMI2/fmu_dummy/fmu2_model_cs.c b/Test/FMI2/fmu_dummy/fmu2_model_cs.c index 5ca65911..e6dc9fcb 100644 --- a/Test/FMI2/fmu_dummy/fmu2_model_cs.c +++ b/Test/FMI2/fmu_dummy/fmu2_model_cs.c @@ -37,12 +37,12 @@ along with this program. If not, contact Modelon AB . /* FMI 2.0 Common Functions */ FMI2_Export const char* fmi2GetVersion() { - return fmi_get_version(); + return fmi_get_version(); } FMI2_Export fmi2Status fmi2SetDebugLogging(fmi2Component c, fmi2Boolean loggingOn, size_t n, const fmi2String cat[]) { - return fmi_set_debug_logging(c, loggingOn); + return fmi_set_debug_logging(c, loggingOn); } FMI2_Export fmi2Component fmi2Instantiate(fmi2String instanceName, @@ -56,7 +56,7 @@ FMI2_Export fmi2Component fmi2Instantiate(fmi2String instanceName, FMI2_Export void fmi2FreeInstance(fmi2Component c) { - fmi_free_instance(c); + fmi_free_instance(c); } FMI2_Export fmi2Status fmi2SetupExperiment(fmi2Component c, @@ -80,101 +80,101 @@ FMI2_Export fmi2Status fmi2ExitInitializationMode(fmi2Component c) FMI2_Export fmi2Status fmi2GetReal(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[]) { - return fmi_get_real(c, vr, nvr, value); + return fmi_get_real(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2GetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[]) { - return fmi_get_integer(c, vr, nvr, value); + return fmi_get_integer(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2GetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[]) { - return fmi_get_boolean(c, vr, nvr, value); + return fmi_get_boolean(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2GetString(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[]) { - return fmi_get_string(c, vr, nvr, value); + return fmi_get_string(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetReal(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[]) { - return fmi_set_real(c, vr, nvr, value); + return fmi_set_real(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[]) { - return fmi_set_integer(c, vr, nvr, value); + return fmi_set_integer(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[]) { - return fmi_set_boolean(c, vr, nvr, value); + return fmi_set_boolean(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetString(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[]) { - return fmi_set_string(c, vr, nvr, value); + return fmi_set_string(c, vr, nvr, value); } /* FMI 2.0 CS Functions */ FMI2_Export const char* fmi2GetTypesPlatform() { - return fmi_get_types_platform(); + return fmi_get_types_platform(); } FMI2_Export fmi2Status fmi2Terminate(fmi2Component c) { - return fmi_terminate(c); + return fmi_terminate(c); } FMI2_Export fmi2Status fmi2Reset(fmi2Component c) { - return fmi_reset(c); + return fmi_reset(c); } FMI2_Export fmi2Status fmi2SetRealInputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer order[], const fmi2Real value[]) { - return fmi_set_real_input_derivatives(c, vr, nvr, order, value); + return fmi_set_real_input_derivatives(c, vr, nvr, order, value); } FMI2_Export fmi2Status fmi2GetRealOutputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer order[], fmi2Real value[]) { - return fmi_get_real_output_derivatives(c, vr, nvr, order, value); + return fmi_get_real_output_derivatives(c, vr, nvr, order, value); } FMI2_Export fmi2Status fmi2CancelStep(fmi2Component c) { - return fmi_cancel_step(c); + return fmi_cancel_step(c); } FMI2_Export fmi2Status fmi2DoStep(fmi2Component c, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean newStep) { - return fmi_do_step(c, currentCommunicationPoint, communicationStepSize, newStep); + return fmi_do_step(c, currentCommunicationPoint, communicationStepSize, newStep); } FMI2_Export fmi2Status fmi2GetStatus(fmi2Component c, const fmi2StatusKind s, fmi2Status* value) { - return fmi_get_status(c, s, value); + return fmi_get_status(c, s, value); } FMI2_Export fmi2Status fmi2GetRealStatus(fmi2Component c, const fmi2StatusKind s, fmi2Real* value) { - return fmi_get_real_status(c, s, value); + return fmi_get_real_status(c, s, value); } FMI2_Export fmi2Status fmi2GetIntegerStatus(fmi2Component c, const fmi2StatusKind s, fmi2Integer* value) { - return fmi_get_integer_status(c, s, value); + return fmi_get_integer_status(c, s, value); } FMI2_Export fmi2Status fmi2GetBooleanStatus(fmi2Component c, const fmi2StatusKind s, fmi2Boolean* value) { - return fmi_get_boolean_status(c, s, value); + return fmi_get_boolean_status(c, s, value); } FMI2_Export fmi2Status fmi2GetStringStatus(fmi2Component c, const fmi2StatusKind s, fmi2String* value) { - return fmi_get_string_status(c, s, value); + return fmi_get_string_status(c, s, value); } diff --git a/Test/FMI2/fmu_dummy/fmu2_model_defines.h b/Test/FMI2/fmu_dummy/fmu2_model_defines.h index b7d004ce..f94835e6 100644 --- a/Test/FMI2/fmu_dummy/fmu2_model_defines.h +++ b/Test/FMI2/fmu_dummy/fmu2_model_defines.h @@ -18,45 +18,45 @@ along with this program. If not, contact Modelon AB . /* This header is used to generate the FMU test DLL and in the C API test that uses the DLL */ #ifndef FMU2_MODEL_DEFINES_H_ -/*#define STRINGIFY(a) #a -#define STRINGIFY2(a) STRINGIFY(a) -#define MODEL_IDENTIFIER_STR STRINGIFY2(MODEL_IDENTIFIER) */ +/*#define STRINGIFY(a) #a +#define STRINGIFY2(a) STRINGIFY(a) +#define MODEL_IDENTIFIER_STR STRINGIFY2(MODEL_IDENTIFIER) */ -#define BUFFER 1024 -#define MAGIC_TEST_VALUE 13.0 /* A test value for some functions */ +#define BUFFER 1024 +#define MAGIC_TEST_VALUE 13.0 /* A test value for some functions */ /* BouncingBall model with redundant values */ /* ValueReferences for the variables and parameters in the model */ /* States */ -#define VAR_R_HEIGHT 0 -#define VAR_R_HEIGHT_SPEED 1 +#define VAR_R_HEIGHT 0 +#define VAR_R_HEIGHT_SPEED 1 /* Real */ -#define VAR_R_GRATIVY 2 -#define VAR_R_BOUNCE_CONF 3 +#define VAR_R_GRATIVY 2 +#define VAR_R_BOUNCE_CONF 3 /* Event indicators */ -#define EVENT_HEIGHT 0 +#define EVENT_HEIGHT 0 /* Event indicators */ -#define VAR_S_LOGGER_TEST 0 +#define VAR_S_LOGGER_TEST 0 /* Sizes */ -#define N_STATES 2 -#define N_EVENT_INDICATORS 1 -#define N_REAL 4 -#define N_INTEGER 4 -#define N_BOOLEAN 4 -#define N_STRING 4 +#define N_STATES 2 +#define N_EVENT_INDICATORS 1 +#define N_REAL 4 +#define N_INTEGER 4 +#define N_BOOLEAN 4 +#define N_STRING 4 -#define N_INPUT_REAL 2 /* CS only */ -#define N_INPUT_REAL_MAX_ORDER 2 /* CS only */ -#define N_OUTPUT_REAL 2 /* CS only */ -#define N_OUTPUT_REAL_MAX_ORDER 2 /* CS only */ +#define N_INPUT_REAL 2 /* CS only */ +#define N_INPUT_REAL_MAX_ORDER 2 /* CS only */ +#define N_OUTPUT_REAL 2 /* CS only */ +#define N_OUTPUT_REAL_MAX_ORDER 2 /* CS only */ -#define FMI_VERSION "2.0" +#define FMI_VERSION "2.0" -#define FMI_GUID "123" +#define FMI_GUID "123" #endif /* End of header FMU2_MODEL_DEFINES_H_ */ \ No newline at end of file diff --git a/Test/FMI2/fmu_dummy/fmu2_model_me.c b/Test/FMI2/fmu_dummy/fmu2_model_me.c index 3a3932a2..7bdd6f8c 100644 --- a/Test/FMI2/fmu_dummy/fmu2_model_me.c +++ b/Test/FMI2/fmu_dummy/fmu2_model_me.c @@ -34,12 +34,12 @@ along with this program. If not, contact Modelon AB . /* FMI 2.0 Common Functions */ FMI2_Export const char* fmi2GetVersion() { - return fmi_get_version(); + return fmi_get_version(); } FMI2_Export fmi2Status fmi2SetDebugLogging(fmi2Component c, fmi2Boolean loggingOn, size_t n , const fmi2String cat[]) { - return fmi_set_debug_logging(c, loggingOn); + return fmi_set_debug_logging(c, loggingOn); } FMI2_Export fmi2Component fmi2Instantiate(fmi2String instanceName, @@ -53,7 +53,7 @@ FMI2_Export fmi2Component fmi2Instantiate(fmi2String instanceName, FMI2_Export void fmi2FreeInstance(fmi2Component c) { - fmi_free_instance(c); + fmi_free_instance(c); } FMI2_Export fmi2Status fmi2SetupExperiment(fmi2Component c, @@ -77,48 +77,48 @@ FMI2_Export fmi2Status fmi2ExitInitializationMode(fmi2Component c) FMI2_Export fmi2Status fmi2GetReal(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[]) { - return fmi_get_real(c, vr, nvr, value); + return fmi_get_real(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2GetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[]) { - return fmi_get_integer(c, vr, nvr, value); + return fmi_get_integer(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2GetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[]) { - return fmi_get_boolean(c, vr, nvr, value); + return fmi_get_boolean(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2GetString(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[]) { - return fmi_get_string(c, vr, nvr, value); + return fmi_get_string(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetReal(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[]) { - return fmi_set_real(c, vr, nvr, value); + return fmi_set_real(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[]) { - return fmi_set_integer(c, vr, nvr, value); + return fmi_set_integer(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[]) { - return fmi_set_boolean(c, vr, nvr, value); + return fmi_set_boolean(c, vr, nvr, value); } FMI2_Export fmi2Status fmi2SetString(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[]) { - return fmi_set_string(c, vr, nvr, value); + return fmi_set_string(c, vr, nvr, value); } /* FMI 2.0 ME Functions */ FMI2_Export const char* fmi2GetTypesPlatform() { - return fmi_get_model_types_platform(); + return fmi_get_model_types_platform(); } FMI2_Export fmi2Status fmi2EnterEventMode(fmi2Component c) @@ -138,12 +138,12 @@ FMI2_Export fmi2Status fmi2EnterContinuousTimeMode(fmi2Component c) FMI2_Export fmi2Status fmi2SetTime(fmi2Component c, fmi2Real fmitime) { - return fmi_set_time(c, fmitime); + return fmi_set_time(c, fmitime); } FMI2_Export fmi2Status fmi2SetContinuousStates(fmi2Component c, const fmi2Real x[], size_t nx) { - return fmi_set_continuous_states(c, x, nx); + return fmi_set_continuous_states(c, x, nx); } FMI2_Export fmi2Status fmi2CompletedIntegratorStep(fmi2Component c, @@ -156,30 +156,30 @@ FMI2_Export fmi2Status fmi2CompletedIntegratorStep(fmi2Component c, FMI2_Export fmi2Status fmi2GetDerivatives(fmi2Component c, fmi2Real derivatives[] , size_t nx) { - return fmi_get_derivatives(c, derivatives, nx); + return fmi_get_derivatives(c, derivatives, nx); } FMI2_Export fmi2Status fmi2GetEventIndicators(fmi2Component c, fmi2Real eventIndicators[], size_t ni) { - return fmi_get_event_indicators(c, eventIndicators, ni); + return fmi_get_event_indicators(c, eventIndicators, ni); } FMI2_Export fmi2Status fmi2GetContinuousStates(fmi2Component c, fmi2Real states[], size_t nx) { - return fmi_get_continuous_states(c, states, nx); + return fmi_get_continuous_states(c, states, nx); } FMI2_Export fmi2Status fmi2GetNominalsOfContinuousStates(fmi2Component c, fmi2Real x_nominal[], size_t nx) { - return fmi_get_nominals_of_continuousstates(c, x_nominal, nx); + return fmi_get_nominals_of_continuousstates(c, x_nominal, nx); } FMI2_Export fmi2Status fmi2Terminate(fmi2Component c) { - return fmi_terminate(c); + return fmi_terminate(c); } FMI2_Export fmi2Status fmi2Reset(fmi2Component c) { - return fmi_reset(c); + return fmi_reset(c); } diff --git a/Test/FMI3/fmu_dummy/fmu3_model_defines.h b/Test/FMI3/fmu_dummy/fmu3_model_defines.h index 19eefc2d..769ae1dc 100644 --- a/Test/FMI3/fmu_dummy/fmu3_model_defines.h +++ b/Test/FMI3/fmu_dummy/fmu3_model_defines.h @@ -20,45 +20,45 @@ along with this program. If not, contact Modelon AB . #include "FMI3/fmi3PlatformTypes.h" -/*#define STRINGIFY(a) #a -#define STRINGIFY2(a) STRINGIFY(a) -#define MODEL_IDENTIFIER_STR STRINGIFY2(MODEL_IDENTIFIER) */ +/*#define STRINGIFY(a) #a +#define STRINGIFY2(a) STRINGIFY(a) +#define MODEL_IDENTIFIER_STR STRINGIFY2(MODEL_IDENTIFIER) */ -#define BUFFER 1024 -#define MAGIC_TEST_VALUE 13.0 /* A test value for some functions */ +#define BUFFER 1024 +#define MAGIC_TEST_VALUE 13.0 /* A test value for some functions */ /* BouncingBall model with redundant values */ /* ValueReferences for the variables and parameters in the model */ /* States */ -#define VAR_R_HEIGHT 0 -#define VAR_R_HEIGHT_SPEED 1 +#define VAR_R_HEIGHT 0 +#define VAR_R_HEIGHT_SPEED 1 /* Real */ -#define VAR_R_GRATIVY 2 -#define VAR_R_BOUNCE_CONF 3 +#define VAR_R_GRATIVY 2 +#define VAR_R_BOUNCE_CONF 3 /* Event indicators */ -#define EVENT_HEIGHT 0 +#define EVENT_HEIGHT 0 /* Event indicators */ -#define VAR_S_LOGGER_TEST 0 +#define VAR_S_LOGGER_TEST 0 /* Sizes */ -#define N_STATES 2 -#define N_EVENT_INDICATORS 1 -#define N_REAL 4 -#define N_INTEGER 4 -#define N_BOOLEAN 4 -#define N_STRING 4 -#define N_BINARY 1 +#define N_STATES 2 +#define N_EVENT_INDICATORS 1 +#define N_REAL 4 +#define N_INTEGER 4 +#define N_BOOLEAN 4 +#define N_STRING 4 +#define N_BINARY 1 -#define N_INPUT_REAL 2 /* CS only */ -#define N_INPUT_REAL_MAX_ORDER 2 /* CS only */ -#define N_OUTPUT_REAL 2 /* CS only */ -#define N_OUTPUT_REAL_MAX_ORDER 2 /* CS only */ +#define N_INPUT_REAL 2 /* CS only */ +#define N_INPUT_REAL_MAX_ORDER 2 /* CS only */ +#define N_OUTPUT_REAL 2 /* CS only */ +#define N_OUTPUT_REAL_MAX_ORDER 2 /* CS only */ -#define FMI_VERSION "3.0" +#define FMI_VERSION "3.0" -#define FMI_INSTANTIATION_TOKEN "123" +#define FMI_INSTANTIATION_TOKEN "123" #endif /* End of header FMU3_MODEL_DEFINES_H_ */ diff --git a/Test/compress_test_fmu_zip.c b/Test/compress_test_fmu_zip.c index 3c89a741..195ef2e9 100644 --- a/Test/compress_test_fmu_zip.c +++ b/Test/compress_test_fmu_zip.c @@ -26,42 +26,42 @@ static void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t l int main(int argc, char *argv[]) { - jm_status_enu_t status; - jm_callbacks callbacks; - char* output_name; - const char** files_to_zip; - int i, n_files_to_zip; + jm_status_enu_t status; + jm_callbacks callbacks; + char* output_name; + const char** files_to_zip; + int i, n_files_to_zip; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_warning; + callbacks.log_level = jm_log_level_warning; callbacks.context = 0; - if (argc < 3) { - printf("Not enought input arguments\n"); - return 1; - } + if (argc < 3) { + printf("Not enought input arguments\n"); + return 1; + } - output_name = argv[1]; - files_to_zip = (const char**)&argv[2]; - n_files_to_zip = argc - 2; + output_name = argv[1]; + files_to_zip = (const char**)&argv[2]; + n_files_to_zip = argc - 2; - printf("Will compress following files: \n"); - for (i = 0; i < n_files_to_zip; i++) { - printf( "\t%s\n", files_to_zip[i]); - } - status = fmi_zip_zip(output_name, n_files_to_zip, files_to_zip, &callbacks); + printf("Will compress following files: \n"); + for (i = 0; i < n_files_to_zip; i++) { + printf( "\t%s\n", files_to_zip[i]); + } + status = fmi_zip_zip(output_name, n_files_to_zip, files_to_zip, &callbacks); + + if (status == jm_status_error) { + printf("Failed to compress the file\n"); + return 1; + } else { + printf("Succesfully compressed the file\n"); + return 0; + } - if (status == jm_status_error) { - printf("Failed to compress the file\n"); - return 1; - } else { - printf("Succesfully compressed the file\n"); - return 0; - } - } diff --git a/Test/fmi_import_test.c b/Test/fmi_import_test.c index abcb2e89..df97bd30 100644 --- a/Test/fmi_import_test.c +++ b/Test/fmi_import_test.c @@ -33,44 +33,44 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve void do_exit(int code) { - printf("Press 'Enter' to exit\n"); - /* getchar(); */ - exit(code); + printf("Press 'Enter' to exit\n"); + /* getchar(); */ + exit(code); } - + int main(int argc, char *argv[]) { - const char* FMUPath; - const char* tmpPath; - jm_callbacks callbacks; - fmi_import_context_t* context; - fmi_version_enu_t version; - int ret; - - if(argc < 3) { - printf("Usage: %s \n", argv[0]); - do_exit(CTEST_RETURN_FAIL); - } + const char* FMUPath; + const char* tmpPath; + jm_callbacks callbacks; + fmi_import_context_t* context; + fmi_version_enu_t version; + int ret; + + if(argc < 3) { + printf("Usage: %s \n", argv[0]); + do_exit(CTEST_RETURN_FAIL); + } - FMUPath = argv[1]; - tmpPath = argv[2]; + FMUPath = argv[1]; + tmpPath = argv[2]; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_all; + callbacks.log_level = jm_log_level_all; callbacks.context = 0; #ifdef FMILIB_GENERATE_BUILD_STAMP - printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); + printf("Library build stamp:\n%s\n", fmilib_get_build_stamp()); #endif - context = fmi_import_allocate_context(&callbacks); + context = fmi_import_allocate_context(&callbacks); - version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); + version = fmi_import_get_fmi_version(context, FMUPath, tmpPath); /* Check that version can be retrieved from unzipped FMU: */ if (version != fmi_import_get_fmi_version(context, NULL, tmpPath)) { @@ -78,29 +78,29 @@ int main(int argc, char *argv[]) do_exit(CTEST_RETURN_FAIL); } - if(version == fmi_version_1_enu) { - ret = fmi1_test(context, tmpPath); - } - else if(version == fmi_version_2_0_enu) { - ret = fmi2_test(context, tmpPath); - } - else if(version == fmi_version_3_0_enu) { - ret = fmi3_test(context, tmpPath); - } - else { + if(version == fmi_version_1_enu) { + ret = fmi1_test(context, tmpPath); + } + else if(version == fmi_version_2_0_enu) { + ret = fmi2_test(context, tmpPath); + } + else if(version == fmi_version_3_0_enu) { + ret = fmi3_test(context, tmpPath); + } + else { fmi_import_free_context(context); - printf("Only versions 1.0 and 2.0 are supported so far\n"); - do_exit(CTEST_RETURN_FAIL); - } + printf("Only versions 1.0 and 2.0 are supported so far\n"); + do_exit(CTEST_RETURN_FAIL); + } - fmi_import_free_context(context); - - if(ret == CTEST_RETURN_SUCCESS) - printf("Everything seems to be OK since you got this far=)!\n"); + fmi_import_free_context(context); + + if(ret == CTEST_RETURN_SUCCESS) + printf("Everything seems to be OK since you got this far=)!\n"); - do_exit(ret); + do_exit(ret); - return 0; + return 0; } diff --git a/Test/fmi_zip_unzip_test.c b/Test/fmi_zip_unzip_test.c index 7d46ee2a..f5c13fb6 100644 --- a/Test/fmi_zip_unzip_test.c +++ b/Test/fmi_zip_unzip_test.c @@ -27,9 +27,9 @@ void do_exit(int code) { - printf("Press any key to exit\n"); - /* getchar(); */ - exit(code); + printf("Press any key to exit\n"); + /* getchar(); */ + exit(code); } /* Logger function */ @@ -44,26 +44,26 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve */ int main(int argc, char *argv[]) { - jm_callbacks callbacks; - jm_status_enu_t status; + jm_callbacks callbacks; + jm_status_enu_t status; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; - status = fmi_zip_unzip(UNCOMPRESSED_DUMMY_FILE_PATH_SRC, UNCOMPRESSED_DUMMY_FOLDER_PATH_DIST, &callbacks); + status = fmi_zip_unzip(UNCOMPRESSED_DUMMY_FILE_PATH_SRC, UNCOMPRESSED_DUMMY_FOLDER_PATH_DIST, &callbacks); - if (status == jm_status_error) { - printf("Failed to uncompress the file\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("Succesfully uncompressed the file\n"); - do_exit(CTEST_RETURN_SUCCESS); - } + if (status == jm_status_error) { + printf("Failed to uncompress the file\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("Succesfully uncompressed the file\n"); + do_exit(CTEST_RETURN_SUCCESS); + } } diff --git a/Test/fmi_zip_zip_test.c b/Test/fmi_zip_zip_test.c index a5567e92..9d3e97cc 100644 --- a/Test/fmi_zip_zip_test.c +++ b/Test/fmi_zip_zip_test.c @@ -27,9 +27,9 @@ void do_exit(int code) { - printf("Press any key to exit\n"); - /* getchar(); */ - exit(code); + printf("Press any key to exit\n"); + /* getchar(); */ + exit(code); } /* Logger function */ @@ -44,30 +44,30 @@ void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_leve */ int main(int argc, char *argv[]) { - jm_status_enu_t status; - jm_callbacks callbacks; - - const char* files_to_zip[] = {COMPRESS_DUMMY_FILE_PATH_SRC}; - int n_files_to_zip = 1; + jm_status_enu_t status; + jm_callbacks callbacks; + + const char* files_to_zip[] = {COMPRESS_DUMMY_FILE_PATH_SRC}; + int n_files_to_zip = 1; - callbacks.malloc = malloc; + callbacks.malloc = malloc; callbacks.calloc = calloc; callbacks.realloc = realloc; callbacks.free = free; callbacks.logger = importlogger; - callbacks.log_level = jm_log_level_debug; + callbacks.log_level = jm_log_level_debug; callbacks.context = 0; - status = fmi_zip_zip(COMPRESS_DUMMY_FILE_PATH_DIST, n_files_to_zip, files_to_zip, &callbacks); + status = fmi_zip_zip(COMPRESS_DUMMY_FILE_PATH_DIST, n_files_to_zip, files_to_zip, &callbacks); - if (status == jm_status_error) { - printf("Failed to compress the file\n"); - do_exit(CTEST_RETURN_FAIL); - } else { - printf("Succesfully compressed the file\n"); - do_exit(CTEST_RETURN_SUCCESS); - } + if (status == jm_status_error) { + printf("Failed to compress the file\n"); + do_exit(CTEST_RETURN_FAIL); + } else { + printf("Succesfully compressed the file\n"); + do_exit(CTEST_RETURN_SUCCESS); + } } diff --git a/Test/jm_vector_test.c b/Test/jm_vector_test.c index ef0945b0..62a91c43 100644 --- a/Test/jm_vector_test.c +++ b/Test/jm_vector_test.c @@ -21,11 +21,11 @@ int compar_int(int* a, int* b) { int return_code = CTEST_RETURN_SUCCESS; void log_error(const char* fmt, ...) { - va_list args; + va_list args; va_start (args, fmt); vprintf(fmt, args); va_end (args); - return_code = CTEST_RETURN_FAIL; + return_code = CTEST_RETURN_FAIL; } #define TESTVAL 49 @@ -44,20 +44,20 @@ int main() { jm_vector_set_item(int)(v, 2, TESTVAL); for( i = 0; i < 32; i++) { int x = i+TESTVAL; - int top; + int top; jm_vector_push_back(int)(v,x); jm_stack_push(double)(s,x); - top = (int)jm_stack_top(double)(s); + top = (int)jm_stack_top(double)(s); printf("pushed item %d=%d (stack top %g), vector size: %u, capacity: %u\n", i, x, jm_stack_top(double)(s), (unsigned)jm_vector_get_size(int)(v), (unsigned)jm_vector_reserve(int)(v,0)); - if(top != x) log_error("Stack top does not match the pushed value \n"); - if(jm_vector_get_size(int)(v) != VINIT_SIZE+i+1) log_error("Vector size %d is not as expected %d\n", jm_vector_get_size(int)(v), VINIT_SIZE+i+1); + if(top != x) log_error("Stack top does not match the pushed value \n"); + if(jm_vector_get_size(int)(v) != VINIT_SIZE+i+1) log_error("Vector size %d is not as expected %d\n", jm_vector_get_size(int)(v), VINIT_SIZE+i+1); + } + { + size_t index = jm_vector_find_index(int)(v, &k,jm_compare_int); + k = TESTVAL; + if( index != 2) log_error("Index of '%d' should be '2' but got %d\n", TESTVAL, k ); } - { - size_t index = jm_vector_find_index(int)(v, &k,jm_compare_int); - k = TESTVAL; - if( index != 2) log_error("Index of '%d' should be '2' but got %d\n", TESTVAL, k ); - } for( i = 0; i < 22; i++) { jm_stack_pop(double)(s); } diff --git a/Test/main.cpp b/Test/main.cpp deleted file mode 100644 index 063e8787..00000000 --- a/Test/main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include "catch.hpp" \ No newline at end of file diff --git a/src/CAPI/include/FMI1/fmi1_capi.h b/src/CAPI/include/FMI1/fmi1_capi.h index 287ba889..5cb88c76 100644 --- a/src/CAPI/include/FMI1/fmi1_capi.h +++ b/src/CAPI/include/FMI1/fmi1_capi.h @@ -1,383 +1,383 @@ -/* - Copyright (C) 2012 Modelon AB - - This program is free software: you can redistribute it and/or modify - it under the terms of the BSD style license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - FMILIB_License.txt file for more details. - - You should have received a copy of the FMILIB_License.txt file - along with this program. If not, contact Modelon AB . -*/ - - -#ifndef FMI1_CAPI_H_ -#define FMI1_CAPI_H_ - -#include -#include -#include -#include -#include - -typedef struct fmi1_capi_t fmi1_capi_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file fmi1_capi.h - \brief Public interfaces for the FMI CAPI library. - */ - +/* + Copyright (C) 2012 Modelon AB + + This program is free software: you can redistribute it and/or modify + it under the terms of the BSD style license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + FMILIB_License.txt file for more details. + + You should have received a copy of the FMILIB_License.txt file + along with this program. If not, contact Modelon AB . +*/ + + +#ifndef FMI1_CAPI_H_ +#define FMI1_CAPI_H_ + +#include +#include +#include +#include +#include + +typedef struct fmi1_capi_t fmi1_capi_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file fmi1_capi.h + \brief Public interfaces for the FMI CAPI library. +*/ + /** \addtogroup fmi1_capi Standard FMI 1.0 "C" API * \brief The "C" API loads and frees the FMI functions and it is through theise functions all the communcation with the FMU occures. The FMI import library wrappes these functions in a more convenient way. * @{ - */ - -/** \addtogroup fmi1_capi_const_destroy FMI 1.0 Utility functions - * \brief Utility functions used to load and free the FMI functions. - * \addtogroup fmi1_capi_me FMI 1.0 (ME) Model Exchange functions - * \brief List of Model Exchange wrapper functions. Common functions are not listed. - * \addtogroup fmi1_capi_cs FMI 1.0 (CS) Co-Simulation functions - * \brief List of Co-Simulation wrapper functions. Common functions are not listed. - * \addtogroup fmi1_capi_common FMI 1.0 (ME & CS) Common functions - * \brief List of wrapper functions that are in common for both Model Exchange and Co-Simulation. - */ - - + */ + +/** \addtogroup fmi1_capi_const_destroy FMI 1.0 Utility functions + * \brief Utility functions used to load and free the FMI functions. + * \addtogroup fmi1_capi_me FMI 1.0 (ME) Model Exchange functions + * \brief List of Model Exchange wrapper functions. Common functions are not listed. + * \addtogroup fmi1_capi_cs FMI 1.0 (CS) Co-Simulation functions +* \brief List of Co-Simulation wrapper functions. Common functions are not listed. + * \addtogroup fmi1_capi_common FMI 1.0 (ME & CS) Common functions + * \brief List of wrapper functions that are in common for both Model Exchange and Co-Simulation. + */ + + /** \addtogroup fmi1_capi_const_destroy * @{ - */ - + */ + /** * \brief Free a C-API struct. All memory allocated since the struct was created is freed. - * + * * @param fmu A model description object returned by fmi1_import_allocate. - */ -void fmi1_capi_destroy_dllfmu(fmi1_capi_t* fmu); - + */ +void fmi1_capi_destroy_dllfmu(fmi1_capi_t* fmu); + /** * \brief Create a C-API struct. The C-API struct is a placeholder for the FMI DLL functions. - * + * * @param callbacks ::jm_callbacks used to construct library objects. * @param dllPath Full path to the FMU shared library. * @param modelIdentifier The model indentifier. * @param standard FMI standard that the function should load. * @param callBackFunctions callbacks passed to the FMU. * @return Error status. If the function returns with an error, it is not allowed to call any of the other C-API functions. - */ -fmi1_capi_t* fmi1_capi_create_dllfmu(jm_callbacks* callbacks, const char* dllPath, const char* modelIdentifier, fmi1_callback_functions_t callBackFunctions, fmi1_fmu_kind_enu_t standard); - + */ +fmi1_capi_t* fmi1_capi_create_dllfmu(jm_callbacks* callbacks, const char* dllPath, const char* modelIdentifier, fmi1_callback_functions_t callBackFunctions, fmi1_fmu_kind_enu_t standard); + /** * \brief Loads the FMI functions from the shared library. The shared library must be loaded before this function can be called, see fmi1_import_create_dllfmu(). - * + * * @param fmu A model description object returned by fmi1_import_allocate. * @return Error status. If the function returns with an error, no other C-API functions than fmi1_import_free_dll and fmi1_import_destroy_dllfmu are allowed to be called. - */ -jm_status_enu_t fmi1_capi_load_fcn(fmi1_capi_t* fmu); - + */ +jm_status_enu_t fmi1_capi_load_fcn(fmi1_capi_t* fmu); + /** - * \brief Loads the FMUs shared library. The shared library functions are not loaded in this call, see fmi1_import_create_dllfmu. - * + * \brief Loads the FMU�s shared library. The shared library functions are not loaded in this call, see fmi1_import_create_dllfmu. + * * @param fmu A model description object returned by fmi1_import_allocate. * @return Error status. If the function returns with an error, no other C-API functions than fmi1_import_destroy_dllfmu are allowed to be called. - */ -jm_status_enu_t fmi1_capi_load_dll(fmi1_capi_t* fmu); - + */ +jm_status_enu_t fmi1_capi_load_dll(fmi1_capi_t* fmu); + /** - * \brief Frees the handle to the FMUs shared library. After this function returnes, no other C-API functions than fmi1_import_destroy_dllfmu and fmi1_import_create_dllfmu are allowed to be called. - * - * @param fmu A model description object returned by fmi1_import_allocate that has loaded the FMUs shared library, see fmi1_import_load_dll. + * \brief Frees the handle to the FMU�s shared library. After this function returnes, no other C-API functions than fmi1_import_destroy_dllfmu and fmi1_import_create_dllfmu are allowed to be called. + * + * @param fmu A model description object returned by fmi1_import_allocate that has loaded the FMU�s shared library, see fmi1_import_load_dll. * @return Error status. - */ -jm_status_enu_t fmi1_capi_free_dll(fmi1_capi_t* fmu); - + */ +jm_status_enu_t fmi1_capi_free_dll(fmi1_capi_t* fmu); + /** * \brief Set CAPI debug mode flag. Setting to non-zero prevents DLL unloading in fmi1_capi_free_dll - * while all the memory is deallocated. This is to support valgrind debugging. - * + * while all the memory is deallocated. This is to support valgrind debugging. + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param mode The debug mode to set. */ -void fmi1_capi_set_debug_mode(fmi1_capi_t* fmu, int mode); - +void fmi1_capi_set_debug_mode(fmi1_capi_t* fmu, int mode); + /** * \brief Get CAPI debug mode flag that was set with fmi1_capi_set_debug_mode() - * + * * @param fmu C-API struct that has succesfully loaded the FMI function. */ -int fmi1_capi_get_debug_mode(fmi1_capi_t* fmu); - - -/**@} */ - +int fmi1_capi_get_debug_mode(fmi1_capi_t* fmu); + + +/**@} */ + /** \addtogroup fmi1_capi_common * @{ - */ - + */ + /** - * \brief Calls the FMI function fmiGetVersion() - * + * \brief Calls the FMI function fmiGetVersion() + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @return FMI version. - */ -const char* fmi1_capi_get_version(fmi1_capi_t* fmu); - + */ +const char* fmi1_capi_get_version(fmi1_capi_t* fmu); + /** - * \brief Calls the FMI function fmiSetDebugLogging(...) - * + * \brief Calls the FMI function fmiSetDebugLogging(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param loggingOn Enable or disable the debug logger. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_debug_logging(fmi1_capi_t* fmu, fmi1_boolean_t loggingOn); - + */ +fmi1_status_t fmi1_capi_set_debug_logging(fmi1_capi_t* fmu, fmi1_boolean_t loggingOn); + /** - * \brief Calls the FMI function fmiSetReal(...) - * + * \brief Calls the FMI function fmiSetReal(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_real(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_real_t value[]); - + */ +fmi1_status_t fmi1_capi_set_real(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_real_t value[]); + /** - * \brief Calls the FMI function fmiSetInteger(...) - * + * \brief Calls the FMI function fmiSetInteger(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_integer(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t value[]); - + */ +fmi1_status_t fmi1_capi_set_integer(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t value[]); + /** - * \brief Calls the FMI function fmiSetBoolean(...) - * + * \brief Calls the FMI function fmiSetBoolean(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_boolean(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_boolean_t value[]); - + */ +fmi1_status_t fmi1_capi_set_boolean(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_boolean_t value[]); + /** - * \brief Calls the FMI function fmiSetString(...) - * + * \brief Calls the FMI function fmiSetString(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_string(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_string_t value[]); - + */ +fmi1_status_t fmi1_capi_set_string(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_string_t value[]); + /** - * \brief Calls the FMI function fmiGetReal(...) - * + * \brief Calls the FMI function fmiGetReal(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value (Output)Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_real(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_real_t value[]); - + */ +fmi1_status_t fmi1_capi_get_real(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_real_t value[]); + /** - * \brief Calls the FMI function fmiGetInteger(...) - * + * \brief Calls the FMI function fmiGetInteger(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value (Output)Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_integer(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_integer_t value[]); - + */ +fmi1_status_t fmi1_capi_get_integer(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_integer_t value[]); + /** - * \brief Calls the FMI function fmiGetBoolean(...) - * + * \brief Calls the FMI function fmiGetBoolean(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value (Output)Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_boolean(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_boolean_t value[]); - + */ +fmi1_status_t fmi1_capi_get_boolean(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_boolean_t value[]); + /** - * \brief Calls the FMI function fmiGetString(...) - * + * \brief Calls the FMI function fmiGetString(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. * @param value (Output)Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_string(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_string_t value[]); - -/**@} */ - + */ +fmi1_status_t fmi1_capi_get_string(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_string_t value[]); + +/**@} */ + /** \addtogroup fmi1_capi_me * @{ - */ - + */ + /** - * \brief Calls the FMI function fmiGetModelTypesPlatform(...) - * + * \brief Calls the FMI function fmiGetModelTypesPlatform(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @return The platform the FMU was compiled for. - */ -const char* fmi1_capi_get_model_types_platform(fmi1_capi_t* fmu); - + */ +const char* fmi1_capi_get_model_types_platform(fmi1_capi_t* fmu); + /** - * \brief Calls the FMI function fmiInstantiateModel(...) - * + * \brief Calls the FMI function fmiInstantiateModel(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param instanceName The name of the instance. * @param GUID The GUID identifier. * @param loggingOn Enable or disable the debug logger. * @return An instance of a model. - */ -fmi1_component_t fmi1_capi_instantiate_model(fmi1_capi_t* fmu, fmi1_string_t instanceName, fmi1_string_t GUID, fmi1_boolean_t loggingOn); - + */ +fmi1_component_t fmi1_capi_instantiate_model(fmi1_capi_t* fmu, fmi1_string_t instanceName, fmi1_string_t GUID, fmi1_boolean_t loggingOn); + /** - * \brief Calls the FMI function fmiFreeModelInstance(...) - * + * \brief Calls the FMI function fmiFreeModelInstance(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. - */ -void fmi1_capi_free_model_instance(fmi1_capi_t* fmu); - + */ +void fmi1_capi_free_model_instance(fmi1_capi_t* fmu); + /** - * \brief Calls the FMI function fmiSetTime(...) - * + * \brief Calls the FMI function fmiSetTime(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param time Set the current time. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_time(fmi1_capi_t* fmu, fmi1_real_t time); - + */ +fmi1_status_t fmi1_capi_set_time(fmi1_capi_t* fmu, fmi1_real_t time); + /** - * \brief Calls the FMI function fmiSetContinuousStates(...) - * + * \brief Calls the FMI function fmiSetContinuousStates(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param x Array of state values. * @param nx Number of states. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_continuous_states(fmi1_capi_t* fmu, const fmi1_real_t x[], size_t nx); - + */ +fmi1_status_t fmi1_capi_set_continuous_states(fmi1_capi_t* fmu, const fmi1_real_t x[], size_t nx); + /** - * \brief Calls the FMI function fmiCompletedIntegratorStep(...) - * + * \brief Calls the FMI function fmiCompletedIntegratorStep(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param callEventUpdate (Output) Call fmiEventUpdate indicator. * @return FMI status. - */ -fmi1_status_t fmi1_capi_completed_integrator_step(fmi1_capi_t* fmu, fmi1_boolean_t* callEventUpdate); - + */ +fmi1_status_t fmi1_capi_completed_integrator_step(fmi1_capi_t* fmu, fmi1_boolean_t* callEventUpdate); + /** - * \brief Calls the FMI function fmiInitialize(...) - * + * \brief Calls the FMI function fmiInitialize(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param toleranceControlled Enable or disable the use of relativeTolerance in the FMU. * @param relativeTolerance A relative tolerance used in the FMU. * @param eventInfo (Output) fmiEventInfo struct. * @return FMI status. - */ -fmi1_status_t fmi1_capi_initialize(fmi1_capi_t* fmu, fmi1_boolean_t toleranceControlled, fmi1_real_t relativeTolerance, fmi1_event_info_t* eventInfo); - + */ +fmi1_status_t fmi1_capi_initialize(fmi1_capi_t* fmu, fmi1_boolean_t toleranceControlled, fmi1_real_t relativeTolerance, fmi1_event_info_t* eventInfo); + /** - * \brief Calls the FMI function fmiGetDerivatives(...) - * + * \brief Calls the FMI function fmiGetDerivatives(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param derivatives (Output) Array of the derivatives. * @param nx Number of derivatives. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_derivatives(fmi1_capi_t* fmu, fmi1_real_t derivatives[] , size_t nx); - + */ +fmi1_status_t fmi1_capi_get_derivatives(fmi1_capi_t* fmu, fmi1_real_t derivatives[] , size_t nx); + /** - * \brief Calls the FMI function fmiGetEventIndicators(...) - * + * \brief Calls the FMI function fmiGetEventIndicators(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param eventIndicators (Output) The event indicators. * @param ni Number of event indicators. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_event_indicators(fmi1_capi_t* fmu, fmi1_real_t eventIndicators[], size_t ni); - + */ +fmi1_status_t fmi1_capi_get_event_indicators(fmi1_capi_t* fmu, fmi1_real_t eventIndicators[], size_t ni); + /** - * \brief Calls the FMI function fmiEventUpdate(...) - * + * \brief Calls the FMI function fmiEventUpdate(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param intermediateResults Indicate whether or not the fmiEventUpdate shall return after every internal event interation. * @param eventInfo (Output) An fmiEventInfo struct. * @return FMI status. - */ -fmi1_status_t fmi1_capi_eventUpdate(fmi1_capi_t* fmu, fmi1_boolean_t intermediateResults, fmi1_event_info_t* eventInfo); - + */ +fmi1_status_t fmi1_capi_eventUpdate(fmi1_capi_t* fmu, fmi1_boolean_t intermediateResults, fmi1_event_info_t* eventInfo); + /** - * \brief Calls the FMI function fmiGetContinuousStates(...) - * + * \brief Calls the FMI function fmiGetContinuousStates(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param states (Output) Array of state values. * @param nx Number of states. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_continuous_states(fmi1_capi_t* fmu, fmi1_real_t states[], size_t nx); - + */ +fmi1_status_t fmi1_capi_get_continuous_states(fmi1_capi_t* fmu, fmi1_real_t states[], size_t nx); + /** - * \brief Calls the FMI function fmiGetNominalContinuousStates(...) - * + * \brief Calls the FMI function fmiGetNominalContinuousStates(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param x_nominal (Output) The nominal values. * @param nx Number of nominal values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_nominal_continuous_states(fmi1_capi_t* fmu, fmi1_real_t x_nominal[], size_t nx); - + */ +fmi1_status_t fmi1_capi_get_nominal_continuous_states(fmi1_capi_t* fmu, fmi1_real_t x_nominal[], size_t nx); + /** - * \brief Calls the FMI function fmiGetStateValueReferences(...) - * + * \brief Calls the FMI function fmiGetStateValueReferences(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vrx (Output) The value-references of the states. * @param nx Number of value-references. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_state_value_references(fmi1_capi_t* fmu, fmi1_value_reference_t vrx[], size_t nx); - + */ +fmi1_status_t fmi1_capi_get_state_value_references(fmi1_capi_t* fmu, fmi1_value_reference_t vrx[], size_t nx); + /** - * \brief Calls the FMI function fmiTerminate(...) - * + * \brief Calls the FMI function fmiTerminate(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @return FMI status. - */ -fmi1_status_t fmi1_capi_terminate(fmi1_capi_t* fmu); - -/**@} */ - + */ +fmi1_status_t fmi1_capi_terminate(fmi1_capi_t* fmu); + +/**@} */ + /** \addtogroup fmi1_capi_cs * @{ - */ - + */ + /** - * \brief Calls the FMI function fmiGetTypesPlatform(...) - * + * \brief Calls the FMI function fmiGetTypesPlatform(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @return The platform the FMU was compiled for. - */ -const char* fmi1_capi_get_types_platform(fmi1_capi_t* fmu); + */ +const char* fmi1_capi_get_types_platform(fmi1_capi_t* fmu); /** - * \brief Calls the FMI function fmiInstantiateSlave(...) - * + * \brief Calls the FMI function fmiInstantiateSlave(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param instanceName The name of the instance. * @param fmuGUID The GUID identifier. @@ -388,141 +388,141 @@ const char* fmi1_capi_get_types_platform(fmi1_capi_t* fmu); * @param interactive Indicates whether the simulator application must be manually started by the user. * @param loggingOn Enable or disable the debug logger. * @return An instance of a model. - */ -fmi1_component_t fmi1_capi_instantiate_slave(fmi1_capi_t* fmu, fmi1_string_t instanceName, fmi1_string_t fmuGUID, fmi1_string_t fmuLocation, fmi1_string_t mimeType, - fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive, fmi1_boolean_t loggingOn); + */ +fmi1_component_t fmi1_capi_instantiate_slave(fmi1_capi_t* fmu, fmi1_string_t instanceName, fmi1_string_t fmuGUID, fmi1_string_t fmuLocation, fmi1_string_t mimeType, + fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive, fmi1_boolean_t loggingOn); /** - * \brief Calls the FMI function fmiInitializeSlave(...) - * + * \brief Calls the FMI function fmiInitializeSlave(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param tStart Start time of the simulation * @param StopTimeDefined Indicates whether or not the stop time is used. * @param tStop The stop time of the simulation. * @return FMI status. - */ -fmi1_status_t fmi1_capi_initialize_slave(fmi1_capi_t* fmu, fmi1_real_t tStart, fmi1_boolean_t StopTimeDefined, fmi1_real_t tStop); - + */ +fmi1_status_t fmi1_capi_initialize_slave(fmi1_capi_t* fmu, fmi1_real_t tStart, fmi1_boolean_t StopTimeDefined, fmi1_real_t tStop); + /** - * \brief Calls the FMI function fmiTerminateSlave(...) - * + * \brief Calls the FMI function fmiTerminateSlave(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @return FMI status. - */ -fmi1_status_t fmi1_capi_terminate_slave(fmi1_capi_t* fmu); - + */ +fmi1_status_t fmi1_capi_terminate_slave(fmi1_capi_t* fmu); + /** - * \brief Calls the FMI function fmiResetSlave(...) - * + * \brief Calls the FMI function fmiResetSlave(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @return FMI status. - */ -fmi1_status_t fmi1_capi_reset_slave(fmi1_capi_t* fmu); - + */ +fmi1_status_t fmi1_capi_reset_slave(fmi1_capi_t* fmu); + /** - * \brief Calls the FMI function fmiFreeSlaveInstance(...) - * + * \brief Calls the FMI function fmiFreeSlaveInstance(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. - */ -void fmi1_capi_free_slave_instance(fmi1_capi_t* fmu); - + */ +void fmi1_capi_free_slave_instance(fmi1_capi_t* fmu); + /** - * \brief Calls the FMI function fmiSetRealInputDerivatives(...) - * + * \brief Calls the FMI function fmiSetRealInputDerivatives(...) + * * @param fmu C-API struct that has succesfully load the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. - * @param order Array of derivative orders. + * @param order Array of derivative orders. * @param value Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_set_real_input_derivatives(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], const fmi1_real_t value[]); - + */ +fmi1_status_t fmi1_capi_set_real_input_derivatives(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], const fmi1_real_t value[]); + /** - * \brief Calls the FMI function fmiGetOutputDerivatives(...) - * + * \brief Calls the FMI function fmiGetOutputDerivatives(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param vr Array of value references. * @param nvr Number of array elements. - * @param order Array of derivative orders. + * @param order Array of derivative orders. * @param value (Output) Array of variable values. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_real_output_derivatives(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], fmi1_real_t value[]); - + */ +fmi1_status_t fmi1_capi_get_real_output_derivatives(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], fmi1_real_t value[]); + /** - * \brief Calls the FMI function fmiCancelStep(...) - * + * \brief Calls the FMI function fmiCancelStep(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @return FMI status. - */ -fmi1_status_t fmi1_capi_cancel_step(fmi1_capi_t* fmu); - + */ +fmi1_status_t fmi1_capi_cancel_step(fmi1_capi_t* fmu); + /** - * \brief Calls the FMI function fmiDoStep(...) - * + * \brief Calls the FMI function fmiDoStep(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param currentCommunicationPoint Current communication point of the master. * @param communicationStepSize Communication step size. * @param newStep Indicates whether or not the last communication step was accepted by the master. * @return FMI status. - */ -fmi1_status_t fmi1_capi_do_step(fmi1_capi_t* fmu, fmi1_real_t currentCommunicationPoint, fmi1_real_t communicationStepSize, fmi1_boolean_t newStep); - + */ +fmi1_status_t fmi1_capi_do_step(fmi1_capi_t* fmu, fmi1_real_t currentCommunicationPoint, fmi1_real_t communicationStepSize, fmi1_boolean_t newStep); + /** - * \brief Calls the FMI function fmiGetStatus(...) - * + * \brief Calls the FMI function fmiGetStatus(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param s Kind of status to return the value for. * @param value (Output) FMI status value. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_status_t* value); - + */ +fmi1_status_t fmi1_capi_get_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_status_t* value); + /** - * \brief Calls the FMI function fmiGetRealStatus(...) - * + * \brief Calls the FMI function fmiGetRealStatus(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param s Kind of status to return the value for. * @param value (Output) FMI real value. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_real_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_real_t* value); + */ +fmi1_status_t fmi1_capi_get_real_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_real_t* value); /** - * \brief Calls the FMI function fmiGetIntegerStatus(...) - * + * \brief Calls the FMI function fmiGetIntegerStatus(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param s Kind of status to return the value for. * @param value (Output) FMI integer value. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_integer_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_integer_t* value); - + */ +fmi1_status_t fmi1_capi_get_integer_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_integer_t* value); + /** - * \brief Calls the FMI function fmiGetBooleanStatus(...) - * + * \brief Calls the FMI function fmiGetBooleanStatus(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param s Kind of status to return the value for. * @param value (Output) FMI boolean value. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_boolean_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_boolean_t* value); - + */ +fmi1_status_t fmi1_capi_get_boolean_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_boolean_t* value); + /** - * \brief Calls the FMI function fmiGetStringStatus(...) - * + * \brief Calls the FMI function fmiGetStringStatus(...) + * * @param fmu C-API struct that has succesfully loaded the FMI function. * @param s Kind of status to return the value for. * @param value (Output) FMI string value. * @return FMI status. - */ -fmi1_status_t fmi1_capi_get_string_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_string_t* value); - -/** @}*/ -/** @}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* End of header file FMI1_CAPI_H_ */ + */ +fmi1_status_t fmi1_capi_get_string_status(fmi1_capi_t* fmu, const fmi1_status_kind_t s, fmi1_string_t* value); + +/** @}*/ +/** @}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* End of header file FMI1_CAPI_H_ */ diff --git a/src/CAPI/include/FMI3/fmi3_capi.h b/src/CAPI/include/FMI3/fmi3_capi.h index 76e6138b..e596e7ea 100644 --- a/src/CAPI/include/FMI3/fmi3_capi.h +++ b/src/CAPI/include/FMI3/fmi3_capi.h @@ -30,24 +30,24 @@ extern "C" { #endif /** \file fmi3_capi.h - \brief Public interfaces for the FMI CAPI library. - */ + \brief Public interfaces for the FMI CAPI library. + */ /** \addtogroup fmi3_capi Standard FMI 3.0 "C" API * \brief The "C" API loads and frees the FMI functions and it is through these functions all the communication with the FMU occurs. The FMI import library wraps these functions in a more convenient way. * @{ */ -/** \addtogroup fmi3_capi_const_destroy FMI 3.0 Utility functions - * \brief Utility functions used to load and free the FMI functions. - * \addtogroup fmi3_capi_me FMI 3.0 (ME) Model Exchange functions - * \brief List of Model Exchange wrapper functions. Common functions are not listed. - * \addtogroup fmi3_capi_cs FMI 3.0 (CS) Co-Simulation functions - * \brief List of Co-Simulation wrapper functions. Common functions are not listed. - * \addtogroup fmi3_capi_se FMI 3.0 (CS) Scheduled-Execution functions - * \brief List of Scheduled-Execution wrapper functions. Common functions are not listed. - * \addtogroup fmi3_capi_common FMI 3.0 Common functions - * \brief List of wrapper functions that are in common for Model Exchange, Co-Simulation and Scheduled-Execution. +/** \addtogroup fmi3_capi_const_destroy FMI 3.0 Utility functions + * \brief Utility functions used to load and free the FMI functions. + * \addtogroup fmi3_capi_me FMI 3.0 (ME) Model Exchange functions + * \brief List of Model Exchange wrapper functions. Common functions are not listed. + * \addtogroup fmi3_capi_cs FMI 3.0 (CS) Co-Simulation functions + * \brief List of Co-Simulation wrapper functions. Common functions are not listed. + * \addtogroup fmi3_capi_se FMI 3.0 (CS) Scheduled-Execution functions + * \brief List of Scheduled-Execution wrapper functions. Common functions are not listed. + * \addtogroup fmi3_capi_common FMI 3.0 Common functions + * \brief List of wrapper functions that are in common for Model Exchange, Co-Simulation and Scheduled-Execution. */ diff --git a/src/CAPI/src/FMI1/fmi1_capi.c b/src/CAPI/src/FMI1/fmi1_capi.c index f1282e6b..42d5960f 100644 --- a/src/CAPI/src/FMI1/fmi1_capi.c +++ b/src/CAPI/src/FMI1/fmi1_capi.c @@ -28,283 +28,283 @@ extern "C" { #include "FMI/fmi_util_options.h" #include -#define FUNCTION_NAME_LENGTH_MAX 2048 /* Maximum length of FMI function name. Used in the load DLL function. */ +#define FUNCTION_NAME_LENGTH_MAX 2048 /* Maximum length of FMI function name. Used in the load DLL function. */ #define STRINGIFY(str) #str /* Loading shared library functions */ static jm_status_enu_t fmi1_capi_get_fcn(fmi1_capi_t* fmu, const char* function_name, jm_dll_function_ptr* dll_function_ptrptr) { - char fname[FUNCTION_NAME_LENGTH_MAX]; + char fname[FUNCTION_NAME_LENGTH_MAX]; int len; - if (strlen(fmu->modelIdentifier) + strlen(function_name) + 2 > FUNCTION_NAME_LENGTH_MAX) { - jm_log_fatal(fmu->callbacks, FMI_CAPI_MODULE_NAME, "DLL function name is too long. Max name length is set to %s.", STRINGIFY(FUNCTION_NAME_LENGTH_MAX)); - return jm_status_error; - } + if (strlen(fmu->modelIdentifier) + strlen(function_name) + 2 > FUNCTION_NAME_LENGTH_MAX) { + jm_log_fatal(fmu->callbacks, FMI_CAPI_MODULE_NAME, "DLL function name is too long. Max name length is set to %s.", STRINGIFY(FUNCTION_NAME_LENGTH_MAX)); + return jm_status_error; + } - len = jm_snprintf(fname,FUNCTION_NAME_LENGTH_MAX,"%s_%s",fmu->modelIdentifier, function_name); + len = jm_snprintf(fname,FUNCTION_NAME_LENGTH_MAX,"%s_%s",fmu->modelIdentifier, function_name); - return jm_portability_load_dll_function(fmu->dllHandle, fname, dll_function_ptrptr); + return jm_portability_load_dll_function(fmu->dllHandle, fname, dll_function_ptrptr); } /* Load FMI functions from DLL macro */ #define LOAD_DLL_FUNCTION(FMIFUNCTION) if (fmi1_capi_get_fcn(fmu, #FMIFUNCTION, (jm_dll_function_ptr*)&fmu->FMIFUNCTION) == jm_status_error) { \ - jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function '"#FMIFUNCTION"'. %s", jm_portability_get_last_dll_error()); \ - jm_status = jm_status_error; \ + jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function '"#FMIFUNCTION"'. %s", jm_portability_get_last_dll_error()); \ + jm_status = jm_status_error; \ } /* Load FMI 1.0 Co-Simulation functions */ static jm_status_enu_t fmi1_capi_load_cs_fcn(fmi1_capi_t* fmu) { - jm_status_enu_t jm_status = jm_status_success; - - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the co-simulation interface"); - - /* Workaround for Dymola 2012 and SimulationX 3.x */ - if (fmi1_capi_get_fcn(fmu, "fmiGetTypesPlatform",(jm_dll_function_ptr*)&fmu->fmiGetTypesPlatform) == jm_status_error) { - jm_log_warning(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function 'fmiGetTypesPlatform'. %s. Trying to load fmiGetModelTypesPlatform instead.", jm_portability_get_last_dll_error()); - jm_status = jm_status_warning; - if (fmi1_capi_get_fcn(fmu, "fmiGetModelTypesPlatform", (jm_dll_function_ptr*)&fmu->fmiGetTypesPlatform) == jm_status_error) { - jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function 'fmiGetModelTypesPlatform'. %s", jm_portability_get_last_dll_error()); - jm_status = jm_status_error; - } - } - - LOAD_DLL_FUNCTION(fmiInstantiateSlave); - LOAD_DLL_FUNCTION(fmiInitializeSlave); - LOAD_DLL_FUNCTION(fmiTerminateSlave); - LOAD_DLL_FUNCTION(fmiResetSlave); - LOAD_DLL_FUNCTION(fmiFreeSlaveInstance); - LOAD_DLL_FUNCTION(fmiSetRealInputDerivatives); - LOAD_DLL_FUNCTION(fmiGetRealOutputDerivatives); - LOAD_DLL_FUNCTION(fmiCancelStep); - LOAD_DLL_FUNCTION(fmiDoStep); - LOAD_DLL_FUNCTION(fmiGetStatus); - LOAD_DLL_FUNCTION(fmiGetRealStatus); - LOAD_DLL_FUNCTION(fmiGetIntegerStatus); - LOAD_DLL_FUNCTION(fmiGetBooleanStatus); - LOAD_DLL_FUNCTION(fmiGetStringStatus); - - LOAD_DLL_FUNCTION(fmiGetVersion); - LOAD_DLL_FUNCTION(fmiSetDebugLogging); - LOAD_DLL_FUNCTION(fmiSetReal); - LOAD_DLL_FUNCTION(fmiSetInteger); - LOAD_DLL_FUNCTION(fmiSetBoolean); - LOAD_DLL_FUNCTION(fmiSetString); - LOAD_DLL_FUNCTION(fmiGetReal); - LOAD_DLL_FUNCTION(fmiGetInteger); - LOAD_DLL_FUNCTION(fmiGetBoolean); - LOAD_DLL_FUNCTION(fmiGetString); - return jm_status; + jm_status_enu_t jm_status = jm_status_success; + + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the co-simulation interface"); + + /* Workaround for Dymola 2012 and SimulationX 3.x */ + if (fmi1_capi_get_fcn(fmu, "fmiGetTypesPlatform",(jm_dll_function_ptr*)&fmu->fmiGetTypesPlatform) == jm_status_error) { + jm_log_warning(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function 'fmiGetTypesPlatform'. %s. Trying to load fmiGetModelTypesPlatform instead.", jm_portability_get_last_dll_error()); + jm_status = jm_status_warning; + if (fmi1_capi_get_fcn(fmu, "fmiGetModelTypesPlatform", (jm_dll_function_ptr*)&fmu->fmiGetTypesPlatform) == jm_status_error) { + jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function 'fmiGetModelTypesPlatform'. %s", jm_portability_get_last_dll_error()); + jm_status = jm_status_error; + } + } + + LOAD_DLL_FUNCTION(fmiInstantiateSlave); + LOAD_DLL_FUNCTION(fmiInitializeSlave); + LOAD_DLL_FUNCTION(fmiTerminateSlave); + LOAD_DLL_FUNCTION(fmiResetSlave); + LOAD_DLL_FUNCTION(fmiFreeSlaveInstance); + LOAD_DLL_FUNCTION(fmiSetRealInputDerivatives); + LOAD_DLL_FUNCTION(fmiGetRealOutputDerivatives); + LOAD_DLL_FUNCTION(fmiCancelStep); + LOAD_DLL_FUNCTION(fmiDoStep); + LOAD_DLL_FUNCTION(fmiGetStatus); + LOAD_DLL_FUNCTION(fmiGetRealStatus); + LOAD_DLL_FUNCTION(fmiGetIntegerStatus); + LOAD_DLL_FUNCTION(fmiGetBooleanStatus); + LOAD_DLL_FUNCTION(fmiGetStringStatus); + + LOAD_DLL_FUNCTION(fmiGetVersion); + LOAD_DLL_FUNCTION(fmiSetDebugLogging); + LOAD_DLL_FUNCTION(fmiSetReal); + LOAD_DLL_FUNCTION(fmiSetInteger); + LOAD_DLL_FUNCTION(fmiSetBoolean); + LOAD_DLL_FUNCTION(fmiSetString); + LOAD_DLL_FUNCTION(fmiGetReal); + LOAD_DLL_FUNCTION(fmiGetInteger); + LOAD_DLL_FUNCTION(fmiGetBoolean); + LOAD_DLL_FUNCTION(fmiGetString); + return jm_status; } /* Load FMI 1.0 Model Exchange functions */ static jm_status_enu_t fmi1_capi_load_me_fcn(fmi1_capi_t* fmu) { - jm_status_enu_t jm_status = jm_status_success; - - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the model exchange interface"); - - LOAD_DLL_FUNCTION(fmiGetModelTypesPlatform); - LOAD_DLL_FUNCTION(fmiInstantiateModel); - LOAD_DLL_FUNCTION(fmiFreeModelInstance); - LOAD_DLL_FUNCTION(fmiSetTime); - LOAD_DLL_FUNCTION(fmiSetContinuousStates); - LOAD_DLL_FUNCTION(fmiCompletedIntegratorStep); - LOAD_DLL_FUNCTION(fmiInitialize); - LOAD_DLL_FUNCTION(fmiGetDerivatives); - LOAD_DLL_FUNCTION(fmiGetEventIndicators); - LOAD_DLL_FUNCTION(fmiEventUpdate); - LOAD_DLL_FUNCTION(fmiGetContinuousStates); - LOAD_DLL_FUNCTION(fmiGetNominalContinuousStates); - LOAD_DLL_FUNCTION(fmiGetStateValueReferences); - LOAD_DLL_FUNCTION(fmiTerminate); - - LOAD_DLL_FUNCTION(fmiGetVersion); - LOAD_DLL_FUNCTION(fmiSetDebugLogging); - LOAD_DLL_FUNCTION(fmiSetReal); - LOAD_DLL_FUNCTION(fmiSetInteger); - LOAD_DLL_FUNCTION(fmiSetBoolean); - LOAD_DLL_FUNCTION(fmiSetString); - LOAD_DLL_FUNCTION(fmiGetReal); - LOAD_DLL_FUNCTION(fmiGetInteger); - LOAD_DLL_FUNCTION(fmiGetBoolean); - LOAD_DLL_FUNCTION(fmiGetString); - - return jm_status; + jm_status_enu_t jm_status = jm_status_success; + + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the model exchange interface"); + + LOAD_DLL_FUNCTION(fmiGetModelTypesPlatform); + LOAD_DLL_FUNCTION(fmiInstantiateModel); + LOAD_DLL_FUNCTION(fmiFreeModelInstance); + LOAD_DLL_FUNCTION(fmiSetTime); + LOAD_DLL_FUNCTION(fmiSetContinuousStates); + LOAD_DLL_FUNCTION(fmiCompletedIntegratorStep); + LOAD_DLL_FUNCTION(fmiInitialize); + LOAD_DLL_FUNCTION(fmiGetDerivatives); + LOAD_DLL_FUNCTION(fmiGetEventIndicators); + LOAD_DLL_FUNCTION(fmiEventUpdate); + LOAD_DLL_FUNCTION(fmiGetContinuousStates); + LOAD_DLL_FUNCTION(fmiGetNominalContinuousStates); + LOAD_DLL_FUNCTION(fmiGetStateValueReferences); + LOAD_DLL_FUNCTION(fmiTerminate); + + LOAD_DLL_FUNCTION(fmiGetVersion); + LOAD_DLL_FUNCTION(fmiSetDebugLogging); + LOAD_DLL_FUNCTION(fmiSetReal); + LOAD_DLL_FUNCTION(fmiSetInteger); + LOAD_DLL_FUNCTION(fmiSetBoolean); + LOAD_DLL_FUNCTION(fmiSetString); + LOAD_DLL_FUNCTION(fmiGetReal); + LOAD_DLL_FUNCTION(fmiGetInteger); + LOAD_DLL_FUNCTION(fmiGetBoolean); + LOAD_DLL_FUNCTION(fmiGetString); + + return jm_status; } void fmi1_capi_destroy_dllfmu(fmi1_capi_t* fmu) { - if (fmu == NULL) { - return; - } - fmi1_capi_free_dll(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Releasing allocated memory"); - fmi_util_free_options(fmu->callbacks, fmu->options); - fmu->callbacks->free((void*)fmu->dllPath); - fmu->callbacks->free((void*)fmu->modelIdentifier); - fmu->callbacks->free((void*)fmu); + if (fmu == NULL) { + return; + } + fmi1_capi_free_dll(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Releasing allocated memory"); + fmi_util_free_options(fmu->callbacks, fmu->options); + fmu->callbacks->free((void*)fmu->dllPath); + fmu->callbacks->free((void*)fmu->modelIdentifier); + fmu->callbacks->free((void*)fmu); } fmi1_capi_t* fmi1_capi_create_dllfmu(jm_callbacks* cb, const char* dllPath, const char* modelIdentifier, fmi1_callback_functions_t callBackFunctions, fmi1_fmu_kind_enu_t standard) { - fmi1_capi_t* fmu = NULL; - - jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Initializing data stuctures for FMICAPI."); - - /* Minor check for the callbacks */ - if (cb == NULL) { - assert(0); - return NULL; - } - - /* Allocate memory for the FMU instance */ - fmu = (fmi1_capi_t*)cb->calloc(1, sizeof(fmi1_capi_t)); - if (fmu == NULL) { /* Could not allocate memory for the FMU struct */ - jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the FMU struct."); - return NULL; - } - - /* Set the import package callback functions */ - fmu->callbacks = cb; - - /* Set the FMI callback functions */ - fmu->callBackFunctions = callBackFunctions; - - /* Set FMI standard to load */ - fmu->standard = standard; - - /* Set all memory alloated pointers to NULL */ - fmu->dllPath = NULL; - fmu->modelIdentifier = NULL; - - /* Create options */ - fmu->options = fmi_util_allocate_options(cb); - - /* Copy DLL path */ - fmu->dllPath = (char*)cb->calloc(sizeof(char), strlen(dllPath) + 1); - if (fmu->dllPath == NULL) { - jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the DLL path string."); - fmi1_capi_destroy_dllfmu(fmu); - return NULL; - } - strcpy((char*)fmu->dllPath, dllPath); - - /* Copy the modelIdentifier */ - fmu->modelIdentifier = (char*)cb->calloc(sizeof(char), strlen(modelIdentifier) + 1); - if (fmu->modelIdentifier == NULL) { - jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the modelIdentifier string."); - fmi1_capi_destroy_dllfmu(fmu); - return NULL; - } - strcpy((char*)fmu->modelIdentifier, modelIdentifier); - - jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Successfully initialized data stuctures for FMICAPI."); - - /* Everything was succesfull */ - return fmu; + fmi1_capi_t* fmu = NULL; + + jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Initializing data stuctures for FMICAPI."); + + /* Minor check for the callbacks */ + if (cb == NULL) { + assert(0); + return NULL; + } + + /* Allocate memory for the FMU instance */ + fmu = (fmi1_capi_t*)cb->calloc(1, sizeof(fmi1_capi_t)); + if (fmu == NULL) { /* Could not allocate memory for the FMU struct */ + jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the FMU struct."); + return NULL; + } + + /* Set the import package callback functions */ + fmu->callbacks = cb; + + /* Set the FMI callback functions */ + fmu->callBackFunctions = callBackFunctions; + + /* Set FMI standard to load */ + fmu->standard = standard; + + /* Set all memory alloated pointers to NULL */ + fmu->dllPath = NULL; + fmu->modelIdentifier = NULL; + + /* Create options */ + fmu->options = fmi_util_allocate_options(cb); + + /* Copy DLL path */ + fmu->dllPath = (char*)cb->calloc(sizeof(char), strlen(dllPath) + 1); + if (fmu->dllPath == NULL) { + jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the DLL path string."); + fmi1_capi_destroy_dllfmu(fmu); + return NULL; + } + strcpy((char*)fmu->dllPath, dllPath); + + /* Copy the modelIdentifier */ + fmu->modelIdentifier = (char*)cb->calloc(sizeof(char), strlen(modelIdentifier) + 1); + if (fmu->modelIdentifier == NULL) { + jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the modelIdentifier string."); + fmi1_capi_destroy_dllfmu(fmu); + return NULL; + } + strcpy((char*)fmu->modelIdentifier, modelIdentifier); + + jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Successfully initialized data stuctures for FMICAPI."); + + /* Everything was succesfull */ + return fmu; } jm_status_enu_t fmi1_capi_load_fcn(fmi1_capi_t* fmu) { - assert(fmu); - /* Load ME functions */ - if (fmu->standard == fmi1_fmu_kind_enu_me) { - return fmi1_capi_load_me_fcn(fmu); - /* Load CS functions */ - } else if (fmu->standard == fmi1_fmu_kind_enu_cs_standalone || fmu->standard == fmi1_fmu_kind_enu_cs_tool) { - return fmi1_capi_load_cs_fcn(fmu); - } else { - return jm_status_error; - } + assert(fmu); + /* Load ME functions */ + if (fmu->standard == fmi1_fmu_kind_enu_me) { + return fmi1_capi_load_me_fcn(fmu); + /* Load CS functions */ + } else if (fmu->standard == fmi1_fmu_kind_enu_cs_standalone || fmu->standard == fmi1_fmu_kind_enu_cs_tool) { + return fmi1_capi_load_cs_fcn(fmu); + } else { + return jm_status_error; + } } jm_status_enu_t fmi1_capi_load_dll(fmi1_capi_t* fmu) { - assert(fmu && fmu->dllPath); - fmu->dllHandle = jm_portability_load_dll_handle_with_flag(fmu->dllPath, fmu->options->loadlibrary_flag); /* Load the shared library */ - if (fmu->dllHandle == NULL) { - jm_log_fatal(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMU binary: %s", jm_portability_get_last_dll_error()); - return jm_status_error; - } else { - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loaded FMU binary from %s", fmu->dllPath); - return jm_status_success; - } + assert(fmu && fmu->dllPath); + fmu->dllHandle = jm_portability_load_dll_handle_with_flag(fmu->dllPath, fmu->options->loadlibrary_flag); /* Load the shared library */ + if (fmu->dllHandle == NULL) { + jm_log_fatal(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMU binary: %s", jm_portability_get_last_dll_error()); + return jm_status_error; + } else { + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loaded FMU binary from %s", fmu->dllPath); + return jm_status_success; + } } void fmi1_capi_set_debug_mode(fmi1_capi_t* fmu, int mode) { - if(fmu) - fmu->debugMode = mode; + if(fmu) + fmu->debugMode = mode; } int fmi1_capi_get_debug_mode(fmi1_capi_t* fmu) { - if(fmu) return fmu->debugMode; - return 0; + if(fmu) return fmu->debugMode; + return 0; } jm_status_enu_t fmi1_capi_free_dll(fmi1_capi_t* fmu) { - if (fmu == NULL) { - return jm_status_error; /* Return without writing any log message */ - } + if (fmu == NULL) { + return jm_status_error; /* Return without writing any log message */ + } - if (fmu->dllHandle) { - jm_status_enu_t status = - (fmu->debugMode != 0) ? + if (fmu->dllHandle) { + jm_status_enu_t status = + (fmu->debugMode != 0) ? /* When running valgrind this may be convenient to track mem leaks */ jm_status_success: jm_portability_free_dll_handle(fmu->dllHandle); - fmu->dllHandle = 0; - if (status == jm_status_error) { /* Free the library handle */ - jm_log(fmu->callbacks, FMI_CAPI_MODULE_NAME, jm_log_level_error, "Could not free the FMU binary: %s", jm_portability_get_last_dll_error()); - return jm_status_error; - } else { - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Successfully unloaded FMU binary"); - return jm_status_success; - } - } - return jm_status_success; + fmu->dllHandle = 0; + if (status == jm_status_error) { /* Free the library handle */ + jm_log(fmu->callbacks, FMI_CAPI_MODULE_NAME, jm_log_level_error, "Could not free the FMU binary: %s", jm_portability_get_last_dll_error()); + return jm_status_error; + } else { + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Successfully unloaded FMU binary"); + return jm_status_success; + } + } + return jm_status_success; } /* Common FMI 1.0 functions */ const char* fmi1_capi_get_version(fmi1_capi_t* fmu) { - assert(fmu); - return fmu->fmiGetVersion(); + assert(fmu); + return fmu->fmiGetVersion(); } fmi1_status_t fmi1_capi_set_debug_logging(fmi1_capi_t* fmu, fmi1_boolean_t loggingOn) { - return fmu->fmiSetDebugLogging(fmu->c, loggingOn); + return fmu->fmiSetDebugLogging(fmu->c, loggingOn); } /* fmiSet* functions */ #define FMISETX(FNAME1, FNAME2, FTYPE) \ -fmi1_status_t FNAME1(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const FTYPE value[]) \ +fmi1_status_t FNAME1(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const FTYPE value[]) \ { \ - return fmu->FNAME2(fmu->c, vr, nvr, value); \ + return fmu->FNAME2(fmu->c, vr, nvr, value); \ } /* fmiGet* functions */ #define FMIGETX(FNAME1, FNAME2, FTYPE) \ fmi1_status_t FNAME1(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, FTYPE value[]) \ { \ - return fmu->FNAME2(fmu->c, vr, nvr, value); \ + return fmu->FNAME2(fmu->c, vr, nvr, value); \ } -FMISETX(fmi1_capi_set_real, fmiSetReal, fmi1_real_t) -FMISETX(fmi1_capi_set_integer, fmiSetInteger, fmi1_integer_t) -FMISETX(fmi1_capi_set_boolean, fmiSetBoolean, fmi1_boolean_t) -FMISETX(fmi1_capi_set_string, fmiSetString, fmi1_string_t) +FMISETX(fmi1_capi_set_real, fmiSetReal, fmi1_real_t) +FMISETX(fmi1_capi_set_integer, fmiSetInteger, fmi1_integer_t) +FMISETX(fmi1_capi_set_boolean, fmiSetBoolean, fmi1_boolean_t) +FMISETX(fmi1_capi_set_string, fmiSetString, fmi1_string_t) -FMIGETX(fmi1_capi_get_real, fmiGetReal, fmi1_real_t) -FMIGETX(fmi1_capi_get_integer, fmiGetInteger, fmi1_integer_t) -FMIGETX(fmi1_capi_get_boolean, fmiGetBoolean, fmi1_boolean_t) -FMIGETX(fmi1_capi_get_string, fmiGetString, fmi1_string_t) +FMIGETX(fmi1_capi_get_real, fmiGetReal, fmi1_real_t) +FMIGETX(fmi1_capi_get_integer, fmiGetInteger, fmi1_integer_t) +FMIGETX(fmi1_capi_get_boolean, fmiGetBoolean, fmi1_boolean_t) +FMIGETX(fmi1_capi_get_string, fmiGetString, fmi1_string_t) #ifdef __cplusplus } diff --git a/src/CAPI/src/FMI1/fmi1_capi_cs.c b/src/CAPI/src/FMI1/fmi1_capi_cs.c index 62a9fc0a..9fcc0c7f 100644 --- a/src/CAPI/src/FMI1/fmi1_capi_cs.c +++ b/src/CAPI/src/FMI1/fmi1_capi_cs.c @@ -22,70 +22,70 @@ extern "C" { fmi1_component_t fmi1_capi_instantiate_slave(fmi1_capi_t* fmu, fmi1_string_t instanceName, fmi1_string_t fmuGUID, fmi1_string_t fmuLocation, fmi1_string_t mimeType, fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive, fmi1_boolean_t loggingOn) { - return fmu->c = fmu->fmiInstantiateSlave(instanceName, fmuGUID, fmuLocation, mimeType, timeout, visible, interactive, fmu->callBackFunctions, loggingOn); + return fmu->c = fmu->fmiInstantiateSlave(instanceName, fmuGUID, fmuLocation, mimeType, timeout, visible, interactive, fmu->callBackFunctions, loggingOn); } void fmi1_capi_free_slave_instance(fmi1_capi_t* fmu) { - if(fmu->c) { - fmu->fmiFreeSlaveInstance(fmu->c); - fmu->c = 0; - } + if(fmu->c) { + fmu->fmiFreeSlaveInstance(fmu->c); + fmu->c = 0; + } } fmi1_status_t fmi1_capi_initialize_slave(fmi1_capi_t* fmu, fmi1_real_t tStart, fmi1_boolean_t StopTimeDefined, fmi1_real_t tStop) { - return fmu->fmiInitializeSlave(fmu->c, tStart, StopTimeDefined, tStop); + return fmu->fmiInitializeSlave(fmu->c, tStart, StopTimeDefined, tStop); } const char* fmi1_capi_get_types_platform(fmi1_capi_t* fmu) { - return fmu->fmiGetTypesPlatform(); + return fmu->fmiGetTypesPlatform(); } fmi1_status_t fmi1_capi_terminate_slave(fmi1_capi_t* fmu) { - return fmu->fmiTerminateSlave(fmu->c); + return fmu->fmiTerminateSlave(fmu->c); } fmi1_status_t fmi1_capi_reset_slave(fmi1_capi_t* fmu) { - return fmu->fmiResetSlave(fmu->c); + return fmu->fmiResetSlave(fmu->c); } fmi1_status_t fmi1_capi_set_real_input_derivatives(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], const fmi1_real_t value[]) { - return fmu->fmiSetRealInputDerivatives(fmu->c, vr, nvr, order, value); + return fmu->fmiSetRealInputDerivatives(fmu->c, vr, nvr, order, value); } fmi1_status_t fmi1_capi_get_real_output_derivatives(fmi1_capi_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], fmi1_real_t value[]) { - return fmu->fmiGetRealOutputDerivatives(fmu->c, vr, nvr, order, value); + return fmu->fmiGetRealOutputDerivatives(fmu->c, vr, nvr, order, value); } fmi1_status_t fmi1_capi_cancel_step(fmi1_capi_t* fmu) { - return fmu->fmiCancelStep(fmu->c); + return fmu->fmiCancelStep(fmu->c); } fmi1_status_t fmi1_capi_do_step(fmi1_capi_t* fmu, fmi1_real_t currentCommunicationPoint, fmi1_real_t communicationStepSize, fmi1_boolean_t newStep) { - return fmu->fmiDoStep(fmu->c, currentCommunicationPoint, communicationStepSize, newStep); + return fmu->fmiDoStep(fmu->c, currentCommunicationPoint, communicationStepSize, newStep); } /* fmiGetStatus* */ #define FMIGETSTATUSX(FNAME1, FNAME2,FSTATUSTYPE) \ fmi1_status_t FNAME1(fmi1_capi_t* fmu, const fmi1_status_kind_t s, FSTATUSTYPE* value) \ { \ - return fmu->FNAME2(fmu->c, s, value); \ + return fmu->FNAME2(fmu->c, s, value); \ } -FMIGETSTATUSX(fmi1_capi_get_status, fmiGetStatus, fmi1_status_t) -FMIGETSTATUSX(fmi1_capi_get_real_status, fmiGetRealStatus, fmi1_real_t) -FMIGETSTATUSX(fmi1_capi_get_integer_status, fmiGetIntegerStatus, fmi1_integer_t) -FMIGETSTATUSX(fmi1_capi_get_boolean_status, fmiGetBooleanStatus, fmi1_boolean_t) -FMIGETSTATUSX(fmi1_capi_get_string_status, fmiGetStringStatus, fmi1_string_t) +FMIGETSTATUSX(fmi1_capi_get_status, fmiGetStatus, fmi1_status_t) +FMIGETSTATUSX(fmi1_capi_get_real_status, fmiGetRealStatus, fmi1_real_t) +FMIGETSTATUSX(fmi1_capi_get_integer_status, fmiGetIntegerStatus, fmi1_integer_t) +FMIGETSTATUSX(fmi1_capi_get_boolean_status, fmiGetBooleanStatus, fmi1_boolean_t) +FMIGETSTATUSX(fmi1_capi_get_string_status, fmiGetStringStatus, fmi1_string_t) #ifdef __cplusplus } diff --git a/src/CAPI/src/FMI1/fmi1_capi_impl.h b/src/CAPI/src/FMI1/fmi1_capi_impl.h index 54a51432..6ab162a2 100644 --- a/src/CAPI/src/FMI1/fmi1_capi_impl.h +++ b/src/CAPI/src/FMI1/fmi1_capi_impl.h @@ -37,65 +37,65 @@ extern "C" { * \brief C-API struct used as a placeholder for the FMI funktions and shared library handler. */ struct fmi1_capi_t { - const char* dllPath; - const char* modelIdentifier; - fmi1_callback_functions_t callBackFunctions; - - jm_callbacks* callbacks; - fmi_util_options_t* options; - - DLL_HANDLE dllHandle; - - fmi1_fmu_kind_enu_t standard; - - fmi1_component_t c; - - int debugMode; - - /* FMI common */ - fmi1_get_version_ft fmiGetVersion; - fmi1_set_debug_logging_ft fmiSetDebugLogging; - fmi1_set_real_ft fmiSetReal; - fmi1_set_integer_ft fmiSetInteger; - fmi1_set_boolean_ft fmiSetBoolean; - fmi1_set_string_ft fmiSetString; - fmi1_get_real_ft fmiGetReal; - fmi1_get_integer_ft fmiGetInteger; - fmi1_get_boolean_ft fmiGetBoolean; - fmi1_get_string_ft fmiGetString; - - /* FMI ME */ - fmi1_get_model_typesPlatform_ft fmiGetModelTypesPlatform; - fmi1_instantiate_model_ft fmiInstantiateModel; - fmi1_free_model_instance_ft fmiFreeModelInstance; - fmi1_set_time_ft fmiSetTime; - fmi1_set_continuous_states_ft fmiSetContinuousStates; - fmi1_completed_integrator_step_ft fmiCompletedIntegratorStep; - fmi1_initialize_ft fmiInitialize; - fmi1_get_derivatives_ft fmiGetDerivatives; - fmi1_get_event_indicators_ft fmiGetEventIndicators; - fmi1_event_update_ft fmiEventUpdate; - fmi1_get_continuous_states_ft fmiGetContinuousStates; + const char* dllPath; + const char* modelIdentifier; + fmi1_callback_functions_t callBackFunctions; + + jm_callbacks* callbacks; + fmi_util_options_t* options; + + DLL_HANDLE dllHandle; + + fmi1_fmu_kind_enu_t standard; + + fmi1_component_t c; + + int debugMode; + + /* FMI common */ + fmi1_get_version_ft fmiGetVersion; + fmi1_set_debug_logging_ft fmiSetDebugLogging; + fmi1_set_real_ft fmiSetReal; + fmi1_set_integer_ft fmiSetInteger; + fmi1_set_boolean_ft fmiSetBoolean; + fmi1_set_string_ft fmiSetString; + fmi1_get_real_ft fmiGetReal; + fmi1_get_integer_ft fmiGetInteger; + fmi1_get_boolean_ft fmiGetBoolean; + fmi1_get_string_ft fmiGetString; + + /* FMI ME */ + fmi1_get_model_typesPlatform_ft fmiGetModelTypesPlatform; + fmi1_instantiate_model_ft fmiInstantiateModel; + fmi1_free_model_instance_ft fmiFreeModelInstance; + fmi1_set_time_ft fmiSetTime; + fmi1_set_continuous_states_ft fmiSetContinuousStates; + fmi1_completed_integrator_step_ft fmiCompletedIntegratorStep; + fmi1_initialize_ft fmiInitialize; + fmi1_get_derivatives_ft fmiGetDerivatives; + fmi1_get_event_indicators_ft fmiGetEventIndicators; + fmi1_event_update_ft fmiEventUpdate; + fmi1_get_continuous_states_ft fmiGetContinuousStates; fmi1_get_nominal_continuousStates_ft fmiGetNominalContinuousStates; - fmi1_get_state_valueReferences_ft fmiGetStateValueReferences; - fmi1_terminate_ft fmiTerminate; - - /* FMI CS */ - fmi1_get_types_platform_ft fmiGetTypesPlatform; - fmi1_instantiate_slave_ft fmiInstantiateSlave; - fmi1_initialize_slave_ft fmiInitializeSlave; - fmi1_terminate_slave_ft fmiTerminateSlave; - fmi1_reset_slave_ft fmiResetSlave; - fmi1_free_slave_instance_ft fmiFreeSlaveInstance; - fmi1_set_real_inputDerivatives_ft fmiSetRealInputDerivatives; - fmi1_get_real_outputDerivatives_ft fmiGetRealOutputDerivatives; - fmi1_do_step_ft fmiDoStep; - fmi1_cancel_step_ft fmiCancelStep; - fmi1_get_status_ft fmiGetStatus; - fmi1_get_real_status_ft fmiGetRealStatus; - fmi1_get_integer_status_ft fmiGetIntegerStatus; - fmi1_get_boolean_status_ft fmiGetBooleanStatus; - fmi1_get_string_status_ft fmiGetStringStatus; + fmi1_get_state_valueReferences_ft fmiGetStateValueReferences; + fmi1_terminate_ft fmiTerminate; + + /* FMI CS */ + fmi1_get_types_platform_ft fmiGetTypesPlatform; + fmi1_instantiate_slave_ft fmiInstantiateSlave; + fmi1_initialize_slave_ft fmiInitializeSlave; + fmi1_terminate_slave_ft fmiTerminateSlave; + fmi1_reset_slave_ft fmiResetSlave; + fmi1_free_slave_instance_ft fmiFreeSlaveInstance; + fmi1_set_real_inputDerivatives_ft fmiSetRealInputDerivatives; + fmi1_get_real_outputDerivatives_ft fmiGetRealOutputDerivatives; + fmi1_do_step_ft fmiDoStep; + fmi1_cancel_step_ft fmiCancelStep; + fmi1_get_status_ft fmiGetStatus; + fmi1_get_real_status_ft fmiGetRealStatus; + fmi1_get_integer_status_ft fmiGetIntegerStatus; + fmi1_get_boolean_status_ft fmiGetBooleanStatus; + fmi1_get_string_status_ft fmiGetStringStatus; }; diff --git a/src/CAPI/src/FMI1/fmi1_capi_me.c b/src/CAPI/src/FMI1/fmi1_capi_me.c index 9c64fad5..e02de065 100644 --- a/src/CAPI/src/FMI1/fmi1_capi_me.c +++ b/src/CAPI/src/FMI1/fmi1_capi_me.c @@ -23,103 +23,103 @@ extern "C" { fmi1_component_t fmi1_capi_instantiate_model(fmi1_capi_t* fmu, fmi1_string_t instanceName, fmi1_string_t GUID, fmi1_boolean_t loggingOn) { - fmi1_me_callback_functions_t cb; - assert(fmu); - cb.logger = fmu->callBackFunctions.logger; + fmi1_me_callback_functions_t cb; + assert(fmu); + cb.logger = fmu->callBackFunctions.logger; cb.allocateMemory = fmu->callBackFunctions.allocateMemory; cb.freeMemory = fmu->callBackFunctions.freeMemory; - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiInstantiateModel"); - return fmu->c = fmu->fmiInstantiateModel(instanceName, GUID, cb, loggingOn); + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiInstantiateModel"); + return fmu->c = fmu->fmiInstantiateModel(instanceName, GUID, cb, loggingOn); } void fmi1_capi_free_model_instance(fmi1_capi_t* fmu) { - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiFreeModelInstance"); - fmu->fmiFreeModelInstance(fmu->c); + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiFreeModelInstance"); + fmu->fmiFreeModelInstance(fmu->c); } fmi1_status_t fmi1_capi_initialize(fmi1_capi_t* fmu, fmi1_boolean_t toleranceControlled, fmi1_real_t relativeTolerance, fmi1_event_info_t* eventInfo) { - assert(fmu); - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiInitialize"); - return fmu->fmiInitialize(fmu->c, toleranceControlled, relativeTolerance, eventInfo); + assert(fmu); + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiInitialize"); + return fmu->fmiInitialize(fmu->c, toleranceControlled, relativeTolerance, eventInfo); } const char* fmi1_capi_get_model_types_platform(fmi1_capi_t* fmu) { - assert(fmu); - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetModelTypesPlatform"); - return fmu->fmiGetModelTypesPlatform(); + assert(fmu); + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetModelTypesPlatform"); + return fmu->fmiGetModelTypesPlatform(); } fmi1_status_t fmi1_capi_set_time(fmi1_capi_t* fmu, fmi1_real_t time) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetModelTypesPlatform"); - return fmu->fmiSetTime(fmu->c, time); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetModelTypesPlatform"); + return fmu->fmiSetTime(fmu->c, time); } fmi1_status_t fmi1_capi_set_continuous_states(fmi1_capi_t* fmu, const fmi1_real_t x[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiSetContinuousStates"); - return fmu->fmiSetContinuousStates(fmu->c, x, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiSetContinuousStates"); + return fmu->fmiSetContinuousStates(fmu->c, x, nx); } fmi1_status_t fmi1_capi_completed_integrator_step(fmi1_capi_t* fmu, fmi1_boolean_t* callEventUpdate) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiCompletedIntegratorStep"); - return fmu->fmiCompletedIntegratorStep(fmu->c, callEventUpdate); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiCompletedIntegratorStep"); + return fmu->fmiCompletedIntegratorStep(fmu->c, callEventUpdate); } fmi1_status_t fmi1_capi_get_derivatives(fmi1_capi_t* fmu, fmi1_real_t derivatives[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetDerivatives"); - return fmu->fmiGetDerivatives(fmu->c, derivatives, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetDerivatives"); + return fmu->fmiGetDerivatives(fmu->c, derivatives, nx); } fmi1_status_t fmi1_capi_get_event_indicators(fmi1_capi_t* fmu, fmi1_real_t eventIndicators[], size_t ni) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetEventIndicators"); - return fmu->fmiGetEventIndicators(fmu->c, eventIndicators, ni); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetEventIndicators"); + return fmu->fmiGetEventIndicators(fmu->c, eventIndicators, ni); } fmi1_status_t fmi1_capi_eventUpdate(fmi1_capi_t* fmu, fmi1_boolean_t intermediateResults, fmi1_event_info_t* eventInfo) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiEventUpdate"); - return fmu->fmiEventUpdate(fmu->c, intermediateResults, eventInfo); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiEventUpdate"); + return fmu->fmiEventUpdate(fmu->c, intermediateResults, eventInfo); } fmi1_status_t fmi1_capi_get_continuous_states(fmi1_capi_t* fmu, fmi1_real_t states[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetContinuousStates"); - return fmu->fmiGetContinuousStates(fmu->c, states, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetContinuousStates"); + return fmu->fmiGetContinuousStates(fmu->c, states, nx); } fmi1_status_t fmi1_capi_get_nominal_continuous_states(fmi1_capi_t* fmu, fmi1_real_t x_nominal[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetNominalContinuousStates"); - return fmu->fmiGetNominalContinuousStates(fmu->c, x_nominal, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetNominalContinuousStates"); + return fmu->fmiGetNominalContinuousStates(fmu->c, x_nominal, nx); } fmi1_status_t fmi1_capi_get_state_value_references(fmi1_capi_t* fmu, fmi1_value_reference_t vrx[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetStateValueReferences"); - return fmu->fmiGetStateValueReferences(fmu->c, vrx, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiGetStateValueReferences"); + return fmu->fmiGetStateValueReferences(fmu->c, vrx, nx); } fmi1_status_t fmi1_capi_terminate(fmi1_capi_t* fmu) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiTerminate"); - return fmu->fmiTerminate(fmu->c); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmiTerminate"); + return fmu->fmiTerminate(fmu->c); } #ifdef __cplusplus diff --git a/src/CAPI/src/FMI2/fmi2_capi.c b/src/CAPI/src/FMI2/fmi2_capi.c index 0b24406c..474a8002 100644 --- a/src/CAPI/src/FMI2/fmi2_capi.c +++ b/src/CAPI/src/FMI2/fmi2_capi.c @@ -24,32 +24,32 @@ #include "FMI/fmi_util_options.h" #include -#define FUNCTION_NAME_LENGTH_MAX 2048 /* Maximum length of FMI function name. Used in the load DLL function. */ +#define FUNCTION_NAME_LENGTH_MAX 2048 /* Maximum length of FMI function name. Used in the load DLL function. */ #define STRINGIFY(str) #str /* Loading shared library functions */ static jm_status_enu_t fmi2_capi_get_fcn(fmi2_capi_t* fmu, const char* function_name, jm_dll_function_ptr* dll_function_ptrptr, jm_status_enu_t* status ) { - jm_status_enu_t jm_status = jm_portability_load_dll_function(fmu->dllHandle, (char*)function_name, dll_function_ptrptr); - if (jm_status == jm_status_error) { - jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function '%s'. %s", function_name, jm_portability_get_last_dll_error()); - *status = jm_status_error; - } - return jm_status; + jm_status_enu_t jm_status = jm_portability_load_dll_function(fmu->dllHandle, (char*)function_name, dll_function_ptrptr); + if (jm_status == jm_status_error) { + jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMI function '%s'. %s", function_name, jm_portability_get_last_dll_error()); + *status = jm_status_error; + } + return jm_status; } static void fmi2_capi_get_fcn_with_flag(fmi2_capi_t* fmu, const char* function_name, - jm_dll_function_ptr* dll_function_ptrptr, - unsigned int capabilities[], - fmi2_capabilities_enu_t flag) { - jm_status_enu_t status = jm_status_success; - if(capabilities[flag]) { - fmi2_capi_get_fcn(fmu, function_name, dll_function_ptrptr, &status); - if(status != jm_status_success) { - jm_log_warning(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Resetting flag '%s'", fmi2_capability_to_string(flag)); - capabilities[flag] = 0; - } - } + jm_dll_function_ptr* dll_function_ptrptr, + unsigned int capabilities[], + fmi2_capabilities_enu_t flag) { + jm_status_enu_t status = jm_status_success; + if(capabilities[flag]) { + fmi2_capi_get_fcn(fmu, function_name, dll_function_ptrptr, &status); + if(status != jm_status_success) { + jm_log_warning(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Resetting flag '%s'", fmi2_capability_to_string(flag)); + capabilities[flag] = 0; + } + } } /* Load FMI functions from DLL macro */ @@ -57,12 +57,12 @@ static void fmi2_capi_get_fcn_with_flag(fmi2_capi_t* fmu, const char* function_n /* Load FMI functions from DLL macro for functions controlled by capability flags */ #define LOAD_DLL_FUNCTION_WITH_FLAG(FMIFUNCTION, FLAG) \ - fmi2_capi_get_fcn_with_flag(fmu, #FMIFUNCTION, (jm_dll_function_ptr*)&fmu->FMIFUNCTION, capabilities, FLAG) + fmi2_capi_get_fcn_with_flag(fmu, #FMIFUNCTION, (jm_dll_function_ptr*)&fmu->FMIFUNCTION, capabilities, FLAG) static jm_status_enu_t fmi2_capi_load_common_fcn(fmi2_capi_t* fmu, unsigned int capabilities[]) { - jm_status_enu_t jm_status = jm_status_success; - /*************************************************** + jm_status_enu_t jm_status = jm_status_success; + /*************************************************** Types for Common Functions ****************************************************/ @@ -71,15 +71,15 @@ Types for Common Functions typedef const char* fmi2GetVersionTYPE(void); typedef fmi2Status fmi2SetDebugLoggingTYPE(fmi2Component, fmi2Boolean, size_t, const fmi2String[]); */ - LOAD_DLL_FUNCTION(fmi2GetTypesPlatform); - LOAD_DLL_FUNCTION(fmi2GetVersion); - LOAD_DLL_FUNCTION(fmi2SetDebugLogging); + LOAD_DLL_FUNCTION(fmi2GetTypesPlatform); + LOAD_DLL_FUNCTION(fmi2GetVersion); + LOAD_DLL_FUNCTION(fmi2SetDebugLogging); /* Enter and exit initialization mode, terminate and reset */ /* typedef fmi2Status fmi2TerminateTYPE (fmi2Component); typedef fmi2Status fmi2ResetTYPE (fmi2Component); */ - LOAD_DLL_FUNCTION(fmi2Terminate); - LOAD_DLL_FUNCTION(fmi2Reset); + LOAD_DLL_FUNCTION(fmi2Terminate); + LOAD_DLL_FUNCTION(fmi2Reset); /* Creation and destruction of instances and setting debug status */ /*typedef fmi2Component fmi2InstantiateTYPE (fmi2String, fmi2Type, fmi2String, fmi2String, const fmi2CallbackFunctions*, fmi2Boolean, fmi2Boolean); @@ -94,40 +94,40 @@ Types for Common Functions LOAD_DLL_FUNCTION(fmi2EnterInitializationMode); LOAD_DLL_FUNCTION(fmi2ExitInitializationMode); - /* Getting and setting variable values */ + /* Getting and setting variable values */ /* typedef fmi2Status fmi2GetRealTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2Real []); typedef fmi2Status fmi2GetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Integer[]); typedef fmi2Status fmi2GetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Boolean[]); typedef fmi2Status fmi2GetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2String []); */ - LOAD_DLL_FUNCTION(fmi2GetReal); - LOAD_DLL_FUNCTION(fmi2GetInteger); - LOAD_DLL_FUNCTION(fmi2GetBoolean); - LOAD_DLL_FUNCTION(fmi2GetString); + LOAD_DLL_FUNCTION(fmi2GetReal); + LOAD_DLL_FUNCTION(fmi2GetInteger); + LOAD_DLL_FUNCTION(fmi2GetBoolean); + LOAD_DLL_FUNCTION(fmi2GetString); - /* typedef fmi2Status fmi2SetRealTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2Real []); + /* typedef fmi2Status fmi2SetRealTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2Real []); typedef fmi2Status fmi2SetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Integer[]); typedef fmi2Status fmi2SetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Boolean[]); typedef fmi2Status fmi2SetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2String []); */ - LOAD_DLL_FUNCTION(fmi2SetReal); - LOAD_DLL_FUNCTION(fmi2SetInteger); - LOAD_DLL_FUNCTION(fmi2SetBoolean); - LOAD_DLL_FUNCTION(fmi2SetString); + LOAD_DLL_FUNCTION(fmi2SetReal); + LOAD_DLL_FUNCTION(fmi2SetInteger); + LOAD_DLL_FUNCTION(fmi2SetBoolean); + LOAD_DLL_FUNCTION(fmi2SetString); - return jm_status; + return jm_status; } /* Load FMI 2.0 Co-Simulation functions */ static jm_status_enu_t fmi2_capi_load_cs_fcn(fmi2_capi_t* fmu, unsigned int capabilities[]) { - jm_status_enu_t jm_status = jm_status_success; + jm_status_enu_t jm_status = jm_status_success; - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the co-simulation interface"); + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the co-simulation interface"); - jm_status = fmi2_capi_load_common_fcn(fmu, capabilities); + jm_status = fmi2_capi_load_common_fcn(fmu, capabilities); - /* Getting and setting the internal FMU state */ + /* Getting and setting the internal FMU state */ /* typedef fmi2Status fmi2GetFMUstateTYPE (fmi2Component, fmi2FMUstate*); typedef fmi2Status fmi2SetFMUstateTYPE (fmi2Component, fmi2FMUstate); typedef fmi2Status fmi2FreeFMUstateTYPE (fmi2Component, fmi2FMUstate*); @@ -150,13 +150,13 @@ static jm_status_enu_t fmi2_capi_load_cs_fcn(fmi2_capi_t* fmu, unsigned int capa /* Simulating the slave */ /* typedef fmi2Status fmi2SetRealInputDerivativesTYPE (fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], const fmi2Real []); typedef fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], fmi2Real []); */ - LOAD_DLL_FUNCTION(fmi2SetRealInputDerivatives); - LOAD_DLL_FUNCTION(fmi2GetRealOutputDerivatives); + LOAD_DLL_FUNCTION(fmi2SetRealInputDerivatives); + LOAD_DLL_FUNCTION(fmi2GetRealOutputDerivatives); /* typedef fmi2Status fmi2DoStepTYPE (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean); typedef fmi2Status fmi2CancelStepTYPE (fmi2Component); */ - LOAD_DLL_FUNCTION(fmi2CancelStep); - LOAD_DLL_FUNCTION(fmi2DoStep); + LOAD_DLL_FUNCTION(fmi2CancelStep); + LOAD_DLL_FUNCTION(fmi2DoStep); /* Inquire slave status */ /* typedef fmi2Status fmi2GetStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2Status* ); @@ -164,24 +164,24 @@ static jm_status_enu_t fmi2_capi_load_cs_fcn(fmi2_capi_t* fmu, unsigned int capa typedef fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Integer*); typedef fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Boolean*); typedef fmi2Status fmi2GetStringStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2String* ); */ - LOAD_DLL_FUNCTION(fmi2GetStatus); - LOAD_DLL_FUNCTION(fmi2GetRealStatus); - LOAD_DLL_FUNCTION(fmi2GetIntegerStatus); - LOAD_DLL_FUNCTION(fmi2GetBooleanStatus); - LOAD_DLL_FUNCTION(fmi2GetStringStatus); + LOAD_DLL_FUNCTION(fmi2GetStatus); + LOAD_DLL_FUNCTION(fmi2GetRealStatus); + LOAD_DLL_FUNCTION(fmi2GetIntegerStatus); + LOAD_DLL_FUNCTION(fmi2GetBooleanStatus); + LOAD_DLL_FUNCTION(fmi2GetStringStatus); - return jm_status; + return jm_status; } /* Load FMI 2.0 Model Exchange functions */ static jm_status_enu_t fmi2_capi_load_me_fcn(fmi2_capi_t* fmu, unsigned int capabilities[]) { - jm_status_enu_t jm_status = jm_status_success; + jm_status_enu_t jm_status = jm_status_success; - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the model exchange interface"); + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loading functions for the model exchange interface"); - jm_status = fmi2_capi_load_common_fcn(fmu, capabilities); - /* Getting and setting the internal FMU state */ + jm_status = fmi2_capi_load_common_fcn(fmu, capabilities); + /* Getting and setting the internal FMU state */ /* typedef fmi2Status fmi2GetFMUstateTYPE (fmi2Component, fmi2FMUstate*); typedef fmi2Status fmi2SetFMUstateTYPE (fmi2Component, fmi2FMUstate); typedef fmi2Status fmi2FreeFMUstateTYPE (fmi2Component, fmi2FMUstate*); @@ -206,16 +206,16 @@ static jm_status_enu_t fmi2_capi_load_me_fcn(fmi2_capi_t* fmu, unsigned int capa typedef fmi2Status fmi2NewDiscreteStatesTYPE (fmi2Component, fmi2EventInfo*); typedef fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component); typedef fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component, fmi2Boolean, fmi2Boolean*, fmi2Boolean*);*/ - LOAD_DLL_FUNCTION(fmi2EnterEventMode); - LOAD_DLL_FUNCTION(fmi2NewDiscreteStates); - LOAD_DLL_FUNCTION(fmi2EnterContinuousTimeMode); - LOAD_DLL_FUNCTION(fmi2CompletedIntegratorStep); + LOAD_DLL_FUNCTION(fmi2EnterEventMode); + LOAD_DLL_FUNCTION(fmi2NewDiscreteStates); + LOAD_DLL_FUNCTION(fmi2EnterContinuousTimeMode); + LOAD_DLL_FUNCTION(fmi2CompletedIntegratorStep); /* Providing independent variables and re-initialization of caching */ /*typedef fmi2Status fmi2SetTimeTYPE (fmi2Component, fmi2Real); typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component, const fmi2Real[], size_t);*/ - LOAD_DLL_FUNCTION(fmi2SetTime); - LOAD_DLL_FUNCTION(fmi2SetContinuousStates); + LOAD_DLL_FUNCTION(fmi2SetTime); + LOAD_DLL_FUNCTION(fmi2SetContinuousStates); /* Evaluation of the model equations */ @@ -224,171 +224,171 @@ static jm_status_enu_t fmi2_capi_load_me_fcn(fmi2_capi_t* fmu, unsigned int capa typedef fmi2Status fmi2GetEventIndicatorsTYPE (fmi2Component, fmi2Real[], size_t); typedef fmi2Status fmi2GetContinuousStatesTYPE (fmi2Component, fmi2Real[], size_t); typedef fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component, fmi2Real[], size_t);*/ - LOAD_DLL_FUNCTION(fmi2GetDerivatives); - LOAD_DLL_FUNCTION(fmi2GetEventIndicators); - LOAD_DLL_FUNCTION(fmi2GetContinuousStates); - LOAD_DLL_FUNCTION(fmi2GetNominalsOfContinuousStates); + LOAD_DLL_FUNCTION(fmi2GetDerivatives); + LOAD_DLL_FUNCTION(fmi2GetEventIndicators); + LOAD_DLL_FUNCTION(fmi2GetContinuousStates); + LOAD_DLL_FUNCTION(fmi2GetNominalsOfContinuousStates); - return jm_status; + return jm_status; } void fmi2_capi_destroy_dllfmu(fmi2_capi_t* fmu) { - if (fmu == NULL) { - return; - } - fmi2_capi_free_dll(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Releasing allocated memory"); - fmi_util_free_options(fmu->callbacks, fmu->options); - fmu->callbacks->free((void*)fmu->dllPath); - fmu->callbacks->free((void*)fmu->modelIdentifier); - fmu->callbacks->free((void*)fmu); + if (fmu == NULL) { + return; + } + fmi2_capi_free_dll(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Releasing allocated memory"); + fmi_util_free_options(fmu->callbacks, fmu->options); + fmu->callbacks->free((void*)fmu->dllPath); + fmu->callbacks->free((void*)fmu->modelIdentifier); + fmu->callbacks->free((void*)fmu); } fmi2_capi_t* fmi2_capi_create_dllfmu(jm_callbacks* cb, const char* dllPath, const char* modelIdentifier, const fmi2_callback_functions_t* callBackFunctions, fmi2_fmu_kind_enu_t standard) { - fmi2_capi_t* fmu = NULL; - - jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Initializing data structures for FMICAPI."); + fmi2_capi_t* fmu = NULL; - /* Minor check for the callbacks */ - if (cb == NULL) { - assert(0); - return NULL; - } + jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Initializing data structures for FMICAPI."); - /* Allocate memory for the FMU instance */ - fmu = (fmi2_capi_t*)cb->calloc(1, sizeof(fmi2_capi_t)); - if (fmu == NULL) { /* Could not allocate memory for the FMU struct */ - jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the FMU struct."); - return NULL; - } + /* Minor check for the callbacks */ + if (cb == NULL) { + assert(0); + return NULL; + } - /* Set the import package callback functions */ - fmu->callbacks = cb; + /* Allocate memory for the FMU instance */ + fmu = (fmi2_capi_t*)cb->calloc(1, sizeof(fmi2_capi_t)); + if (fmu == NULL) { /* Could not allocate memory for the FMU struct */ + jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the FMU struct."); + return NULL; + } - /* Set the FMI callback functions */ - fmu->callBackFunctions = *callBackFunctions; + /* Set the import package callback functions */ + fmu->callbacks = cb; - /* Set FMI standard to load */ - fmu->standard = standard; + /* Set the FMI callback functions */ + fmu->callBackFunctions = *callBackFunctions; - /* Set all memory alloated pointers to NULL */ - fmu->dllPath = NULL; - fmu->modelIdentifier = NULL; + /* Set FMI standard to load */ + fmu->standard = standard; - /* Create options */ - fmu->options = fmi_util_allocate_options(cb); + /* Set all memory alloated pointers to NULL */ + fmu->dllPath = NULL; + fmu->modelIdentifier = NULL; - /* Copy DLL path */ - fmu->dllPath = (char*)cb->calloc(sizeof(char), strlen(dllPath) + 1); - if (fmu->dllPath == NULL) { - jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the DLL path string."); - fmi2_capi_destroy_dllfmu(fmu); - return NULL; - } - strcpy((char*)fmu->dllPath, dllPath); + /* Create options */ + fmu->options = fmi_util_allocate_options(cb); - /* Copy the modelIdentifier */ - fmu->modelIdentifier = (char*)cb->calloc(sizeof(char), strlen(modelIdentifier) + 1); - if (fmu->modelIdentifier == NULL) { - jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the modelIdentifier string."); - fmi2_capi_destroy_dllfmu(fmu); - return NULL; - } - strcpy((char*)fmu->modelIdentifier, modelIdentifier); + /* Copy DLL path */ + fmu->dllPath = (char*)cb->calloc(sizeof(char), strlen(dllPath) + 1); + if (fmu->dllPath == NULL) { + jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the DLL path string."); + fmi2_capi_destroy_dllfmu(fmu); + return NULL; + } + strcpy((char*)fmu->dllPath, dllPath); + + /* Copy the modelIdentifier */ + fmu->modelIdentifier = (char*)cb->calloc(sizeof(char), strlen(modelIdentifier) + 1); + if (fmu->modelIdentifier == NULL) { + jm_log_fatal(cb, FMI_CAPI_MODULE_NAME, "Could not allocate memory for the modelIdentifier string."); + fmi2_capi_destroy_dllfmu(fmu); + return NULL; + } + strcpy((char*)fmu->modelIdentifier, modelIdentifier); - jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Successfully initialized data structures for FMICAPI."); + jm_log_debug(cb, FMI_CAPI_MODULE_NAME, "Successfully initialized data structures for FMICAPI."); - /* Everything was successful */ - return fmu; + /* Everything was successful */ + return fmu; } jm_status_enu_t fmi2_capi_load_fcn(fmi2_capi_t* fmu, unsigned int capabilities[]) { - assert(fmu); - /* Load ME functions */ - if (fmu->standard == fmi2_fmu_kind_me) { - return fmi2_capi_load_me_fcn(fmu, capabilities); - /* Load CS functions */ - } else if (fmu->standard == fmi2_fmu_kind_cs) { - return fmi2_capi_load_cs_fcn(fmu, capabilities); - } else { - jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Unexpected FMU kind in FMICAPI."); - return jm_status_error; - } + assert(fmu); + /* Load ME functions */ + if (fmu->standard == fmi2_fmu_kind_me) { + return fmi2_capi_load_me_fcn(fmu, capabilities); + /* Load CS functions */ + } else if (fmu->standard == fmi2_fmu_kind_cs) { + return fmi2_capi_load_cs_fcn(fmu, capabilities); + } else { + jm_log_error(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Unexpected FMU kind in FMICAPI."); + return jm_status_error; + } } jm_status_enu_t fmi2_capi_load_dll(fmi2_capi_t* fmu) { - assert(fmu && fmu->dllPath); - fmu->dllHandle = jm_portability_load_dll_handle_with_flag(fmu->dllPath, fmu->options->loadlibrary_flag); /* Load the shared library */ - if (fmu->dllHandle == NULL) { - jm_log_fatal(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMU binary: %s", jm_portability_get_last_dll_error()); - return jm_status_error; - } else { - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loaded FMU binary from %s", fmu->dllPath); - return jm_status_success; - } + assert(fmu && fmu->dllPath); + fmu->dllHandle = jm_portability_load_dll_handle_with_flag(fmu->dllPath, fmu->options->loadlibrary_flag); /* Load the shared library */ + if (fmu->dllHandle == NULL) { + jm_log_fatal(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Could not load the FMU binary: %s", jm_portability_get_last_dll_error()); + return jm_status_error; + } else { + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Loaded FMU binary from %s", fmu->dllPath); + return jm_status_success; + } } void fmi2_capi_set_debug_mode(fmi2_capi_t* fmu, int mode) { - if(fmu) - fmu->debugMode = mode; + if(fmu) + fmu->debugMode = mode; } int fmi2_capi_get_debug_mode(fmi2_capi_t* fmu) { - if(fmu) return fmu->debugMode; - return 0; + if(fmu) return fmu->debugMode; + return 0; } fmi2_fmu_kind_enu_t fmi2_capi_get_fmu_kind(fmi2_capi_t* fmu) { - if(fmu) return fmu->standard; - return fmi2_fmu_kind_unknown; + if(fmu) return fmu->standard; + return fmi2_fmu_kind_unknown; } jm_status_enu_t fmi2_capi_free_dll(fmi2_capi_t* fmu) { - if (fmu == NULL) { - return jm_status_error; /* Return without writing any log message */ - } + if (fmu == NULL) { + return jm_status_error; /* Return without writing any log message */ + } - if (fmu->dllHandle) { - jm_status_enu_t status = - (fmu->debugMode != 0) ? + if (fmu->dllHandle) { + jm_status_enu_t status = + (fmu->debugMode != 0) ? /* When running valgrind this may be convenient to track mem leaks */ jm_status_success: jm_portability_free_dll_handle(fmu->dllHandle); - fmu->dllHandle = 0; - if (status == jm_status_error) { /* Free the library handle */ - jm_log(fmu->callbacks, FMI_CAPI_MODULE_NAME, jm_log_level_error, "Could not free the FMU binary: %s", jm_portability_get_last_dll_error()); - return jm_status_error; - } else { - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Successfully unloaded FMU binary"); - return jm_status_success; - } - } - return jm_status_success; + fmu->dllHandle = 0; + if (status == jm_status_error) { /* Free the library handle */ + jm_log(fmu->callbacks, FMI_CAPI_MODULE_NAME, jm_log_level_error, "Could not free the FMU binary: %s", jm_portability_get_last_dll_error()); + return jm_status_error; + } else { + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Successfully unloaded FMU binary"); + return jm_status_success; + } + } + return jm_status_success; } /* Common FMI 2.0 functions */ const char* fmi2_capi_get_version(fmi2_capi_t* fmu) { - assert(fmu); - return fmu->fmi2GetVersion(); + assert(fmu); + return fmu->fmi2GetVersion(); } const char* fmi2_capi_get_types_platform(fmi2_capi_t* fmu) { - assert(fmu); - jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetModelTypesPlatform"); - return fmu->fmi2GetTypesPlatform(); + assert(fmu); + jm_log_verbose(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetModelTypesPlatform"); + return fmu->fmi2GetTypesPlatform(); } fmi2_status_t fmi2_capi_set_debug_logging(fmi2_capi_t* fmu, fmi2_boolean_t loggingOn, size_t nCategories, fmi2_string_t categories[]) { - return fmu->fmi2SetDebugLogging(fmu->c, loggingOn, nCategories, categories); + return fmu->fmi2SetDebugLogging(fmu->c, loggingOn, nCategories, categories); } fmi2_component_t fmi2_capi_instantiate(fmi2_capi_t* fmu, @@ -437,62 +437,62 @@ fmi2_status_t fmi2_capi_exit_initialization_mode(fmi2_capi_t* fmu) fmi2_status_t fmi2_capi_terminate(fmi2_capi_t* fmu) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2Terminate"); - return fmu->fmi2Terminate(fmu->c); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2Terminate"); + return fmu->fmi2Terminate(fmu->c); } fmi2_status_t fmi2_capi_reset(fmi2_capi_t* fmu) { - return fmu->fmi2Reset(fmu->c); + return fmu->fmi2Reset(fmu->c); } fmi2_status_t fmi2_capi_get_fmu_state (fmi2_capi_t* fmu, fmi2_FMU_state_t* s) { - return fmu->fmi2GetFMUstate(fmu -> c,s); + return fmu->fmi2GetFMUstate(fmu -> c,s); } fmi2_status_t fmi2_capi_set_fmu_state (fmi2_capi_t* fmu, fmi2_FMU_state_t s){ - return fmu->fmi2SetFMUstate(fmu -> c,s); + return fmu->fmi2SetFMUstate(fmu -> c,s); } fmi2_status_t fmi2_capi_free_fmu_state (fmi2_capi_t* fmu, fmi2_FMU_state_t* s){ - return fmu->fmi2FreeFMUstate (fmu -> c,s); + return fmu->fmi2FreeFMUstate (fmu -> c,s); } fmi2_status_t fmi2_capi_serialized_fmu_state_size(fmi2_capi_t* fmu, fmi2_FMU_state_t s, size_t* sz){ - return fmu->fmi2SerializedFMUstateSize(fmu -> c,s,sz); + return fmu->fmi2SerializedFMUstateSize(fmu -> c,s,sz); } fmi2_status_t fmi2_capi_serialize_fmu_state (fmi2_capi_t* fmu, fmi2_FMU_state_t s , fmi2_byte_t data[], size_t sz){ - return fmu->fmi2SerializeFMUstate(fmu -> c,s,data,sz); + return fmu->fmi2SerializeFMUstate(fmu -> c,s,data,sz); } fmi2_status_t fmi2_capi_de_serialize_fmu_state (fmi2_capi_t* fmu, const fmi2_byte_t data[], size_t sz, fmi2_FMU_state_t* s){ - return fmu->fmi2DeSerializeFMUstate (fmu -> c,data,sz,s); + return fmu->fmi2DeSerializeFMUstate (fmu -> c,data,sz,s); } fmi2_status_t fmi2_capi_get_directional_derivative(fmi2_capi_t* fmu, const fmi2_value_reference_t v_ref[], size_t nv, const fmi2_value_reference_t z_ref[], size_t nz, const fmi2_real_t dv[], fmi2_real_t dz[]){ - return fmu->fmi2GetDirectionalDerivative(fmu -> c, z_ref, nz, v_ref, nv, dv, dz); + return fmu->fmi2GetDirectionalDerivative(fmu -> c, z_ref, nz, v_ref, nv, dv, dz); } /* fmiSet* functions */ #define FMISETX(FNAME1, FNAME2, FTYPE) \ -fmi2_status_t FNAME1(fmi2_capi_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const FTYPE value[]) \ +fmi2_status_t FNAME1(fmi2_capi_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const FTYPE value[]) \ { \ - return fmu->FNAME2(fmu->c, vr, nvr, value); \ + return fmu->FNAME2(fmu->c, vr, nvr, value); \ } /* fmiGet* functions */ #define FMIGETX(FNAME1, FNAME2, FTYPE) \ fmi2_status_t FNAME1(fmi2_capi_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, FTYPE value[]) \ { \ - return fmu->FNAME2(fmu->c, vr, nvr, value); \ + return fmu->FNAME2(fmu->c, vr, nvr, value); \ } -FMISETX(fmi2_capi_set_real, fmi2SetReal, fmi2_real_t) -FMISETX(fmi2_capi_set_integer, fmi2SetInteger, fmi2_integer_t) -FMISETX(fmi2_capi_set_boolean, fmi2SetBoolean, fmi2_boolean_t) -FMISETX(fmi2_capi_set_string, fmi2SetString, fmi2_string_t) +FMISETX(fmi2_capi_set_real, fmi2SetReal, fmi2_real_t) +FMISETX(fmi2_capi_set_integer, fmi2SetInteger, fmi2_integer_t) +FMISETX(fmi2_capi_set_boolean, fmi2SetBoolean, fmi2_boolean_t) +FMISETX(fmi2_capi_set_string, fmi2SetString, fmi2_string_t) -FMIGETX(fmi2_capi_get_real, fmi2GetReal, fmi2_real_t) -FMIGETX(fmi2_capi_get_integer, fmi2GetInteger, fmi2_integer_t) -FMIGETX(fmi2_capi_get_boolean, fmi2GetBoolean, fmi2_boolean_t) -FMIGETX(fmi2_capi_get_string, fmi2GetString, fmi2_string_t) +FMIGETX(fmi2_capi_get_real, fmi2GetReal, fmi2_real_t) +FMIGETX(fmi2_capi_get_integer, fmi2GetInteger, fmi2_integer_t) +FMIGETX(fmi2_capi_get_boolean, fmi2GetBoolean, fmi2_boolean_t) +FMIGETX(fmi2_capi_get_string, fmi2GetString, fmi2_string_t) diff --git a/src/CAPI/src/FMI2/fmi2_capi_cs.c b/src/CAPI/src/FMI2/fmi2_capi_cs.c index 9d1a69dc..43cee88c 100644 --- a/src/CAPI/src/FMI2/fmi2_capi_cs.c +++ b/src/CAPI/src/FMI2/fmi2_capi_cs.c @@ -23,36 +23,36 @@ extern "C" { fmi2_status_t fmi2_capi_set_real_input_derivatives(fmi2_capi_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_integer_t order[], const fmi2_real_t value[]) { - return fmu->fmi2SetRealInputDerivatives(fmu->c, vr, nvr, order, value); + return fmu->fmi2SetRealInputDerivatives(fmu->c, vr, nvr, order, value); } fmi2_status_t fmi2_capi_get_real_output_derivatives(fmi2_capi_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_integer_t order[], fmi2_real_t value[]) { - return fmu->fmi2GetRealOutputDerivatives(fmu->c, vr, nvr, order, value); + return fmu->fmi2GetRealOutputDerivatives(fmu->c, vr, nvr, order, value); } fmi2_status_t fmi2_capi_cancel_step(fmi2_capi_t* fmu) { - return fmu->fmi2CancelStep(fmu->c); + return fmu->fmi2CancelStep(fmu->c); } fmi2_status_t fmi2_capi_do_step(fmi2_capi_t* fmu, fmi2_real_t currentCommunicationPoint, fmi2_real_t communicationStepSize, fmi2_boolean_t newStep) { - return fmu->fmi2DoStep(fmu->c, currentCommunicationPoint, communicationStepSize, newStep); + return fmu->fmi2DoStep(fmu->c, currentCommunicationPoint, communicationStepSize, newStep); } /* fmiGetStatus* */ #define FMIGETSTATUSX(FNAME1, FNAME2,FSTATUSTYPE) \ fmi2_status_t FNAME1(fmi2_capi_t* fmu, const fmi2_status_kind_t s, FSTATUSTYPE* value) \ { \ - return fmu->FNAME2(fmu->c, s, value); \ + return fmu->FNAME2(fmu->c, s, value); \ } -FMIGETSTATUSX(fmi2_capi_get_status, fmi2GetStatus, fmi2_status_t) -FMIGETSTATUSX(fmi2_capi_get_real_status, fmi2GetRealStatus, fmi2_real_t) -FMIGETSTATUSX(fmi2_capi_get_integer_status, fmi2GetIntegerStatus, fmi2_integer_t) -FMIGETSTATUSX(fmi2_capi_get_boolean_status, fmi2GetBooleanStatus, fmi2_boolean_t) -FMIGETSTATUSX(fmi2_capi_get_string_status, fmi2GetStringStatus, fmi2_string_t) +FMIGETSTATUSX(fmi2_capi_get_status, fmi2GetStatus, fmi2_status_t) +FMIGETSTATUSX(fmi2_capi_get_real_status, fmi2GetRealStatus, fmi2_real_t) +FMIGETSTATUSX(fmi2_capi_get_integer_status, fmi2GetIntegerStatus, fmi2_integer_t) +FMIGETSTATUSX(fmi2_capi_get_boolean_status, fmi2GetBooleanStatus, fmi2_boolean_t) +FMIGETSTATUSX(fmi2_capi_get_string_status, fmi2GetStringStatus, fmi2_string_t) #ifdef __cplusplus } diff --git a/src/CAPI/src/FMI2/fmi2_capi_impl.h b/src/CAPI/src/FMI2/fmi2_capi_impl.h index ecc51077..444c7282 100644 --- a/src/CAPI/src/FMI2/fmi2_capi_impl.h +++ b/src/CAPI/src/FMI2/fmi2_capi_impl.h @@ -37,79 +37,79 @@ extern "C" { * \brief C-API struct used as a placeholder for the FMI functions and shared library handler. */ struct fmi2_capi_t { - const char* dllPath; - const char* modelIdentifier; - fmi2_callback_functions_t callBackFunctions; + const char* dllPath; + const char* modelIdentifier; + fmi2_callback_functions_t callBackFunctions; - jm_callbacks* callbacks; - fmi_util_options_t* options; + jm_callbacks* callbacks; + fmi_util_options_t* options; - DLL_HANDLE dllHandle; + DLL_HANDLE dllHandle; - fmi2_fmu_kind_enu_t standard; + fmi2_fmu_kind_enu_t standard; - fmi2_component_t c; + fmi2_component_t c; - int debugMode; + int debugMode; - /* FMI common */ - fmi2_get_version_ft fmi2GetVersion; - fmi2_set_debug_logging_ft fmi2SetDebugLogging; - fmi2_instantiate_ft fmi2Instantiate; - fmi2_free_instance_ft fmi2FreeInstance; + /* FMI common */ + fmi2_get_version_ft fmi2GetVersion; + fmi2_set_debug_logging_ft fmi2SetDebugLogging; + fmi2_instantiate_ft fmi2Instantiate; + fmi2_free_instance_ft fmi2FreeInstance; - fmi2_setup_experiment_ft fmi2SetupExperiment; - fmi2_enter_initialization_mode_ft fmi2EnterInitializationMode; - fmi2_exit_initialization_mode_ft fmi2ExitInitializationMode; + fmi2_setup_experiment_ft fmi2SetupExperiment; + fmi2_enter_initialization_mode_ft fmi2EnterInitializationMode; + fmi2_exit_initialization_mode_ft fmi2ExitInitializationMode; - fmi2_terminate_ft fmi2Terminate; - fmi2_reset_ft fmi2Reset; + fmi2_terminate_ft fmi2Terminate; + fmi2_reset_ft fmi2Reset; - fmi2_set_real_ft fmi2SetReal; - fmi2_set_integer_ft fmi2SetInteger; - fmi2_set_boolean_ft fmi2SetBoolean; - fmi2_set_string_ft fmi2SetString; - fmi2_get_real_ft fmi2GetReal; - fmi2_get_integer_ft fmi2GetInteger; - fmi2_get_boolean_ft fmi2GetBoolean; - fmi2_get_string_ft fmi2GetString; + fmi2_set_real_ft fmi2SetReal; + fmi2_set_integer_ft fmi2SetInteger; + fmi2_set_boolean_ft fmi2SetBoolean; + fmi2_set_string_ft fmi2SetString; + fmi2_get_real_ft fmi2GetReal; + fmi2_get_integer_ft fmi2GetInteger; + fmi2_get_boolean_ft fmi2GetBoolean; + fmi2_get_string_ft fmi2GetString; - fmi2_get_fmu_state_ft fmi2GetFMUstate; - fmi2_set_fmu_state_ft fmi2SetFMUstate; - fmi2_free_fmu_state_ft fmi2FreeFMUstate; - - fmi2_serialized_fmu_state_size_ft fmi2SerializedFMUstateSize; - fmi2_serialize_fmu_state_ft fmi2SerializeFMUstate; - fmi2_de_serialize_fmu_state_ft fmi2DeSerializeFMUstate; + fmi2_get_fmu_state_ft fmi2GetFMUstate; + fmi2_set_fmu_state_ft fmi2SetFMUstate; + fmi2_free_fmu_state_ft fmi2FreeFMUstate; + + fmi2_serialized_fmu_state_size_ft fmi2SerializedFMUstateSize; + fmi2_serialize_fmu_state_ft fmi2SerializeFMUstate; + fmi2_de_serialize_fmu_state_ft fmi2DeSerializeFMUstate; /* Getting partial derivatives */ - fmi2_get_directional_derivative_ft fmi2GetDirectionalDerivative; + fmi2_get_directional_derivative_ft fmi2GetDirectionalDerivative; - /* FMI ME */ - fmi2_enter_event_mode_ft fmi2EnterEventMode; - fmi2_new_discrete_states_ft fmi2NewDiscreteStates; - fmi2_enter_continuous_time_mode_ft fmi2EnterContinuousTimeMode; - fmi2_completed_integrator_step_ft fmi2CompletedIntegratorStep; + /* FMI ME */ + fmi2_enter_event_mode_ft fmi2EnterEventMode; + fmi2_new_discrete_states_ft fmi2NewDiscreteStates; + fmi2_enter_continuous_time_mode_ft fmi2EnterContinuousTimeMode; + fmi2_completed_integrator_step_ft fmi2CompletedIntegratorStep; - fmi2_get_types_platform_ft fmi2GetTypesPlatform; + fmi2_get_types_platform_ft fmi2GetTypesPlatform; - fmi2_set_time_ft fmi2SetTime; - fmi2_set_continuous_states_ft fmi2SetContinuousStates; - fmi2_get_derivatives_ft fmi2GetDerivatives; - fmi2_get_event_indicators_ft fmi2GetEventIndicators; - fmi2_get_continuous_states_ft fmi2GetContinuousStates; + fmi2_set_time_ft fmi2SetTime; + fmi2_set_continuous_states_ft fmi2SetContinuousStates; + fmi2_get_derivatives_ft fmi2GetDerivatives; + fmi2_get_event_indicators_ft fmi2GetEventIndicators; + fmi2_get_continuous_states_ft fmi2GetContinuousStates; fmi2_get_nominals_of_continuous_states_ft fmi2GetNominalsOfContinuousStates; - /* FMI CS */ - fmi2_set_real_input_derivatives_ft fmi2SetRealInputDerivatives; - fmi2_get_real_output_derivatives_ft fmi2GetRealOutputDerivatives; - fmi2_do_step_ft fmi2DoStep; - fmi2_cancel_step_ft fmi2CancelStep; - fmi2_get_status_ft fmi2GetStatus; - fmi2_get_real_status_ft fmi2GetRealStatus; - fmi2_get_integer_status_ft fmi2GetIntegerStatus; - fmi2_get_boolean_status_ft fmi2GetBooleanStatus; - fmi2_get_string_status_ft fmi2GetStringStatus; + /* FMI CS */ + fmi2_set_real_input_derivatives_ft fmi2SetRealInputDerivatives; + fmi2_get_real_output_derivatives_ft fmi2GetRealOutputDerivatives; + fmi2_do_step_ft fmi2DoStep; + fmi2_cancel_step_ft fmi2CancelStep; + fmi2_get_status_ft fmi2GetStatus; + fmi2_get_real_status_ft fmi2GetRealStatus; + fmi2_get_integer_status_ft fmi2GetIntegerStatus; + fmi2_get_boolean_status_ft fmi2GetBooleanStatus; + fmi2_get_string_status_ft fmi2GetStringStatus; }; diff --git a/src/CAPI/src/FMI2/fmi2_capi_me.c b/src/CAPI/src/FMI2/fmi2_capi_me.c index b32d3a9b..3887b869 100644 --- a/src/CAPI/src/FMI2/fmi2_capi_me.c +++ b/src/CAPI/src/FMI2/fmi2_capi_me.c @@ -41,16 +41,16 @@ fmi2_status_t fmi2_capi_enter_continuous_time_mode(fmi2_capi_t* fmu) fmi2_status_t fmi2_capi_set_time(fmi2_capi_t* fmu, fmi2_real_t time) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2SetTime"); - return fmu->fmi2SetTime(fmu->c, time); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2SetTime"); + return fmu->fmi2SetTime(fmu->c, time); } fmi2_status_t fmi2_capi_set_continuous_states(fmi2_capi_t* fmu, const fmi2_real_t x[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2SetContinuousStates"); - return fmu->fmi2SetContinuousStates(fmu->c, x, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2SetContinuousStates"); + return fmu->fmi2SetContinuousStates(fmu->c, x, nx); } fmi2_status_t fmi2_capi_completed_integrator_step(fmi2_capi_t* fmu, @@ -65,28 +65,28 @@ fmi2_status_t fmi2_capi_completed_integrator_step(fmi2_capi_t* fmu, fmi2_status_t fmi2_capi_get_derivatives(fmi2_capi_t* fmu, fmi2_real_t derivatives[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetDerivatives"); - return fmu->fmi2GetDerivatives(fmu->c, derivatives, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetDerivatives"); + return fmu->fmi2GetDerivatives(fmu->c, derivatives, nx); } fmi2_status_t fmi2_capi_get_event_indicators(fmi2_capi_t* fmu, fmi2_real_t eventIndicators[], size_t ni) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetEventIndicators"); - return fmu->fmi2GetEventIndicators(fmu->c, eventIndicators, ni); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetEventIndicators"); + return fmu->fmi2GetEventIndicators(fmu->c, eventIndicators, ni); } fmi2_status_t fmi2_capi_get_continuous_states(fmi2_capi_t* fmu, fmi2_real_t states[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetContinuousStates"); - return fmu->fmi2GetContinuousStates(fmu->c, states, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetContinuousStates"); + return fmu->fmi2GetContinuousStates(fmu->c, states, nx); } fmi2_status_t fmi2_capi_get_nominals_of_continuous_states(fmi2_capi_t* fmu, fmi2_real_t x_nominal[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetNominalsOfContinuousStates"); - return fmu->fmi2GetNominalsOfContinuousStates(fmu->c, x_nominal, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2GetNominalsOfContinuousStates"); + return fmu->fmi2GetNominalsOfContinuousStates(fmu->c, x_nominal, nx); } diff --git a/src/CAPI/src/FMI3/fmi3_capi_me.c b/src/CAPI/src/FMI3/fmi3_capi_me.c index 42d92dd6..69e6b1f1 100644 --- a/src/CAPI/src/FMI3/fmi3_capi_me.c +++ b/src/CAPI/src/FMI3/fmi3_capi_me.c @@ -26,16 +26,16 @@ fmi3_status_t fmi3_capi_enter_continuous_time_mode(fmi3_capi_t* fmu) fmi3_status_t fmi3_capi_set_time(fmi3_capi_t* fmu, fmi3_float64_t time) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3SetTime"); - return fmu->fmi3SetTime(fmu->inst, time); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3SetTime"); + return fmu->fmi3SetTime(fmu->inst, time); } fmi3_status_t fmi3_capi_set_continuous_states(fmi3_capi_t* fmu, const fmi3_float64_t x[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3SetContinuousStates"); - return fmu->fmi3SetContinuousStates(fmu->inst, x, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3SetContinuousStates"); + return fmu->fmi3SetContinuousStates(fmu->inst, x, nx); } fmi3_status_t fmi3_capi_completed_integrator_step(fmi3_capi_t* fmu, @@ -50,42 +50,42 @@ fmi3_status_t fmi3_capi_completed_integrator_step(fmi3_capi_t* fmu, fmi3_status_t fmi3_capi_get_derivatives(fmi3_capi_t* fmu, fmi3_float64_t derivatives[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetContinuousStateDerivatives"); - return fmu->fmi3GetContinuousStateDerivatives(fmu->inst, derivatives, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetContinuousStateDerivatives"); + return fmu->fmi3GetContinuousStateDerivatives(fmu->inst, derivatives, nx); } fmi3_status_t fmi3_capi_get_event_indicators(fmi3_capi_t* fmu, fmi3_float64_t eventIndicators[], size_t ni) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetEventIndicators"); - return fmu->fmi3GetEventIndicators(fmu->inst, eventIndicators, ni); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetEventIndicators"); + return fmu->fmi3GetEventIndicators(fmu->inst, eventIndicators, ni); } fmi3_status_t fmi3_capi_get_continuous_states(fmi3_capi_t* fmu, fmi3_float64_t x[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetContinuousStates"); - return fmu->fmi3GetContinuousStates(fmu->inst, x, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetContinuousStates"); + return fmu->fmi3GetContinuousStates(fmu->inst, x, nx); } fmi3_status_t fmi3_capi_get_nominals_of_continuous_states(fmi3_capi_t* fmu, fmi3_float64_t nominals[], size_t nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetNominalsOfContinuousStates"); - return fmu->fmi3GetNominalsOfContinuousStates(fmu->inst, nominals, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetNominalsOfContinuousStates"); + return fmu->fmi3GetNominalsOfContinuousStates(fmu->inst, nominals, nx); } fmi3_status_t fmi3_capi_get_number_of_event_indicators(fmi3_capi_t* fmu, size_t* nz) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetNumberOfEventIndicators"); - return fmu->fmi3GetNumberOfEventIndicators(fmu->inst, nz); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetNumberOfEventIndicators"); + return fmu->fmi3GetNumberOfEventIndicators(fmu->inst, nz); } fmi3_status_t fmi3_capi_get_number_of_continuous_states(fmi3_capi_t* fmu, size_t* nx) { - assert(fmu); - jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetNumberOfContinuousStates"); - return fmu->fmi3GetNumberOfContinuousStates(fmu->inst, nx); + assert(fmu); + jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi3GetNumberOfContinuousStates"); + return fmu->fmi3GetNumberOfContinuousStates(fmu->inst, nx); } diff --git a/src/Import/include/FMI/fmi_import_context.h b/src/Import/include/FMI/fmi_import_context.h index 3b9c5274..7067529a 100644 --- a/src/Import/include/FMI/fmi_import_context.h +++ b/src/Import/include/FMI/fmi_import_context.h @@ -38,7 +38,7 @@ extern "C" { #endif - + /** \addtogroup fmi_import FMI import library @{ @@ -64,19 +64,19 @@ in \ref fmi1_import_capi, \ref fmi2_import_capi and \ref fmi3_import_capi. */ /** \brief FMI version independent library context. - Opaque struct returned from fmi_import_allocate_context() + Opaque struct returned from fmi_import_allocate_context() */ typedef struct fmi_xml_context_t fmi_import_context_t ; /** \brief Create fmi_import_context_t structure. - @param callbacks - a pointer to the library callbacks for memory management and logging. May be NULL if defaults are utilized. - @return A new structure if memory allocation was successful. + @param callbacks - a pointer to the library callbacks for memory management and logging. May be NULL if defaults are utilized. + @return A new structure if memory allocation was successful. */ FMILIB_EXPORT fmi_import_context_t* fmi_import_allocate_context( jm_callbacks* callbacks); /** - \brief Free memory allocated for the library context. - @param c - library context allocated by fmi_import_allocate_context() + \brief Free memory allocated for the library context. + @param c - library context allocated by fmi_import_allocate_context() */ FMILIB_EXPORT void fmi_import_free_context( fmi_import_context_t* c); @@ -104,43 +104,43 @@ FMILIB_EXPORT void fmi_import_set_configuration( fmi_import_context_t* c, int co FMILIB_EXPORT fmi_version_enu_t fmi_import_get_fmi_version(fmi_import_context_t* c, const char* fileName, const char* dirName); /** - \brief FMU version 1.0 object + \brief FMU version 1.0 object */ typedef struct fmi1_import_t fmi1_import_t; /** - \brief FMU version 2.0 object + \brief FMU version 2.0 object */ typedef struct fmi2_import_t fmi2_import_t; /** - \brief FMU version 3.0 object + \brief FMU version 3.0 object */ typedef struct fmi3_import_t fmi3_import_t; /** - \brief Parse FMI 1.0 XML file found in the directory dirName. - \param c - library context. - \param dirName - a directory where the FMU was unpacked and XML file is present. - \return fmi1_import_t:: opaque object pointer + \brief Parse FMI 1.0 XML file found in the directory dirName. + \param c - library context. + \param dirName - a directory where the FMU was unpacked and XML file is present. + \return fmi1_import_t:: opaque object pointer */ FMILIB_EXPORT fmi1_import_t* fmi1_import_parse_xml( fmi_import_context_t* c, const char* dirName); /** \brief Create ::fmi2_import_t structure and parse the FMI 2.0 XML file found in the directory dirName. - \param context - library context. - \param dirPath - a directory where the FMU was unpacked and XML file is present. - \param xml_callbacks Callbacks to use for processing of annotations (may be NULL). - \return fmi2_import_t:: opaque object pointer + \param context - library context. + \param dirPath - a directory where the FMU was unpacked and XML file is present. + \param xml_callbacks Callbacks to use for processing of annotations (may be NULL). + \return fmi2_import_t:: opaque object pointer */ FMILIB_EXPORT fmi2_import_t* fmi2_import_parse_xml( fmi_import_context_t* context, const char* dirPath, fmi2_xml_callbacks_t* xml_callbacks); /** \brief Create ::fmi3_import_t structure and parse the FMI 3.0 XML file found in the directory dirName. - \param context - library context. - \param dirPath - a directory where the FMU was unpacked and XML file is present. - \param xml_callbacks Callbacks to use for processing of annotations (may be NULL). - \return fmi3_import_t:: opaque object pointer + \param context - library context. + \param dirPath - a directory where the FMU was unpacked and XML file is present. + \param xml_callbacks Callbacks to use for processing of annotations (may be NULL). + \return fmi3_import_t:: opaque object pointer */ FMILIB_EXPORT fmi3_import_t* fmi3_import_parse_xml( fmi_import_context_t* context, const char* dirPath, fmi3_xml_callbacks_t* xml_callbacks); diff --git a/src/Import/include/FMI/fmi_import_util.h b/src/Import/include/FMI/fmi_import_util.h index fceb79df..c1312011 100644 --- a/src/Import/include/FMI/fmi_import_util.h +++ b/src/Import/include/FMI/fmi_import_util.h @@ -26,40 +26,40 @@ extern "C" { @{ */ /** - \brief Create a unique temporary directory - \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. - \param systemTempDir - directory where the temp dir should be located both absolute and relative path are accepted. - System-wide directory is used if this parameter is NULL. - \param tempPrefix - File name template prefix used when creating temporaty directories. "fmil" is used if this is NULL. - \return A pointer to the temporary directory name (absolute path, no terminating '/'). Caller is responsible for freeing the memory. - The function returns NULL if there were errors in which case a message is send to the logger. + \brief Create a unique temporary directory + \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. + \param systemTempDir - directory where the temp dir should be located both absolute and relative path are accepted. + System-wide directory is used if this parameter is NULL. + \param tempPrefix - File name template prefix used when creating temporaty directories. "fmil" is used if this is NULL. + \return A pointer to the temporary directory name (absolute path, no terminating '/'). Caller is responsible for freeing the memory. + The function returns NULL if there were errors in which case a message is send to the logger. */ FMILIB_EXPORT char* fmi_import_mk_temp_dir(jm_callbacks* cb, const char* systemTempDir, const char* tempPrefix); /** \brief Remove directory and all it contents. - \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. - \param dir - path to be removed. - \return Statuc success or error. + \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. + \param dir - path to be removed. + \return Statuc success or error. */ FMILIB_EXPORT jm_status_enu_t fmi_import_rmdir(jm_callbacks* cb, const char* dir); /** - \brief Create a file:// URL from absolute path - \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. - \param absPath - absolute path to be converted into the URL - \return A pointer to the URL. Caller is responsible for freeing the memory. - The function returns NULL if there were errors in which case a message is send to the logger. + \brief Create a file:// URL from absolute path + \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. + \param absPath - absolute path to be converted into the URL + \return A pointer to the URL. Caller is responsible for freeing the memory. + The function returns NULL if there were errors in which case a message is send to the logger. */ FMILIB_EXPORT char* fmi_import_create_URL_from_abs_path(jm_callbacks* cb, const char* absPath); /** Given directory name fmu_unzipped_path and model identifier consturct Dll/so name - @return Pointer to a string with the file name. Caller is responsible for freeing the memory. + @return Pointer to a string with the file name. Caller is responsible for freeing the memory. */ FMILIB_EXPORT char* fmi_import_get_dll_path(const char* fmu_unzipped_path, const char* model_identifier, jm_callbacks* callBackFunctions); /** Given directory name fmu_unzipped_path and model identifier consturct XML file name - @return Pointer to a string with the file name. Caller is responsible for freeing the memory. + @return Pointer to a string with the file name. Caller is responsible for freeing the memory. */ FMILIB_EXPORT char* fmi_import_get_model_description_path(const char* fmu_unzipped_path, jm_callbacks* callBackFunctions); /** diff --git a/src/Import/include/FMI1/fmi1_import.h b/src/Import/include/FMI1/fmi1_import.h index 0aea5242..791fd39f 100644 --- a/src/Import/include/FMI1/fmi1_import.h +++ b/src/Import/include/FMI1/fmi1_import.h @@ -93,7 +93,7 @@ FMILIB_EXPORT const char* fmi1_import_get_last_error(fmi1_import_t* fmu); \brief Clear the error message. * @param fmu An FMU object as returned by fmi1_import_parse_xml(). * @return 0 if further processing is possible. If it returns 1 then the -* error was not recoverable. The \p fmu object should then be freed and recreated. +* error was not recoverable. The \p fmu object should then be freed and recreated. */ FMILIB_EXPORT int fmi1_import_clear_last_error(fmi1_import_t* fmu); @@ -201,8 +201,8 @@ FMILIB_EXPORT double fmi1_import_get_default_experiment_tolerance(fmi1_import_t* FMILIB_EXPORT fmi1_fmu_kind_enu_t fmi1_import_get_fmu_kind(fmi1_import_t* fmu); /** \brief Get the structure with capability flags. - @return A pointer to the fmi1_import_capabilities_t allocated within the library. - Note that for model exchange FMUs the values of all the flags are always default. + @return A pointer to the fmi1_import_capabilities_t allocated within the library. + Note that for model exchange FMUs the values of all the flags are always default. */ FMILIB_EXPORT fmi1_import_capabilities_t* fmi1_import_get_capabilities(fmi1_import_t* fmu); @@ -213,9 +213,9 @@ FMILIB_EXPORT fmi1_import_type_definitions_t* fmi1_import_get_type_definitions(f FMILIB_EXPORT fmi1_import_unit_definitions_t* fmi1_import_get_unit_definitions(fmi1_import_t* fmu); /** - \brief Get the direct dependency information + \brief Get the direct dependency information - @return A variable list is returned for variables with causality Output. Null pointer for others. */ + @return A variable list is returned for variables with causality Output. Null pointer for others. */ FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_get_direct_dependency(fmi1_import_t* fmu, fmi1_import_variable_t*); /** \brief Get the variable with the same value reference that is not an alias*/ diff --git a/src/Import/include/FMI1/fmi1_import_capabilities.h b/src/Import/include/FMI1/fmi1_import_capabilities.h index be1f11ca..e73481a0 100644 --- a/src/Import/include/FMI1/fmi1_import_capabilities.h +++ b/src/Import/include/FMI1/fmi1_import_capabilities.h @@ -22,43 +22,43 @@ extern "C" { #endif - /** - \file fmi1_import_capabilities.h - Functions to retrieve capability flags. - */ - /** - \addtogroup fmi1_import - @{ - \addtogroup fmi1_import_capabilities Functions to retrieve capability flags. - The functions accept a pointer to ::fmi1_import_capabilities_t returned by fmi1_import_get_capabilities(). - They return the flags as specified by the FMI 1.0 standard. Default values are returned for model-exachange FMUs. - @} - \addtogroup fmi1_import_capabilities - @{ - */ + /** + \file fmi1_import_capabilities.h + Functions to retrieve capability flags. + */ + /** + \addtogroup fmi1_import + @{ + \addtogroup fmi1_import_capabilities Functions to retrieve capability flags. + The functions accept a pointer to ::fmi1_import_capabilities_t returned by fmi1_import_get_capabilities(). + They return the flags as specified by the FMI 1.0 standard. Default values are returned for model-exachange FMUs. + @} + \addtogroup fmi1_import_capabilities + @{ + */ /**\name FMU capabilities flags */ /**@{ */ /** \brief A container for all the capability flags */ typedef struct fmi1_xml_capabilities_t fmi1_import_capabilities_t; /** @} */ - /** \brief Retrieve canHandleVariableCommunicationStepSize flag. */ + /** \brief Retrieve canHandleVariableCommunicationStepSize flag. */ FMILIB_EXPORT int fmi1_import_get_canHandleVariableCommunicationStepSize(fmi1_import_capabilities_t* ); - /** \brief Retrieve canHandleEvents flag. */ + /** \brief Retrieve canHandleEvents flag. */ FMILIB_EXPORT int fmi1_import_get_canHandleEvents(fmi1_import_capabilities_t* ); - /** \brief Retrieve canRejectSteps flag. */ + /** \brief Retrieve canRejectSteps flag. */ FMILIB_EXPORT int fmi1_import_get_canRejectSteps(fmi1_import_capabilities_t* ); - /** \brief Retrieve canInterpolateInputs flag. */ + /** \brief Retrieve canInterpolateInputs flag. */ FMILIB_EXPORT int fmi1_import_get_canInterpolateInputs(fmi1_import_capabilities_t* ); - /** \brief Retrieve maxOutputDerivativeOrder. */ + /** \brief Retrieve maxOutputDerivativeOrder. */ FMILIB_EXPORT unsigned int fmi1_import_get_maxOutputDerivativeOrder(fmi1_import_capabilities_t* ); - /** \brief Retrieve canRunAsynchronuously flag. */ + /** \brief Retrieve canRunAsynchronuously flag. */ FMILIB_EXPORT int fmi1_import_get_canRunAsynchronuously(fmi1_import_capabilities_t* ); - /** \brief Deprecated since 1.0.1, do not use. */ + /** \brief Deprecated since 1.0.1, do not use. */ FMILIB_EXPORT int fmi1_import_get_canSignalEvents(fmi1_import_capabilities_t* ); - /** \brief Retrieve canBeInstantiatedOnlyOncePerProcess flag. */ + /** \brief Retrieve canBeInstantiatedOnlyOncePerProcess flag. */ FMILIB_EXPORT int fmi1_import_get_canBeInstantiatedOnlyOncePerProcess(fmi1_import_capabilities_t* ); - /** \brief Retrieve canNotUseMemoryManagementFunctions flag. */ + /** \brief Retrieve canNotUseMemoryManagementFunctions flag. */ FMILIB_EXPORT int fmi1_import_get_canNotUseMemoryManagementFunctions(fmi1_import_capabilities_t* ); /** @} diff --git a/src/Import/include/FMI1/fmi1_import_capi.h b/src/Import/include/FMI1/fmi1_import_capi.h index d7fd068f..4955c431 100644 --- a/src/Import/include/FMI1/fmi1_import_capi.h +++ b/src/Import/include/FMI1/fmi1_import_capi.h @@ -40,18 +40,18 @@ Wrapper functions for the FMI 1.0 functions * @{ */ -/** \addtogroup fmi1_import_capi_const_destroy FMI 1.0 Constructor and Destructor +/** \addtogroup fmi1_import_capi_const_destroy FMI 1.0 Constructor and Destructor * \brief Functions for instantiating and freeing the container of the struct that is responsible for the FMI functions. * - * Before any of the FMI functions may be called, the construction function must instantiate a fmi_import_t module. - * After the fmi_import_t module has been succesfully instantiated, all the FMI functions can be called. To unload - * the FMI functions, the destroy functions shall be called. + * Before any of the FMI functions may be called, the construction function must instantiate a fmi_import_t module. + * After the fmi_import_t module has been succesfully instantiated, all the FMI functions can be called. To unload + * the FMI functions, the destroy functions shall be called. * - * \addtogroup fmi1_import_capi_me FMI 1.0 (ME) Model Exchange functions + * \addtogroup fmi1_import_capi_me FMI 1.0 (ME) Model Exchange functions * \brief List of Model Exchange wrapper functions. Common functions are not listed. - * \addtogroup fmi1_import_capi_cs FMI 1.0 (CS) Co-Simulation functions + * \addtogroup fmi1_import_capi_cs FMI 1.0 (CS) Co-Simulation functions * \brief List of Co-Simulation wrapper functions. Common functions are not listed. - * \addtogroup fmi1_import_capi_common FMI 1.0 (ME & CS) Common functions + * \addtogroup fmi1_import_capi_common FMI 1.0 (ME & CS) Common functions * \brief List of wrapper functions that are in common for both Model Exchange and Co-Simulation. */ @@ -367,7 +367,7 @@ FMILIB_EXPORT const char* fmi1_import_get_types_platform(fmi1_import_t* fmu); * @return Error status. Returnes jm_status_error if fmiInstantiateSlave returned NULL, otherwise jm_status_success. */ FMILIB_EXPORT jm_status_enu_t fmi1_import_instantiate_slave(fmi1_import_t* fmu, fmi1_string_t instanceName, fmi1_string_t fmuLocation, fmi1_string_t mimeType, - fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive); + fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive); /** * \brief Wrapper for the FMI function fmiInitializeSlave(...) @@ -409,7 +409,7 @@ FMILIB_EXPORT void fmi1_import_free_slave_instance(fmi1_import_t* fmu); * @param fmu A model description object returned by fmi1_import_parse_xml() that has loaded the FMI functions, see fmi1_import_create_dllfmu(). * @param vr Array of value references. * @param nvr Number of array elements. - * @param order Array of derivative orders. + * @param order Array of derivative orders. * @param value Array of variable values. * @return FMI status. */ @@ -421,7 +421,7 @@ FMILIB_EXPORT fmi1_status_t fmi1_import_set_real_input_derivatives(fmi1_import_t * @param fmu A model description object returned by fmi1_import_parse_xml() that has loaded the FMI functions, see fmi1_import_create_dllfmu(). * @param vr Array of value references. * @param nvr Number of array elements. - * @param order Array of derivative orders. + * @param order Array of derivative orders. * @param value (Output) Array of variable values. * @return FMI status. */ diff --git a/src/Import/include/FMI1/fmi1_import_convenience.h b/src/Import/include/FMI1/fmi1_import_convenience.h index fc51903d..caf72e1a 100644 --- a/src/Import/include/FMI1/fmi1_import_convenience.h +++ b/src/Import/include/FMI1/fmi1_import_convenience.h @@ -30,57 +30,57 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi1_import - @{ - \addtogroup fmi1_import_convenience Convenience functions. - @} - \addtogroup fmi1_import_convenience Convenience functions. - \brief The functions in this module are provided for convenience. The functionality - * is already available via other lower level functions. - - @{ - */ - + /** + \addtogroup fmi1_import + @{ + \addtogroup fmi1_import_convenience Convenience functions. + @} + \addtogroup fmi1_import_convenience Convenience functions. + \brief The functions in this module are provided for convenience. The functionality + * is already available via other lower level functions. + + @{ + */ + /** \brief Collection of counters providing model information. - */ + */ typedef struct { - /** \brief Number of constants */ - unsigned int num_constants; - /** \brief Number of parameters */ - unsigned int num_parameters; - - /** \brief Number of discrete variables */ - unsigned int num_discrete; - /** \brief Number of continuous variables */ - unsigned int num_continuous; - - /** \brief Number of inputs */ - unsigned int num_inputs; - /** \brief Number of outputs */ - unsigned int num_outputs; - /** \brief Number of internal variables */ - unsigned int num_internal; - /** \brief Number of variables with causality 'none'*/ - unsigned int num_causality_none; - - /** \brief Number of real variables*/ - unsigned int num_real_vars; - /** \brief Number of integer variables*/ - unsigned int num_integer_vars; - /** \brief Number of enumeration variables*/ - unsigned int num_enum_vars; - /** \brief Number of boolean variables*/ - unsigned int num_bool_vars; - /** \brief Number of string variables*/ - unsigned int num_string_vars; + /** \brief Number of constants */ + unsigned int num_constants; + /** \brief Number of parameters */ + unsigned int num_parameters; + + /** \brief Number of discrete variables */ + unsigned int num_discrete; + /** \brief Number of continuous variables */ + unsigned int num_continuous; + + /** \brief Number of inputs */ + unsigned int num_inputs; + /** \brief Number of outputs */ + unsigned int num_outputs; + /** \brief Number of internal variables */ + unsigned int num_internal; + /** \brief Number of variables with causality 'none'*/ + unsigned int num_causality_none; + + /** \brief Number of real variables*/ + unsigned int num_real_vars; + /** \brief Number of integer variables*/ + unsigned int num_integer_vars; + /** \brief Number of enumeration variables*/ + unsigned int num_enum_vars; + /** \brief Number of boolean variables*/ + unsigned int num_bool_vars; + /** \brief Number of string variables*/ + unsigned int num_string_vars; } fmi1_import_model_counts_t; /** - \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi1_import_model_counts_t struct. - \param fmu - An fmu object as returned by fmi1_import_parse_xml(). - \param counts - a pointer to a preallocated struct. + \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi1_import_model_counts_t struct. + \param fmu - An fmu object as returned by fmi1_import_parse_xml(). + \param counts - a pointer to a preallocated struct. */ FMILIB_EXPORT void fmi1_import_collect_model_counts(fmi1_import_t* fmu, fmi1_import_model_counts_t* counts); @@ -98,21 +98,21 @@ void fmi1_import_expand_variable_references(fmi1_import_t* fmu, const char* msgI /** - \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. - - The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then - forwards the message to the logger connected to the particular ::fmi1_import_t struct. The function is called by the FMU. - The FMU must be loaded with non-zero registerGlobally parameter of fmi1_import_create_dllfmu() in order to work. - 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. - Note that this function is not thread safe due to the use of the global list. + \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. + + The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then + forwards the message to the logger connected to the particular ::fmi1_import_t struct. The function is called by the FMU. + The FMU must be loaded with non-zero registerGlobally parameter of fmi1_import_create_dllfmu() in order to work. + 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. + Note that this function is not thread safe due to the use of the global list. */ FMILIB_EXPORT void fmi1_log_forwarding(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...); /** - \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. - - See fmi1_log_forwarding() for more information. + \brief An implementation of FMI 1.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. + + See fmi1_log_forwarding() for more information. */ FMILIB_EXPORT 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); @@ -125,12 +125,12 @@ void fmi1_default_callback_logger(fmi1_component_t c, fmi1_string_t instanceNam /** \brief Given ::fmi1_callback_functions_t logger (fmi1_logger), the ::jm_callbacks logger may be setup to redirect the messages to the fmi1_logger. 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. - \param cb FMI Library callbacks - \param fmiCallbacks FMI 1.0 standard callbacks + \param cb FMI Library callbacks + \param fmiCallbacks FMI 1.0 standard callbacks */ FMILIB_EXPORT void fmi1_import_init_logger(jm_callbacks* cb, fmi1_callback_functions_t* fmiCallbacks); -/** @} +/** @} */ diff --git a/src/Import/include/FMI1/fmi1_import_cosim.h b/src/Import/include/FMI1/fmi1_import_cosim.h index 345bb82b..94b3e6d8 100644 --- a/src/Import/include/FMI1/fmi1_import_cosim.h +++ b/src/Import/include/FMI1/fmi1_import_cosim.h @@ -22,35 +22,35 @@ extern "C" { #endif - /** - \file fmi1_import_cosim.h - Functions to retrieve co-simulation related information. - */ - /** - \addtogroup fmi1_import - @{ - \addtogroup fmi1_import_cosim Functions to retrieve co-simulation related information. - @} - */ - /** - \addtogroup fmi1_import_cosim - @{ - */ - - /** \brief Get the entry point.*/ + /** + \file fmi1_import_cosim.h + Functions to retrieve co-simulation related information. + */ + /** + \addtogroup fmi1_import + @{ + \addtogroup fmi1_import_cosim Functions to retrieve co-simulation related information. + @} + */ + /** + \addtogroup fmi1_import_cosim + @{ + */ + + /** \brief Get the entry point.*/ FMILIB_EXPORT const char* fmi1_import_get_entry_point(fmi1_import_t* ); - /** \brief Get mime type. */ + /** \brief Get mime type. */ FMILIB_EXPORT const char* fmi1_import_get_mime_type(fmi1_import_t* ); - /** \brief Get manual start flag. */ + /** \brief Get manual start flag. */ FMILIB_EXPORT int fmi1_import_get_manual_start(fmi1_import_t* ); - /** \brief Get the number of additional models specified. */ + /** \brief Get the number of additional models specified. */ FMILIB_EXPORT size_t fmi1_import_get_number_of_additional_models(fmi1_import_t* fmu); - /** \brief Get the name of an additional model. - @param fmu - the FMU processed - @param index - the index of an additional model (must be less than the number returned by fmi1_import_get_number_of_additional_models(). - */ + /** \brief Get the name of an additional model. + @param fmu - the FMU processed + @param index - the index of an additional model (must be less than the number returned by fmi1_import_get_number_of_additional_models(). + */ FMILIB_EXPORT const char* fmi1_import_get_additional_model_name(fmi1_import_t* fmu, size_t index); /** diff --git a/src/Import/include/FMI1/fmi1_import_type.h b/src/Import/include/FMI1/fmi1_import_type.h index fec928d1..2deedad9 100644 --- a/src/Import/include/FMI1/fmi1_import_type.h +++ b/src/Import/include/FMI1/fmi1_import_type.h @@ -29,11 +29,11 @@ extern "C" { #endif /** - \addtogroup fmi1_import - @{ - \addtogroup fmi1_import_typedef Support for processing variable types - @} - \addtogroup fmi1_import_typedef Support for processing variable types + \addtogroup fmi1_import + @{ + \addtogroup fmi1_import_typedef Support for processing variable types + @} + \addtogroup fmi1_import_typedef Support for processing variable types @{ */ /**@name Type definitions supporting structures*/ @@ -54,9 +54,9 @@ typedef struct fmi1_xml_type_definitions_t fmi1_import_type_definitions_t; FMILIB_EXPORT size_t fmi1_import_get_type_definition_number(fmi1_import_type_definitions_t* td); /** \brief Get a type definition specified by the index - @param td the type definition list object - @param index the index of type definition. Must be less than the numbere returned by fmi1_import_get_type_definition_number() - @return A type definition object or NULL if index is out of range. + @param td the type definition list object + @param index the index of type definition. Must be less than the numbere returned by fmi1_import_get_type_definition_number() + @return A type definition object or NULL if index is out of range. */ FMILIB_EXPORT fmi1_import_variable_typedef_t* fmi1_import_get_typedef(fmi1_import_type_definitions_t* td, unsigned int index); @@ -77,31 +77,31 @@ FMILIB_EXPORT fmi1_base_type_enu_t fmi1_import_get_base_type(fmi1_import_variabl /* Boolean and String has no extra attributes -> not needed*/ /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi1_import_real_typedef_t* fmi1_import_get_type_as_real(fmi1_import_variable_typedef_t*); /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi1_import_integer_typedef_t* fmi1_import_get_type_as_int(fmi1_import_variable_typedef_t*); /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi1_import_enumeration_typedef_t* fmi1_import_get_type_as_enum(fmi1_import_variable_typedef_t*); /** \brief Get the quantity associated with the type definition. - @return The quantity, or NULL-pointer if quantity is not defined (NULL-pointer is always returned for strings and booleans). + @return The quantity, or NULL-pointer if quantity is not defined (NULL-pointer is always returned for strings and booleans). */ FMILIB_EXPORT const char* fmi1_import_get_type_quantity(fmi1_import_variable_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or negated DBL_MAX as defined in + @return Either the value specified in the XML file or negated DBL_MAX as defined in */ FMILIB_EXPORT double fmi1_import_get_real_type_min(fmi1_import_real_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or DBL_MAX as defined in + @return Either the value specified in the XML file or DBL_MAX as defined in */ FMILIB_EXPORT double fmi1_import_get_real_type_max(fmi1_import_real_typedef_t*); @@ -115,25 +115,25 @@ FMILIB_EXPORT fmi1_import_unit_t* fmi1_import_get_real_type_unit(fmi1_import_rea FMILIB_EXPORT int fmi1_import_get_real_type_is_relative_quantity(fmi1_import_real_typedef_t*); /** \brief Get minimal value for the type. - - @return Either the value specified in the XML file or INT_MIN as defined in + + @return Either the value specified in the XML file or INT_MIN as defined in */ FMILIB_EXPORT int fmi1_import_get_integer_type_min(fmi1_import_integer_typedef_t*); /** \brief Get maximum value for the type - - @return Either the value specified in the XML file or INT_MAX as defined in + + @return Either the value specified in the XML file or INT_MAX as defined in */ FMILIB_EXPORT int fmi1_import_get_integer_type_max(fmi1_import_integer_typedef_t*); /** \brief Get minimal value for the type. - - @return Either the value specified in the XML file or 0 + + @return Either the value specified in the XML file or 0 */ FMILIB_EXPORT unsigned int fmi1_import_get_enum_type_min(fmi1_import_enumeration_typedef_t*); /** \brief Get maximum value for the type. - - @return Either the value specified in the XML file or INT_MAX as defined in + + @return Either the value specified in the XML file or INT_MAX as defined in */ FMILIB_EXPORT unsigned int fmi1_import_get_enum_type_max(fmi1_import_enumeration_typedef_t*); @@ -146,8 +146,8 @@ FMILIB_EXPORT const char* fmi1_import_get_enum_type_item_name(fmi1_import_enumer FMILIB_EXPORT const char* fmi1_import_get_enum_type_item_description(fmi1_import_enumeration_typedef_t*, unsigned int item); /** - \brief Get display unit associated with a real type definition. - @return Display unit object of NULL if none was given. + \brief Get display unit associated with a real type definition. + @return Display unit object of NULL if none was given. */ FMILIB_EXPORT fmi1_import_display_unit_t* fmi1_import_get_type_display_unit(fmi1_import_real_typedef_t*); diff --git a/src/Import/include/FMI1/fmi1_import_unit.h b/src/Import/include/FMI1/fmi1_import_unit.h index df494a13..2643bc46 100644 --- a/src/Import/include/FMI1/fmi1_import_unit.h +++ b/src/Import/include/FMI1/fmi1_import_unit.h @@ -26,14 +26,14 @@ extern "C" { #endif - /** - \addtogroup fmi1_import - @{ - \addtogroup fmi1_import_units Functions for handling unit definitions. - @} - \addtogroup fmi1_import_units Functions for handling unit definitions. - @{ - */ + /** + \addtogroup fmi1_import + @{ + \addtogroup fmi1_import_units Functions for handling unit definitions. + @} + \addtogroup fmi1_import_units Functions for handling unit definitions. + @{ + */ /**\name Structures encapsulating unit information */ /**@{ */ @@ -58,42 +58,42 @@ FMILIB_EXPORT const char* fmi1_import_get_unit_name(fmi1_import_unit_t*); FMILIB_EXPORT unsigned int fmi1_import_get_unit_display_unit_number(fmi1_import_unit_t*); /** \brief Get a display unit object by index. - @param index The index of display unit to be returned. Must be less than the number returned by fmi1_import_get_unit_display_unit_number() + @param index The index of display unit to be returned. Must be less than the number returned by fmi1_import_get_unit_display_unit_number() */ FMILIB_EXPORT fmi1_import_display_unit_t* fmi1_import_get_unit_display_unit(fmi1_import_unit_t*, size_t index); /** - \brief Get unit defition for a display unit. + \brief Get unit defition for a display unit. */ FMILIB_EXPORT fmi1_import_unit_t* fmi1_import_get_base_unit(fmi1_import_display_unit_t*); /** - \brief Get display unit name + \brief Get display unit name */ FMILIB_EXPORT const char* fmi1_import_get_display_unit_name(fmi1_import_display_unit_t*); /** - \brief Get the "gain" associated with the display unit. + \brief Get the "gain" associated with the display unit. */ FMILIB_EXPORT fmi1_real_t fmi1_import_get_display_unit_gain(fmi1_import_display_unit_t*); /** - \brief Get the "offset" associated with the display unit. + \brief Get the "offset" associated with the display unit. */ FMILIB_EXPORT fmi1_real_t fmi1_import_get_display_unit_offset(fmi1_import_display_unit_t*); /** - \brief Convert a value measured in "units" to a value measured with "display units" - @param value The value to be converted. - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "units" to a value measured with "display units" + @param value The value to be converted. + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi1_real_t fmi1_import_convert_to_display_unit(fmi1_real_t value , fmi1_import_display_unit_t* du, int isRelativeQuantity); /** - \brief Convert a value measured in "display units" to a value measured with "units" - @param value The value to be converted. - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "display units" to a value measured with "units" + @param value The value to be converted. + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi1_real_t fmi1_import_convert_from_display_unit(fmi1_real_t value, fmi1_import_display_unit_t* du, int isRelativeQuantity); /** @} */ diff --git a/src/Import/include/FMI1/fmi1_import_variable.h b/src/Import/include/FMI1/fmi1_import_variable.h index 6e34422b..3e73f2fd 100644 --- a/src/Import/include/FMI1/fmi1_import_variable.h +++ b/src/Import/include/FMI1/fmi1_import_variable.h @@ -30,23 +30,23 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi1_import - @{ - \addtogroup fmi1_import_variables Functions for handling variable definitions. - @} - \addtogroup fmi1_import_variables Functions for handling variable definitions. - \brief All the functions in this group take a pointer to ::fmi1_import_variable_t as a parameter. - A variable pointer may be obtained via a \ref fmi1_import_varlist module or via functions - fmi1_import_get_variable_by_name() and fmi1_import_get_variable_by_vr(). - @{ - */ - /**@name Scalar variable types */ + /** + \addtogroup fmi1_import + @{ + \addtogroup fmi1_import_variables Functions for handling variable definitions. + @} + \addtogroup fmi1_import_variables Functions for handling variable definitions. + \brief All the functions in this group take a pointer to ::fmi1_import_variable_t as a parameter. + A variable pointer may be obtained via a \ref fmi1_import_varlist module or via functions + fmi1_import_get_variable_by_name() and fmi1_import_get_variable_by_vr(). + @{ + */ + /**@name Scalar variable types */ /**@{ */ /** \brief General variable type. * * This type is convenient to unify all the variable list operations. -* However, typed variables are needed to support specific attributes. +* However, typed variables are needed to support specific attributes. */ typedef struct fmi1_xml_variable_t fmi1_import_variable_t; /** \brief Opaque real variable */ @@ -64,19 +64,19 @@ typedef struct fmi1_import_variable_list_t fmi1_import_variable_list_t; /**@} */ /** - \brief Get variable by variable name. - \param fmu - An fmu object as returned by fmi1_import_parse_xml(). - \param name - variable name - \return variable pointer. + \brief Get variable by variable name. + \param fmu - An fmu object as returned by fmi1_import_parse_xml(). + \param name - variable name + \return variable pointer. */ FMILIB_EXPORT fmi1_import_variable_t* fmi1_import_get_variable_by_name(fmi1_import_t* fmu, const char* name); /** - \brief Get variable by value reference. - \param fmu - An fmu object as returned by fmi1_import_parse_xml(). - \param baseType - basic data type - \param vr - value reference - \return variable pointer. + \brief Get variable by value reference. + \param fmu - An fmu object as returned by fmi1_import_parse_xml(). + \param baseType - basic data type + \param vr - value reference + \return variable pointer. */ 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); @@ -85,7 +85,7 @@ FMILIB_EXPORT fmi1_import_variable_t* fmi1_import_get_variable_by_vr(fmi1_import FMILIB_EXPORT const char* fmi1_import_get_variable_name(fmi1_import_variable_t*); /** \brief Get variable description. - @return Description string or empty string ("") if no description in the XML file was given. + @return Description string or empty string ("") if no description in the XML file was given. */ FMILIB_EXPORT const char* fmi1_import_get_variable_description(fmi1_import_variable_t*); @@ -93,7 +93,7 @@ FMILIB_EXPORT const char* fmi1_import_get_variable_description(fmi1_import_varia FMILIB_EXPORT fmi1_value_reference_t fmi1_import_get_variable_vr(fmi1_import_variable_t*); /** \brief For scalar variable gives the type definition is present - @return Pointer of a type #fmi1_import_variable_typedef_t object or NULL of not present. + @return Pointer of a type #fmi1_import_variable_typedef_t object or NULL of not present. */ FMILIB_EXPORT fmi1_import_variable_typedef_t* fmi1_import_get_variable_declared_type(fmi1_import_variable_t*); @@ -112,54 +112,54 @@ FMILIB_EXPORT fmi1_variability_enu_t fmi1_import_get_variability(fmi1_import_var FMILIB_EXPORT fmi1_causality_enu_t fmi1_import_get_causality(fmi1_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi1_import_real_variable_t* fmi1_import_get_variable_as_real(fmi1_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi1_import_integer_variable_t* fmi1_import_get_variable_as_integer(fmi1_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi1_import_enum_variable_t* fmi1_import_get_variable_as_enum(fmi1_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi1_import_string_variable_t* fmi1_import_get_variable_as_string(fmi1_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi1_import_bool_variable_t* fmi1_import_get_variable_as_boolean(fmi1_import_variable_t*); /** - \brief Get the variable "relativeQuantity" attribute. - @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. + \brief Get the variable "relativeQuantity" attribute. + @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. */ FMILIB_EXPORT fmi1_boolean_t fmi1_import_get_real_variable_relative_quantity(fmi1_import_real_variable_t* v); /** - \brief Get the variable start attribute. + \brief Get the variable start attribute. - @return The "start" attriburte as specified in the XML file or variable nominal value. + @return The "start" attriburte as specified in the XML file or variable nominal value. */ FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_start(fmi1_import_real_variable_t* v); /** \brief Get maximum value for the variable - @return Either the value specified in the XML file or DBL_MAX as defined in + @return Either the value specified in the XML file or DBL_MAX as defined in */ FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_max(fmi1_import_real_variable_t* v); /** \brief Get minimal value for the variable. - @return Either the value specified in the XML file or negated DBL_MAX as defined in + @return Either the value specified in the XML file or negated DBL_MAX as defined in */ FMILIB_EXPORT fmi1_real_t fmi1_import_get_real_variable_min(fmi1_import_real_variable_t* v); diff --git a/src/Import/include/FMI1/fmi1_import_variable_list.h b/src/Import/include/FMI1/fmi1_import_variable_list.h index 25845e21..b83cd2e6 100644 --- a/src/Import/include/FMI1/fmi1_import_variable_list.h +++ b/src/Import/include/FMI1/fmi1_import_variable_list.h @@ -31,7 +31,7 @@ extern "C" { /** \addtogroup fmi1_import @{ - \defgroup fmi1_import_varlist Handling of variable lists + \defgroup fmi1_import_varlist Handling of variable lists @} */ @@ -46,12 +46,12 @@ extern "C" { FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_alloc_variable_list(fmi1_import_t* fmu, size_t size); /** \brief Free a variable list. Note that variable lists are allocated dynamically and must be freed when not needed any longer - \param vl A variable list. + \param vl A variable list. */ FMILIB_EXPORT void fmi1_import_free_variable_list(fmi1_import_variable_list_t* vl); /** \brief Make a copy of the list. - \param vl A variable list. + \param vl A variable list. */ FMILIB_EXPORT fmi1_import_variable_list_t* fmi1_import_clone_variable_list(fmi1_import_variable_list_t* vl); diff --git a/src/Import/include/FMI1/fmi1_import_vendor_annotations.h b/src/Import/include/FMI1/fmi1_import_vendor_annotations.h index ee85cb54..ad476316 100644 --- a/src/Import/include/FMI1/fmi1_import_vendor_annotations.h +++ b/src/Import/include/FMI1/fmi1_import_vendor_annotations.h @@ -29,7 +29,7 @@ extern "C" { /** * \addtogroup fmi1_import * @{ -* \addtogroup fmi1_import_annotations Basic support for vendor annotations. +* \addtogroup fmi1_import_annotations Basic support for vendor annotations. *@} * \addtogroup fmi1_import_annotations Basic support for vendor annotations. @{ @@ -39,11 +39,11 @@ extern "C" { \name Vendor annotation supporting structures */ /**@{ */ - /** \brief Opaque list of vendor annotations. */ + /** \brief Opaque list of vendor annotations. */ typedef struct fmi1_xml_vendor_list_t fmi1_import_vendor_list_t; - /** \brief Opaque vendor object. */ + /** \brief Opaque vendor object. */ typedef struct fmi1_xml_vendor_t fmi1_import_vendor_t; - /** \brief Opaque annotation object. */ + /** \brief Opaque annotation object. */ typedef struct fmi1_xml_annotation_t fmi1_import_annotation_t; /**@} */ @@ -61,7 +61,7 @@ FMILIB_EXPORT unsigned int fmi1_import_get_number_of_vendor_annotations(fmi1_im /** \brief Get an annotation object for the vendor by index - Note: Annotations may later be used in other places but have common interface name-value + Note: Annotations may later be used in other places but have common interface name-value */ FMILIB_EXPORT fmi1_import_annotation_t* fmi1_import_get_vendor_annotation(fmi1_import_vendor_t*, unsigned int index); diff --git a/src/Import/include/FMI2/fmi2_import.h b/src/Import/include/FMI2/fmi2_import.h index 9573b996..2285e2e1 100644 --- a/src/Import/include/FMI2/fmi2_import.h +++ b/src/Import/include/FMI2/fmi2_import.h @@ -83,7 +83,7 @@ FMILIB_EXPORT const char* fmi2_import_get_last_error(fmi2_import_t* fmu); \brief Clear the error message. * @param fmu An FMU object as returned by fmi2_import_parse_xml(). * @return 0 if further processing is possible. If it returns 1 then the -* error was not recoverable. The \p fmu object should then be freed and recreated. +* error was not recoverable. The \p fmu object should then be freed and recreated. */ FMILIB_EXPORT int fmi2_import_clear_last_error(fmi2_import_t* fmu); @@ -240,7 +240,7 @@ FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_get_variable_aliases(fmi2 /** \brief Get the list of all the variables in the model. * @param fmu An FMU object as returned by fmi2_import_parse_xml(). * @param sortOrder Specifies the order of the variables in the list: - 0 - original order as found in the XML file; 1 - sorted alfabetically by variable name; 2 sorted by types/value references. + 0 - original order as found in the XML file; 1 - sorted alfabetically by variable name; 2 sorted by types/value references. * @return a variable list with all the variables in the model. * * Note that variable lists are allocated dynamically and must be freed when not needed any longer. @@ -282,19 +282,19 @@ FMILIB_EXPORT size_t fmi2_import_get_source_files_cs_num(fmi2_import_t* fmu); FMILIB_EXPORT const char* fmi2_import_get_source_file_cs(fmi2_import_t* fmu, size_t index); /** - \brief Get variable by variable name. - \param fmu - An fmu object as returned by fmi2_import_parse_xml(). - \param name - variable name - \return variable pointer. + \brief Get variable by variable name. + \param fmu - An fmu object as returned by fmi2_import_parse_xml(). + \param name - variable name + \return variable pointer. */ FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_variable_by_name(fmi2_import_t* fmu, const char* name); /** - \brief Get variable by value reference. - \param fmu - An fmu object as returned by fmi2_import_parse_xml(). - \param baseType - basic data type - \param vr - value reference - \return variable pointer. + \brief Get variable by value reference. + \param fmu - An fmu object as returned by fmi2_import_parse_xml(). + \param baseType - basic data type + \param vr - value reference + \return variable pointer. */ FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_variable_by_vr(fmi2_import_t* fmu, fmi2_base_type_enu_t baseType, fmi2_value_reference_t vr); diff --git a/src/Import/include/FMI2/fmi2_import_capi.h b/src/Import/include/FMI2/fmi2_import_capi.h index 82ab69f9..c5cd5251 100644 --- a/src/Import/include/FMI2/fmi2_import_capi.h +++ b/src/Import/include/FMI2/fmi2_import_capi.h @@ -40,18 +40,18 @@ Wrapper functions for the FMI 2.0 functions * @{ */ -/** \addtogroup fmi2_import_capi_const_destroy FMI 2.0 Constructor and Destructor +/** \addtogroup fmi2_import_capi_const_destroy FMI 2.0 Constructor and Destructor * \brief Functions for instantiating and freeing the container of the struct that is responsible for the FMI functions. * - * Before any of the FMI functions may be called, the construction function must instantiate a fmi_import_t module. - * After the fmi_import_t module has been succesfully instantiated, all the FMI functions can be called. To unload - * the FMI functions, the destroy functions shall be called. + * Before any of the FMI functions may be called, the construction function must instantiate a fmi_import_t module. + * After the fmi_import_t module has been succesfully instantiated, all the FMI functions can be called. To unload + * the FMI functions, the destroy functions shall be called. * - * \addtogroup fmi2_import_capi_me FMI 2.0 (ME) Model Exchange functions + * \addtogroup fmi2_import_capi_me FMI 2.0 (ME) Model Exchange functions * \brief List of Model Exchange wrapper functions. Common functions are not listed. - * \addtogroup fmi2_import_capi_cs FMI 2.0 (CS) Co-Simulation functions + * \addtogroup fmi2_import_capi_cs FMI 2.0 (CS) Co-Simulation functions * \brief List of Co-Simulation wrapper functions. Common functions are not listed. - * \addtogroup fmi2_import_capi_common FMI 2.0 (ME & CS) Common functions + * \addtogroup fmi2_import_capi_common FMI 2.0 (ME & CS) Common functions * \brief List of wrapper functions that are in common for both Model Exchange and Co-Simulation. */ @@ -479,7 +479,7 @@ FMILIB_EXPORT fmi2_status_t fmi2_import_get_nominals_of_continuous_states(fmi2_i * @param fmu A model description object returned by fmi2_import_parse_xml() that has loaded the FMI functions, see fmi2_import_create_dllfmu(). * @param vr Array of value references. * @param nvr Number of array elements. - * @param order Array of derivative orders. + * @param order Array of derivative orders. * @param value Array of variable values. * @return FMI status. */ @@ -491,7 +491,7 @@ FMILIB_EXPORT fmi2_status_t fmi2_import_set_real_input_derivatives(fmi2_import_t * @param fmu A model description object returned by fmi2_import_parse_xml() that has loaded the FMI functions, see fmi2_import_create_dllfmu(). * @param vr Array of value references. * @param nvr Number of array elements. - * @param order Array of derivative orders. + * @param order Array of derivative orders. * @param value (Output) Array of variable values. * @return FMI status. */ diff --git a/src/Import/include/FMI2/fmi2_import_convenience.h b/src/Import/include/FMI2/fmi2_import_convenience.h index 266a115b..03e50d37 100644 --- a/src/Import/include/FMI2/fmi2_import_convenience.h +++ b/src/Import/include/FMI2/fmi2_import_convenience.h @@ -31,61 +31,61 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi2_import - @{ - \addtogroup fmi2_import_convenience Convenience functions. - @} - \addtogroup fmi2_import_convenience Convenience functions. - \brief The functions in this module are provided for convenience. The functionality - * is already available via other lower level functions. - - @{ - */ + /** + \addtogroup fmi2_import + @{ + \addtogroup fmi2_import_convenience Convenience functions. + @} + \addtogroup fmi2_import_convenience Convenience functions. + \brief The functions in this module are provided for convenience. The functionality + * is already available via other lower level functions. + + @{ + */ /** \brief Collection of counters providing model information. - */ + */ typedef struct { - /** \brief Number of constants */ - unsigned int num_constants; - /** \brief Number of fixed */ - unsigned int num_fixed; - /** \brief Number of tunable */ - unsigned int num_tunable; - /** \brief Number of discrete variables */ - unsigned int num_discrete; - /** \brief Number of continuous variables */ - unsigned int num_continuous; - - /** \brief Number of parameters*/ - unsigned int num_parameters; - /** \brief Number of calculated parameters*/ - unsigned int num_calculated_parameters; - /** \brief Number of inputs */ - unsigned int num_inputs; - /** \brief Number of outputs */ - unsigned int num_outputs; - /** \brief Number of local variables */ - unsigned int num_local; - /** \brief Number of independent variables */ - unsigned int num_independent; - - /** \brief Number of real variables*/ - unsigned int num_real_vars; - /** \brief Number of integer variables*/ - unsigned int num_integer_vars; - /** \brief Number of enumeration variables*/ - unsigned int num_enum_vars; - /** \brief Number of boolean variables*/ - unsigned int num_bool_vars; - /** \brief Number of string variables*/ - unsigned int num_string_vars; + /** \brief Number of constants */ + unsigned int num_constants; + /** \brief Number of fixed */ + unsigned int num_fixed; + /** \brief Number of tunable */ + unsigned int num_tunable; + /** \brief Number of discrete variables */ + unsigned int num_discrete; + /** \brief Number of continuous variables */ + unsigned int num_continuous; + + /** \brief Number of parameters*/ + unsigned int num_parameters; + /** \brief Number of calculated parameters*/ + unsigned int num_calculated_parameters; + /** \brief Number of inputs */ + unsigned int num_inputs; + /** \brief Number of outputs */ + unsigned int num_outputs; + /** \brief Number of local variables */ + unsigned int num_local; + /** \brief Number of independent variables */ + unsigned int num_independent; + + /** \brief Number of real variables*/ + unsigned int num_real_vars; + /** \brief Number of integer variables*/ + unsigned int num_integer_vars; + /** \brief Number of enumeration variables*/ + unsigned int num_enum_vars; + /** \brief Number of boolean variables*/ + unsigned int num_bool_vars; + /** \brief Number of string variables*/ + unsigned int num_string_vars; } fmi2_import_model_counts_t; /** - \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi2_import_model_counts_t struct. - \param fmu - An fmu object as returned by fmi2_import_parse_xml(). - \param counts - a pointer to a preallocated struct. + \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi2_import_model_counts_t struct. + \param fmu - An fmu object as returned by fmi2_import_parse_xml(). + \param counts - a pointer to a preallocated struct. */ FMILIB_EXPORT void fmi2_import_collect_model_counts(fmi2_import_t* fmu, fmi2_import_model_counts_t* counts); @@ -103,21 +103,21 @@ void fmi2_import_expand_variable_references(fmi2_import_t* fmu, const char* msgI /** - \brief An implementation of FMI 2.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. - - The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then - forwards the message to the logger connected to the particular ::fmi2_import_t struct. The function is called by the FMU. - The FMU must be loaded with non-zero registerGlobally parameter of fmi2_import_create_dllfmu() in order to work. - 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. - Note that this function is not thread safe due to the use of the global list. + \brief An implementation of FMI 2.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. + + The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then + forwards the message to the logger connected to the particular ::fmi2_import_t struct. The function is called by the FMU. + The FMU must be loaded with non-zero registerGlobally parameter of fmi2_import_create_dllfmu() in order to work. + 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. + Note that this function is not thread safe due to the use of the global list. */ FMILIB_EXPORT void fmi2_log_forwarding(fmi2_component_t c, fmi2_string_t instanceName, fmi2_status_t status, fmi2_string_t category, fmi2_string_t message, ...); /** - \brief An implementation of FMI 2.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. - - See fmi2_log_forwarding() for more information. + \brief An implementation of FMI 2.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. + + See fmi2_log_forwarding() for more information. */ FMILIB_EXPORT 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); @@ -130,12 +130,12 @@ void fmi2_default_callback_logger(fmi2_component_t c, fmi2_string_t instanceNam /** \brief Given ::fmi2_callback_functions_t logger (fmi2_logger), the ::jm_callbacks logger may be setup to redirect the messages to the fmi2_logger. 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. - \param cb FMI Library callbacks - \param fmiCallbacks FMI 2.0 standard callbacks + \param cb FMI Library callbacks + \param fmiCallbacks FMI 2.0 standard callbacks */ FMILIB_EXPORT void fmi2_import_init_logger(jm_callbacks* cb, fmi2_callback_functions_t* fmiCallbacks); -/** @} +/** @} */ diff --git a/src/Import/include/FMI2/fmi2_import_type.h b/src/Import/include/FMI2/fmi2_import_type.h index 95d438cc..36d52027 100644 --- a/src/Import/include/FMI2/fmi2_import_type.h +++ b/src/Import/include/FMI2/fmi2_import_type.h @@ -29,11 +29,11 @@ extern "C" { #endif /** - \addtogroup fmi2_import - @{ - \addtogroup fmi2_import_typedef Support for processing variable types - @} - \addtogroup fmi2_import_typedef Support for processing variable types + \addtogroup fmi2_import + @{ + \addtogroup fmi2_import_typedef Support for processing variable types + @} + \addtogroup fmi2_import_typedef Support for processing variable types @{ */ /**@name Type definitions supporting structures*/ @@ -54,9 +54,9 @@ typedef struct fmi2_xml_type_definitions_t fmi2_import_type_definitions_t; FMILIB_EXPORT unsigned int fmi2_import_get_type_definition_number(fmi2_import_type_definitions_t* td); /** \brief Get a type definition specified by the index - @param td the type definition list object - @param index the index of type definition. Must be less than the number returned by fmi2_import_get_type_definition_number() - @return A type definition object or NULL if index is out of range. + @param td the type definition list object + @param index the index of type definition. Must be less than the number returned by fmi2_import_get_type_definition_number() + @return A type definition object or NULL if index is out of range. */ FMILIB_EXPORT fmi2_import_variable_typedef_t* fmi2_import_get_typedef(fmi2_import_type_definitions_t* td, unsigned int index); @@ -77,31 +77,31 @@ FMILIB_EXPORT fmi2_base_type_enu_t fmi2_import_get_base_type(fmi2_import_variabl /* Boolean and String has no extra attributes -> not needed*/ /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi2_import_real_typedef_t* fmi2_import_get_type_as_real(fmi2_import_variable_typedef_t*); /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi2_import_integer_typedef_t* fmi2_import_get_type_as_int(fmi2_import_variable_typedef_t*); /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi2_import_enumeration_typedef_t* fmi2_import_get_type_as_enum(fmi2_import_variable_typedef_t*); /** \brief Get the quantity associated with the type definition. - @return The quantity, or NULL-pointer if quantity is not defined (NULL-pointer is always returned for strings and booleans). + @return The quantity, or NULL-pointer if quantity is not defined (NULL-pointer is always returned for strings and booleans). */ FMILIB_EXPORT const char* fmi2_import_get_type_quantity(fmi2_import_variable_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or negated DBL_MAX as defined in + @return Either the value specified in the XML file or negated DBL_MAX as defined in */ FMILIB_EXPORT double fmi2_import_get_real_type_min(fmi2_import_real_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or DBL_MAX as defined in + @return Either the value specified in the XML file or DBL_MAX as defined in */ FMILIB_EXPORT double fmi2_import_get_real_type_max(fmi2_import_real_typedef_t*); @@ -118,25 +118,25 @@ FMILIB_EXPORT int fmi2_import_get_real_type_is_relative_quantity(fmi2_import_rea FMILIB_EXPORT int fmi2_import_get_real_type_is_unbounded(fmi2_import_real_typedef_t*); /** \brief Get minimal value for the type. - - @return Either the value specified in the XML file or INT_MIN as defined in + + @return Either the value specified in the XML file or INT_MIN as defined in */ FMILIB_EXPORT int fmi2_import_get_integer_type_min(fmi2_import_integer_typedef_t*); /** \brief Get maximum value for the type - - @return Either the value specified in the XML file or INT_MAX as defined in + + @return Either the value specified in the XML file or INT_MAX as defined in */ FMILIB_EXPORT int fmi2_import_get_integer_type_max(fmi2_import_integer_typedef_t*); /** \brief Get minimal value for the type. - - @return Either the value specified in the XML file or 0 + + @return Either the value specified in the XML file or 0 */ FMILIB_EXPORT unsigned int fmi2_import_get_enum_type_min(fmi2_import_enumeration_typedef_t*); /** \brief Get maximum value for the type. - - @return Either the value specified in the XML file or INT_MAX as defined in + + @return Either the value specified in the XML file or INT_MAX as defined in */ FMILIB_EXPORT unsigned int fmi2_import_get_enum_type_max(fmi2_import_enumeration_typedef_t*); @@ -156,8 +156,8 @@ FMILIB_EXPORT const char* fmi2_import_get_enum_type_item_description(fmi2_import FMILIB_EXPORT const char* fmi2_import_get_enum_type_value_name(fmi2_import_enumeration_typedef_t* t, int value); /** - \brief Get display unit associated with a real type definition. - @return Display unit object of NULL if none was given. + \brief Get display unit associated with a real type definition. + @return Display unit object of NULL if none was given. */ FMILIB_EXPORT fmi2_import_display_unit_t* fmi2_import_get_type_display_unit(fmi2_import_real_typedef_t*); diff --git a/src/Import/include/FMI2/fmi2_import_unit.h b/src/Import/include/FMI2/fmi2_import_unit.h index 6ab809ca..453abade 100644 --- a/src/Import/include/FMI2/fmi2_import_unit.h +++ b/src/Import/include/FMI2/fmi2_import_unit.h @@ -26,14 +26,14 @@ extern "C" { #endif - /** - \addtogroup fmi2_import - @{ - \addtogroup fmi2_import_units Functions for handling unit definitions. - @} - \addtogroup fmi2_import_units Functions for handling unit definitions. - @{ - */ + /** + \addtogroup fmi2_import + @{ + \addtogroup fmi2_import_units Functions for handling unit definitions. + @} + \addtogroup fmi2_import_units Functions for handling unit definitions. + @{ + */ /**\name Structures encapsulating unit information */ /**@{ */ @@ -58,69 +58,69 @@ FMILIB_EXPORT const char* fmi2_import_get_unit_name(fmi2_import_unit_t*); FMILIB_EXPORT unsigned int fmi2_import_get_unit_display_unit_number(fmi2_import_unit_t*); /** - \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit. + \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit. */ FMILIB_EXPORT const int* fmi2_import_get_SI_unit_exponents(fmi2_import_unit_t*); /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ FMILIB_EXPORT double fmi2_import_get_SI_unit_factor(fmi2_import_unit_t*); /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ FMILIB_EXPORT double fmi2_import_get_SI_unit_offset(fmi2_import_unit_t*); /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ FMILIB_EXPORT double fmi2_import_convert_to_SI_base_unit(double, fmi2_import_unit_t*); /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ FMILIB_EXPORT double fmi2_import_convert_from_SI_base_unit(double, fmi2_import_unit_t*); /** \brief Get a display unit object by index. - @param index The index of display unit to be returned. Must be less than the number returned by fmi2_import_get_unit_display_unit_number() + @param index The index of display unit to be returned. Must be less than the number returned by fmi2_import_get_unit_display_unit_number() */ FMILIB_EXPORT fmi2_import_display_unit_t* fmi2_import_get_unit_display_unit(fmi2_import_unit_t*, size_t index); /** - \brief Get unit defition for a display unit. + \brief Get unit defition for a display unit. */ FMILIB_EXPORT fmi2_import_unit_t* fmi2_import_get_base_unit(fmi2_import_display_unit_t*); /** - \brief Get display unit name + \brief Get display unit name */ FMILIB_EXPORT const char* fmi2_import_get_display_unit_name(fmi2_import_display_unit_t*); /** - \brief Get the "factor" associated with the display unit. + \brief Get the "factor" associated with the display unit. */ FMILIB_EXPORT fmi2_real_t fmi2_import_get_display_unit_factor(fmi2_import_display_unit_t*); /** - \brief Get the "offset" associated with the display unit. + \brief Get the "offset" associated with the display unit. */ FMILIB_EXPORT fmi2_real_t fmi2_import_get_display_unit_offset(fmi2_import_display_unit_t*); /** - \brief Convert a value measured in "units" to a value measured with "display units" - @param value The value to be converted. - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "units" to a value measured with "display units" + @param value The value to be converted. + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi2_real_t fmi2_import_convert_to_display_unit(fmi2_real_t value , fmi2_import_display_unit_t* du, int isRelativeQuantity); /** - \brief Convert a value measured in "display units" to a value measured with "units" - @param value The value to be converted. - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "display units" to a value measured with "units" + @param value The value to be converted. + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi2_real_t fmi2_import_convert_from_display_unit(fmi2_real_t value, fmi2_import_display_unit_t* du, int isRelativeQuantity); /** @} */ diff --git a/src/Import/include/FMI2/fmi2_import_variable.h b/src/Import/include/FMI2/fmi2_import_variable.h index 7e75a3a0..f7c48c91 100644 --- a/src/Import/include/FMI2/fmi2_import_variable.h +++ b/src/Import/include/FMI2/fmi2_import_variable.h @@ -30,23 +30,23 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi2_import - @{ - \addtogroup fmi2_import_variables Functions for handling variable definitions. - @} - \addtogroup fmi2_import_variables Functions for handling variable definitions. - \brief All the functions in this group take a pointer to ::fmi2_import_variable_t as a parameter. - A variable pointer may be obtained via a \ref fmi2_import_varlist module or via functions - fmi2_import_get_variable_by_name() and fmi2_import_get_variable_by_vr(). - @{ - */ - /**@name Scalar variable types */ + /** + \addtogroup fmi2_import + @{ + \addtogroup fmi2_import_variables Functions for handling variable definitions. + @} + \addtogroup fmi2_import_variables Functions for handling variable definitions. + \brief All the functions in this group take a pointer to ::fmi2_import_variable_t as a parameter. + A variable pointer may be obtained via a \ref fmi2_import_varlist module or via functions + fmi2_import_get_variable_by_name() and fmi2_import_get_variable_by_vr(). + @{ + */ + /**@name Scalar variable types */ /**@{ */ /** \brief General variable type. * * This type is convenient to unify all the variable list operations. -* However, typed variables are needed to support specific attributes. +* However, typed variables are needed to support specific attributes. */ typedef struct fmi2_xml_variable_t fmi2_import_variable_t; /** \brief Opaque real variable */ @@ -68,7 +68,7 @@ typedef struct fmi2_import_variable_list_t fmi2_import_variable_list_t; FMILIB_EXPORT const char* fmi2_import_get_variable_name(fmi2_import_variable_t*); /** \brief Get variable description. - @return Description string or empty string ("") if no description in the XML file was given. + @return Description string or empty string ("") if no description in the XML file was given. */ FMILIB_EXPORT const char* fmi2_import_get_variable_description(fmi2_import_variable_t*); @@ -76,7 +76,7 @@ FMILIB_EXPORT const char* fmi2_import_get_variable_description(fmi2_import_varia FMILIB_EXPORT fmi2_value_reference_t fmi2_import_get_variable_vr(fmi2_import_variable_t*); /** \brief For scalar variable gives the type definition is present - @return Pointer of a type #fmi2_import_variable_typedef_t object or NULL of not present. + @return Pointer of a type #fmi2_import_variable_typedef_t object or NULL of not present. */ FMILIB_EXPORT fmi2_import_variable_typedef_t* fmi2_import_get_variable_declared_type(fmi2_import_variable_t*); @@ -105,55 +105,55 @@ FMILIB_EXPORT fmi2_import_variable_t* fmi2_import_get_previous(fmi2_import_varia /** \brief Get the canHandleMultipleSetPerTimeInstant flag for a variable. - @return For inputs: If false, then only one fmiSetXXX call is allowed at + @return For inputs: If false, then only one fmiSetXXX call is allowed at one super dense time instant. In other words, this input is not allowed to appear in an algebraic loop. */ FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_canHandleMultipleSetPerTimeInstant(fmi2_import_variable_t* v); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi2_import_real_variable_t* fmi2_import_get_variable_as_real(fmi2_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi2_import_integer_variable_t* fmi2_import_get_variable_as_integer(fmi2_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi2_import_enum_variable_t* fmi2_import_get_variable_as_enum(fmi2_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi2_import_string_variable_t* fmi2_import_get_variable_as_string(fmi2_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi2_import_bool_variable_t* fmi2_import_get_variable_as_boolean(fmi2_import_variable_t*); /** - \brief Get the variable "relativeQuantity" attribute. - @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. + \brief Get the variable "relativeQuantity" attribute. + @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. */ FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_real_variable_relative_quantity(fmi2_import_real_variable_t* v); /** - \brief Get the variable "unbounded" attribute. - @return The "unbounded" attribute as specified in the XML file. False if undefined. + \brief Get the variable "unbounded" attribute. + @return The "unbounded" attribute as specified in the XML file. False if undefined. */ FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_real_variable_unbounded(fmi2_import_real_variable_t* v); /** - \brief Get the variable start attribute. + \brief Get the variable start attribute. - @return The "start" attribute as specified in the XML file or variable nominal value. + @return The "start" attribute as specified in the XML file or variable nominal value. */ FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_start(fmi2_import_real_variable_t* v); @@ -167,19 +167,19 @@ FMILIB_EXPORT fmi2_import_real_variable_t* fmi2_import_get_real_variable_derivat /** \brief Get the reinit flag for a real variable. - @return True if the real variable may change value at events. + @return True if the real variable may change value at events. */ FMILIB_EXPORT fmi2_boolean_t fmi2_import_get_real_variable_reinit(fmi2_import_real_variable_t* v); /** \brief Get maximum value for the variable - @return Either the value specified in the XML file or DBL_MAX as defined in + @return Either the value specified in the XML file or DBL_MAX as defined in */ FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_max(fmi2_import_real_variable_t* v); /** \brief Get minimal value for the variable. - @return Either the value specified in the XML file or negated DBL_MAX as defined in + @return Either the value specified in the XML file or negated DBL_MAX as defined in */ FMILIB_EXPORT fmi2_real_t fmi2_import_get_real_variable_min(fmi2_import_real_variable_t* v); diff --git a/src/Import/include/FMI2/fmi2_import_variable_list.h b/src/Import/include/FMI2/fmi2_import_variable_list.h index 11444c4d..05729666 100644 --- a/src/Import/include/FMI2/fmi2_import_variable_list.h +++ b/src/Import/include/FMI2/fmi2_import_variable_list.h @@ -31,7 +31,7 @@ extern "C" { /** \addtogroup fmi2_import @{ - \defgroup fmi2_import_varlist Handling of variable lists + \defgroup fmi2_import_varlist Handling of variable lists @} */ @@ -46,12 +46,12 @@ extern "C" { FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_alloc_variable_list(fmi2_import_t* fmu, size_t size); /** \brief Free a variable list. Note that variable lists are allocated dynamically and must be freed when not needed any longer - \param vl A variable list. + \param vl A variable list. */ FMILIB_EXPORT void fmi2_import_free_variable_list(fmi2_import_variable_list_t* vl); /** \brief Make a copy of the list. - \param vl A variable list. + \param vl A variable list. */ FMILIB_EXPORT fmi2_import_variable_list_t* fmi2_import_clone_variable_list(fmi2_import_variable_list_t* vl); diff --git a/src/Import/include/FMI3/fmi3_import.h b/src/Import/include/FMI3/fmi3_import.h index 9880b43e..502424b2 100644 --- a/src/Import/include/FMI3/fmi3_import.h +++ b/src/Import/include/FMI3/fmi3_import.h @@ -52,9 +52,9 @@ extern "C" { @{ */ -/** \addtogroup fmi3_import_init Constuction, destruction and error handling - * \addtogroup fmi3_import_gen General information retrieval - * \addtogroup fmi3_import_capi Interface to the standard FMI 3.0 "C" API +/** \addtogroup fmi3_import_init Constuction, destruction and error handling + * \addtogroup fmi3_import_gen General information retrieval + * \addtogroup fmi3_import_capi Interface to the standard FMI 3.0 "C" API * \brief Convenient functions for calling the FMI functions. This interface wrappes the "C" API. */ /** @} */ @@ -83,7 +83,7 @@ FMILIB_EXPORT const char* fmi3_import_get_last_error(fmi3_import_t* fmu); \brief Clear the error message. * @param fmu An FMU object as returned by fmi3_import_parse_xml(). * @return 0 if further processing is possible. If it returns 1 then the -* error was not recoverable. The \p fmu object should then be freed and recreated. +* error was not recoverable. The \p fmu object should then be freed and recreated. */ FMILIB_EXPORT int fmi3_import_clear_last_error(fmi3_import_t* fmu); @@ -241,7 +241,7 @@ FMILIB_EXPORT fmi3_import_variable_list_t* fmi3_import_get_variable_aliases(fmi3 /** \brief Get the list of all the variables in the model. * @param fmu An FMU object as returned by fmi3_import_parse_xml(). * @param sortOrder Specifies the order of the variables in the list: - 0 - original order as found in the XML file; 1 - sorted alfabetically by variable name; 2 sorted by types/value references. + 0 - original order as found in the XML file; 1 - sorted alfabetically by variable name; 2 sorted by types/value references. * @return a variable list with all the variables in the model. * * Note that variable lists are allocated dynamically and must be freed when not needed any longer. @@ -283,19 +283,19 @@ FMILIB_EXPORT size_t fmi3_import_get_source_files_cs_num(fmi3_import_t* fmu); FMILIB_EXPORT const char* fmi3_import_get_source_file_cs(fmi3_import_t* fmu, size_t index); /** - \brief Get variable by variable name. - \param fmu - An fmu object as returned by fmi3_import_parse_xml(). - \param name - variable name - \return variable pointer. + \brief Get variable by variable name. + \param fmu - An fmu object as returned by fmi3_import_parse_xml(). + \param name - variable name + \return variable pointer. */ FMILIB_EXPORT fmi3_import_variable_t* fmi3_import_get_variable_by_name(fmi3_import_t* fmu, const char* name); /** - \brief Get variable by value reference. - \param fmu - An fmu object as returned by fmi3_import_parse_xml(). - \param baseType - basic data type - \param vr - value reference - \return variable pointer. + \brief Get variable by value reference. + \param fmu - An fmu object as returned by fmi3_import_parse_xml(). + \param baseType - basic data type + \param vr - value reference + \return variable pointer. */ FMILIB_EXPORT fmi3_import_variable_t* fmi3_import_get_variable_by_vr(fmi3_import_t* fmu, fmi3_base_type_enu_t baseType, fmi3_value_reference_t vr); diff --git a/src/Import/include/FMI3/fmi3_import_capi.h b/src/Import/include/FMI3/fmi3_import_capi.h index d3643f78..92900a62 100644 --- a/src/Import/include/FMI3/fmi3_import_capi.h +++ b/src/Import/include/FMI3/fmi3_import_capi.h @@ -40,18 +40,18 @@ Wrapper functions for the FMI 3.0 functions * @{ */ -/** \addtogroup fmi3_import_capi_const_destroy FMI 3.0 Constructor and Destructor +/** \addtogroup fmi3_import_capi_const_destroy FMI 3.0 Constructor and Destructor * \brief Functions for instantiating and freeing the container of the struct that is responsible for the FMI functions. * - * Before any of the FMI functions may be called, the construction function must instantiate a fmi_import_t module. - * After the fmi_import_t module has been succesfully instantiated, all the FMI functions can be called. To unload - * the FMI functions, the destroy functions shall be called. + * Before any of the FMI functions may be called, the construction function must instantiate a fmi_import_t module. + * After the fmi_import_t module has been succesfully instantiated, all the FMI functions can be called. To unload + * the FMI functions, the destroy functions shall be called. * - * \addtogroup fmi3_import_capi_me FMI 3.0 (ME) Model Exchange functions + * \addtogroup fmi3_import_capi_me FMI 3.0 (ME) Model Exchange functions * \brief List of Model Exchange wrapper functions. Common functions are not listed. - * \addtogroup fmi3_import_capi_cs FMI 3.0 (CS) Co-Simulation functions + * \addtogroup fmi3_import_capi_cs FMI 3.0 (CS) Co-Simulation functions * \brief List of Co-Simulation wrapper functions. Common functions are not listed. - * \addtogroup fmi3_import_capi_common FMI 3.0 (ME & CS) Common functions + * \addtogroup fmi3_import_capi_common FMI 3.0 (ME & CS) Common functions * \brief List of wrapper functions that are in common for both Model Exchange and Co-Simulation. */ diff --git a/src/Import/include/FMI3/fmi3_import_convenience.h b/src/Import/include/FMI3/fmi3_import_convenience.h index 68cdd57b..58886b53 100644 --- a/src/Import/include/FMI3/fmi3_import_convenience.h +++ b/src/Import/include/FMI3/fmi3_import_convenience.h @@ -31,87 +31,87 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi3_import - @{ - \addtogroup fmi3_import_convenience Convenience functions. - @} - \addtogroup fmi3_import_convenience Convenience functions. - \brief The functions in this module are provided for convenience. The functionality - * is already available via other lower level functions. - - @{ - */ + /** + \addtogroup fmi3_import + @{ + \addtogroup fmi3_import_convenience Convenience functions. + @} + \addtogroup fmi3_import_convenience Convenience functions. + \brief The functions in this module are provided for convenience. The functionality + * is already available via other lower level functions. + + @{ + */ /** \brief Collection of counters providing model information. - */ + */ typedef struct { - /** \brief Number of constants */ - unsigned int num_constants; - /** \brief Number of fixed */ - unsigned int num_fixed; - /** \brief Number of tunable */ - unsigned int num_tunable; - /** \brief Number of discrete variables */ - unsigned int num_discrete; - /** \brief Number of continuous variables */ - unsigned int num_continuous; - - /** \brief Number of parameters*/ - unsigned int num_parameters; - /** \brief Number of calculated parameters*/ - unsigned int num_calculated_parameters; - /** \brief Number of inputs */ - unsigned int num_inputs; - /** \brief Number of outputs */ - unsigned int num_outputs; - /** \brief Number of local variables */ - unsigned int num_local; - /** \brief Number of independent variables */ - unsigned int num_independent; - - /** \brief Number of float64 variables*/ - unsigned int num_float64_vars; - /** \brief Number of float32 variables*/ - unsigned int num_float32_vars; - - /** \brief Number of int64 variables*/ - unsigned int num_int64_vars; - /** \brief Number of int32 variables*/ - unsigned int num_int32_vars; - /** \brief Number of int16 variables*/ - unsigned int num_int16_vars; - /** \brief Number of int8 variables*/ - unsigned int num_int8_vars; - /** \brief Number of int64 variables*/ - unsigned int num_uint64_vars; - /** \brief Number of uint32 variables*/ - unsigned int num_uint32_vars; - /** \brief Number of uint16 variables*/ - unsigned int num_uint16_vars; - /** \brief Number of uint8 variables*/ - unsigned int num_uint8_vars; - - /** \brief Number of enumeration variables*/ - unsigned int num_enum_vars; - /** \brief Number of boolean variables*/ - unsigned int num_bool_vars; - /** \brief Number of string variables*/ - unsigned int num_string_vars; + /** \brief Number of constants */ + unsigned int num_constants; + /** \brief Number of fixed */ + unsigned int num_fixed; + /** \brief Number of tunable */ + unsigned int num_tunable; + /** \brief Number of discrete variables */ + unsigned int num_discrete; + /** \brief Number of continuous variables */ + unsigned int num_continuous; + + /** \brief Number of parameters*/ + unsigned int num_parameters; + /** \brief Number of calculated parameters*/ + unsigned int num_calculated_parameters; + /** \brief Number of inputs */ + unsigned int num_inputs; + /** \brief Number of outputs */ + unsigned int num_outputs; + /** \brief Number of local variables */ + unsigned int num_local; + /** \brief Number of independent variables */ + unsigned int num_independent; + + /** \brief Number of float64 variables*/ + unsigned int num_float64_vars; + /** \brief Number of float32 variables*/ + unsigned int num_float32_vars; + + /** \brief Number of int64 variables*/ + unsigned int num_int64_vars; + /** \brief Number of int32 variables*/ + unsigned int num_int32_vars; + /** \brief Number of int16 variables*/ + unsigned int num_int16_vars; + /** \brief Number of int8 variables*/ + unsigned int num_int8_vars; + /** \brief Number of int64 variables*/ + unsigned int num_uint64_vars; + /** \brief Number of uint32 variables*/ + unsigned int num_uint32_vars; + /** \brief Number of uint16 variables*/ + unsigned int num_uint16_vars; + /** \brief Number of uint8 variables*/ + unsigned int num_uint8_vars; + + /** \brief Number of enumeration variables*/ + unsigned int num_enum_vars; + /** \brief Number of boolean variables*/ + unsigned int num_bool_vars; + /** \brief Number of string variables*/ + unsigned int num_string_vars; } fmi3_import_model_counts_t; /** \brief Struct for initializing #fmi3_logger. */ typedef struct { - const fmi3_instance_environment_t instanceEnvironment; - const fmi3_log_message_callback_ft logMessage; + const fmi3_instance_environment_t instanceEnvironment; + const fmi3_log_message_callback_ft logMessage; } fmi3_logger_context_t; /** - \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi3_import_model_counts_t struct. - \param fmu - An fmu object as returned by fmi3_import_parse_xml(). - \param counts - a pointer to a preallocated struct. + \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi3_import_model_counts_t struct. + \param fmu - An fmu object as returned by fmi3_import_parse_xml(). + \param counts - a pointer to a preallocated struct. */ FMILIB_EXPORT void fmi3_import_collect_model_counts(fmi3_import_t* fmu, fmi3_import_model_counts_t* counts); @@ -128,29 +128,29 @@ FMILIB_EXPORT void fmi3_import_expand_variable_references(fmi3_import_t* fmu, const char* msgIn, char* msgOut, size_t maxMsgSize); /** - \brief Default function for fmi3CallbackAllocateMemory. + \brief Default function for fmi3CallbackAllocateMemory. - Calls calloc from stdlib.h. Argument 'instEnv' is not used. + Calls calloc from stdlib.h. Argument 'instEnv' is not used. */ FMILIB_EXPORT void* fmi3_callback_allocate_memory_default(fmi3_instance_environment_t instEnv, size_t nobj, size_t size); /** - \brief Default function for fmi3CallbackFreeMemory. + \brief Default function for fmi3CallbackFreeMemory. - Calls free from stdlib.h. Argument 'instEnv' is not used. + Calls free from stdlib.h. Argument 'instEnv' is not used. */ FMILIB_EXPORT void fmi3_callback_free_memory_default(fmi3_instance_environment_t instEnv, void* obj); /** - \brief An implementation of FMI 3.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. + \brief An implementation of FMI 3.0 logger that forwards the messages to logger function inside ::jm_callbacks structure. - The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then - forwards the message to the logger connected to the particular ::fmi3_import_t struct. The function is called by the FMU. - The FMU must be loaded with non-zero registerGlobally parameter of fmi3_import_create_dllfmu() in order to work. - If no matching ::fmi3_import_t struct is found on the global list then jm_get_default_callbacks() is used to get the default logger. - Note that this function is not thread safe due to the use of the global list. + The function is using a global array of active FMUs to find out which FMU is sending the log messege. It then + forwards the message to the logger connected to the particular ::fmi3_import_t struct. The function is called by the FMU. + The FMU must be loaded with non-zero registerGlobally parameter of fmi3_import_create_dllfmu() in order to work. + If no matching ::fmi3_import_t struct is found on the global list then jm_get_default_callbacks() is used to get the default logger. + Note that this function is not thread safe due to the use of the global list. */ FMILIB_EXPORT void fmi3_log_forwarding(fmi3_instance_environment_t inst, fmi3_status_t status, fmi3_string_t category, fmi3_string_t message); @@ -162,13 +162,13 @@ void fmi3_default_callback_logger(fmi3_instance_environment_t inst, fmi3_string /** \brief Given ::fmi3_callback_functions_t logger (fmi3_logger), the ::jm_callbacks logger may be setup to redirect the messages to the fmi3_logger. The functions sets up the redirection. Note that the context field in ::jm_callbacks is set to point to the provided ::fmi3_callback_functions_t. - \param cb FMI Library callbacks - \param fmiCallbacks FMI 3.0 standard callbacks + \param cb FMI Library callbacks + \param fmiCallbacks FMI 3.0 standard callbacks */ FMILIB_EXPORT void fmi3_import_init_logger(jm_callbacks* cb, fmi3_logger_context_t* loggerCallbacks); -/** @} */ +/** @} */ /** @} */ diff --git a/src/Import/include/FMI3/fmi3_import_dimension_list.h b/src/Import/include/FMI3/fmi3_import_dimension_list.h index 314eed35..e1e0d73b 100644 --- a/src/Import/include/FMI3/fmi3_import_dimension_list.h +++ b/src/Import/include/FMI3/fmi3_import_dimension_list.h @@ -45,7 +45,7 @@ extern "C" { fmi3_import_dimension_list_t* fmi3_import_alloc_dimension_list(fmi3_import_t* fmu, fmi3_import_variable_t* v); /** \brief Free a dimension list. Note that dimension lists are allocated dynamically and must be freed when not needed any longer - \param dl A dimension list. + \param dl A dimension list. */ FMILIB_EXPORT void fmi3_import_free_dimension_list(fmi3_import_dimension_list_t* dl); diff --git a/src/Import/include/FMI3/fmi3_import_type.h b/src/Import/include/FMI3/fmi3_import_type.h index 7cb33e2e..7a12bd16 100644 --- a/src/Import/include/FMI3/fmi3_import_type.h +++ b/src/Import/include/FMI3/fmi3_import_type.h @@ -29,11 +29,11 @@ extern "C" { #endif /** - \addtogroup fmi3_import - @{ - \addtogroup fmi3_import_typedef Support for processing variable types - @} - \addtogroup fmi3_import_typedef Support for processing variable types + \addtogroup fmi3_import + @{ + \addtogroup fmi3_import_typedef Support for processing variable types + @} + \addtogroup fmi3_import_typedef Support for processing variable types @{ */ /**@name Type definitions supporting structures*/ @@ -54,10 +54,10 @@ typedef struct fmi3_xml_type_definitions_t fmi3_import_type_definitions_t; FMILIB_EXPORT unsigned int fmi3_import_get_type_definition_number(fmi3_import_type_definitions_t* td); /** \brief Get a type definition specified by the index. Parameter 'index' does not reflect the index in the XML, but the - index in an internal list of type definitions. - @param td the type definition list object - @param index the index of type definition. Must be less than the number returned by #fmi3_import_get_type_definition_number - @return A type definition object or NULL if index is out of range. + index in an internal list of type definitions. + @param td the type definition list object + @param index the index of type definition. Must be less than the number returned by #fmi3_import_get_type_definition_number + @return A type definition object or NULL if index is out of range. */ FMILIB_EXPORT fmi3_import_variable_typedef_t* fmi3_import_get_typedef(fmi3_import_type_definitions_t* td, unsigned int index); @@ -75,36 +75,36 @@ FMILIB_EXPORT fmi3_base_type_enu_t fmi3_import_get_base_type(fmi3_import_variabl /* Boolean and String has no extra attributes -> not needed*/ /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi3_import_float_typedef_t* fmi3_import_get_type_as_float(fmi3_import_variable_typedef_t*); /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi3_import_int_typedef_t* fmi3_import_get_type_as_int(fmi3_import_variable_typedef_t*); /** \brief Cast the general type definition object to an object with a specific base type - @return Pointer to the specific type object or NULL if base type does not match. + @return Pointer to the specific type object or NULL if base type does not match. */ FMILIB_EXPORT fmi3_import_enumeration_typedef_t* fmi3_import_get_type_as_enum(fmi3_import_variable_typedef_t*); /** \brief Get the quantity associated with the type definition. - @return The quantity, or NULL-pointer if quantity is not defined (NULL-pointer is always returned for strings and - booleans). + @return The quantity, or NULL-pointer if quantity is not defined (NULL-pointer is always returned for strings and + booleans). */ FMILIB_EXPORT const char* fmi3_import_get_type_quantity(fmi3_import_variable_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or negated DBL_MAX as defined in + @return Either the value specified in the XML file or negated DBL_MAX as defined in */ FMILIB_EXPORT fmi3_float64_t fmi3_import_get_float64_type_min(fmi3_import_float_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or DBL_MAX as defined in + @return Either the value specified in the XML file or DBL_MAX as defined in */ FMILIB_EXPORT fmi3_float64_t fmi3_import_get_float64_type_max(fmi3_import_float_typedef_t*); @@ -121,20 +121,20 @@ FMILIB_EXPORT int fmi3_import_get_float64_type_is_relative_quantity(fmi3_import_ FMILIB_EXPORT int fmi3_import_get_float64_type_is_unbounded(fmi3_import_float_typedef_t*); /** - \brief Get display unit associated with a type definition. - @return Display unit object of NULL if none was given. + \brief Get display unit associated with a type definition. + @return Display unit object of NULL if none was given. */ FMILIB_EXPORT fmi3_import_display_unit_t* fmi3_import_get_float64_type_display_unit(fmi3_import_float_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or negated FLT_MAX as defined in + @return Either the value specified in the XML file or negated FLT_MAX as defined in */ FMILIB_EXPORT fmi3_float32_t fmi3_import_get_float32_type_min(fmi3_import_float_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or FLT_MAX as defined in + @return Either the value specified in the XML file or FLT_MAX as defined in */ FMILIB_EXPORT fmi3_float32_t fmi3_import_get_float32_type_max(fmi3_import_float_typedef_t*); @@ -151,100 +151,100 @@ FMILIB_EXPORT int fmi3_import_get_float32_type_is_relative_quantity(fmi3_import_ FMILIB_EXPORT int fmi3_import_get_float32_type_is_unbounded(fmi3_import_float_typedef_t*); /** - \brief Get display unit associated with a type definition. - @return Display unit object of NULL if none was given. + \brief Get display unit associated with a type definition. + @return Display unit object of NULL if none was given. */ FMILIB_EXPORT fmi3_import_display_unit_t* fmi3_import_get_float32_type_display_unit(fmi3_import_float_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or INT64_MAX as defined in + @return Either the value specified in the XML file or INT64_MAX as defined in */ FMILIB_EXPORT fmi3_int64_t fmi3_import_get_int64_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or INT64_MIN as defined in + @return Either the value specified in the XML file or INT64_MIN as defined in */ FMILIB_EXPORT fmi3_int64_t fmi3_import_get_int64_type_min(fmi3_import_int_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or INT32_MAX as defined in + @return Either the value specified in the XML file or INT32_MAX as defined in */ FMILIB_EXPORT fmi3_int32_t fmi3_import_get_int32_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or INT32_MIN as defined in + @return Either the value specified in the XML file or INT32_MIN as defined in */ FMILIB_EXPORT fmi3_int32_t fmi3_import_get_int32_type_min(fmi3_import_int_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or INT16_MAX as defined in + @return Either the value specified in the XML file or INT16_MAX as defined in */ FMILIB_EXPORT fmi3_int16_t fmi3_import_get_int16_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or INT16_MIN as defined in + @return Either the value specified in the XML file or INT16_MIN as defined in */ FMILIB_EXPORT fmi3_int16_t fmi3_import_get_int16_type_min(fmi3_import_int_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or INT8_MAX as defined in + @return Either the value specified in the XML file or INT8_MAX as defined in */ FMILIB_EXPORT fmi3_int8_t fmi3_import_get_int8_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or INT8_MIN as defined in + @return Either the value specified in the XML file or INT8_MIN as defined in */ FMILIB_EXPORT fmi3_int8_t fmi3_import_get_int8_type_min(fmi3_import_int_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or UINT64_MAX as defined in + @return Either the value specified in the XML file or UINT64_MAX as defined in */ FMILIB_EXPORT fmi3_uint64_t fmi3_import_get_uint64_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or 0 + @return Either the value specified in the XML file or 0 */ FMILIB_EXPORT fmi3_uint64_t fmi3_import_get_uint64_type_min(fmi3_import_int_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or UINT32_MAX as defined in + @return Either the value specified in the XML file or UINT32_MAX as defined in */ FMILIB_EXPORT fmi3_uint32_t fmi3_import_get_uint32_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or 0 + @return Either the value specified in the XML file or 0 */ FMILIB_EXPORT fmi3_uint32_t fmi3_import_get_uint32_type_min(fmi3_import_int_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or UINT16_MAX as defined in + @return Either the value specified in the XML file or UINT16_MAX as defined in */ FMILIB_EXPORT fmi3_uint16_t fmi3_import_get_uint16_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or 0 + @return Either the value specified in the XML file or 0 */ FMILIB_EXPORT fmi3_uint16_t fmi3_import_get_uint16_type_min(fmi3_import_int_typedef_t*); /** \brief Get maximum value for the type - @return Either the value specified in the XML file or UINT8_MAX as defined in + @return Either the value specified in the XML file or UINT8_MAX as defined in */ FMILIB_EXPORT fmi3_uint8_t fmi3_import_get_uint8_type_max(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - @return Either the value specified in the XML file or 0 + @return Either the value specified in the XML file or 0 */ FMILIB_EXPORT fmi3_uint8_t fmi3_import_get_uint8_type_min(fmi3_import_int_typedef_t*); /** \brief Get minimal value for the type. - - @return Either the value specified in the XML file or 0 + + @return Either the value specified in the XML file or 0 */ FMILIB_EXPORT unsigned int fmi3_import_get_enum_type_min(fmi3_import_enumeration_typedef_t*); /** \brief Get maximum value for the type. - - @return Either the value specified in the XML file or INT_MAX as defined in + + @return Either the value specified in the XML file or INT_MAX as defined in */ FMILIB_EXPORT unsigned int fmi3_import_get_enum_type_max(fmi3_import_enumeration_typedef_t*); diff --git a/src/Import/include/FMI3/fmi3_import_unit.h b/src/Import/include/FMI3/fmi3_import_unit.h index ef70c2ec..1156c1fc 100644 --- a/src/Import/include/FMI3/fmi3_import_unit.h +++ b/src/Import/include/FMI3/fmi3_import_unit.h @@ -26,14 +26,14 @@ extern "C" { #endif - /** - \addtogroup fmi3_import - @{ - \addtogroup fmi3_import_units Functions for handling unit definitions. - @} - \addtogroup fmi3_import_units Functions for handling unit definitions. - @{ - */ + /** + \addtogroup fmi3_import + @{ + \addtogroup fmi3_import_units Functions for handling unit definitions. + @} + \addtogroup fmi3_import_units Functions for handling unit definitions. + @{ + */ /**\name Structures encapsulating unit information */ /**@{ */ @@ -58,84 +58,84 @@ FMILIB_EXPORT const char* fmi3_import_get_unit_name(fmi3_import_unit_t*); FMILIB_EXPORT unsigned int fmi3_import_get_unit_display_unit_number(fmi3_import_unit_t*); /** - \brief Get fmi3_SI_base_units_Num SI base units exponents associated with the unit. + \brief Get fmi3_SI_base_units_Num SI base units exponents associated with the unit. */ FMILIB_EXPORT const int* fmi3_import_get_SI_unit_exponents(fmi3_import_unit_t*); /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ FMILIB_EXPORT double fmi3_import_get_SI_unit_factor(fmi3_import_unit_t*); /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ FMILIB_EXPORT double fmi3_import_get_SI_unit_offset(fmi3_import_unit_t*); /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ FMILIB_EXPORT double fmi3_import_convert_to_SI_base_unit(double, fmi3_import_unit_t*); /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ FMILIB_EXPORT double fmi3_import_convert_from_SI_base_unit(double, fmi3_import_unit_t*); /** \brief Get a display unit object by index. - @param index The index of display unit to be returned. Must be less than the number returned by fmi3_import_get_unit_display_unit_number() + @param index The index of display unit to be returned. Must be less than the number returned by fmi3_import_get_unit_display_unit_number() */ FMILIB_EXPORT fmi3_import_display_unit_t* fmi3_import_get_unit_display_unit(fmi3_import_unit_t*, size_t index); /** - \brief Get unit defition for a display unit. + \brief Get unit defition for a display unit. */ FMILIB_EXPORT fmi3_import_unit_t* fmi3_import_get_base_unit(fmi3_import_display_unit_t*); /** - \brief Get display unit name + \brief Get display unit name */ FMILIB_EXPORT const char* fmi3_import_get_display_unit_name(fmi3_import_display_unit_t*); /** - \brief Get the "factor" associated with the display unit. + \brief Get the "factor" associated with the display unit. */ FMILIB_EXPORT double fmi3_import_get_display_unit_factor(fmi3_import_display_unit_t*); /** - \brief Get the "offset" associated with the display unit. + \brief Get the "offset" associated with the display unit. */ FMILIB_EXPORT double fmi3_import_get_display_unit_offset(fmi3_import_display_unit_t*); /** - \brief Convert a value measured in "units" to a value measured with "display units" - @param value The value to be converted - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "units" to a value measured with "display units" + @param value The value to be converted + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi3_float64_t fmi3_import_float64_convert_to_display_unit(fmi3_float64_t value , fmi3_import_display_unit_t* du, int isRelativeQuantity); /** - \brief Convert a value measured in "display units" to a value measured with "units" - @param value The value to be converted - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "display units" to a value measured with "units" + @param value The value to be converted + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi3_float64_t fmi3_import_float64_convert_from_display_unit(fmi3_float64_t value, fmi3_import_display_unit_t* du, int isRelativeQuantity); /** - \brief Convert a value measured in "units" to a value measured with "display units" - @param value The value to be converted - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "units" to a value measured with "display units" + @param value The value to be converted + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi3_float32_t fmi3_import_float32_convert_to_display_unit(fmi3_float32_t value , fmi3_import_display_unit_t* du, int isRelativeQuantity); /** - \brief Convert a value measured in "display units" to a value measured with "units". - @param value The value to be converted - @param du The display unit object - @param isRelativeQuantity specifies if "offset" should be incorporated into conversion + \brief Convert a value measured in "display units" to a value measured with "units". + @param value The value to be converted + @param du The display unit object + @param isRelativeQuantity specifies if "offset" should be incorporated into conversion */ FMILIB_EXPORT fmi3_float32_t fmi3_import_float32_convert_from_display_unit(fmi3_float32_t value, fmi3_import_display_unit_t* du, int isRelativeQuantity); diff --git a/src/Import/include/FMI3/fmi3_import_variable.h b/src/Import/include/FMI3/fmi3_import_variable.h index f1f75bdb..fb0b6ec8 100644 --- a/src/Import/include/FMI3/fmi3_import_variable.h +++ b/src/Import/include/FMI3/fmi3_import_variable.h @@ -31,23 +31,23 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi3_import - @{ - \addtogroup fmi3_import_variables Functions for handling variable definitions. - @} - \addtogroup fmi3_import_variables Functions for handling variable definitions. - \brief All the functions in this group take a pointer to ::fmi3_import_variable_t as a parameter. - A variable pointer may be obtained via a \ref fmi3_import_varlist module or via functions - fmi3_import_get_variable_by_name() and fmi3_import_get_variable_by_vr(). - @{ - */ - /**@name Scalar variable types */ + /** + \addtogroup fmi3_import + @{ + \addtogroup fmi3_import_variables Functions for handling variable definitions. + @} + \addtogroup fmi3_import_variables Functions for handling variable definitions. + \brief All the functions in this group take a pointer to ::fmi3_import_variable_t as a parameter. + A variable pointer may be obtained via a \ref fmi3_import_varlist module or via functions + fmi3_import_get_variable_by_name() and fmi3_import_get_variable_by_vr(). + @{ + */ + /**@name Scalar variable types */ /**@{ */ /** \brief General variable type. * * This type is convenient to unify all the variable list operations. -* However, typed variables are needed to support specific attributes. +* However, typed variables are needed to support specific attributes. */ typedef struct fmi3_xml_variable_t fmi3_import_variable_t; /** \brief Opaque float32 variable */ @@ -84,7 +84,7 @@ typedef struct fmi3_import_variable_list_t fmi3_import_variable_list_t; FMILIB_EXPORT const char* fmi3_import_get_variable_name(fmi3_import_variable_t*); /** \brief Get variable description. - @return Description string or empty string ("") if no description in the XML file was given. + @return Description string or empty string ("") if no description in the XML file was given. */ FMILIB_EXPORT const char* fmi3_import_get_variable_description(fmi3_import_variable_t*); @@ -92,7 +92,7 @@ FMILIB_EXPORT const char* fmi3_import_get_variable_description(fmi3_import_varia FMILIB_EXPORT fmi3_value_reference_t fmi3_import_get_variable_vr(fmi3_import_variable_t*); /** \brief For scalar variable gives the type definition is present - @return Pointer of a type #fmi3_import_variable_typedef_t object or NULL of not present. + @return Pointer of a type #fmi3_import_variable_typedef_t object or NULL of not present. */ FMILIB_EXPORT fmi3_import_variable_typedef_t* fmi3_import_get_variable_declared_type(fmi3_import_variable_t*); @@ -117,7 +117,7 @@ FMILIB_EXPORT fmi3_float32_t* fmi3_import_get_float32_variable_start_array(fmi3_ FMILIB_EXPORT fmi3_import_dimension_list_t* fmi3_import_get_variable_dimension_list(fmi3_import_t* fmu, fmi3_import_variable_t* v); /** \brief Check if the variable is an array. - @return True if array, false if scalar. + @return True if array, false if scalar. */ FMILIB_EXPORT int fmi3_import_variable_is_array(fmi3_import_variable_t*); @@ -143,95 +143,95 @@ FMILIB_EXPORT fmi3_import_variable_t* fmi3_import_get_previous(fmi3_import_varia /** \brief Get the canHandleMultipleSetPerTimeInstant flag for a variable. - @return For inputs: If false, then only one fmiSetXXX call is allowed at + @return For inputs: If false, then only one fmiSetXXX call is allowed at one super dense time instant. In other words, this input is not allowed to appear in an algebraic loop. */ FMILIB_EXPORT fmi3_boolean_t fmi3_import_get_canHandleMultipleSetPerTimeInstant(fmi3_import_variable_t* v); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_float64_variable_t* fmi3_import_get_variable_as_float64(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_float32_variable_t* fmi3_import_get_variable_as_float32(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_int64_variable_t* fmi3_import_get_variable_as_int64(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_int32_variable_t* fmi3_import_get_variable_as_int32(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_int16_variable_t* fmi3_import_get_variable_as_int16(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_int8_variable_t* fmi3_import_get_variable_as_int8(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_uint64_variable_t* fmi3_import_get_variable_as_uint64(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_uint32_variable_t* fmi3_import_get_variable_as_uint32(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_uint16_variable_t* fmi3_import_get_variable_as_uint16(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - @return Typed object or NULL if base type does not match + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_uint8_variable_t* fmi3_import_get_variable_as_uint8(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_enum_variable_t* fmi3_import_get_variable_as_enum(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_string_variable_t* fmi3_import_get_variable_as_string(fmi3_import_variable_t*); /** \brief Cast general variable to a one with the specific type - - @return Typed object or NULL if base type does not match + + @return Typed object or NULL if base type does not match */ FMILIB_EXPORT fmi3_import_bool_variable_t* fmi3_import_get_variable_as_boolean(fmi3_import_variable_t*); /** \brief Get minimal value for the variable. - @return Either the value specified in the XML file or negated FLT_MAX as defined in + @return Either the value specified in the XML file or negated FLT_MAX as defined in */ FMILIB_EXPORT fmi3_float32_t fmi3_import_get_float32_variable_min(fmi3_import_float32_variable_t* v); /** \brief Get maximum value for the variable. - @return Either the value specified in the XML file or FLT_MAX as defined in + @return Either the value specified in the XML file or FLT_MAX as defined in */ FMILIB_EXPORT fmi3_float32_t fmi3_import_get_float32_variable_max(fmi3_import_float32_variable_t* v); /** \brief Get nominal value for the variable. - @return The "start" attribute as specified in the XML file or variable nominal value. + @return The "start" attribute as specified in the XML file or variable nominal value. */ FMILIB_EXPORT fmi3_float32_t fmi3_import_get_float32_variable_nominal(fmi3_import_float32_variable_t* v); @@ -253,38 +253,38 @@ FMILIB_EXPORT fmi3_import_display_unit_t* fmi3_import_get_float32_variable_displ FMILIB_EXPORT fmi3_import_float32_variable_t* fmi3_import_get_float32_variable_derivative_of(fmi3_import_float32_variable_t* v); /** - \brief Get the variable start attribute. + \brief Get the variable start attribute. - @return The "start" attribute as specified in the XML file or variable nominal value. + @return The "start" attribute as specified in the XML file or variable nominal value. */ FMILIB_EXPORT fmi3_float32_t fmi3_import_get_float32_variable_start(fmi3_import_float32_variable_t* v); /** \brief Get the variable "relativeQuantity" attribute. - @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. + @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. */ FMILIB_EXPORT fmi3_boolean_t fmi3_import_get_float32_variable_relative_quantity(fmi3_import_float32_variable_t* v); /** \brief Get the variable "unbounded" attribute. - @return The "unbounded" attribute as specified in the XML file. False if undefined. + @return The "unbounded" attribute as specified in the XML file. False if undefined. */ FMILIB_EXPORT fmi3_boolean_t fmi3_import_get_float32_variable_unbounded(fmi3_import_float32_variable_t* v); /** \brief Get minimal value for the variable. - @return Either the value specified in the XML file or negated DBL_MAX as defined in + @return Either the value specified in the XML file or negated DBL_MAX as defined in */ FMILIB_EXPORT fmi3_float64_t fmi3_import_get_float64_variable_min(fmi3_import_float64_variable_t* v); /** \brief Get maximum value for the variable. - @return Either the value specified in the XML file or DBL_MAX as defined in + @return Either the value specified in the XML file or DBL_MAX as defined in */ FMILIB_EXPORT fmi3_float64_t fmi3_import_get_float64_variable_max(fmi3_import_float64_variable_t* v); /** \brief Get nominal value for the variable. - @return The "start" attribute as specified in the XML file or variable nominal value. + @return The "start" attribute as specified in the XML file or variable nominal value. */ FMILIB_EXPORT fmi3_float64_t fmi3_import_get_float64_variable_nominal(fmi3_import_float64_variable_t* v); @@ -292,9 +292,9 @@ FMILIB_EXPORT fmi3_float64_t fmi3_import_get_float64_variable_nominal(fmi3_impor FMILIB_EXPORT fmi3_string_t fmi3_import_get_float64_variable_quantity(fmi3_import_float64_variable_t* v); /** - \brief Get the variable start attribute. + \brief Get the variable start attribute. - @return The "start" attribute as specified in the XML file or variable nominal value. + @return The "start" attribute as specified in the XML file or variable nominal value. */ FMILIB_EXPORT fmi3_float64_t fmi3_import_get_float64_variable_start(fmi3_import_float64_variable_t* v); @@ -313,12 +313,12 @@ FMILIB_EXPORT fmi3_import_display_unit_t* fmi3_import_get_float64_variable_displ FMILIB_EXPORT fmi3_import_float64_variable_t* fmi3_import_get_float64_variable_derivative_of(fmi3_import_float64_variable_t* v); /** \brief Get the variable "relativeQuantity" attribute. - @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. + @return The "relativeQuantity" attribute as specified in the XML file. False if undefined. */ FMILIB_EXPORT fmi3_boolean_t fmi3_import_get_float64_variable_relative_quantity(fmi3_import_float64_variable_t* v); /** \brief Get the variable "unbounded" attribute. - @return The "unbounded" attribute as specified in the XML file. False if undefined. + @return The "unbounded" attribute as specified in the XML file. False if undefined. */ FMILIB_EXPORT fmi3_boolean_t fmi3_import_get_float64_variable_unbounded(fmi3_import_float64_variable_t* v); diff --git a/src/Import/include/FMI3/fmi3_import_variable_list.h b/src/Import/include/FMI3/fmi3_import_variable_list.h index 86209030..6e8ded49 100644 --- a/src/Import/include/FMI3/fmi3_import_variable_list.h +++ b/src/Import/include/FMI3/fmi3_import_variable_list.h @@ -31,7 +31,7 @@ extern "C" { /** \addtogroup fmi3_import @{ - \defgroup fmi3_import_varlist Handling of variable lists + \defgroup fmi3_import_varlist Handling of variable lists @} */ @@ -46,12 +46,12 @@ extern "C" { FMILIB_EXPORT fmi3_import_variable_list_t* fmi3_import_alloc_variable_list(fmi3_import_t* fmu, size_t size); /** \brief Free a variable list. Note that variable lists are allocated dynamically and must be freed when not needed any longer - \param vl A variable list. + \param vl A variable list. */ FMILIB_EXPORT void fmi3_import_free_variable_list(fmi3_import_variable_list_t* vl); /** \brief Make a copy of the list. - \param vl A variable list. + \param vl A variable list. */ FMILIB_EXPORT fmi3_import_variable_list_t* fmi3_import_clone_variable_list(fmi3_import_variable_list_t* vl); diff --git a/src/Import/src/FMI/fmi_import_context.c b/src/Import/src/FMI/fmi_import_context.c index 44004c33..4dadbf92 100644 --- a/src/Import/src/FMI/fmi_import_context.c +++ b/src/Import/src/FMI/fmi_import_context.c @@ -26,12 +26,12 @@ #define MODULE "FMILIB" fmi_import_context_t* fmi_import_allocate_context( jm_callbacks* callbacks) { - jm_log_verbose(callbacks, MODULE, "Allocating FMIL context"); - return fmi_xml_allocate_context(callbacks); + jm_log_verbose(callbacks, MODULE, "Allocating FMIL context"); + return fmi_xml_allocate_context(callbacks); } void fmi_import_free_context( fmi_import_context_t* c) { - fmi_xml_free_context(c); + fmi_xml_free_context(c); } void fmi_import_set_configuration( fmi_import_context_t* c, int conf) { @@ -39,24 +39,24 @@ void fmi_import_set_configuration( fmi_import_context_t* c, int conf) { } fmi_version_enu_t fmi_import_get_fmi_version( fmi_import_context_t* c, const char* fileName, const char* dirName) { - fmi_version_enu_t ret = fmi_version_unknown_enu; - jm_status_enu_t status; - char* mdpath; - jm_log_verbose(c->callbacks, MODULE, "Detecting FMI standard version"); - if(!dirName || !*dirName) { - jm_log_fatal(c->callbacks, MODULE, "No temporary directory name specified"); - return fmi_version_unknown_enu; - } - if(fileName && !*fileName) { - jm_log_fatal(c->callbacks, MODULE, "No FMU filename specified"); - return fmi_version_unknown_enu; - } else if (fileName) { - status = fmi_zip_unzip(fileName, dirName, c->callbacks); - if(status == jm_status_error) return fmi_version_unknown_enu; - } - mdpath = fmi_import_get_model_description_path(dirName, c->callbacks); - ret = fmi_xml_get_fmi_version(c, mdpath); - jm_log_info(c->callbacks, MODULE, "XML specifies FMI standard version %s", fmi_version_to_string(ret)); - c->callbacks->free(mdpath); - return ret; + fmi_version_enu_t ret = fmi_version_unknown_enu; + jm_status_enu_t status; + char* mdpath; + jm_log_verbose(c->callbacks, MODULE, "Detecting FMI standard version"); + if(!dirName || !*dirName) { + jm_log_fatal(c->callbacks, MODULE, "No temporary directory name specified"); + return fmi_version_unknown_enu; + } + if(fileName && !*fileName) { + jm_log_fatal(c->callbacks, MODULE, "No FMU filename specified"); + return fmi_version_unknown_enu; + } else if (fileName) { + status = fmi_zip_unzip(fileName, dirName, c->callbacks); + if(status == jm_status_error) return fmi_version_unknown_enu; + } + mdpath = fmi_import_get_model_description_path(dirName, c->callbacks); + ret = fmi_xml_get_fmi_version(c, mdpath); + jm_log_info(c->callbacks, MODULE, "XML specifies FMI standard version %s", fmi_version_to_string(ret)); + c->callbacks->free(mdpath); + return ret; } diff --git a/src/Import/src/FMI/fmi_import_context_impl.h b/src/Import/src/FMI/fmi_import_context_impl.h index d549b8c6..699900cd 100644 --- a/src/Import/src/FMI/fmi_import_context_impl.h +++ b/src/Import/src/FMI/fmi_import_context_impl.h @@ -30,11 +30,11 @@ extern "C" { #endif struct fmi_xml_context_t { - jm_callbacks* callbacks; + jm_callbacks* callbacks; XML_Parser parser; - fmi_version_enu_t fmi_version; + fmi_version_enu_t fmi_version; int configuration; }; diff --git a/src/Import/src/FMI/fmi_import_util.c b/src/Import/src/FMI/fmi_import_util.c index 52ad61d9..4a130c55 100644 --- a/src/Import/src/FMI/fmi_import_util.c +++ b/src/Import/src/FMI/fmi_import_util.c @@ -23,55 +23,55 @@ #include char* fmi_import_mk_temp_dir(jm_callbacks* cb, const char* systemTempDir, const char* tempPrefix) { - if(!tempPrefix) tempPrefix = "fmil"; - return jm_mk_temp_dir(cb, systemTempDir, tempPrefix); + if(!tempPrefix) tempPrefix = "fmil"; + return jm_mk_temp_dir(cb, systemTempDir, tempPrefix); } char* fmi_import_create_URL_from_abs_path(jm_callbacks* cb, const char* absPath) { - return jm_create_URL_from_abs_path(cb, absPath); + return jm_create_URL_from_abs_path(cb, absPath); } jm_status_enu_t fmi_import_rmdir(jm_callbacks* cb, const char* dir) { - return jm_rmdir(cb, dir); + return jm_rmdir(cb, dir); } char* fmi_import_get_dll_path(const char* fmu_unzipped_path, const char* model_identifier, jm_callbacks* callbacks) { - char* dll_path; - size_t len; + char* dll_path; + size_t len; - if (model_identifier == NULL || fmu_unzipped_path == NULL) { - assert(0); - return NULL; - } + if (model_identifier == NULL || fmu_unzipped_path == NULL) { + assert(0); + return NULL; + } - len = strlen(fmu_unzipped_path) + strlen(FMI_FILE_SEP) + strlen(FMI_BINARIES) + strlen(FMI_FILE_SEP) + strlen(FMI_PLATFORM) + strlen(FMI_FILE_SEP) + strlen(model_identifier) + strlen(FMI_DLL_EXT) + 1; + len = strlen(fmu_unzipped_path) + strlen(FMI_FILE_SEP) + strlen(FMI_BINARIES) + strlen(FMI_FILE_SEP) + strlen(FMI_PLATFORM) + strlen(FMI_FILE_SEP) + strlen(model_identifier) + strlen(FMI_DLL_EXT) + 1; - dll_path = (char*)callbacks->calloc(len, sizeof(char)); - if (dll_path == NULL) { - jm_log_fatal(callbacks, "FMILIB", "Failed to allocate memory."); - return NULL; - } + dll_path = (char*)callbacks->calloc(len, sizeof(char)); + if (dll_path == NULL) { + jm_log_fatal(callbacks, "FMILIB", "Failed to allocate memory."); + return NULL; + } - jm_snprintf(dll_path, len, "%s%s%s%s%s%s%s%s", fmu_unzipped_path, FMI_FILE_SEP, FMI_BINARIES, FMI_FILE_SEP, FMI_PLATFORM, FMI_FILE_SEP, model_identifier, FMI_DLL_EXT); + jm_snprintf(dll_path, len, "%s%s%s%s%s%s%s%s", fmu_unzipped_path, FMI_FILE_SEP, FMI_BINARIES, FMI_FILE_SEP, FMI_PLATFORM, FMI_FILE_SEP, model_identifier, FMI_DLL_EXT); - return dll_path; + return dll_path; } char* fmi_import_get_model_description_path(const char* fmu_unzipped_path, jm_callbacks* callbacks) { - char* model_description_path; - size_t len; + char* model_description_path; + size_t len; - len = strlen(fmu_unzipped_path) + strlen(FMI_FILE_SEP) + strlen(FMI_MODEL_DESCRIPTION_XML) + 1; + len = strlen(fmu_unzipped_path) + strlen(FMI_FILE_SEP) + strlen(FMI_MODEL_DESCRIPTION_XML) + 1; - model_description_path = (char*)callbacks->calloc(len, sizeof(char)); - if (model_description_path == NULL) { - callbacks->logger(NULL, "FMIIMPORTUTIL", jm_log_level_error, "Failed to allocate memory."); - return NULL; - } + model_description_path = (char*)callbacks->calloc(len, sizeof(char)); + if (model_description_path == NULL) { + callbacks->logger(NULL, "FMIIMPORTUTIL", jm_log_level_error, "Failed to allocate memory."); + return NULL; + } - jm_snprintf(model_description_path, len, "%s%s%s", fmu_unzipped_path, FMI_FILE_SEP, FMI_MODEL_DESCRIPTION_XML); + jm_snprintf(model_description_path, len, "%s%s%s", fmu_unzipped_path, FMI_FILE_SEP, FMI_MODEL_DESCRIPTION_XML); - return model_description_path; + return model_description_path; } diff --git a/src/Import/src/FMI1/fmi1_import.c b/src/Import/src/FMI1/fmi1_import.c index 1795f5dc..6a60e9c5 100644 --- a/src/Import/src/FMI1/fmi1_import.c +++ b/src/Import/src/FMI1/fmi1_import.c @@ -32,33 +32,33 @@ static const char* module = "FMILIB"; #include "fmi1_import_parser.h" */ fmi1_import_t* fmi1_import_allocate(jm_callbacks* cb) { - fmi1_import_t* fmu = (fmi1_import_t*)cb->calloc(1, sizeof(fmi1_import_t)); + fmi1_import_t* fmu = (fmi1_import_t*)cb->calloc(1, sizeof(fmi1_import_t)); - if(!fmu || (jm_vector_init(char)(&fmu->logMessageBufferCoded,JM_MAX_ERROR_MESSAGE_SIZE,cb) < JM_MAX_ERROR_MESSAGE_SIZE)) { - jm_log_fatal(cb, module, "Could not allocate memory"); + if(!fmu || (jm_vector_init(char)(&fmu->logMessageBufferCoded,JM_MAX_ERROR_MESSAGE_SIZE,cb) < JM_MAX_ERROR_MESSAGE_SIZE)) { + jm_log_fatal(cb, module, "Could not allocate memory"); if(fmu) cb->free(fmu); - return 0; - } + return 0; + } - fmu->dirPath = 0; - fmu->location = 0; - fmu->callbacks = cb; - fmu->capi = 0; - fmu->md = fmi1_xml_allocate_model_description(cb); - fmu->registerGlobally = 0; - jm_vector_init(char)(&fmu->logMessageBufferExpanded,0,cb); + fmu->dirPath = 0; + fmu->location = 0; + fmu->callbacks = cb; + fmu->capi = 0; + fmu->md = fmi1_xml_allocate_model_description(cb); + fmu->registerGlobally = 0; + jm_vector_init(char)(&fmu->logMessageBufferExpanded,0,cb); - if(!fmu->md) { - goto err1; - } + if(!fmu->md) { + goto err1; + } - fmu->options = fmi_util_allocate_options(cb); - if(!fmu->options) { - goto err2; - } + fmu->options = fmi_util_allocate_options(cb); + if(!fmu->options) { + goto err2; + } - return fmu; + return fmu; err2: fmi1_xml_free_model_description(fmu->md); @@ -68,300 +68,300 @@ fmi1_import_t* fmi1_import_allocate(jm_callbacks* cb) { } const char* fmi1_import_get_last_error(fmi1_import_t* fmu) { - return jm_get_last_error(fmu->callbacks); + return jm_get_last_error(fmu->callbacks); } fmi1_import_t* fmi1_import_parse_xml( fmi_import_context_t* context, const char* dirPath) { - char* xmlPath; - char absPath[FILENAME_MAX + 2]; - jm_callbacks* cb; - fmi1_import_t* fmu; + char* xmlPath; + char absPath[FILENAME_MAX + 2]; + jm_callbacks* cb; + fmi1_import_t* fmu; int configuration = 0; - if(!context) return 0; + if(!context) return 0; + + cb = context->callbacks; + + xmlPath = fmi_import_get_model_description_path(dirPath, context->callbacks); - cb = context->callbacks; - - xmlPath = fmi_import_get_model_description_path(dirPath, context->callbacks); + fmu = fmi1_import_allocate(context->callbacks); - fmu = fmi1_import_allocate(context->callbacks); + if(!fmu) { + context->callbacks->free(xmlPath); + return 0; + } - if(!fmu) { - context->callbacks->free(xmlPath); - return 0; - } - - jm_log_verbose( cb, "FMILIB", "Parsing model description XML"); + jm_log_verbose( cb, "FMILIB", "Parsing model description XML"); /* convert the import configuration to the xml configuration */ if (context->configuration & FMI_IMPORT_NAME_CHECK) { configuration |= FMI1_XML_NAME_CHECK; } - if(fmi1_xml_parse_model_description( fmu->md, xmlPath, configuration)) { - fmi1_import_free(fmu); - cb->free(xmlPath); - return 0; - } - cb->free(xmlPath); - - fmu->dirPath = (char*)cb->calloc(strlen(dirPath) + 1, sizeof(char)); + if(fmi1_xml_parse_model_description( fmu->md, xmlPath, configuration)) { + fmi1_import_free(fmu); + cb->free(xmlPath); + return 0; + } + cb->free(xmlPath); + + fmu->dirPath = (char*)cb->calloc(strlen(dirPath) + 1, sizeof(char)); - if(jm_get_dir_abspath(cb, dirPath, absPath, FILENAME_MAX + 2)) { - fmu->location = fmi_import_create_URL_from_abs_path(cb, absPath); - } - - if ((fmu->dirPath == NULL) || (fmu->location == 0)){ - jm_log_fatal( cb, "FMILIB", "Could not allocated memory"); - fmi1_import_free(fmu); - cb->free(xmlPath); - return 0; - } - strcpy(fmu->dirPath, dirPath); + if(jm_get_dir_abspath(cb, dirPath, absPath, FILENAME_MAX + 2)) { + fmu->location = fmi_import_create_URL_from_abs_path(cb, absPath); + } - jm_log_verbose( cb, "FMILIB", "Parsing finished successfully"); + if ((fmu->dirPath == NULL) || (fmu->location == 0)){ + jm_log_fatal( cb, "FMILIB", "Could not allocated memory"); + fmi1_import_free(fmu); + cb->free(xmlPath); + return 0; + } + strcpy(fmu->dirPath, dirPath); - return fmu; + jm_log_verbose( cb, "FMILIB", "Parsing finished successfully"); + + return fmu; } void fmi1_import_free(fmi1_import_t* fmu) { jm_callbacks* cb = fmu->callbacks; - if(!fmu) return; - jm_log_verbose( fmu->callbacks, "FMILIB", "Releasing allocated library resources"); + if(!fmu) return; + jm_log_verbose( fmu->callbacks, "FMILIB", "Releasing allocated library resources"); - fmi1_import_destroy_dllfmu(fmu); - fmi1_xml_free_model_description(fmu->md); - fmi_util_free_options(cb, fmu->options); - jm_vector_free_data(char)(&fmu->logMessageBufferCoded); - jm_vector_free_data(char)(&fmu->logMessageBufferExpanded); + fmi1_import_destroy_dllfmu(fmu); + fmi1_xml_free_model_description(fmu->md); + fmi_util_free_options(cb, fmu->options); + jm_vector_free_data(char)(&fmu->logMessageBufferCoded); + jm_vector_free_data(char)(&fmu->logMessageBufferExpanded); - cb->free(fmu->dirPath); - cb->free(fmu->location); + cb->free(fmu->dirPath); + cb->free(fmu->location); cb->free(fmu); } const char* fmi1_import_get_model_name(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_model_name(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_model_name(fmu->md); } const char* fmi1_import_get_model_identifier(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_model_identifier(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_model_identifier(fmu->md); } const char* fmi1_import_get_GUID(fmi1_import_t* fmu){ - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } return fmi1_xml_get_GUID(fmu->md); } const char* fmi1_import_get_description(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_description(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_description(fmu->md); } const char* fmi1_import_get_author(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_author(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_author(fmu->md); } const char* fmi1_import_get_model_standard_version(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_model_standard_version(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_model_standard_version(fmu->md); } const char* fmi1_import_get_model_version(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_model_version(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_model_version(fmu->md); } const char* fmi1_import_get_generation_tool(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_generation_tool(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_generation_tool(fmu->md); } const char* fmi1_import_get_generation_date_and_time(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_generation_date_and_time(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_generation_date_and_time(fmu->md); } fmi1_variable_naming_convension_enu_t fmi1_import_get_naming_convention(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return fmi1_naming_enu_unknown; - } - return fmi1_xml_get_naming_convention(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return fmi1_naming_enu_unknown; + } + return fmi1_xml_get_naming_convention(fmu->md); } unsigned int fmi1_import_get_number_of_continuous_states(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_number_of_continuous_states(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_number_of_continuous_states(fmu->md); } unsigned int fmi1_import_get_number_of_event_indicators(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_number_of_event_indicators(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_number_of_event_indicators(fmu->md); } int fmi1_import_get_default_experiment_has_start(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } - return fmi1_xml_get_default_experiment_has_start(fmu->md); + return fmi1_xml_get_default_experiment_has_start(fmu->md); } int fmi1_import_get_default_experiment_has_stop(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } - return fmi1_xml_get_default_experiment_has_stop(fmu->md); + return fmi1_xml_get_default_experiment_has_stop(fmu->md); } int fmi1_import_get_default_experiment_has_tolerance(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } - return fmi1_xml_get_default_experiment_has_tolerance(fmu->md); + return fmi1_xml_get_default_experiment_has_tolerance(fmu->md); } double fmi1_import_get_default_experiment_start(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_default_experiment_start(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_default_experiment_start(fmu->md); } void fmi1_import_set_default_experiment_start(fmi1_import_t* fmu, double t) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return; - } - fmi1_xml_set_default_experiment_start(fmu->md, t); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return; + } + fmi1_xml_set_default_experiment_start(fmu->md, t); } double fmi1_import_get_default_experiment_stop(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_default_experiment_stop(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_default_experiment_stop(fmu->md); } void fmi1_import_set_default_experiment_stop(fmi1_import_t* fmu, double t) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return; - } - fmi1_xml_set_default_experiment_stop(fmu->md, t); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return; + } + fmi1_xml_set_default_experiment_stop(fmu->md, t); } double fmi1_import_get_default_experiment_tolerance(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_default_experiment_tolerance(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_default_experiment_tolerance(fmu->md); } void fmi1_import_set_default_experiment_tolerance(fmi1_import_t* fmu, double tol) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return; - } - fmi1_xml_set_default_experiment_tolerance(fmu->md, tol); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return; + } + fmi1_xml_set_default_experiment_tolerance(fmu->md, tol); } fmi1_import_vendor_list_t* fmi1_import_get_vendor_list(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_vendor_list(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_vendor_list(fmu->md); } unsigned int fmi1_import_get_number_of_vendors(fmi1_import_vendor_list_t* vl) { - return fmi1_xml_get_number_of_vendors(vl); + return fmi1_xml_get_number_of_vendors(vl); } fmi1_import_vendor_t* fmi1_import_get_vendor(fmi1_import_vendor_list_t* v, unsigned int index) { - return fmi1_xml_get_vendor(v, index); + return fmi1_xml_get_vendor(v, index); } fmi1_import_unit_definitions_t* fmi1_import_get_unit_definitions(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_unit_definitions(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_unit_definitions(fmu->md); } unsigned int fmi1_import_get_unit_definitions_number(fmi1_import_unit_definitions_t* ud) { - return fmi1_xml_get_unit_definitions_number(ud); + return fmi1_xml_get_unit_definitions_number(ud); } fmi1_import_type_definitions_t* fmi1_import_get_type_definitions(fmi1_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return fmi1_xml_get_type_definitions(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return fmi1_xml_get_type_definitions(fmu->md); } /* Get the list of all the variables in the model */ fmi1_import_variable_list_t* fmi1_import_get_variable_list(fmi1_import_t* fmu) { - jm_vector(jm_voidp)* vars; + jm_vector(jm_voidp)* vars; fmi1_import_variable_list_t* vl; size_t nv, i; - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - vars = fmi1_xml_get_variables_original_order(fmu->md); - if(vars) - nv = jm_vector_get_size(jm_voidp)(vars); - else - nv = 0; + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + vars = fmi1_xml_get_variables_original_order(fmu->md); + if(vars) + nv = jm_vector_get_size(jm_voidp)(vars); + else + nv = 0; vl = fmi1_import_alloc_variable_list(fmu, nv); if(!vl) return 0; for(i = 0; i< nv; i++) { @@ -372,19 +372,19 @@ fmi1_import_variable_list_t* fmi1_import_get_variable_list(fmi1_import_t* fmu) { /* Get the list of all the variables in the model in alphabetical order */ fmi1_import_variable_list_t* fmi1_import_get_variable_list_alphabetical_order(fmi1_import_t* fmu) { - jm_vector(jm_named_ptr)* vars; + jm_vector(jm_named_ptr)* vars; fmi1_import_variable_list_t* vl; size_t nv, i; - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - vars = fmi1_xml_get_variables_alphabetical_order(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + vars = fmi1_xml_get_variables_alphabetical_order(fmu->md); nv = jm_vector_get_size(jm_named_ptr)(vars); vl = fmi1_import_alloc_variable_list(fmu, nv); if(!vl) return 0; for(i = 0; i< nv; i++) { - jm_vector_set_item(jm_voidp)(&vl->variables, i, jm_vector_get_item(jm_named_ptr)(vars, i).ptr); + jm_vector_set_item(jm_voidp)(&vl->variables, i, jm_vector_get_item(jm_named_ptr)(vars, i).ptr); } return vl; } diff --git a/src/Import/src/FMI1/fmi1_import_capi.c b/src/Import/src/FMI1/fmi1_import_capi.c index fc27ee55..d3197c88 100644 --- a/src/Import/src/FMI1/fmi1_import_capi.c +++ b/src/Import/src/FMI1/fmi1_import_capi.c @@ -29,66 +29,66 @@ extern "C" { static const char * module = "FMILIB"; static void fmi1_import_capi_destroy_dllfmu_and_restore_options(fmi1_import_t* fmu) { - if (fmu->capi->options) { - /* Take back ownership of Options */ - fmu->options = fmu->capi->options; - fmu->capi->options = NULL; - } + if (fmu->capi->options) { + /* Take back ownership of Options */ + fmu->options = fmu->capi->options; + fmu->capi->options = NULL; + } - fmi1_capi_destroy_dllfmu(fmu->capi); - fmu->capi = NULL; + fmi1_capi_destroy_dllfmu(fmu->capi); + fmu->capi = NULL; } /* Load and destroy functions */ jm_status_enu_t fmi1_import_create_dllfmu(fmi1_import_t* fmu, fmi1_callback_functions_t callBackFunctions, int registerGlobally) { - char curDir[FILENAME_MAX + 2]; - char* dllDirPath = 0; - char* dllFileName = 0; - const char* modelIdentifier; - fmi1_fmu_kind_enu_t standard; - - if (fmu == NULL) { - assert(0); - return jm_status_error; - } - - if(fmu -> capi) { - jm_log_warning(fmu->callbacks, module, "FMU binary is already loaded"); - return jm_status_success; - } - - standard = fmi1_import_get_fmu_kind(fmu); - - modelIdentifier = fmi1_import_get_model_identifier(fmu); - if (modelIdentifier == NULL) { - return jm_status_error; - } - - if( jm_portability_get_current_working_directory(curDir, FILENAME_MAX+1) != jm_status_success) { - jm_log_warning(fmu->callbacks, module, "Could not get current working directory (%s)", strerror(errno)); - curDir[0] = 0; - }; - - dllDirPath = fmi_construct_dll_dir_name(fmu->callbacks, fmu->dirPath); - dllFileName = fmi_construct_dll_file_name(fmu->callbacks, dllDirPath, modelIdentifier); - - if (!dllDirPath ||!dllFileName) { - fmu->callbacks->free(dllDirPath); - return jm_status_error; - } - - if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { - jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); - if(ENOENT == errno) - jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); - else - jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); - } - else { - /* Allocate memory for the C-API struct */ - fmu -> capi = fmi1_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, standard); - } + char curDir[FILENAME_MAX + 2]; + char* dllDirPath = 0; + char* dllFileName = 0; + const char* modelIdentifier; + fmi1_fmu_kind_enu_t standard; + + if (fmu == NULL) { + assert(0); + return jm_status_error; + } + + if(fmu -> capi) { + jm_log_warning(fmu->callbacks, module, "FMU binary is already loaded"); + return jm_status_success; + } + + standard = fmi1_import_get_fmu_kind(fmu); + + modelIdentifier = fmi1_import_get_model_identifier(fmu); + if (modelIdentifier == NULL) { + return jm_status_error; + } + + if( jm_portability_get_current_working_directory(curDir, FILENAME_MAX+1) != jm_status_success) { + jm_log_warning(fmu->callbacks, module, "Could not get current working directory (%s)", strerror(errno)); + curDir[0] = 0; + }; + + dllDirPath = fmi_construct_dll_dir_name(fmu->callbacks, fmu->dirPath); + dllFileName = fmi_construct_dll_file_name(fmu->callbacks, dllDirPath, modelIdentifier); + + if (!dllDirPath ||!dllFileName) { + fmu->callbacks->free(dllDirPath); + return jm_status_error; + } + + if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { + jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); + if(ENOENT == errno) + jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); + else + jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); + } + else { + /* Allocate memory for the C-API struct */ + fmu -> capi = fmi1_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, standard); + } if (fmu->capi) { /* Replace the CAPI options with the import ones */ @@ -97,288 +97,288 @@ jm_status_enu_t fmi1_import_create_dllfmu(fmi1_import_t* fmu, fmi1_callback_func fmu->options = NULL; } - /* Load the DLL handle */ - if (fmu -> capi) { - jm_log_info(fmu->callbacks, module, - "Loading '" FMI_PLATFORM "' binary with '%s' platform types", fmi1_get_platform() ); + /* Load the DLL handle */ + if (fmu -> capi) { + jm_log_info(fmu->callbacks, module, + "Loading '" FMI_PLATFORM "' binary with '%s' platform types", fmi1_get_platform() ); - if(fmi1_capi_load_dll(fmu -> capi) == jm_status_error) { - fmi1_import_capi_destroy_dllfmu_and_restore_options(fmu); - } - } - - if(curDir[0] && (jm_portability_set_current_working_directory(curDir) != jm_status_success)) { - jm_log_error(fmu->callbacks, module, "Could not restore current working directory (%s)", strerror(errno)); - } + if(fmi1_capi_load_dll(fmu -> capi) == jm_status_error) { + fmi1_import_capi_destroy_dllfmu_and_restore_options(fmu); + } + } - fmu->callbacks->free((jm_voidp)dllDirPath); - fmu->callbacks->free((jm_voidp)dllFileName); + if(curDir[0] && (jm_portability_set_current_working_directory(curDir) != jm_status_success)) { + jm_log_error(fmu->callbacks, module, "Could not restore current working directory (%s)", strerror(errno)); + } - if (fmu -> capi == NULL) { - return jm_status_error; - } + fmu->callbacks->free((jm_voidp)dllDirPath); + fmu->callbacks->free((jm_voidp)dllFileName); + if (fmu -> capi == NULL) { + return jm_status_error; + } - /* Load the DLL functions */ - if (fmi1_capi_load_fcn(fmu -> capi) == jm_status_error) { - fmi1_capi_free_dll(fmu -> capi); - fmi1_import_capi_destroy_dllfmu_and_restore_options(fmu); - return jm_status_error; - } - jm_log_verbose(fmu->callbacks, module, "Successfully loaded all the interface functions"); - if (registerGlobally) { - fmu->registerGlobally = 1; - if(!fmi1_import_active_fmu) { - fmi1_import_active_fmu_store_callbacks = *fmu->callbacks; - fmi1_import_active_fmu_store_callbacks.context = 0; - jm_vector_init(jm_voidp)(&fmi1_import_active_fmu_store,0, &fmi1_import_active_fmu_store_callbacks); - fmi1_import_active_fmu = &fmi1_import_active_fmu_store; - jm_log_debug(fmu->callbacks, module, "Created an empty active fmu list"); - } - jm_vector_push_back(jm_voidp)(fmi1_import_active_fmu, fmu); - jm_log_debug(fmu->callbacks, module, "Registrered active fmu(%p)", fmu); - } + /* Load the DLL functions */ + if (fmi1_capi_load_fcn(fmu -> capi) == jm_status_error) { + fmi1_capi_free_dll(fmu -> capi); + fmi1_import_capi_destroy_dllfmu_and_restore_options(fmu); + return jm_status_error; + } + jm_log_verbose(fmu->callbacks, module, "Successfully loaded all the interface functions"); + + if (registerGlobally) { + fmu->registerGlobally = 1; + if(!fmi1_import_active_fmu) { + fmi1_import_active_fmu_store_callbacks = *fmu->callbacks; + fmi1_import_active_fmu_store_callbacks.context = 0; + jm_vector_init(jm_voidp)(&fmi1_import_active_fmu_store,0, &fmi1_import_active_fmu_store_callbacks); + fmi1_import_active_fmu = &fmi1_import_active_fmu_store; + jm_log_debug(fmu->callbacks, module, "Created an empty active fmu list"); + } + jm_vector_push_back(jm_voidp)(fmi1_import_active_fmu, fmu); + jm_log_debug(fmu->callbacks, module, "Registrered active fmu(%p)", fmu); + } - return jm_status_success; + return jm_status_success; } void fmi1_import_set_debug_mode(fmi1_import_t* fmu, int mode) { - if (fmu == NULL) { - return; - } - fmi1_capi_set_debug_mode(fmu->capi, mode); + if (fmu == NULL) { + return; + } + fmi1_capi_set_debug_mode(fmu->capi, mode); } void fmi1_import_destroy_dllfmu(fmi1_import_t* fmu) { - - if (fmu == NULL) { - return; - } - - - if(fmu -> capi) { - jm_log_verbose(fmu->callbacks, module, "Releasing FMU CAPI interface"); - - /* Free DLL handle */ - fmi1_capi_free_dll(fmu -> capi); - - /* Destroy the C-API struct and restore options */ - fmi1_import_capi_destroy_dllfmu_and_restore_options(fmu); - - if(fmu->registerGlobally && fmi1_import_active_fmu) { - size_t index; - size_t nFmu; - - index = jm_vector_find_index(jm_voidp)(fmi1_import_active_fmu, (void**)&fmu, jm_compare_voidp); - nFmu = jm_vector_get_size(jm_voidp)(fmi1_import_active_fmu); - if(index < nFmu) { - jm_vector_remove_item(jm_voidp)(fmi1_import_active_fmu,index); - jm_log_debug(fmu->callbacks, module, "Unregistrered active fmu(%p)", fmu); - if(nFmu == 1) { - jm_vector_free_data(jm_voidp)(fmi1_import_active_fmu); - fmi1_import_active_fmu = 0; - jm_log_debug(fmu->callbacks, module, "Freed active fmu list"); - } - } - fmu->registerGlobally = 0; - } - - fmu -> capi = NULL; - } - else { - assert(fmu->registerGlobally == 0); - } + + if (fmu == NULL) { + return; + } + + + if(fmu -> capi) { + jm_log_verbose(fmu->callbacks, module, "Releasing FMU CAPI interface"); + + /* Free DLL handle */ + fmi1_capi_free_dll(fmu -> capi); + + /* Destroy the C-API struct and restore options */ + fmi1_import_capi_destroy_dllfmu_and_restore_options(fmu); + + if(fmu->registerGlobally && fmi1_import_active_fmu) { + size_t index; + size_t nFmu; + + index = jm_vector_find_index(jm_voidp)(fmi1_import_active_fmu, (void**)&fmu, jm_compare_voidp); + nFmu = jm_vector_get_size(jm_voidp)(fmi1_import_active_fmu); + if(index < nFmu) { + jm_vector_remove_item(jm_voidp)(fmi1_import_active_fmu,index); + jm_log_debug(fmu->callbacks, module, "Unregistrered active fmu(%p)", fmu); + if(nFmu == 1) { + jm_vector_free_data(jm_voidp)(fmi1_import_active_fmu); + fmi1_import_active_fmu = 0; + jm_log_debug(fmu->callbacks, module, "Freed active fmu list"); + } + } + fmu->registerGlobally = 0; + } + + fmu -> capi = NULL; + } + else { + assert(fmu->registerGlobally == 0); + } } /* FMI 1.0 Common functions */ const char* fmi1_import_get_version(fmi1_import_t* fmu) { - if(!fmu->capi) { - jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); - return 0; - } - return fmi1_capi_get_version(fmu -> capi); + if(!fmu->capi) { + jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); + return 0; + } + return fmi1_capi_get_version(fmu -> capi); } fmi1_status_t fmi1_import_set_debug_logging(fmi1_import_t* fmu, fmi1_boolean_t loggingOn) { - if(!fmu->capi) { - jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); - return fmi1_status_fatal; - } - return fmi1_capi_set_debug_logging(fmu -> capi, loggingOn); + if(!fmu->capi) { + jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); + return fmi1_status_fatal; + } + return fmi1_capi_set_debug_logging(fmu -> capi, loggingOn); } fmi1_status_t fmi1_import_set_real(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_real_t value[]) { - return fmi1_capi_set_real(fmu -> capi, vr, nvr, value); + return fmi1_capi_set_real(fmu -> capi, vr, nvr, value); } fmi1_status_t fmi1_import_set_integer(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t value[]) { - return fmi1_capi_set_integer(fmu -> capi, vr, nvr, value); + return fmi1_capi_set_integer(fmu -> capi, vr, nvr, value); } fmi1_status_t fmi1_import_set_boolean(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_boolean_t value[]) { - return fmi1_capi_set_boolean(fmu -> capi, vr, nvr, value); + return fmi1_capi_set_boolean(fmu -> capi, vr, nvr, value); } fmi1_status_t fmi1_import_set_string(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_string_t value[]) { - return fmi1_capi_set_string(fmu -> capi, vr, nvr, value); + return fmi1_capi_set_string(fmu -> capi, vr, nvr, value); } fmi1_status_t fmi1_import_get_real(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_real_t value[]) { - return fmi1_capi_get_real(fmu -> capi, vr, nvr, value); + return fmi1_capi_get_real(fmu -> capi, vr, nvr, value); } fmi1_status_t fmi1_import_get_integer(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_integer_t value[]) { - return fmi1_capi_get_integer(fmu -> capi, vr, nvr, value); + return fmi1_capi_get_integer(fmu -> capi, vr, nvr, value); } fmi1_status_t fmi1_import_get_boolean(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_boolean_t value[]) { - return fmi1_capi_get_boolean(fmu -> capi, vr, nvr, value); + return fmi1_capi_get_boolean(fmu -> capi, vr, nvr, value); } fmi1_status_t fmi1_import_get_string(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, fmi1_string_t value[]) { - return fmi1_capi_get_string(fmu -> capi, vr, nvr, value); + return fmi1_capi_get_string(fmu -> capi, vr, nvr, value); } /* FMI 1.0 ME functions */ const char* fmi1_import_get_model_types_platform(fmi1_import_t* fmu) { - return fmi1_capi_get_model_types_platform(fmu -> capi); + return fmi1_capi_get_model_types_platform(fmu -> capi); } jm_status_enu_t fmi1_import_instantiate_model(fmi1_import_t* fmu, fmi1_string_t instanceName) { - fmi1_string_t GUID = fmi1_import_get_GUID(fmu); - fmi1_boolean_t loggingOn = (fmu->callbacks->log_level > jm_log_level_nothing); - fmi1_component_t c = fmi1_capi_instantiate_model(fmu -> capi, instanceName, GUID, loggingOn); - if (c == NULL) { - return jm_status_error; - } else { - return jm_status_success; - } + fmi1_string_t GUID = fmi1_import_get_GUID(fmu); + fmi1_boolean_t loggingOn = (fmu->callbacks->log_level > jm_log_level_nothing); + fmi1_component_t c = fmi1_capi_instantiate_model(fmu -> capi, instanceName, GUID, loggingOn); + if (c == NULL) { + return jm_status_error; + } else { + return jm_status_success; + } } void fmi1_import_free_model_instance(fmi1_import_t* fmu) { - fmi1_capi_free_model_instance(fmu -> capi); + fmi1_capi_free_model_instance(fmu -> capi); } fmi1_status_t fmi1_import_set_time(fmi1_import_t* fmu, fmi1_real_t time) { - return fmi1_capi_set_time(fmu -> capi, time); + return fmi1_capi_set_time(fmu -> capi, time); } fmi1_status_t fmi1_import_set_continuous_states(fmi1_import_t* fmu, const fmi1_real_t x[], size_t nx) { - return fmi1_capi_set_continuous_states(fmu -> capi, x, nx); + return fmi1_capi_set_continuous_states(fmu -> capi, x, nx); } fmi1_status_t fmi1_import_completed_integrator_step(fmi1_import_t* fmu, fmi1_boolean_t* callEventUpdate) { - return fmi1_capi_completed_integrator_step(fmu -> capi, callEventUpdate); + return fmi1_capi_completed_integrator_step(fmu -> capi, callEventUpdate); } fmi1_status_t fmi1_import_initialize(fmi1_import_t* fmu, fmi1_boolean_t toleranceControlled, fmi1_real_t relativeTolerance, fmi1_event_info_t* eventInfo) { - return fmi1_capi_initialize(fmu -> capi, toleranceControlled, relativeTolerance, eventInfo); + return fmi1_capi_initialize(fmu -> capi, toleranceControlled, relativeTolerance, eventInfo); } fmi1_status_t fmi1_import_get_derivatives(fmi1_import_t* fmu, fmi1_real_t derivatives[], size_t nx) { - return fmi1_capi_get_derivatives(fmu -> capi, derivatives, nx); + return fmi1_capi_get_derivatives(fmu -> capi, derivatives, nx); } fmi1_status_t fmi1_import_get_event_indicators(fmi1_import_t* fmu, fmi1_real_t eventIndicators[], size_t ni) { - return fmi1_capi_get_event_indicators(fmu -> capi, eventIndicators, ni); + return fmi1_capi_get_event_indicators(fmu -> capi, eventIndicators, ni); } fmi1_status_t fmi1_import_eventUpdate(fmi1_import_t* fmu, fmi1_boolean_t intermediateResults, fmi1_event_info_t* eventInfo) { - return fmi1_capi_eventUpdate(fmu -> capi, intermediateResults, eventInfo); + return fmi1_capi_eventUpdate(fmu -> capi, intermediateResults, eventInfo); } fmi1_status_t fmi1_import_get_continuous_states(fmi1_import_t* fmu, fmi1_real_t states[], size_t nx) { - return fmi1_capi_get_continuous_states(fmu -> capi, states, nx); + return fmi1_capi_get_continuous_states(fmu -> capi, states, nx); } fmi1_status_t fmi1_import_get_nominal_continuous_states(fmi1_import_t* fmu, fmi1_real_t x_nominal[], size_t nx) { - return fmi1_capi_get_nominal_continuous_states(fmu -> capi, x_nominal, nx); + return fmi1_capi_get_nominal_continuous_states(fmu -> capi, x_nominal, nx); } fmi1_status_t fmi1_import_get_state_value_references(fmi1_import_t* fmu, fmi1_value_reference_t vrx[], size_t nx) { - return fmi1_capi_get_state_value_references(fmu -> capi, vrx, nx); + return fmi1_capi_get_state_value_references(fmu -> capi, vrx, nx); } fmi1_status_t fmi1_import_terminate(fmi1_import_t* fmu) { - return fmi1_capi_terminate(fmu -> capi); + return fmi1_capi_terminate(fmu -> capi); } /* FMI 1.0 CS functions */ const char* fmi1_import_get_types_platform(fmi1_import_t* fmu) { - return fmi1_capi_get_types_platform(fmu -> capi); + return fmi1_capi_get_types_platform(fmu -> capi); } jm_status_enu_t fmi1_import_instantiate_slave(fmi1_import_t* fmu, fmi1_string_t instanceName, fmi1_string_t fmuLocation, fmi1_string_t mimeType, - fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive) { - fmi1_string_t fmuGUID = fmi1_import_get_GUID(fmu); - fmi1_boolean_t loggingOn = (fmu->callbacks->log_level > jm_log_level_nothing); - fmi1_component_t c; - if(!mimeType) mimeType = "application/x-fmu-sharedlibrary"; - if(!fmuLocation) fmuLocation = fmu->location; - jm_log_verbose(fmu->callbacks, module, "Instantiating the slave with \n" - "\tFMU location ='%s'\n\tMIME type = '%s'", fmuLocation, mimeType); - - c = fmi1_capi_instantiate_slave(fmu -> capi, instanceName, fmuGUID, fmuLocation, mimeType, timeout, visible, interactive, loggingOn); - if (c == NULL) { - return jm_status_error; - } else { - return jm_status_success; - } + fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive) { + fmi1_string_t fmuGUID = fmi1_import_get_GUID(fmu); + fmi1_boolean_t loggingOn = (fmu->callbacks->log_level > jm_log_level_nothing); + fmi1_component_t c; + if(!mimeType) mimeType = "application/x-fmu-sharedlibrary"; + if(!fmuLocation) fmuLocation = fmu->location; + jm_log_verbose(fmu->callbacks, module, "Instantiating the slave with \n" + "\tFMU location ='%s'\n\tMIME type = '%s'", fmuLocation, mimeType); + + c = fmi1_capi_instantiate_slave(fmu -> capi, instanceName, fmuGUID, fmuLocation, mimeType, timeout, visible, interactive, loggingOn); + if (c == NULL) { + return jm_status_error; + } else { + return jm_status_success; + } } fmi1_status_t fmi1_import_initialize_slave(fmi1_import_t* fmu, fmi1_real_t tStart, fmi1_boolean_t StopTimeDefined, fmi1_real_t tStop) { - return fmi1_capi_initialize_slave(fmu -> capi, tStart, StopTimeDefined, tStop); + return fmi1_capi_initialize_slave(fmu -> capi, tStart, StopTimeDefined, tStop); } fmi1_status_t fmi1_import_terminate_slave(fmi1_import_t* fmu) { - return fmi1_capi_terminate_slave(fmu -> capi); + return fmi1_capi_terminate_slave(fmu -> capi); } fmi1_status_t fmi1_import_reset_slave(fmi1_import_t* fmu) { - return fmi1_capi_reset_slave(fmu -> capi); + return fmi1_capi_reset_slave(fmu -> capi); } void fmi1_import_free_slave_instance(fmi1_import_t* fmu) { - fmi1_capi_free_slave_instance(fmu -> capi); + fmi1_capi_free_slave_instance(fmu -> capi); } fmi1_status_t fmi1_import_set_real_input_derivatives(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], const fmi1_real_t value[]) { - return fmi1_capi_set_real_input_derivatives(fmu -> capi, vr, nvr, order, value); + return fmi1_capi_set_real_input_derivatives(fmu -> capi, vr, nvr, order, value); } fmi1_status_t fmi1_import_get_real_output_derivatives(fmi1_import_t* fmu, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], fmi1_real_t value[]) { - return fmi1_capi_get_real_output_derivatives(fmu -> capi, vr, nvr, order, value); + return fmi1_capi_get_real_output_derivatives(fmu -> capi, vr, nvr, order, value); } fmi1_status_t fmi1_import_cancel_step(fmi1_import_t* fmu) { - return fmi1_capi_cancel_step(fmu -> capi); + return fmi1_capi_cancel_step(fmu -> capi); } fmi1_status_t fmi1_import_do_step(fmi1_import_t* fmu, fmi1_real_t currentCommunicationPoint, fmi1_real_t communicationStepSize, fmi1_boolean_t newStep) { - return fmi1_capi_do_step(fmu -> capi, currentCommunicationPoint, communicationStepSize, newStep); + return fmi1_capi_do_step(fmu -> capi, currentCommunicationPoint, communicationStepSize, newStep); } fmi1_status_t fmi1_import_get_status(fmi1_import_t* fmu, const fmi1_status_kind_t s, fmi1_status_t* value) { - return fmi1_capi_get_status(fmu -> capi, s, value); + return fmi1_capi_get_status(fmu -> capi, s, value); } fmi1_status_t fmi1_import_get_real_status(fmi1_import_t* fmu, const fmi1_status_kind_t s, fmi1_real_t* value) { - return fmi1_capi_get_real_status(fmu -> capi, s, value); + return fmi1_capi_get_real_status(fmu -> capi, s, value); } fmi1_status_t fmi1_import_get_integer_status(fmi1_import_t* fmu, const fmi1_status_kind_t s, fmi1_integer_t* value) { - return fmi1_capi_get_integer_status(fmu -> capi, s, value); + return fmi1_capi_get_integer_status(fmu -> capi, s, value); } fmi1_status_t fmi1_import_get_boolean_status(fmi1_import_t* fmu, const fmi1_status_kind_t s, fmi1_boolean_t* value) { - return fmi1_capi_get_boolean_status(fmu -> capi, s, value); + return fmi1_capi_get_boolean_status(fmu -> capi, s, value); } fmi1_status_t fmi1_import_get_string_status(fmi1_import_t* fmu, const fmi1_status_kind_t s, fmi1_string_t* value) { - return fmi1_capi_get_string_status(fmu -> capi, s, value); + return fmi1_capi_get_string_status(fmu -> capi, s, value); } #ifdef __cplusplus diff --git a/src/Import/src/FMI1/fmi1_import_convenience.c b/src/Import/src/FMI1/fmi1_import_convenience.c index 280e1296..09c27498 100644 --- a/src/Import/src/FMI1/fmi1_import_convenience.c +++ b/src/Import/src/FMI1/fmi1_import_convenience.c @@ -23,68 +23,68 @@ #include "fmi1_import_impl.h" /** - \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi1_import_model_counts_t struct. - \param fmu - An fmu object as returned by fmi1_import_parse_xml(). - \param counts - a pointer to a preallocated struct. + \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi1_import_model_counts_t struct. + \param fmu - An fmu object as returned by fmi1_import_parse_xml(). + \param counts - a pointer to a preallocated struct. */ void fmi1_import_collect_model_counts(fmi1_import_t* fmu, fmi1_import_model_counts_t* counts) { - jm_vector(jm_voidp)* vars = fmi1_xml_get_variables_original_order(fmu->md); + jm_vector(jm_voidp)* vars = fmi1_xml_get_variables_original_order(fmu->md); size_t nv, i; - memset(counts,0,sizeof(fmi1_import_model_counts_t)); - if(!vars) return; - nv = jm_vector_get_size(jm_voidp)(vars); + memset(counts,0,sizeof(fmi1_import_model_counts_t)); + if(!vars) return; + nv = jm_vector_get_size(jm_voidp)(vars); for(i = 0; i< nv; i++) { - fmi1_xml_variable_t* var = (fmi1_xml_variable_t*)jm_vector_get_item(jm_voidp)(vars, i); - switch (fmi1_xml_get_variability(var)) { - case fmi1_variability_enu_constant: - counts->num_constants++; - break; - case fmi1_variability_enu_parameter: - counts->num_parameters++; - break; - case fmi1_variability_enu_discrete: - counts->num_discrete++; - break; - case fmi1_variability_enu_continuous: - counts->num_continuous++; - break; - default: - assert(0); - } - switch(fmi1_xml_get_causality(var)) { - case fmi1_causality_enu_none: - counts->num_causality_none++; - break; - case fmi1_causality_enu_input: - counts->num_inputs++; - break; - case fmi1_causality_enu_output: - counts->num_outputs++; - break; - case fmi1_causality_enu_internal: - counts->num_internal++; - break; - default: assert(0); - } - switch(fmi1_xml_get_variable_base_type(var)) { - case fmi1_base_type_real: - counts->num_real_vars++; - break; - case fmi1_base_type_int: - counts->num_integer_vars++; - break; - case fmi1_base_type_bool: - counts->num_bool_vars++; - break; - case fmi1_base_type_str: - counts->num_string_vars++; - break; - case fmi1_base_type_enum: - counts->num_enum_vars++; - break; - default: - assert(0); - } + fmi1_xml_variable_t* var = (fmi1_xml_variable_t*)jm_vector_get_item(jm_voidp)(vars, i); + switch (fmi1_xml_get_variability(var)) { + case fmi1_variability_enu_constant: + counts->num_constants++; + break; + case fmi1_variability_enu_parameter: + counts->num_parameters++; + break; + case fmi1_variability_enu_discrete: + counts->num_discrete++; + break; + case fmi1_variability_enu_continuous: + counts->num_continuous++; + break; + default: + assert(0); + } + switch(fmi1_xml_get_causality(var)) { + case fmi1_causality_enu_none: + counts->num_causality_none++; + break; + case fmi1_causality_enu_input: + counts->num_inputs++; + break; + case fmi1_causality_enu_output: + counts->num_outputs++; + break; + case fmi1_causality_enu_internal: + counts->num_internal++; + break; + default: assert(0); + } + switch(fmi1_xml_get_variable_base_type(var)) { + case fmi1_base_type_real: + counts->num_real_vars++; + break; + case fmi1_base_type_int: + counts->num_integer_vars++; + break; + case fmi1_base_type_bool: + counts->num_bool_vars++; + break; + case fmi1_base_type_str: + counts->num_string_vars++; + break; + case fmi1_base_type_enum: + counts->num_enum_vars++; + break; + default: + assert(0); + } } return; } @@ -92,130 +92,130 @@ void fmi1_import_collect_model_counts(fmi1_import_t* fmu, fmi1_import_model_coun void fmi1_import_expand_variable_references_impl(fmi1_import_t* fmu, const char* msgIn); void fmi1_import_expand_variable_references(fmi1_import_t* fmu, const char* msgIn, char* msgOut, size_t maxMsgSize) { - fmi1_import_expand_variable_references_impl(fmu, msgIn); - strncpy(msgOut, jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0),maxMsgSize); - msgOut[maxMsgSize - 1] = '\0'; + fmi1_import_expand_variable_references_impl(fmu, msgIn); + strncpy(msgOut, jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0),maxMsgSize); + msgOut[maxMsgSize - 1] = '\0'; } /* Print msgIn into msgOut by expanding variable references of the form ## into variable names and replacing '##' with a single # */ void fmi1_import_expand_variable_references_impl(fmi1_import_t* fmu, const char* msgIn){ - jm_vector(char)* msgOut = &fmu->logMessageBufferExpanded; - fmi1_xml_model_description_t* md = fmu->md; - jm_callbacks* callbacks = fmu->callbacks; + jm_vector(char)* msgOut = &fmu->logMessageBufferExpanded; + fmi1_xml_model_description_t* md = fmu->md; + jm_callbacks* callbacks = fmu->callbacks; char curCh; - const char* firstRef; + const char* firstRef; size_t i; /* next char index after curCh in msgIn*/ - size_t msgLen = strlen(msgIn)+1; /* original message length including terminating 0 */ + size_t msgLen = strlen(msgIn)+1; /* original message length including terminating 0 */ - if(jm_vector_reserve(char)(msgOut, msgLen + 100) < msgLen + 100) { - jm_log(fmu->callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); - jm_vector_resize(char)(msgOut, 6); - memcpy(jm_vector_get_itemp(char)(msgOut,0),"ERROR",6); /* at least 16 chars are always there */ - return; - } + if(jm_vector_reserve(char)(msgOut, msgLen + 100) < msgLen + 100) { + jm_log(fmu->callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); + jm_vector_resize(char)(msgOut, 6); + memcpy(jm_vector_get_itemp(char)(msgOut,0),"ERROR",6); /* at least 16 chars are always there */ + return; + } - /* check if there are any refs at all and copy the head of the string without references */ - firstRef = strchr(msgIn, '#'); - if(firstRef) { - i = firstRef - msgIn; - jm_vector_resize(char)(msgOut, i); - if(i) { - memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, i); - } - curCh = msgIn[i++]; - } - else { - jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, msgLen); - return; - } + /* check if there are any refs at all and copy the head of the string without references */ + firstRef = strchr(msgIn, '#'); + if(firstRef) { + i = firstRef - msgIn; + jm_vector_resize(char)(msgOut, i); + if(i) { + memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, i); + } + curCh = msgIn[i++]; + } + else { + jm_vector_resize(char)(msgOut, msgLen); + memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, msgLen); + return; + } do { if (curCh!='#') { jm_vector_push_back(char)(msgOut, curCh); /* copy in to out */ } - else if(msgIn[i] == '#') { - jm_vector_push_back(char)(msgOut, '#'); - i++; /* skip the second # */ - } - else { - fmi1_value_reference_t vr = fmi1_undefined_value_reference; - char typeChar = msgIn[i++]; - size_t pastePos = jm_vector_get_size(char)(msgOut); - fmi1_base_type_enu_t baseType; - size_t num_digits; - fmi1_xml_variable_t* var; - const char* name; - size_t nameLen; - switch(typeChar) { - case 'r': - baseType = fmi1_base_type_real; - break; - case 'i': - baseType = fmi1_base_type_int; - break; - case 'b': - baseType = fmi1_base_type_bool; - break; - case 's': - baseType = fmi1_base_type_str; - break; - default: - jm_vector_push_back(char)(msgOut, 0); - jm_log(callbacks,"LOGGER", jm_log_level_warning, - "Expected type specification character 'r', 'i', 'b' or 's' in log message here: '%s'", - jm_vector_get_itemp(char)(msgOut,0)); + else if(msgIn[i] == '#') { + jm_vector_push_back(char)(msgOut, '#'); + i++; /* skip the second # */ + } + else { + fmi1_value_reference_t vr = fmi1_undefined_value_reference; + char typeChar = msgIn[i++]; + size_t pastePos = jm_vector_get_size(char)(msgOut); + fmi1_base_type_enu_t baseType; + size_t num_digits; + fmi1_xml_variable_t* var; + const char* name; + size_t nameLen; + switch(typeChar) { + case 'r': + baseType = fmi1_base_type_real; + break; + case 'i': + baseType = fmi1_base_type_int; + break; + case 'b': + baseType = fmi1_base_type_bool; + break; + case 's': + baseType = fmi1_base_type_str; + break; + default: + jm_vector_push_back(char)(msgOut, 0); + jm_log(callbacks,"LOGGER", jm_log_level_warning, + "Expected type specification character 'r', 'i', 'b' or 's' in log message here: '%s'", + jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } curCh = msgIn[i++]; - while( isdigit(curCh) ) { - jm_vector_push_back(char)(msgOut, curCh); - curCh = msgIn[i++]; - } - num_digits = jm_vector_get_size(char)(msgOut) - pastePos; - jm_vector_push_back(char)(msgOut, 0); - if(num_digits == 0) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + while( isdigit(curCh) ) { + jm_vector_push_back(char)(msgOut, curCh); + curCh = msgIn[i++]; + } + num_digits = jm_vector_get_size(char)(msgOut) - pastePos; + jm_vector_push_back(char)(msgOut, 0); + if(num_digits == 0) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } - else if(curCh != '#') { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected terminating '#' in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } + else if(curCh != '#') { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected terminating '#' in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } - - if(sscanf(jm_vector_get_itemp(char)(msgOut, pastePos), "%u",&vr) != 1) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not decode value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } + + if(sscanf(jm_vector_get_itemp(char)(msgOut, pastePos), "%u",&vr) != 1) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not decode value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } - var = fmi1_xml_get_variable_by_vr(md,baseType,vr); - if(!var) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not find variable referenced in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } + var = fmi1_xml_get_variable_by_vr(md,baseType,vr); + if(!var) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not find variable referenced in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } - name = fmi1_xml_get_variable_name(var); - nameLen = strlen(name); - if(jm_vector_resize(char)(msgOut, pastePos + nameLen) != pastePos + nameLen) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } + name = fmi1_xml_get_variable_name(var); + nameLen = strlen(name); + if(jm_vector_resize(char)(msgOut, pastePos + nameLen) != pastePos + nameLen) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - }; - memcpy(jm_vector_get_itemp(char)(msgOut, pastePos), name, nameLen); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + }; + memcpy(jm_vector_get_itemp(char)(msgOut, pastePos), name, nameLen); } curCh = msgIn[i++]; } while (curCh); @@ -231,76 +231,76 @@ jm_vector(jm_voidp)* fmi1_import_active_fmu = 0; void fmi1_log_forwarding(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...) { va_list args; va_start (args, message); - fmi1_log_forwarding_v(c, instanceName, status, category, message, args); + fmi1_log_forwarding_v(c, instanceName, status, category, message, args); va_end (args); } 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) { #define BUFSIZE JM_MAX_ERROR_MESSAGE_SIZE char buffer[BUFSIZE], *buf, *curp, *msg; - const char* statusStr; - fmi1_import_t* fmu = 0; - jm_callbacks* cb = jm_get_default_callbacks(); - jm_log_level_enu_t logLevel = jm_log_level_error; - if(fmi1_import_active_fmu) { - size_t n = jm_vector_get_size(jm_voidp)(fmi1_import_active_fmu); - size_t i; - for(i= 0; i < n; i++) { - fmu = (fmi1_import_t*)jm_vector_get_item(jm_voidp)(fmi1_import_active_fmu, i); - if(fmu->capi->c == c) { - cb = fmu->callbacks; - break; - } - } - if(i >= n) { /* Could not find matching FMU -> use default callbacks */ - fmu = 0; - cb = jm_get_default_callbacks(); - } - } + const char* statusStr; + fmi1_import_t* fmu = 0; + jm_callbacks* cb = jm_get_default_callbacks(); + jm_log_level_enu_t logLevel = jm_log_level_error; + if(fmi1_import_active_fmu) { + size_t n = jm_vector_get_size(jm_voidp)(fmi1_import_active_fmu); + size_t i; + for(i= 0; i < n; i++) { + fmu = (fmi1_import_t*)jm_vector_get_item(jm_voidp)(fmi1_import_active_fmu, i); + if(fmu->capi->c == c) { + cb = fmu->callbacks; + break; + } + } + if(i >= n) { /* Could not find matching FMU -> use default callbacks */ + fmu = 0; + cb = jm_get_default_callbacks(); + } + } if(fmu) { buf = jm_vector_get_itemp(char)(&fmu->logMessageBufferCoded,0); - } - else { + } + else { buf = buffer; } - switch(status) { - case fmi1_status_discard: - case fmi1_status_pending: - case fmi1_status_ok: - logLevel = jm_log_level_info; - break; - case fmi1_status_warning: - logLevel = jm_log_level_warning; - break; - case fmi1_status_error: - logLevel = jm_log_level_error; - break; - case fmi1_status_fatal: - default: - logLevel = jm_log_level_fatal; - } + switch(status) { + case fmi1_status_discard: + case fmi1_status_pending: + case fmi1_status_ok: + logLevel = jm_log_level_info; + break; + case fmi1_status_warning: + logLevel = jm_log_level_warning; + break; + case fmi1_status_error: + logLevel = jm_log_level_error; + break; + case fmi1_status_fatal: + default: + logLevel = jm_log_level_fatal; + } if(logLevel > cb->log_level) return; - curp = buf; + curp = buf; *curp = 0; - if(category) { + if(category) { curp += jm_snprintf(curp, 100, "[%s]", category); } - statusStr = fmi1_status_to_string(status); + statusStr = fmi1_status_to_string(status); curp += jm_snprintf(curp, 100,"[FMU status:%s] ", statusStr); - if(fmu) { - int bufsize = jm_vector_get_size(char)(&fmu->logMessageBufferCoded); + if(fmu) { + int bufsize = jm_vector_get_size(char)(&fmu->logMessageBufferCoded); int len; #ifdef JM_VA_COPY va_list argscp; JM_VA_COPY(argscp, args); #endif - /* WARNING: - * We don't handle the compiler/platform dependent case when vsnprintf - * returns -1 on failure to write the full message. */ + /* WARNING: + * We don't handle the compiler/platform dependent case when vsnprintf + * returns -1 on failure to write the full message. */ len = jm_vsnprintf(curp, bufsize -(curp-buf), message, args); if(len > (bufsize -(curp-buf+1))) { int offset = (curp-buf); @@ -314,18 +314,18 @@ void fmi1_log_forwarding_v(fmi1_component_t c, fmi1_string_t instanceName, fmi1 #ifdef JM_VA_COPY va_end(argscp); #endif - fmi1_import_expand_variable_references(fmu, buf, cb->errMessageBuffer,JM_MAX_ERROR_MESSAGE_SIZE); - msg = jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0); - } - else { - jm_vsnprintf(curp, BUFSIZE -(curp-buf), message, args); + fmi1_import_expand_variable_references(fmu, buf, cb->errMessageBuffer,JM_MAX_ERROR_MESSAGE_SIZE); + msg = jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0); + } + else { + jm_vsnprintf(curp, BUFSIZE -(curp-buf), message, args); strncpy(cb->errMessageBuffer, buf, JM_MAX_ERROR_MESSAGE_SIZE); - cb->errMessageBuffer[JM_MAX_ERROR_MESSAGE_SIZE - 1] = '\0'; - msg = cb->errMessageBuffer; - } - if(cb->logger) { - cb->logger(cb, instanceName, logLevel, msg); - } + cb->errMessageBuffer[JM_MAX_ERROR_MESSAGE_SIZE - 1] = '\0'; + msg = cb->errMessageBuffer; + } + if(cb->logger) { + cb->logger(cb, instanceName, logLevel, msg); + } } 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, ...) { @@ -348,30 +348,30 @@ void fmi1_default_callback_logger(fmi1_component_t c, fmi1_string_t instanceNam } void fmi1_logger(jm_callbacks* cb, jm_string module, jm_log_level_enu_t log_level, jm_string message) { - fmi1_callback_functions_t* c = (fmi1_callback_functions_t*)cb->context; - fmi1_status_t status; - if(!c ||!c->logger) return; + fmi1_callback_functions_t* c = (fmi1_callback_functions_t*)cb->context; + fmi1_status_t status; + if(!c ||!c->logger) return; - if(log_level > jm_log_level_all) { - assert(0); - status = fmi1_status_error; - } - else if(log_level >= jm_log_level_info) - status = fmi1_status_ok; - else if(log_level >= jm_log_level_warning) - status = fmi1_status_warning; - else if(log_level >= jm_log_level_error) - status = fmi1_status_error; - else if(log_level >= jm_log_level_fatal) - status = fmi1_status_fatal; - else { - status = fmi1_status_ok; - } + if(log_level > jm_log_level_all) { + assert(0); + status = fmi1_status_error; + } + else if(log_level >= jm_log_level_info) + status = fmi1_status_ok; + else if(log_level >= jm_log_level_warning) + status = fmi1_status_warning; + else if(log_level >= jm_log_level_error) + status = fmi1_status_error; + else if(log_level >= jm_log_level_fatal) + status = fmi1_status_fatal; + else { + status = fmi1_status_ok; + } - c->logger( c, module, status, jm_log_level_to_string(log_level), message); + c->logger( c, module, status, jm_log_level_to_string(log_level), message); } void fmi1_import_init_logger(jm_callbacks* cb, fmi1_callback_functions_t* fmiCallbacks) { - cb->logger = fmi1_logger; - cb->context = fmiCallbacks; + cb->logger = fmi1_logger; + cb->context = fmiCallbacks; } diff --git a/src/Import/src/FMI1/fmi1_import_cosim.c b/src/Import/src/FMI1/fmi1_import_cosim.c index 290a51f7..30ea545c 100644 --- a/src/Import/src/FMI1/fmi1_import_cosim.c +++ b/src/Import/src/FMI1/fmi1_import_cosim.c @@ -29,12 +29,12 @@ size_t fmi1_import_get_number_of_additional_models(fmi1_import_t* fmu) { } const char* fmi1_import_get_additional_model_name(fmi1_import_t* fmu, size_t index) { - return fmi1_xml_get_additional_model_name(fmu->md, index); + return fmi1_xml_get_additional_model_name(fmu->md, index); } const char* fmi1_import_get_entry_point(fmi1_import_t* fmu) { - return fmi1_xml_get_entry_point(fmu->md); + return fmi1_xml_get_entry_point(fmu->md); } const char* fmi1_import_get_mime_type(fmi1_import_t* fmu){ diff --git a/src/Import/src/FMI1/fmi1_import_impl.h b/src/Import/src/FMI1/fmi1_import_impl.h index bf9dda8e..8459af40 100644 --- a/src/Import/src/FMI1/fmi1_import_impl.h +++ b/src/Import/src/FMI1/fmi1_import_impl.h @@ -34,16 +34,16 @@ extern "C" { #endif -struct fmi1_import_t { - char* dirPath; - char* location; - jm_callbacks* callbacks; - fmi1_xml_model_description_t* md; - fmi1_capi_t* capi; - int registerGlobally; - jm_vector(char) logMessageBufferCoded; - jm_vector(char) logMessageBufferExpanded; - fmi_util_options_t* options; +struct fmi1_import_t { + char* dirPath; + char* location; + jm_callbacks* callbacks; + fmi1_xml_model_description_t* md; + fmi1_capi_t* capi; + int registerGlobally; + jm_vector(char) logMessageBufferCoded; + jm_vector(char) logMessageBufferExpanded; + fmi_util_options_t* options; }; extern jm_callbacks fmi1_import_active_fmu_store_callbacks; diff --git a/src/Import/src/FMI1/fmi1_import_type.c b/src/Import/src/FMI1/fmi1_import_type.c index 19a7cab6..f7ec8d73 100644 --- a/src/Import/src/FMI1/fmi1_import_type.c +++ b/src/Import/src/FMI1/fmi1_import_type.c @@ -20,90 +20,90 @@ #include "fmi1_import_impl.h" fmi1_import_display_unit_t* fmi1_import_get_type_display_unit(fmi1_import_real_typedef_t* t) { - return fmi1_xml_get_type_display_unit(t); + return fmi1_xml_get_type_display_unit(t); } size_t fmi1_import_get_type_definition_number(fmi1_import_type_definitions_t* td) { - return fmi1_xml_get_type_definition_number(td); + return fmi1_xml_get_type_definition_number(td); } fmi1_import_variable_typedef_t* fmi1_import_get_typedef(fmi1_import_type_definitions_t* td, unsigned int index) { - return fmi1_xml_get_typedef(td, index); + return fmi1_xml_get_typedef(td, index); } const char* fmi1_import_get_type_name(fmi1_import_variable_typedef_t* t) { - return fmi1_xml_get_type_name(t); + return fmi1_xml_get_type_name(t); } /* Note that NULL pointer is returned if the attribute is not present in the XML.*/ const char* fmi1_import_get_type_description(fmi1_import_variable_typedef_t* t) { - return fmi1_xml_get_type_description(t); + return fmi1_xml_get_type_description(t); } fmi1_base_type_enu_t fmi1_import_get_base_type(fmi1_import_variable_typedef_t* t) { - return fmi1_xml_get_base_type(t); + return fmi1_xml_get_base_type(t); } fmi1_import_real_typedef_t* fmi1_import_get_type_as_real(fmi1_import_variable_typedef_t* t) { - return fmi1_xml_get_type_as_real(t); + return fmi1_xml_get_type_as_real(t); } fmi1_import_integer_typedef_t* fmi1_import_get_type_as_int(fmi1_import_variable_typedef_t* t) { - return fmi1_xml_get_type_as_int(t); + return fmi1_xml_get_type_as_int(t); } fmi1_import_enumeration_typedef_t* fmi1_import_get_type_as_enum(fmi1_import_variable_typedef_t* t) { - return fmi1_xml_get_type_as_enum(t); + return fmi1_xml_get_type_as_enum(t); } const char* fmi1_import_get_type_quantity(fmi1_import_variable_typedef_t* t) { - return fmi1_xml_get_type_quantity(t); + return fmi1_xml_get_type_quantity(t); } fmi1_real_t fmi1_import_get_real_type_min(fmi1_import_real_typedef_t* t) { - return fmi1_xml_get_real_type_min(t); + return fmi1_xml_get_real_type_min(t); } fmi1_real_t fmi1_import_get_real_type_max(fmi1_import_real_typedef_t* t) { - return fmi1_xml_get_real_type_max(t); + return fmi1_xml_get_real_type_max(t); } fmi1_real_t fmi1_import_get_real_type_nominal(fmi1_import_real_typedef_t* t) { - return fmi1_xml_get_real_type_nominal(t); + return fmi1_xml_get_real_type_nominal(t); } fmi1_import_unit_t* fmi1_import_get_real_type_unit(fmi1_import_real_typedef_t* t) { - return fmi1_xml_get_real_type_unit(t); + return fmi1_xml_get_real_type_unit(t); } int fmi1_import_get_real_type_is_relative_quantity(fmi1_import_real_typedef_t* t) { - return fmi1_xml_get_real_type_is_relative_quantity(t); + return fmi1_xml_get_real_type_is_relative_quantity(t); } fmi1_integer_t fmi1_import_get_integer_type_min(fmi1_import_integer_typedef_t* t) { - return fmi1_xml_get_integer_type_min(t); + return fmi1_xml_get_integer_type_min(t); } fmi1_integer_t fmi1_import_get_integer_type_max(fmi1_import_integer_typedef_t* t){ - return fmi1_xml_get_integer_type_max(t); + return fmi1_xml_get_integer_type_max(t); } unsigned int fmi1_import_get_enum_type_min(fmi1_import_enumeration_typedef_t* t){ - return fmi1_xml_get_enum_type_min(t); + return fmi1_xml_get_enum_type_min(t); } unsigned int fmi1_import_get_enum_type_max(fmi1_import_enumeration_typedef_t* t){ - return fmi1_xml_get_enum_type_max(t); + return fmi1_xml_get_enum_type_max(t); } unsigned int fmi1_import_get_enum_type_size(fmi1_import_enumeration_typedef_t* t) { - return fmi1_xml_get_enum_type_size(t); + return fmi1_xml_get_enum_type_size(t); } const char* fmi1_import_get_enum_type_item_name(fmi1_import_enumeration_typedef_t* t, unsigned int item) { - return fmi1_xml_get_enum_type_item_name(t, item); + return fmi1_xml_get_enum_type_item_name(t, item); } const char* fmi1_import_get_enum_type_item_description(fmi1_import_enumeration_typedef_t* t, unsigned int item){ - return fmi1_xml_get_enum_type_item_description(t, item); + return fmi1_xml_get_enum_type_item_description(t, item); } diff --git a/src/Import/src/FMI1/fmi1_import_unit.c b/src/Import/src/FMI1/fmi1_import_unit.c index b667b79c..97746be9 100644 --- a/src/Import/src/FMI1/fmi1_import_unit.c +++ b/src/Import/src/FMI1/fmi1_import_unit.c @@ -16,31 +16,31 @@ #include "fmi1_import_impl.h" fmi1_import_unit_t* fmi1_import_get_unit(fmi1_import_unit_definitions_t* ud, unsigned int index) { - return fmi1_xml_get_unit(ud, index); + return fmi1_xml_get_unit(ud, index); } const char* fmi1_import_get_unit_name(fmi1_import_unit_t* u) { - return fmi1_xml_get_unit_name(u); + return fmi1_xml_get_unit_name(u); } unsigned int fmi1_import_get_unit_display_unit_number(fmi1_import_unit_t* u) { - return fmi1_xml_get_unit_display_unit_number(u); + return fmi1_xml_get_unit_display_unit_number(u); } fmi1_import_display_unit_t* fmi1_import_get_unit_display_unit(fmi1_import_unit_t* u, size_t index) { - return fmi1_xml_get_unit_display_unit(u, index); + return fmi1_xml_get_unit_display_unit(u, index); } fmi1_import_unit_t* fmi1_import_get_base_unit(fmi1_import_display_unit_t* du) { - return fmi1_xml_get_base_unit(du); + return fmi1_xml_get_base_unit(du); } const char* fmi1_import_get_display_unit_name(fmi1_import_display_unit_t* du) { - return fmi1_xml_get_display_unit_name(du); + return fmi1_xml_get_display_unit_name(du); } fmi1_real_t fmi1_import_get_display_unit_gain(fmi1_import_display_unit_t* du) { - return fmi1_xml_get_display_unit_gain(du); + return fmi1_xml_get_display_unit_gain(du); } fmi1_real_t fmi1_import_get_display_unit_offset(fmi1_import_display_unit_t* du) { diff --git a/src/Import/src/FMI1/fmi1_import_variable.c b/src/Import/src/FMI1/fmi1_import_variable.c index 1c505a1b..266186a9 100644 --- a/src/Import/src/FMI1/fmi1_import_variable.c +++ b/src/Import/src/FMI1/fmi1_import_variable.c @@ -24,160 +24,160 @@ #include "fmi1_import_variable_list_impl.h" fmi1_import_variable_t* fmi1_import_get_variable_by_name(fmi1_import_t* fmu, const char* name) { - return fmi1_xml_get_variable_by_name(fmu->md, name); + return fmi1_xml_get_variable_by_name(fmu->md, name); } 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) { - return fmi1_xml_get_variable_by_vr(fmu->md, baseType, vr); + return fmi1_xml_get_variable_by_vr(fmu->md, baseType, vr); } const char* fmi1_import_get_variable_name(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_name(v); + return fmi1_xml_get_variable_name(v); } const char* fmi1_import_get_variable_description(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_description(v); + return fmi1_xml_get_variable_description(v); } fmi1_value_reference_t fmi1_import_get_variable_vr(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_vr(v); + return fmi1_xml_get_variable_vr(v); } /* For scalar variable gives the type definition is present */ fmi1_import_variable_typedef_t* fmi1_import_get_variable_declared_type(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_declared_type(v); + return fmi1_xml_get_variable_declared_type(v); } fmi1_base_type_enu_t fmi1_import_get_variable_base_type(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_base_type(v); + return fmi1_xml_get_variable_base_type(v); } int fmi1_import_get_variable_has_start(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_has_start(v); + return fmi1_xml_get_variable_has_start(v); } int fmi1_import_get_variable_is_fixed(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_is_fixed(v); + return fmi1_xml_get_variable_is_fixed(v); } fmi1_variability_enu_t fmi1_import_get_variability(fmi1_import_variable_t* v) { - return fmi1_xml_get_variability(v); + return fmi1_xml_get_variability(v); } fmi1_causality_enu_t fmi1_import_get_causality(fmi1_import_variable_t* v) { - return fmi1_xml_get_causality(v); + return fmi1_xml_get_causality(v); } /* DirectDependency is returned for variables with causality Output. Null pointer for others. */ fmi1_import_variable_list_t* fmi1_import_get_direct_dependency(fmi1_import_t* fmu, fmi1_import_variable_t* v) { - fmi1_import_variable_list_t* list = fmi1_import_alloc_variable_list(fmu, fmi1_xml_get_direct_dependency_size(fmu->md,v)); - if(fmi1_xml_get_direct_dependency(fmu->md,v,&list->variables) != jm_status_success) { - fmi1_import_free_variable_list(list); - return 0; - } - return list; + fmi1_import_variable_list_t* list = fmi1_import_alloc_variable_list(fmu, fmi1_xml_get_direct_dependency_size(fmu->md,v)); + if(fmi1_xml_get_direct_dependency(fmu->md,v,&list->variables) != jm_status_success) { + fmi1_import_free_variable_list(list); + return 0; + } + return list; } fmi1_import_real_variable_t* fmi1_import_get_variable_as_real(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_as_real(v); + return fmi1_xml_get_variable_as_real(v); } fmi1_import_integer_variable_t* fmi1_import_get_variable_as_integer(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_as_integer(v); + return fmi1_xml_get_variable_as_integer(v); } fmi1_import_enum_variable_t* fmi1_import_get_variable_as_enum(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_as_enum(v); + return fmi1_xml_get_variable_as_enum(v); } fmi1_import_string_variable_t* fmi1_import_get_variable_as_string(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_as_string(v); + return fmi1_xml_get_variable_as_string(v); } fmi1_import_bool_variable_t* fmi1_import_get_variable_as_boolean(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_as_boolean(v); + return fmi1_xml_get_variable_as_boolean(v); } fmi1_real_t fmi1_import_get_real_variable_start(fmi1_import_real_variable_t* v) { - return fmi1_xml_get_real_variable_start(v); + return fmi1_xml_get_real_variable_start(v); } fmi1_real_t fmi1_import_get_real_variable_max(fmi1_import_real_variable_t* v) { - return fmi1_xml_get_real_variable_max(v); + return fmi1_xml_get_real_variable_max(v); } fmi1_real_t fmi1_import_get_real_variable_min(fmi1_import_real_variable_t* v) { - return fmi1_xml_get_real_variable_min(v); + return fmi1_xml_get_real_variable_min(v); } fmi1_real_t fmi1_import_get_real_variable_nominal(fmi1_import_real_variable_t* v) { - return fmi1_xml_get_real_variable_nominal(v); + return fmi1_xml_get_real_variable_nominal(v); } fmi1_boolean_t fmi1_import_get_real_variable_relative_quantity(fmi1_import_real_variable_t* v) { - return fmi1_xml_get_real_variable_relative_quantity(v); + return fmi1_xml_get_real_variable_relative_quantity(v); } fmi1_string_t fmi1_import_get_real_variable_quantity(fmi1_import_real_variable_t* v) { - return fmi1_xml_get_real_variable_quantity(v); + return fmi1_xml_get_real_variable_quantity(v); } fmi1_import_unit_t* fmi1_import_get_real_variable_unit(fmi1_import_real_variable_t* v) { - return fmi1_xml_get_real_variable_unit(v); + return fmi1_xml_get_real_variable_unit(v); } fmi1_import_display_unit_t* fmi1_import_get_real_variable_display_unit(fmi1_import_real_variable_t* v){ - return fmi1_xml_get_real_variable_display_unit(v); + return fmi1_xml_get_real_variable_display_unit(v); } const char* fmi1_import_get_string_variable_start(fmi1_import_string_variable_t* v) { - return fmi1_xml_get_string_variable_start(v); + return fmi1_xml_get_string_variable_start(v); } fmi1_boolean_t fmi1_import_get_boolean_variable_start(fmi1_import_bool_variable_t* v){ - return fmi1_xml_get_boolean_variable_start(v); + return fmi1_xml_get_boolean_variable_start(v); } fmi1_string_t fmi1_import_get_integer_variable_quantity(fmi1_import_integer_variable_t* v) { - return fmi1_xml_get_integer_variable_quantity(v); + return fmi1_xml_get_integer_variable_quantity(v); } int fmi1_import_get_integer_variable_start(fmi1_import_integer_variable_t* v) { - return fmi1_xml_get_integer_variable_start(v); + return fmi1_xml_get_integer_variable_start(v); } int fmi1_import_get_integer_variable_min(fmi1_import_integer_variable_t* v) { - return fmi1_xml_get_integer_variable_min(v); + return fmi1_xml_get_integer_variable_min(v); } int fmi1_import_get_integer_variable_max(fmi1_import_integer_variable_t* v) { - return fmi1_xml_get_integer_variable_max(v); + return fmi1_xml_get_integer_variable_max(v); } fmi1_string_t fmi1_import_get_enum_variable_quantity(fmi1_import_enum_variable_t* v) { - return fmi1_xml_get_enum_variable_quantity(v); + return fmi1_xml_get_enum_variable_quantity(v); } int fmi1_import_get_enum_variable_start(fmi1_import_enum_variable_t* v) { - return fmi1_xml_get_enum_variable_start(v); + return fmi1_xml_get_enum_variable_start(v); } int fmi1_import_get_enum_variable_min(fmi1_import_enum_variable_t* v) { - return fmi1_xml_get_enum_variable_min(v); + return fmi1_xml_get_enum_variable_min(v); } int fmi1_import_get_enum_variable_max(fmi1_import_enum_variable_t* v) { - return fmi1_xml_get_enum_variable_max(v); + return fmi1_xml_get_enum_variable_max(v); } fmi1_variable_alias_kind_enu_t fmi1_import_get_variable_alias_kind(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_alias_kind(v); + return fmi1_xml_get_variable_alias_kind(v); } fmi1_import_variable_t* fmi1_import_get_variable_alias_base(fmi1_import_t* fmu,fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_alias_base(fmu->md, v); + return fmi1_xml_get_variable_alias_base(fmu->md, v); } /* @@ -185,14 +185,14 @@ fmi1_import_variable_t* fmi1_import_get_variable_alias_base(fmi1_import_t* fmu,f The list is ordered: base variable, aliases, negated aliases. */ fmi1_import_variable_list_t* fmi1_import_get_variable_aliases(fmi1_import_t* fmu,fmi1_import_variable_t* v) { - fmi1_import_variable_list_t* list = fmi1_import_alloc_variable_list(fmu, 0); - if(fmi1_xml_get_variable_aliases(fmu->md, v, &list->variables) != jm_status_success) { - fmi1_import_free_variable_list(list); - return 0; - } - return list; + fmi1_import_variable_list_t* list = fmi1_import_alloc_variable_list(fmu, 0); + if(fmi1_xml_get_variable_aliases(fmu->md, v, &list->variables) != jm_status_success) { + fmi1_import_free_variable_list(list); + return 0; + } + return list; } size_t fmi1_import_get_variable_original_order(fmi1_import_variable_t* v) { - return fmi1_xml_get_variable_original_order((fmi1_xml_variable_t*)v); + return fmi1_xml_get_variable_original_order((fmi1_xml_variable_t*)v); } diff --git a/src/Import/src/FMI1/fmi1_import_variable_list.c b/src/Import/src/FMI1/fmi1_import_variable_list.c index a8c217ab..0b54b65b 100644 --- a/src/Import/src/FMI1/fmi1_import_variable_list.c +++ b/src/Import/src/FMI1/fmi1_import_variable_list.c @@ -18,11 +18,11 @@ #include "fmi1_import_variable_list_impl.h" fmi1_import_variable_list_t* fmi1_import_alloc_variable_list(fmi1_import_t* fmu, size_t size) { - jm_callbacks* cb = fmu->callbacks; - fmi1_import_variable_list_t* vl = (fmi1_import_variable_list_t*)cb->malloc(sizeof(fmi1_import_variable_list_t)); + jm_callbacks* cb = fmu->callbacks; + fmi1_import_variable_list_t* vl = (fmi1_import_variable_list_t*)cb->malloc(sizeof(fmi1_import_variable_list_t)); if(!vl) return 0; vl->vr = 0; - vl->fmu = fmu; + vl->fmu = fmu; if(jm_vector_init(jm_voidp)(&vl->variables,size,cb) < size) { fmi1_import_free_variable_list(vl); return 0; @@ -32,26 +32,26 @@ fmi1_import_variable_list_t* fmi1_import_alloc_variable_list(fmi1_import_t* fmu, void fmi1_import_free_variable_list(fmi1_import_variable_list_t* vl) { jm_callbacks* cb; - if(!vl) return; - cb = vl->variables.callbacks; - cb->free(vl->vr); + if(!vl) return; + cb = vl->variables.callbacks; + cb->free(vl->vr); jm_vector_free_data(jm_voidp)(&vl->variables); cb->free(vl); } /* Get number of variables in a list */ size_t fmi1_import_get_variable_list_size(fmi1_import_variable_list_t* vl) { - if(vl) - return jm_vector_get_size(jm_voidp)(&vl->variables); - else - return 0; + if(vl) + return jm_vector_get_size(jm_voidp)(&vl->variables); + else + return 0; } /* Make a copy */ fmi1_import_variable_list_t* fmi1_import_clone_variable_list(fmi1_import_variable_list_t* vl) { fmi1_import_variable_list_t* copy; - if(!vl) return 0; - copy = fmi1_import_alloc_variable_list(vl->fmu, fmi1_import_get_variable_list_size(vl)); + if(!vl) return 0; + copy = fmi1_import_alloc_variable_list(vl->fmu, fmi1_import_get_variable_list_size(vl)); if(!copy) return 0; jm_vector_copy(jm_voidp)(©->variables, &vl->variables); return copy; @@ -65,12 +65,12 @@ fmi1_import_variable_list_t* fmi1_import_join_var_list(fmi1_import_variable_list if(!list) { return list; } - if(a) - jm_vector_copy(jm_voidp)(&list->variables,&a->variables); - if(b) { - jm_vector_resize(jm_voidp)(&list->variables,joinSize); - memcpy((void*)jm_vector_get_itemp(jm_voidp)(&list->variables,asize), (void*)jm_vector_get_itemp(jm_voidp)(&b->variables,0), sizeof(jm_voidp)*bsize); - } + if(a) + jm_vector_copy(jm_voidp)(&list->variables,&a->variables); + if(b) { + jm_vector_resize(jm_voidp)(&list->variables,joinSize); + memcpy((void*)jm_vector_get_itemp(jm_voidp)(&list->variables,asize), (void*)jm_vector_get_itemp(jm_voidp)(&b->variables,0), sizeof(jm_voidp)*bsize); + } return list; } @@ -108,27 +108,27 @@ jm_status_enu_t fmi1_import_var_list_push_back(fmi1_import_variable_list_t* list /* Get a pointer to the list of the value references for all the variables */ const fmi1_value_reference_t* fmi1_import_get_value_referece_list(fmi1_import_variable_list_t* vl) { if(!vl->vr) { - jm_callbacks* cb = vl->fmu->callbacks; + jm_callbacks* cb = vl->fmu->callbacks; size_t nv = fmi1_import_get_variable_list_size(vl); - unsigned i = (unsigned)nv; - assert( i == nv); - vl->vr = (fmi1_value_reference_t*)cb->malloc(nv * sizeof(fmi1_value_reference_t)); + unsigned i = (unsigned)nv; + assert( i == nv); + vl->vr = (fmi1_value_reference_t*)cb->malloc(nv * sizeof(fmi1_value_reference_t)); if(vl->vr) { for(i = 0; i < nv; i++) { - vl->vr[i] = fmi1_xml_get_variable_vr(fmi1_import_get_variable(vl, i)); + vl->vr[i] = fmi1_xml_get_variable_vr(fmi1_import_get_variable(vl, i)); } } - else return 0; + else return 0; } return vl->vr; } /* Get a single variable from the list*/ fmi1_import_variable_t* fmi1_import_get_variable(fmi1_import_variable_list_t* vl, unsigned int index) { - if(index >= fmi1_import_get_variable_list_size(vl)) - return 0; - else - return (fmi1_import_variable_t*)jm_vector_get_item(jm_voidp)(&vl->variables, index); + if(index >= fmi1_import_get_variable_list_size(vl)) + return 0; + else + return (fmi1_import_variable_t*)jm_vector_get_item(jm_voidp)(&vl->variables, index); } /* Operations on variable lists. Every operation creates a new list. */ @@ -151,13 +151,13 @@ fmi1_import_variable_list_t* fmi1_import_get_sublist(fmi1_import_variable_list_t It returns a sub-list list with the variables for which filter returned non-zero value. */ fmi1_import_variable_list_t* fmi1_import_filter_variables(fmi1_import_variable_list_t* vl, fmi1_import_variable_filter_function_ft filter, void* context) { size_t nv; - unsigned i; + unsigned i; fmi1_import_variable_list_t* out; nv = fmi1_import_get_variable_list_size(vl); - i = (unsigned) nv; - if(i != nv) return 0; /* this is not really possible */ - out = fmi1_import_alloc_variable_list(vl->fmu, 0); - if(!out) return 0; /* out of memory */ + i = (unsigned) nv; + if(i != nv) return 0; /* this is not really possible */ + out = fmi1_import_alloc_variable_list(vl->fmu, 0); + if(!out) return 0; /* out of memory */ for(i=0; i < nv;i++) { fmi1_import_variable_t* variable = fmi1_import_get_variable(vl, i); if(filter(variable, context)) diff --git a/src/Import/src/FMI1/fmi1_import_variable_list_impl.h b/src/Import/src/FMI1/fmi1_import_variable_list_impl.h index 331bc68a..2d0ec5c8 100644 --- a/src/Import/src/FMI1/fmi1_import_variable_list_impl.h +++ b/src/Import/src/FMI1/fmi1_import_variable_list_impl.h @@ -25,7 +25,7 @@ extern "C" { #endif struct fmi1_import_variable_list_t { - fmi1_import_t* fmu; + fmi1_import_t* fmu; jm_vector(jm_voidp) variables; fmi1_value_reference_t* vr; }; diff --git a/src/Import/src/FMI1/fmi1_import_vendor_annotations.c b/src/Import/src/FMI1/fmi1_import_vendor_annotations.c index f8e35267..814e8918 100644 --- a/src/Import/src/FMI1/fmi1_import_vendor_annotations.c +++ b/src/Import/src/FMI1/fmi1_import_vendor_annotations.c @@ -18,7 +18,7 @@ #include "fmi1_import_impl.h" const char* fmi1_import_get_vendor_name(fmi1_import_vendor_t* v) { - return fmi1_xml_get_vendor_name(v); + return fmi1_xml_get_vendor_name(v); } unsigned int fmi1_import_get_number_of_vendor_annotations(fmi1_import_vendor_t* v) { @@ -26,13 +26,13 @@ unsigned int fmi1_import_get_number_of_vendor_annotations(fmi1_import_vendor_t* } fmi1_import_annotation_t* fmi1_import_get_vendor_annotation(fmi1_import_vendor_t* v, unsigned int index) { - return fmi1_xml_get_vendor_annotation(v, index); + return fmi1_xml_get_vendor_annotation(v, index); } const char* fmi1_import_get_annotation_name(fmi1_import_annotation_t* a) { - return fmi1_xml_get_annotation_name(a); + return fmi1_xml_get_annotation_name(a); } const char* fmi1_import_get_annotation_value(fmi1_import_annotation_t* a) { - return fmi1_xml_get_annotation_value(a); + return fmi1_xml_get_annotation_value(a); } diff --git a/src/Import/src/FMI2/fmi2_import.c b/src/Import/src/FMI2/fmi2_import.c index cd7029e2..70268b65 100644 --- a/src/Import/src/FMI2/fmi2_import.c +++ b/src/Import/src/FMI2/fmi2_import.c @@ -34,30 +34,30 @@ static const char* module = "FMILIB"; #include "fmi2_import_parser.h" */ fmi2_import_t* fmi2_import_allocate(jm_callbacks* cb) { - fmi2_import_t* fmu = (fmi2_import_t*)cb->calloc(1, sizeof(fmi2_import_t)); + fmi2_import_t* fmu = (fmi2_import_t*)cb->calloc(1, sizeof(fmi2_import_t)); - if(!fmu || (jm_vector_init(char)(&fmu->logMessageBufferCoded,JM_MAX_ERROR_MESSAGE_SIZE,cb) < JM_MAX_ERROR_MESSAGE_SIZE)) { - jm_log_fatal(cb, module, "Could not allocate memory"); + if(!fmu || (jm_vector_init(char)(&fmu->logMessageBufferCoded,JM_MAX_ERROR_MESSAGE_SIZE,cb) < JM_MAX_ERROR_MESSAGE_SIZE)) { + jm_log_fatal(cb, module, "Could not allocate memory"); if(fmu) cb->free(fmu); - return 0; - } - fmu->dirPath = 0; - fmu->resourceLocation = 0; - fmu->callbacks = cb; - fmu->capi = 0; - fmu->md = fmi2_xml_allocate_model_description(cb); - jm_vector_init(char)(&fmu->logMessageBufferExpanded,0,cb); - - if(!fmu->md) { - goto err1; - } - - fmu->options = fmi_util_allocate_options(cb); - if(!fmu->options) { - goto err2; - } - - return fmu; + return 0; + } + fmu->dirPath = 0; + fmu->resourceLocation = 0; + fmu->callbacks = cb; + fmu->capi = 0; + fmu->md = fmi2_xml_allocate_model_description(cb); + jm_vector_init(char)(&fmu->logMessageBufferExpanded,0,cb); + + if(!fmu->md) { + goto err1; + } + + fmu->options = fmi_util_allocate_options(cb); + if(!fmu->options) { + goto err2; + } + + return fmu; err2: fmi2_xml_free_model_description(fmu->md); @@ -67,253 +67,253 @@ fmi2_import_t* fmi2_import_allocate(jm_callbacks* cb) { } const char* fmi2_import_get_last_error(fmi2_import_t* fmu) { - return jm_get_last_error(fmu->callbacks); + return jm_get_last_error(fmu->callbacks); } fmi2_import_t* fmi2_import_parse_xml( fmi_import_context_t* context, const char* dirPath, fmi2_xml_callbacks_t* xml_callbacks) { - char* xmlPath; - char absPath[FILENAME_MAX + 2]; - fmi2_import_t* fmu = 0; + char* xmlPath; + char absPath[FILENAME_MAX + 2]; + fmi2_import_t* fmu = 0; int configuration = 0; - if(strlen(dirPath) + 20 > FILENAME_MAX) { - jm_log_fatal(context->callbacks, module, "Directory path for FMU is too long"); - return 0; - } - - xmlPath = fmi_import_get_model_description_path(dirPath, context->callbacks); - fmu = fmi2_import_allocate(context->callbacks); - - if(!fmu) { - context->callbacks->free(xmlPath); - return 0; - } - - if(jm_get_dir_abspath(context->callbacks, dirPath, absPath, FILENAME_MAX + 2)) { - size_t len = strlen(absPath); - strcpy(absPath + len, FMI_FILE_SEP "resources"); - fmu->resourceLocation = fmi_import_create_URL_from_abs_path(context->callbacks, absPath); - } - fmu->dirPath = context->callbacks->malloc(strlen(dirPath) + 1); - if (!fmu->dirPath || !fmu->resourceLocation) { - jm_log_fatal( context->callbacks, "FMILIB", "Could not allocated memory"); - fmi2_import_free(fmu); - context->callbacks->free(xmlPath); - return 0; - } - strcpy(fmu->dirPath, dirPath); - - jm_log_verbose( context->callbacks, "FMILIB", "Parsing model description XML"); + if(strlen(dirPath) + 20 > FILENAME_MAX) { + jm_log_fatal(context->callbacks, module, "Directory path for FMU is too long"); + return 0; + } + + xmlPath = fmi_import_get_model_description_path(dirPath, context->callbacks); + fmu = fmi2_import_allocate(context->callbacks); + + if(!fmu) { + context->callbacks->free(xmlPath); + return 0; + } + + if(jm_get_dir_abspath(context->callbacks, dirPath, absPath, FILENAME_MAX + 2)) { + size_t len = strlen(absPath); + strcpy(absPath + len, FMI_FILE_SEP "resources"); + fmu->resourceLocation = fmi_import_create_URL_from_abs_path(context->callbacks, absPath); + } + fmu->dirPath = context->callbacks->malloc(strlen(dirPath) + 1); + if (!fmu->dirPath || !fmu->resourceLocation) { + jm_log_fatal( context->callbacks, "FMILIB", "Could not allocated memory"); + fmi2_import_free(fmu); + context->callbacks->free(xmlPath); + return 0; + } + strcpy(fmu->dirPath, dirPath); + + jm_log_verbose( context->callbacks, "FMILIB", "Parsing model description XML"); /* convert the import configuration to the xml configuration */ if (context->configuration & FMI_IMPORT_NAME_CHECK) { configuration |= FMI2_XML_NAME_CHECK; } - if (fmi2_xml_parse_model_description( fmu->md, xmlPath, xml_callbacks, configuration)) { - fmi2_import_free(fmu); - fmu = 0; - } - context->callbacks->free(xmlPath); + if (fmi2_xml_parse_model_description( fmu->md, xmlPath, xml_callbacks, configuration)) { + fmi2_import_free(fmu); + fmu = 0; + } + context->callbacks->free(xmlPath); - if(fmu) - jm_log_verbose( context->callbacks, "FMILIB", "Parsing finished successfully"); + if(fmu) + jm_log_verbose( context->callbacks, "FMILIB", "Parsing finished successfully"); - return fmu; + return fmu; } void fmi2_import_free(fmi2_import_t* fmu) { jm_callbacks* cb; - if(!fmu) return; + if(!fmu) return; cb = fmu->callbacks; - jm_log_verbose( fmu->callbacks, "FMILIB", "Releasing allocated library resources"); + jm_log_verbose( fmu->callbacks, "FMILIB", "Releasing allocated library resources"); - fmi2_import_destroy_dllfmu(fmu); - fmi2_xml_free_model_description(fmu->md); - fmi_util_free_options(cb, fmu->options); - jm_vector_free_data(char)(&fmu->logMessageBufferCoded); - jm_vector_free_data(char)(&fmu->logMessageBufferExpanded); + fmi2_import_destroy_dllfmu(fmu); + fmi2_xml_free_model_description(fmu->md); + fmi_util_free_options(cb, fmu->options); + jm_vector_free_data(char)(&fmu->logMessageBufferCoded); + jm_vector_free_data(char)(&fmu->logMessageBufferExpanded); - cb->free(fmu->resourceLocation); - cb->free(fmu->dirPath); + cb->free(fmu->resourceLocation); + cb->free(fmu->dirPath); cb->free(fmu); } int fmi2_import_check_has_FMU(fmi2_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return 0; - } - return 1; + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return 0; + } + return 1; } const char* fmi2_import_get_model_name(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_model_name(fmu->md); + return fmi2_xml_get_model_name(fmu->md); } unsigned int fmi2_import_get_capability(fmi2_import_t* fmu , fmi2_capabilities_enu_t id) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_capability(fmu->md, id); + return fmi2_xml_get_capability(fmu->md, id); } const char* fmi2_import_get_model_identifier_ME(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_model_identifier_ME(fmu->md); + return fmi2_xml_get_model_identifier_ME(fmu->md); } const char* fmi2_import_get_model_identifier_CS(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_model_identifier_CS(fmu->md); + return fmi2_xml_get_model_identifier_CS(fmu->md); } const char* fmi2_import_get_GUID(fmi2_import_t* fmu){ - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; return fmi2_xml_get_GUID(fmu->md); } const char* fmi2_import_get_description(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_description(fmu->md); + return fmi2_xml_get_description(fmu->md); } const char* fmi2_import_get_author(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_author(fmu->md); + return fmi2_xml_get_author(fmu->md); } const char* fmi2_import_get_license(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_license(fmu->md); + return fmi2_xml_get_license(fmu->md); } const char* fmi2_import_get_copyright(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_copyright(fmu->md); + return fmi2_xml_get_copyright(fmu->md); } const char* fmi2_import_get_model_standard_version(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_model_standard_version(fmu->md); + return fmi2_xml_get_model_standard_version(fmu->md); } const char* fmi2_import_get_model_version(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_model_version(fmu->md); + return fmi2_xml_get_model_version(fmu->md); } const char* fmi2_import_get_generation_tool(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_generation_tool(fmu->md); + return fmi2_xml_get_generation_tool(fmu->md); } const char* fmi2_import_get_generation_date_and_time(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_generation_date_and_time(fmu->md); + return fmi2_xml_get_generation_date_and_time(fmu->md); } fmi2_variable_naming_convension_enu_t fmi2_import_get_naming_convention(fmi2_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, module,"No FMU is loaded"); - return fmi2_naming_enu_unknown; - } - return fmi2_xml_get_naming_convention(fmu->md); + if(!fmu->md) { + jm_log_error(fmu->callbacks, module,"No FMU is loaded"); + return fmi2_naming_enu_unknown; + } + return fmi2_xml_get_naming_convention(fmu->md); } size_t fmi2_import_get_number_of_continuous_states(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_number_of_continuous_states(fmu->md); + return fmi2_xml_get_number_of_continuous_states(fmu->md); } size_t fmi2_import_get_number_of_event_indicators(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_number_of_event_indicators(fmu->md); + return fmi2_xml_get_number_of_event_indicators(fmu->md); } int fmi2_import_get_default_experiment_has_start(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_has_start(fmu->md); + return fmi2_xml_get_default_experiment_has_start(fmu->md); } int fmi2_import_get_default_experiment_has_stop(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_has_stop(fmu->md); + return fmi2_xml_get_default_experiment_has_stop(fmu->md); } int fmi2_import_get_default_experiment_has_tolerance(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_has_tolerance(fmu->md); + return fmi2_xml_get_default_experiment_has_tolerance(fmu->md); } int fmi2_import_get_default_experiment_has_step(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_has_step(fmu->md); + return fmi2_xml_get_default_experiment_has_step(fmu->md); } double fmi2_import_get_default_experiment_start(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_start(fmu->md); + return fmi2_xml_get_default_experiment_start(fmu->md); } double fmi2_import_get_default_experiment_stop(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_stop(fmu->md); + return fmi2_xml_get_default_experiment_stop(fmu->md); } double fmi2_import_get_default_experiment_tolerance(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_tolerance(fmu->md); + return fmi2_xml_get_default_experiment_tolerance(fmu->md); } double fmi2_import_get_default_experiment_step(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_default_experiment_step(fmu->md); + return fmi2_xml_get_default_experiment_step(fmu->md); } fmi2_import_unit_definitions_t* fmi2_import_get_unit_definitions(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_unit_definitions(fmu->md); + return fmi2_xml_get_unit_definitions(fmu->md); } unsigned int fmi2_import_get_unit_definitions_number(fmi2_import_unit_definitions_t* ud) { - return fmi2_xml_get_unit_definitions_number(ud); + return fmi2_xml_get_unit_definitions_number(ud); } fmi2_import_type_definitions_t* fmi2_import_get_type_definitions(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_type_definitions(fmu->md); + return fmi2_xml_get_type_definitions(fmu->md); } fmi2_import_variable_list_t* fmi2_import_vector_to_varlist(fmi2_import_t* fmu, jm_vector(jm_voidp)* vars) { fmi2_import_variable_list_t* vl; size_t nv, i; - if(!vars) return 0; + if(!vars) return 0; nv = jm_vector_get_size(jm_voidp)(vars); vl = fmi2_import_alloc_variable_list(fmu, nv); @@ -328,29 +328,29 @@ fmi2_import_variable_list_t* fmi2_import_vector_to_varlist(fmi2_import_t* fmu, j /* Get the list of all the variables in the model */ /* 0 - original order as found in the XML file; 1 - sorted alfabetically by variable name; 2 sorted by types/value references. */ fmi2_import_variable_list_t* fmi2_import_get_variable_list(fmi2_import_t* fmu, int sortOrder) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; - switch(sortOrder) { - case 0: - return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_variables_original_order(fmu->md)); - case 1: { - fmi2_import_variable_list_t* vl; - size_t nv, i; - jm_vector(jm_named_ptr)* vars = fmi2_xml_get_variables_alphabetical_order(fmu->md); - if(!vars) return 0; - nv = jm_vector_get_size(jm_named_ptr)(vars); - vl = fmi2_import_alloc_variable_list(fmu, nv); - if(!vl) return 0; - for(i = 0; i< nv; i++) { - jm_vector_set_item(jm_voidp)(&vl->variables, i, jm_vector_get_item(jm_named_ptr)(vars, i).ptr); - } - return vl; - } - case 2: - return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_variables_vr_order(fmu->md)); - default: - assert(0); - } - return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; + switch(sortOrder) { + case 0: + return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_variables_original_order(fmu->md)); + case 1: { + fmi2_import_variable_list_t* vl; + size_t nv, i; + jm_vector(jm_named_ptr)* vars = fmi2_xml_get_variables_alphabetical_order(fmu->md); + if(!vars) return 0; + nv = jm_vector_get_size(jm_named_ptr)(vars); + vl = fmi2_import_alloc_variable_list(fmu, nv); + if(!vl) return 0; + for(i = 0; i< nv; i++) { + jm_vector_set_item(jm_voidp)(&vl->variables, i, jm_vector_get_item(jm_named_ptr)(vars, i).ptr); + } + return vl; + } + case 2: + return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_variables_vr_order(fmu->md)); + default: + assert(0); + } + return 0; } fmi2_fmu_kind_enu_t fmi2_import_get_fmu_kind(fmi2_import_t* fmu) { @@ -358,85 +358,85 @@ fmi2_fmu_kind_enu_t fmi2_import_get_fmu_kind(fmi2_import_t* fmu) { } size_t fmi2_import_get_vendors_num(fmi2_import_t* fmu){ - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_vendors_num(fmu->md); + return fmi2_xml_get_vendors_num(fmu->md); } const char* fmi2_import_get_vendor_name(fmi2_import_t* fmu, size_t index){ - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_xml_get_vendor_name(fmu->md, index); + return fmi2_xml_get_vendor_name(fmu->md, index); } /** \brief Get the number of log categories defined in the XML */ size_t fmi2_import_get_log_categories_num(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return jm_vector_get_size(jm_string)(fmi2_xml_get_log_categories(fmu->md)); + return jm_vector_get_size(jm_string)(fmi2_xml_get_log_categories(fmu->md)); } /** \brief Get the log category by index */ const char* fmi2_import_get_log_category(fmi2_import_t* fmu, size_t index) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return jm_vector_get_item(jm_string)(fmi2_xml_get_log_categories(fmu->md), index); + return jm_vector_get_item(jm_string)(fmi2_xml_get_log_categories(fmu->md), index); } /** \brief Get the log category description by index */ const char* fmi2_import_get_log_category_description(fmi2_import_t* fmu, size_t index) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return jm_vector_get_item(jm_string)(fmi2_xml_get_log_category_descriptions(fmu->md), index); + return jm_vector_get_item(jm_string)(fmi2_xml_get_log_category_descriptions(fmu->md), index); } /** \brief Get the number of source files for ME defined in the XML */ size_t fmi2_import_get_source_files_me_num(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return jm_vector_get_size(jm_string)(fmi2_xml_get_source_files_me(fmu->md)); + return jm_vector_get_size(jm_string)(fmi2_xml_get_source_files_me(fmu->md)); } /** \brief Get the ME source file by index */ const char* fmi2_import_get_source_file_me(fmi2_import_t* fmu, size_t index) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return jm_vector_get_item(jm_string)(fmi2_xml_get_source_files_me(fmu->md), index); + return jm_vector_get_item(jm_string)(fmi2_xml_get_source_files_me(fmu->md), index); } /** \brief Get the number of source files for CS defined in the XML */ size_t fmi2_import_get_source_files_cs_num(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return jm_vector_get_size(jm_string)(fmi2_xml_get_source_files_cs(fmu->md)); + return jm_vector_get_size(jm_string)(fmi2_xml_get_source_files_cs(fmu->md)); } /** \brief Get the CS source file by index */ const char* fmi2_import_get_source_file_cs(fmi2_import_t* fmu, size_t index) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; + if(!fmi2_import_check_has_FMU(fmu)) return 0; - return jm_vector_get_item(jm_string)(fmi2_xml_get_source_files_cs(fmu->md), index); + return jm_vector_get_item(jm_string)(fmi2_xml_get_source_files_cs(fmu->md), index); } fmi2_import_variable_list_t* fmi2_import_get_outputs_list(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_outputs(fmi2_xml_get_model_structure(fmu->md))); + if(!fmi2_import_check_has_FMU(fmu)) return 0; + return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_outputs(fmi2_xml_get_model_structure(fmu->md))); } fmi2_import_variable_list_t* fmi2_import_get_derivatives_list(fmi2_import_t* fmu){ - if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_derivatives(fmi2_xml_get_model_structure(fmu->md))); + if(!fmi2_import_check_has_FMU(fmu)) return 0; + return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_derivatives(fmi2_xml_get_model_structure(fmu->md))); } fmi2_import_variable_list_t* fmi2_import_get_discrete_states_list(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_discrete_states(fmi2_xml_get_model_structure(fmu->md))); + if(!fmi2_import_check_has_FMU(fmu)) return 0; + return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_discrete_states(fmi2_xml_get_model_structure(fmu->md))); } fmi2_import_variable_list_t* fmi2_import_get_initial_unknowns_list(fmi2_import_t* fmu) { - if(!fmi2_import_check_has_FMU(fmu)) return 0; - return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_initial_unknowns(fmi2_xml_get_model_structure(fmu->md))); + if(!fmi2_import_check_has_FMU(fmu)) return 0; + return fmi2_import_vector_to_varlist(fmu, fmi2_xml_get_initial_unknowns(fmi2_xml_get_model_structure(fmu->md))); } void fmi2_import_get_outputs_dependencies(fmi2_import_t* fmu,size_t** startIndex, size_t** dependency, char** factorKind) { diff --git a/src/Import/src/FMI2/fmi2_import_capi.c b/src/Import/src/FMI2/fmi2_import_capi.c index 791ed484..f7062605 100644 --- a/src/Import/src/FMI2/fmi2_import_capi.c +++ b/src/Import/src/FMI2/fmi2_import_capi.c @@ -30,169 +30,169 @@ static const char * module = "FMILIB"; static void fmi2_import_capi_destroy_dllfmu_and_restore_options(fmi2_import_t* fmu) { - if (fmu->capi->options) { - /* Take back ownership of Options */ - fmu->options = fmu->capi->options; - fmu->capi->options = NULL; - } + if (fmu->capi->options) { + /* Take back ownership of Options */ + fmu->options = fmu->capi->options; + fmu->capi->options = NULL; + } fmi2_capi_destroy_dllfmu(fmu->capi); - fmu->capi = NULL; + fmu->capi = NULL; } /* Load and destroy functions */ jm_status_enu_t fmi2_import_create_dllfmu(fmi2_import_t* fmu, fmi2_fmu_kind_enu_t fmuKind, const fmi2_callback_functions_t* callBackFunctions) { - char curDir[FILENAME_MAX + 2]; - char* dllDirPath = 0; - char* dllFileName = 0; - const char* modelIdentifier; - fmi2_callback_functions_t defaultCallbacks; - - if (fmu == NULL) { - assert(0); - return jm_status_error; - } - - if(fmu -> capi) { - if(fmi2_capi_get_fmu_kind(fmu -> capi) == fmuKind) { - jm_log_warning(fmu->callbacks, module, "FMU binary is already loaded"); - return jm_status_success; - } - else - fmi2_import_destroy_dllfmu(fmu); - } - - if(fmuKind == fmi2_fmu_kind_me) - modelIdentifier = fmi2_import_get_model_identifier_ME(fmu); - else if(fmuKind == fmi2_fmu_kind_cs) - modelIdentifier = fmi2_import_get_model_identifier_CS(fmu); - else { - assert(0); - return jm_status_error; - } - - if (modelIdentifier == NULL) { - jm_log_error(fmu->callbacks, module, "No model identifier given"); - return jm_status_error; - } - - if( jm_portability_get_current_working_directory(curDir, FILENAME_MAX+1) != jm_status_success) { - jm_log_warning(fmu->callbacks, module, "Could not get current working directory (%s)", strerror(errno)); - curDir[0] = 0; - }; - - dllDirPath = fmi_construct_dll_dir_name(fmu->callbacks, fmu->dirPath); - dllFileName = fmi_construct_dll_file_name(fmu->callbacks, dllDirPath, modelIdentifier); - - if (!dllDirPath ||!dllFileName) { - fmu->callbacks->free(dllDirPath); - return jm_status_error; - } - - if(!callBackFunctions) { - jm_callbacks* cb = fmu->callbacks; - defaultCallbacks.allocateMemory = cb->calloc; - defaultCallbacks.freeMemory = cb->free; - defaultCallbacks.componentEnvironment = fmu; - defaultCallbacks.logger = fmi2_log_forwarding; - defaultCallbacks.stepFinished = 0; - callBackFunctions = &defaultCallbacks; - } - - if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { - jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); - if(ENOENT == errno) - jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); - else - jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); - } - else { - /* Allocate memory for the C-API struct */ - fmu -> capi = fmi2_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, fmuKind); - } - - if (fmu->capi) { - /* Replace the CAPI options with the import ones */ + char curDir[FILENAME_MAX + 2]; + char* dllDirPath = 0; + char* dllFileName = 0; + const char* modelIdentifier; + fmi2_callback_functions_t defaultCallbacks; + + if (fmu == NULL) { + assert(0); + return jm_status_error; + } + + if(fmu -> capi) { + if(fmi2_capi_get_fmu_kind(fmu -> capi) == fmuKind) { + jm_log_warning(fmu->callbacks, module, "FMU binary is already loaded"); + return jm_status_success; + } + else + fmi2_import_destroy_dllfmu(fmu); + } + + if(fmuKind == fmi2_fmu_kind_me) + modelIdentifier = fmi2_import_get_model_identifier_ME(fmu); + else if(fmuKind == fmi2_fmu_kind_cs) + modelIdentifier = fmi2_import_get_model_identifier_CS(fmu); + else { + assert(0); + return jm_status_error; + } + + if (modelIdentifier == NULL) { + jm_log_error(fmu->callbacks, module, "No model identifier given"); + return jm_status_error; + } + + if( jm_portability_get_current_working_directory(curDir, FILENAME_MAX+1) != jm_status_success) { + jm_log_warning(fmu->callbacks, module, "Could not get current working directory (%s)", strerror(errno)); + curDir[0] = 0; + }; + + dllDirPath = fmi_construct_dll_dir_name(fmu->callbacks, fmu->dirPath); + dllFileName = fmi_construct_dll_file_name(fmu->callbacks, dllDirPath, modelIdentifier); + + if (!dllDirPath ||!dllFileName) { + fmu->callbacks->free(dllDirPath); + return jm_status_error; + } + + if(!callBackFunctions) { + jm_callbacks* cb = fmu->callbacks; + defaultCallbacks.allocateMemory = cb->calloc; + defaultCallbacks.freeMemory = cb->free; + defaultCallbacks.componentEnvironment = fmu; + defaultCallbacks.logger = fmi2_log_forwarding; + defaultCallbacks.stepFinished = 0; + callBackFunctions = &defaultCallbacks; + } + + if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { + jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); + if(ENOENT == errno) + jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); + else + jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); + } + else { + /* Allocate memory for the C-API struct */ + fmu -> capi = fmi2_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, fmuKind); + } + + if (fmu->capi) { + /* Replace the CAPI options with the import ones */ fmi_util_free_options(fmu->callbacks, fmu->capi->options); - fmu->capi->options = fmu->options; - fmu->options = NULL; - } + fmu->capi->options = fmu->options; + fmu->options = NULL; + } - /* Load the DLL handle */ - if (fmu -> capi) { - jm_log_info(fmu->callbacks, module, - "Loading '" FMI_PLATFORM "' binary with '%s' platform types", fmi2_get_types_platform() ); + /* Load the DLL handle */ + if (fmu -> capi) { + jm_log_info(fmu->callbacks, module, + "Loading '" FMI_PLATFORM "' binary with '%s' platform types", fmi2_get_types_platform() ); - if(fmi2_capi_load_dll(fmu -> capi) == jm_status_error) { - fmi2_import_capi_destroy_dllfmu_and_restore_options(fmu); - } - } + if(fmi2_capi_load_dll(fmu -> capi) == jm_status_error) { + fmi2_import_capi_destroy_dllfmu_and_restore_options(fmu); + } + } - if(curDir[0] && (jm_portability_set_current_working_directory(curDir) != jm_status_success)) { - jm_log_error(fmu->callbacks, module, "Could not restore current working directory (%s)", strerror(errno)); - } + if(curDir[0] && (jm_portability_set_current_working_directory(curDir) != jm_status_success)) { + jm_log_error(fmu->callbacks, module, "Could not restore current working directory (%s)", strerror(errno)); + } - fmu->callbacks->free((jm_voidp)dllDirPath); - fmu->callbacks->free((jm_voidp)dllFileName); + fmu->callbacks->free((jm_voidp)dllDirPath); + fmu->callbacks->free((jm_voidp)dllFileName); - if (fmu -> capi == NULL) { - return jm_status_error; - } + if (fmu -> capi == NULL) { + return jm_status_error; + } - /* Load the DLL functions */ - if (fmi2_capi_load_fcn(fmu -> capi, fmi2_xml_get_capabilities(fmu->md)) == jm_status_error) { - fmi2_capi_free_dll(fmu -> capi); + /* Load the DLL functions */ + if (fmi2_capi_load_fcn(fmu -> capi, fmi2_xml_get_capabilities(fmu->md)) == jm_status_error) { + fmi2_capi_free_dll(fmu -> capi); - fmi2_import_capi_destroy_dllfmu_and_restore_options(fmu); - return jm_status_error; - } - jm_log_verbose(fmu->callbacks, module, "Successfully loaded all the interface functions"); + fmi2_import_capi_destroy_dllfmu_and_restore_options(fmu); + return jm_status_error; + } + jm_log_verbose(fmu->callbacks, module, "Successfully loaded all the interface functions"); - return jm_status_success; + return jm_status_success; } void fmi2_import_set_debug_mode(fmi2_import_t* fmu, int mode) { - if (fmu == NULL) { - return; - } - fmi2_capi_set_debug_mode(fmu->capi, mode); + if (fmu == NULL) { + return; + } + fmi2_capi_set_debug_mode(fmu->capi, mode); } void fmi2_import_destroy_dllfmu(fmi2_import_t* fmu) { - - if (fmu == NULL) { - return; - } - - if(fmu -> capi) { - jm_log_verbose(fmu->callbacks, module, "Releasing FMU CAPI interface"); + if (fmu == NULL) { + return; + } + - /* Free DLL handle */ - fmi2_capi_free_dll(fmu -> capi); + if(fmu -> capi) { + jm_log_verbose(fmu->callbacks, module, "Releasing FMU CAPI interface"); - /* Destroy the C-API struct and restore options */ + /* Free DLL handle */ + fmi2_capi_free_dll(fmu -> capi); + + /* Destroy the C-API struct and restore options */ fmi2_import_capi_destroy_dllfmu_and_restore_options(fmu); - } + } } /* FMI 2.0 Common functions */ const char* fmi2_import_get_version(fmi2_import_t* fmu) { - if(!fmu->capi) { - jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); - return 0; - } - return fmi2_capi_get_version(fmu -> capi); + if(!fmu->capi) { + jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); + return 0; + } + return fmi2_capi_get_version(fmu -> capi); } fmi2_status_t fmi2_import_set_debug_logging(fmi2_import_t* fmu, fmi2_boolean_t loggingOn, size_t nCategories, fmi2_string_t categories[]) { - if(!fmu->capi) { - jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); - return fmi2_status_fatal; - } - return fmi2_capi_set_debug_logging(fmu -> capi, loggingOn, nCategories, categories); + if(!fmu->capi) { + jm_log_error(fmu->callbacks, module,"FMU CAPI is not loaded"); + return fmi2_status_fatal; + } + return fmi2_capi_set_debug_logging(fmu -> capi, loggingOn, nCategories, categories); } @@ -242,73 +242,73 @@ fmi2_status_t fmi2_import_exit_initialization_mode(fmi2_import_t* fmu) } fmi2_status_t fmi2_import_terminate(fmi2_import_t* fmu) { - return fmi2_capi_terminate(fmu -> capi); + return fmi2_capi_terminate(fmu -> capi); } fmi2_status_t fmi2_import_reset(fmi2_import_t* fmu) { - return fmi2_capi_reset(fmu -> capi); + return fmi2_capi_reset(fmu -> capi); } fmi2_status_t fmi2_import_set_real(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_real_t value[]) { - return fmi2_capi_set_real(fmu -> capi, vr, nvr, value); + return fmi2_capi_set_real(fmu -> capi, vr, nvr, value); } fmi2_status_t fmi2_import_set_integer(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_integer_t value[]) { - return fmi2_capi_set_integer(fmu -> capi, vr, nvr, value); + return fmi2_capi_set_integer(fmu -> capi, vr, nvr, value); } fmi2_status_t fmi2_import_set_boolean(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_boolean_t value[]) { - return fmi2_capi_set_boolean(fmu -> capi, vr, nvr, value); + return fmi2_capi_set_boolean(fmu -> capi, vr, nvr, value); } fmi2_status_t fmi2_import_set_string(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_string_t value[]) { - return fmi2_capi_set_string(fmu -> capi, vr, nvr, value); + return fmi2_capi_set_string(fmu -> capi, vr, nvr, value); } fmi2_status_t fmi2_import_get_real(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, fmi2_real_t value[]) { - return fmi2_capi_get_real(fmu -> capi, vr, nvr, value); + return fmi2_capi_get_real(fmu -> capi, vr, nvr, value); } fmi2_status_t fmi2_import_get_integer(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, fmi2_integer_t value[]) { - return fmi2_capi_get_integer(fmu -> capi, vr, nvr, value); + return fmi2_capi_get_integer(fmu -> capi, vr, nvr, value); } fmi2_status_t fmi2_import_get_boolean(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, fmi2_boolean_t value[]) { - return fmi2_capi_get_boolean(fmu -> capi, vr, nvr, value); + return fmi2_capi_get_boolean(fmu -> capi, vr, nvr, value); } fmi2_status_t fmi2_import_get_string(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, fmi2_string_t value[]) { - return fmi2_capi_get_string(fmu -> capi, vr, nvr, value); + return fmi2_capi_get_string(fmu -> capi, vr, nvr, value); } const char* fmi2_import_get_types_platform(fmi2_import_t* fmu) { - return fmi2_capi_get_types_platform(fmu -> capi); + return fmi2_capi_get_types_platform(fmu -> capi); } fmi2_status_t fmi2_import_get_fmu_state (fmi2_import_t* fmu, fmi2_FMU_state_t* s) { - return fmi2_capi_get_fmu_state(fmu -> capi,s); + return fmi2_capi_get_fmu_state(fmu -> capi,s); } fmi2_status_t fmi2_import_set_fmu_state (fmi2_import_t* fmu, fmi2_FMU_state_t s){ - return fmi2_capi_set_fmu_state(fmu -> capi,s); + return fmi2_capi_set_fmu_state(fmu -> capi,s); } fmi2_status_t fmi2_import_free_fmu_state (fmi2_import_t* fmu, fmi2_FMU_state_t* s){ - return fmi2_capi_free_fmu_state (fmu -> capi,s); + return fmi2_capi_free_fmu_state (fmu -> capi,s); } fmi2_status_t fmi2_import_serialized_fmu_state_size(fmi2_import_t* fmu, fmi2_FMU_state_t s, size_t* sz){ - return fmi2_capi_serialized_fmu_state_size(fmu -> capi,s,sz); + return fmi2_capi_serialized_fmu_state_size(fmu -> capi,s,sz); } fmi2_status_t fmi2_import_serialize_fmu_state (fmi2_import_t* fmu, fmi2_FMU_state_t s , fmi2_byte_t data[], size_t sz){ - return fmi2_capi_serialize_fmu_state(fmu -> capi,s,data,sz); + return fmi2_capi_serialize_fmu_state(fmu -> capi,s,data,sz); } fmi2_status_t fmi2_import_de_serialize_fmu_state (fmi2_import_t* fmu, const fmi2_byte_t data[], size_t sz, fmi2_FMU_state_t* s){ - return fmi2_capi_de_serialize_fmu_state (fmu -> capi,data,sz,s); + return fmi2_capi_de_serialize_fmu_state (fmu -> capi,data,sz,s); } fmi2_status_t fmi2_import_get_directional_derivative(fmi2_import_t* fmu, const fmi2_value_reference_t v_ref[], size_t nv, const fmi2_value_reference_t z_ref[], size_t nz, const fmi2_real_t dv[], fmi2_real_t dz[]){ - return fmi2_capi_get_directional_derivative(fmu -> capi,v_ref, nv, z_ref, nz, dv, dz); + return fmi2_capi_get_directional_derivative(fmu -> capi,v_ref, nv, z_ref, nz, dv, dz); } /* FMI 2.0 ME functions */ @@ -326,11 +326,11 @@ fmi2_status_t fmi2_import_enter_continuous_time_mode(fmi2_import_t* fmu) { } fmi2_status_t fmi2_import_set_time(fmi2_import_t* fmu, fmi2_real_t time) { - return fmi2_capi_set_time(fmu -> capi, time); + return fmi2_capi_set_time(fmu -> capi, time); } fmi2_status_t fmi2_import_set_continuous_states(fmi2_import_t* fmu, const fmi2_real_t x[], size_t nx) { - return fmi2_capi_set_continuous_states(fmu -> capi, x, nx); + return fmi2_capi_set_continuous_states(fmu -> capi, x, nx); } fmi2_status_t fmi2_import_completed_integrator_step(fmi2_import_t* fmu, @@ -341,57 +341,57 @@ fmi2_status_t fmi2_import_completed_integrator_step(fmi2_import_t* fmu, } fmi2_status_t fmi2_import_get_derivatives(fmi2_import_t* fmu, fmi2_real_t derivatives[], size_t nx) { - return fmi2_capi_get_derivatives(fmu -> capi, derivatives, nx); + return fmi2_capi_get_derivatives(fmu -> capi, derivatives, nx); } fmi2_status_t fmi2_import_get_event_indicators(fmi2_import_t* fmu, fmi2_real_t eventIndicators[], size_t ni) { - return fmi2_capi_get_event_indicators(fmu -> capi, eventIndicators, ni); + return fmi2_capi_get_event_indicators(fmu -> capi, eventIndicators, ni); } fmi2_status_t fmi2_import_get_continuous_states(fmi2_import_t* fmu, fmi2_real_t states[], size_t nx) { - return fmi2_capi_get_continuous_states(fmu -> capi, states, nx); + return fmi2_capi_get_continuous_states(fmu -> capi, states, nx); } fmi2_status_t fmi2_import_get_nominals_of_continuous_states(fmi2_import_t* fmu, fmi2_real_t x_nominal[], size_t nx) { - return fmi2_capi_get_nominals_of_continuous_states(fmu -> capi, x_nominal, nx); + return fmi2_capi_get_nominals_of_continuous_states(fmu -> capi, x_nominal, nx); } /* FMI 2.0 CS functions */ fmi2_status_t fmi2_import_set_real_input_derivatives(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_integer_t order[], const fmi2_real_t value[]) { - return fmi2_capi_set_real_input_derivatives(fmu -> capi, vr, nvr, order, value); + return fmi2_capi_set_real_input_derivatives(fmu -> capi, vr, nvr, order, value); } fmi2_status_t fmi2_import_get_real_output_derivatives(fmi2_import_t* fmu, const fmi2_value_reference_t vr[], size_t nvr, const fmi2_integer_t order[], fmi2_real_t value[]) { - return fmi2_capi_get_real_output_derivatives(fmu -> capi, vr, nvr, order, value); + return fmi2_capi_get_real_output_derivatives(fmu -> capi, vr, nvr, order, value); } fmi2_status_t fmi2_import_cancel_step(fmi2_import_t* fmu) { - return fmi2_capi_cancel_step(fmu -> capi); + return fmi2_capi_cancel_step(fmu -> capi); } fmi2_status_t fmi2_import_do_step(fmi2_import_t* fmu, fmi2_real_t currentCommunicationPoint, fmi2_real_t communicationStepSize, fmi2_boolean_t newStep) { - return fmi2_capi_do_step(fmu -> capi, currentCommunicationPoint, communicationStepSize, newStep); + return fmi2_capi_do_step(fmu -> capi, currentCommunicationPoint, communicationStepSize, newStep); } fmi2_status_t fmi2_import_get_status(fmi2_import_t* fmu, const fmi2_status_kind_t s, fmi2_status_t* value) { - return fmi2_capi_get_status(fmu -> capi, s, value); + return fmi2_capi_get_status(fmu -> capi, s, value); } fmi2_status_t fmi2_import_get_real_status(fmi2_import_t* fmu, const fmi2_status_kind_t s, fmi2_real_t* value) { - return fmi2_capi_get_real_status(fmu -> capi, s, value); + return fmi2_capi_get_real_status(fmu -> capi, s, value); } fmi2_status_t fmi2_import_get_integer_status(fmi2_import_t* fmu, const fmi2_status_kind_t s, fmi2_integer_t* value) { - return fmi2_capi_get_integer_status(fmu -> capi, s, value); + return fmi2_capi_get_integer_status(fmu -> capi, s, value); } fmi2_status_t fmi2_import_get_boolean_status(fmi2_import_t* fmu, const fmi2_status_kind_t s, fmi2_boolean_t* value) { - return fmi2_capi_get_boolean_status(fmu -> capi, s, value); + return fmi2_capi_get_boolean_status(fmu -> capi, s, value); } fmi2_status_t fmi2_import_get_string_status(fmi2_import_t* fmu, const fmi2_status_kind_t s, fmi2_string_t* value) { - return fmi2_capi_get_string_status(fmu -> capi, s, value); + return fmi2_capi_get_string_status(fmu -> capi, s, value); } #ifdef __cplusplus diff --git a/src/Import/src/FMI2/fmi2_import_convenience.c b/src/Import/src/FMI2/fmi2_import_convenience.c index e94c18d5..12264f7e 100644 --- a/src/Import/src/FMI2/fmi2_import_convenience.c +++ b/src/Import/src/FMI2/fmi2_import_convenience.c @@ -23,77 +23,77 @@ #include "fmi2_import_impl.h" /** - \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi2_import_model_counts_t struct. - \param fmu - An fmu object as returned by fmi2_import_parse_xml(). - \param counts - a pointer to a preallocated struct. + \brief Collect model information by counting the number of variables with specific properties and fillinf in fmi2_import_model_counts_t struct. + \param fmu - An fmu object as returned by fmi2_import_parse_xml(). + \param counts - a pointer to a preallocated struct. */ void fmi2_import_collect_model_counts(fmi2_import_t* fmu, fmi2_import_model_counts_t* counts) { - jm_vector(jm_voidp)* vars = fmi2_xml_get_variables_original_order(fmu->md); + jm_vector(jm_voidp)* vars = fmi2_xml_get_variables_original_order(fmu->md); size_t nv, i; - memset(counts,0,sizeof(fmi2_import_model_counts_t)); - if(!vars) return; - nv = jm_vector_get_size(jm_voidp)(vars); + memset(counts,0,sizeof(fmi2_import_model_counts_t)); + if(!vars) return; + nv = jm_vector_get_size(jm_voidp)(vars); for(i = 0; i< nv; i++) { - fmi2_xml_variable_t* var = (fmi2_xml_variable_t*)jm_vector_get_item(jm_voidp)(vars, i); - switch (fmi2_xml_get_variability(var)) { - case fmi2_variability_enu_constant: - counts->num_constants++; - break; - case fmi2_variability_enu_fixed: - counts->num_fixed++; - break; - case fmi2_variability_enu_tunable: - counts->num_tunable++; - break; - case fmi2_variability_enu_discrete: - counts->num_discrete++; - break; - case fmi2_variability_enu_continuous: - counts->num_continuous++; - break; - default: - assert(0); - } - switch(fmi2_xml_get_causality(var)) { - case fmi2_causality_enu_parameter: - counts->num_parameters++; - break; - case fmi2_causality_enu_calculated_parameter: - counts->num_calculated_parameters++; - break; - case fmi2_causality_enu_input: - counts->num_inputs++; - break; - case fmi2_causality_enu_output: - counts->num_outputs++; - break; - case fmi2_causality_enu_local: - counts->num_local++; - break; - case fmi2_causality_enu_independent: - counts->num_local++; - break; - default: assert(0); - } - switch(fmi2_xml_get_variable_base_type(var)) { - case fmi2_base_type_real: - counts->num_real_vars++; - break; - case fmi2_base_type_int: - counts->num_integer_vars++; - break; - case fmi2_base_type_bool: - counts->num_bool_vars++; - break; - case fmi2_base_type_str: - counts->num_string_vars++; - break; - case fmi2_base_type_enum: - counts->num_enum_vars++; - break; - default: - assert(0); - } + fmi2_xml_variable_t* var = (fmi2_xml_variable_t*)jm_vector_get_item(jm_voidp)(vars, i); + switch (fmi2_xml_get_variability(var)) { + case fmi2_variability_enu_constant: + counts->num_constants++; + break; + case fmi2_variability_enu_fixed: + counts->num_fixed++; + break; + case fmi2_variability_enu_tunable: + counts->num_tunable++; + break; + case fmi2_variability_enu_discrete: + counts->num_discrete++; + break; + case fmi2_variability_enu_continuous: + counts->num_continuous++; + break; + default: + assert(0); + } + switch(fmi2_xml_get_causality(var)) { + case fmi2_causality_enu_parameter: + counts->num_parameters++; + break; + case fmi2_causality_enu_calculated_parameter: + counts->num_calculated_parameters++; + break; + case fmi2_causality_enu_input: + counts->num_inputs++; + break; + case fmi2_causality_enu_output: + counts->num_outputs++; + break; + case fmi2_causality_enu_local: + counts->num_local++; + break; + case fmi2_causality_enu_independent: + counts->num_local++; + break; + default: assert(0); + } + switch(fmi2_xml_get_variable_base_type(var)) { + case fmi2_base_type_real: + counts->num_real_vars++; + break; + case fmi2_base_type_int: + counts->num_integer_vars++; + break; + case fmi2_base_type_bool: + counts->num_bool_vars++; + break; + case fmi2_base_type_str: + counts->num_string_vars++; + break; + case fmi2_base_type_enum: + counts->num_enum_vars++; + break; + default: + assert(0); + } } return; } @@ -101,132 +101,132 @@ void fmi2_import_collect_model_counts(fmi2_import_t* fmu, fmi2_import_model_coun void fmi2_import_expand_variable_references_impl(fmi2_import_t* fmu, const char* msgIn); void fmi2_import_expand_variable_references(fmi2_import_t* fmu, const char* msgIn, char* msgOut, size_t maxMsgSize) { - fmi2_import_expand_variable_references_impl(fmu, msgIn); - strncpy(msgOut, jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0),maxMsgSize); - msgOut[maxMsgSize - 1] = '\0'; + fmi2_import_expand_variable_references_impl(fmu, msgIn); + strncpy(msgOut, jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0),maxMsgSize); + msgOut[maxMsgSize - 1] = '\0'; } /* Print msgIn into msgOut by expanding variable references of the form ## into variable names and replacing '##' with a single # */ void fmi2_import_expand_variable_references_impl(fmi2_import_t* fmu, const char* msgIn){ - jm_vector(char)* msgOut = &fmu->logMessageBufferExpanded; - fmi2_xml_model_description_t* md = fmu->md; - jm_callbacks* callbacks = fmu->callbacks; + jm_vector(char)* msgOut = &fmu->logMessageBufferExpanded; + fmi2_xml_model_description_t* md = fmu->md; + jm_callbacks* callbacks = fmu->callbacks; char curCh; - const char* firstRef; + const char* firstRef; size_t i; /* next char index after curCh in msgIn*/ - size_t msgLen = strlen(msgIn)+1; /* original message length including terminating 0 */ + size_t msgLen = strlen(msgIn)+1; /* original message length including terminating 0 */ - if(jm_vector_reserve(char)(msgOut, msgLen + 100) < msgLen + 100) { - jm_log(fmu->callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); - jm_vector_resize(char)(msgOut, 6); - memcpy(jm_vector_get_itemp(char)(msgOut,0),"ERROR",6); /* at least 16 chars are always there */ - return; - } + if(jm_vector_reserve(char)(msgOut, msgLen + 100) < msgLen + 100) { + jm_log(fmu->callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); + jm_vector_resize(char)(msgOut, 6); + memcpy(jm_vector_get_itemp(char)(msgOut,0),"ERROR",6); /* at least 16 chars are always there */ + return; + } - /* check if there are any refs at all and copy the head of the string without references */ - firstRef = strchr(msgIn, '#'); - if(firstRef) { - i = firstRef - msgIn; - jm_vector_resize(char)(msgOut, i); - if(i) { - memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, i); - } - curCh = msgIn[i++]; - } - else { - jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, msgLen); - return; - } + /* check if there are any refs at all and copy the head of the string without references */ + firstRef = strchr(msgIn, '#'); + if(firstRef) { + i = firstRef - msgIn; + jm_vector_resize(char)(msgOut, i); + if(i) { + memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, i); + } + curCh = msgIn[i++]; + } + else { + jm_vector_resize(char)(msgOut, msgLen); + memcpy(jm_vector_get_itemp(char)(msgOut, 0), msgIn, msgLen); + return; + } do { if (curCh!='#') { jm_vector_push_back(char)(msgOut, curCh); /* copy in to out */ } - else if(msgIn[i] == '#') { - jm_vector_push_back(char)(msgOut, '#'); - i++; /* skip the second # */ - } - else { + else if(msgIn[i] == '#') { + jm_vector_push_back(char)(msgOut, '#'); + i++; /* skip the second # */ + } + else { unsigned int bufVR; - fmi2_value_reference_t vr; - char typeChar = msgIn[i++]; - size_t pastePos = jm_vector_get_size(char)(msgOut); - fmi2_base_type_enu_t baseType; - size_t num_digits; - fmi2_xml_variable_t* var; - const char* name; - size_t nameLen; - switch(typeChar) { - case 'r': - baseType = fmi2_base_type_real; - break; - case 'i': - baseType = fmi2_base_type_int; - break; - case 'b': - baseType = fmi2_base_type_bool; - break; - case 's': - baseType = fmi2_base_type_str; - break; - default: - jm_vector_push_back(char)(msgOut, 0); - jm_log(callbacks,"LOGGER", jm_log_level_warning, - "Expected type specification character 'r', 'i', 'b' or 's' in log message here: '%s'", - jm_vector_get_itemp(char)(msgOut,0)); + fmi2_value_reference_t vr; + char typeChar = msgIn[i++]; + size_t pastePos = jm_vector_get_size(char)(msgOut); + fmi2_base_type_enu_t baseType; + size_t num_digits; + fmi2_xml_variable_t* var; + const char* name; + size_t nameLen; + switch(typeChar) { + case 'r': + baseType = fmi2_base_type_real; + break; + case 'i': + baseType = fmi2_base_type_int; + break; + case 'b': + baseType = fmi2_base_type_bool; + break; + case 's': + baseType = fmi2_base_type_str; + break; + default: + jm_vector_push_back(char)(msgOut, 0); + jm_log(callbacks,"LOGGER", jm_log_level_warning, + "Expected type specification character 'r', 'i', 'b' or 's' in log message here: '%s'", + jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } curCh = msgIn[i++]; - while( isdigit(curCh) ) { - jm_vector_push_back(char)(msgOut, curCh); - curCh = msgIn[i++]; - } - num_digits = jm_vector_get_size(char)(msgOut) - pastePos; - jm_vector_push_back(char)(msgOut, 0); - if(num_digits == 0) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + while( isdigit(curCh) ) { + jm_vector_push_back(char)(msgOut, curCh); + curCh = msgIn[i++]; + } + num_digits = jm_vector_get_size(char)(msgOut) - pastePos; + jm_vector_push_back(char)(msgOut, 0); + if(num_digits == 0) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } - else if(curCh != '#') { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected terminating '#' in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } + else if(curCh != '#') { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Expected terminating '#' in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } - - if(sscanf(jm_vector_get_itemp(char)(msgOut, pastePos), "%u",&bufVR) != 1) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not decode value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } + + if(sscanf(jm_vector_get_itemp(char)(msgOut, pastePos), "%u",&bufVR) != 1) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not decode value reference in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } vr = bufVR; - var = fmi2_xml_get_variable_by_vr(md,baseType,vr); - if(!var) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not find variable referenced in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); + var = fmi2_xml_get_variable_by_vr(md,baseType,vr); + if(!var) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not find variable referenced in log message here: '%s'", jm_vector_get_itemp(char)(msgOut,0)); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - } - name = fmi2_xml_get_variable_name(var); - nameLen = strlen(name); - if(jm_vector_resize(char)(msgOut, pastePos + nameLen) != pastePos + nameLen) { - jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + } + name = fmi2_xml_get_variable_name(var); + nameLen = strlen(name); + if(jm_vector_resize(char)(msgOut, pastePos + nameLen) != pastePos + nameLen) { + jm_log(callbacks,"LOGGER", jm_log_level_warning, "Could not allocate memory for the log message"); jm_vector_resize(char)(msgOut, msgLen); jm_vector_resize(char)(msgOut, msgLen); - memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); - return; - }; - memcpy(jm_vector_get_itemp(char)(msgOut, pastePos), name, nameLen); + memcpy(jm_vector_get_itemp(char)(msgOut,0),msgIn,msgLen); + return; + }; + memcpy(jm_vector_get_itemp(char)(msgOut, pastePos), name, nameLen); } curCh = msgIn[i++]; } while (curCh); @@ -236,57 +236,57 @@ void fmi2_import_expand_variable_references_impl(fmi2_import_t* fmu, const char* void fmi2_log_forwarding(fmi2_component_environment_t c, fmi2_string_t instanceName, fmi2_status_t status, fmi2_string_t category, fmi2_string_t message, ...) { va_list args; va_start (args, message); - fmi2_log_forwarding_v(c, instanceName, status, category, message, args); + fmi2_log_forwarding_v(c, instanceName, status, category, message, args); va_end (args); } void fmi2_log_forwarding_v(fmi2_component_environment_t c, fmi2_string_t instanceName, fmi2_status_t status, fmi2_string_t category, fmi2_string_t message, va_list args) { #define BUFSIZE JM_MAX_ERROR_MESSAGE_SIZE char buffer[BUFSIZE], *buf, *curp, *msg; - const char* statusStr; - fmi2_import_t* fmu = (fmi2_import_t*)c; - jm_callbacks* cb; - jm_log_level_enu_t logLevel; + const char* statusStr; + fmi2_import_t* fmu = (fmi2_import_t*)c; + jm_callbacks* cb; + jm_log_level_enu_t logLevel; - if(fmu) { - cb = fmu->callbacks; + if(fmu) { + cb = fmu->callbacks; buf = jm_vector_get_itemp(char)(&fmu->logMessageBufferCoded,0); - } - else { - cb = jm_get_default_callbacks(); + } + else { + cb = jm_get_default_callbacks(); buf = buffer; } - logLevel = cb->log_level; - switch(status) { - case fmi2_status_discard: - case fmi2_status_pending: - case fmi2_status_ok: - logLevel = jm_log_level_info; - break; - case fmi2_status_warning: - logLevel = jm_log_level_warning; - break; - case fmi2_status_error: - logLevel = jm_log_level_error; - break; - case fmi2_status_fatal: - default: - logLevel = jm_log_level_fatal; - } + logLevel = cb->log_level; + switch(status) { + case fmi2_status_discard: + case fmi2_status_pending: + case fmi2_status_ok: + logLevel = jm_log_level_info; + break; + case fmi2_status_warning: + logLevel = jm_log_level_warning; + break; + case fmi2_status_error: + logLevel = jm_log_level_error; + break; + case fmi2_status_fatal: + default: + logLevel = jm_log_level_fatal; + } if(logLevel > cb->log_level) return; - curp = buf; + curp = buf; *curp = 0; - if(category) { + if(category) { curp += jm_snprintf(curp, 100, "[%s]", category); } - statusStr = fmi2_status_to_string(status); - curp += jm_snprintf(curp, 200, "[FMU status:%s] ", statusStr); + statusStr = fmi2_status_to_string(status); + curp += jm_snprintf(curp, 200, "[FMU status:%s] ", statusStr); - if(fmu) { - int bufsize = jm_vector_get_size(char)(&fmu->logMessageBufferCoded); + if(fmu) { + int bufsize = jm_vector_get_size(char)(&fmu->logMessageBufferCoded); int len; #ifdef JM_VA_COPY va_list argscp; @@ -305,18 +305,18 @@ void fmi2_log_forwarding_v(fmi2_component_environment_t c, fmi2_string_t instan #ifdef JM_VA_COPY va_end(argscp); #endif - fmi2_import_expand_variable_references(fmu, buf, cb->errMessageBuffer,JM_MAX_ERROR_MESSAGE_SIZE); - msg = jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0); - } - else { + fmi2_import_expand_variable_references(fmu, buf, cb->errMessageBuffer,JM_MAX_ERROR_MESSAGE_SIZE); + msg = jm_vector_get_itemp(char)(&fmu->logMessageBufferExpanded,0); + } + else { jm_vsnprintf(curp, BUFSIZE -(curp-buf), message, args); - strncpy(cb->errMessageBuffer, buf, JM_MAX_ERROR_MESSAGE_SIZE); - cb->errMessageBuffer[JM_MAX_ERROR_MESSAGE_SIZE - 1] = '\0'; - msg = cb->errMessageBuffer; - } - if(cb->logger) { - cb->logger(cb, instanceName, logLevel, msg); - } + strncpy(cb->errMessageBuffer, buf, JM_MAX_ERROR_MESSAGE_SIZE); + cb->errMessageBuffer[JM_MAX_ERROR_MESSAGE_SIZE - 1] = '\0'; + msg = cb->errMessageBuffer; + } + if(cb->logger) { + cb->logger(cb, instanceName, logLevel, msg); + } } @@ -339,30 +339,30 @@ void fmi2_default_callback_logger(fmi2_component_environment_t c, fmi2_string_t } void fmi2_logger(jm_callbacks* cb, jm_string module, jm_log_level_enu_t log_level, jm_string message) { - fmi2_callback_functions_t* c = (fmi2_callback_functions_t*)cb->context; - fmi2_status_t status; - if(!c ||!c->logger) return; + fmi2_callback_functions_t* c = (fmi2_callback_functions_t*)cb->context; + fmi2_status_t status; + if(!c ||!c->logger) return; - if(log_level > jm_log_level_all) { - assert(0); - status = fmi2_status_error; - } - else if(log_level >= jm_log_level_info) - status = fmi2_status_ok; - else if(log_level >= jm_log_level_warning) - status = fmi2_status_warning; - else if(log_level >= jm_log_level_error) - status = fmi2_status_error; - else if(log_level >= jm_log_level_fatal) - status = fmi2_status_fatal; - else { - status = fmi2_status_ok; - } + if(log_level > jm_log_level_all) { + assert(0); + status = fmi2_status_error; + } + else if(log_level >= jm_log_level_info) + status = fmi2_status_ok; + else if(log_level >= jm_log_level_warning) + status = fmi2_status_warning; + else if(log_level >= jm_log_level_error) + status = fmi2_status_error; + else if(log_level >= jm_log_level_fatal) + status = fmi2_status_fatal; + else { + status = fmi2_status_ok; + } - c->logger( c, module, status, jm_log_level_to_string(log_level), message); + c->logger( c, module, status, jm_log_level_to_string(log_level), message); } void fmi2_import_init_logger(jm_callbacks* cb, fmi2_callback_functions_t* fmiCallbacks) { - cb->logger = fmi2_logger; - cb->context = fmiCallbacks; + cb->logger = fmi2_logger; + cb->context = fmiCallbacks; } diff --git a/src/Import/src/FMI2/fmi2_import_impl.h b/src/Import/src/FMI2/fmi2_import_impl.h index 2b7108f1..a97fb916 100644 --- a/src/Import/src/FMI2/fmi2_import_impl.h +++ b/src/Import/src/FMI2/fmi2_import_impl.h @@ -34,15 +34,15 @@ extern "C" { #endif -struct fmi2_import_t { - char* dirPath; - char* resourceLocation; - jm_callbacks* callbacks; - fmi2_xml_model_description_t* md; - fmi2_capi_t* capi; - jm_vector(char) logMessageBufferCoded; - jm_vector(char) logMessageBufferExpanded; - fmi_util_options_t* options; +struct fmi2_import_t { + char* dirPath; + char* resourceLocation; + jm_callbacks* callbacks; + fmi2_xml_model_description_t* md; + fmi2_capi_t* capi; + jm_vector(char) logMessageBufferCoded; + jm_vector(char) logMessageBufferExpanded; + fmi_util_options_t* options; }; #ifdef __cplusplus diff --git a/src/Import/src/FMI2/fmi2_import_type.c b/src/Import/src/FMI2/fmi2_import_type.c index f90f6d8a..52207cba 100644 --- a/src/Import/src/FMI2/fmi2_import_type.c +++ b/src/Import/src/FMI2/fmi2_import_type.c @@ -20,103 +20,103 @@ #include "fmi2_import_impl.h" fmi2_import_display_unit_t* fmi2_import_get_type_display_unit(fmi2_import_real_typedef_t* t) { - return fmi2_xml_get_type_display_unit(t); + return fmi2_xml_get_type_display_unit(t); } unsigned int fmi2_import_get_type_definition_number(fmi2_import_type_definitions_t* td) { - return fmi2_xml_get_type_definition_number(td); + return fmi2_xml_get_type_definition_number(td); } fmi2_import_variable_typedef_t* fmi2_import_get_typedef(fmi2_import_type_definitions_t* td, unsigned int index) { - return fmi2_xml_get_typedef(td, index); + return fmi2_xml_get_typedef(td, index); } const char* fmi2_import_get_type_name(fmi2_import_variable_typedef_t* t) { - return fmi2_xml_get_type_name(t); + return fmi2_xml_get_type_name(t); } /* Note that NULL pointer is returned if the attribute is not present in the XML.*/ const char* fmi2_import_get_type_description(fmi2_import_variable_typedef_t* t) { - return fmi2_xml_get_type_description(t); + return fmi2_xml_get_type_description(t); } fmi2_base_type_enu_t fmi2_import_get_base_type(fmi2_import_variable_typedef_t* t) { - return fmi2_xml_get_base_type(t); + return fmi2_xml_get_base_type(t); } fmi2_import_real_typedef_t* fmi2_import_get_type_as_real(fmi2_import_variable_typedef_t* t) { - return fmi2_xml_get_type_as_real(t); + return fmi2_xml_get_type_as_real(t); } fmi2_import_integer_typedef_t* fmi2_import_get_type_as_int(fmi2_import_variable_typedef_t* t) { - return fmi2_xml_get_type_as_int(t); + return fmi2_xml_get_type_as_int(t); } fmi2_import_enumeration_typedef_t* fmi2_import_get_type_as_enum(fmi2_import_variable_typedef_t* t) { - return fmi2_xml_get_type_as_enum(t); + return fmi2_xml_get_type_as_enum(t); } const char* fmi2_import_get_type_quantity(fmi2_import_variable_typedef_t* t) { - return fmi2_xml_get_type_quantity(t); + return fmi2_xml_get_type_quantity(t); } fmi2_real_t fmi2_import_get_real_type_min(fmi2_import_real_typedef_t* t) { - return fmi2_xml_get_real_type_min(t); + return fmi2_xml_get_real_type_min(t); } fmi2_real_t fmi2_import_get_real_type_max(fmi2_import_real_typedef_t* t) { - return fmi2_xml_get_real_type_max(t); + return fmi2_xml_get_real_type_max(t); } fmi2_real_t fmi2_import_get_real_type_nominal(fmi2_import_real_typedef_t* t) { - return fmi2_xml_get_real_type_nominal(t); + return fmi2_xml_get_real_type_nominal(t); } fmi2_import_unit_t* fmi2_import_get_real_type_unit(fmi2_import_real_typedef_t* t) { - return fmi2_xml_get_real_type_unit(t); + return fmi2_xml_get_real_type_unit(t); } int fmi2_import_get_real_type_is_relative_quantity(fmi2_import_real_typedef_t* t) { - return fmi2_xml_get_real_type_is_relative_quantity(t); + return fmi2_xml_get_real_type_is_relative_quantity(t); } int fmi2_import_get_real_type_is_unbounded(fmi2_import_real_typedef_t* t) { - return fmi2_xml_get_real_type_is_unbounded(t); + return fmi2_xml_get_real_type_is_unbounded(t); } fmi2_integer_t fmi2_import_get_integer_type_min(fmi2_import_integer_typedef_t* t) { - return fmi2_xml_get_integer_type_min(t); + return fmi2_xml_get_integer_type_min(t); } fmi2_integer_t fmi2_import_get_integer_type_max(fmi2_import_integer_typedef_t* t){ - return fmi2_xml_get_integer_type_max(t); + return fmi2_xml_get_integer_type_max(t); } unsigned int fmi2_import_get_enum_type_min(fmi2_import_enumeration_typedef_t* t){ - return fmi2_xml_get_enum_type_min(t); + return fmi2_xml_get_enum_type_min(t); } unsigned int fmi2_import_get_enum_type_max(fmi2_import_enumeration_typedef_t* t){ - return fmi2_xml_get_enum_type_max(t); + return fmi2_xml_get_enum_type_max(t); } unsigned int fmi2_import_get_enum_type_size(fmi2_import_enumeration_typedef_t* t) { - return fmi2_xml_get_enum_type_size(t); + return fmi2_xml_get_enum_type_size(t); } const char* fmi2_import_get_enum_type_item_name(fmi2_import_enumeration_typedef_t* t, unsigned int item) { - return fmi2_xml_get_enum_type_item_name(t, item); + return fmi2_xml_get_enum_type_item_name(t, item); } const char* fmi2_import_get_enum_type_item_description(fmi2_import_enumeration_typedef_t* t, unsigned int item){ - return fmi2_xml_get_enum_type_item_description(t, item); + return fmi2_xml_get_enum_type_item_description(t, item); } int fmi2_import_get_enum_type_item_value(fmi2_import_enumeration_typedef_t* t, unsigned int item) { - return fmi2_xml_get_enum_type_item_value(t, item); + return fmi2_xml_get_enum_type_item_value(t, item); } const char* fmi2_import_get_enum_type_value_name(fmi2_import_enumeration_typedef_t* t, int value) { - return fmi2_xml_get_enum_type_value_name(t, value); + return fmi2_xml_get_enum_type_value_name(t, value); } diff --git a/src/Import/src/FMI2/fmi2_import_unit.c b/src/Import/src/FMI2/fmi2_import_unit.c index c5f6631f..8f406a73 100644 --- a/src/Import/src/FMI2/fmi2_import_unit.c +++ b/src/Import/src/FMI2/fmi2_import_unit.c @@ -16,65 +16,65 @@ #include "fmi2_import_impl.h" fmi2_import_unit_t* fmi2_import_get_unit(fmi2_import_unit_definitions_t* ud, unsigned int index) { - return fmi2_xml_get_unit(ud, index); + return fmi2_xml_get_unit(ud, index); } const char* fmi2_import_get_unit_name(fmi2_import_unit_t* u) { - return fmi2_xml_get_unit_name(u); + return fmi2_xml_get_unit_name(u); } const int* fmi2_import_get_SI_unit_exponents(fmi2_import_unit_t* u){ - return fmi2_xml_get_SI_unit_exponents(u); + return fmi2_xml_get_SI_unit_exponents(u); } /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ double fmi2_import_get_SI_unit_factor(fmi2_import_unit_t* u) { - return fmi2_xml_get_SI_unit_factor(u); + return fmi2_xml_get_SI_unit_factor(u); } /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ double fmi2_import_get_SI_unit_offset(fmi2_import_unit_t* u) { - return fmi2_xml_get_SI_unit_offset(u); + return fmi2_xml_get_SI_unit_offset(u); } /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ double fmi2_import_convert_to_SI_base_unit(double v, fmi2_import_unit_t* u) { - return fmi2_xml_convert_to_SI_base_unit(v,u); + return fmi2_xml_convert_to_SI_base_unit(v,u); } /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ double fmi2_import_convert_from_SI_base_unit(double v , fmi2_import_unit_t* u) { - return fmi2_xml_convert_from_SI_base_unit( v, u); + return fmi2_xml_convert_from_SI_base_unit( v, u); } unsigned int fmi2_import_get_unit_display_unit_number(fmi2_import_unit_t* u) { - return fmi2_xml_get_unit_display_unit_number(u); + return fmi2_xml_get_unit_display_unit_number(u); } fmi2_import_display_unit_t* fmi2_import_get_unit_display_unit(fmi2_import_unit_t* u, size_t index) { - return fmi2_xml_get_unit_display_unit(u, index); + return fmi2_xml_get_unit_display_unit(u, index); } fmi2_import_unit_t* fmi2_import_get_base_unit(fmi2_import_display_unit_t* du) { - return fmi2_xml_get_base_unit(du); + return fmi2_xml_get_base_unit(du); } const char* fmi2_import_get_display_unit_name(fmi2_import_display_unit_t* du) { - return fmi2_xml_get_display_unit_name(du); + return fmi2_xml_get_display_unit_name(du); } fmi2_real_t fmi2_import_get_display_unit_factor(fmi2_import_display_unit_t* du) { - return fmi2_xml_get_display_unit_factor(du); + return fmi2_xml_get_display_unit_factor(du); } fmi2_real_t fmi2_import_get_display_unit_offset(fmi2_import_display_unit_t* du) { diff --git a/src/Import/src/FMI2/fmi2_import_variable.c b/src/Import/src/FMI2/fmi2_import_variable.c index 16b85323..e8b4db5c 100644 --- a/src/Import/src/FMI2/fmi2_import_variable.c +++ b/src/Import/src/FMI2/fmi2_import_variable.c @@ -24,83 +24,83 @@ #include "fmi2_import_variable_list_impl.h" fmi2_import_variable_t* fmi2_import_get_variable_by_name(fmi2_import_t* fmu, const char* name) { - return fmi2_xml_get_variable_by_name(fmu->md, name); + return fmi2_xml_get_variable_by_name(fmu->md, name); } fmi2_import_variable_t* fmi2_import_get_variable_by_vr(fmi2_import_t* fmu, fmi2_base_type_enu_t baseType, fmi2_value_reference_t vr) { - return fmi2_xml_get_variable_by_vr(fmu->md, baseType, vr); + return fmi2_xml_get_variable_by_vr(fmu->md, baseType, vr); } const char* fmi2_import_get_variable_name(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_name(v); + return fmi2_xml_get_variable_name(v); } const char* fmi2_import_get_variable_description(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_description(v); + return fmi2_xml_get_variable_description(v); } fmi2_value_reference_t fmi2_import_get_variable_vr(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_vr(v); + return fmi2_xml_get_variable_vr(v); } /* For scalar variable gives the type definition is present */ fmi2_import_variable_typedef_t* fmi2_import_get_variable_declared_type(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_declared_type(v); + return fmi2_xml_get_variable_declared_type(v); } fmi2_base_type_enu_t fmi2_import_get_variable_base_type(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_base_type(v); + return fmi2_xml_get_variable_base_type(v); } int fmi2_import_get_variable_has_start(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_has_start(v); + return fmi2_xml_get_variable_has_start(v); } fmi2_variability_enu_t fmi2_import_get_variability(fmi2_import_variable_t* v) { - return fmi2_xml_get_variability(v); + return fmi2_xml_get_variability(v); } fmi2_causality_enu_t fmi2_import_get_causality(fmi2_import_variable_t* v) { - return fmi2_xml_get_causality(v); + return fmi2_xml_get_causality(v); } fmi2_initial_enu_t fmi2_import_get_initial(fmi2_import_variable_t* v) { - return fmi2_xml_get_initial(v); + return fmi2_xml_get_initial(v); } fmi2_import_variable_t* fmi2_import_get_previous(fmi2_import_variable_t* v) { - return fmi2_xml_get_previous(v); + return fmi2_xml_get_previous(v); } fmi2_boolean_t fmi2_import_get_canHandleMultipleSetPerTimeInstant(fmi2_import_variable_t* v) { - return fmi2_xml_get_canHandleMultipleSetPerTimeInstant(v); + return fmi2_xml_get_canHandleMultipleSetPerTimeInstant(v); } fmi2_import_real_variable_t* fmi2_import_get_variable_as_real(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_as_real(v); + return fmi2_xml_get_variable_as_real(v); } fmi2_import_integer_variable_t* fmi2_import_get_variable_as_integer(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_as_integer(v); + return fmi2_xml_get_variable_as_integer(v); } fmi2_import_enum_variable_t* fmi2_import_get_variable_as_enum(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_as_enum(v); + return fmi2_xml_get_variable_as_enum(v); } fmi2_import_string_variable_t* fmi2_import_get_variable_as_string(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_as_string(v); + return fmi2_xml_get_variable_as_string(v); } fmi2_import_bool_variable_t* fmi2_import_get_variable_as_boolean(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_as_boolean(v); + return fmi2_xml_get_variable_as_boolean(v); } fmi2_real_t fmi2_import_get_real_variable_start(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_start(v); + return fmi2_xml_get_real_variable_start(v); } fmi2_import_real_variable_t* fmi2_import_get_real_variable_derivative_of(fmi2_import_real_variable_t* v) { @@ -112,83 +112,83 @@ fmi2_boolean_t fmi2_import_get_real_variable_reinit(fmi2_import_real_variable_t* } fmi2_real_t fmi2_import_get_real_variable_max(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_max(v); + return fmi2_xml_get_real_variable_max(v); } fmi2_real_t fmi2_import_get_real_variable_min(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_min(v); + return fmi2_xml_get_real_variable_min(v); } fmi2_real_t fmi2_import_get_real_variable_nominal(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_nominal(v); + return fmi2_xml_get_real_variable_nominal(v); } fmi2_boolean_t fmi2_import_get_real_variable_unbounded(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_unbounded(v); + return fmi2_xml_get_real_variable_unbounded(v); } fmi2_boolean_t fmi2_import_get_real_variable_relative_quantity(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_relative_quantity(v); + return fmi2_xml_get_real_variable_relative_quantity(v); } fmi2_string_t fmi2_import_get_real_variable_quantity(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_quantity(v); + return fmi2_xml_get_real_variable_quantity(v); } fmi2_import_unit_t* fmi2_import_get_real_variable_unit(fmi2_import_real_variable_t* v) { - return fmi2_xml_get_real_variable_unit(v); + return fmi2_xml_get_real_variable_unit(v); } fmi2_import_display_unit_t* fmi2_import_get_real_variable_display_unit(fmi2_import_real_variable_t* v){ - return fmi2_xml_get_real_variable_display_unit(v); + return fmi2_xml_get_real_variable_display_unit(v); } const char* fmi2_import_get_string_variable_start(fmi2_import_string_variable_t* v) { - return fmi2_xml_get_string_variable_start(v); + return fmi2_xml_get_string_variable_start(v); } fmi2_boolean_t fmi2_import_get_boolean_variable_start(fmi2_import_bool_variable_t* v){ - return fmi2_xml_get_boolean_variable_start(v); + return fmi2_xml_get_boolean_variable_start(v); } fmi2_string_t fmi2_import_get_integer_variable_quantity(fmi2_import_integer_variable_t* v) { - return fmi2_xml_get_integer_variable_quantity(v); + return fmi2_xml_get_integer_variable_quantity(v); } int fmi2_import_get_integer_variable_start(fmi2_import_integer_variable_t* v) { - return fmi2_xml_get_integer_variable_start(v); + return fmi2_xml_get_integer_variable_start(v); } int fmi2_import_get_integer_variable_min(fmi2_import_integer_variable_t* v) { - return fmi2_xml_get_integer_variable_min(v); + return fmi2_xml_get_integer_variable_min(v); } int fmi2_import_get_integer_variable_max(fmi2_import_integer_variable_t* v) { - return fmi2_xml_get_integer_variable_max(v); + return fmi2_xml_get_integer_variable_max(v); } fmi2_string_t fmi2_import_get_enum_variable_quantity(fmi2_import_enum_variable_t* v) { - return fmi2_xml_get_enum_variable_quantity(v); + return fmi2_xml_get_enum_variable_quantity(v); } int fmi2_import_get_enum_variable_start(fmi2_import_enum_variable_t* v) { - return fmi2_xml_get_enum_variable_start(v); + return fmi2_xml_get_enum_variable_start(v); } int fmi2_import_get_enum_variable_min(fmi2_import_enum_variable_t* v) { - return fmi2_xml_get_enum_variable_min(v); + return fmi2_xml_get_enum_variable_min(v); } int fmi2_import_get_enum_variable_max(fmi2_import_enum_variable_t* v) { - return fmi2_xml_get_enum_variable_max(v); + return fmi2_xml_get_enum_variable_max(v); } fmi2_variable_alias_kind_enu_t fmi2_import_get_variable_alias_kind(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_alias_kind(v); + return fmi2_xml_get_variable_alias_kind(v); } fmi2_import_variable_t* fmi2_import_get_variable_alias_base(fmi2_import_t* fmu,fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_alias_base(fmu->md, v); + return fmi2_xml_get_variable_alias_base(fmu->md, v); } /* @@ -196,14 +196,14 @@ fmi2_import_variable_t* fmi2_import_get_variable_alias_base(fmi2_import_t* fmu,f The list is ordered: base variable, aliases, negated aliases. */ fmi2_import_variable_list_t* fmi2_import_get_variable_aliases(fmi2_import_t* fmu,fmi2_import_variable_t* v) { - fmi2_import_variable_list_t* list = fmi2_import_alloc_variable_list(fmu, 0); - if(fmi2_xml_get_variable_aliases(fmu->md, v, &list->variables) != jm_status_success) { - fmi2_import_free_variable_list(list); - return 0; - } - return list; + fmi2_import_variable_list_t* list = fmi2_import_alloc_variable_list(fmu, 0); + if(fmi2_xml_get_variable_aliases(fmu->md, v, &list->variables) != jm_status_success) { + fmi2_import_free_variable_list(list); + return 0; + } + return list; } size_t fmi2_import_get_variable_original_order(fmi2_import_variable_t* v) { - return fmi2_xml_get_variable_original_order((fmi2_xml_variable_t*)v); + return fmi2_xml_get_variable_original_order((fmi2_xml_variable_t*)v); } diff --git a/src/Import/src/FMI2/fmi2_import_variable_list.c b/src/Import/src/FMI2/fmi2_import_variable_list.c index e7fcd04e..e006cda7 100644 --- a/src/Import/src/FMI2/fmi2_import_variable_list.c +++ b/src/Import/src/FMI2/fmi2_import_variable_list.c @@ -18,11 +18,11 @@ #include "fmi2_import_variable_list_impl.h" fmi2_import_variable_list_t* fmi2_import_alloc_variable_list(fmi2_import_t* fmu, size_t size) { - jm_callbacks* cb = fmu->callbacks; - fmi2_import_variable_list_t* vl = (fmi2_import_variable_list_t*)cb->malloc(sizeof(fmi2_import_variable_list_t)); + jm_callbacks* cb = fmu->callbacks; + fmi2_import_variable_list_t* vl = (fmi2_import_variable_list_t*)cb->malloc(sizeof(fmi2_import_variable_list_t)); if(!vl) return 0; vl->vr = 0; - vl->fmu = fmu; + vl->fmu = fmu; if(jm_vector_init(jm_voidp)(&vl->variables,size,cb) < size) { fmi2_import_free_variable_list(vl); return 0; @@ -32,19 +32,19 @@ fmi2_import_variable_list_t* fmi2_import_alloc_variable_list(fmi2_import_t* fmu, void fmi2_import_free_variable_list(fmi2_import_variable_list_t* vl) { jm_callbacks* cb; - if(!vl) return; - cb = vl->variables.callbacks; - cb->free(vl->vr); + if(!vl) return; + cb = vl->variables.callbacks; + cb->free(vl->vr); jm_vector_free_data(jm_voidp)(&vl->variables); cb->free(vl); } /* Get number of variables in a list */ size_t fmi2_import_get_variable_list_size(fmi2_import_variable_list_t* vl) { - if(vl) - return jm_vector_get_size(jm_voidp)(&vl->variables); - else - return 0; + if(vl) + return jm_vector_get_size(jm_voidp)(&vl->variables); + else + return 0; } /* Make a copy */ @@ -103,25 +103,25 @@ jm_status_enu_t fmi2_import_var_list_push_back(fmi2_import_variable_list_t* list /* Get a pointer to the list of the value references for all the variables */ const fmi2_value_reference_t* fmi2_import_get_value_referece_list(fmi2_import_variable_list_t* vl) { if(!vl->vr) { - jm_callbacks* cb = vl->fmu->callbacks; + jm_callbacks* cb = vl->fmu->callbacks; size_t i, nv = fmi2_import_get_variable_list_size(vl); - vl->vr = (fmi2_value_reference_t*)cb->malloc(nv * sizeof(fmi2_value_reference_t)); + vl->vr = (fmi2_value_reference_t*)cb->malloc(nv * sizeof(fmi2_value_reference_t)); if(vl->vr) { for(i = 0; i < nv; i++) { - vl->vr[i] = fmi2_xml_get_variable_vr(fmi2_import_get_variable(vl, i)); + vl->vr[i] = fmi2_xml_get_variable_vr(fmi2_import_get_variable(vl, i)); } } - else return 0; + else return 0; } return vl->vr; } /* Get a single variable from the list*/ fmi2_import_variable_t* fmi2_import_get_variable(fmi2_import_variable_list_t* vl, size_t index) { - if(index >= fmi2_import_get_variable_list_size(vl)) - return 0; - else - return (fmi2_import_variable_t*)jm_vector_get_item(jm_voidp)(&vl->variables, index); + if(index >= fmi2_import_get_variable_list_size(vl)) + return 0; + else + return (fmi2_import_variable_t*)jm_vector_get_item(jm_voidp)(&vl->variables, index); } /* Operations on variable lists. Every operation creates a new list. */ @@ -145,7 +145,7 @@ fmi2_import_variable_list_t* fmi2_import_get_sublist(fmi2_import_variable_list_t fmi2_import_variable_list_t* fmi2_import_filter_variables(fmi2_import_variable_list_t* vl, fmi2_import_variable_filter_function_ft filter, void* context) { size_t nv, i; fmi2_import_variable_list_t* out = fmi2_import_alloc_variable_list(vl->fmu, 0); - if(!out) return 0; /* out of memory */ + if(!out) return 0; /* out of memory */ nv = fmi2_import_get_variable_list_size(vl); for(i=0; i < nv;i++) { fmi2_import_variable_t* variable = fmi2_import_get_variable(vl, i); diff --git a/src/Import/src/FMI2/fmi2_import_variable_list_impl.h b/src/Import/src/FMI2/fmi2_import_variable_list_impl.h index 3a31f171..b58a11c4 100644 --- a/src/Import/src/FMI2/fmi2_import_variable_list_impl.h +++ b/src/Import/src/FMI2/fmi2_import_variable_list_impl.h @@ -25,7 +25,7 @@ extern "C" { #endif struct fmi2_import_variable_list_t { - fmi2_import_t* fmu; + fmi2_import_t* fmu; jm_vector(jm_voidp) variables; fmi2_value_reference_t* vr; }; diff --git a/src/Import/src/FMI3/fmi3_import_dimension_list.c b/src/Import/src/FMI3/fmi3_import_dimension_list.c index 08f4e55a..47780da3 100644 --- a/src/Import/src/FMI3/fmi3_import_dimension_list.c +++ b/src/Import/src/FMI3/fmi3_import_dimension_list.c @@ -21,25 +21,25 @@ #include "../XML/src/FMI3/fmi3_xml_dimension_impl.h" /* TODO: we need access to jm_vector(fmi3_xml_dimension_t), but we shouldn't include any xml impl. files */ fmi3_import_dimension_list_t* fmi3_import_alloc_dimension_list(fmi3_import_t* fmu, fmi3_import_variable_t* v) { - jm_callbacks* cb = fmu->callbacks; - fmi3_import_dimension_list_t* dl = (fmi3_import_dimension_list_t*)cb->malloc(sizeof(fmi3_import_dimension_list_t)); + jm_callbacks* cb = fmu->callbacks; + fmi3_import_dimension_list_t* dl = (fmi3_import_dimension_list_t*)cb->malloc(sizeof(fmi3_import_dimension_list_t)); if (!dl) return 0; - dl->fmu = fmu; + dl->fmu = fmu; dl->vec = fmi3_xml_get_variable_dimension_vector(v); return dl; } void fmi3_import_free_dimension_list(fmi3_import_dimension_list_t* dl) { - if (!dl) + if (!dl) return; - dl->vec->callbacks->free(dl); + dl->vec->callbacks->free(dl); } /* get number of dimensions in list */ size_t fmi3_import_get_dimension_list_size(fmi3_import_dimension_list_t* dl) { - if (!dl) - return 0; + if (!dl) + return 0; return jm_vector_get_size(fmi3_xml_dimension_t)(dl->vec); } diff --git a/src/Import/src/FMI3/fmi3_import_dimension_list_impl.h b/src/Import/src/FMI3/fmi3_import_dimension_list_impl.h index 39e9a798..24314062 100644 --- a/src/Import/src/FMI3/fmi3_import_dimension_list_impl.h +++ b/src/Import/src/FMI3/fmi3_import_dimension_list_impl.h @@ -26,7 +26,7 @@ extern "C" { #endif struct fmi3_import_dimension_list_t { - fmi3_import_t* fmu; + fmi3_import_t* fmu; jm_vector(fmi3_xml_dimension_t)* vec; }; diff --git a/src/Import/src/FMI3/fmi3_import_impl.h b/src/Import/src/FMI3/fmi3_import_impl.h index 7c0c6d77..091bf6d7 100644 --- a/src/Import/src/FMI3/fmi3_import_impl.h +++ b/src/Import/src/FMI3/fmi3_import_impl.h @@ -37,13 +37,13 @@ extern "C" { * 'capi' contains references to the FMU's loaded CAPI functions. Is NULL if never loaded or terminated. */ struct fmi3_import_t { - char* dirPath; - char* resourcePath; - jm_callbacks* callbacks; - fmi3_xml_model_description_t* md; - fmi3_capi_t* capi; - jm_vector(char) logMessageBufferCoded; - jm_vector(char) logMessageBufferExpanded; + char* dirPath; + char* resourcePath; + jm_callbacks* callbacks; + fmi3_xml_model_description_t* md; + fmi3_capi_t* capi; + jm_vector(char) logMessageBufferCoded; + jm_vector(char) logMessageBufferExpanded; }; #ifdef __cplusplus diff --git a/src/Import/src/FMI3/fmi3_import_priv.c b/src/Import/src/FMI3/fmi3_import_priv.c index 0d937370..fa521340 100644 --- a/src/Import/src/FMI3/fmi3_import_priv.c +++ b/src/Import/src/FMI3/fmi3_import_priv.c @@ -18,9 +18,9 @@ #include "fmi3_import_priv.h" int fmi3_import_check_has_FMU(fmi3_import_t* fmu) { - if(!fmu->md) { - jm_log_error(fmu->callbacks, "FMILIB", "No FMU is loaded"); - return 0; - } - return 1; + if(!fmu->md) { + jm_log_error(fmu->callbacks, "FMILIB", "No FMU is loaded"); + return 0; + } + return 1; } diff --git a/src/Import/src/FMI3/fmi3_import_type.c b/src/Import/src/FMI3/fmi3_import_type.c index 88ff6139..b5bbe17d 100644 --- a/src/Import/src/FMI3/fmi3_import_type.c +++ b/src/Import/src/FMI3/fmi3_import_type.c @@ -21,40 +21,40 @@ #include "fmi3_import_impl.h" unsigned int fmi3_import_get_type_definition_number(fmi3_import_type_definitions_t* td) { - return fmi3_xml_get_type_definition_number(td); + return fmi3_xml_get_type_definition_number(td); } fmi3_import_variable_typedef_t* fmi3_import_get_typedef(fmi3_import_type_definitions_t* td, unsigned int index) { - return fmi3_xml_get_typedef(td, index); + return fmi3_xml_get_typedef(td, index); } const char* fmi3_import_get_type_name(fmi3_import_variable_typedef_t* t) { - return fmi3_xml_get_type_name(t); + return fmi3_xml_get_type_name(t); } /* Note that NULL pointer is returned if the attribute is not present in the XML.*/ const char* fmi3_import_get_type_description(fmi3_import_variable_typedef_t* t) { - return fmi3_xml_get_type_description(t); + return fmi3_xml_get_type_description(t); } fmi3_base_type_enu_t fmi3_import_get_base_type(fmi3_import_variable_typedef_t* t) { - return fmi3_xml_get_base_type(t); + return fmi3_xml_get_base_type(t); } fmi3_import_float_typedef_t* fmi3_import_get_type_as_float(fmi3_import_variable_typedef_t* t) { - return fmi3_xml_get_type_as_float(t); + return fmi3_xml_get_type_as_float(t); } fmi3_import_int_typedef_t* fmi3_import_get_type_as_int(fmi3_import_variable_typedef_t* t) { - return fmi3_xml_get_type_as_int(t); + return fmi3_xml_get_type_as_int(t); } fmi3_import_enumeration_typedef_t* fmi3_import_get_type_as_enum(fmi3_import_variable_typedef_t* t) { - return fmi3_xml_get_type_as_enum(t); + return fmi3_xml_get_type_as_enum(t); } const char* fmi3_import_get_type_quantity(fmi3_import_variable_typedef_t* t) { - return fmi3_xml_get_type_quantity(t); + return fmi3_xml_get_type_quantity(t); } fmi3_float64_t fmi3_import_get_float64_type_min(fmi3_import_float_typedef_t* t) { @@ -178,29 +178,29 @@ fmi3_uint8_t fmi3_import_get_uint8_type_max(fmi3_import_int_typedef_t* t) { } unsigned int fmi3_import_get_enum_type_min(fmi3_import_enumeration_typedef_t* t){ - return fmi3_xml_get_enum_type_min(t); + return fmi3_xml_get_enum_type_min(t); } unsigned int fmi3_import_get_enum_type_max(fmi3_import_enumeration_typedef_t* t){ - return fmi3_xml_get_enum_type_max(t); + return fmi3_xml_get_enum_type_max(t); } unsigned int fmi3_import_get_enum_type_size(fmi3_import_enumeration_typedef_t* t) { - return fmi3_xml_get_enum_type_size(t); + return fmi3_xml_get_enum_type_size(t); } const char* fmi3_import_get_enum_type_item_name(fmi3_import_enumeration_typedef_t* t, unsigned int item) { - return fmi3_xml_get_enum_type_item_name(t, item); + return fmi3_xml_get_enum_type_item_name(t, item); } const char* fmi3_import_get_enum_type_item_description(fmi3_import_enumeration_typedef_t* t, unsigned int item){ - return fmi3_xml_get_enum_type_item_description(t, item); + return fmi3_xml_get_enum_type_item_description(t, item); } int fmi3_import_get_enum_type_item_value(fmi3_import_enumeration_typedef_t* t, unsigned int item) { - return fmi3_xml_get_enum_type_item_value(t, item); + return fmi3_xml_get_enum_type_item_value(t, item); } const char* fmi3_import_get_enum_type_value_name(fmi3_import_enumeration_typedef_t* t, int value) { - return fmi3_xml_get_enum_type_value_name(t, value); + return fmi3_xml_get_enum_type_value_name(t, value); } diff --git a/src/Import/src/FMI3/fmi3_import_unit.c b/src/Import/src/FMI3/fmi3_import_unit.c index 10f6a970..3657e149 100644 --- a/src/Import/src/FMI3/fmi3_import_unit.c +++ b/src/Import/src/FMI3/fmi3_import_unit.c @@ -16,65 +16,65 @@ #include "fmi3_import_impl.h" fmi3_import_unit_t* fmi3_import_get_unit(fmi3_import_unit_definitions_t* ud, unsigned int index) { - return fmi3_xml_get_unit(ud, index); + return fmi3_xml_get_unit(ud, index); } const char* fmi3_import_get_unit_name(fmi3_import_unit_t* u) { - return fmi3_xml_get_unit_name(u); + return fmi3_xml_get_unit_name(u); } const int* fmi3_import_get_SI_unit_exponents(fmi3_import_unit_t* u){ - return fmi3_xml_get_SI_unit_exponents(u); + return fmi3_xml_get_SI_unit_exponents(u); } /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ double fmi3_import_get_SI_unit_factor(fmi3_import_unit_t* u) { - return fmi3_xml_get_SI_unit_factor(u); + return fmi3_xml_get_SI_unit_factor(u); } /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ double fmi3_import_get_SI_unit_offset(fmi3_import_unit_t* u) { - return fmi3_xml_get_SI_unit_offset(u); + return fmi3_xml_get_SI_unit_offset(u); } /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ double fmi3_import_convert_to_SI_base_unit(double v, fmi3_import_unit_t* u) { - return fmi3_xml_convert_to_SI_base_unit(v,u); + return fmi3_xml_convert_to_SI_base_unit(v,u); } /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ double fmi3_import_convert_from_SI_base_unit(double v , fmi3_import_unit_t* u) { - return fmi3_xml_convert_from_SI_base_unit( v, u); + return fmi3_xml_convert_from_SI_base_unit( v, u); } unsigned int fmi3_import_get_unit_display_unit_number(fmi3_import_unit_t* u) { - return fmi3_xml_get_unit_display_unit_number(u); + return fmi3_xml_get_unit_display_unit_number(u); } fmi3_import_display_unit_t* fmi3_import_get_unit_display_unit(fmi3_import_unit_t* u, size_t index) { - return fmi3_xml_get_unit_display_unit(u, index); + return fmi3_xml_get_unit_display_unit(u, index); } fmi3_import_unit_t* fmi3_import_get_base_unit(fmi3_import_display_unit_t* du) { - return fmi3_xml_get_base_unit(du); + return fmi3_xml_get_base_unit(du); } const char* fmi3_import_get_display_unit_name(fmi3_import_display_unit_t* du) { - return fmi3_xml_get_display_unit_name(du); + return fmi3_xml_get_display_unit_name(du); } double fmi3_import_get_display_unit_factor(fmi3_import_display_unit_t* du) { - return fmi3_xml_get_display_unit_factor(du); + return fmi3_xml_get_display_unit_factor(du); } double fmi3_import_get_display_unit_offset(fmi3_import_display_unit_t* du) { diff --git a/src/Import/src/FMI3/fmi3_import_variable.c b/src/Import/src/FMI3/fmi3_import_variable.c index 7cc36c69..df5e949d 100644 --- a/src/Import/src/FMI3/fmi3_import_variable.c +++ b/src/Import/src/FMI3/fmi3_import_variable.c @@ -26,34 +26,34 @@ #include "FMI3/fmi3_import_dimension_list.h" fmi3_import_variable_t* fmi3_import_get_variable_by_name(fmi3_import_t* fmu, const char* name) { - return fmi3_xml_get_variable_by_name(fmu->md, name); + return fmi3_xml_get_variable_by_name(fmu->md, name); } fmi3_import_variable_t* fmi3_import_get_variable_by_vr(fmi3_import_t* fmu, fmi3_base_type_enu_t baseType, fmi3_value_reference_t vr) { - return fmi3_xml_get_variable_by_vr(fmu->md, baseType, vr); + return fmi3_xml_get_variable_by_vr(fmu->md, baseType, vr); } const char* fmi3_import_get_variable_name(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_name(v); + return fmi3_xml_get_variable_name(v); } const char* fmi3_import_get_variable_description(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_description(v); + return fmi3_xml_get_variable_description(v); } fmi3_value_reference_t fmi3_import_get_variable_vr(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_vr(v); + return fmi3_xml_get_variable_vr(v); } /* For scalar variable gives the type definition is present */ fmi3_import_variable_typedef_t* fmi3_import_get_variable_declared_type(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_declared_type(v); + return fmi3_xml_get_variable_declared_type(v); } fmi3_base_type_enu_t fmi3_import_get_variable_base_type(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_base_type(v); + return fmi3_xml_get_variable_base_type(v); } fmi3_import_dimension_list_t* fmi3_import_get_variable_dimension_list(fmi3_import_t* fmu, fmi3_import_variable_t* v) { @@ -61,317 +61,317 @@ fmi3_import_dimension_list_t* fmi3_import_get_variable_dimension_list(fmi3_impor } int fmi3_import_variable_is_array(fmi3_import_variable_t* v) { - return fmi3_xml_variable_is_array(v); + return fmi3_xml_variable_is_array(v); } int fmi3_import_get_variable_has_start(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_has_start(v); + return fmi3_xml_get_variable_has_start(v); } fmi3_variability_enu_t fmi3_import_get_variability(fmi3_import_variable_t* v) { - return fmi3_xml_get_variability(v); + return fmi3_xml_get_variability(v); } fmi3_causality_enu_t fmi3_import_get_causality(fmi3_import_variable_t* v) { - return fmi3_xml_get_causality(v); + return fmi3_xml_get_causality(v); } fmi3_initial_enu_t fmi3_import_get_initial(fmi3_import_variable_t* v) { - return fmi3_xml_get_initial(v); + return fmi3_xml_get_initial(v); } fmi3_import_variable_t* fmi3_import_get_previous(fmi3_import_variable_t* v) { - return fmi3_xml_get_previous(v); + return fmi3_xml_get_previous(v); } fmi3_boolean_t fmi3_import_get_canHandleMultipleSetPerTimeInstant(fmi3_import_variable_t* v) { - return fmi3_xml_get_canHandleMultipleSetPerTimeInstant(v); + return fmi3_xml_get_canHandleMultipleSetPerTimeInstant(v); } fmi3_import_enum_variable_t* fmi3_import_get_variable_as_enum(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_enum(v); + return fmi3_xml_get_variable_as_enum(v); } fmi3_import_string_variable_t* fmi3_import_get_variable_as_string(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_string(v); + return fmi3_xml_get_variable_as_string(v); } fmi3_import_bool_variable_t* fmi3_import_get_variable_as_boolean(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_boolean(v); + return fmi3_xml_get_variable_as_boolean(v); } fmi3_import_float64_variable_t* fmi3_import_get_variable_as_float64(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_float64(v); + return fmi3_xml_get_variable_as_float64(v); } fmi3_float64_t fmi3_import_get_float64_variable_min(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_min(v); + return fmi3_xml_get_float64_variable_min(v); } fmi3_float64_t fmi3_import_get_float64_variable_max(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_max(v); + return fmi3_xml_get_float64_variable_max(v); } fmi3_float64_t fmi3_import_get_float64_variable_nominal(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_nominal(v); + return fmi3_xml_get_float64_variable_nominal(v); } fmi3_float64_t fmi3_import_get_float64_variable_start(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_start(v); + return fmi3_xml_get_float64_variable_start(v); } fmi3_float64_t* fmi3_import_get_float64_variable_start_array(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_start_array(v); + return fmi3_xml_get_float64_variable_start_array(v); } fmi3_boolean_t fmi3_import_get_float64_variable_reinit(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_reinit(v); + return fmi3_xml_get_float64_variable_reinit(v); } fmi3_import_float64_variable_t* fmi3_import_get_float64_variable_derivative_of(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_derivative_of(v); + return fmi3_xml_get_float64_variable_derivative_of(v); } fmi3_import_unit_t* fmi3_import_get_float64_variable_unit(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_unit(v); + return fmi3_xml_get_float64_variable_unit(v); } fmi3_import_display_unit_t* fmi3_import_get_float64_variable_display_unit(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_display_unit(v); + return fmi3_xml_get_float64_variable_display_unit(v); } fmi3_string_t fmi3_import_get_float64_variable_quantity(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_quantity(v); + return fmi3_xml_get_float64_variable_quantity(v); } fmi3_boolean_t fmi3_import_get_float64_variable_unbounded(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_unbounded(v); + return fmi3_xml_get_float64_variable_unbounded(v); } fmi3_boolean_t fmi3_import_get_float64_variable_relative_quantity(fmi3_import_float64_variable_t* v) { - return fmi3_xml_get_float64_variable_relative_quantity(v); + return fmi3_xml_get_float64_variable_relative_quantity(v); } fmi3_import_float32_variable_t* fmi3_import_get_variable_as_float32(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_float32(v); + return fmi3_xml_get_variable_as_float32(v); } fmi3_float32_t fmi3_import_get_float32_variable_min(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_min(v); + return fmi3_xml_get_float32_variable_min(v); } fmi3_float32_t fmi3_import_get_float32_variable_max(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_max(v); + return fmi3_xml_get_float32_variable_max(v); } fmi3_float32_t fmi3_import_get_float32_variable_nominal(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_nominal(v); + return fmi3_xml_get_float32_variable_nominal(v); } fmi3_float32_t fmi3_import_get_float32_variable_start(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_start(v); + return fmi3_xml_get_float32_variable_start(v); } fmi3_float32_t* fmi3_import_get_float32_variable_start_array(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_start_array(v); + return fmi3_xml_get_float32_variable_start_array(v); } fmi3_boolean_t fmi3_import_get_float32_variable_reinit(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_reinit(v); + return fmi3_xml_get_float32_variable_reinit(v); } fmi3_import_float32_variable_t* fmi3_import_get_float32_variable_derivative_of(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_derivative_of(v); + return fmi3_xml_get_float32_variable_derivative_of(v); } fmi3_import_unit_t* fmi3_import_get_float32_variable_unit(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_unit(v); + return fmi3_xml_get_float32_variable_unit(v); } fmi3_import_display_unit_t* fmi3_import_get_float32_variable_display_unit(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_display_unit(v); + return fmi3_xml_get_float32_variable_display_unit(v); } fmi3_string_t fmi3_import_get_float32_variable_quantity(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_quantity(v); + return fmi3_xml_get_float32_variable_quantity(v); } fmi3_boolean_t fmi3_import_get_float32_variable_unbounded(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_unbounded(v); + return fmi3_xml_get_float32_variable_unbounded(v); } fmi3_boolean_t fmi3_import_get_float32_variable_relative_quantity(fmi3_import_float32_variable_t* v) { - return fmi3_xml_get_float32_variable_relative_quantity(v); + return fmi3_xml_get_float32_variable_relative_quantity(v); } fmi3_import_int64_variable_t* fmi3_import_get_variable_as_int64(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_int64(v); + return fmi3_xml_get_variable_as_int64(v); } fmi3_int64_t fmi3_import_get_int64_variable_min(fmi3_import_int64_variable_t* v) { - return fmi3_xml_get_int64_variable_min(v); + return fmi3_xml_get_int64_variable_min(v); } fmi3_int64_t fmi3_import_get_int64_variable_max(fmi3_import_int64_variable_t* v) { - return fmi3_xml_get_int64_variable_max(v); + return fmi3_xml_get_int64_variable_max(v); } fmi3_int64_t fmi3_import_get_int64_variable_start(fmi3_import_int64_variable_t* v) { - return fmi3_xml_get_int64_variable_start(v); + return fmi3_xml_get_int64_variable_start(v); } fmi3_string_t fmi3_import_get_int64_variable_quantity(fmi3_import_int64_variable_t* v) { - return fmi3_xml_get_int64_variable_quantity(v); + return fmi3_xml_get_int64_variable_quantity(v); } fmi3_import_int32_variable_t* fmi3_import_get_variable_as_int32(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_int32(v); + return fmi3_xml_get_variable_as_int32(v); } fmi3_int32_t fmi3_import_get_int32_variable_min(fmi3_import_int32_variable_t* v) { - return fmi3_xml_get_int32_variable_min(v); + return fmi3_xml_get_int32_variable_min(v); } fmi3_int32_t fmi3_import_get_int32_variable_max(fmi3_import_int32_variable_t* v) { - return fmi3_xml_get_int32_variable_max(v); + return fmi3_xml_get_int32_variable_max(v); } fmi3_int32_t fmi3_import_get_int32_variable_start(fmi3_import_int32_variable_t* v) { - return fmi3_xml_get_int32_variable_start(v); + return fmi3_xml_get_int32_variable_start(v); } fmi3_string_t fmi3_import_get_int32_variable_quantity(fmi3_import_int32_variable_t* v) { - return fmi3_xml_get_int32_variable_quantity(v); + return fmi3_xml_get_int32_variable_quantity(v); } fmi3_import_int16_variable_t* fmi3_import_get_variable_as_int16(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_int16(v); + return fmi3_xml_get_variable_as_int16(v); } fmi3_int16_t fmi3_import_get_int16_variable_min(fmi3_import_int16_variable_t* v) { - return fmi3_xml_get_int16_variable_min(v); + return fmi3_xml_get_int16_variable_min(v); } fmi3_int16_t fmi3_import_get_int16_variable_max(fmi3_import_int16_variable_t* v) { - return fmi3_xml_get_int16_variable_max(v); + return fmi3_xml_get_int16_variable_max(v); } fmi3_int16_t fmi3_import_get_int16_variable_start(fmi3_import_int16_variable_t* v) { - return fmi3_xml_get_int16_variable_start(v); + return fmi3_xml_get_int16_variable_start(v); } fmi3_string_t fmi3_import_get_int16_variable_quantity(fmi3_import_int16_variable_t* v) { - return fmi3_xml_get_int16_variable_quantity(v); + return fmi3_xml_get_int16_variable_quantity(v); } fmi3_import_int8_variable_t* fmi3_import_get_variable_as_int8(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_int8(v); + return fmi3_xml_get_variable_as_int8(v); } fmi3_int8_t fmi3_import_get_int8_variable_min(fmi3_import_int8_variable_t* v) { - return fmi3_xml_get_int8_variable_min(v); + return fmi3_xml_get_int8_variable_min(v); } fmi3_int8_t fmi3_import_get_int8_variable_max(fmi3_import_int8_variable_t* v) { - return fmi3_xml_get_int8_variable_max(v); + return fmi3_xml_get_int8_variable_max(v); } fmi3_int8_t fmi3_import_get_int8_variable_start(fmi3_import_int8_variable_t* v) { - return fmi3_xml_get_int8_variable_start(v); + return fmi3_xml_get_int8_variable_start(v); } fmi3_string_t fmi3_import_get_int8_variable_quantity(fmi3_import_int8_variable_t* v) { - return fmi3_xml_get_int8_variable_quantity(v); + return fmi3_xml_get_int8_variable_quantity(v); } fmi3_import_uint64_variable_t* fmi3_import_get_variable_as_uint64(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_uint64(v); + return fmi3_xml_get_variable_as_uint64(v); } fmi3_uint64_t fmi3_import_get_uint64_variable_min(fmi3_import_uint64_variable_t* v) { - return fmi3_xml_get_uint64_variable_min(v); + return fmi3_xml_get_uint64_variable_min(v); } fmi3_uint64_t fmi3_import_get_uint64_variable_max(fmi3_import_uint64_variable_t* v) { - return fmi3_xml_get_uint64_variable_max(v); + return fmi3_xml_get_uint64_variable_max(v); } fmi3_uint64_t fmi3_import_get_uint64_variable_start(fmi3_import_uint64_variable_t* v) { - return fmi3_xml_get_uint64_variable_start(v); + return fmi3_xml_get_uint64_variable_start(v); } fmi3_string_t fmi3_import_get_uint64_variable_quantity(fmi3_import_uint64_variable_t* v) { - return fmi3_xml_get_uint64_variable_quantity(v); + return fmi3_xml_get_uint64_variable_quantity(v); } fmi3_import_uint32_variable_t* fmi3_import_get_variable_as_uint32(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_uint32(v); + return fmi3_xml_get_variable_as_uint32(v); } fmi3_uint32_t fmi3_import_get_uint32_variable_min(fmi3_import_uint32_variable_t* v) { - return fmi3_xml_get_uint32_variable_min(v); + return fmi3_xml_get_uint32_variable_min(v); } fmi3_uint32_t fmi3_import_get_uint32_variable_max(fmi3_import_uint32_variable_t* v) { - return fmi3_xml_get_uint32_variable_max(v); + return fmi3_xml_get_uint32_variable_max(v); } fmi3_uint32_t fmi3_import_get_uint32_variable_start(fmi3_import_uint32_variable_t* v) { - return fmi3_xml_get_uint32_variable_start(v); + return fmi3_xml_get_uint32_variable_start(v); } fmi3_string_t fmi3_import_get_uint32_variable_quantity(fmi3_import_uint32_variable_t* v) { - return fmi3_xml_get_uint32_variable_quantity(v); + return fmi3_xml_get_uint32_variable_quantity(v); } fmi3_import_uint16_variable_t* fmi3_import_get_variable_as_uint16(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_uint16(v); + return fmi3_xml_get_variable_as_uint16(v); } fmi3_uint16_t fmi3_import_get_uint16_variable_min(fmi3_import_uint16_variable_t* v) { - return fmi3_xml_get_uint16_variable_min(v); + return fmi3_xml_get_uint16_variable_min(v); } fmi3_uint16_t fmi3_import_get_uint16_variable_max(fmi3_import_uint16_variable_t* v) { - return fmi3_xml_get_uint16_variable_max(v); + return fmi3_xml_get_uint16_variable_max(v); } fmi3_uint16_t fmi3_import_get_uint16_variable_start(fmi3_import_uint16_variable_t* v) { - return fmi3_xml_get_uint16_variable_start(v); + return fmi3_xml_get_uint16_variable_start(v); } fmi3_string_t fmi3_import_get_uint16_variable_quantity(fmi3_import_uint16_variable_t* v) { - return fmi3_xml_get_uint16_variable_quantity(v); + return fmi3_xml_get_uint16_variable_quantity(v); } fmi3_import_uint8_variable_t* fmi3_import_get_variable_as_uint8(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_as_uint8(v); + return fmi3_xml_get_variable_as_uint8(v); } fmi3_uint8_t fmi3_import_get_uint8_variable_min(fmi3_import_uint8_variable_t* v) { - return fmi3_xml_get_uint8_variable_min(v); + return fmi3_xml_get_uint8_variable_min(v); } fmi3_uint8_t fmi3_import_get_uint8_variable_max(fmi3_import_uint8_variable_t* v) { - return fmi3_xml_get_uint8_variable_max(v); + return fmi3_xml_get_uint8_variable_max(v); } fmi3_uint8_t fmi3_import_get_uint8_variable_start(fmi3_import_uint8_variable_t* v) { - return fmi3_xml_get_uint8_variable_start(v); + return fmi3_xml_get_uint8_variable_start(v); } fmi3_string_t fmi3_import_get_uint8_variable_quantity(fmi3_import_uint8_variable_t* v) { - return fmi3_xml_get_uint8_variable_quantity(v); + return fmi3_xml_get_uint8_variable_quantity(v); } const char* fmi3_import_get_string_variable_start(fmi3_import_string_variable_t* v) { - return fmi3_xml_get_string_variable_start(v); + return fmi3_xml_get_string_variable_start(v); } fmi3_boolean_t fmi3_import_get_boolean_variable_start(fmi3_import_bool_variable_t* v){ - return fmi3_xml_get_boolean_variable_start(v); + return fmi3_xml_get_boolean_variable_start(v); } fmi3_string_t fmi3_import_get_enum_variable_quantity(fmi3_import_enum_variable_t* v) { @@ -379,23 +379,23 @@ fmi3_string_t fmi3_import_get_enum_variable_quantity(fmi3_import_enum_variable_t } int fmi3_import_get_enum_variable_start(fmi3_import_enum_variable_t* v) { - return fmi3_xml_get_enum_variable_start(v); + return fmi3_xml_get_enum_variable_start(v); } int fmi3_import_get_enum_variable_min(fmi3_import_enum_variable_t* v) { - return fmi3_xml_get_enum_variable_min(v); + return fmi3_xml_get_enum_variable_min(v); } int fmi3_import_get_enum_variable_max(fmi3_import_enum_variable_t* v) { - return fmi3_xml_get_enum_variable_max(v); + return fmi3_xml_get_enum_variable_max(v); } fmi3_variable_alias_kind_enu_t fmi3_import_get_variable_alias_kind(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_alias_kind(v); + return fmi3_xml_get_variable_alias_kind(v); } fmi3_import_variable_t* fmi3_import_get_variable_alias_base(fmi3_import_t* fmu,fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_alias_base(fmu->md, v); + return fmi3_xml_get_variable_alias_base(fmu->md, v); } /* @@ -403,14 +403,14 @@ fmi3_import_variable_t* fmi3_import_get_variable_alias_base(fmi3_import_t* fmu,f The list is ordered: base variable, aliases, negated aliases. */ fmi3_import_variable_list_t* fmi3_import_get_variable_aliases(fmi3_import_t* fmu, fmi3_import_variable_t* v) { - fmi3_import_variable_list_t* list = fmi3_import_alloc_variable_list(fmu, 0); - if(fmi3_xml_get_variable_aliases(fmu->md, v, &list->variables) != jm_status_success) { - fmi3_import_free_variable_list(list); - return 0; - } - return list; + fmi3_import_variable_list_t* list = fmi3_import_alloc_variable_list(fmu, 0); + if(fmi3_xml_get_variable_aliases(fmu->md, v, &list->variables) != jm_status_success) { + fmi3_import_free_variable_list(list); + return 0; + } + return list; } size_t fmi3_import_get_variable_original_order(fmi3_import_variable_t* v) { - return fmi3_xml_get_variable_original_order((fmi3_xml_variable_t*)v); + return fmi3_xml_get_variable_original_order((fmi3_xml_variable_t*)v); } diff --git a/src/Import/src/FMI3/fmi3_import_variable_list.c b/src/Import/src/FMI3/fmi3_import_variable_list.c index 53bc7d04..5587090a 100644 --- a/src/Import/src/FMI3/fmi3_import_variable_list.c +++ b/src/Import/src/FMI3/fmi3_import_variable_list.c @@ -18,11 +18,11 @@ #include "fmi3_import_variable_list_impl.h" fmi3_import_variable_list_t* fmi3_import_alloc_variable_list(fmi3_import_t* fmu, size_t size) { - jm_callbacks* cb = fmu->callbacks; - fmi3_import_variable_list_t* vl = (fmi3_import_variable_list_t*)cb->malloc(sizeof(fmi3_import_variable_list_t)); + jm_callbacks* cb = fmu->callbacks; + fmi3_import_variable_list_t* vl = (fmi3_import_variable_list_t*)cb->malloc(sizeof(fmi3_import_variable_list_t)); if(!vl) return 0; vl->vr = 0; - vl->fmu = fmu; + vl->fmu = fmu; if(jm_vector_init(jm_voidp)(&vl->variables,size,cb) < size) { fmi3_import_free_variable_list(vl); return 0; @@ -32,19 +32,19 @@ fmi3_import_variable_list_t* fmi3_import_alloc_variable_list(fmi3_import_t* fmu, void fmi3_import_free_variable_list(fmi3_import_variable_list_t* vl) { jm_callbacks* cb; - if(!vl) return; - cb = vl->variables.callbacks; - cb->free(vl->vr); + if(!vl) return; + cb = vl->variables.callbacks; + cb->free(vl->vr); jm_vector_free_data(jm_voidp)(&vl->variables); cb->free(vl); } /* Get number of variables in a list */ size_t fmi3_import_get_variable_list_size(fmi3_import_variable_list_t* vl) { - if(vl) - return jm_vector_get_size(jm_voidp)(&vl->variables); - else - return 0; + if(vl) + return jm_vector_get_size(jm_voidp)(&vl->variables); + else + return 0; } /* Make a copy */ @@ -103,25 +103,25 @@ jm_status_enu_t fmi3_import_var_list_push_back(fmi3_import_variable_list_t* list /* Get a pointer to the list of the value references for all the variables */ const fmi3_value_reference_t* fmi3_import_get_value_referece_list(fmi3_import_variable_list_t* vl) { if(!vl->vr) { - jm_callbacks* cb = vl->fmu->callbacks; + jm_callbacks* cb = vl->fmu->callbacks; size_t i, nv = fmi3_import_get_variable_list_size(vl); - vl->vr = (fmi3_value_reference_t*)cb->malloc(nv * sizeof(fmi3_value_reference_t)); + vl->vr = (fmi3_value_reference_t*)cb->malloc(nv * sizeof(fmi3_value_reference_t)); if(vl->vr) { for(i = 0; i < nv; i++) { - vl->vr[i] = fmi3_xml_get_variable_vr(fmi3_import_get_variable(vl, i)); + vl->vr[i] = fmi3_xml_get_variable_vr(fmi3_import_get_variable(vl, i)); } } - else return 0; + else return 0; } return vl->vr; } /* Get a single variable from the list*/ fmi3_import_variable_t* fmi3_import_get_variable(fmi3_import_variable_list_t* vl, size_t index) { - if(index >= fmi3_import_get_variable_list_size(vl)) - return 0; - else - return (fmi3_import_variable_t*)jm_vector_get_item(jm_voidp)(&vl->variables, index); + if(index >= fmi3_import_get_variable_list_size(vl)) + return 0; + else + return (fmi3_import_variable_t*)jm_vector_get_item(jm_voidp)(&vl->variables, index); } /* Operations on variable lists. Every operation creates a new list. */ @@ -145,7 +145,7 @@ fmi3_import_variable_list_t* fmi3_import_get_sublist(fmi3_import_variable_list_t fmi3_import_variable_list_t* fmi3_import_filter_variables(fmi3_import_variable_list_t* vl, fmi3_import_variable_filter_function_ft filter, void* context) { size_t nv, i; fmi3_import_variable_list_t* out = fmi3_import_alloc_variable_list(vl->fmu, 0); - if(!out) return 0; /* out of memory */ + if(!out) return 0; /* out of memory */ nv = fmi3_import_get_variable_list_size(vl); for(i=0; i < nv;i++) { fmi3_import_variable_t* variable = fmi3_import_get_variable(vl, i); diff --git a/src/Import/src/FMI3/fmi3_import_variable_list_impl.h b/src/Import/src/FMI3/fmi3_import_variable_list_impl.h index 308a081e..f518c83f 100644 --- a/src/Import/src/FMI3/fmi3_import_variable_list_impl.h +++ b/src/Import/src/FMI3/fmi3_import_variable_list_impl.h @@ -25,7 +25,7 @@ extern "C" { #endif struct fmi3_import_variable_list_t { - fmi3_import_t* fmu; + fmi3_import_t* fmu; jm_vector(jm_voidp) variables; fmi3_value_reference_t* vr; }; diff --git a/src/Util/include/FMI/fmi_util.h b/src/Util/include/FMI/fmi_util.h index fab87200..a3d27289 100644 --- a/src/Util/include/FMI/fmi_util.h +++ b/src/Util/include/FMI/fmi_util.h @@ -23,25 +23,25 @@ extern "C" { #endif /** - @file fmi_util.h - \brief Some low-level utility functions suitable for all standards. + @file fmi_util.h + \brief Some low-level utility functions suitable for all standards. - */ + */ /** \addtogroup jm_utils * @{ */ /** \brief Given directory name fmu_unzipped_path and construct the directory path for Dll/so - \param fmu_unzipped_path Directory name where FMU is unpacked. - \param callbacks Callbacks for memory allocation. - @return Pointer to a string with the directory name (last symbol is directory separator). Caller is responsible for freeing the memory. + \param fmu_unzipped_path Directory name where FMU is unpacked. + \param callbacks Callbacks for memory allocation. + @return Pointer to a string with the directory name (last symbol is directory separator). Caller is responsible for freeing the memory. */ FMILIB_EXPORT char* fmi_construct_dll_dir_name(jm_callbacks* callbacks, const char* fmu_unzipped_path); /** \brief Given model_identifier construct the dll/so name by adding platform suffix - \param callbacks Callbacks for memory allocation. - \param dll_dir_name Directory path for Dll/so as returned by fmi_construct_dll_dir_name - \param model_identifier The FMU model identifier. - @return Pointer to a string with the file name. Caller is responsible for freeing the memory. + \param callbacks Callbacks for memory allocation. + \param dll_dir_name Directory path for Dll/so as returned by fmi_construct_dll_dir_name + \param model_identifier The FMU model identifier. + @return Pointer to a string with the file name. Caller is responsible for freeing the memory. */ FMILIB_EXPORT char* fmi_construct_dll_file_name(jm_callbacks* callbacks, const char* dll_dir_name, const char* model_identifier); diff --git a/src/Util/include/FMI/fmi_version.h b/src/Util/include/FMI/fmi_version.h index 4bd9964a..4248cc19 100644 --- a/src/Util/include/FMI/fmi_version.h +++ b/src/Util/include/FMI/fmi_version.h @@ -22,10 +22,10 @@ extern "C" { #endif /** - @file fmi_version.h - \brief Enum defining supported FMI versions. + @file fmi_version.h + \brief Enum defining supported FMI versions. - */ + */ /** \addtogroup jm_utils * @{ */ @@ -33,11 +33,11 @@ extern "C" { /** \brief Suported versions of FMI standard */ typedef enum { - fmi_version_unknown_enu = 0, - fmi_version_1_enu, - fmi_version_2_0_enu, - fmi_version_3_0_enu, - fmi_version_unsupported_enu + fmi_version_unknown_enu = 0, + fmi_version_1_enu, + fmi_version_2_0_enu, + fmi_version_3_0_enu, + fmi_version_unsupported_enu } fmi_version_enu_t; /** Convert version enum into string */ diff --git a/src/Util/include/FMI1/fmi1_enums.h b/src/Util/include/FMI1/fmi1_enums.h index 7213d3d9..edee6826 100644 --- a/src/Util/include/FMI1/fmi1_enums.h +++ b/src/Util/include/FMI1/fmi1_enums.h @@ -24,16 +24,16 @@ extern "C" { #endif /** \file fmi1_enums.h - \brief Definions the enum types used with FMI 1.0 libs + \brief Definions the enum types used with FMI 1.0 libs */ -/** \addtogroup fmi1_utils - @{ - \addtogroup fmi1_enums - @} +/** \addtogroup fmi1_utils + @{ + \addtogroup fmi1_enums + @} */ /** \addtogroup fmi1_enums Enum types used with FMI 1.0 libs - @{ + @{ */ /** \brief Naming convention for the variables in XML file*/ typedef enum fmi1_variable_naming_convension_enu_t @@ -52,7 +52,7 @@ typedef enum fmi1_fmu_kind_enu_t fmi1_fmu_kind_enu_me = 0, fmi1_fmu_kind_enu_cs_standalone, fmi1_fmu_kind_enu_cs_tool, - fmi1_fmu_kind_enu_unknown + fmi1_fmu_kind_enu_unknown } fmi1_fmu_kind_enu_t; /** \brief Convert a #fmi1_fmu_kind_enu_t constant into string */ @@ -64,7 +64,7 @@ typedef enum fmi1_variability_enu_t { fmi1_variability_enu_parameter, fmi1_variability_enu_discrete, fmi1_variability_enu_continuous, - fmi1_variability_enu_unknown + fmi1_variability_enu_unknown } fmi1_variability_enu_t; /** \brief Convert a #fmi1_variability_enu_t constant into string */ @@ -95,20 +95,20 @@ typedef enum fmi1_variable_alias_kind_enu_t { /** \brief Base types used in type definitions */ typedef enum fmi1_base_type_enu_t { - fmi1_base_type_real, - fmi1_base_type_int, - fmi1_base_type_bool, - fmi1_base_type_str, - fmi1_base_type_enum + fmi1_base_type_real, + fmi1_base_type_int, + fmi1_base_type_bool, + fmi1_base_type_str, + fmi1_base_type_enum } fmi1_base_type_enu_t; /** \brief Convert base type constant to string - \param bt Base type identifier. - \return Corresponding base type name. - */ + \param bt Base type identifier. + \return Corresponding base type name. + */ FMILIB_EXPORT const char* fmi1_base_type_to_string(fmi1_base_type_enu_t bt); -/** +/** @} */ #ifdef __cplusplus diff --git a/src/Util/include/FMI1/fmi1_functions.h b/src/Util/include/FMI1/fmi1_functions.h index fc4a7c54..1250084c 100644 --- a/src/Util/include/FMI1/fmi1_functions.h +++ b/src/Util/include/FMI1/fmi1_functions.h @@ -20,21 +20,21 @@ #include "fmi1_types.h" #include -/** \file fmi1_functions.h - Mapping for the standard FMI 1.0 functions into fmi1_ namespace. +/** \file fmi1_functions.h + Mapping for the standard FMI 1.0 functions into fmi1_ namespace. - \addtogroup fmi1_utils - @{ + \addtogroup fmi1_utils + @{ */ /** FMI 1.0 status codes */ typedef enum { - fmi1_status_ok, - fmi1_status_warning, - fmi1_status_discard, - fmi1_status_error, - fmi1_status_fatal, - fmi1_status_pending + fmi1_status_ok, + fmi1_status_warning, + fmi1_status_discard, + fmi1_status_error, + fmi1_status_fatal, + fmi1_status_pending } fmi1_status_t; /** FMI 1.0 logger function type */ @@ -48,84 +48,84 @@ typedef void (*fmi1_step_finished_ft) (fmi1_component_t c, fmi1_status /** Functions for FMI 1.0 ME */ typedef struct { - fmi1_callback_logger_ft logger; - fmi1_callback_allocate_memory_ft allocateMemory; - fmi1_callback_free_memory_ft freeMemory; + fmi1_callback_logger_ft logger; + fmi1_callback_allocate_memory_ft allocateMemory; + fmi1_callback_free_memory_ft freeMemory; } fmi1_me_callback_functions_t; /** The FMI 1.0 CS strcuture adds one field to the ME, otherwize compatible */ typedef struct { - fmi1_callback_logger_ft logger; - fmi1_callback_allocate_memory_ft allocateMemory; - fmi1_callback_free_memory_ft freeMemory; - fmi1_step_finished_ft stepFinished; + fmi1_callback_logger_ft logger; + fmi1_callback_allocate_memory_ft allocateMemory; + fmi1_callback_free_memory_ft freeMemory; + fmi1_step_finished_ft stepFinished; } fmi1_callback_functions_t; /** Event info structure as used in FMI 1.0 ME */ typedef struct { - fmi1_boolean_t iterationConverged; - fmi1_boolean_t stateValueReferencesChanged; - fmi1_boolean_t stateValuesChanged; - fmi1_boolean_t terminateSimulation; - fmi1_boolean_t upcomingTimeEvent; - fmi1_real_t nextEventTime; + fmi1_boolean_t iterationConverged; + fmi1_boolean_t stateValueReferencesChanged; + fmi1_boolean_t stateValuesChanged; + fmi1_boolean_t terminateSimulation; + fmi1_boolean_t upcomingTimeEvent; + fmi1_real_t nextEventTime; } fmi1_event_info_t; /** FMI 1.0 asyncronous co-simulation status */ typedef enum { - fmi1_do_step_status, - fmi1_pending_status, - fmi1_last_successful_time + fmi1_do_step_status, + fmi1_pending_status, + fmi1_last_successful_time } fmi1_status_kind_t; /* FMI 1.0 common functions */ -typedef const char* (*fmi1_get_version_ft) (void); -typedef fmi1_status_t (*fmi1_set_debug_logging_ft) (fmi1_component_t c, fmi1_boolean_t loggingOn); -typedef fmi1_status_t (*fmi1_set_real_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_real_t value[]); -typedef fmi1_status_t (*fmi1_set_integer_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t value[]); -typedef fmi1_status_t (*fmi1_set_boolean_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_boolean_t value[]); -typedef fmi1_status_t (*fmi1_set_string_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_string_t value[]); -typedef fmi1_status_t (*fmi1_get_real_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_real_t value[]); -typedef fmi1_status_t (*fmi1_get_integer_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_integer_t value[]); -typedef fmi1_status_t (*fmi1_get_boolean_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_boolean_t value[]); -typedef fmi1_status_t (*fmi1_get_string_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_string_t value[]); +typedef const char* (*fmi1_get_version_ft) (void); +typedef fmi1_status_t (*fmi1_set_debug_logging_ft) (fmi1_component_t c, fmi1_boolean_t loggingOn); +typedef fmi1_status_t (*fmi1_set_real_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_real_t value[]); +typedef fmi1_status_t (*fmi1_set_integer_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t value[]); +typedef fmi1_status_t (*fmi1_set_boolean_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_boolean_t value[]); +typedef fmi1_status_t (*fmi1_set_string_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_string_t value[]); +typedef fmi1_status_t (*fmi1_get_real_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_real_t value[]); +typedef fmi1_status_t (*fmi1_get_integer_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_integer_t value[]); +typedef fmi1_status_t (*fmi1_get_boolean_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_boolean_t value[]); +typedef fmi1_status_t (*fmi1_get_string_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, fmi1_string_t value[]); /* FMI ME 1.0 functions */ -typedef const char* (*fmi1_get_model_typesPlatform_ft) (void); -typedef fmi1_component_t (*fmi1_instantiate_model_ft) (fmi1_string_t instanceName, fmi1_string_t GUID, fmi1_me_callback_functions_t functions, fmi1_boolean_t loggingOn); -typedef void (*fmi1_free_model_instance_ft) (fmi1_component_t c); -typedef fmi1_status_t (*fmi1_set_time_ft) (fmi1_component_t c, fmi1_real_t time); -typedef fmi1_status_t (*fmi1_set_continuous_states_ft) (fmi1_component_t c, const fmi1_real_t x[], size_t nx); -typedef fmi1_status_t (*fmi1_completed_integrator_step_ft) (fmi1_component_t c, fmi1_boolean_t* callEventUpdate); -typedef fmi1_status_t (*fmi1_initialize_ft) (fmi1_component_t c, fmi1_boolean_t toleranceControlled, fmi1_real_t relativeTolerance, fmi1_event_info_t* eventInfo); -typedef fmi1_status_t (*fmi1_get_derivatives_ft) (fmi1_component_t c, fmi1_real_t derivatives[] , size_t nx); -typedef fmi1_status_t (*fmi1_get_event_indicators_ft) (fmi1_component_t c, fmi1_real_t eventIndicators[], size_t ni); -typedef fmi1_status_t (*fmi1_event_update_ft) (fmi1_component_t c, fmi1_boolean_t intermediateResults, fmi1_event_info_t* eventInfo); -typedef fmi1_status_t (*fmi1_get_continuous_states_ft) (fmi1_component_t c, fmi1_real_t states[], size_t nx); -typedef fmi1_status_t (*fmi1_get_nominal_continuousStates_ft) (fmi1_component_t c, fmi1_real_t x_nominal[], size_t nx); -typedef fmi1_status_t (*fmi1_get_state_valueReferences_ft) (fmi1_component_t c, fmi1_value_reference_t vrx[], size_t nx); -typedef fmi1_status_t (*fmi1_terminate_ft) (fmi1_component_t c); +typedef const char* (*fmi1_get_model_typesPlatform_ft) (void); +typedef fmi1_component_t (*fmi1_instantiate_model_ft) (fmi1_string_t instanceName, fmi1_string_t GUID, fmi1_me_callback_functions_t functions, fmi1_boolean_t loggingOn); +typedef void (*fmi1_free_model_instance_ft) (fmi1_component_t c); +typedef fmi1_status_t (*fmi1_set_time_ft) (fmi1_component_t c, fmi1_real_t time); +typedef fmi1_status_t (*fmi1_set_continuous_states_ft) (fmi1_component_t c, const fmi1_real_t x[], size_t nx); +typedef fmi1_status_t (*fmi1_completed_integrator_step_ft) (fmi1_component_t c, fmi1_boolean_t* callEventUpdate); +typedef fmi1_status_t (*fmi1_initialize_ft) (fmi1_component_t c, fmi1_boolean_t toleranceControlled, fmi1_real_t relativeTolerance, fmi1_event_info_t* eventInfo); +typedef fmi1_status_t (*fmi1_get_derivatives_ft) (fmi1_component_t c, fmi1_real_t derivatives[] , size_t nx); +typedef fmi1_status_t (*fmi1_get_event_indicators_ft) (fmi1_component_t c, fmi1_real_t eventIndicators[], size_t ni); +typedef fmi1_status_t (*fmi1_event_update_ft) (fmi1_component_t c, fmi1_boolean_t intermediateResults, fmi1_event_info_t* eventInfo); +typedef fmi1_status_t (*fmi1_get_continuous_states_ft) (fmi1_component_t c, fmi1_real_t states[], size_t nx); +typedef fmi1_status_t (*fmi1_get_nominal_continuousStates_ft) (fmi1_component_t c, fmi1_real_t x_nominal[], size_t nx); +typedef fmi1_status_t (*fmi1_get_state_valueReferences_ft) (fmi1_component_t c, fmi1_value_reference_t vrx[], size_t nx); +typedef fmi1_status_t (*fmi1_terminate_ft) (fmi1_component_t c); /* FMI CS 1.0 functions */ -typedef const char* (*fmi1_get_types_platform_ft) (void ); -typedef fmi1_component_t (*fmi1_instantiate_slave_ft) (fmi1_string_t instanceName, fmi1_string_t fmuGUID, fmi1_string_t fmuLocation, - fmi1_string_t mimeType, fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive, - fmi1_callback_functions_t functions, fmi1_boolean_t loggingOn); -typedef fmi1_status_t (*fmi1_initialize_slave_ft) (fmi1_component_t c, fmi1_real_t tStart, fmi1_boolean_t StopTimeDefined, fmi1_real_t tStop); -typedef fmi1_status_t (*fmi1_terminate_slave_ft) (fmi1_component_t c); -typedef fmi1_status_t (*fmi1_reset_slave_ft) (fmi1_component_t c); -typedef void (*fmi1_free_slave_instance_ft) (fmi1_component_t c); -typedef fmi1_status_t (*fmi1_set_real_inputDerivatives_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], const fmi1_real_t value[]); -typedef fmi1_status_t (*fmi1_get_real_outputDerivatives_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], fmi1_real_t value[]); -typedef fmi1_status_t (*fmi1_cancel_step_ft) (fmi1_component_t c); -typedef fmi1_status_t (*fmi1_do_step_ft) (fmi1_component_t c, fmi1_real_t currentCommunicationPoint, fmi1_real_t communicationStepSize, fmi1_boolean_t newStep); - -typedef fmi1_status_t (*fmi1_get_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_status_t* value); -typedef fmi1_status_t (*fmi1_get_real_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_real_t* value); -typedef fmi1_status_t (*fmi1_get_integer_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_integer_t* value); -typedef fmi1_status_t (*fmi1_get_boolean_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_boolean_t* value); -typedef fmi1_status_t (*fmi1_get_string_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_string_t* value); +typedef const char* (*fmi1_get_types_platform_ft) (void ); +typedef fmi1_component_t (*fmi1_instantiate_slave_ft) (fmi1_string_t instanceName, fmi1_string_t fmuGUID, fmi1_string_t fmuLocation, + fmi1_string_t mimeType, fmi1_real_t timeout, fmi1_boolean_t visible, fmi1_boolean_t interactive, + fmi1_callback_functions_t functions, fmi1_boolean_t loggingOn); +typedef fmi1_status_t (*fmi1_initialize_slave_ft) (fmi1_component_t c, fmi1_real_t tStart, fmi1_boolean_t StopTimeDefined, fmi1_real_t tStop); +typedef fmi1_status_t (*fmi1_terminate_slave_ft) (fmi1_component_t c); +typedef fmi1_status_t (*fmi1_reset_slave_ft) (fmi1_component_t c); +typedef void (*fmi1_free_slave_instance_ft) (fmi1_component_t c); +typedef fmi1_status_t (*fmi1_set_real_inputDerivatives_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], const fmi1_real_t value[]); +typedef fmi1_status_t (*fmi1_get_real_outputDerivatives_ft) (fmi1_component_t c, const fmi1_value_reference_t vr[], size_t nvr, const fmi1_integer_t order[], fmi1_real_t value[]); +typedef fmi1_status_t (*fmi1_cancel_step_ft) (fmi1_component_t c); +typedef fmi1_status_t (*fmi1_do_step_ft) (fmi1_component_t c, fmi1_real_t currentCommunicationPoint, fmi1_real_t communicationStepSize, fmi1_boolean_t newStep); + +typedef fmi1_status_t (*fmi1_get_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_status_t* value); +typedef fmi1_status_t (*fmi1_get_real_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_real_t* value); +typedef fmi1_status_t (*fmi1_get_integer_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_integer_t* value); +typedef fmi1_status_t (*fmi1_get_boolean_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_boolean_t* value); +typedef fmi1_status_t (*fmi1_get_string_status_ft) (fmi1_component_t c, const fmi1_status_kind_t s, fmi1_string_t* value); /** @} */ diff --git a/src/Util/include/FMI1/fmi1_types.h b/src/Util/include/FMI1/fmi1_types.h index d557dae5..5cf6513e 100644 --- a/src/Util/include/FMI1/fmi1_types.h +++ b/src/Util/include/FMI1/fmi1_types.h @@ -16,17 +16,17 @@ #ifndef FMI1_TYPES_H_ #define FMI1_TYPES_H_ /** \file fmi1_types.h - Transformation of the standard FMI type names into fmi1_ prefixed. + Transformation of the standard FMI type names into fmi1_ prefixed. */ /** - \addtogroup jm_utils - @{ - \addtogroup fmi1_utils - @} + \addtogroup jm_utils + @{ + \addtogroup fmi1_utils + @} */ -/** \addtogroup fmi1_utils Functions and types supporting FMI 1.0 processing. - @{ +/** \addtogroup fmi1_utils Functions and types supporting FMI 1.0 processing. + @{ */ /** \name Renaming of typedefs @{*/ @@ -46,15 +46,15 @@ /** FMI platform name constant string.*/ static const char * fmi1_get_platform(void) { - return fmiPlatform; + return fmiPlatform; } #undef fmiPlatform /** FMI boolean constants.*/ typedef enum { - fmi1_true=fmiTrue, - fmi1_false=fmiFalse + fmi1_true=fmiTrue, + fmi1_false=fmiFalse } fmi1_boolean_enu_t; #undef fmiTrue @@ -62,11 +62,11 @@ typedef enum { /** Undefined value for fmiValueReference (largest unsigned int value) */ typedef enum fmi1_value_reference_enu_t { - fmi1_undefined_value_reference = (int)fmiUndefinedValueReference + fmi1_undefined_value_reference = (int)fmiUndefinedValueReference } fmi1_value_reference_enu_t; -/** - @} +/** + @} */ #undef fmiComponent diff --git a/src/Util/include/FMI2/fmi2_function_types.h b/src/Util/include/FMI2/fmi2_function_types.h index 65efc200..6be23c55 100644 --- a/src/Util/include/FMI2/fmi2_function_types.h +++ b/src/Util/include/FMI2/fmi2_function_types.h @@ -20,11 +20,11 @@ #include #include "fmi2_types.h" -/** \file fmi2_function_types.h - Mapping for the standard FMI 2.0 functions into fmi2_ namespace. +/** \file fmi2_function_types.h + Mapping for the standard FMI 2.0 functions into fmi2_ namespace. - \addtogroup fmi2_utils - @{ + \addtogroup fmi2_utils + @{ */ #ifdef __cplusplus @@ -38,12 +38,12 @@ extern "C" { /** FMI 2.0 status codes */ typedef enum { - fmi2_status_ok, - fmi2_status_warning, - fmi2_status_discard, - fmi2_status_error, - fmi2_status_fatal, - fmi2_status_pending + fmi2_status_ok, + fmi2_status_warning, + fmi2_status_discard, + fmi2_status_error, + fmi2_status_fatal, + fmi2_status_pending } fmi2_status_t; typedef enum { @@ -65,11 +65,11 @@ typedef void (*fmi2_step_finished_ft) (fmi2_component_environment_t en /** The FMI 2.0 callbacks */ typedef struct { - fmi2_callback_logger_ft logger; - fmi2_callback_allocate_memory_ft allocateMemory; - fmi2_callback_free_memory_ft freeMemory; - fmi2_step_finished_ft stepFinished; - fmi2_component_environment_t componentEnvironment; + fmi2_callback_logger_ft logger; + fmi2_callback_allocate_memory_ft allocateMemory; + fmi2_callback_free_memory_ft freeMemory; + fmi2_step_finished_ft stepFinished; + fmi2_component_environment_t componentEnvironment; } fmi2_callback_functions_t; /** Event info structure as used in FMI 2.0 ME */ @@ -184,7 +184,7 @@ Types for_functions for FMI for Co-_simulation typedef fmi2_status_t (*fmi2_get_boolean_status_ft)(fmi2_component_t, const fmi2_status_kind_t, fmi2_boolean_t*); typedef fmi2_status_t (*fmi2_get_string_status_ft) (fmi2_component_t, const fmi2_status_kind_t, fmi2_string_t* ); -/** @} +/** @} */ #ifdef __cplusplus diff --git a/src/Util/include/FMI2/fmi2_types.h b/src/Util/include/FMI2/fmi2_types.h index 5fa11fe7..be91387e 100644 --- a/src/Util/include/FMI2/fmi2_types.h +++ b/src/Util/include/FMI2/fmi2_types.h @@ -16,17 +16,17 @@ #ifndef FMI2_TYPES_H_ #define FMI2_TYPES_H_ /** \file fmi2_types.h - Transformation of the standard FMI type names into fmi2_ prefixed. + Transformation of the standard FMI type names into fmi2_ prefixed. */ /** - \addtogroup jm_utils - @{ - \addtogroup fmi2_utils - @} + \addtogroup jm_utils + @{ + \addtogroup fmi2_utils + @} */ -/** \addtogroup fmi2_utils Functions and types supporting FMI 2.0 processing. - @{ +/** \addtogroup fmi2_utils Functions and types supporting FMI 2.0 processing. + @{ */ /** \name Renaming of typedefs @{*/ @@ -51,22 +51,22 @@ /** FMI platform name constant string.*/ static const char * fmi2_get_types_platform(void) { - return fmi2TypesPlatform; + return fmi2TypesPlatform; } #undef fmi2TypesPlatform /** FMI boolean constants.*/ typedef enum { - fmi2_true=fmi2True, - fmi2_false=fmi2False + fmi2_true=fmi2True, + fmi2_false=fmi2False } fmi2_boolean_enu_t; #undef fmi2True #undef fmi2False -/** - @} +/** + @} */ #undef fmi2Component diff --git a/src/Util/include/FMI2/fmi2_xml_callbacks.h b/src/Util/include/FMI2/fmi2_xml_callbacks.h index 6ec5f0ad..86e73d5c 100644 --- a/src/Util/include/FMI2/fmi2_xml_callbacks.h +++ b/src/Util/include/FMI2/fmi2_xml_callbacks.h @@ -22,11 +22,11 @@ extern "C" { #endif /** \file fmi2_xml_callbacks.h Definition of ::fmi2_xml_callbacks_t and supporting functions - * - * \addtogroup fmi2_utils - * @{ - \addtogroup fmi2_xml_callbacks - * @} + * + * \addtogroup fmi2_utils + * @{ + \addtogroup fmi2_xml_callbacks + * @} */ /** \addtogroup fmi2_xml_callbacks Definition of XML callbacks struct * @{ */ @@ -37,14 +37,14 @@ typedef struct fmi2_xml_callbacks_t fmi2_xml_callbacks_t; */ /** \brief Handle start of an XML element within tool annotation in a SAX parser. * -* @param context as specified when setting up the callbacks, +* @param context as specified when setting up the callbacks, * @param parentName - tool name as given by name attibute to the Tool elelent, * @param parent - NULL for model level annotations; fmi2_import_variable_t * variable pointer for variable annotations. * @param elm - name of the element, * @param attr - attributes (names and values). * The function should return 0 on success or error code on exit (in which case parsing will be aborted). */ -typedef int (*fmi2_xml_element_start_handle_ft)( void *context, const char *toolName, void *parent, const char *elm, const char **attr); +typedef int (*fmi2_xml_element_start_handle_ft)( void *context, const char *toolName, void *parent, const char *elm, const char **attr); /** \brief Handle data of an XML element within tool annotation in a SAX parser. * @@ -65,10 +65,10 @@ typedef int (*fmi2_xml_element_end_handle_ft)(void *context, const char *elm); /** \brief XML callbacks are used to process parts of XML that are not handled by the library */ struct fmi2_xml_callbacks_t { - fmi2_xml_element_start_handle_ft startHandle; /** \brief Handle start of an XML element within tool annotation in a SAX parser. */ - fmi2_xml_element_data_handle_ft dataHandle; /** \brief Handle data of an XML element within tool annotation in a SAX parser. */ - fmi2_xml_element_end_handle_ft endHandle; /** \brief Handle end of an XML element within tool annotation in a SAX parser. */ - void* context; /** \breif Context ponter is forwarded to the handle functions. */ + fmi2_xml_element_start_handle_ft startHandle; /** \brief Handle start of an XML element within tool annotation in a SAX parser. */ + fmi2_xml_element_data_handle_ft dataHandle; /** \brief Handle data of an XML element within tool annotation in a SAX parser. */ + fmi2_xml_element_end_handle_ft endHandle; /** \brief Handle end of an XML element within tool annotation in a SAX parser. */ + void* context; /** \breif Context ponter is forwarded to the handle functions. */ }; /* @} */ diff --git a/src/Util/include/FMI3/fmi3_types.h b/src/Util/include/FMI3/fmi3_types.h index 041cf5ae..48c5d17a 100644 --- a/src/Util/include/FMI3/fmi3_types.h +++ b/src/Util/include/FMI3/fmi3_types.h @@ -16,17 +16,17 @@ #ifndef FMI3_TYPES_H_ #define FMI3_TYPES_H_ /** \file fmi3_types.h - Transformation of the standard FMI type names into fmi3_ prefixed. + Transformation of the standard FMI type names into fmi3_ prefixed. */ /** - \addtogroup jm_utils - @{ - \addtogroup fmi3_utils - @} + \addtogroup jm_utils + @{ + \addtogroup fmi3_utils + @} */ -/** \addtogroup fmi3_utils Functions and types supporting FMI 3.0 processing. - @{ +/** \addtogroup fmi3_utils Functions and types supporting FMI 3.0 processing. + @{ */ /** \name Renaming of typedefs @{*/ @@ -61,8 +61,8 @@ /** FMI boolean constants.*/ typedef enum { - fmi3_true = fmi3True, - fmi3_false = fmi3False + fmi3_true = fmi3True, + fmi3_false = fmi3False } fmi3_boolean_enu_t; #undef fmi3True @@ -70,15 +70,15 @@ typedef enum { /** FMI clock constants. */ typedef enum { - fmi3_clock_active = fmi3ClockActive, - fmi3_clock_inactive = fmi3ClockInactive + fmi3_clock_active = fmi3ClockActive, + fmi3_clock_inactive = fmi3ClockInactive } fmi3_clock_enu_t; #undef fmi3ClockActive #undef fmi3ClockInActive -/** - @} +/** + @} */ #undef fmi3Instance diff --git a/src/Util/include/FMI3/fmi3_xml_callbacks.h b/src/Util/include/FMI3/fmi3_xml_callbacks.h index 9787241d..43205789 100644 --- a/src/Util/include/FMI3/fmi3_xml_callbacks.h +++ b/src/Util/include/FMI3/fmi3_xml_callbacks.h @@ -22,11 +22,11 @@ extern "C" { #endif /** \file fmi3_xml_callbacks.h Definition of ::fmi3_xml_callbacks_t and supporting functions - * - * \addtogroup fmi3_utils - * @{ - \addtogroup fmi3_xml_callbacks - * @} + * + * \addtogroup fmi3_utils + * @{ + \addtogroup fmi3_xml_callbacks + * @} */ /** \addtogroup fmi3_xml_callbacks Definition of XML callbacks struct * @{ */ @@ -37,14 +37,14 @@ typedef struct fmi3_xml_callbacks_t fmi3_xml_callbacks_t; */ /** \brief Handle start of an XML element within tool annotation in a SAX parser. * -* @param context as specified when setting up the callbacks, +* @param context as specified when setting up the callbacks, * @param parentName - tool name as given by name attibute to the Tool elelent, * @param parent - NULL for model level annotations; fmi3_import_variable_t * variable pointer for variable annotations. * @param elm - name of the element, * @param attr - attributes (names and values). * The function should return 0 on success or error code on exit (in which case parsing will be aborted). */ -typedef int (*fmi3_xml_element_start_handle_ft)( void *context, const char *toolName, void *parent, const char *elm, const char **attr); +typedef int (*fmi3_xml_element_start_handle_ft)( void *context, const char *toolName, void *parent, const char *elm, const char **attr); /** \brief Handle data of an XML element within tool annotation in a SAX parser. * @@ -65,10 +65,10 @@ typedef int (*fmi3_xml_element_end_handle_ft)(void *context, const char *elm); /** \brief XML callbacks are used to process parts of XML that are not handled by the library */ struct fmi3_xml_callbacks_t { - fmi3_xml_element_start_handle_ft startHandle; /** \brief Handle start of an XML element within tool annotation in a SAX parser. */ - fmi3_xml_element_data_handle_ft dataHandle; /** \brief Handle data of an XML element within tool annotation in a SAX parser. */ - fmi3_xml_element_end_handle_ft endHandle; /** \brief Handle end of an XML element within tool annotation in a SAX parser. */ - void* context; /** \breif Context ponter is forwarded to the handle functions. */ + fmi3_xml_element_start_handle_ft startHandle; /** \brief Handle start of an XML element within tool annotation in a SAX parser. */ + fmi3_xml_element_data_handle_ft dataHandle; /** \brief Handle data of an XML element within tool annotation in a SAX parser. */ + fmi3_xml_element_end_handle_ft endHandle; /** \brief Handle end of an XML element within tool annotation in a SAX parser. */ + void* context; /** \breif Context ponter is forwarded to the handle functions. */ }; /* @} */ diff --git a/src/Util/include/JM/jm_callbacks.h b/src/Util/include/JM/jm_callbacks.h index c6e84929..0e64962a 100644 --- a/src/Util/include/JM/jm_callbacks.h +++ b/src/Util/include/JM/jm_callbacks.h @@ -26,11 +26,11 @@ extern "C" { #endif /** \file jm_callbacks.h Definition of ::jm_callbacks and supporting functions - * - * \addtogroup jm_utils - * @{ - \addtogroup jm_callbacks - * @} + * + * \addtogroup jm_utils + * @{ + \addtogroup jm_callbacks + * @} */ /** \addtogroup jm_callbacks Definition of callbacks struct and supporting functions * @{ */ @@ -72,22 +72,22 @@ typedef void (*jm_logger_f)(jm_callbacks* c, jm_string module, jm_log_level_enu_ /** \brief The callbacks struct is sent to all the modules in the library */ struct jm_callbacks { - /** \brief Allocate non-initialized memory */ - jm_malloc_f malloc; - /** \brief Allocate zero initialized memory */ - jm_calloc_f calloc; - /** \brief Re-allocate memory */ - jm_realloc_f realloc; - /** \brief Free-allocated memory */ - jm_free_f free; - /** \brief Logging callback */ - jm_logger_f logger; - /** \brief Logging level */ - jm_log_level_enu_t log_level; - /** \brief Arbitrary context pointer passed to the logger function */ - jm_voidp context; - /** \brief The buffer used along with jm_get_last_error() */ - char errMessageBuffer[JM_MAX_ERROR_MESSAGE_SIZE]; + /** \brief Allocate non-initialized memory */ + jm_malloc_f malloc; + /** \brief Allocate zero initialized memory */ + jm_calloc_f calloc; + /** \brief Re-allocate memory */ + jm_realloc_f realloc; + /** \brief Free-allocated memory */ + jm_free_f free; + /** \brief Logging callback */ + jm_logger_f logger; + /** \brief Logging level */ + jm_log_level_enu_t log_level; + /** \brief Arbitrary context pointer passed to the logger function */ + jm_voidp context; + /** \brief The buffer used along with jm_get_last_error() */ + char errMessageBuffer[JM_MAX_ERROR_MESSAGE_SIZE]; }; /** @@ -107,7 +107,7 @@ static void jm_clear_last_error(jm_callbacks* cb) { cb->errMessageBuffer[0] = 0; \brief Set the structure to be returned by jm_get_default_callbacks(). @param c - a pointer to initialized struct to be used as default later on. If this is NULL - library default implementation will be used. + library default implementation will be used. */ FMILIB_EXPORT void jm_set_default_callbacks(jm_callbacks* c); @@ -127,16 +127,16 @@ void jm_default_logger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log /** \brief Send a message to the logger function. - @param cb - callbacks to be used for reporting; - @param module - a name of reporting module; - @param log_level - message kind; - @param fmt - "printf" type of format followed by the arguments. + @param cb - callbacks to be used for reporting; + @param module - a name of reporting module; + @param log_level - message kind; + @param fmt - "printf" type of format followed by the arguments. */ FMILIB_EXPORT void jm_log(jm_callbacks* cb, const char* module, jm_log_level_enu_t log_level, const char* fmt, ...); /** \copydoc jm_log() - @param ap - variable size argument list. + @param ap - variable size argument list. */ FMILIB_EXPORT void jm_log_v(jm_callbacks* cb, const char* module, jm_log_level_enu_t log_level, const char* fmt, va_list ap); @@ -191,25 +191,25 @@ void jm_log_verbose(jm_callbacks* cb, const char* module, const char* fmt, ...); #ifdef FMILIB_ENABLE_LOG_LEVEL_DEBUG /** \brief Send a debug message to the logger function. See jm_log() for details. - Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON + Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON */ FMILIB_EXPORT void jm_log_debug_v(jm_callbacks* cb, const char* module, const char* fmt, va_list ap); /** \brief Send a debug message to the logger function. See jm_log() for details. - Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON + Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON */ FMILIB_EXPORT void jm_log_debug(jm_callbacks* cb, const char* module, const char* fmt, ...); #else /** \brief Send a debug message to the logger function. See jm_log() for details. - Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON + Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON */ static void jm_log_debug_v(jm_callbacks* cb, const char* module, const char* fmt, va_list ap) {} /** \brief Send a debug message to the logger function. See jm_log() for details. - Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON + Note that the function is only active if the library is configure with FMILIB_ENABLE_LOG_LEVEL_DEBUG=ON */ static void jm_log_debug(jm_callbacks* cb, const char* module, const char* fmt, ...) {} #endif diff --git a/src/Util/include/JM/jm_named_ptr.h b/src/Util/include/JM/jm_named_ptr.h index 150e538c..fcf97d24 100644 --- a/src/Util/include/JM/jm_named_ptr.h +++ b/src/Util/include/JM/jm_named_ptr.h @@ -23,11 +23,11 @@ extern "C" { #endif /** \file jm_named_ptr.h Definition of ::jm_named_ptr and supporting functions - * - * \addtogroup jm_utils - * @{ - \addtogroup jm_named_ptr - * @} + * + * \addtogroup jm_utils + * @{ + \addtogroup jm_named_ptr + * @} */ /** \addtogroup jm_named_ptr Named objects @{ diff --git a/src/Util/include/JM/jm_portability.h b/src/Util/include/JM/jm_portability.h index 58342d7b..271612ba 100644 --- a/src/Util/include/JM/jm_portability.h +++ b/src/Util/include/JM/jm_portability.h @@ -29,13 +29,13 @@ #include "jm_types.h" /** \file jm_portability.h - Handling platform specific defines and functions. + Handling platform specific defines and functions. */ /** - \addtogroup jm_utils - @{ - \addtogroup jm_portability - @} + \addtogroup jm_utils + @{ + \addtogroup jm_portability + @} */ /** \addtogroup jm_portability Handling platform specific defines and functions @{*/ @@ -63,10 +63,10 @@ jm_portability_loadlibrary_flag_t jm_portability_get_load_dll_handle_default_fla DLL_HANDLE jm_portability_load_dll_handle_with_flag(const char* dll_file_path, jm_portability_loadlibrary_flag_t flag); /** \brief Load a dll/so library into the process and return a handle. */ -DLL_HANDLE jm_portability_load_dll_handle (const char* dll_file_path); +DLL_HANDLE jm_portability_load_dll_handle (const char* dll_file_path); /** \brief Unload a Dll and release the handle*/ -jm_status_enu_t jm_portability_free_dll_handle (DLL_HANDLE dll_handle); +jm_status_enu_t jm_portability_free_dll_handle (DLL_HANDLE dll_handle); /** \brief A function pointer as returned when DLL symbol is loaded.*/ #ifdef WIN32 @@ -76,10 +76,10 @@ typedef void* jm_dll_function_ptr; #endif /** \brief Find a function in the Dll and return a function pointer */ -jm_status_enu_t jm_portability_load_dll_function (DLL_HANDLE dll_handle, char* dll_function_name, jm_dll_function_ptr* dll_function_ptrptr); +jm_status_enu_t jm_portability_load_dll_function (DLL_HANDLE dll_handle, char* dll_function_name, jm_dll_function_ptr* dll_function_ptrptr); /** \brief Return error associated with Dll handling */ -char* jm_portability_get_last_dll_error (void); +char* jm_portability_get_last_dll_error (void); /** \brief Get current working directory name */ jm_status_enu_t jm_portability_get_current_working_directory(char* buffer, size_t len); @@ -104,37 +104,37 @@ char *jm_mkdtemp(jm_callbacks *cb, char *tmplt); /** - \brief Get absolute path to an existing directory - \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. - \param dir - path to a directory (relative or absolute). - \param outPath - buffer for storing the directory - \param len - of the buffer (if size is larger than FILENAME_MAX + 1 then the path will always fit in) - \return Pointer to outPath on success, 0 - on error in which case a message is send to the logger. + \brief Get absolute path to an existing directory + \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. + \param dir - path to a directory (relative or absolute). + \param outPath - buffer for storing the directory + \param len - of the buffer (if size is larger than FILENAME_MAX + 1 then the path will always fit in) + \return Pointer to outPath on success, 0 - on error in which case a message is send to the logger. */ char* jm_get_dir_abspath(jm_callbacks* cb, const char* dir, char* outPath, size_t len); /** - \brief Create a unique temporary directory - \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. - \param systemTempDir - directory where the temp dir should be located both absolute and relative path are accepted. - System-wide directory is used if this parameter is NULL. - \param tempPrefix - File name template prefix used when creating temporaty directories. "jm" is used if this is NULL. - \return A pointer to the temporary directory name (absolute path, no terminating '/'). Caller is responsible for freeing the memory. - The function returns NULL if there were errors in which case a message is send to the logger. + \brief Create a unique temporary directory + \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. + \param systemTempDir - directory where the temp dir should be located both absolute and relative path are accepted. + System-wide directory is used if this parameter is NULL. + \param tempPrefix - File name template prefix used when creating temporaty directories. "jm" is used if this is NULL. + \return A pointer to the temporary directory name (absolute path, no terminating '/'). Caller is responsible for freeing the memory. + The function returns NULL if there were errors in which case a message is send to the logger. */ char* jm_mk_temp_dir(jm_callbacks* cb, const char* systemTempDir, const char* tempPrefix); /** - \brief Create a file:// URL from absolute path - \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. - \param absPath - absolute path to be converted into the URL - \return A pointer to the URL. Caller is responsible for freeing the memory. - The function returns NULL if there were errors in which case a message is send to the logger. + \brief Create a file:// URL from absolute path + \param cb - callbacks for memory allocation and logging. Default callbacks are used if this parameter is NULL. + \param absPath - absolute path to be converted into the URL + \return A pointer to the URL. Caller is responsible for freeing the memory. + The function returns NULL if there were errors in which case a message is send to the logger. */ char* jm_create_URL_from_abs_path(jm_callbacks* cb, const char* absPath); /** - \brief Make a directory. + \brief Make a directory. */ jm_status_enu_t jm_mkdir(jm_callbacks* cb, const char* dir); diff --git a/src/Util/include/JM/jm_stack.h b/src/Util/include/JM/jm_stack.h index bf3cf9f6..cde066bb 100644 --- a/src/Util/include/JM/jm_stack.h +++ b/src/Util/include/JM/jm_stack.h @@ -22,20 +22,20 @@ extern "C" { #endif /** \file jm_named_ptr.h Definition of ::jm_named_ptr and supporting functions - * - * \addtogroup jm_utils - * @{ - * \defgroup jm_stack_grp A basic stack - * @} - */ - - /** \addtogroup jm_stack_grp - @{ - */ + * + * \addtogroup jm_utils + * @{ + * \defgroup jm_stack_grp A basic stack + * @} + */ + + /** \addtogroup jm_stack_grp + @{ + */ /** - \brief A basic stack of items. - - Stack is implemented on top of jm_vector right now. There is a couple of extra methonds that are convenient. + \brief A basic stack of items. + + Stack is implemented on top of jm_vector right now. There is a couple of extra methonds that are convenient. */ #define jm_stack(T) jm_mangle(jm_stack, T) @@ -143,14 +143,14 @@ T* jm_stack_push_back(jm_stack(T)* a, T item); #define JM_STACK_MAX_MEMORY_CHUNK JM_VECTOR_MAX_MEMORY_CHUNK /** Declare stack for the specific type. */ -#define jm_stack_declare_template(T) \ -typedef jm_vector(T) jm_stack(T); \ +#define jm_stack_declare_template(T) \ +typedef jm_vector(T) jm_stack(T); \ \ -static jm_stack(T)* jm_stack_alloc(T)(size_t capacity,jm_callbacks* c) { return jm_vector_alloc(T)(0, capacity, c); } \ +static jm_stack(T)* jm_stack_alloc(T)(size_t capacity,jm_callbacks* c) { return jm_vector_alloc(T)(0, capacity, c); } \ \ static void jm_stack_free(T)(jm_stack(T) * a) { jm_vector_free(T)(a); } \ \ -static void jm_stack_init(T)(jm_stack(T)* a, jm_callbacks* c) { jm_vector_init(T)(a,0,c); } \ +static void jm_stack_init(T)(jm_stack(T)* a, jm_callbacks* c) { jm_vector_init(T)(a,0,c); } \ \ static void jm_stack_free_data(T)(jm_stack(T)* a) { jm_vector_free_data(T)(a); } \ \ diff --git a/src/Util/include/JM/jm_string_set.h b/src/Util/include/JM/jm_string_set.h index 982ecab0..6f52063c 100644 --- a/src/Util/include/JM/jm_string_set.h +++ b/src/Util/include/JM/jm_string_set.h @@ -25,19 +25,19 @@ extern "C" { #endif /** \file jm_string_set.h Definition of ::jm_string_set and supporting functions - * - * \addtogroup jm_utils - * @{ - * \addtogroup jm_string_set_group - * @} - */ + * + * \addtogroup jm_utils + * @{ + * \addtogroup jm_string_set_group + * @} + */ - /** \addtogroup jm_string_set_group A set of strings - @{ - */ + /** \addtogroup jm_string_set_group A set of strings + @{ + */ /** - \brief Set of string is based on a vector + \brief Set of string is based on a vector */ typedef struct jm_vector_jm_string jm_string_set; /* equivalent to "typedef jm_vector(jm_string) jm_string_set" which Doxygen does not understand */ @@ -113,7 +113,7 @@ static jm_string jm_string_set_put(jm_string_set* s, jm_string str) { } /** @} - */ + */ #ifdef __cplusplus } diff --git a/src/Util/include/JM/jm_types.h b/src/Util/include/JM/jm_types.h index 4f01afa0..52e11299 100644 --- a/src/Util/include/JM/jm_types.h +++ b/src/Util/include/JM/jm_types.h @@ -21,9 +21,9 @@ extern "C" { #include /** - @file jm_types.h Types used in the Utils module. + @file jm_types.h Types used in the Utils module. - */ + */ /** \defgroup jm_utils Utilities \addtogroup jm_utils @@ -41,22 +41,22 @@ typedef struct jm_name_ID_map_t { } jm_name_ID_map_t; /** \brief Return status codes */ -typedef enum { - jm_status_error = -1, - jm_status_success = 0, - jm_status_warning = 1 +typedef enum { + jm_status_error = -1, + jm_status_success = 0, + jm_status_warning = 1 } jm_status_enu_t; /** \brief Log levels supported via the logger functions in ::jm_callbacks */ -typedef enum { - jm_log_level_nothing = 0, /** \brief Must be first in this enum. May be usefull in application relying solely on jm_get_last_error() */ - jm_log_level_fatal, /** \brief Unrecoverable errors */ - jm_log_level_error, /** \brief Errors that may be not critical for some FMUs. */ - jm_log_level_warning, /** \brief Non-critical issues */ - jm_log_level_info, /** \brief Informative messages */ - jm_log_level_verbose, /** \brief Verbose messages */ - jm_log_level_debug, /** \brief Debug messages. Only enabled if library is configured with FMILIB_ENABLE_LOG_LEVEL_DEBUG */ - jm_log_level_all /** \brief Must be last in this enum. */ +typedef enum { + jm_log_level_nothing = 0, /** \brief Must be first in this enum. May be usefull in application relying solely on jm_get_last_error() */ + jm_log_level_fatal, /** \brief Unrecoverable errors */ + jm_log_level_error, /** \brief Errors that may be not critical for some FMUs. */ + jm_log_level_warning, /** \brief Non-critical issues */ + jm_log_level_info, /** \brief Informative messages */ + jm_log_level_verbose, /** \brief Verbose messages */ + jm_log_level_debug, /** \brief Debug messages. Only enabled if library is configured with FMILIB_ENABLE_LOG_LEVEL_DEBUG */ + jm_log_level_all /** \brief Must be last in this enum. */ } jm_log_level_enu_t; /** \brief Convert log level into a string */ diff --git a/src/Util/include/JM/jm_vector.h b/src/Util/include/JM/jm_vector.h index cc1e0557..b04494d4 100644 --- a/src/Util/include/JM/jm_vector.h +++ b/src/Util/include/JM/jm_vector.h @@ -279,19 +279,19 @@ Default definition below is jm_diff and is implemented as (int)(first-second) #define JM_VECTOR_MAX_MEMORY_CHUNK 1024 /** Declare the struct and functions for the specified type. */ -#define jm_vector_declare_template(T) \ +#define jm_vector_declare_template(T) \ typedef struct jm_vector(T) { \ - jm_callbacks* callbacks; \ - T *items; \ - size_t size; \ - size_t capacity; \ - T preallocated[JM_VECTOR_MINIMAL_CAPACITY]; \ -} jm_vector(T); \ + jm_callbacks* callbacks; \ + T *items; \ + size_t size; \ + size_t capacity; \ + T preallocated[JM_VECTOR_MINIMAL_CAPACITY]; \ +} jm_vector(T); \ \ -extern jm_vector(T)* jm_vector_alloc(T)(size_t size,size_t capacity, jm_callbacks*); \ +extern jm_vector(T)* jm_vector_alloc(T)(size_t size,size_t capacity, jm_callbacks*); \ \ extern size_t jm_vector_copy(T)(jm_vector(T)* destination, jm_vector(T)* source); \ -static jm_vector(T)* jm_vector_clone(T)(jm_vector(T)* v) { \ +static jm_vector(T)* jm_vector_clone(T)(jm_vector(T)* v) { \ jm_vector(T)* ret = jm_vector_alloc(T)(v->size, v->size, v->callbacks);\ if(ret) jm_vector_copy(T)(ret, v) ; \ return ret; \ @@ -299,7 +299,7 @@ static jm_vector(T)* jm_vector_clone(T)(jm_vector(T)* v) { \ \ extern void jm_vector_free(T)(jm_vector(T) * a); \ \ -extern size_t jm_vector_init(T)(jm_vector(T)* a, size_t size,jm_callbacks*); \ +extern size_t jm_vector_init(T)(jm_vector(T)* a, size_t size,jm_callbacks*); \ \ static void jm_vector_free_data(T)(jm_vector(T)* a) { \ if(a) { \ diff --git a/src/Util/src/FMI/fmi_util.c b/src/Util/src/FMI/fmi_util.c index 59964c95..576405ea 100644 --- a/src/Util/src/FMI/fmi_util.c +++ b/src/Util/src/FMI/fmi_util.c @@ -19,41 +19,41 @@ #include char* fmi_construct_dll_dir_name(jm_callbacks* callbacks, const char* fmu_unzipped_path) { - char* dir_path; - size_t len; + char* dir_path; + size_t len; - assert( fmu_unzipped_path && callbacks); + assert( fmu_unzipped_path && callbacks); - len = - strlen(fmu_unzipped_path) + strlen(FMI_FILE_SEP) - + strlen(FMI_BINARIES) + strlen(FMI_FILE_SEP) - + strlen(FMI_PLATFORM) + strlen(FMI_FILE_SEP) + 1; + len = + strlen(fmu_unzipped_path) + strlen(FMI_FILE_SEP) + + strlen(FMI_BINARIES) + strlen(FMI_FILE_SEP) + + strlen(FMI_PLATFORM) + strlen(FMI_FILE_SEP) + 1; - dir_path = (char*)callbacks->malloc(len); - if (dir_path == NULL) { - jm_log_fatal(callbacks, "FMIUT", "Failed to allocate memory."); - return NULL; - } + dir_path = (char*)callbacks->malloc(len); + if (dir_path == NULL) { + jm_log_fatal(callbacks, "FMIUT", "Failed to allocate memory."); + return NULL; + } - sprintf(dir_path, "%s%s%s%s%s%s", fmu_unzipped_path, FMI_FILE_SEP, FMI_BINARIES, FMI_FILE_SEP, FMI_PLATFORM, FMI_FILE_SEP);/*safe */ + sprintf(dir_path, "%s%s%s%s%s%s", fmu_unzipped_path, FMI_FILE_SEP, FMI_BINARIES, FMI_FILE_SEP, FMI_PLATFORM, FMI_FILE_SEP);/*safe */ - return dir_path; + return dir_path; } char* fmi_construct_dll_file_name(jm_callbacks* callbacks, const char* dll_dir_name, const char* model_identifier) { - char* fname; - size_t len; - assert(callbacks && model_identifier); - len = - strlen(dll_dir_name) + - strlen(model_identifier) - + strlen(FMI_DLL_EXT) + 1; - fname = (char*)callbacks->malloc(len); - if (fname == NULL) { - jm_log_fatal(callbacks, "FMIUT", "Failed to allocate memory."); - return NULL; - } - sprintf(fname, "%s%s%s", dll_dir_name, model_identifier, FMI_DLL_EXT);/*safe */ - - return fname; + char* fname; + size_t len; + assert(callbacks && model_identifier); + len = + strlen(dll_dir_name) + + strlen(model_identifier) + + strlen(FMI_DLL_EXT) + 1; + fname = (char*)callbacks->malloc(len); + if (fname == NULL) { + jm_log_fatal(callbacks, "FMIUT", "Failed to allocate memory."); + return NULL; + } + sprintf(fname, "%s%s%s", dll_dir_name, model_identifier, FMI_DLL_EXT);/*safe */ + + return fname; } diff --git a/src/Util/src/FMI/fmi_version.c b/src/Util/src/FMI/fmi_version.c index 2684bfe6..65ad83cb 100644 --- a/src/Util/src/FMI/fmi_version.c +++ b/src/Util/src/FMI/fmi_version.c @@ -17,15 +17,15 @@ #include static const char* fmi_versions[] = { - "1.0", - "2.0", + "1.0", + "2.0", "3.0" }; const char * fmi_version_to_string(fmi_version_enu_t v){ - if( (v <= fmi_version_unknown_enu) || (v > fmi_version_unsupported_enu - 1)) { - return "unknown"; - } - return fmi_versions[v - 1]; + if( (v <= fmi_version_unknown_enu) || (v > fmi_version_unsupported_enu - 1)) { + return "unknown"; + } + return fmi_versions[v - 1]; } diff --git a/src/Util/src/FMI1/fmi1_enums.c b/src/Util/src/FMI1/fmi1_enums.c index 3150f88c..55c12c83 100644 --- a/src/Util/src/FMI1/fmi1_enums.c +++ b/src/Util/src/FMI1/fmi1_enums.c @@ -28,7 +28,7 @@ const char* fmi1_fmu_kind_to_string(fmi1_fmu_kind_enu_t kind) { case fmi1_fmu_kind_enu_me: return "ModelExchange"; case fmi1_fmu_kind_enu_cs_standalone: return "CoSimulation_StandAlone"; case fmi1_fmu_kind_enu_cs_tool: return "CoSimulation_Tool"; - default: break; + default: break; } return "Unknown"; } @@ -39,7 +39,7 @@ const char* fmi1_variability_to_string(fmi1_variability_enu_t v) { case fmi1_variability_enu_parameter: return "parameter"; case fmi1_variability_enu_discrete: return "discrete"; case fmi1_variability_enu_continuous: return "continuous"; - default: break; + default: break; } return "Unknown"; } @@ -50,28 +50,28 @@ const char* fmi1_causality_to_string(fmi1_causality_enu_t c) { case fmi1_causality_enu_output: return "output"; case fmi1_causality_enu_internal: return "internal"; case fmi1_causality_enu_none: return "none"; - default: break; + default: break; }; return "Unknown"; } const char* fmi1_status_to_string(fmi1_status_t status) { - switch(status) { - case fmi1_status_ok: - return "OK"; - case fmi1_status_warning: - return "Warning"; - case fmi1_status_discard: - return "Discard"; - case fmi1_status_error: - return "Error"; - case fmi1_status_fatal: - return "Fatal"; - case fmi1_status_pending: - return "Pending"; - default: break; - } - return "Undefined"; + switch(status) { + case fmi1_status_ok: + return "OK"; + case fmi1_status_warning: + return "Warning"; + case fmi1_status_discard: + return "Discard"; + case fmi1_status_error: + return "Error"; + case fmi1_status_fatal: + return "Fatal"; + case fmi1_status_pending: + return "Pending"; + default: break; + } + return "Undefined"; } const char* fmi1_base_type_to_string(fmi1_base_type_enu_t bt) { @@ -81,7 +81,7 @@ const char* fmi1_base_type_to_string(fmi1_base_type_enu_t bt) { case fmi1_base_type_bool: return "Boolean"; case fmi1_base_type_str: return "String"; case fmi1_base_type_enum: return "Enumeration"; - default: break; + default: break; } return "Error"; } diff --git a/src/Util/src/JM/jm_callbacks.c b/src/Util/src/JM/jm_callbacks.c index b07283ad..088b360c 100644 --- a/src/Util/src/JM/jm_callbacks.c +++ b/src/Util/src/JM/jm_callbacks.c @@ -24,54 +24,54 @@ static const char* jm_log_level_str[] = { - "NOTHING", - "FATAL", - "ERROR", - "WARNING", - "INFO", - "VERBOSE", - "DEBUG", - "ALL" + "NOTHING", + "FATAL", + "ERROR", + "WARNING", + "INFO", + "VERBOSE", + "DEBUG", + "ALL" }; /** \brief Convert log level into a string */ const char* jm_log_level_to_string(jm_log_level_enu_t level) { - if((level >= jm_log_level_nothing) && (level <= jm_log_level_all)) - return jm_log_level_str[level]; - else { - assert(0); - return "UNEXPECTED"; - } + if((level >= jm_log_level_nothing) && (level <= jm_log_level_all)) + return jm_log_level_str[level]; + else { + assert(0); + return "UNEXPECTED"; + } } void jm_default_logger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message) { - fprintf(stderr, "[%s][%s] %s\n", jm_log_level_to_string(log_level), module, message); + fprintf(stderr, "[%s][%s] %s\n", jm_log_level_to_string(log_level), module, message); } void jm_log(jm_callbacks* cb, const char* module, jm_log_level_enu_t log_level, const char* fmt, ...) { - va_list args; - if(log_level > cb->log_level) return; + va_list args; + if(log_level > cb->log_level) return; va_start (args, fmt); jm_log_v(cb, module, log_level, fmt, args); va_end (args); } void jm_log_v(jm_callbacks* cb, const char* module, jm_log_level_enu_t log_level, const char* fmt, va_list ap) { - if(log_level > cb->log_level) return; + if(log_level > cb->log_level) return; jm_vsnprintf(cb->errMessageBuffer, JM_MAX_ERROR_MESSAGE_SIZE, fmt, ap); - if(cb->logger) { - cb->logger(cb,module, log_level, cb->errMessageBuffer); - } + if(cb->logger) { + cb->logger(cb,module, log_level, cb->errMessageBuffer); + } } #define CREATE_LOG_FUNCTIONS(log_level) \ void jm_log_ ## log_level(jm_callbacks* cb, const char* module, const char* fmt, ...) { \ - va_list args; \ + va_list args; \ va_start (args, fmt); \ - jm_log_v(cb, module, jm_log_level_ ## log_level, fmt, args); \ + jm_log_v(cb, module, jm_log_level_ ## log_level, fmt, args); \ va_end (args); \ } \ - void jm_log_ ## log_level ## _v(jm_callbacks* cb, const char* module, const char* fmt, va_list ap) { \ + void jm_log_ ## log_level ## _v(jm_callbacks* cb, const char* module, const char* fmt, va_list ap) { \ jm_log_v(cb, module, jm_log_level_ ## log_level, fmt, ap); \ } @@ -92,27 +92,27 @@ jm_callbacks* jm_standard_callbacks_ptr = 0; jm_callbacks* jm_default_callbacks = 0; void jm_set_default_callbacks(jm_callbacks* c) { - if(c) - jm_default_callbacks = c; - else - jm_default_callbacks = jm_standard_callbacks_ptr; + if(c) + jm_default_callbacks = c; + else + jm_default_callbacks = jm_standard_callbacks_ptr; } jm_callbacks* jm_get_default_callbacks() { - if(!jm_default_callbacks) { - if(!jm_standard_callbacks_ptr) { - jm_standard_callbacks.calloc = calloc; - jm_standard_callbacks.malloc = malloc; - jm_standard_callbacks.realloc = realloc; - jm_standard_callbacks.free = free; - jm_standard_callbacks.logger = jm_default_logger; - jm_standard_callbacks.log_level = jm_log_level_info; - jm_standard_callbacks.context = 0; - jm_standard_callbacks.errMessageBuffer[0] = 0; - - jm_standard_callbacks_ptr = &jm_standard_callbacks; - } - jm_default_callbacks = jm_standard_callbacks_ptr; - } - return jm_default_callbacks; + if(!jm_default_callbacks) { + if(!jm_standard_callbacks_ptr) { + jm_standard_callbacks.calloc = calloc; + jm_standard_callbacks.malloc = malloc; + jm_standard_callbacks.realloc = realloc; + jm_standard_callbacks.free = free; + jm_standard_callbacks.logger = jm_default_logger; + jm_standard_callbacks.log_level = jm_log_level_info; + jm_standard_callbacks.context = 0; + jm_standard_callbacks.errMessageBuffer[0] = 0; + + jm_standard_callbacks_ptr = &jm_standard_callbacks; + } + jm_default_callbacks = jm_standard_callbacks_ptr; + } + return jm_default_callbacks; } diff --git a/src/Util/src/JM/jm_named_ptr.c b/src/Util/src/JM/jm_named_ptr.c index e0b332c1..6be85e73 100644 --- a/src/Util/src/JM/jm_named_ptr.c +++ b/src/Util/src/JM/jm_named_ptr.c @@ -25,7 +25,7 @@ jm_named_ptr jm_named_alloc(const char* name, size_t size, size_t nameoffset, jm size_t namelen = strlen(name); size_t sizefull = size + namelen; out.ptr = c->malloc(sizefull); - out.name = 0; + out.name = 0; if(out.ptr) { char* outname; outname = out.ptr; @@ -59,7 +59,7 @@ jm_named_ptr jm_named_alloc_v(jm_vector(char)* name, size_t size, size_t nameoff size_t namelen = jm_vector_get_size(char)(name); size_t sizefull = size + namelen; out.ptr = c->malloc(sizefull); /* Optimization: malloc once instead of twice */ - out.name = 0; + out.name = 0; if (out.ptr) { char* outname = out.ptr; outname += nameoffset; diff --git a/src/Util/src/JM/jm_portability.c b/src/Util/src/JM/jm_portability.c index f6ca133a..f1981bbd 100644 --- a/src/Util/src/JM/jm_portability.c +++ b/src/Util/src/JM/jm_portability.c @@ -39,7 +39,7 @@ static const char * module = "JMPRT"; #include #include #define get_current_working_directory _getcwd -#define set_current_working_directory _chdir +#define set_current_working_directory _chdir #else #include #define get_current_working_directory getcwd @@ -71,71 +71,71 @@ DLL_HANDLE jm_portability_load_dll_handle(const char* dll_file_path) } jm_status_enu_t jm_portability_free_dll_handle(DLL_HANDLE dll_handle) -{ -#ifdef WIN32 - if (FreeLibrary(dll_handle)==0) { - return jm_status_error; - } else { - return jm_status_success; - } -#else - if (dlclose(dll_handle)==0) { - return jm_status_success; - } else { - return jm_status_error; - } +{ +#ifdef WIN32 + if (FreeLibrary(dll_handle)==0) { + return jm_status_error; + } else { + return jm_status_success; + } +#else + if (dlclose(dll_handle)==0) { + return jm_status_success; + } else { + return jm_status_error; + } #endif } jm_status_enu_t jm_portability_load_dll_function(DLL_HANDLE dll_handle, char* dll_function_name, jm_dll_function_ptr* dll_function_ptrptr) { #ifdef WIN32 - *dll_function_ptrptr = (jm_dll_function_ptr)GetProcAddress(dll_handle, dll_function_name); + *dll_function_ptrptr = (jm_dll_function_ptr)GetProcAddress(dll_handle, dll_function_name); #else - *dll_function_ptrptr = dlsym(dll_handle, dll_function_name); + *dll_function_ptrptr = dlsym(dll_handle, dll_function_name); #endif - if (*dll_function_ptrptr == NULL) { - return jm_status_error; - } else { - return jm_status_success; - } + if (*dll_function_ptrptr == NULL) { + return jm_status_error; + } else { + return jm_status_success; + } } char* jm_portability_get_last_dll_error(void) { - static char err_str[JM_PORTABILITY_DLL_ERROR_MESSAGE_SIZE]; + static char err_str[JM_PORTABILITY_DLL_ERROR_MESSAGE_SIZE]; #ifdef WIN32 - LPVOID lpMsgBuf; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); - jm_snprintf(err_str, JM_PORTABILITY_DLL_ERROR_MESSAGE_SIZE, "%s", lpMsgBuf); + LPVOID lpMsgBuf; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); + jm_snprintf(err_str, JM_PORTABILITY_DLL_ERROR_MESSAGE_SIZE, "%s", lpMsgBuf); #else - jm_snprintf(err_str, JM_PORTABILITY_DLL_ERROR_MESSAGE_SIZE, "%s", dlerror()); -#endif - return err_str; + jm_snprintf(err_str, JM_PORTABILITY_DLL_ERROR_MESSAGE_SIZE, "%s", dlerror()); +#endif + return err_str; } jm_status_enu_t jm_portability_get_current_working_directory(char* buffer, size_t len) { - int ilen = (int)len; - if(ilen != len) ilen = FILENAME_MAX + 2; - setlocale(LC_CTYPE, "en_US.UTF-8"); /* just in case, does not seem to have an effect */ - if (get_current_working_directory(buffer, ilen) == NULL) { - return jm_status_error; - } else { - return jm_status_success; - } + int ilen = (int)len; + if(ilen != len) ilen = FILENAME_MAX + 2; + setlocale(LC_CTYPE, "en_US.UTF-8"); /* just in case, does not seem to have an effect */ + if (get_current_working_directory(buffer, ilen) == NULL) { + return jm_status_error; + } else { + return jm_status_success; + } } jm_status_enu_t jm_portability_set_current_working_directory(const char* cwd) { - if (set_current_working_directory(cwd) == 0) { - return jm_status_success; - } else { - return jm_status_error; - } + if (set_current_working_directory(cwd) == 0) { + return jm_status_success; + } else { + return jm_status_error; + } } #ifdef WIN32 @@ -145,10 +145,10 @@ TCHAR jm_temp_dir_buffer[MAX_TEMP_DIR_NAME_LENGTH]; const char* jm_get_system_temp_dir() { #ifdef WIN32 - if(!GetTempPath(MAX_TEMP_DIR_NAME_LENGTH, jm_temp_dir_buffer)) return 0; - return jm_temp_dir_buffer; + if(!GetTempPath(MAX_TEMP_DIR_NAME_LENGTH, jm_temp_dir_buffer)) return 0; + return jm_temp_dir_buffer; #else - return "/tmp/"; + return "/tmp/"; #endif } @@ -186,179 +186,179 @@ char *jm_mkdtemp(jm_callbacks *cb, char *tmplt) #endif jm_status_enu_t jm_mkdir(jm_callbacks* cb, const char* dir) { - if(!cb) { - cb = jm_get_default_callbacks(); - } - if(MKDIR(dir)) { - jm_log_fatal(cb,module,"Could not create directory %s", dir); - return jm_status_error; - } - else - return jm_status_success; + if(!cb) { + cb = jm_get_default_callbacks(); + } + if(MKDIR(dir)) { + jm_log_fatal(cb,module,"Could not create directory %s", dir); + return jm_status_error; + } + else + return jm_status_success; } jm_status_enu_t jm_rmdir(jm_callbacks* cb, const char* dir) { #ifdef WIN32 - const char* fmt_cmd = "rmdir /s /q %s"; + const char* fmt_cmd = "rmdir /s /q %s"; #else const char* fmt_cmd = "rm -rf %s"; #endif char * buf = (char*)cb->calloc(sizeof(char), strlen(dir)+strlen(fmt_cmd)+1); - if(!cb) { - cb = jm_get_default_callbacks(); - } - if(!buf) { - jm_log_error(cb,module,"Could not allocate memory"); - return jm_status_error; - } + if(!cb) { + cb = jm_get_default_callbacks(); + } + if(!buf) { + jm_log_error(cb,module,"Could not allocate memory"); + return jm_status_error; + } sprintf(buf, fmt_cmd, dir);/*safe*/ #ifdef WIN32 - { - char* ch = buf+strlen(fmt_cmd) - 2; - while(*ch) { - if(*ch == '/') *ch = '\\'; - ch++; - } - } + { + char* ch = buf+strlen(fmt_cmd) - 2; + while(*ch) { + if(*ch == '/') *ch = '\\'; + ch++; + } + } #endif jm_log_verbose(cb,module,"Removing %s", dir); if(system(buf)) { - jm_log_error(cb,module,"Error removing %s (%s)", dir, strerror(errno)); - return jm_status_error; - } + jm_log_error(cb,module,"Error removing %s (%s)", dir, strerror(errno)); + return jm_status_error; + } cb->free(buf); - return jm_status_success; + return jm_status_success; } char* jm_get_dir_abspath(jm_callbacks* cb, const char* dir, char* outPath, size_t len) { - char curDir[FILENAME_MAX + 2]; - - if(!cb) { - cb = jm_get_default_callbacks(); - } - if( jm_portability_get_current_working_directory(curDir, FILENAME_MAX+1) != jm_status_success) { - jm_log_fatal(cb,module, "Could not get current working directory (%s)", strerror(errno)); - return 0; - }; - - if(jm_portability_set_current_working_directory(dir) != jm_status_success) { - jm_log_fatal(cb,module, "Could not change to the directory %s", dir); - jm_portability_set_current_working_directory(curDir); - return 0; - }; - if( jm_portability_get_current_working_directory(outPath, len) != jm_status_success) { - jm_log_fatal(cb,module, "Could not get absolute path for the directory (%s)", strerror(errno)); - jm_portability_set_current_working_directory(curDir); - return 0; - }; - jm_portability_set_current_working_directory(curDir); - return outPath; + char curDir[FILENAME_MAX + 2]; + + if(!cb) { + cb = jm_get_default_callbacks(); + } + if( jm_portability_get_current_working_directory(curDir, FILENAME_MAX+1) != jm_status_success) { + jm_log_fatal(cb,module, "Could not get current working directory (%s)", strerror(errno)); + return 0; + }; + + if(jm_portability_set_current_working_directory(dir) != jm_status_success) { + jm_log_fatal(cb,module, "Could not change to the directory %s", dir); + jm_portability_set_current_working_directory(curDir); + return 0; + }; + if( jm_portability_get_current_working_directory(outPath, len) != jm_status_success) { + jm_log_fatal(cb,module, "Could not get absolute path for the directory (%s)", strerror(errno)); + jm_portability_set_current_working_directory(curDir); + return 0; + }; + jm_portability_set_current_working_directory(curDir); + return outPath; } char* jm_mk_temp_dir(jm_callbacks* cb, const char* systemTempDir, const char* tempPrefix) { - size_t len; - - char tmpDir[FILENAME_MAX + 2]; - char* tmpPath; - - if(!cb) { - cb = jm_get_default_callbacks(); - } - if(!systemTempDir) { - systemTempDir = jm_get_system_temp_dir(); - if(!systemTempDir) systemTempDir = "./"; - } - if(!tempPrefix) { - tempPrefix = "jm"; - } - len = strlen(systemTempDir); - - if(!jm_get_dir_abspath(cb, systemTempDir, tmpDir, FILENAME_MAX + 2)) { - return 0; - } - - len = strlen(tmpDir); - if(tmpDir[len-1] != FMI_FILE_SEP[0]) { - tmpDir[len] = FMI_FILE_SEP[0]; - tmpDir[len+1] = 0; - len++; - } - len += strlen(tempPrefix) + 6; - if(len + 16 > FILENAME_MAX) { - jm_log_fatal(cb,module, "Canonical name for the temporary files directory is too long (system limit for path length is %d)", FILENAME_MAX); - return 0; - } - tmpPath = (char*)cb->malloc(len + 7); - if(!tmpPath) { - jm_log_fatal(cb, module,"Could not allocate memory"); - return 0; - } - sprintf(tmpPath,"%s%sXXXXXX",tmpDir,tempPrefix);/*safe*/ + size_t len; + + char tmpDir[FILENAME_MAX + 2]; + char* tmpPath; + + if(!cb) { + cb = jm_get_default_callbacks(); + } + if(!systemTempDir) { + systemTempDir = jm_get_system_temp_dir(); + if(!systemTempDir) systemTempDir = "./"; + } + if(!tempPrefix) { + tempPrefix = "jm"; + } + len = strlen(systemTempDir); + + if(!jm_get_dir_abspath(cb, systemTempDir, tmpDir, FILENAME_MAX + 2)) { + return 0; + } + + len = strlen(tmpDir); + if(tmpDir[len-1] != FMI_FILE_SEP[0]) { + tmpDir[len] = FMI_FILE_SEP[0]; + tmpDir[len+1] = 0; + len++; + } + len += strlen(tempPrefix) + 6; + if(len + 16 > FILENAME_MAX) { + jm_log_fatal(cb,module, "Canonical name for the temporary files directory is too long (system limit for path length is %d)", FILENAME_MAX); + return 0; + } + tmpPath = (char*)cb->malloc(len + 7); + if(!tmpPath) { + jm_log_fatal(cb, module,"Could not allocate memory"); + return 0; + } + sprintf(tmpPath,"%s%sXXXXXX",tmpDir,tempPrefix);/*safe*/ if (jm_mkdtemp(cb, tmpPath) == NULL) { jm_log_fatal(cb, module,"Could not create a unique temporary directory"); } - return tmpPath; + return tmpPath; } char* jm_create_URL_from_abs_path(jm_callbacks* cb, const char* path) { - /* worst case: all symbols are 4-byte UTF-8 and need to be %-encoded */ + /* worst case: all symbols are 4-byte UTF-8 and need to be %-encoded */ #define MAX_URL_LENGTH (FILENAME_MAX * 4 * 3 + 7) - char buffer[MAX_URL_LENGTH]; - char* url; - size_t urllen; - if(!cb) { - cb = jm_get_default_callbacks(); - } + char buffer[MAX_URL_LENGTH]; + char* url; + size_t urllen; + if(!cb) { + cb = jm_get_default_callbacks(); + } #if defined(_WIN32) || defined(WIN32) - { - DWORD pathLen = MAX_URL_LENGTH; - HRESULT code = UrlCreateFromPathA( - path, - buffer, - &pathLen, - 0); - if( (code != S_FALSE) && (code != S_OK)) { - jm_log_fatal(cb, module,"Could not constuct file URL from path %s", path); - return 0; - } - urllen = pathLen; - } + { + DWORD pathLen = MAX_URL_LENGTH; + HRESULT code = UrlCreateFromPathA( + path, + buffer, + &pathLen, + 0); + if( (code != S_FALSE) && (code != S_OK)) { + jm_log_fatal(cb, module,"Could not constuct file URL from path %s", path); + return 0; + } + urllen = pathLen; + } #else - { - size_t i, len = strlen(path); - char *curBuf = buffer + 7; - unsigned char ch; - strcpy(buffer, "file://"); - for( i = 0; i < len; i++) { - ch = (unsigned char)path[i]; - if( (ch == '/') || ((ch >= 'A') && (ch <= 'Z')) - || ((ch >= 'a') && (ch <= 'z')) - || ((ch >= '0') && (ch <= '9')) - || (ch == '-') || (ch == '_') || (ch == '.') ||(ch == '~')) { - *curBuf = ch; - curBuf++; - continue; - } - sprintf(curBuf, "%%%2X", (int)ch);/*safe*/ - curBuf+=3; - } - *curBuf = 0; - urllen = curBuf - buffer; - } + { + size_t i, len = strlen(path); + char *curBuf = buffer + 7; + unsigned char ch; + strcpy(buffer, "file://"); + for( i = 0; i < len; i++) { + ch = (unsigned char)path[i]; + if( (ch == '/') || ((ch >= 'A') && (ch <= 'Z')) + || ((ch >= 'a') && (ch <= 'z')) + || ((ch >= '0') && (ch <= '9')) + || (ch == '-') || (ch == '_') || (ch == '.') ||(ch == '~')) { + *curBuf = ch; + curBuf++; + continue; + } + sprintf(curBuf, "%%%2X", (int)ch);/*safe*/ + curBuf+=3; + } + *curBuf = 0; + urllen = curBuf - buffer; + } #endif - url = (char*)cb->malloc(urllen+1); - if(!url) { - jm_log_fatal(cb, module,"Could not allocate memory"); - return 0; - } - strcpy(url, buffer); - return url; + url = (char*)cb->malloc(urllen+1); + if(!url) { + jm_log_fatal(cb, module,"Could not allocate memory"); + return 0; + } + strcpy(url, buffer); + return url; } #ifndef HAVE_VSNPRINTF @@ -391,44 +391,44 @@ struct jm_locale_t { jm_locale_t* jm_setlocale_numeric(jm_callbacks* cb, const char* value) { - jm_locale_t* jmloc = (jm_locale_t*)malloc(sizeof(jm_locale_t)); - if (!jmloc) { + jm_locale_t* jmloc = (jm_locale_t*)malloc(sizeof(jm_locale_t)); + if (!jmloc) { jm_log_error(cb, module, "failed to allocate memory"); - return NULL; - } + return NULL; + } #ifdef UNIX_THREAD_LOCALE - { - locale_t nloc = NULL; - - /* Retrieve old locale */ - jmloc->locale_old = uselocale((locale_t)0); - if (jmloc->locale_old == (locale_t)0) { - jm_log_error(cb, module, "'uselocale' failed to get current locale"); - goto err1; - } + { + locale_t nloc = NULL; + + /* Retrieve old locale */ + jmloc->locale_old = uselocale((locale_t)0); + if (jmloc->locale_old == (locale_t)0) { + jm_log_error(cb, module, "'uselocale' failed to get current locale"); + goto err1; + } - /* Create new locale. */ - nloc = newlocale(LC_NUMERIC_MASK, value, (locale_t)0); - if (nloc == (locale_t)0) { - jm_log_error(cb, module, "call failed: 'newlocale'"); - goto err1; - } + /* Create new locale. */ + nloc = newlocale(LC_NUMERIC_MASK, value, (locale_t)0); + if (nloc == (locale_t)0) { + jm_log_error(cb, module, "call failed: 'newlocale'"); + goto err1; + } - /* Set new locale */ - uselocale(nloc); + /* Set new locale */ + uselocale(nloc); - return jmloc; + return jmloc; - /* Error handling */ + /* Error handling */ err1: - free(jmloc); - return NULL; - } + free(jmloc); + return NULL; + } #else - { - /* Only thread-safe for MSVC. */ - char* tmp; + { + /* Only thread-safe for MSVC. */ + char* tmp; #ifdef _MSC_VER /* Save current thread settings. */ @@ -438,11 +438,11 @@ jm_locale_t* jm_setlocale_numeric(jm_callbacks* cb, const char* value) { /* Create a copy of locale, since any further calls to setlocale (e.g. * from 3rd party code) will override the returned pointer. */ tmp = setlocale(LC_NUMERIC, NULL); - if (!tmp) { + if (!tmp) { jm_log_error(cb, module, "Failed to get current locale with 'setlocale'"); - free(jmloc); - return NULL; - } + free(jmloc); + return NULL; + } jmloc->locale_old = (char*)cb->malloc(strlen(tmp) + 1); /* + 1 for \0 */ strcpy(jmloc->locale_old, tmp); @@ -453,38 +453,38 @@ jm_locale_t* jm_setlocale_numeric(jm_callbacks* cb, const char* value) { if (setlocale(LC_NUMERIC, value) == NULL) { jm_log_error(cb, module, "Failed to call 'setlocale' for LC_NUMERIC with value: '%s'", value); - free(jmloc->locale_old); - free(jmloc); - return NULL; + free(jmloc->locale_old); + free(jmloc); + return NULL; } - return jmloc; - } + return jmloc; + } #endif } int jm_resetlocale_numeric(jm_callbacks* cb, jm_locale_t* jmloc) { - if (jmloc == NULL) { - return 1; /* impl. error */ - } + if (jmloc == NULL) { + return 1; /* impl. error */ + } #ifdef UNIX_THREAD_LOCALE - { - /* Get current locale, which is expected to have been set with a previous - * call to 'jm_setlocale_numeric'. */ - locale_t loc = uselocale((locale_t)0); - if (loc == (locale_t)0) { - jm_log_error(cb, module, "'uselocale' failed to get current locale."); - return 1; - } - uselocale(jmloc->locale_old); + { + /* Get current locale, which is expected to have been set with a previous + * call to 'jm_setlocale_numeric'. */ + locale_t loc = uselocale((locale_t)0); + if (loc == (locale_t)0) { + jm_log_error(cb, module, "'uselocale' failed to get current locale."); + return 1; + } + uselocale(jmloc->locale_old); - freelocale(loc); - } + freelocale(loc); + } #else setlocale(LC_NUMERIC, jmloc->locale_old); - cb->free(jmloc->locale_old); - jmloc->locale_old = NULL; + cb->free(jmloc->locale_old); + jmloc->locale_old = NULL; #ifdef _MSC_VER _configthreadlocale(jmloc->per_thread_locale_type_old); @@ -492,6 +492,6 @@ int jm_resetlocale_numeric(jm_callbacks* cb, jm_locale_t* jmloc) { #endif - free(jmloc); - return 0; + free(jmloc); + return 0; } diff --git a/src/XML/include/FMI/fmi_xml_context.h b/src/XML/include/FMI/fmi_xml_context.h index 7efa1fc1..ab5715e1 100644 --- a/src/XML/include/FMI/fmi_xml_context.h +++ b/src/XML/include/FMI/fmi_xml_context.h @@ -39,8 +39,8 @@ extern "C" { typedef struct fmi_xml_context_t fmi_xml_context_t; /** \brief Allocate library context - @param callbacks - the callbacks to be used for memory allocation and logging. Can be NULL if default callbacks are to be used. - @return A pointer to the newly allocated ::fmi_xml_context_t or NULL if memory allocation failed. + @param callbacks - the callbacks to be used for memory allocation and logging. Can be NULL if default callbacks are to be used. + @return A pointer to the newly allocated ::fmi_xml_context_t or NULL if memory allocation failed. */ fmi_xml_context_t* fmi_xml_allocate_context( jm_callbacks* callbacks); @@ -59,23 +59,23 @@ typedef struct fmi3_xml_model_description_t fmi3_xml_model_description_t; /** \brief Parse FMI 1.0 XML file and create model description object. - Errors are reported via the ::jm_callbacks object passed to fmi_xml_allocate_context(). - @return Model description object or NULL if parsing failed. + Errors are reported via the ::jm_callbacks object passed to fmi_xml_allocate_context(). + @return Model description object or NULL if parsing failed. */ fmi1_xml_model_description_t* fmi1_xml_parse( fmi_xml_context_t* c, const char* fileName); /** \brief Parse FMI 2.0 XML file and create model description object. - Errors are reported via the ::jm_callbacks object passed to fmi_xml_allocate_context(). - @return Model description object or NULL if parsing failed. + Errors are reported via the ::jm_callbacks object passed to fmi_xml_allocate_context(). + @return Model description object or NULL if parsing failed. */ fmi2_xml_model_description_t* fmi2_xml_parse( fmi_xml_context_t* c, const char* fileName); /** \brief Parse FMI 3.0 XML file and create model description object. - Errors are reported via the ::jm_callbacks object passed to fmi_xml_allocate_context(). - @return Model description object or NULL if parsing failed. + Errors are reported via the ::jm_callbacks object passed to fmi_xml_allocate_context(). + @return Model description object or NULL if parsing failed. */ fmi3_xml_model_description_t* fmi3_xml_parse( fmi_xml_context_t* c, const char* fileName); /** @} diff --git a/src/XML/include/FMI1/fmi1_xml_capabilities.h b/src/XML/include/FMI1/fmi1_xml_capabilities.h index f6564be8..af32aa76 100644 --- a/src/XML/include/FMI1/fmi1_xml_capabilities.h +++ b/src/XML/include/FMI1/fmi1_xml_capabilities.h @@ -21,37 +21,37 @@ extern "C" { #endif #include "FMI1/fmi1_xml_model_description.h" - /** - \file fmi1_xml_capabilities.h - Functions to retrieve capability flags. - */ - /** - \addtogroup fmi1_xml - @{ - \addtogroup fmi1_xml_capabilities Functions to retrieve capability flags. - The functions accept a pointer to ::fmi1_xml_capabilities_t returned by fmi1_xml_get_capabilities(). - They return the flags as specified by the FMI 1.0 standard. Default values are returned for model-exachange FMUs. - @} - \addtogroup fmi1_xml_capabilities - @{ - */ + /** + \file fmi1_xml_capabilities.h + Functions to retrieve capability flags. + */ + /** + \addtogroup fmi1_xml + @{ + \addtogroup fmi1_xml_capabilities Functions to retrieve capability flags. + The functions accept a pointer to ::fmi1_xml_capabilities_t returned by fmi1_xml_get_capabilities(). + They return the flags as specified by the FMI 1.0 standard. Default values are returned for model-exachange FMUs. + @} + \addtogroup fmi1_xml_capabilities + @{ + */ /** \brief Retrieve canHandleVariableCommunicationStepSize flag. */ int fmi1_xml_get_canHandleVariableCommunicationStepSize(fmi1_xml_capabilities_t* ); - /** \brief Retrieve canHandleEvents flag. */ + /** \brief Retrieve canHandleEvents flag. */ int fmi1_xml_get_canHandleEvents(fmi1_xml_capabilities_t* ); - /** \brief Retrieve canRejectSteps flag. */ + /** \brief Retrieve canRejectSteps flag. */ int fmi1_xml_get_canRejectSteps(fmi1_xml_capabilities_t* ); - /** \brief Retrieve canInterpolateInputs flag. */ + /** \brief Retrieve canInterpolateInputs flag. */ int fmi1_xml_get_canInterpolateInputs(fmi1_xml_capabilities_t* ); - /** \brief Retrieve maxOutputDerivativeOrder. */ + /** \brief Retrieve maxOutputDerivativeOrder. */ unsigned int fmi1_xml_get_maxOutputDerivativeOrder(fmi1_xml_capabilities_t* ); - /** \brief Retrieve canRunAsynchronuously flag. */ + /** \brief Retrieve canRunAsynchronuously flag. */ int fmi1_xml_get_canRunAsynchronuously(fmi1_xml_capabilities_t* ); - /** \brief Deprecated since 1.0.1, do not use. */ + /** \brief Deprecated since 1.0.1, do not use. */ int fmi1_xml_get_canSignalEvents(fmi1_xml_capabilities_t* ); - /** \brief Retrieve canBeInstantiatedOnlyOncePerProcess flag. */ + /** \brief Retrieve canBeInstantiatedOnlyOncePerProcess flag. */ int fmi1_xml_get_canBeInstantiatedOnlyOncePerProcess(fmi1_xml_capabilities_t* ); - /** \brief Retrieve canNotUseMemoryManagementFunctions flag. */ + /** \brief Retrieve canNotUseMemoryManagementFunctions flag. */ int fmi1_xml_get_canNotUseMemoryManagementFunctions(fmi1_xml_capabilities_t* ); /** diff --git a/src/XML/include/FMI1/fmi1_xml_model_description.h b/src/XML/include/FMI1/fmi1_xml_model_description.h index 3f268e48..ba3e0145 100644 --- a/src/XML/include/FMI1/fmi1_xml_model_description.h +++ b/src/XML/include/FMI1/fmi1_xml_model_description.h @@ -35,7 +35,7 @@ extern "C" { /** \addtogroup fmi_xml @{ - \addtogroup fmi1_xml + \addtogroup fmi1_xml @} */ /** @@ -89,12 +89,12 @@ typedef struct fmi1_xml_unit_definitions_t fmi1_xml_unit_definitions_t; /**@{ */ typedef struct fmi1_xml_capabilities_t fmi1_xml_capabilities_t; /**@} */ -/** \addtogroup fmi1_xml_gen General information retrieval*/ -/** \addtogroup fmi1_xml_init Constuction, destruction and error checking */ +/** \addtogroup fmi1_xml_gen General information retrieval*/ +/** \addtogroup fmi1_xml_init Constuction, destruction and error checking */ /** @} */ -/** \addtogroup fmi1_xml_init +/** \addtogroup fmi1_xml_init @{ */ /** \brief Allocate the ModelDescription structure and initialize as empty model. @@ -210,19 +210,19 @@ jm_vector(jm_named_ptr)* fmi1_xml_get_variables_alphabetical_order(fmi1_xml_mode jm_vector(jm_voidp)* fmi1_xml_get_variables_vr_order(fmi1_xml_model_description_t* md); /** - \brief Get variable by variable name. - \param md - the model description - \param name - variable name - \return variable pointer. + \brief Get variable by variable name. + \param md - the model description + \param name - variable name + \return variable pointer. */ fmi1_xml_variable_t* fmi1_xml_get_variable_by_name(fmi1_xml_model_description_t* md, const char* name); /** - \brief Get variable by value reference. - \param md - the model description - \param baseType - basic data type - \param vr - value reference - \return variable pointer. + \brief Get variable by value reference. + \param md - the model description + \param baseType - basic data type + \param vr - value reference + \return variable pointer. */ fmi1_xml_variable_t* fmi1_xml_get_variable_by_vr(fmi1_xml_model_description_t* md, fmi1_base_type_enu_t baseType, fmi1_value_reference_t vr); diff --git a/src/XML/include/FMI1/fmi1_xml_type.h b/src/XML/include/FMI1/fmi1_xml_type.h index 26e201e4..63c6e158 100644 --- a/src/XML/include/FMI1/fmi1_xml_type.h +++ b/src/XML/include/FMI1/fmi1_xml_type.h @@ -28,14 +28,14 @@ extern "C" { #endif - /** - \addtogroup fmi1_xml - @{ - \addtogroup fmi1_xml_types Support for processing variable types - @} - \addtogroup fmi1_xml_types Support for processing variable types - @{ - */ + /** + \addtogroup fmi1_xml + @{ + \addtogroup fmi1_xml_types Support for processing variable types + @} + \addtogroup fmi1_xml_types Support for processing variable types + @{ + */ fmi1_xml_display_unit_t* fmi1_xml_get_type_display_unit(fmi1_xml_real_typedef_t*); diff --git a/src/XML/include/FMI1/fmi1_xml_unit.h b/src/XML/include/FMI1/fmi1_xml_unit.h index c75ea75d..4aaea338 100644 --- a/src/XML/include/FMI1/fmi1_xml_unit.h +++ b/src/XML/include/FMI1/fmi1_xml_unit.h @@ -25,15 +25,15 @@ #ifdef __cplusplus extern "C" { #endif - - /** - \addtogroup fmi1_xml - @{ - \addtogroup fmi1_xml_units Functions for handling unit definitions. - @} - \addtogroup fmi1_xml_units Functions for handling unit definitions. - @{ - */ + + /** + \addtogroup fmi1_xml + @{ + \addtogroup fmi1_xml_units Functions for handling unit definitions. + @} + \addtogroup fmi1_xml_units Functions for handling unit definitions. + @{ + */ /** \brief Get a list of all the unit definitions */ fmi1_xml_unit_definitions_t* fmi1_xml_get_unit_definitions(fmi1_xml_model_description_t* md); diff --git a/src/XML/include/FMI1/fmi1_xml_variable.h b/src/XML/include/FMI1/fmi1_xml_variable.h index c03199fe..63924d1f 100644 --- a/src/XML/include/FMI1/fmi1_xml_variable.h +++ b/src/XML/include/FMI1/fmi1_xml_variable.h @@ -29,14 +29,14 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi1_xml - @{ - \addtogroup fmi1_xml_variables Functions for handling variable definitions. - @} - \addtogroup fmi1_xml_variables Functions for handling variable definitions. - @{ - */ + /** + \addtogroup fmi1_xml + @{ + \addtogroup fmi1_xml_variables Functions for handling variable definitions. + @} + \addtogroup fmi1_xml_variables Functions for handling variable definitions. + @{ + */ const char* fmi1_xml_get_variable_name(fmi1_xml_variable_t*); const char* fmi1_xml_get_variable_description(fmi1_xml_variable_t*); diff --git a/src/XML/include/FMI2/fmi2_xml_capabilities.h b/src/XML/include/FMI2/fmi2_xml_capabilities.h index b18b32d0..b67390fc 100644 --- a/src/XML/include/FMI2/fmi2_xml_capabilities.h +++ b/src/XML/include/FMI2/fmi2_xml_capabilities.h @@ -21,25 +21,25 @@ extern "C" { #endif #include "FMI2/fmi2_xml_model_description.h" - /** - \file fmi2_xml_capabilities.h - Functions to retrieve capability flags. - */ - /** - \addtogroup fmi2_xml - @{ - \addtogroup fmi2_xml_capabilities Functions to retrieve capability flags. - The functions accept a pointer to ::fmi2_xml_capabilities_t returned by fmi2_xml_get_capabilities(). - They return the flags as specified by the FMI 2.0 standard. Default values are returned for model-exachange FMUs. - @} - \addtogroup fmi2_xml_capabilities - @{ - */ + /** + \file fmi2_xml_capabilities.h + Functions to retrieve capability flags. + */ + /** + \addtogroup fmi2_xml + @{ + \addtogroup fmi2_xml_capabilities Functions to retrieve capability flags. + The functions accept a pointer to ::fmi2_xml_capabilities_t returned by fmi2_xml_get_capabilities(). + They return the flags as specified by the FMI 2.0 standard. Default values are returned for model-exachange FMUs. + @} + \addtogroup fmi2_xml_capabilities + @{ + */ /** \brief Retrieve canHandleVariableCommunicationStepSize flag. */ - + unsigned int fmi2_xml_get_capability(fmi2_xml_model_description_t* , fmi2_capabilities_enu_t id); - - + + /** @} */ diff --git a/src/XML/include/FMI2/fmi2_xml_model_description.h b/src/XML/include/FMI2/fmi2_xml_model_description.h index 28bc8a69..e6061b3c 100644 --- a/src/XML/include/FMI2/fmi2_xml_model_description.h +++ b/src/XML/include/FMI2/fmi2_xml_model_description.h @@ -36,7 +36,7 @@ extern "C" { /** \addtogroup fmi_xml @{ - \addtogroup fmi2_xml + \addtogroup fmi2_xml @} */ /** @@ -85,12 +85,12 @@ typedef struct fmi2_xml_unit_definitions_t fmi2_xml_unit_definitions_t; /**@{ */ typedef struct fmi2_xml_capabilities_t fmi2_xml_capabilities_t; /**@} */ -/** \addtogroup fmi2_xml_gen General information retrieval*/ -/** \addtogroup fmi2_xml_init Constuction, destruction and error checking */ +/** \addtogroup fmi2_xml_gen General information retrieval*/ +/** \addtogroup fmi2_xml_init Constuction, destruction and error checking */ /** @} */ -/** \addtogroup fmi2_xml_init +/** \addtogroup fmi2_xml_init @{ */ /** \brief Allocate the ModelDescription structure and initialize as empty model. @@ -113,7 +113,7 @@ fmi2_xml_model_description_t* fmi2_xml_allocate_model_description( jm_callbacks* @param md A model description object as returned by fmi2_xml_allocate_model_description. @param fileName A name (full path) of the XML file name with model definition. - @param xml_callbacks Callbacks to use for processing annotations (may be NULL). + @param xml_callbacks Callbacks to use for processing annotations (may be NULL). @param configuration Specifies how to parse the model description, 0 is default. Other possible configuration is FMI_XML_NAME_CHECK. @return 0 if parsing was successfull. Non-zero value indicates an error. @@ -215,19 +215,19 @@ jm_vector(jm_named_ptr)* fmi2_xml_get_variables_alphabetical_order(fmi2_xml_mode jm_vector(jm_voidp)* fmi2_xml_get_variables_vr_order(fmi2_xml_model_description_t* md); /** - \brief Get variable by variable name. - \param md - the model description - \param name - variable name - \return variable pointer. + \brief Get variable by variable name. + \param md - the model description + \param name - variable name + \return variable pointer. */ fmi2_xml_variable_t* fmi2_xml_get_variable_by_name(fmi2_xml_model_description_t* md, const char* name); /** - \brief Get variable by value reference. - \param md - the model description - \param baseType - basic data type - \param vr - value reference - \return variable pointer. + \brief Get variable by value reference. + \param md - the model description + \param baseType - basic data type + \param vr - value reference + \return variable pointer. */ fmi2_xml_variable_t* fmi2_xml_get_variable_by_vr(fmi2_xml_model_description_t* md, fmi2_base_type_enu_t baseType, fmi2_value_reference_t vr); diff --git a/src/XML/include/FMI2/fmi2_xml_model_structure.h b/src/XML/include/FMI2/fmi2_xml_model_structure.h index 191a04e4..bd3d7e82 100644 --- a/src/XML/include/FMI2/fmi2_xml_model_structure.h +++ b/src/XML/include/FMI2/fmi2_xml_model_structure.h @@ -63,7 +63,7 @@ jm_vector(jm_voidp)* fmi2_xml_get_initial_unknowns(fmi2_xml_model_structure_t* m * @param factorKind - outputs a pointer to the factor kind data. The values can be converted to ::fmi2_dependency_factor_kind_enu_t */ void fmi2_xml_get_outputs_dependencies(fmi2_xml_model_structure_t* ms, size_t** startIndex, size_t** dependency, char** factorKind); - + /** \brief Get dependency information in row-compressed format. * @param startIndex - outputs a pointer to an array of start indices (size of array is number of derivatives + 1). * First element is zero, last is equal to the number of elements in the dependency and factor arrays. diff --git a/src/XML/include/FMI2/fmi2_xml_type.h b/src/XML/include/FMI2/fmi2_xml_type.h index 4f8cc261..6db5d868 100644 --- a/src/XML/include/FMI2/fmi2_xml_type.h +++ b/src/XML/include/FMI2/fmi2_xml_type.h @@ -28,14 +28,14 @@ extern "C" { #endif - /** - \addtogroup fmi2_xml - @{ - \addtogroup fmi2_xml_types Support for processing variable types - @} - \addtogroup fmi2_xml_types Support for processing variable types - @{ - */ + /** + \addtogroup fmi2_xml + @{ + \addtogroup fmi2_xml_types Support for processing variable types + @} + \addtogroup fmi2_xml_types Support for processing variable types + @{ + */ fmi2_xml_display_unit_t* fmi2_xml_get_type_display_unit(fmi2_xml_real_typedef_t*); diff --git a/src/XML/include/FMI2/fmi2_xml_unit.h b/src/XML/include/FMI2/fmi2_xml_unit.h index 1ef62b2b..d1736288 100644 --- a/src/XML/include/FMI2/fmi2_xml_unit.h +++ b/src/XML/include/FMI2/fmi2_xml_unit.h @@ -25,15 +25,15 @@ #ifdef __cplusplus extern "C" { #endif - - /** - \addtogroup fmi2_xml - @{ - \addtogroup fmi2_xml_units Functions for handling unit definitions. - @} - \addtogroup fmi2_xml_units Functions for handling unit definitions. - @{ - */ + + /** + \addtogroup fmi2_xml + @{ + \addtogroup fmi2_xml_units Functions for handling unit definitions. + @} + \addtogroup fmi2_xml_units Functions for handling unit definitions. + @{ + */ /** \brief Get a list of all the unit definitions */ fmi2_xml_unit_definitions_t* fmi2_xml_get_unit_definitions(fmi2_xml_model_description_t* md); @@ -45,29 +45,29 @@ unsigned int fmi2_xml_get_unit_display_unit_number(fmi2_xml_unit_t*); fmi2_xml_display_unit_t* fmi2_xml_get_unit_display_unit(fmi2_xml_unit_t*, size_t index); /** - \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit. + \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit. */ const int* fmi2_xml_get_SI_unit_exponents(fmi2_xml_unit_t*); /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ double fmi2_xml_get_SI_unit_factor(fmi2_xml_unit_t*); /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ double fmi2_xml_get_SI_unit_offset(fmi2_xml_unit_t*); /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ double fmi2_xml_convert_to_SI_base_unit(double, fmi2_xml_unit_t*); /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ double fmi2_xml_convert_from_SI_base_unit(double, fmi2_xml_unit_t*); diff --git a/src/XML/include/FMI2/fmi2_xml_variable.h b/src/XML/include/FMI2/fmi2_xml_variable.h index 21d6b843..a29df33b 100644 --- a/src/XML/include/FMI2/fmi2_xml_variable.h +++ b/src/XML/include/FMI2/fmi2_xml_variable.h @@ -29,14 +29,14 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi2_xml - @{ - \addtogroup fmi2_xml_variables Functions for handling variable definitions. - @} - \addtogroup fmi2_xml_variables Functions for handling variable definitions. - @{ - */ + /** + \addtogroup fmi2_xml + @{ + \addtogroup fmi2_xml_variables Functions for handling variable definitions. + @} + \addtogroup fmi2_xml_variables Functions for handling variable definitions. + @{ + */ const char* fmi2_xml_get_variable_name(fmi2_xml_variable_t*); const char* fmi2_xml_get_variable_description(fmi2_xml_variable_t*); diff --git a/src/XML/include/FMI3/fmi3_xml_capabilities.h b/src/XML/include/FMI3/fmi3_xml_capabilities.h index bca02aad..cd4e10d6 100644 --- a/src/XML/include/FMI3/fmi3_xml_capabilities.h +++ b/src/XML/include/FMI3/fmi3_xml_capabilities.h @@ -21,25 +21,25 @@ extern "C" { #endif #include "FMI3/fmi3_xml_model_description.h" - /** - \file fmi3_xml_capabilities.h - Functions to retrieve capability flags. - */ - /** - \addtogroup fmi3_xml - @{ - \addtogroup fmi3_xml_capabilities Functions to retrieve capability flags. - The functions accept a pointer to ::fmi3_xml_capabilities_t returned by fmi3_xml_get_capabilities(). - They return the flags as specified by the FMI 3.0 standard. Default values are returned for model-exachange FMUs. - @} - \addtogroup fmi3_xml_capabilities - @{ - */ + /** + \file fmi3_xml_capabilities.h + Functions to retrieve capability flags. + */ + /** + \addtogroup fmi3_xml + @{ + \addtogroup fmi3_xml_capabilities Functions to retrieve capability flags. + The functions accept a pointer to ::fmi3_xml_capabilities_t returned by fmi3_xml_get_capabilities(). + They return the flags as specified by the FMI 3.0 standard. Default values are returned for model-exachange FMUs. + @} + \addtogroup fmi3_xml_capabilities + @{ + */ /** \brief Retrieve canHandleVariableCommunicationStepSize flag. */ - + unsigned int fmi3_xml_get_capability(fmi3_xml_model_description_t* , fmi3_capabilities_enu_t id); - - + + /** @} */ diff --git a/src/XML/include/FMI3/fmi3_xml_model_description.h b/src/XML/include/FMI3/fmi3_xml_model_description.h index a866ba51..8d6f50ef 100644 --- a/src/XML/include/FMI3/fmi3_xml_model_description.h +++ b/src/XML/include/FMI3/fmi3_xml_model_description.h @@ -36,7 +36,7 @@ extern "C" { /** \addtogroup fmi_xml @{ - \addtogroup fmi3_xml + \addtogroup fmi3_xml @} */ /** @@ -95,12 +95,12 @@ typedef struct fmi3_xml_unit_definitions_t fmi3_xml_unit_definitions_t; /**@{ */ typedef struct fmi3_xml_capabilities_t fmi3_xml_capabilities_t; /**@} */ -/** \addtogroup fmi3_xml_gen General information retrieval*/ -/** \addtogroup fmi3_xml_init Constuction, destruction and error checking */ +/** \addtogroup fmi3_xml_gen General information retrieval*/ +/** \addtogroup fmi3_xml_init Constuction, destruction and error checking */ /** @} */ -/** \addtogroup fmi3_xml_init +/** \addtogroup fmi3_xml_init @{ */ /** \brief Allocate the ModelDescription structure and initialize as empty model. @@ -123,7 +123,7 @@ fmi3_xml_model_description_t* fmi3_xml_allocate_model_description( jm_callbacks* @param md A model description object as returned by fmi3_xml_allocate_model_description. @param fileName A name (full path) of the XML file name with model definition. - @param xml_callbacks Callbacks to use for processing annotations (may be NULL). + @param xml_callbacks Callbacks to use for processing annotations (may be NULL). @param configuration Specifies how to parse the model description, 0 is default. Other possible configuration is FMI_XML_NAME_CHECK. @return 0 if parsing was successfull. Non-zero value indicates an error. @@ -227,19 +227,19 @@ jm_vector(jm_named_ptr)* fmi3_xml_get_variables_alphabetical_order(fmi3_xml_mode jm_vector(jm_voidp)* fmi3_xml_get_variables_vr_order(fmi3_xml_model_description_t* md); /** - \brief Get variable by variable name. - \param md - the model description - \param name - variable name - \return variable pointer. + \brief Get variable by variable name. + \param md - the model description + \param name - variable name + \return variable pointer. */ fmi3_xml_variable_t* fmi3_xml_get_variable_by_name(fmi3_xml_model_description_t* md, const char* name); /** - \brief Get variable by value reference. - \param md - the model description - \param baseType - basic data type - \param vr - value reference - \return variable pointer. + \brief Get variable by value reference. + \param md - the model description + \param baseType - basic data type + \param vr - value reference + \return variable pointer. */ fmi3_xml_variable_t* fmi3_xml_get_variable_by_vr(fmi3_xml_model_description_t* md, fmi3_base_type_enu_t baseType, fmi3_value_reference_t vr); diff --git a/src/XML/include/FMI3/fmi3_xml_model_structure.h b/src/XML/include/FMI3/fmi3_xml_model_structure.h index 7bab069a..c3288f0f 100644 --- a/src/XML/include/FMI3/fmi3_xml_model_structure.h +++ b/src/XML/include/FMI3/fmi3_xml_model_structure.h @@ -63,7 +63,7 @@ jm_vector(jm_voidp)* fmi3_xml_get_initial_unknowns(fmi3_xml_model_structure_t* m * @param factorKind - outputs a pointer to the factor kind data. The values can be converted to ::fmi3_dependency_factor_kind_enu_t */ void fmi3_xml_get_outputs_dependencies(fmi3_xml_model_structure_t* ms, size_t** startIndex, size_t** dependency, char** factorKind); - + /** \brief Get dependency information in row-compressed format. * @param startIndex - outputs a pointer to an array of start indices (size of array is number of derivatives + 1). * First element is zero, last is equal to the number of elements in the dependency and factor arrays. diff --git a/src/XML/include/FMI3/fmi3_xml_type.h b/src/XML/include/FMI3/fmi3_xml_type.h index 20692eef..26d7f07a 100644 --- a/src/XML/include/FMI3/fmi3_xml_type.h +++ b/src/XML/include/FMI3/fmi3_xml_type.h @@ -28,14 +28,14 @@ extern "C" { #endif - /** - \addtogroup fmi3_xml - @{ - \addtogroup fmi3_xml_types Support for processing variable types - @} - \addtogroup fmi3_xml_types Support for processing variable types - @{ - */ + /** + \addtogroup fmi3_xml + @{ + \addtogroup fmi3_xml_types Support for processing variable types + @} + \addtogroup fmi3_xml_types Support for processing variable types + @{ + */ fmi3_xml_type_definitions_t* fmi3_xml_get_type_definitions(fmi3_xml_model_description_t* md); diff --git a/src/XML/include/FMI3/fmi3_xml_unit.h b/src/XML/include/FMI3/fmi3_xml_unit.h index 577dd6b8..de1a84da 100644 --- a/src/XML/include/FMI3/fmi3_xml_unit.h +++ b/src/XML/include/FMI3/fmi3_xml_unit.h @@ -25,15 +25,15 @@ #ifdef __cplusplus extern "C" { #endif - - /** - \addtogroup fmi3_xml - @{ - \addtogroup fmi3_xml_units Functions for handling unit definitions. - @} - \addtogroup fmi3_xml_units Functions for handling unit definitions. - @{ - */ + + /** + \addtogroup fmi3_xml + @{ + \addtogroup fmi3_xml_units Functions for handling unit definitions. + @} + \addtogroup fmi3_xml_units Functions for handling unit definitions. + @{ + */ /** \brief Get a list of all the unit definitions */ fmi3_xml_unit_definitions_t* fmi3_xml_get_unit_definitions(fmi3_xml_model_description_t* md); @@ -45,29 +45,29 @@ unsigned int fmi3_xml_get_unit_display_unit_number(fmi3_xml_unit_t*); fmi3_xml_display_unit_t* fmi3_xml_get_unit_display_unit(fmi3_xml_unit_t*, size_t index); /** - \brief Get fmi3_SI_base_units_Num SI base units exponents associated with the unit. + \brief Get fmi3_SI_base_units_Num SI base units exponents associated with the unit. */ const int* fmi3_xml_get_SI_unit_exponents(fmi3_xml_unit_t*); /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ double fmi3_xml_get_SI_unit_factor(fmi3_xml_unit_t*); /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ double fmi3_xml_get_SI_unit_offset(fmi3_xml_unit_t*); /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ double fmi3_xml_convert_to_SI_base_unit(double, fmi3_xml_unit_t*); /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ double fmi3_xml_convert_from_SI_base_unit(double, fmi3_xml_unit_t*); diff --git a/src/XML/include/FMI3/fmi3_xml_variable.h b/src/XML/include/FMI3/fmi3_xml_variable.h index d206c5bc..b4815033 100644 --- a/src/XML/include/FMI3/fmi3_xml_variable.h +++ b/src/XML/include/FMI3/fmi3_xml_variable.h @@ -29,14 +29,14 @@ #ifdef __cplusplus extern "C" { #endif - /** - \addtogroup fmi3_xml - @{ - \addtogroup fmi3_xml_variables Functions for handling variable definitions. - @} - \addtogroup fmi3_xml_variables Functions for handling variable definitions. - @{ - */ + /** + \addtogroup fmi3_xml + @{ + \addtogroup fmi3_xml_variables Functions for handling variable definitions. + @} + \addtogroup fmi3_xml_variables Functions for handling variable definitions. + @{ + */ const char* fmi3_xml_get_variable_name(fmi3_xml_variable_t*); const char* fmi3_xml_get_variable_description(fmi3_xml_variable_t*); diff --git a/src/XML/src-gen/FMI1/fmi1_xml_variable_name_lex.h b/src/XML/src-gen/FMI1/fmi1_xml_variable_name_lex.h index 9e8b4946..6fbb689d 100644 --- a/src/XML/src-gen/FMI1/fmi1_xml_variable_name_lex.h +++ b/src/XML/src-gen/FMI1/fmi1_xml_variable_name_lex.h @@ -95,15 +95,15 @@ typedef unsigned int flex_uint32_t; /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST -#else /* ! __cplusplus */ +#else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const @@ -146,52 +146,52 @@ typedef size_t yy_size_t; #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; - }; + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ void yyfmi1restart (FILE *input_file ,yyscan_t yyscanner ); diff --git a/src/XML/src-gen/FMI1/fmi1_xml_variable_name_parser.tab.c b/src/XML/src-gen/FMI1/fmi1_xml_variable_name_parser.tab.c index 8c9803c5..9b68bfa9 100644 --- a/src/XML/src-gen/FMI1/fmi1_xml_variable_name_parser.tab.c +++ b/src/XML/src-gen/FMI1/fmi1_xml_variable_name_parser.tab.c @@ -87,7 +87,7 @@ int yydebug = 1; void yyfmi1error(yyscan_t* scanner, jm_callbacks* cb, char* name, char const *msg) { - jm_log_error(cb, MODULE, "Invalid structured ScalarVariable name \"%s\": %s", name, msg); + jm_log_error(cb, MODULE, "Invalid structured ScalarVariable name \"%s\": %s", name, msg); } @@ -302,7 +302,7 @@ YYID (yyi) # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -328,7 +328,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYFMI1STYPE_IS_TRIVIAL && YYFMI1STYPE_IS_TRIVIAL))) + || (defined YYFMI1STYPE_IS_TRIVIAL && YYFMI1STYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -353,15 +353,15 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ while (YYID (0)) #endif @@ -404,7 +404,7 @@ union yyalloc #define YYUNDEFTOK 2 #define YYMAXUTOK 261 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ @@ -567,14 +567,14 @@ static const yytype_uint8 yystos[] = 4, 18, 4, 8, 11, 7, 4 }; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily @@ -584,7 +584,7 @@ static const yytype_uint8 yystos[] = in Bison 2.4.2's NEWS entry, where a plan to phase it out is discussed. */ -#define YYFAIL goto yyerrlab +#define YYFAIL goto yyerrlab #if defined YYFAIL /* This is here to suppress warnings from the GCC cpp's -Wunused-macros. Normally we don't worry about that warning, but @@ -607,13 +607,13 @@ do \ else \ { \ yyerror (scanner, cb, name, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ + YYERROR; \ + } \ while (YYID (0)) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 /* This macro is provided for backward compatibility. */ @@ -637,21 +637,21 @@ while (YYID (0)) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ } while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, scanner, cb, name); \ - YYFPRINTF (stderr, "\n"); \ - } \ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, scanner, cb, name); \ + YYFPRINTF (stderr, "\n"); \ + } \ } while (YYID (0)) @@ -749,10 +749,10 @@ yy_stack_print (yybottom, yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) @@ -778,21 +778,21 @@ yy_reduce_print (yyvsp, yyrule, scanner, cb, name) int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , scanner, cb, name); + &(yyvsp[(yyi + 1) - (yynrhs)]) + , scanner, cb, name); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ yy_reduce_print (yyvsp, Rule, scanner, cb, name); \ } while (YYID (0)) @@ -808,7 +808,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -894,27 +894,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1239,23 +1239,23 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1263,22 +1263,22 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1287,10 +1287,10 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1488,20 +1488,20 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval, scanner, cb, name); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval, scanner, cb, name); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -1533,29 +1533,29 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp, scanner, cb, name); + yystos[yystate], yyvsp, scanner, cb, name); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1613,7 +1613,7 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, scanner, cb, name); + yystos[*yyssp], yyvsp, scanner, cb, name); YYPOPSTACK (1); } #ifndef yyoverflow diff --git a/src/XML/src-gen/FMI1/lex.yyfmi1.c b/src/XML/src-gen/FMI1/lex.yyfmi1.c index e0d43c12..f373cf6d 100644 --- a/src/XML/src-gen/FMI1/lex.yyfmi1.c +++ b/src/XML/src-gen/FMI1/lex.yyfmi1.c @@ -92,15 +92,15 @@ typedef unsigned int flex_uint32_t; /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST -#else /* ! __cplusplus */ +#else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const @@ -183,83 +183,83 @@ typedef size_t yy_size_t; /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyfmi1restart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyfmi1restart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ #define YY_BUFFER_EOF_PENDING 2 - }; + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the @@ -302,24 +302,24 @@ void yyfmi1free (void * ,yyscan_t yyscanner ); #define yy_new_buffer yyfmi1_create_buffer #define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ yyfmi1ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ + YY_CURRENT_BUFFER_LVALUE = \ yyfmi1_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } #define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ + { \ + if ( ! YY_CURRENT_BUFFER ){\ yyfmi1ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ + YY_CURRENT_BUFFER_LVALUE = \ yyfmi1_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) @@ -341,21 +341,21 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 13 #define YY_END_OF_BUFFER 14 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; static yyconst flex_int16_t yy_accept[27] = { 0, 0, 0, 14, 12, 13, 12, 2, 3, 5, 6, @@ -624,33 +624,33 @@ static int input (yyscan_t yyscanner ); */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ \ #endif @@ -701,522 +701,522 @@ extern int yyfmi1lex \ #endif #define YY_RULE_SETUP \ - YY_USER_ACTION + YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; #ifdef YY_USER_INIT - YY_USER_INIT; + YY_USER_INIT; #endif - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ - if ( ! yyin ) - yyin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! yyout ) - yyout = stdout; + if ( ! yyout ) + yyout = stdout; - if ( ! YY_CURRENT_BUFFER ) { - yyfmi1ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yyfmi1_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } + if ( ! YY_CURRENT_BUFFER ) { + yyfmi1ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yyfmi1_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } - yyfmi1_load_buffer_state(yyscanner ); - } + yyfmi1_load_buffer_state(yyscanner ); + } - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; - yy_current_state = yyg->yy_start; + yy_current_state = yyg->yy_start; yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 27 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 70 ); + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 27 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 70 ); yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; case 1: YY_RULE_SETUP {LEX_VAL(DER)} - YY_BREAK + YY_BREAK case 2: YY_RULE_SETUP {LEX_VAL('(')} - YY_BREAK + YY_BREAK case 3: YY_RULE_SETUP {LEX_VAL(')')} - YY_BREAK + YY_BREAK case 4: YY_RULE_SETUP {LEX_VAL(',')} - YY_BREAK + YY_BREAK case 5: YY_RULE_SETUP {LEX_VAL(',')} - YY_BREAK + YY_BREAK case 6: YY_RULE_SETUP {LEX_VAL('.')} - YY_BREAK + YY_BREAK case 7: YY_RULE_SETUP {LEX_VAL('[')} - YY_BREAK + YY_BREAK case 8: YY_RULE_SETUP {LEX_VAL(']')} - YY_BREAK + YY_BREAK case 9: /* rule 9 can match eol */ YY_RULE_SETUP {LEX_VAL(Q_NAME)} - YY_BREAK + YY_BREAK case 10: YY_RULE_SETUP {LEX_VAL(NONDIGIT)} - YY_BREAK + YY_BREAK case 11: YY_RULE_SETUP {LEX_VAL(UNSIGNED_INTEGER)} - YY_BREAK + YY_BREAK case 12: YY_RULE_SETUP {LEX_VAL(*yytext)} - YY_BREAK + YY_BREAK case 13: YY_RULE_SETUP ECHO; - YY_BREAK + YY_BREAK case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yyfmi1lex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yyfmi1wrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yyfmi1lex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yyfmi1wrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ } /* end of yyfmi1lex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - yy_size_t new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyfmi1realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyfmi1restart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyfmi1realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyfmi1realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyfmi1restart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyfmi1realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } - return ret_val; + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - register yy_state_type yy_current_state; - register char *yy_cp; + register yy_state_type yy_current_state; + register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 27 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 27 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis - * next_state = yy_try_NUL_trans( current_state ); + * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - register int yy_is_jam; + register int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 27 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 26); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 27 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 26); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; } static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) { - register char *yy_cp; + register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_cp = yyg->yy_c_buf_p; - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; + /* undo effects of setting up yytext */ + *yy_cp = yyg->yy_hold_char; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register yy_size_t number_to_move = yyg->yy_n_chars + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = yyg->yy_n_chars + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } - *--yy_cp = (char) c; + *--yy_cp = (char) c; - yyg->yytext_ptr = yy_bp; - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; + yyg->yytext_ptr = yy_bp; + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; } #ifndef YY_NO_INPUT @@ -1227,72 +1227,72 @@ static int yy_get_next_buffer (yyscan_t yyscanner) #endif { - int c; + int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyfmi1restart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yyfmi1wrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyfmi1restart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yyfmi1wrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; #ifdef __cplusplus - return yyinput(yyscanner); + return yyinput(yyscanner); #else - return input(yyscanner); + return input(yyscanner); #endif - } + } - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; - return c; + return c; } -#endif /* ifndef YY_NO_INPUT */ +#endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. @@ -1303,14 +1303,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! YY_CURRENT_BUFFER ){ + if ( ! YY_CURRENT_BUFFER ){ yyfmi1ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = + YY_CURRENT_BUFFER_LVALUE = yyfmi1_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } + } - yyfmi1_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - yyfmi1_load_buffer_state(yyscanner ); + yyfmi1_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + yyfmi1_load_buffer_state(yyscanner ); } /** Switch to a different input buffer. @@ -1321,41 +1321,41 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* TODO. We should be able to replace this entire function body - * with - * yyfmi1pop_buffer_state(); - * yyfmi1push_buffer_state(new_buffer); + /* TODO. We should be able to replace this entire function body + * with + * yyfmi1pop_buffer_state(); + * yyfmi1push_buffer_state(new_buffer); + */ + yyfmi1ensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yyfmi1_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yyfmi1wrap()) processing, but the only time this flag + * is looked at is after yyfmi1wrap() is called, so it's safe + * to go ahead and always set it. */ - yyfmi1ensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yyfmi1_load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yyfmi1wrap()) processing, but the only time this flag - * is looked at is after yyfmi1wrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + yyg->yy_did_buffer_switch_on_eof = 1; } static void yyfmi1_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. @@ -1366,26 +1366,26 @@ static void yyfmi1_load_buffer_state (yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi1_create_buffer (FILE * file, int size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyfmi1alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_create_buffer()" ); + b = (YY_BUFFER_STATE) yyfmi1alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_create_buffer()" ); - b->yy_buf_size = size; + b->yy_buf_size = size; - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyfmi1alloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_create_buffer()" ); + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyfmi1alloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_create_buffer()" ); - b->yy_is_our_buffer = 1; + b->yy_is_our_buffer = 1; - yyfmi1_init_buffer(b,file ,yyscanner); + yyfmi1_init_buffer(b,file ,yyscanner); - return b; + return b; } /** Destroy the buffer. @@ -1396,16 +1396,16 @@ static void yyfmi1_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; + if ( ! b ) + return; - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - if ( b->yy_is_our_buffer ) - yyfmi1free((void *) b->yy_ch_buf ,yyscanner ); + if ( b->yy_is_our_buffer ) + yyfmi1free((void *) b->yy_ch_buf ,yyscanner ); - yyfmi1free((void *) b ,yyscanner ); + yyfmi1free((void *) b ,yyscanner ); } /* Initializes or reinitializes a buffer. @@ -1415,13 +1415,13 @@ static void yyfmi1_load_buffer_state (yyscan_t yyscanner) static void yyfmi1_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { - int oerrno = errno; + int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyfmi1_flush_buffer(b ,yyscanner); + yyfmi1_flush_buffer(b ,yyscanner); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + b->yy_input_file = file; + b->yy_fill_buffer = 1; /* If b is the current buffer, then yyfmi1_init_buffer was _probably_ * called from yyfmi1restart() or through yy_get_next_buffer. @@ -1434,7 +1434,7 @@ static void yyfmi1_load_buffer_state (yyscan_t yyscanner) b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - errno = oerrno; + errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. @@ -1444,25 +1444,25 @@ static void yyfmi1_load_buffer_state (yyscan_t yyscanner) void yyfmi1_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; + if ( ! b ) + return; - b->yy_n_chars = 0; + b->yy_n_chars = 0; - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yy_ch_buf[0]; + b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == YY_CURRENT_BUFFER ) - yyfmi1_load_buffer_state(yyscanner ); + if ( b == YY_CURRENT_BUFFER ) + yyfmi1_load_buffer_state(yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1474,28 +1474,28 @@ static void yyfmi1_load_buffer_state (yyscan_t yyscanner) void yyfmi1push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyfmi1ensure_buffer_stack(yyscanner); - - /* This block is copied from yyfmi1_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yyfmi1_switch_to_buffer. */ - yyfmi1_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; + if (new_buffer == NULL) + return; + + yyfmi1ensure_buffer_stack(yyscanner); + + /* This block is copied from yyfmi1_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yyfmi1_switch_to_buffer. */ + yyfmi1_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. @@ -1505,18 +1505,18 @@ void yyfmi1push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) void yyfmi1pop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yyfmi1_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yyfmi1_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } + if (!YY_CURRENT_BUFFER) + return; + + yyfmi1_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yyfmi1_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } } /* Allocates the stack if it does not exist. @@ -1524,46 +1524,46 @@ void yyfmi1pop_buffer_state (yyscan_t yyscanner) */ static void yyfmi1ensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!yyg->yy_buffer_stack) { + if (!yyg->yy_buffer_stack) { - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi1alloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi1ensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi1realloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi1ensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi1alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi1ensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi1realloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi1ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } } /** Setup the input buffer state to scan directly from a user-specified character buffer. @@ -1574,31 +1574,31 @@ static void yyfmi1ensure_buffer_stack (yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi1_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyfmi1alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yyfmi1_switch_to_buffer(b ,yyscanner ); - - return b; + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyfmi1alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yyfmi1_switch_to_buffer(b ,yyscanner ); + + return b; } /** Setup the input buffer state to scan a string. The next call to yyfmi1lex() will @@ -1612,7 +1612,7 @@ YY_BUFFER_STATE yyfmi1_scan_buffer (char * base, yy_size_t size , yyscan_t yys YY_BUFFER_STATE yyfmi1_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - return yyfmi1_scan_bytes(yystr,strlen(yystr) ,yyscanner); + return yyfmi1_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to yyfmi1lex() will @@ -1624,32 +1624,32 @@ YY_BUFFER_STATE yyfmi1_scan_string (yyconst char * yystr , yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi1_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyfmi1alloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_scan_bytes()" ); + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) yyfmi1alloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi1_scan_bytes()" ); - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yyfmi1_scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yyfmi1_scan_bytes()" ); + b = yyfmi1_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yyfmi1_scan_bytes()" ); - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; - return b; + return b; } #ifndef YY_EXIT_FAILURE @@ -1658,26 +1658,26 @@ YY_BUFFER_STATE yyfmi1_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ @@ -1884,9 +1884,9 @@ int yyfmi1lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) yyfmi1alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; @@ -1940,15 +1940,15 @@ int yyfmi1lex_destroy (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yyfmi1_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yyfmi1pop_buffer_state(yyscanner); - } + while(YY_CURRENT_BUFFER){ + yyfmi1_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yyfmi1pop_buffer_state(yyscanner); + } - /* Destroy the stack itself. */ - yyfmi1free(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; + /* Destroy the stack itself. */ + yyfmi1free(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ yyfmi1free(yyg->yy_start_stack ,yyscanner ); @@ -1971,43 +1971,43 @@ int yyfmi1lex_destroy (yyscan_t yyscanner) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) { - register int n; - for ( n = 0; s[n]; ++n ) - ; + register int n; + for ( n = 0; s[n]; ++n ) + ; - return n; + return n; } #endif void *yyfmi1alloc (yy_size_t size , yyscan_t yyscanner) { - return (void *) malloc( size ); + return (void *) malloc( size ); } void *yyfmi1realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); } void yyfmi1free (void * ptr , yyscan_t yyscanner) { - free( (char *) ptr ); /* see yyfmi1realloc() for (char *) cast */ + free( (char *) ptr ); /* see yyfmi1realloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" diff --git a/src/XML/src-gen/FMI2/fmi2_xml_variable_name_lex.h b/src/XML/src-gen/FMI2/fmi2_xml_variable_name_lex.h index 3759e957..04106e88 100644 --- a/src/XML/src-gen/FMI2/fmi2_xml_variable_name_lex.h +++ b/src/XML/src-gen/FMI2/fmi2_xml_variable_name_lex.h @@ -95,15 +95,15 @@ typedef unsigned int flex_uint32_t; /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST -#else /* ! __cplusplus */ +#else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const @@ -146,52 +146,52 @@ typedef size_t yy_size_t; #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; - }; + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ void yyfmi2restart (FILE *input_file ,yyscan_t yyscanner ); diff --git a/src/XML/src-gen/FMI2/fmi2_xml_variable_name_parser.tab.c b/src/XML/src-gen/FMI2/fmi2_xml_variable_name_parser.tab.c index 8e966ce5..909fa722 100644 --- a/src/XML/src-gen/FMI2/fmi2_xml_variable_name_parser.tab.c +++ b/src/XML/src-gen/FMI2/fmi2_xml_variable_name_parser.tab.c @@ -87,7 +87,7 @@ int yydebug = 1; void yyfmi2error(yyscan_t* scanner, jm_callbacks* cb, char* name, char const *msg) { - jm_log_error(cb, MODULE, "Invalid structured ScalarVariable name \"%s\": %s", name, msg); + jm_log_error(cb, MODULE, "Invalid structured ScalarVariable name \"%s\": %s", name, msg); } @@ -302,7 +302,7 @@ YYID (yyi) # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -328,7 +328,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYFMI2STYPE_IS_TRIVIAL && YYFMI2STYPE_IS_TRIVIAL))) + || (defined YYFMI2STYPE_IS_TRIVIAL && YYFMI2STYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -353,15 +353,15 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ while (YYID (0)) #endif @@ -404,7 +404,7 @@ union yyalloc #define YYUNDEFTOK 2 #define YYMAXUTOK 261 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ @@ -567,14 +567,14 @@ static const yytype_uint8 yystos[] = 4, 18, 4, 8, 11, 7, 4 }; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily @@ -584,7 +584,7 @@ static const yytype_uint8 yystos[] = in Bison 2.4.2's NEWS entry, where a plan to phase it out is discussed. */ -#define YYFAIL goto yyerrlab +#define YYFAIL goto yyerrlab #if defined YYFAIL /* This is here to suppress warnings from the GCC cpp's -Wunused-macros. Normally we don't worry about that warning, but @@ -607,13 +607,13 @@ do \ else \ { \ yyerror (scanner, cb, name, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ + YYERROR; \ + } \ while (YYID (0)) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 /* This macro is provided for backward compatibility. */ @@ -637,21 +637,21 @@ while (YYID (0)) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ } while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, scanner, cb, name); \ - YYFPRINTF (stderr, "\n"); \ - } \ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, scanner, cb, name); \ + YYFPRINTF (stderr, "\n"); \ + } \ } while (YYID (0)) @@ -749,10 +749,10 @@ yy_stack_print (yybottom, yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) @@ -778,21 +778,21 @@ yy_reduce_print (yyvsp, yyrule, scanner, cb, name) int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , scanner, cb, name); + &(yyvsp[(yyi + 1) - (yynrhs)]) + , scanner, cb, name); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ yy_reduce_print (yyvsp, Rule, scanner, cb, name); \ } while (YYID (0)) @@ -808,7 +808,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -894,27 +894,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1239,23 +1239,23 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1263,22 +1263,22 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1287,10 +1287,10 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1488,20 +1488,20 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval, scanner, cb, name); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval, scanner, cb, name); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -1533,29 +1533,29 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp, scanner, cb, name); + yystos[yystate], yyvsp, scanner, cb, name); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1613,7 +1613,7 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, scanner, cb, name); + yystos[*yyssp], yyvsp, scanner, cb, name); YYPOPSTACK (1); } #ifndef yyoverflow diff --git a/src/XML/src-gen/FMI2/lex.yyfmi2.c b/src/XML/src-gen/FMI2/lex.yyfmi2.c index 571cf81b..7acf6cbf 100644 --- a/src/XML/src-gen/FMI2/lex.yyfmi2.c +++ b/src/XML/src-gen/FMI2/lex.yyfmi2.c @@ -92,15 +92,15 @@ typedef unsigned int flex_uint32_t; /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST -#else /* ! __cplusplus */ +#else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const @@ -183,83 +183,83 @@ typedef size_t yy_size_t; /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyfmi2restart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyfmi2restart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ #define YY_BUFFER_EOF_PENDING 2 - }; + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the @@ -302,24 +302,24 @@ void yyfmi2free (void * ,yyscan_t yyscanner ); #define yy_new_buffer yyfmi2_create_buffer #define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ yyfmi2ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ + YY_CURRENT_BUFFER_LVALUE = \ yyfmi2_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } #define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ + { \ + if ( ! YY_CURRENT_BUFFER ){\ yyfmi2ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ + YY_CURRENT_BUFFER_LVALUE = \ yyfmi2_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) @@ -341,21 +341,21 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 12 #define YY_END_OF_BUFFER 13 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; static yyconst flex_int16_t yy_accept[25] = { 0, 0, 0, 13, 11, 12, 11, 2, 3, 4, 5, @@ -619,33 +619,33 @@ static int input (yyscan_t yyscanner ); */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ \ #endif @@ -696,517 +696,517 @@ extern int yyfmi2lex \ #endif #define YY_RULE_SETUP \ - YY_USER_ACTION + YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; #ifdef YY_USER_INIT - YY_USER_INIT; + YY_USER_INIT; #endif - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ - if ( ! yyin ) - yyin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! yyout ) - yyout = stdout; + if ( ! yyout ) + yyout = stdout; - if ( ! YY_CURRENT_BUFFER ) { - yyfmi2ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yyfmi2_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } + if ( ! YY_CURRENT_BUFFER ) { + yyfmi2ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yyfmi2_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } - yyfmi2_load_buffer_state(yyscanner ); - } + yyfmi2_load_buffer_state(yyscanner ); + } - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; - yy_current_state = yyg->yy_start; + yy_current_state = yyg->yy_start; yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 25 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 56 ); + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 25 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 56 ); yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; case 1: YY_RULE_SETUP {LEX_VAL(DER)} - YY_BREAK + YY_BREAK case 2: YY_RULE_SETUP {LEX_VAL('(')} - YY_BREAK + YY_BREAK case 3: YY_RULE_SETUP {LEX_VAL(')')} - YY_BREAK + YY_BREAK case 4: YY_RULE_SETUP {LEX_VAL(',')} - YY_BREAK + YY_BREAK case 5: YY_RULE_SETUP {LEX_VAL('.')} - YY_BREAK + YY_BREAK case 6: YY_RULE_SETUP {LEX_VAL('[')} - YY_BREAK + YY_BREAK case 7: YY_RULE_SETUP {LEX_VAL(']')} - YY_BREAK + YY_BREAK case 8: YY_RULE_SETUP {LEX_VAL(Q_NAME)} - YY_BREAK + YY_BREAK case 9: YY_RULE_SETUP {LEX_VAL(NONDIGIT)} - YY_BREAK + YY_BREAK case 10: YY_RULE_SETUP {LEX_VAL(UNSIGNED_INTEGER);} - YY_BREAK + YY_BREAK case 11: YY_RULE_SETUP {LEX_VAL(*yytext)} - YY_BREAK + YY_BREAK case 12: YY_RULE_SETUP ECHO; - YY_BREAK + YY_BREAK case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yyfmi2lex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yyfmi2wrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yyfmi2lex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yyfmi2wrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ } /* end of yyfmi2lex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - yy_size_t new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyfmi2realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyfmi2restart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyfmi2realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyfmi2realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyfmi2restart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyfmi2realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } - return ret_val; + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - register yy_state_type yy_current_state; - register char *yy_cp; + register yy_state_type yy_current_state; + register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 25 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 25 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis - * next_state = yy_try_NUL_trans( current_state ); + * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - register int yy_is_jam; + register int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 25 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 24); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 25 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 24); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; } static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) { - register char *yy_cp; + register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_cp = yyg->yy_c_buf_p; - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; + /* undo effects of setting up yytext */ + *yy_cp = yyg->yy_hold_char; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register yy_size_t number_to_move = yyg->yy_n_chars + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = yyg->yy_n_chars + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } - *--yy_cp = (char) c; + *--yy_cp = (char) c; - yyg->yytext_ptr = yy_bp; - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; + yyg->yytext_ptr = yy_bp; + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; } #ifndef YY_NO_INPUT @@ -1217,72 +1217,72 @@ static int yy_get_next_buffer (yyscan_t yyscanner) #endif { - int c; + int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyfmi2restart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yyfmi2wrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyfmi2restart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yyfmi2wrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; #ifdef __cplusplus - return yyinput(yyscanner); + return yyinput(yyscanner); #else - return input(yyscanner); + return input(yyscanner); #endif - } + } - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; - return c; + return c; } -#endif /* ifndef YY_NO_INPUT */ +#endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. @@ -1293,14 +1293,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! YY_CURRENT_BUFFER ){ + if ( ! YY_CURRENT_BUFFER ){ yyfmi2ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = + YY_CURRENT_BUFFER_LVALUE = yyfmi2_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } + } - yyfmi2_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - yyfmi2_load_buffer_state(yyscanner ); + yyfmi2_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + yyfmi2_load_buffer_state(yyscanner ); } /** Switch to a different input buffer. @@ -1311,41 +1311,41 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* TODO. We should be able to replace this entire function body - * with - * yyfmi2pop_buffer_state(); - * yyfmi2push_buffer_state(new_buffer); + /* TODO. We should be able to replace this entire function body + * with + * yyfmi2pop_buffer_state(); + * yyfmi2push_buffer_state(new_buffer); + */ + yyfmi2ensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yyfmi2_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yyfmi2wrap()) processing, but the only time this flag + * is looked at is after yyfmi2wrap() is called, so it's safe + * to go ahead and always set it. */ - yyfmi2ensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yyfmi2_load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yyfmi2wrap()) processing, but the only time this flag - * is looked at is after yyfmi2wrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + yyg->yy_did_buffer_switch_on_eof = 1; } static void yyfmi2_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. @@ -1356,26 +1356,26 @@ static void yyfmi2_load_buffer_state (yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi2_create_buffer (FILE * file, int size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyfmi2alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_create_buffer()" ); + b = (YY_BUFFER_STATE) yyfmi2alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_create_buffer()" ); - b->yy_buf_size = size; + b->yy_buf_size = size; - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyfmi2alloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_create_buffer()" ); + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyfmi2alloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_create_buffer()" ); - b->yy_is_our_buffer = 1; + b->yy_is_our_buffer = 1; - yyfmi2_init_buffer(b,file ,yyscanner); + yyfmi2_init_buffer(b,file ,yyscanner); - return b; + return b; } /** Destroy the buffer. @@ -1386,16 +1386,16 @@ static void yyfmi2_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; + if ( ! b ) + return; - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - if ( b->yy_is_our_buffer ) - yyfmi2free((void *) b->yy_ch_buf ,yyscanner ); + if ( b->yy_is_our_buffer ) + yyfmi2free((void *) b->yy_ch_buf ,yyscanner ); - yyfmi2free((void *) b ,yyscanner ); + yyfmi2free((void *) b ,yyscanner ); } /* Initializes or reinitializes a buffer. @@ -1405,13 +1405,13 @@ static void yyfmi2_load_buffer_state (yyscan_t yyscanner) static void yyfmi2_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { - int oerrno = errno; + int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyfmi2_flush_buffer(b ,yyscanner); + yyfmi2_flush_buffer(b ,yyscanner); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + b->yy_input_file = file; + b->yy_fill_buffer = 1; /* If b is the current buffer, then yyfmi2_init_buffer was _probably_ * called from yyfmi2restart() or through yy_get_next_buffer. @@ -1424,7 +1424,7 @@ static void yyfmi2_load_buffer_state (yyscan_t yyscanner) b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - errno = oerrno; + errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. @@ -1434,25 +1434,25 @@ static void yyfmi2_load_buffer_state (yyscan_t yyscanner) void yyfmi2_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; + if ( ! b ) + return; - b->yy_n_chars = 0; + b->yy_n_chars = 0; - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yy_ch_buf[0]; + b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == YY_CURRENT_BUFFER ) - yyfmi2_load_buffer_state(yyscanner ); + if ( b == YY_CURRENT_BUFFER ) + yyfmi2_load_buffer_state(yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1464,28 +1464,28 @@ static void yyfmi2_load_buffer_state (yyscan_t yyscanner) void yyfmi2push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyfmi2ensure_buffer_stack(yyscanner); - - /* This block is copied from yyfmi2_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yyfmi2_switch_to_buffer. */ - yyfmi2_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; + if (new_buffer == NULL) + return; + + yyfmi2ensure_buffer_stack(yyscanner); + + /* This block is copied from yyfmi2_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yyfmi2_switch_to_buffer. */ + yyfmi2_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. @@ -1495,18 +1495,18 @@ void yyfmi2push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) void yyfmi2pop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yyfmi2_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yyfmi2_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } + if (!YY_CURRENT_BUFFER) + return; + + yyfmi2_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yyfmi2_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } } /* Allocates the stack if it does not exist. @@ -1514,46 +1514,46 @@ void yyfmi2pop_buffer_state (yyscan_t yyscanner) */ static void yyfmi2ensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!yyg->yy_buffer_stack) { + if (!yyg->yy_buffer_stack) { - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi2alloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi2ensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi2realloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi2ensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi2alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi2ensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi2realloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi2ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } } /** Setup the input buffer state to scan directly from a user-specified character buffer. @@ -1564,31 +1564,31 @@ static void yyfmi2ensure_buffer_stack (yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi2_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyfmi2alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yyfmi2_switch_to_buffer(b ,yyscanner ); - - return b; + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyfmi2alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yyfmi2_switch_to_buffer(b ,yyscanner ); + + return b; } /** Setup the input buffer state to scan a string. The next call to yyfmi2lex() will @@ -1602,7 +1602,7 @@ YY_BUFFER_STATE yyfmi2_scan_buffer (char * base, yy_size_t size , yyscan_t yys YY_BUFFER_STATE yyfmi2_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - return yyfmi2_scan_bytes(yystr,strlen(yystr) ,yyscanner); + return yyfmi2_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to yyfmi2lex() will @@ -1614,32 +1614,32 @@ YY_BUFFER_STATE yyfmi2_scan_string (yyconst char * yystr , yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi2_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyfmi2alloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_scan_bytes()" ); + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) yyfmi2alloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi2_scan_bytes()" ); - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yyfmi2_scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yyfmi2_scan_bytes()" ); + b = yyfmi2_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yyfmi2_scan_bytes()" ); - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; - return b; + return b; } #ifndef YY_EXIT_FAILURE @@ -1648,26 +1648,26 @@ YY_BUFFER_STATE yyfmi2_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ @@ -1874,9 +1874,9 @@ int yyfmi2lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) yyfmi2alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; @@ -1930,15 +1930,15 @@ int yyfmi2lex_destroy (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yyfmi2_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yyfmi2pop_buffer_state(yyscanner); - } + while(YY_CURRENT_BUFFER){ + yyfmi2_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yyfmi2pop_buffer_state(yyscanner); + } - /* Destroy the stack itself. */ - yyfmi2free(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; + /* Destroy the stack itself. */ + yyfmi2free(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ yyfmi2free(yyg->yy_start_stack ,yyscanner ); @@ -1961,43 +1961,43 @@ int yyfmi2lex_destroy (yyscan_t yyscanner) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) { - register int n; - for ( n = 0; s[n]; ++n ) - ; + register int n; + for ( n = 0; s[n]; ++n ) + ; - return n; + return n; } #endif void *yyfmi2alloc (yy_size_t size , yyscan_t yyscanner) { - return (void *) malloc( size ); + return (void *) malloc( size ); } void *yyfmi2realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); } void yyfmi2free (void * ptr , yyscan_t yyscanner) { - free( (char *) ptr ); /* see yyfmi2realloc() for (char *) cast */ + free( (char *) ptr ); /* see yyfmi2realloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" diff --git a/src/XML/src-gen/FMI3/fmi3_xml_variable_name_lex.h b/src/XML/src-gen/FMI3/fmi3_xml_variable_name_lex.h index 6bd1570c..b8f9298b 100644 --- a/src/XML/src-gen/FMI3/fmi3_xml_variable_name_lex.h +++ b/src/XML/src-gen/FMI3/fmi3_xml_variable_name_lex.h @@ -214,52 +214,52 @@ typedef size_t yy_size_t; #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; - }; + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ void yyfmi3restart ( FILE *input_file , yyscan_t yyscanner ); @@ -325,7 +325,7 @@ FILE *yyfmi3get_out ( yyscan_t yyscanner ); void yyfmi3set_out ( FILE * _out_str , yyscan_t yyscanner ); - int yyfmi3get_leng ( yyscan_t yyscanner ); + int yyfmi3get_leng ( yyscan_t yyscanner ); char *yyfmi3get_text ( yyscan_t yyscanner ); diff --git a/src/XML/src-gen/FMI3/fmi3_xml_variable_name_parser.tab.c b/src/XML/src-gen/FMI3/fmi3_xml_variable_name_parser.tab.c index 78fce48d..7d810012 100644 --- a/src/XML/src-gen/FMI3/fmi3_xml_variable_name_parser.tab.c +++ b/src/XML/src-gen/FMI3/fmi3_xml_variable_name_parser.tab.c @@ -87,7 +87,7 @@ int yydebug = 1; void yyfmi3error(yyscan_t* scanner, jm_callbacks* cb, char* name, char const *msg) { - jm_log_error(cb, MODULE, "Invalid structured ScalarVariable name \"%s\": %s", name, msg); + jm_log_error(cb, MODULE, "Invalid structured ScalarVariable name \"%s\": %s", name, msg); } @@ -302,7 +302,7 @@ YYID (yyi) # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -328,7 +328,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYFMI3STYPE_IS_TRIVIAL && YYFMI3STYPE_IS_TRIVIAL))) + || (defined YYFMI3STYPE_IS_TRIVIAL && YYFMI3STYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -353,15 +353,15 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ while (YYID (0)) #endif @@ -404,7 +404,7 @@ union yyalloc #define YYUNDEFTOK 2 #define YYMAXUTOK 261 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ @@ -567,14 +567,14 @@ static const yytype_uint8 yystos[] = 4, 18, 4, 8, 11, 7, 4 }; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily @@ -584,7 +584,7 @@ static const yytype_uint8 yystos[] = in Bison 2.4.2's NEWS entry, where a plan to phase it out is discussed. */ -#define YYFAIL goto yyerrlab +#define YYFAIL goto yyerrlab #if defined YYFAIL /* This is here to suppress warnings from the GCC cpp's -Wunused-macros. Normally we don't worry about that warning, but @@ -607,13 +607,13 @@ do \ else \ { \ yyerror (scanner, cb, name, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ + YYERROR; \ + } \ while (YYID (0)) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 /* This macro is provided for backward compatibility. */ @@ -637,21 +637,21 @@ while (YYID (0)) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ } while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, scanner, cb, name); \ - YYFPRINTF (stderr, "\n"); \ - } \ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, scanner, cb, name); \ + YYFPRINTF (stderr, "\n"); \ + } \ } while (YYID (0)) @@ -749,10 +749,10 @@ yy_stack_print (yybottom, yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) @@ -778,21 +778,21 @@ yy_reduce_print (yyvsp, yyrule, scanner, cb, name) int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , scanner, cb, name); + &(yyvsp[(yyi + 1) - (yynrhs)]) + , scanner, cb, name); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ yy_reduce_print (yyvsp, Rule, scanner, cb, name); \ } while (YYID (0)) @@ -808,7 +808,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -894,27 +894,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1239,23 +1239,23 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1263,22 +1263,22 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1287,10 +1287,10 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1488,20 +1488,20 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval, scanner, cb, name); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval, scanner, cb, name); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -1533,29 +1533,29 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp, scanner, cb, name); + yystos[yystate], yyvsp, scanner, cb, name); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1613,7 +1613,7 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, scanner, cb, name); + yystos[*yyssp], yyvsp, scanner, cb, name); YYPOPSTACK (1); } #ifndef yyoverflow diff --git a/src/XML/src-gen/FMI3/lex.yyfmi3.c b/src/XML/src-gen/FMI3/lex.yyfmi3.c index 7205d6d5..e47a2cea 100644 --- a/src/XML/src-gen/FMI3/lex.yyfmi3.c +++ b/src/XML/src-gen/FMI3/lex.yyfmi3.c @@ -246,82 +246,82 @@ typedef size_t yy_size_t; /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyfmi3restart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyfmi3restart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ #define YY_BUFFER_EOF_PENDING 2 - }; + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the @@ -361,23 +361,23 @@ void yyfmi3free ( void * , yyscan_t yyscanner ); #define yy_new_buffer yyfmi3_create_buffer #define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ yyfmi3ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ + YY_CURRENT_BUFFER_LVALUE = \ yyfmi3_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } #define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ + { \ + if ( ! YY_CURRENT_BUFFER ){\ yyfmi3ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ + YY_CURRENT_BUFFER_LVALUE = \ yyfmi3_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) #define yyfmi3wrap(yyscanner) (/*CONSTCOND*/1) @@ -397,20 +397,20 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; + yyg->yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 12 #define YY_END_OF_BUFFER 13 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; static const flex_int16_t yy_accept[25] = { 0, 0, 0, 13, 11, 12, 11, 2, 3, 4, 5, @@ -603,7 +603,7 @@ FILE *yyfmi3get_out ( yyscan_t yyscanner ); void yyfmi3set_out ( FILE * _out_str , yyscan_t yyscanner ); - int yyfmi3get_leng ( yyscan_t yyscanner ); + int yyfmi3get_leng ( yyscan_t yyscanner ); char *yyfmi3get_text ( yyscan_t yyscanner ); @@ -677,33 +677,33 @@ static int input ( yyscan_t yyscanner ); */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ \ #endif @@ -754,522 +754,522 @@ extern int yyfmi3lex \ #endif #define YY_RULE_SETUP \ - YY_USER_ACTION + YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; #ifdef YY_USER_INIT - YY_USER_INIT; + YY_USER_INIT; #endif - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ - if ( ! yyin ) - yyin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! yyout ) - yyout = stdout; + if ( ! yyout ) + yyout = stdout; - if ( ! YY_CURRENT_BUFFER ) { - yyfmi3ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yyfmi3_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } + if ( ! YY_CURRENT_BUFFER ) { + yyfmi3ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yyfmi3_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } - yyfmi3_load_buffer_state(yyscanner ); - } + yyfmi3_load_buffer_state(yyscanner ); + } - { + { - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; - yy_current_state = yyg->yy_start; + yy_current_state = yyg->yy_start; yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 25 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 56 ); + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 25 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 56 ); yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; case 1: YY_RULE_SETUP {LEX_VAL(DER)} - YY_BREAK + YY_BREAK case 2: YY_RULE_SETUP {LEX_VAL('(')} - YY_BREAK + YY_BREAK case 3: YY_RULE_SETUP {LEX_VAL(')')} - YY_BREAK + YY_BREAK case 4: YY_RULE_SETUP {LEX_VAL(',')} - YY_BREAK + YY_BREAK case 5: YY_RULE_SETUP {LEX_VAL('.')} - YY_BREAK + YY_BREAK case 6: YY_RULE_SETUP {LEX_VAL('[')} - YY_BREAK + YY_BREAK case 7: YY_RULE_SETUP {LEX_VAL(']')} - YY_BREAK + YY_BREAK case 8: YY_RULE_SETUP {LEX_VAL(Q_NAME)} - YY_BREAK + YY_BREAK case 9: YY_RULE_SETUP {LEX_VAL(NONDIGIT)} - YY_BREAK + YY_BREAK case 10: YY_RULE_SETUP {LEX_VAL(UNSIGNED_INTEGER);} - YY_BREAK + YY_BREAK case 11: YY_RULE_SETUP {LEX_VAL(*yytext)} - YY_BREAK + YY_BREAK case 12: YY_RULE_SETUP ECHO; - YY_BREAK + YY_BREAK case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yyfmi3lex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yyfmi3wrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yyfmi3lex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yyfmi3wrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ } /* end of yyfmi3lex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyfmi3realloc((void *) b->yy_ch_buf,(yy_size_t) (b->yy_buf_size + 2) ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyfmi3restart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyfmi3realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,(yy_size_t) new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyfmi3realloc((void *) b->yy_ch_buf,(yy_size_t) (b->yy_buf_size + 2) ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyfmi3restart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyfmi3realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,(yy_size_t) new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } - return ret_val; + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - yy_state_type yy_current_state; - char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 25 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 25 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis - * next_state = yy_try_NUL_trans( current_state ); + * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - int yy_is_jam; + int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 25 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 24); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 25 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 24); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT static void yyunput (int c, char * yy_bp , yyscan_t yyscanner) { - char *yy_cp; + char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_cp = yyg->yy_c_buf_p; - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; + /* undo effects of setting up yytext */ + *yy_cp = yyg->yy_hold_char; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - int number_to_move = yyg->yy_n_chars + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = yyg->yy_n_chars + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - yyg->yy_n_chars = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + yyg->yy_n_chars = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } - *--yy_cp = (char) c; + *--yy_cp = (char) c; - yyg->yytext_ptr = yy_bp; - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; + yyg->yytext_ptr = yy_bp; + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; } #endif @@ -1282,72 +1282,72 @@ static int yy_get_next_buffer (yyscan_t yyscanner) #endif { - int c; + int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyfmi3restart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yyfmi3wrap(yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyfmi3restart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yyfmi3wrap(yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; #ifdef __cplusplus - return yyinput(yyscanner); + return yyinput(yyscanner); #else - return input(yyscanner); + return input(yyscanner); #endif - } + } - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; - return c; + return c; } -#endif /* ifndef YY_NO_INPUT */ +#endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. @@ -1358,14 +1358,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! YY_CURRENT_BUFFER ){ + if ( ! YY_CURRENT_BUFFER ){ yyfmi3ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = + YY_CURRENT_BUFFER_LVALUE = yyfmi3_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } + } - yyfmi3_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - yyfmi3_load_buffer_state(yyscanner ); + yyfmi3_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + yyfmi3_load_buffer_state(yyscanner ); } /** Switch to a different input buffer. @@ -1376,41 +1376,41 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* TODO. We should be able to replace this entire function body - * with - * yyfmi3pop_buffer_state(); - * yyfmi3push_buffer_state(new_buffer); + /* TODO. We should be able to replace this entire function body + * with + * yyfmi3pop_buffer_state(); + * yyfmi3push_buffer_state(new_buffer); */ - yyfmi3ensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yyfmi3_load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yyfmi3wrap()) processing, but the only time this flag - * is looked at is after yyfmi3wrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + yyfmi3ensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yyfmi3_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yyfmi3wrap()) processing, but the only time this flag + * is looked at is after yyfmi3wrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; } static void yyfmi3_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. @@ -1421,26 +1421,26 @@ static void yyfmi3_load_buffer_state (yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi3_create_buffer (FILE * file, int size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyfmi3alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_create_buffer()" ); + b = (YY_BUFFER_STATE) yyfmi3alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_create_buffer()" ); - b->yy_buf_size = size; + b->yy_buf_size = size; - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyfmi3alloc((yy_size_t) (b->yy_buf_size + 2) ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_create_buffer()" ); + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyfmi3alloc((yy_size_t) (b->yy_buf_size + 2) ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_create_buffer()" ); - b->yy_is_our_buffer = 1; + b->yy_is_our_buffer = 1; - yyfmi3_init_buffer(b,file ,yyscanner); + yyfmi3_init_buffer(b,file ,yyscanner); - return b; + return b; } /** Destroy the buffer. @@ -1451,16 +1451,16 @@ static void yyfmi3_load_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; + if ( ! b ) + return; - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - if ( b->yy_is_our_buffer ) - yyfmi3free((void *) b->yy_ch_buf ,yyscanner ); + if ( b->yy_is_our_buffer ) + yyfmi3free((void *) b->yy_ch_buf ,yyscanner ); - yyfmi3free((void *) b ,yyscanner ); + yyfmi3free((void *) b ,yyscanner ); } /* Initializes or reinitializes a buffer. @@ -1470,13 +1470,13 @@ static void yyfmi3_load_buffer_state (yyscan_t yyscanner) static void yyfmi3_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { - int oerrno = errno; + int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyfmi3_flush_buffer(b ,yyscanner); + yyfmi3_flush_buffer(b ,yyscanner); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + b->yy_input_file = file; + b->yy_fill_buffer = 1; /* If b is the current buffer, then yyfmi3_init_buffer was _probably_ * called from yyfmi3restart() or through yy_get_next_buffer. @@ -1489,7 +1489,7 @@ static void yyfmi3_load_buffer_state (yyscan_t yyscanner) b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - errno = oerrno; + errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. @@ -1499,25 +1499,25 @@ static void yyfmi3_load_buffer_state (yyscan_t yyscanner) void yyfmi3_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; + if ( ! b ) + return; - b->yy_n_chars = 0; + b->yy_n_chars = 0; - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yy_ch_buf[0]; + b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == YY_CURRENT_BUFFER ) - yyfmi3_load_buffer_state(yyscanner ); + if ( b == YY_CURRENT_BUFFER ) + yyfmi3_load_buffer_state(yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1529,28 +1529,28 @@ static void yyfmi3_load_buffer_state (yyscan_t yyscanner) void yyfmi3push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyfmi3ensure_buffer_stack(yyscanner); - - /* This block is copied from yyfmi3_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yyfmi3_switch_to_buffer. */ - yyfmi3_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; + if (new_buffer == NULL) + return; + + yyfmi3ensure_buffer_stack(yyscanner); + + /* This block is copied from yyfmi3_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yyfmi3_switch_to_buffer. */ + yyfmi3_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. @@ -1560,18 +1560,18 @@ void yyfmi3push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) void yyfmi3pop_buffer_state (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yyfmi3_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yyfmi3_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } + if (!YY_CURRENT_BUFFER) + return; + + yyfmi3_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yyfmi3_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } } /* Allocates the stack if it does not exist. @@ -1579,46 +1579,46 @@ void yyfmi3pop_buffer_state (yyscan_t yyscanner) */ static void yyfmi3ensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!yyg->yy_buffer_stack) { + if (!yyg->yy_buffer_stack) { - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi3alloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi3ensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi3realloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi3ensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi3alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi3ensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyfmi3realloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi3ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } } /** Setup the input buffer state to scan directly from a user-specified character buffer. @@ -1629,31 +1629,31 @@ static void yyfmi3ensure_buffer_stack (yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi3_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyfmi3alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yyfmi3_switch_to_buffer(b ,yyscanner ); - - return b; + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyfmi3alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yyfmi3_switch_to_buffer(b ,yyscanner ); + + return b; } /** Setup the input buffer state to scan a string. The next call to yyfmi3lex() will @@ -1667,7 +1667,7 @@ YY_BUFFER_STATE yyfmi3_scan_buffer (char * base, yy_size_t size , yyscan_t yys YY_BUFFER_STATE yyfmi3_scan_string (const char * yystr , yyscan_t yyscanner) { - return yyfmi3_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); + return yyfmi3_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to yyfmi3lex() will @@ -1679,32 +1679,32 @@ YY_BUFFER_STATE yyfmi3_scan_string (const char * yystr , yyscan_t yyscanner) */ YY_BUFFER_STATE yyfmi3_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyfmi3alloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_scan_bytes()" ); + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyfmi3alloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yyfmi3_scan_bytes()" ); - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yyfmi3_scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yyfmi3_scan_bytes()" ); + b = yyfmi3_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yyfmi3_scan_bytes()" ); - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; - return b; + return b; } #ifndef YY_EXIT_FAILURE @@ -1713,28 +1713,28 @@ YY_BUFFER_STATE yyfmi3_scan_bytes (const char * yybytes, int _yybytes_len , yy static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ @@ -1993,15 +1993,15 @@ int yyfmi3lex_destroy (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yyfmi3_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yyfmi3pop_buffer_state(yyscanner); - } + while(YY_CURRENT_BUFFER){ + yyfmi3_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yyfmi3pop_buffer_state(yyscanner); + } - /* Destroy the stack itself. */ - yyfmi3free(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; + /* Destroy the stack itself. */ + yyfmi3free(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ yyfmi3free(yyg->yy_start_stack ,yyscanner ); @@ -2024,53 +2024,53 @@ int yyfmi3lex_destroy (yyscan_t yyscanner) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { - int n; - for ( n = 0; s[n]; ++n ) - ; + int n; + for ( n = 0; s[n]; ++n ) + ; - return n; + return n; } #endif void *yyfmi3alloc (yy_size_t size , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); } void *yyfmi3realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); } void yyfmi3free (void * ptr , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyfmi3realloc() for (char *) cast */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyfmi3realloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" diff --git a/src/XML/src/FMI/fmi_xml_context.c b/src/XML/src/FMI/fmi_xml_context.c index b6a040df..4f5a7c95 100644 --- a/src/XML/src/FMI/fmi_xml_context.c +++ b/src/XML/src/FMI/fmi_xml_context.c @@ -22,10 +22,10 @@ static char* MODULE="FMIXML"; fmi_xml_context_t* fmi_xml_allocate_context( jm_callbacks* callbacks) { - jm_callbacks* cb; - fmi_xml_context_t* c; + jm_callbacks* cb; + fmi_xml_context_t* c; - jm_log_debug(callbacks, MODULE, "Allocating context for XML parsing module"); + jm_log_debug(callbacks, MODULE, "Allocating context for XML parsing module"); if(callbacks) { cb = callbacks; @@ -35,19 +35,19 @@ fmi_xml_context_t* fmi_xml_allocate_context( jm_callbacks* callbacks) { } c = cb->malloc(sizeof(fmi_xml_context_t)); if(!c) { - jm_log_fatal(callbacks, MODULE, "Could not allocate memory"); - return 0; - } - c->callbacks = callbacks; - c->parser = 0; - c->fmi_version = fmi_version_unknown_enu; + jm_log_fatal(callbacks, MODULE, "Could not allocate memory"); + return 0; + } + c->callbacks = callbacks; + c->parser = 0; + c->fmi_version = fmi_version_unknown_enu; c->configuration = 0; - jm_log_debug(callbacks, MODULE, "Returning allocated context"); + jm_log_debug(callbacks, MODULE, "Returning allocated context"); return c; } void fmi_xml_free_context(fmi_xml_context_t *context) { - jm_log_debug(context->callbacks, MODULE, "Releasing XML parsing module memory"); + jm_log_debug(context->callbacks, MODULE, "Releasing XML parsing module memory"); if(!context) return; if(context->parser) { XML_ParserFree(context->parser); @@ -65,55 +65,55 @@ void fmi_xml_fatal(fmi_xml_context_t *context, const char* fmt, ...) { va_start (args, fmt); - jm_log_fatal_v(context->callbacks, MODULE, fmt, args); + jm_log_fatal_v(context->callbacks, MODULE, fmt, args); va_end (args); - XML_StopParser(context->parser,0); + XML_StopParser(context->parser,0); } void XMLCALL fmi_xml_parse_element_start(void *c, const char *elm, const char **attr) { - fmi_xml_context_t *context = (fmi_xml_context_t*)c; - const char* fmiVersion = 0; - int i = 0; - - if(strcmp(elm, "fmiModelDescription") != 0) { - fmi_xml_fatal(context, "First element in XML must be fmiModelDescription"); - return; - } - while(attr[i]) { - if(strcmp(attr[i], "fmiVersion") == 0) { - fmiVersion = attr[i+1]; - break; - } - i+=2; - } - if(!fmiVersion) { - fmi_xml_fatal(context, "Could not find fmiVersion attribute in the XML. Cannot proceed."); - return; - } - if( strcmp(fmiVersion, "1.0") == 0 ) { - jm_log_verbose(context->callbacks, MODULE, "XML specifies FMI 1.0"); - context->fmi_version = fmi_version_1_enu; - XML_StopParser(context->parser,0); - return; - } - else if( strcmp(fmiVersion, "2.0") == 0 ) { - jm_log_verbose(context->callbacks, MODULE, "XML specifies FMI 2.0"); - context->fmi_version = fmi_version_2_0_enu; - XML_StopParser(context->parser,0); - return; - } - else if( strcmp(fmiVersion, "3.0") == 0 ) { - jm_log_verbose(context->callbacks, MODULE, "XML specifies FMI 3.0"); - context->fmi_version = fmi_version_3_0_enu; - XML_StopParser(context->parser,0); - return; - } - else { - fmi_xml_fatal(context, "This version of FMI standard is not supported (fmiVersion=%s)", fmiVersion); - return; - } + fmi_xml_context_t *context = (fmi_xml_context_t*)c; + const char* fmiVersion = 0; + int i = 0; + + if(strcmp(elm, "fmiModelDescription") != 0) { + fmi_xml_fatal(context, "First element in XML must be fmiModelDescription"); + return; + } + while(attr[i]) { + if(strcmp(attr[i], "fmiVersion") == 0) { + fmiVersion = attr[i+1]; + break; + } + i+=2; + } + if(!fmiVersion) { + fmi_xml_fatal(context, "Could not find fmiVersion attribute in the XML. Cannot proceed."); + return; + } + if( strcmp(fmiVersion, "1.0") == 0 ) { + jm_log_verbose(context->callbacks, MODULE, "XML specifies FMI 1.0"); + context->fmi_version = fmi_version_1_enu; + XML_StopParser(context->parser,0); + return; + } + else if( strcmp(fmiVersion, "2.0") == 0 ) { + jm_log_verbose(context->callbacks, MODULE, "XML specifies FMI 2.0"); + context->fmi_version = fmi_version_2_0_enu; + XML_StopParser(context->parser,0); + return; + } + else if( strcmp(fmiVersion, "3.0") == 0 ) { + jm_log_verbose(context->callbacks, MODULE, "XML specifies FMI 3.0"); + context->fmi_version = fmi_version_3_0_enu; + XML_StopParser(context->parser,0); + return; + } + else { + fmi_xml_fatal(context, "This version of FMI standard is not supported (fmiVersion=%s)", fmiVersion); + return; + } } void XMLCALL fmi_xml_parse_element_end(void* c, const char *elm) { @@ -127,9 +127,9 @@ fmi_version_enu_t fmi_xml_get_fmi_version(fmi_xml_context_t* context, const char XML_Parser parser = NULL; FILE* file; - jm_log_verbose(context->callbacks, MODULE, "Parsing XML to detect FMI standard version"); + jm_log_verbose(context->callbacks, MODULE, "Parsing XML to detect FMI standard version"); - memsuite.malloc_fcn = context->callbacks->malloc; + memsuite.malloc_fcn = context->callbacks->malloc; memsuite.realloc_fcn = context->callbacks->realloc; memsuite.free_fcn = context->callbacks->free; @@ -158,7 +158,7 @@ fmi_version_enu_t fmi_xml_get_fmi_version(fmi_xml_context_t* context, const char return fmi_version_unknown_enu; } - context->fmi_version = fmi_version_unknown_enu; + context->fmi_version = fmi_version_unknown_enu; #define XML_BLOCK_SIZE 1000 @@ -177,13 +177,13 @@ fmi_version_enu_t fmi_xml_get_fmi_version(fmi_xml_context_t* context, const char fclose(file); return fmi_version_unknown_enu; /* failure */ } - if(context->fmi_version != fmi_version_unknown_enu) break; + if(context->fmi_version != fmi_version_unknown_enu) break; } fclose(file); - if(context->fmi_version == fmi_version_unknown_enu) { + if(context->fmi_version == fmi_version_unknown_enu) { fmi_xml_fatal(context, "Could not detect FMI standard version"); - } + } return context->fmi_version; } diff --git a/src/XML/src/FMI/fmi_xml_context_impl.h b/src/XML/src/FMI/fmi_xml_context_impl.h index f99cb98d..9f48e248 100644 --- a/src/XML/src/FMI/fmi_xml_context_impl.h +++ b/src/XML/src/FMI/fmi_xml_context_impl.h @@ -30,11 +30,11 @@ extern "C" { #endif struct fmi_xml_context_t { - jm_callbacks* callbacks; + jm_callbacks* callbacks; XML_Parser parser; - fmi_version_enu_t fmi_version; + fmi_version_enu_t fmi_version; int configuration; }; diff --git a/src/XML/src/FMI1/fmi1_xml_cosim.c b/src/XML/src/FMI1/fmi1_xml_cosim.c index d4519d24..76f624c6 100644 --- a/src/XML/src/FMI1/fmi1_xml_cosim.c +++ b/src/XML/src/FMI1/fmi1_xml_cosim.c @@ -52,7 +52,7 @@ int fmi1_xml_get_manual_start(fmi1_xml_model_description_t* md){ int fmi1_xml_handle_Implementation(fmi1_xml_parser_context_t *context, const char* data) { fmi1_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_info(context->callbacks, module, "Processing implementation element (co-simulation FMU detected)"); + jm_log_info(context->callbacks, module, "Processing implementation element (co-simulation FMU detected)"); md->fmuKind = fmi1_fmu_kind_enu_unknown; /* Explicitly set the "unknown" FMU kind here, in order to * detect if the required CoSimulation_StandAlone and diff --git a/src/XML/src/FMI1/fmi1_xml_model_description.c b/src/XML/src/FMI1/fmi1_xml_model_description.c index 9d159def..c7379f1e 100644 --- a/src/XML/src/FMI1/fmi1_xml_model_description.c +++ b/src/XML/src/FMI1/fmi1_xml_model_description.c @@ -35,9 +35,9 @@ fmi1_xml_model_description_t * fmi1_xml_allocate_model_description( jm_callbacks } md = (fmi1_xml_model_description_t*)cb->malloc(sizeof(fmi1_xml_model_description_t)); if(!md) { - jm_log_fatal(cb, module, "Could not allocate memory"); - return 0; - } + jm_log_fatal(cb, module, "Could not allocate memory"); + return 0; + } md->callbacks = cb; @@ -75,13 +75,13 @@ fmi1_xml_model_description_t * fmi1_xml_allocate_model_description( jm_callbacks jm_vector_init(jm_named_ptr)(&md->variablesByName, 0, cb); - md->variablesOrigOrder = 0; + md->variablesOrigOrder = 0; - md->variablesByVR = 0; + md->variablesByVR = 0; - md->inputVariables = 0; + md->inputVariables = 0; - md->outputVariables = 0; + md->outputVariables = 0; jm_vector_init(jm_string)(&md->descriptions, 0, cb); @@ -130,24 +130,24 @@ void fmi1_xml_clear_model_description( fmi1_xml_model_description_t* md) { jm_vector_foreach(jm_named_ptr)(&md->variablesByName, fmi1_xml_free_direct_dependencies); jm_named_vector_free_data(&md->variablesByName); - if(md->variablesOrigOrder) { - jm_vector_free(jm_voidp)(md->variablesOrigOrder); - md->variablesOrigOrder = 0; - } + if(md->variablesOrigOrder) { + jm_vector_free(jm_voidp)(md->variablesOrigOrder); + md->variablesOrigOrder = 0; + } if(md->variablesByVR) { - jm_vector_free(jm_voidp)(md->variablesByVR); - md->variablesByVR = 0; - } + jm_vector_free(jm_voidp)(md->variablesByVR); + md->variablesByVR = 0; + } - if(md->inputVariables) { - jm_vector_free(jm_voidp)(md->inputVariables); - md->inputVariables = 0; - } + if(md->inputVariables) { + jm_vector_free(jm_voidp)(md->inputVariables); + md->inputVariables = 0; + } - if(md->outputVariables) { - jm_vector_free(jm_voidp)(md->outputVariables); - md->outputVariables = 0; - } + if(md->outputVariables) { + jm_vector_free(jm_voidp)(md->outputVariables); + md->outputVariables = 0; + } jm_vector_foreach(jm_string)(&md->descriptions, (void(*)(const char*))md->callbacks->free); @@ -166,19 +166,19 @@ int fmi1_xml_is_model_description_empty(fmi1_xml_model_description_t* md) { } const char* fmi1_xml_get_last_error(fmi1_xml_model_description_t* md) { - return jm_get_last_error(md->callbacks); + return jm_get_last_error(md->callbacks); } void fmi1_xml_clear_last_error(fmi1_xml_model_description_t* md) { - jm_clear_last_error(md->callbacks); + jm_clear_last_error(md->callbacks); /* return (md->status != fmi1_xml_model_description_enu_error); */ } void fmi1_xml_free_model_description(fmi1_xml_model_description_t* md) { jm_callbacks* cb; - if(!md) return; - cb = md->callbacks; + if(!md) return; + cb = md->callbacks; fmi1_xml_clear_model_description(md); cb->free(md->capabilities); cb->free(md); @@ -280,25 +280,25 @@ void fmi1_xml_set_default_experiment_tolerance(fmi1_xml_model_description_t* md, #undef LOG_WARN_IF_ATTR_NOT_DEFINED fmi1_xml_vendor_list_t* fmi1_xml_get_vendor_list(fmi1_xml_model_description_t* md) { - assert(md); + assert(md); return (fmi1_xml_vendor_list_t*)&md->vendorList; } unsigned int fmi1_xml_get_number_of_vendors(fmi1_xml_vendor_list_t* vl) { - if(!vl) { - assert(vl && "Vendor list cannot be NULL"); - return 0; - } + if(!vl) { + assert(vl && "Vendor list cannot be NULL"); + return 0; + } return (unsigned int)jm_vector_get_size(jm_voidp)(&vl->vendors); } fmi1_xml_vendor_t* fmi1_xml_get_vendor(fmi1_xml_vendor_list_t* v, unsigned int index) { jm_vector(jm_voidp)* vl; - if(!v) { - assert(v && "Vendor list cannot be NULL"); - return 0; - } - vl = &v->vendors; + if(!v) { + assert(v && "Vendor list cannot be NULL"); + return 0; + } + vl = &v->vendors; if(index >= jm_vector_get_size(jm_voidp)(vl)) return 0; return (fmi1_xml_vendor_t*)jm_vector_get_item(jm_voidp)(vl, index); } @@ -308,15 +308,15 @@ fmi1_xml_unit_definitions_t* fmi1_xml_get_unit_definitions(fmi1_xml_model_descri } unsigned int fmi1_xml_get_unit_definitions_number(fmi1_xml_unit_definitions_t* ud) { - if(!ud) { - assert(ud && "Unit definitions cannot be NULL"); - return 0; - } + if(!ud) { + assert(ud && "Unit definitions cannot be NULL"); + return 0; + } return (unsigned int)jm_vector_get_size(jm_named_ptr)(&ud->definitions); } fmi1_xml_type_definitions_t* fmi1_xml_get_type_definitions(fmi1_xml_model_description_t* md) { - assert(md); + assert(md); return &md->typeDefinitions; } @@ -329,7 +329,7 @@ int fmi1_xml_handle_fmiModelDescription(fmi1_xml_parser_context_t *context, cons fmi1_xml_parse_fatal(context, "fmi1_xml_model_description must be the root XML element"); return -1; } - jm_log_verbose(context->callbacks, module, "Parsing XML element fmiModelDescription"); + jm_log_verbose(context->callbacks, module, "Parsing XML element fmiModelDescription"); /* process the attributes */ return ( /* */ @@ -393,38 +393,38 @@ int fmi1_xml_handle_DefaultExperiment(fmi1_xml_parser_context_t *context, const } jm_vector(jm_voidp)* fmi1_xml_get_variables_original_order(fmi1_xml_model_description_t* md) { - return md->variablesOrigOrder; + return md->variablesOrigOrder; } jm_vector(jm_named_ptr)* fmi1_xml_get_variables_alphabetical_order(fmi1_xml_model_description_t* md){ - return &md->variablesByName; + return &md->variablesByName; } jm_vector(jm_voidp)* fmi1_xml_get_variables_vr_order(fmi1_xml_model_description_t* md) { - return md->variablesByVR; + return md->variablesByVR; } fmi1_xml_variable_t* fmi1_xml_get_variable_by_name(fmi1_xml_model_description_t* md, const char* name) { - jm_named_ptr key, *found; + jm_named_ptr key, *found; key.name = name; found = jm_vector_bsearch(jm_named_ptr)(&md->variablesByName, &key, jm_compare_named); - if(!found) return 0; - return found->ptr; + if(!found) return 0; + return found->ptr; } fmi1_xml_variable_t* fmi1_xml_get_variable_by_vr(fmi1_xml_model_description_t* md, fmi1_base_type_enu_t baseType, fmi1_value_reference_t vr) { fmi1_xml_variable_t key; fmi1_xml_variable_t *pkey = &key; - fmi1_xml_variable_type_base_t keyType; - fmi1_xml_variable_t *v = 0; + fmi1_xml_variable_type_base_t keyType; + fmi1_xml_variable_t *v = 0; void ** found; - if(!md->variablesByVR) return 0; - keyType.structKind = fmi1_xml_type_struct_enu_base; - keyType.baseType = baseType; - key.type = &keyType; - key.vr = vr; + if(!md->variablesByVR) return 0; + keyType.structKind = fmi1_xml_type_struct_enu_base; + keyType.baseType = baseType; + key.type = &keyType; + key.vr = vr; key.aliasKind = fmi1_variable_is_not_alias; found = jm_vector_bsearch(jm_voidp)(md->variablesByVR,(void**)&pkey, fmi1_xml_compare_vr); @@ -435,5 +435,5 @@ fmi1_xml_variable_t* fmi1_xml_get_variable_by_vr(fmi1_xml_model_description_t* m jm_vector(jm_voidp)* fmi1_xml_get_input_variable_list(fmi1_xml_model_description_t* md) { - return md->inputVariables; + return md->inputVariables; } \ No newline at end of file diff --git a/src/XML/src/FMI1/fmi1_xml_model_description_impl.h b/src/XML/src/FMI1/fmi1_xml_model_description_impl.h index f574f9fe..a969640e 100644 --- a/src/XML/src/FMI1/fmi1_xml_model_description_impl.h +++ b/src/XML/src/FMI1/fmi1_xml_model_description_impl.h @@ -76,15 +76,15 @@ struct fmi1_xml_model_description_t { jm_string_set descriptions; - jm_vector(jm_named_ptr) variablesByName; + jm_vector(jm_named_ptr) variablesByName; jm_vector(jm_voidp)* variablesOrigOrder; - jm_vector(jm_voidp)* variablesByVR; + jm_vector(jm_voidp)* variablesByVR; - jm_vector(jm_voidp)* inputVariables; + jm_vector(jm_voidp)* inputVariables; - jm_vector(jm_voidp)* outputVariables; + jm_vector(jm_voidp)* outputVariables; fmi1_fmu_kind_enu_t fmuKind; diff --git a/src/XML/src/FMI1/fmi1_xml_parser.c b/src/XML/src/FMI1/fmi1_xml_parser.c index 83ed2424..8d828bcb 100644 --- a/src/XML/src/FMI1/fmi1_xml_parser.c +++ b/src/XML/src/FMI1/fmi1_xml_parser.c @@ -61,7 +61,7 @@ const char *fmi1_xmlAttrNames[] = { #define fmi1_xml_scheme_Implementation {fmi1_xml_elmID_fmiModelDescription, 5, 0} #define fmi1_xml_scheme_CoSimulation_StandAlone {fmi1_xml_elmID_Implementation, 0, 0} /* NOTE: Capabilities need special handling since it can appear both under - CoSimulation_StandAlone and CoSimulation_Tool + CoSimulation_StandAlone and CoSimulation_Tool */ #define fmi1_xml_scheme_Capabilities {fmi1_xml_elmID_CoSimulation_StandAlone, 0, 0} #define fmi1_xml_scheme_CoSimulation_Tool {fmi1_xml_elmID_Implementation, 0, 0} @@ -118,7 +118,7 @@ void fmi1_xml_parse_free_context(fmi1_xml_parser_context_t *context) { void fmi1_xml_parse_fatal(fmi1_xml_parser_context_t *context, const char* fmt, ...) { va_list args; va_start (args, fmt); - jm_log_fatal_v(context->callbacks, module, fmt, args); + jm_log_fatal_v(context->callbacks, module, fmt, args); va_end (args); XML_StopParser(context->parser,0); } @@ -378,67 +378,67 @@ static void XMLCALL fmi1_parse_element_start(void *c, const char *elm, const cha fmi1_xml_element_handle_map_t keyEl; fmi1_xml_element_handle_map_t* currentElMap; jm_named_ptr* currentMap; - fmi1_xml_elm_enu_t currentID; + fmi1_xml_elm_enu_t currentID; int i; fmi1_xml_parser_context_t *context = c; - if(context->skipElementCnt) { - context->skipElementCnt++; + if(context->skipElementCnt) { + context->skipElementCnt++; jm_log_warning(context->callbacks, module, "[Line:%u] Skipping nested XML element '%s'", - XML_GetCurrentLineNumber(context->parser), elm); - return; - } + XML_GetCurrentLineNumber(context->parser), elm); + return; + } - keyEl.elementName = elm; - /* find the element handle by name */ + keyEl.elementName = elm; + /* find the element handle by name */ currentElMap = jm_vector_bsearch(fmi1_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi1_xml_compare_elmName); if(!currentElMap) { /* not found error*/ jm_log_error(context->callbacks, module, "[Line:%u] Unknown element '%s' in XML, skipping", - XML_GetCurrentLineNumber(context->parser), elm); - context->skipElementCnt = 1; + XML_GetCurrentLineNumber(context->parser), elm); + context->skipElementCnt = 1; return; } currentID = currentElMap->elemID; - /* Check that parent-child & siblings are fine */ - { - fmi1_xml_elm_enu_t parentID = context->currentElmID; - fmi1_xml_elm_enu_t siblingID = context->lastElmID; - - if((fmi1_xml_scheme_info[currentID].parentID != parentID) && - ((currentID != fmi1_xml_elmID_Capabilities) || (parentID != fmi1_xml_elmID_CoSimulation_Tool))) { - jm_log_error(context->callbacks, module, - "[Line:%u] XML element '%s' cannot be placed inside '%s', skipping", - XML_GetCurrentLineNumber(context->parser), elm, fmi1_element_handle_map[parentID].elementName); - context->skipElementCnt = 1; - return; - } - if(siblingID != fmi1_xml_elmID_none) { - if(siblingID == currentID) { - if(!fmi1_xml_scheme_info[currentID].multipleAllowed) { - jm_log_error(context->callbacks, module, - "[Line:%u] Multiple instances of XML element '%s' are not allowed, skipping", - XML_GetCurrentLineNumber(context->parser), elm); - context->skipElementCnt = 1; - return; - } - } - else { - int lastSiblingIndex = fmi1_xml_scheme_info[siblingID].siblingIndex; - int curSiblingIndex = fmi1_xml_scheme_info[currentID].siblingIndex; - - if(lastSiblingIndex >= curSiblingIndex) { - jm_log_error(context->callbacks, module, - "[Line:%u] XML element '%s' cannot be placed after element '%s', skipping", - XML_GetCurrentLineNumber(context->parser), elm, fmi1_element_handle_map[siblingID].elementName); - context->skipElementCnt = 1; - return; - } - } - } - context->lastElmID = fmi1_xml_elmID_none; - } + /* Check that parent-child & siblings are fine */ + { + fmi1_xml_elm_enu_t parentID = context->currentElmID; + fmi1_xml_elm_enu_t siblingID = context->lastElmID; + + if((fmi1_xml_scheme_info[currentID].parentID != parentID) && + ((currentID != fmi1_xml_elmID_Capabilities) || (parentID != fmi1_xml_elmID_CoSimulation_Tool))) { + jm_log_error(context->callbacks, module, + "[Line:%u] XML element '%s' cannot be placed inside '%s', skipping", + XML_GetCurrentLineNumber(context->parser), elm, fmi1_element_handle_map[parentID].elementName); + context->skipElementCnt = 1; + return; + } + if(siblingID != fmi1_xml_elmID_none) { + if(siblingID == currentID) { + if(!fmi1_xml_scheme_info[currentID].multipleAllowed) { + jm_log_error(context->callbacks, module, + "[Line:%u] Multiple instances of XML element '%s' are not allowed, skipping", + XML_GetCurrentLineNumber(context->parser), elm); + context->skipElementCnt = 1; + return; + } + } + else { + int lastSiblingIndex = fmi1_xml_scheme_info[siblingID].siblingIndex; + int curSiblingIndex = fmi1_xml_scheme_info[currentID].siblingIndex; + + if(lastSiblingIndex >= curSiblingIndex) { + jm_log_error(context->callbacks, module, + "[Line:%u] XML element '%s' cannot be placed after element '%s', skipping", + XML_GetCurrentLineNumber(context->parser), elm, fmi1_element_handle_map[siblingID].elementName); + context->skipElementCnt = 1; + return; + } + } + } + context->lastElmID = fmi1_xml_elmID_none; + } /* process the attributes */ i = 0; @@ -448,9 +448,9 @@ static void XMLCALL fmi1_parse_element_start(void *c, const char *elm, const cha currentMap = jm_vector_bsearch(jm_named_ptr)(context->attrMap, &key, jm_compare_named); if(!currentMap) { /* not found error*/ - jm_log_error(context->callbacks, module, "Unknown attribute '%s' in XML", attr[i]); + jm_log_error(context->callbacks, module, "Unknown attribute '%s' in XML", attr[i]); } - else { + else { /* save attr value (still as string) for further handling */ const char** mapItem = (const char**)currentMap->ptr; *mapItem = attr[i+1]; @@ -459,10 +459,10 @@ static void XMLCALL fmi1_parse_element_start(void *c, const char *elm, const cha } /* handle the element */ - if( currentElMap->elementHandle(context, 0) ) { + if( currentElMap->elementHandle(context, 0) ) { return; } - if(context->skipElementCnt) return; + if(context->skipElementCnt) return; /* check that the element handle had process all the attributes */ for(i = 0; i < fmi1_xml_attr_number; i++) { if(jm_vector_get_item(jm_string)(context->attrBuffer, i)) { @@ -481,13 +481,13 @@ static void XMLCALL fmi1_parse_element_end(void* c, const char *elm) { fmi1_xml_element_handle_map_t keyEl; fmi1_xml_element_handle_map_t* currentElMap; - fmi1_xml_elm_enu_t currentID; + fmi1_xml_elm_enu_t currentID; fmi1_xml_parser_context_t *context = c; - if(context->skipElementCnt) { - context->skipElementCnt--; - return; - } + if(context->skipElementCnt) { + context->skipElementCnt--; + return; + } keyEl.elementName = elm; currentElMap = jm_vector_bsearch(fmi1_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi1_xml_compare_elmName); @@ -501,13 +501,13 @@ static void XMLCALL fmi1_parse_element_end(void* c, const char *elm) { if(currentID != context -> currentElmID) { /* missmatch error*/ fmi1_xml_parse_fatal(context, "Element end '%s' does not match element start '%s' in XML", elm, - fmi1_element_handle_map[context -> currentElmID].elementName); + fmi1_element_handle_map[context -> currentElmID].elementName); return; } jm_vector_push_back(char)(&context->elmData, 0); - if( currentElMap->elementHandle(context, jm_vector_get_itemp(char)(&context->elmData, 0) )) { + if( currentElMap->elementHandle(context, jm_vector_get_itemp(char)(&context->elmData, 0) )) { return; } jm_vector_resize(char)(&context->elmData, 0); @@ -603,7 +603,7 @@ int fmi1_xml_parse_model_description(fmi1_xml_model_description_t* md, const cha jm_vector_init(jm_voidp)(&context->directDependencyBuf, 0, context->callbacks); jm_vector_init(jm_string)(&context->directDependencyStringsStore, 0, context->callbacks); context->skipOneVariableFlag = 0; - context->skipElementCnt = 0; + context->skipElementCnt = 0; jm_stack_init(int)(&context->elmStack, context->callbacks); jm_vector_init(char)(&context->elmData, 0, context->callbacks); context->lastElmID = fmi1_xml_elmID_none; @@ -647,7 +647,7 @@ int fmi1_xml_parse_model_description(fmi1_xml_model_description_t* md, const cha if(ferror(file)) { fmi1_xml_parse_fatal(context, "Error reading from file %s", filename); fclose(file); - fmi1_xml_parse_free_context(context); + fmi1_xml_parse_free_context(context); return -1; } if (!XML_Parse(parser, text, n, feof(file))) { @@ -655,7 +655,7 @@ int fmi1_xml_parse_model_description(fmi1_xml_model_description_t* md, const cha (int)XML_GetCurrentLineNumber(parser), XML_ErrorString(XML_GetErrorCode(parser))); fclose(file); - fmi1_xml_parse_free_context(context); + fmi1_xml_parse_free_context(context); return -1; /* failure */ } } diff --git a/src/XML/src/FMI1/fmi1_xml_parser.h b/src/XML/src/FMI1/fmi1_xml_parser.h index e91c3134..efe5fa57 100644 --- a/src/XML/src/FMI1/fmi1_xml_parser.h +++ b/src/XML/src/FMI1/fmi1_xml_parser.h @@ -122,7 +122,7 @@ FMI1_XML_ELMLIST(EXPAND_ELM_HANDLE) #define FMI1_XML_ELM_ID(elm) ,fmi1_xml_elmID_##elm typedef enum fmi1_xml_elm_enu_t { - fmi1_xml_elmID_none = -1 + fmi1_xml_elmID_none = -1 FMI1_XML_ELMLIST(FMI1_XML_ELM_ID) ,fmi1_xml_elm_number } fmi1_xml_elm_enu_t; @@ -132,15 +132,15 @@ typedef int (*fmi1_xml_element_handle_ft)(fmi1_xml_parser_context_t *context, co typedef struct fmi1_xml_element_handle_map_t fmi1_xml_element_handle_map_t; typedef struct { - fmi1_xml_elm_enu_t parentID; - int siblingIndex; - int multipleAllowed; + fmi1_xml_elm_enu_t parentID; + int siblingIndex; + int multipleAllowed; } fmi1_xml_scheme_info_t; struct fmi1_xml_element_handle_map_t { const char* elementName; fmi1_xml_element_handle_ft elementHandle; - fmi1_xml_elm_enu_t elemID; + fmi1_xml_elm_enu_t elemID; }; @@ -170,13 +170,13 @@ struct fmi1_xml_parser_context_t { jm_vector(jm_string) directDependencyStringsStore; int skipOneVariableFlag; - int skipElementCnt; + int skipElementCnt; jm_stack(int) elmStack; jm_vector(char) elmData; - fmi1_xml_elm_enu_t lastElmID; - fmi1_xml_elm_enu_t currentElmID; + fmi1_xml_elm_enu_t lastElmID; + fmi1_xml_elm_enu_t currentElmID; /* Data for restoring locale after parsing */ jm_locale_t* jm_locale; diff --git a/src/XML/src/FMI1/fmi1_xml_query.c b/src/XML/src/FMI1/fmi1_xml_query.c index 1687fbe7..a1820125 100644 --- a/src/XML/src/FMI1/fmi1_xml_query.c +++ b/src/XML/src/FMI1/fmi1_xml_query.c @@ -23,31 +23,31 @@ jm_name_ID_map_t fmi1_xml_q_elementary_map[fmi1_xml_elementary_enu_num+1] = { - #define FMI1_XML_Q_ELEMENTARY_MAP(name) {#name , fmi1_xml_q_elmentary_enu_##name}, + #define FMI1_XML_Q_ELEMENTARY_MAP(name) {#name , fmi1_xml_q_elmentary_enu_##name}, FMI1_XML_Q_ELEMENTARY(FMI1_XML_Q_ELEMENTARY_MAP) - {0,0} + {0,0} }; fmi1_xml_q_scan_elementary_ft fmi1_xml_q_scan_elementary_handles[fmi1_xml_elementary_enu_num + 1] = { - #define FMI1_XML_Q_ELEMENTARY_SCAN(name) fmi1_xml_q_scan_elementary_##name, + #define FMI1_XML_Q_ELEMENTARY_SCAN(name) fmi1_xml_q_scan_elementary_##name, FMI1_XML_Q_ELEMENTARY(FMI1_XML_Q_ELEMENTARY_SCAN) - 0 + 0 }; fmi1_xml_q_eval_elementary_ft fmi1_xml_q_eval_elementary_handles[fmi1_xml_elementary_enu_num + 1] = { - #define FMI1_XML_Q_ELEMENTARY_EVAL(name) fmi1_xml_q_eval_elementary_##name, + #define FMI1_XML_Q_ELEMENTARY_EVAL(name) fmi1_xml_q_eval_elementary_##name, FMI1_XML_Q_ELEMENTARY(FMI1_XML_Q_ELEMENTARY_EVAL) - 0 + 0 }; jm_name_ID_map_t fmi1_xml_q_op_map[] = { - {"or", fmi1_xml_q_term_enu_OR}, - {"and", fmi1_xml_q_term_enu_AND}, - {"not", fmi1_xml_q_term_enu_NOT}, - {"&&", fmi1_xml_q_term_enu_AND}, - {"||", fmi1_xml_q_term_enu_OR}, - {"!", fmi1_xml_q_term_enu_NOT}, - {0,-1} + {"or", fmi1_xml_q_term_enu_OR}, + {"and", fmi1_xml_q_term_enu_AND}, + {"not", fmi1_xml_q_term_enu_NOT}, + {"&&", fmi1_xml_q_term_enu_AND}, + {"||", fmi1_xml_q_term_enu_OR}, + {"!", fmi1_xml_q_term_enu_NOT}, + {0,-1} }; static void fmi1_xml_q_skip_space(jm_string* cur) { @@ -62,139 +62,139 @@ static void fmi1_xml_q_skip_space(jm_string* cur) { } int fmi1_xml_q_scan_string(fmi1_xml_q_context_t* context, char** param_str) { - fmi1_xml_q_expression_t* expr = &context->expr; - char* dest; - jm_string cur = context->query + context->curCh; + fmi1_xml_q_expression_t* expr = &context->expr; + char* dest; + jm_string cur = context->query + context->curCh; char ch = *cur; char strterm ; size_t strlen = 0; - if((ch == '\'') || (ch == '"')) /* either ' or " can be used as string terminator */ - strterm = ch; + if((ch == '\'') || (ch == '"')) /* either ' or " can be used as string terminator */ + strterm = ch; else - return -1; + return -1; do { ch = cur[strlen+1]; dest = jm_vector_push_back(char)(&expr->strbuf, ch); - assert(dest); + assert(dest); strlen++; } while((ch != strterm) && ch); if(!ch) return -1; /* string is not terminated */ - *dest = 0; /* put terminating 0*/ - strlen--; /* last zero is not a part of the string */ - *param_str = dest - strlen; + *dest = 0; /* put terminating 0*/ + strlen--; /* last zero is not a part of the string */ + *param_str = dest - strlen; return strlen; } int fmi1_xml_q_scan_elementary_name(fmi1_xml_q_context_t* context, fmi1_xml_q_terminal_t* term) { - jm_string startCh = &context->query[context->curCh]; - jm_string curCh = startCh; - size_t len; - - /* expecting: []'='[] */ - - fmi1_xml_q_skip_space(&curCh); - if(*curCh != '=') - return (int)(startCh - curCh); - curCh++; - fmi1_xml_q_skip_space(&curCh); - - len = (int)(curCh - startCh); - - context->curCh += len; - startCh += len; - - if( fmi1_xml_q_scan_string(context, &term->param_str) < 0) - return (int)(startCh - curCh); - - /* treat as regexp - > skip for now - if(term->param_str[0] == '^') { - - } - else */ - { - term->param_i = strlen(term->param_str); - if( (strchr ( term->param_str, '*') != 0) || (strchr ( term->param_str, '?') != 0) ){ - /* treat as wildcard */ - term->param_i *= -1; - } - } - return (int)(curCh - startCh); + jm_string startCh = &context->query[context->curCh]; + jm_string curCh = startCh; + size_t len; + + /* expecting: []'='[] */ + + fmi1_xml_q_skip_space(&curCh); + if(*curCh != '=') + return (int)(startCh - curCh); + curCh++; + fmi1_xml_q_skip_space(&curCh); + + len = (int)(curCh - startCh); + + context->curCh += len; + startCh += len; + + if( fmi1_xml_q_scan_string(context, &term->param_str) < 0) + return (int)(startCh - curCh); + + /* treat as regexp - > skip for now + if(term->param_str[0] == '^') { + + } + else */ + { + term->param_i = strlen(term->param_str); + if( (strchr ( term->param_str, '*') != 0) || (strchr ( term->param_str, '?') != 0) ){ + /* treat as wildcard */ + term->param_i *= -1; + } + } + return (int)(curCh - startCh); } int fmi1_xml_q_eval_elementary_name(fmi1_xml_variable_t* var, fmi1_xml_q_terminal_t* term) { - assert(term->specific == fmi1_xml_q_elmentary_enu_name); - - if(term->param_i < 0) { - return jm_wc_match(term->param_str, fmi1_xml_get_variable_name(var)); - } - else - return (strncmp(term->param_str, fmi1_xml_get_variable_name(var), term->param_i) == 0); - return 0; + assert(term->specific == fmi1_xml_q_elmentary_enu_name); + + if(term->param_i < 0) { + return jm_wc_match(term->param_str, fmi1_xml_get_variable_name(var)); + } + else + return (strncmp(term->param_str, fmi1_xml_get_variable_name(var), term->param_i) == 0); + return 0; } int fmi1_xml_q_scan_elementary_unit(fmi1_xml_q_context_t* context, fmi1_xml_q_terminal_t* term) { - jm_string startCh = &context->query[context->curCh]; - jm_string curCh = startCh; - size_t len; + jm_string startCh = &context->query[context->curCh]; + jm_string curCh = startCh; + size_t len; - /* expecting: []'='[] */ + /* expecting: []'='[] */ - fmi1_xml_q_skip_space(&curCh); - if(*curCh != '=') - return (int)(startCh - curCh); - curCh++; - fmi1_xml_q_skip_space(&curCh); + fmi1_xml_q_skip_space(&curCh); + if(*curCh != '=') + return (int)(startCh - curCh); + curCh++; + fmi1_xml_q_skip_space(&curCh); - len = (int)(curCh - startCh); + len = (int)(curCh - startCh); - context->curCh += len; - startCh += len; + context->curCh += len; + startCh += len; - if( fmi1_xml_q_scan_string(context, &term->param_str) < 0) - return (int)(startCh - curCh); - return (int)(curCh - startCh); + if( fmi1_xml_q_scan_string(context, &term->param_str) < 0) + return (int)(startCh - curCh); + return (int)(curCh - startCh); } int fmi1_xml_q_eval_elementary_unit(fmi1_xml_variable_t* var, fmi1_xml_q_terminal_t* term) { - return 0; + return 0; } int fmi1_xml_q_get_number(fmi1_xml_q_context_t* context, char* cur, double* val, char* buf) { - int len; - if(sscanf(cur, "%lg%s", val, buf) != 2) return 0; - len = strlen(cur) - strlen(buf); - return len; + int len; + if(sscanf(cur, "%lg%s", val, buf) != 2) return 0; + len = strlen(cur) - strlen(buf); + return len; } int fmi1_xml_q_get_keyword(fmi1_xml_q_context_t* context, char* cur, size_t* len, char* buf) { char ch = *cur; size_t i = 0, id; *len = 0; - if( (ch == '|') || (ch == '&') ) { - if(ch == cur[i+1]) { - buf[i++] = ch; - buf[i++] = ch; - } - } - else { - while(isalpha(ch)) { - buf[i++] = tolower(ch); - ch = cur[i]; - } - } - + if( (ch == '|') || (ch == '&') ) { + if(ch == cur[i+1]) { + buf[i++] = ch; + buf[i++] = ch; + } + } + else { + while(isalpha(ch)) { + buf[i++] = tolower(ch); + ch = cur[i]; + } + } + if(!i) return -1; - { - jm_name_ID_map_t key; - jm_name_ID_map_t* map; - key.name = buf; - map = jm_vector_bsearch(jm_name_ID_map_t)(&context->elementary_map, &key,jm_compare_name); - if(!map) return -1; - id = map->ID; - } + { + jm_name_ID_map_t key; + jm_name_ID_map_t* map; + key.name = buf; + map = jm_vector_bsearch(jm_name_ID_map_t)(&context->elementary_map, &key,jm_compare_name); + if(!map) return -1; + id = map->ID; + } *len = i; return id; } @@ -227,18 +227,18 @@ int pattern2regexp(const char* pattern, jm_vector(char)* re) { } int fmi1_xml_evaluate_terminal(fmi1_xml_variable_t* var, fmi1_xml_q_terminal_t* term) { - return fmi1_xml_q_eval_elementary_handles[term->specific](var, term); + return fmi1_xml_q_eval_elementary_handles[term->specific](var, term); } int fmi1_xml_q_filter_variable(fmi1_xml_variable_t* var, fmi1_xml_q_expression_t* expr) { size_t cur, len = jm_vector_get_size(jm_voidp)(&expr->expression); - jm_vector(jm_voidp)* stack = &expr->stack; - fmi1_xml_q_terminal_t * term; + jm_vector(jm_voidp)* stack = &expr->stack; + fmi1_xml_q_terminal_t * term; for(cur = 0; cur < len; cur++) { fmi1_xml_q_terminal_t *argL, *argR; size_t curlen = jm_vector_get_size(jm_voidp)(stack); - term = (fmi1_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(&expr->expression, cur); + term = (fmi1_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(&expr->expression, cur); argL = (curlen > 0) ? (fmi1_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,curlen -1):0; argR = (curlen > 1) ? (fmi1_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,curlen -2):0; @@ -262,140 +262,140 @@ int fmi1_xml_q_filter_variable(fmi1_xml_variable_t* var, fmi1_xml_q_expression_t } break; case fmi1_xml_q_term_enu_NOT: - assert(argL); + assert(argL); jm_vector_resize(jm_voidp)(stack, curlen -1); if(argL->kind == fmi1_xml_q_term_enu_TRUE) jm_vector_push_back(jm_voidp)(stack, &expr->termFalse); - else if(argL->kind == fmi1_xml_q_term_enu_TRUE) + else if(argL->kind == fmi1_xml_q_term_enu_TRUE) jm_vector_push_back(jm_voidp)(stack, &expr->termTrue); else { jm_vector_push_back(jm_voidp)(stack, (fmi1_xml_evaluate_terminal(var, argL)? &expr->termFalse: &expr->termTrue)); } - break; - case fmi1_xml_q_term_enu_LP: - case fmi1_xml_q_term_enu_RP: - assert(0); - break; + break; + case fmi1_xml_q_term_enu_LP: + case fmi1_xml_q_term_enu_RP: + assert(0); + break; default: jm_vector_push_back(jm_voidp)(stack, term); /* only evaluate when needed. push as is at first */ } } assert(jm_vector_get_size(jm_voidp)(stack) == 1); - + term = (fmi1_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,0); if(term->kind == fmi1_xml_q_term_enu_FALSE) return 0; - assert(term->kind == fmi1_xml_q_term_enu_TRUE); + assert(term->kind == fmi1_xml_q_term_enu_TRUE); return 1; } fmi1_xml_q_expression_t* fmi1_xml_alloc_expression(jm_string query) { - return 0; + return 0; } int fmi1_xml_q_parse_elementary(fmi1_xml_q_context_t* context, fmi1_xml_q_terminal_t* term) { - return 0; + return 0; } void fmi1_xml_q_init_context(fmi1_xml_q_context_t* c, jm_callbacks* cb) { - size_t l = jm_vector_init(jm_name_ID_map_t)(&c->elementary_map, fmi1_xml_elementary_enu_num, cb); - assert(l); - for(l = 0; l < fmi1_xml_elementary_enu_num; l++) { - jm_vector_set_item(jm_name_ID_map_t)(&c->elementary_map, l,fmi1_xml_q_elementary_map[l]); - } - jm_vector_qsort(jm_name_ID_map_t)(&c->elementary_map,jm_compare_name); - c->query = 0; - c->qlen = 0; - c->curCh = 0; - jm_vector_init(char)(&c->buf,0,cb); - - { - fmi1_xml_q_expression_t* expr = &c->expr; - jm_vector_init(jm_voidp)(&expr->expression,0,cb); - jm_vector_init(jm_voidp)(&expr->stack,0,cb); - expr->termFalse.kind = fmi1_xml_q_term_enu_FALSE; - expr->termTrue.kind = fmi1_xml_q_term_enu_TRUE; - jm_vector_init(fmi1_xml_q_terminal_t)(&expr->terms,0,cb); - jm_vector_init(char)(&expr->strbuf, 0, cb); - } + size_t l = jm_vector_init(jm_name_ID_map_t)(&c->elementary_map, fmi1_xml_elementary_enu_num, cb); + assert(l); + for(l = 0; l < fmi1_xml_elementary_enu_num; l++) { + jm_vector_set_item(jm_name_ID_map_t)(&c->elementary_map, l,fmi1_xml_q_elementary_map[l]); + } + jm_vector_qsort(jm_name_ID_map_t)(&c->elementary_map,jm_compare_name); + c->query = 0; + c->qlen = 0; + c->curCh = 0; + jm_vector_init(char)(&c->buf,0,cb); + + { + fmi1_xml_q_expression_t* expr = &c->expr; + jm_vector_init(jm_voidp)(&expr->expression,0,cb); + jm_vector_init(jm_voidp)(&expr->stack,0,cb); + expr->termFalse.kind = fmi1_xml_q_term_enu_FALSE; + expr->termTrue.kind = fmi1_xml_q_term_enu_TRUE; + jm_vector_init(fmi1_xml_q_terminal_t)(&expr->terms,0,cb); + jm_vector_init(char)(&expr->strbuf, 0, cb); + } } void fmi1_xml_q_free_context_data(fmi1_xml_q_context_t* c){ - fmi1_xml_q_expression_t* expr = &c->expr; - jm_vector_free_data(jm_name_ID_map_t)(&c->elementary_map); - jm_vector_free_data(char)(&c->buf); - jm_vector_free_data(jm_voidp)(&expr->expression); - jm_vector_free_data(jm_voidp)(&expr->stack); - jm_vector_free_data(fmi1_xml_q_terminal_t)(&expr->terms); - jm_vector_free_data(char)(&expr->strbuf); + fmi1_xml_q_expression_t* expr = &c->expr; + jm_vector_free_data(jm_name_ID_map_t)(&c->elementary_map); + jm_vector_free_data(char)(&c->buf); + jm_vector_free_data(jm_voidp)(&expr->expression); + jm_vector_free_data(jm_voidp)(&expr->stack); + jm_vector_free_data(fmi1_xml_q_terminal_t)(&expr->terms); + jm_vector_free_data(char)(&expr->strbuf); } int fmi1_xml_q_parse_terminal(fmi1_xml_q_context_t* context, fmi1_xml_q_terminal_t** ppterm) { - int offset = 0; + int offset = 0; fmi1_xml_q_terminal_t* pterm; - jm_string startCh = context->query + context->curCh; - jm_string cur = startCh; - pterm = jm_vector_resize1(fmi1_xml_q_terminal_t)(&context->expr.terms); + jm_string startCh = context->query + context->curCh; + jm_string cur = startCh; + pterm = jm_vector_resize1(fmi1_xml_q_terminal_t)(&context->expr.terms); if(!pterm) return -1; - *ppterm = pterm; + *ppterm = pterm; fmi1_xml_q_skip_space(&cur); switch(*cur) { case '(': - pterm->kind = fmi1_xml_q_term_enu_LP; - break; + pterm->kind = fmi1_xml_q_term_enu_LP; + break; case ')': - pterm->kind = fmi1_xml_q_term_enu_RP; - break; + pterm->kind = fmi1_xml_q_term_enu_RP; + break; case '&': - pterm->kind = fmi1_xml_q_term_enu_AND; - break; + pterm->kind = fmi1_xml_q_term_enu_AND; + break; case '|': - pterm->kind = fmi1_xml_q_term_enu_OR; - break; + pterm->kind = fmi1_xml_q_term_enu_OR; + break; case '!': - pterm->kind = fmi1_xml_q_term_enu_NOT; - break; + pterm->kind = fmi1_xml_q_term_enu_NOT; + break; case 0: - pterm->kind = fmi1_xml_q_term_enu_END; - break; + pterm->kind = fmi1_xml_q_term_enu_END; + break; default: fmi1_xml_q_parse_elementary(context, pterm); } - fmi1_xml_q_skip_space(&cur); - return (int)(cur - startCh); + fmi1_xml_q_skip_space(&cur); + return (int)(cur - startCh); } int fmi1_xml_q_parse_query(fmi1_xml_q_context_t* context, jm_string query) { - fmi1_xml_q_expression_t* expr = &context->expr; + fmi1_xml_q_expression_t* expr = &context->expr; int qlen = strlen(query); - int offset = 0, curCh = 0; - int expectOperand = 1; - size_t stacklen = 0; + int offset = 0, curCh = 0; + int expectOperand = 1; + size_t stacklen = 0; fmi1_xml_q_terminal_t* stackTop = 0; - context->query = query; - context->qlen = qlen; - if(jm_vector_reserve(char)(&context->buf, qlen) < (size_t)qlen) return -1; - if(jm_vector_reserve(char)(&context->expr.strbuf, qlen) < (size_t)qlen) return -1; + context->query = query; + context->qlen = qlen; + if(jm_vector_reserve(char)(&context->buf, qlen) < (size_t)qlen) return -1; + if(jm_vector_reserve(char)(&context->expr.strbuf, qlen) < (size_t)qlen) return -1; while(curCh < qlen) { fmi1_xml_q_terminal_t* term; size_t explen = jm_vector_get_size(jm_voidp)(&expr->expression); fmi1_xml_q_terminal_t* expTop = explen? (fmi1_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->expression,explen -1):0; - offset = fmi1_xml_q_parse_terminal(context, &term); + offset = fmi1_xml_q_parse_terminal(context, &term); - if(offset < 0) return -curCh; + if(offset < 0) return -curCh; - stacklen = jm_vector_get_size(jm_voidp)(&expr->stack); + stacklen = jm_vector_get_size(jm_voidp)(&expr->stack); stackTop = stacklen ? (fmi1_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->stack,stacklen -1):(fmi1_xml_q_terminal_t*)0; switch(term -> kind) { case fmi1_xml_q_term_enu_LP: - if(!expectOperand) return -curCh; + if(!expectOperand) return -curCh; jm_vector_push_back(jm_voidp)(&expr->stack, term); break; case fmi1_xml_q_term_enu_RP: - if(expectOperand) return -curCh; + if(expectOperand) return -curCh; while(stackTop && (stackTop->kind != fmi1_xml_q_term_enu_LP)) { jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); stacklen--; @@ -407,8 +407,8 @@ int fmi1_xml_q_parse_query(fmi1_xml_q_context_t* context, jm_string query) { break; case fmi1_xml_q_term_enu_AND: - if(expectOperand) return -curCh; - expectOperand = 1; + if(expectOperand) return -curCh; + expectOperand = 1; if(!expTop) return -curCh; if(stackTop && (stackTop->kind == fmi1_xml_q_term_enu_AND)) jm_vector_push_back(jm_voidp)(&expr->expression, term); @@ -416,8 +416,8 @@ int fmi1_xml_q_parse_query(fmi1_xml_q_context_t* context, jm_string query) { jm_vector_push_back(jm_voidp)(&expr->stack, term); break; case fmi1_xml_q_term_enu_OR: - if(expectOperand) return -curCh; - expectOperand = 1; + if(expectOperand) return -curCh; + expectOperand = 1; if(!expTop) return -curCh; while(stackTop && ((stackTop->kind == fmi1_xml_q_term_enu_AND)||(stackTop->kind == fmi1_xml_q_term_enu_OR))) { jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); @@ -428,17 +428,17 @@ int fmi1_xml_q_parse_query(fmi1_xml_q_context_t* context, jm_string query) { jm_vector_push_back(jm_voidp)(&expr->stack, term); break; default: - if(!expectOperand) return -curCh; - expectOperand = 0; + if(!expectOperand) return -curCh; + expectOperand = 0; jm_vector_push_back(jm_voidp)(&expr->expression, term); } - curCh += offset; - context->curCh = curCh; + curCh += offset; + context->curCh = curCh; } - if(expectOperand) return -curCh; + if(expectOperand) return -curCh; while(stackTop && (stackTop->kind != fmi1_xml_q_term_enu_LP)) { - jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); + jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); jm_vector_resize(jm_voidp)(&expr->stack, stacklen -1); stacklen--; stackTop = stacklen? (fmi1_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->stack,stacklen -1):0; diff --git a/src/XML/src/FMI1/fmi1_xml_query.h b/src/XML/src/FMI1/fmi1_xml_query.h index d1b016c3..065d2be4 100644 --- a/src/XML/src/FMI1/fmi1_xml_query.h +++ b/src/XML/src/FMI1/fmi1_xml_query.h @@ -77,27 +77,27 @@ typedef int (*fmi1_xml_q_eval_elementary_ft)(fmi1_xml_variable_t* var, fmi1_xml_ FMI1_XML_Q_ELEMENTARY(FMI1_XML_Q_ELEMENTARY_DECLARE_EVAL) typedef enum fmi1_xml_q_term_enu_t { - fmi1_xml_q_term_enu_elementary, - fmi1_xml_q_term_enu_LP, - fmi1_xml_q_term_enu_RP, - fmi1_xml_q_term_enu_OR, - fmi1_xml_q_term_enu_AND, - fmi1_xml_q_term_enu_NOT, - fmi1_xml_q_term_enu_END, - fmi1_xml_q_term_enu_TRUE, - fmi1_xml_q_term_enu_FALSE + fmi1_xml_q_term_enu_elementary, + fmi1_xml_q_term_enu_LP, + fmi1_xml_q_term_enu_RP, + fmi1_xml_q_term_enu_OR, + fmi1_xml_q_term_enu_AND, + fmi1_xml_q_term_enu_NOT, + fmi1_xml_q_term_enu_END, + fmi1_xml_q_term_enu_TRUE, + fmi1_xml_q_term_enu_FALSE } fmi1_xml_q_terminal_enu_t; struct fmi1_xml_q_terminal_t { - fmi1_xml_q_terminal_enu_t kind; + fmi1_xml_q_terminal_enu_t kind; - fmi1_xml_elementary_enu_t specific; + fmi1_xml_elementary_enu_t specific; - int param_i; - double param_d; - void* param_p; - char* param_str; + int param_i; + double param_d; + void* param_p; + char* param_str; }; @@ -114,20 +114,20 @@ struct fmi1_xml_q_expression_t { fmi1_xml_q_terminal_t termFalse, termTrue; fmi1_xml_q_term_vt terms; - jm_vector(char) strbuf; + jm_vector(char) strbuf; }; struct fmi1_xml_q_context_t { jm_vector(jm_name_ID_map_t) elementary_map; - jm_string query; + jm_string query; - size_t qlen; - int curCh; + size_t qlen; + int curCh; - jm_vector(char) buf; + jm_vector(char) buf; - fmi1_xml_q_expression_t expr; + fmi1_xml_q_expression_t expr; }; void fmi1_xml_q_init_context(fmi1_xml_q_context_t*, jm_callbacks* cb); diff --git a/src/XML/src/FMI1/fmi1_xml_type.c b/src/XML/src/FMI1/fmi1_xml_type.c index 45622fd4..cf1cfb4f 100644 --- a/src/XML/src/FMI1/fmi1_xml_type.c +++ b/src/XML/src/FMI1/fmi1_xml_type.c @@ -46,7 +46,7 @@ const char* fmi1_xml_get_type_name(fmi1_xml_variable_typedef_t* t) { } const char* fmi1_xml_get_type_description(fmi1_xml_variable_typedef_t* t) { - const char * ret = t->description; + const char * ret = t->description; return (ret ? ret : ""); } @@ -70,26 +70,26 @@ fmi1_xml_enumeration_typedef_t* fmi1_xml_get_type_as_enum(fmi1_xml_variable_type const char* fmi1_xml_get_type_quantity(fmi1_xml_variable_typedef_t* t) { fmi1_xml_variable_type_base_t* props = t->super.nextLayer; - const char * ret; + const char * ret; if(props->structKind != fmi1_xml_type_struct_enu_props) return 0; switch(props->baseType) { case fmi1_base_type_real: ret = ((fmi1_xml_real_type_props_t*)props)->quantity; - break; + break; case fmi1_base_type_int: ret = ((fmi1_xml_integer_type_props_t*)props)->quantity; - break; + break; case fmi1_base_type_bool: return 0; case fmi1_base_type_str: return 0; case fmi1_base_type_enum: ret = ((fmi1_xml_enum_type_props_t*)props)->quantity; - break; + break; default: return 0; } - return (ret ? ret : 0); + return (ret ? ret : 0); } double fmi1_xml_get_real_type_min(fmi1_xml_real_typedef_t* t) { @@ -244,7 +244,7 @@ void fmi1_xml_free_type_definitions_data(fmi1_xml_type_definitions_t* td) { cb->free(cur); cur = next; } - td->typePropsList = 0; + td->typePropsList = 0; } jm_named_vector_free_data(&td->typeDefinitions); @@ -252,7 +252,7 @@ void fmi1_xml_free_type_definitions_data(fmi1_xml_type_definitions_t* td) { int fmi1_xml_handle_TypeDefinitions(fmi1_xml_parser_context_t *context, const char* data) { if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element TypeDefinitions"); + jm_log_verbose(context->callbacks, module, "Parsing XML element TypeDefinitions"); } else { fmi1_xml_type_definitions_t* defs = &context->modelDescription->typeDefinitions; @@ -280,7 +280,7 @@ int fmi1_xml_handle_Type(fmi1_xml_parser_context_t *context, const char* data) { fmi1_xml_set_attr_string(context, fmi1_xml_elmID_Type, fmi_attr_id_description, 0, bufDescr) ) return -1; named.ptr = 0; - named.name = 0; + named.name = 0; pnamed = jm_vector_push_back(jm_named_ptr)(&td->typeDefinitions,named); if(pnamed) { fmi1_xml_variable_typedef_t dummy; @@ -590,7 +590,7 @@ int fmi1_xml_handle_Item(fmi1_xml_parser_context_t *context, const char* data) { return -1; descrlen = jm_vector_get_size(char)(bufDescr); named.ptr = 0; - named.name = 0; + named.name = 0; pnamed = jm_vector_push_back(jm_named_ptr)(&enumProps->enumItems, named); if(pnamed) *pnamed = named = jm_named_alloc_v(bufName,sizeof(fmi1_xml_enum_type_item_t)+descrlen+1,sizeof(fmi1_xml_enum_type_item_t)+descrlen,context->callbacks); diff --git a/src/XML/src/FMI1/fmi1_xml_type_impl.h b/src/XML/src/FMI1/fmi1_xml_type_impl.h index d5f99989..3becf497 100644 --- a/src/XML/src/FMI1/fmi1_xml_type_impl.h +++ b/src/XML/src/FMI1/fmi1_xml_type_impl.h @@ -147,9 +147,9 @@ static fmi1_xml_variable_type_base_t* fmi1_xml_find_type_props(fmi1_xml_variable fmi1_xml_variable_type_base_t* typeBase = type; while(typeBase) { if((typeBase->structKind == fmi1_xml_type_struct_enu_base) - || (typeBase->structKind == fmi1_xml_type_struct_enu_props)) return typeBase; + || (typeBase->structKind == fmi1_xml_type_struct_enu_props)) return typeBase; typeBase = typeBase->nextLayer; - } + } return 0; } diff --git a/src/XML/src/FMI1/fmi1_xml_unit.c b/src/XML/src/FMI1/fmi1_xml_unit.c index e4be4ba1..385e3a1f 100644 --- a/src/XML/src/FMI1/fmi1_xml_unit.c +++ b/src/XML/src/FMI1/fmi1_xml_unit.c @@ -74,8 +74,8 @@ double fmi1_xml_convert_from_display_unit(double val, fmi1_xml_display_unit_t* d int fmi1_xml_handle_UnitDefinitions(fmi1_xml_parser_context_t *context, const char* data) { fmi1_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element UnitDefinitions"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element UnitDefinitions"); + } else { jm_vector_qsort(jm_named_ptr)(&(md->unitDefinitions),jm_compare_named); jm_vector_qsort(jm_named_ptr)(&(md->displayUnitDefinitions),jm_compare_named); @@ -90,10 +90,10 @@ fmi1_xml_display_unit_t* fmi1_xml_get_parsed_unit(fmi1_xml_parser_context_t *con jm_named_ptr named, *pnamed; fmi1_xml_model_description_t* md = context->modelDescription; - if(jm_vector_get_size(char)(name)) - named.name = jm_vector_get_itemp(char)(name,0); - else - named.name = ""; + if(jm_vector_get_size(char)(name)) + named.name = jm_vector_get_itemp(char)(name,0); + else + named.name = ""; if(sorted) pnamed = jm_vector_bsearch(jm_named_ptr)(&(md->unitDefinitions), &named,jm_compare_named); else diff --git a/src/XML/src/FMI1/fmi1_xml_variable_impl.h b/src/XML/src/FMI1/fmi1_xml_variable_impl.h index 84a6007d..9ed46de5 100644 --- a/src/XML/src/FMI1/fmi1_xml_variable_impl.h +++ b/src/XML/src/FMI1/fmi1_xml_variable_impl.h @@ -33,7 +33,7 @@ struct fmi1_xml_variable_t { const char* description; jm_vector(jm_voidp)* directDependency; - size_t originalIndex; + size_t originalIndex; fmi1_value_reference_t vr; char aliasKind; char variability; @@ -47,8 +47,8 @@ static int fmi1_xml_compare_vr (const void* first, const void* second) { fmi1_xml_variable_t* b = *(fmi1_xml_variable_t**)second; fmi1_base_type_enu_t at = fmi1_xml_get_variable_base_type(a); fmi1_base_type_enu_t bt = fmi1_xml_get_variable_base_type(b); - if(at == fmi1_base_type_enum) at = fmi1_base_type_int; - if(bt == fmi1_base_type_enum) bt = fmi1_base_type_int; + if(at == fmi1_base_type_enum) at = fmi1_base_type_int; + if(bt == fmi1_base_type_enum) bt = fmi1_base_type_int; if(at!=bt) return at - bt; if(a->vr < b->vr) return -1; if(a->vr > b->vr) return 1; diff --git a/src/XML/src/FMI1/fmi1_xml_vendor_annotations.c b/src/XML/src/FMI1/fmi1_xml_vendor_annotations.c index b7590c89..7d2e705a 100644 --- a/src/XML/src/FMI1/fmi1_xml_vendor_annotations.c +++ b/src/XML/src/FMI1/fmi1_xml_vendor_annotations.c @@ -49,8 +49,8 @@ const char* fmi1_xml_get_annotation_value(fmi1_xml_annotation_t* a) { int fmi1_xml_handle_VendorAnnotations(fmi1_xml_parser_context_t *context, const char* data) { if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations"); + } else { /* might give out a warning if(data[0] != 0) */ } @@ -103,7 +103,7 @@ int fmi1_xml_handle_Annotation(fmi1_xml_parser_context_t *context, const char* d return -1; vallen = jm_vector_get_size(char)(bufValue); named.ptr = 0; - named.name = 0; + named.name = 0; pnamed = jm_vector_push_back(jm_named_ptr)(&vendor->annotations, named); if(pnamed) *pnamed = named = jm_named_alloc_v(bufName,sizeof(fmi1_xml_annotation_t)+vallen+1,sizeof(fmi1_xml_annotation_t)+vallen,context->callbacks); diff --git a/src/XML/src/FMI2/fmi2_xml_model_description.c b/src/XML/src/FMI2/fmi2_xml_model_description.c index e06ad9c1..1db492db 100644 --- a/src/XML/src/FMI2/fmi2_xml_model_description.c +++ b/src/XML/src/FMI2/fmi2_xml_model_description.c @@ -35,9 +35,9 @@ fmi2_xml_model_description_t * fmi2_xml_allocate_model_description( jm_callbacks } md = (fmi2_xml_model_description_t*)cb->calloc(1, sizeof(fmi2_xml_model_description_t)); if(!md) { - jm_log_fatal(cb, module, "Could not allocate memory"); - return 0; - } + jm_log_fatal(cb, module, "Could not allocate memory"); + return 0; + } md->callbacks = cb; @@ -72,11 +72,11 @@ fmi2_xml_model_description_t * fmi2_xml_allocate_model_description( jm_callbacks md->defaultExperiment.stepSize = FMI2_DEFAULT_EXPERIMENT_STEPSIZE; jm_vector_init(jm_string)(&md->sourceFilesME, 0, cb); - jm_vector_init(jm_string)(&md->sourceFilesCS, 0, cb); + jm_vector_init(jm_string)(&md->sourceFilesCS, 0, cb); - jm_vector_init(jm_string)(&md->vendorList, 0, cb); - jm_vector_init(jm_string)(&md->logCategories, 0, cb); - jm_vector_init(jm_string)(&md->logCategoryDescriptions, 0, cb); + jm_vector_init(jm_string)(&md->vendorList, 0, cb); + jm_vector_init(jm_string)(&md->logCategories, 0, cb); + jm_vector_init(jm_string)(&md->logCategoryDescriptions, 0, cb); jm_vector_init(jm_named_ptr)(&md->unitDefinitions, 0, cb); jm_vector_init(jm_named_ptr)(&md->displayUnitDefinitions, 0, cb); @@ -85,20 +85,20 @@ fmi2_xml_model_description_t * fmi2_xml_allocate_model_description( jm_callbacks jm_vector_init(jm_named_ptr)(&md->variablesByName, 0, cb); - md->variablesOrigOrder = 0; + md->variablesOrigOrder = 0; - md->variablesByVR = 0; + md->variablesByVR = 0; jm_vector_init(jm_string)(&md->descriptions, 0, cb); md->fmuKind = fmi2_fmu_kind_unknown; - { - int i = fmi2_capabilities_Num; - while(i > 0) - md->capabilities[--i] = 0; - md->capabilities[fmi2_me_completedEventIterationIsProvided] = 1; - } + { + int i = fmi2_capabilities_Num; + while(i > 0) + md->capabilities[--i] = 0; + md->capabilities[fmi2_me_completedEventIterationIsProvided] = 1; + } return md; } @@ -130,19 +130,19 @@ void fmi2_xml_clear_model_description( fmi2_xml_model_description_t* md) { md->defaultExperiment.stepSize = 0; jm_vector_foreach(jm_string)(&md->sourceFilesME, (void(*)(const char*))md->callbacks->free); - jm_vector_free_data(jm_string)(&md->sourceFilesME); + jm_vector_free_data(jm_string)(&md->sourceFilesME); jm_vector_foreach(jm_string)(&md->sourceFilesCS, (void(*)(const char*))md->callbacks->free); - jm_vector_free_data(jm_string)(&md->sourceFilesCS); + jm_vector_free_data(jm_string)(&md->sourceFilesCS); jm_vector_foreach(jm_string)(&md->vendorList, (void(*)(const char*))md->callbacks->free); jm_vector_free_data(jm_string)(&md->vendorList); jm_vector_foreach(jm_string)(&md->logCategories, (void(*)(const char*))md->callbacks->free); - jm_vector_free_data(jm_string)(&md->logCategories); + jm_vector_free_data(jm_string)(&md->logCategories); jm_vector_foreach(jm_string)(&md->logCategoryDescriptions, (void(*)(const char*))md->callbacks->free); - jm_vector_free_data(jm_string)(&md->logCategoryDescriptions); + jm_vector_free_data(jm_string)(&md->logCategoryDescriptions); jm_named_vector_free_data(&md->unitDefinitions); jm_named_vector_free_data(&md->displayUnitDefinitions); @@ -150,20 +150,20 @@ void fmi2_xml_clear_model_description( fmi2_xml_model_description_t* md) { fmi2_xml_free_type_definitions_data(&md->typeDefinitions); jm_named_vector_free_data(&md->variablesByName); - if(md->variablesOrigOrder) { - jm_vector_free(jm_voidp)(md->variablesOrigOrder); - md->variablesOrigOrder = 0; - } + if(md->variablesOrigOrder) { + jm_vector_free(jm_voidp)(md->variablesOrigOrder); + md->variablesOrigOrder = 0; + } if(md->variablesByVR) { - jm_vector_free(jm_voidp)(md->variablesByVR); - md->variablesByVR = 0; - } + jm_vector_free(jm_voidp)(md->variablesByVR); + md->variablesByVR = 0; + } jm_vector_foreach(jm_string)(&md->descriptions, (void(*)(const char*))md->callbacks->free); jm_vector_free_data(jm_string)(&md->descriptions); - fmi2_xml_free_model_structure(md->modelStructure); - md->modelStructure = 0; + fmi2_xml_free_model_structure(md->modelStructure); + md->modelStructure = 0; } int fmi2_xml_is_model_description_empty(fmi2_xml_model_description_t* md) { @@ -171,19 +171,19 @@ int fmi2_xml_is_model_description_empty(fmi2_xml_model_description_t* md) { } const char* fmi2_xml_get_last_error(fmi2_xml_model_description_t* md) { - return jm_get_last_error(md->callbacks); + return jm_get_last_error(md->callbacks); } void fmi2_xml_clear_last_error(fmi2_xml_model_description_t* md) { - jm_clear_last_error(md->callbacks); + jm_clear_last_error(md->callbacks); /* return (md->status != fmi2_xml_model_description_enu_error); */ } void fmi2_xml_free_model_description(fmi2_xml_model_description_t* md) { jm_callbacks* cb; - if(!md) return; - cb = md->callbacks; + if(!md) return; + cb = md->callbacks; fmi2_xml_clear_model_description(md); cb->free(md); } @@ -297,16 +297,16 @@ double fmi2_xml_get_default_experiment_step(fmi2_xml_model_description_t* md) { #undef LOG_WARN_IF_ATTR_NOT_DEFINED fmi2_fmu_kind_enu_t fmi2_xml_get_fmu_kind(fmi2_xml_model_description_t* md) { - return md->fmuKind; + return md->fmuKind; } unsigned int* fmi2_xml_get_capabilities(fmi2_xml_model_description_t* md) { - return md->capabilities; + return md->capabilities; } unsigned int fmi2_xml_get_capability(fmi2_xml_model_description_t* md, fmi2_capabilities_enu_t id) { - assert((unsigned)id < (unsigned)fmi2_capabilities_Num); - return md->capabilities[id]; + assert((unsigned)id < (unsigned)fmi2_capabilities_Num); + return md->capabilities[id]; } fmi2_xml_unit_definitions_t* fmi2_xml_get_unit_definitions(fmi2_xml_model_description_t* md) { @@ -314,92 +314,92 @@ fmi2_xml_unit_definitions_t* fmi2_xml_get_unit_definitions(fmi2_xml_model_descri } unsigned int fmi2_xml_get_unit_definitions_number(fmi2_xml_unit_definitions_t* ud) { - if(!ud) { - assert(ud && "Unit definitions cannot be NULL"); - return 0; - } + if(!ud) { + assert(ud && "Unit definitions cannot be NULL"); + return 0; + } return (unsigned int)jm_vector_get_size(jm_named_ptr)(&ud->definitions); } fmi2_xml_type_definitions_t* fmi2_xml_get_type_definitions(fmi2_xml_model_description_t* md) { - assert(md); + assert(md); return &md->typeDefinitions; } /** \brief Get the number of vendors that had annotations in the XML*/ size_t fmi2_xml_get_vendors_num(fmi2_xml_model_description_t* md) { - assert(md); - return jm_vector_get_size(jm_string)(&md->vendorList); + assert(md); + return jm_vector_get_size(jm_string)(&md->vendorList); } jm_vector(jm_string)* fmi2_xml_get_log_categories(fmi2_xml_model_description_t* md) { - assert(md); - return &md->logCategories; + assert(md); + return &md->logCategories; } jm_vector(jm_string)* fmi2_xml_get_log_category_descriptions(fmi2_xml_model_description_t* md) { - assert(md); - return &md->logCategoryDescriptions; + assert(md); + return &md->logCategoryDescriptions; } jm_vector(jm_string)* fmi2_xml_get_source_files_me(fmi2_xml_model_description_t* md) { - assert(md); - return &md->sourceFilesME; + assert(md); + return &md->sourceFilesME; } jm_vector(jm_string)* fmi2_xml_get_source_files_cs(fmi2_xml_model_description_t* md) { - assert(md); - return &md->sourceFilesCS; + assert(md); + return &md->sourceFilesCS; } fmi2_xml_model_structure_t* fmi2_xml_get_model_structure(fmi2_xml_model_description_t* md) { - assert(md); - return md->modelStructure; + assert(md); + return md->modelStructure; } /** \brief Get the name of the vendor with that had annotations in the XML by index */ const char* fmi2_xml_get_vendor_name(fmi2_xml_model_description_t* md, size_t index) { - assert(fmi2_xml_get_vendors_num(md) > index); + assert(fmi2_xml_get_vendors_num(md) > index); - return jm_vector_get_item(jm_string)(&md->vendorList,index); + return jm_vector_get_item(jm_string)(&md->vendorList,index); } int fmi2_xml_is_valid_model_ID_char(char ch) { - return ((( ch >= 'A') && (ch <= 'Z')) || - (( ch >= 'a') && (ch <= 'z')) || - (ch == '_')); + return ((( ch >= 'A') && (ch <= 'Z')) || + (( ch >= 'a') && (ch <= 'z')) || + (ch == '_')); } int fmi2_xml_is_valid_model_ID(const char* str) { - size_t i, len = strlen(str); - char ch = str[0]; - if( !fmi2_xml_is_valid_model_ID_char(ch)) return 0; - for(i = 1; i < len; i++) { - ch = str[i]; - if( !fmi2_xml_is_valid_model_ID_char(ch) && (ch < '0') && (ch > '9')) return 0; - } - return 1; + size_t i, len = strlen(str); + char ch = str[0]; + if( !fmi2_xml_is_valid_model_ID_char(ch)) return 0; + for(i = 1; i < len; i++) { + ch = str[i]; + if( !fmi2_xml_is_valid_model_ID_char(ch) && (ch < '0') && (ch > '9')) return 0; + } + return 1; } int fmi2_xml_handle_fmiModelDescription(fmi2_xml_parser_context_t *context, const char* data) { jm_name_ID_map_t namingConventionMap[] = {{"flat",fmi2_naming_enu_flat},{"structured", fmi2_naming_enu_structured},{0,0}}; fmi2_xml_model_description_t* md = context->modelDescription; if(!data) { - unsigned int numEventIndicators=0; - int ret; + unsigned int numEventIndicators=0; + int ret; if(context -> currentElmID != fmi2_xml_elmID_none) { fmi2_xml_parse_fatal(context, "fmi2_xml_model_description must be the root XML element"); return -1; } - jm_log_verbose(context->callbacks, module, "Parsing XML element fmiModelDescription"); - md->fmuKind = fmi2_fmu_kind_unknown; + jm_log_verbose(context->callbacks, module, "Parsing XML element fmiModelDescription"); + md->fmuKind = fmi2_fmu_kind_unknown; /* process the attributes */ - ret = /* */ + ret = /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_fmiVersion, 1, &(md->fmi2_xml_standard_version)) || /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_modelName, 1, &(md->modelName)) || - /* */ + /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_guid, 1, &(md->GUID)) || /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_description, 0, &(md->description)) || @@ -407,11 +407,11 @@ int fmi2_xml_handle_fmiModelDescription(fmi2_xml_parser_context_t *context, cons fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_author, 0, &(md->author)) || /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_version, 0, &(md->version)) || - /* */ + /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_copyright, 0, &(md->copyright)) || - /* */ + /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_license, 0, &(md->license)) || - /* */ + /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_generationTool, 0, &(md->generationTool)) || /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_generationDateAndTime, 0, &(md->generationDateAndTime)) || @@ -419,31 +419,31 @@ int fmi2_xml_handle_fmiModelDescription(fmi2_xml_parser_context_t *context, cons fmi2_xml_set_attr_enum(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_variableNamingConvention, 0, (unsigned*)&(md->namingConvension), fmi2_naming_enu_flat, namingConventionMap) || /* */ fmi2_xml_set_attr_uint(context, fmi2_xml_elmID_fmiModelDescription, fmi_attr_id_numberOfEventIndicators, 0, &numEventIndicators,0); - md->numberOfEventIndicators = numEventIndicators; - return (ret ); + md->numberOfEventIndicators = numEventIndicators; + return (ret ); } else { - /* check that fmuKind is defined and that model identifies are valid*/ - if(md->fmuKind == fmi2_fmu_kind_unknown) { - fmi2_xml_parse_fatal(context, "Neither ModelExchange nor CoSimulation element were parsed correctly. FMU kind not known."); - return -1; - } - if( (md->fmuKind != fmi2_fmu_kind_cs) && !fmi2_xml_is_valid_model_ID(fmi2_xml_get_model_identifier_ME(md))) { - fmi2_xml_parse_error(context, "Model identifier '%s' is not valid (must be a valid C-identifier)", fmi2_xml_get_model_identifier_ME(md)); - return -1; - } - if( (md->fmuKind != fmi2_fmu_kind_me) && !fmi2_xml_is_valid_model_ID(fmi2_xml_get_model_identifier_CS(md))) { - fmi2_xml_parse_error(context, "Model identifier '%s' is not valid (must be a valid C-identifier)", fmi2_xml_get_model_identifier_CS(md)); - return -1; - } - if( (md->fmuKind == fmi2_fmu_kind_me_and_cs) && (strcmp(fmi2_xml_get_model_identifier_CS(md), fmi2_xml_get_model_identifier_ME(md)) == 0)) { - jm_log_info(context->callbacks,module, "Found model identifiers for ModelExchange and CoSimulation"); - return 1; - } - if(!md->modelStructure) { - fmi2_xml_parse_fatal(context, "No model structure information available. Cannot continue."); - return -1; - } + /* check that fmuKind is defined and that model identifies are valid*/ + if(md->fmuKind == fmi2_fmu_kind_unknown) { + fmi2_xml_parse_fatal(context, "Neither ModelExchange nor CoSimulation element were parsed correctly. FMU kind not known."); + return -1; + } + if( (md->fmuKind != fmi2_fmu_kind_cs) && !fmi2_xml_is_valid_model_ID(fmi2_xml_get_model_identifier_ME(md))) { + fmi2_xml_parse_error(context, "Model identifier '%s' is not valid (must be a valid C-identifier)", fmi2_xml_get_model_identifier_ME(md)); + return -1; + } + if( (md->fmuKind != fmi2_fmu_kind_me) && !fmi2_xml_is_valid_model_ID(fmi2_xml_get_model_identifier_CS(md))) { + fmi2_xml_parse_error(context, "Model identifier '%s' is not valid (must be a valid C-identifier)", fmi2_xml_get_model_identifier_CS(md)); + return -1; + } + if( (md->fmuKind == fmi2_fmu_kind_me_and_cs) && (strcmp(fmi2_xml_get_model_identifier_CS(md), fmi2_xml_get_model_identifier_ME(md)) == 0)) { + jm_log_info(context->callbacks,module, "Found model identifiers for ModelExchange and CoSimulation"); + return 1; + } + if(!md->modelStructure) { + fmi2_xml_parse_fatal(context, "No model structure information available. Cannot continue."); + return -1; + } return 0; } } @@ -451,18 +451,18 @@ int fmi2_xml_handle_fmiModelDescription(fmi2_xml_parser_context_t *context, cons int fmi2_xml_handle_ModelExchange(fmi2_xml_parser_context_t *context, const char* data) { fmi2_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element ModelExchange"); + jm_log_verbose(context->callbacks, module, "Parsing XML element ModelExchange"); /* reset handles for the elements that are specific under ModelExchange */ fmi2_xml_set_element_handle(context, "SourceFiles", FMI2_XML_ELM_ID(SourceFiles)); fmi2_xml_set_element_handle(context, "File", FMI2_XML_ELM_ID(File)); - md->fmuKind = fmi2_fmu_kind_me; + md->fmuKind = fmi2_fmu_kind_me; /* process the attributes */ /* */ if (fmi2_xml_is_attr_defined(context, fmi_attr_id_providesDirectionalDerivatives)) { - fmi2_xml_parse_error(context, "Attribute 'providesDirectionalDerivatives' has been renamed to 'providesDirectionalDerivative'."); + fmi2_xml_parse_error(context, "Attribute 'providesDirectionalDerivatives' has been renamed to 'providesDirectionalDerivative'."); if (fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_ModelExchange, fmi_attr_id_providesDirectionalDerivatives,0, &md->capabilities[fmi2_me_providesDirectionalDerivatives],0)) return -1; } @@ -471,24 +471,24 @@ int fmi2_xml_handle_ModelExchange(fmi2_xml_parser_context_t *context, const char &md->capabilities[fmi2_me_providesDirectionalDerivatives],0)) return -1; } - return ( /* */ + return ( /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_ModelExchange, fmi_attr_id_modelIdentifier, 1, &(md->modelIdentifierME)) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_ModelExchange, fmi_attr_id_needsExecutionTool,0, &md->capabilities[fmi2_me_needsExecutionTool],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_ModelExchange, fmi_attr_id_completedIntegratorStepNotNeeded,0, &md->capabilities[fmi2_me_completedIntegratorStepNotNeeded],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_ModelExchange, fmi_attr_id_canBeInstantiatedOnlyOncePerProcess,0, &md->capabilities[fmi2_me_canBeInstantiatedOnlyOncePerProcess],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_ModelExchange, fmi_attr_id_canNotUseMemoryManagementFunctions,0, &md->capabilities[fmi2_me_canNotUseMemoryManagementFunctions],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_ModelExchange, fmi_attr_id_canGetAndSetFMUstate,0, &md->capabilities[fmi2_me_canGetAndSetFMUstate],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_ModelExchange, fmi_attr_id_canSerializeFMUstate,0, &md->capabilities[fmi2_me_canSerializeFMUstate],0) ); @@ -502,21 +502,21 @@ int fmi2_xml_handle_ModelExchange(fmi2_xml_parser_context_t *context, const char int fmi2_xml_handle_CoSimulation(fmi2_xml_parser_context_t *context, const char* data) { fmi2_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element CoSimulation"); + jm_log_verbose(context->callbacks, module, "Parsing XML element CoSimulation"); /* reset handles for the elements that are specific under CoSimulation */ fmi2_xml_set_element_handle(context, "SourceFiles", FMI2_XML_ELM_ID(SourceFilesCS)); fmi2_xml_set_element_handle(context, "File", FMI2_XML_ELM_ID(FileCS)); - if(md->fmuKind == fmi2_fmu_kind_me) - md->fmuKind = fmi2_fmu_kind_me_and_cs; - else - md->fmuKind = fmi2_fmu_kind_cs; + if(md->fmuKind == fmi2_fmu_kind_me) + md->fmuKind = fmi2_fmu_kind_me_and_cs; + else + md->fmuKind = fmi2_fmu_kind_cs; /* process the attributes */ /* */ if (fmi2_xml_is_attr_defined(context, fmi_attr_id_providesDirectionalDerivatives)) { - fmi2_xml_parse_error(context, "Attribute 'providesDirectionalDerivatives' has been renamed to 'providesDirectionalDerivative'."); + fmi2_xml_parse_error(context, "Attribute 'providesDirectionalDerivatives' has been renamed to 'providesDirectionalDerivative'."); if (fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_providesDirectionalDerivatives,0, &md->capabilities[fmi2_cs_providesDirectionalDerivatives],0)) return -1; } @@ -525,33 +525,33 @@ int fmi2_xml_handle_CoSimulation(fmi2_xml_parser_context_t *context, const char* &md->capabilities[fmi2_cs_providesDirectionalDerivatives],0)) return -1; } - return ( /* */ + return ( /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_CoSimulation, fmi_attr_id_modelIdentifier, 1, &(md->modelIdentifierCS)) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_needsExecutionTool,0, &md->capabilities[fmi2_cs_needsExecutionTool],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_canHandleVariableCommunicationStepSize,0, &md->capabilities[fmi2_cs_canHandleVariableCommunicationStepSize],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_canInterpolateInputs,0, &md->capabilities[fmi2_cs_canInterpolateInputs],0) || - /* */ + /* */ fmi2_xml_set_attr_uint(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_maxOutputDerivativeOrder,0, &md->capabilities[fmi2_cs_maxOutputDerivativeOrder],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_canRunAsynchronuously,0, &md->capabilities[fmi2_cs_canRunAsynchronuously],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_canBeInstantiatedOnlyOncePerProcess,0, &md->capabilities[fmi2_cs_canBeInstantiatedOnlyOncePerProcess],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_canNotUseMemoryManagementFunctions,0, &md->capabilities[fmi2_cs_canNotUseMemoryManagementFunctions],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_canGetAndSetFMUstate,0, &md->capabilities[fmi2_cs_canGetAndSetFMUstate],0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context,fmi2_xml_elmID_CoSimulation, fmi_attr_id_canSerializeFMUstate,0, &md->capabilities[fmi2_cs_canSerializeFMUstate],0) ); @@ -572,13 +572,13 @@ static int push_back_jm_string(fmi2_xml_parser_context_t *context, jm_vector(jm_ jm_string *pstring; pstring = jm_vector_push_back(jm_string)(stringvector, string); - len = jm_vector_get_size(char)(buf); + len = jm_vector_get_size(char)(buf); if(pstring ) *pstring = string = (char*)(context->callbacks->malloc(len + 1)); - if(!pstring || !string) { - fmi2_xml_parse_fatal(context, "Could not allocate memory"); - return -1; - } + if(!pstring || !string) { + fmi2_xml_parse_fatal(context, "Could not allocate memory"); + return -1; + } if (len != 0) { /* No need to memcpy empty strings (gives assetion error) */ memcpy(string, jm_vector_get_itemp(char)(buf,0), len); } @@ -626,7 +626,7 @@ int fmi2_xml_handle_FileCS(fmi2_xml_parser_context_t *context, const char* data) int fmi2_xml_handle_LogCategories(fmi2_xml_parser_context_t *context, const char* data) { /* fmi2_xml_model_description_t* md = context->modelDescription; */ if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element LogCategories"); + jm_log_verbose(context->callbacks, module, "Parsing XML element LogCategories"); /* process the attributes */ return (0); } @@ -643,9 +643,9 @@ int fmi2_xml_handle_Category(fmi2_xml_parser_context_t *context, const char* dat jm_vector(char)* bufName = fmi2_xml_reserve_parse_buffer(context,1,100); if (!bufName) return -1; - /* */ + /* */ if (fmi2_xml_set_attr_string(context, fmi2_xml_elmID_Category, fmi_attr_id_name, 1, bufName)) - return -1; + return -1; if (push_back_jm_string(context, &md->logCategories, bufName) < 0) return -1; if (fmi2_xml_set_attr_string(context, fmi2_xml_elmID_Category, fmi_attr_id_description, 0, bufName) < 0) return -1; @@ -691,38 +691,38 @@ int fmi2_xml_handle_DefaultExperiment(fmi2_xml_parser_context_t *context, const } jm_vector(jm_voidp)* fmi2_xml_get_variables_original_order(fmi2_xml_model_description_t* md) { - return md->variablesOrigOrder; + return md->variablesOrigOrder; } jm_vector(jm_named_ptr)* fmi2_xml_get_variables_alphabetical_order(fmi2_xml_model_description_t* md){ - return &md->variablesByName; + return &md->variablesByName; } jm_vector(jm_voidp)* fmi2_xml_get_variables_vr_order(fmi2_xml_model_description_t* md) { - return md->variablesByVR; + return md->variablesByVR; } fmi2_xml_variable_t* fmi2_xml_get_variable_by_name(fmi2_xml_model_description_t* md, const char* name) { - jm_named_ptr key, *found; + jm_named_ptr key, *found; key.name = name; found = jm_vector_bsearch(jm_named_ptr)(&md->variablesByName, &key, jm_compare_named); - if(!found) return 0; - return found->ptr; + if(!found) return 0; + return found->ptr; } fmi2_xml_variable_t* fmi2_xml_get_variable_by_vr(fmi2_xml_model_description_t* md, fmi2_base_type_enu_t baseType, fmi2_value_reference_t vr) { fmi2_xml_variable_t key; fmi2_xml_variable_t *pkey = &key; - fmi2_xml_variable_type_base_t keyType; - fmi2_xml_variable_t *v = 0; + fmi2_xml_variable_type_base_t keyType; + fmi2_xml_variable_t *v = 0; void ** found; - if(!md->variablesByVR) return 0; - keyType.structKind = fmi2_xml_type_struct_enu_props; - keyType.baseType = baseType; - key.type = &keyType; - key.vr = vr; + if(!md->variablesByVR) return 0; + keyType.structKind = fmi2_xml_type_struct_enu_props; + keyType.baseType = baseType; + key.type = &keyType; + key.vr = vr; key.aliasKind = fmi2_variable_is_not_alias; found = jm_vector_bsearch(jm_voidp)(md->variablesByVR,(void**)&pkey, fmi2_xml_compare_vr); diff --git a/src/XML/src/FMI2/fmi2_xml_model_description_impl.h b/src/XML/src/FMI2/fmi2_xml_model_description_impl.h index 09e64daa..54c254cc 100644 --- a/src/XML/src/FMI2/fmi2_xml_model_description_impl.h +++ b/src/XML/src/FMI2/fmi2_xml_model_description_impl.h @@ -72,7 +72,7 @@ struct fmi2_xml_model_description_t { jm_vector(char) modelIdentifierME; - jm_vector(char) modelIdentifierCS; + jm_vector(char) modelIdentifierCS; jm_vector(jm_string) sourceFilesME; jm_vector(jm_string) sourceFilesCS; @@ -80,7 +80,7 @@ struct fmi2_xml_model_description_t { jm_vector(jm_string) logCategories; jm_vector(jm_string) logCategoryDescriptions; - jm_vector(jm_string) vendorList; + jm_vector(jm_string) vendorList; jm_vector(jm_named_ptr) unitDefinitions; jm_vector(jm_named_ptr) displayUnitDefinitions; @@ -89,17 +89,17 @@ struct fmi2_xml_model_description_t { jm_string_set descriptions; - jm_vector(jm_named_ptr) variablesByName; + jm_vector(jm_named_ptr) variablesByName; jm_vector(jm_voidp)* variablesOrigOrder; - jm_vector(jm_voidp)* variablesByVR; + jm_vector(jm_voidp)* variablesByVR; fmi2_fmu_kind_enu_t fmuKind; unsigned int capabilities[fmi2_capabilities_Num]; - fmi2_xml_model_structure_t* modelStructure; + fmi2_xml_model_structure_t* modelStructure; }; #ifdef __cplusplus diff --git a/src/XML/src/FMI2/fmi2_xml_model_structure.c b/src/XML/src/FMI2/fmi2_xml_model_structure.c index 1b809cbd..0dbf2130 100644 --- a/src/XML/src/FMI2/fmi2_xml_model_structure.c +++ b/src/XML/src/FMI2/fmi2_xml_model_structure.c @@ -26,60 +26,60 @@ static const char * module = "FMI2XML"; fmi2_xml_model_structure_t* fmi2_xml_allocate_model_structure(jm_callbacks* cb) { - fmi2_xml_model_structure_t* ms = (fmi2_xml_model_structure_t*)(cb->calloc(1, sizeof(fmi2_xml_model_structure_t))); - if(!ms) return 0; + fmi2_xml_model_structure_t* ms = (fmi2_xml_model_structure_t*)(cb->calloc(1, sizeof(fmi2_xml_model_structure_t))); + if(!ms) return 0; - jm_vector_init(jm_voidp)(&ms->outputs,0,cb); - jm_vector_init(jm_voidp)(&ms->derivatives,0,cb); - jm_vector_init(jm_voidp)(&ms->discreteStates,0,cb); - jm_vector_init(jm_voidp)(&ms->initialUnknowns,0,cb); + jm_vector_init(jm_voidp)(&ms->outputs,0,cb); + jm_vector_init(jm_voidp)(&ms->derivatives,0,cb); + jm_vector_init(jm_voidp)(&ms->discreteStates,0,cb); + jm_vector_init(jm_voidp)(&ms->initialUnknowns,0,cb); - ms->isValidFlag = 1; + ms->isValidFlag = 1; ms->outputDeps = fmi2_xml_allocate_dependencies(cb); ms->derivativeDeps = fmi2_xml_allocate_dependencies(cb); ms->discreteStateDeps = fmi2_xml_allocate_dependencies(cb); ms->initialUnknownDeps = fmi2_xml_allocate_dependencies(cb); - if(!ms->outputDeps || !ms->derivativeDeps || !ms->discreteStateDeps || !ms->initialUnknownDeps) { - fmi2_xml_free_model_structure(ms); - return 0; - } + if(!ms->outputDeps || !ms->derivativeDeps || !ms->discreteStateDeps || !ms->initialUnknownDeps) { + fmi2_xml_free_model_structure(ms); + return 0; + } - return ms; + return ms; } void fmi2_xml_free_model_structure(fmi2_xml_model_structure_t* ms) { - jm_callbacks* cb; - if(!ms) return; - cb = ms->outputs.callbacks; + jm_callbacks* cb; + if(!ms) return; + cb = ms->outputs.callbacks; - jm_vector_free_data(jm_voidp)(&ms->outputs); - jm_vector_free_data(jm_voidp)(&ms->derivatives); - jm_vector_free_data(jm_voidp)(&ms->discreteStates); - jm_vector_free_data(jm_voidp)(&ms->initialUnknowns); + jm_vector_free_data(jm_voidp)(&ms->outputs); + jm_vector_free_data(jm_voidp)(&ms->derivatives); + jm_vector_free_data(jm_voidp)(&ms->discreteStates); + jm_vector_free_data(jm_voidp)(&ms->initialUnknowns); fmi2_xml_free_dependencies(ms->outputDeps); fmi2_xml_free_dependencies(ms->derivativeDeps); fmi2_xml_free_dependencies(ms->discreteStateDeps); fmi2_xml_free_dependencies(ms->initialUnknownDeps); - cb->free(ms); + cb->free(ms); } jm_vector(jm_voidp)* fmi2_xml_get_outputs(fmi2_xml_model_structure_t* ms) { - return &ms->outputs; + return &ms->outputs; } jm_vector(jm_voidp)* fmi2_xml_get_derivatives(fmi2_xml_model_structure_t* ms){ - return &ms->derivatives; + return &ms->derivatives; } jm_vector(jm_voidp)* fmi2_xml_get_discrete_states(fmi2_xml_model_structure_t* ms){ - return &ms->discreteStates; + return &ms->discreteStates; } jm_vector(jm_voidp)* fmi2_xml_get_initial_unknowns(fmi2_xml_model_structure_t* ms){ - return &ms->initialUnknowns; + return &ms->initialUnknowns; } @@ -122,73 +122,73 @@ void fmi2_xml_get_initial_unknowns_dependencies(fmi2_xml_model_structure_t* ms, fmi2_xml_dependencies_t* fmi2_xml_allocate_dependencies(jm_callbacks* cb) { - fmi2_xml_dependencies_t* dep = (fmi2_xml_dependencies_t*)(cb->malloc(sizeof(fmi2_xml_dependencies_t))); - if(!dep) return 0; - jm_vector_init(size_t)(&dep->startIndex, 0, cb); - jm_vector_push_back(size_t)(&dep->startIndex, 0); + fmi2_xml_dependencies_t* dep = (fmi2_xml_dependencies_t*)(cb->malloc(sizeof(fmi2_xml_dependencies_t))); + if(!dep) return 0; + jm_vector_init(size_t)(&dep->startIndex, 0, cb); + jm_vector_push_back(size_t)(&dep->startIndex, 0); - jm_vector_init(size_t)(&dep->dependencyIndex, 0, cb); - jm_vector_init(char)(&dep->dependencyFactorKind, 0, cb); + jm_vector_init(size_t)(&dep->dependencyIndex, 0, cb); + jm_vector_init(char)(&dep->dependencyFactorKind, 0, cb); - dep->isRowMajor = 1; + dep->isRowMajor = 1; - return dep; + return dep; } void fmi2_xml_zero_empty_dependencies(fmi2_xml_dependencies_t** pdep) { - fmi2_xml_dependencies_t* dep =*pdep; - size_t ndep = jm_vector_get_size(size_t)(&dep->dependencyIndex); - size_t i; - if(!dep) return; - for(i = 0; idependencyIndex, i)) break; - } - if(i == ndep) { - fmi2_xml_free_dependencies(dep); - *pdep = 0; - } + fmi2_xml_dependencies_t* dep =*pdep; + size_t ndep = jm_vector_get_size(size_t)(&dep->dependencyIndex); + size_t i; + if(!dep) return; + for(i = 0; idependencyIndex, i)) break; + } + if(i == ndep) { + fmi2_xml_free_dependencies(dep); + *pdep = 0; + } } void fmi2_xml_free_dependencies(fmi2_xml_dependencies_t* dep) { jm_callbacks* cb; - if(!dep) return; + if(!dep) return; cb = dep->startIndex.callbacks; - jm_vector_free_data(size_t)(&dep->startIndex); + jm_vector_free_data(size_t)(&dep->startIndex); - jm_vector_free_data(size_t)(&dep->dependencyIndex); - jm_vector_free_data(char)(&dep->dependencyFactorKind); + jm_vector_free_data(size_t)(&dep->dependencyIndex); + jm_vector_free_data(char)(&dep->dependencyFactorKind); cb->free(dep); } int fmi2_xml_check_model_structure(fmi2_xml_model_description_t* md) { - fmi2_xml_model_structure_t* ms = md->modelStructure; + fmi2_xml_model_structure_t* ms = md->modelStructure; - if(!ms || !ms->isValidFlag) return 0; + if(!ms || !ms->isValidFlag) return 0; - return ms->isValidFlag; + return ms->isValidFlag; } int fmi2_xml_handle_ModelStructure(fmi2_xml_parser_context_t *context, const char* data) { fmi2_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_verbose(context->callbacks, module,"Parsing XML element ModelStructure"); - /** allocate model structure */ - md->modelStructure = fmi2_xml_allocate_model_structure(md->callbacks); - if(!md->modelStructure) { - fmi2_xml_parse_fatal(context, module, "Could not allocate memory"); - return -1; - } + jm_log_verbose(context->callbacks, module,"Parsing XML element ModelStructure"); + /** allocate model structure */ + md->modelStructure = fmi2_xml_allocate_model_structure(md->callbacks); + if(!md->modelStructure) { + fmi2_xml_parse_fatal(context, module, "Could not allocate memory"); + return -1; + } } else { - /** make sure model structure information is consistent */ + /** make sure model structure information is consistent */ - if(!fmi2_xml_check_model_structure(md)) { - fmi2_xml_parse_fatal(context, "Model structure is not valid due to detected errors. Cannot continue."); - return -1; - } -/* md->numberOfContinuousStates = jm_vector_get_size(jm_voidp)(&md->modelStructure->states); */ + if(!fmi2_xml_check_model_structure(md)) { + fmi2_xml_parse_fatal(context, "Model structure is not valid due to detected errors. Cannot continue."); + return -1; + } +/* md->numberOfContinuousStates = jm_vector_get_size(jm_voidp)(&md->modelStructure->states); */ } return 0; @@ -238,7 +238,7 @@ int fmi2_xml_handle_InitialUnknowns(fmi2_xml_parser_context_t *context, const ch int fmi2_xml_parse_dependencies(fmi2_xml_parser_context_t *context, fmi2_xml_elm_enu_t parentElmID, - fmi2_xml_dependencies_t* deps) + fmi2_xml_dependencies_t* deps) { fmi2_xml_model_description_t* md = context->modelDescription; fmi2_xml_model_structure_t* ms = md->modelStructure; diff --git a/src/XML/src/FMI2/fmi2_xml_model_structure_impl.h b/src/XML/src/FMI2/fmi2_xml_model_structure_impl.h index 84c70156..f4f5dabb 100644 --- a/src/XML/src/FMI2/fmi2_xml_model_structure_impl.h +++ b/src/XML/src/FMI2/fmi2_xml_model_structure_impl.h @@ -29,33 +29,33 @@ extern "C" { /** \brief Structure for keeping information about variable dependencies. */ typedef struct fmi2_xml_dependencies_t { - int isRowMajor; /** Information is stored in row-major format flag */ + int isRowMajor; /** Information is stored in row-major format flag */ - /** Start index in dependency data for the corresponding row (isRowMajor=1) or column (isRowMajor = 0) */ - jm_vector(size_t) startIndex; + /** Start index in dependency data for the corresponding row (isRowMajor=1) or column (isRowMajor = 0) */ + jm_vector(size_t) startIndex; - /** Column indices (isRowMajor=1) or row indices (isRowMajor=0) - Note that indices are 1-based. 0 has a special meaning - depends on all. - */ - jm_vector(size_t) dependencyIndex; - jm_vector(char) dependencyFactorKind; + /** Column indices (isRowMajor=1) or row indices (isRowMajor=0) + Note that indices are 1-based. 0 has a special meaning - depends on all. + */ + jm_vector(size_t) dependencyIndex; + jm_vector(char) dependencyFactorKind; } fmi2_xml_dependencies_t; fmi2_xml_dependencies_t* fmi2_xml_allocate_dependencies(jm_callbacks* cb); void fmi2_xml_free_dependencies(fmi2_xml_dependencies_t* dep); - + struct fmi2_xml_model_structure_t { - jm_vector(jm_voidp) outputs; - jm_vector(jm_voidp) derivatives; - jm_vector(jm_voidp) discreteStates; - jm_vector(jm_voidp) initialUnknowns; + jm_vector(jm_voidp) outputs; + jm_vector(jm_voidp) derivatives; + jm_vector(jm_voidp) discreteStates; + jm_vector(jm_voidp) initialUnknowns; fmi2_xml_dependencies_t* outputDeps; fmi2_xml_dependencies_t* derivativeDeps; fmi2_xml_dependencies_t* discreteStateDeps; fmi2_xml_dependencies_t* initialUnknownDeps; - int isValidFlag; /**\ brief The flag is used to signal if an error was discovered and the model structure is not usable */ + int isValidFlag; /**\ brief The flag is used to signal if an error was discovered and the model structure is not usable */ }; #ifdef __cplusplus diff --git a/src/XML/src/FMI2/fmi2_xml_parser.c b/src/XML/src/FMI2/fmi2_xml_parser.c index 1ecb7c8b..03602ebc 100644 --- a/src/XML/src/FMI2/fmi2_xml_parser.c +++ b/src/XML/src/FMI2/fmi2_xml_parser.c @@ -84,15 +84,15 @@ const char *fmi2_xmlAttrNames[fmi2_xml_attr_number] = { fmi2_xml_scheme_info_t fmi2_xml_scheme_info[fmi2_xml_elm_number] = { FMI2_XML_ELMLIST(EXPAND_ELM_SCHEME) - {fmi2_xml_elm_actual_number,0,0}, - FMI2_XML_ELMLIST_ALT(EXPAND_ELM_SCHEME)}; + {fmi2_xml_elm_actual_number,0,0}, + FMI2_XML_ELMLIST_ALT(EXPAND_ELM_SCHEME)}; #define EXPAND_ELM_NAME(elm) { #elm, fmi2_xml_handle_##elm, fmi2_xml_elmID_##elm}, fmi2_xml_element_handle_map_t fmi2_element_handle_map[fmi2_xml_elm_number] = { FMI2_XML_ELMLIST(EXPAND_ELM_NAME) - { NULL, NULL, fmi2_xml_elm_actual_number}, - FMI2_XML_ELMLIST_ALT(EXPAND_ELM_NAME) + { NULL, NULL, fmi2_xml_elm_actual_number}, + FMI2_XML_ELMLIST_ALT(EXPAND_ELM_NAME) }; void fmi2_xml_parse_free_context(fmi2_xml_parser_context_t *context) { @@ -129,7 +129,7 @@ void fmi2_xml_parse_free_context(fmi2_xml_parser_context_t *context) { void fmi2_xml_parse_fatal(fmi2_xml_parser_context_t *context, const char* fmt, ...) { va_list args; va_start (args, fmt); - jm_log_fatal_v(context->callbacks, module, fmt, args); + jm_log_fatal_v(context->callbacks, module, fmt, args); va_end (args); XML_StopParser(context->parser,0); } @@ -137,9 +137,9 @@ void fmi2_xml_parse_fatal(fmi2_xml_parser_context_t *context, const char* fmt, . void fmi2_xml_parse_error(fmi2_xml_parser_context_t *context, const char* fmt, ...) { va_list args; va_start (args, fmt); - if(context->parser) - jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser)); - jm_log_error_v(context->callbacks, module,fmt, args); + if(context->parser) + jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser)); + jm_log_error_v(context->callbacks, module,fmt, args); va_end (args); } @@ -252,7 +252,7 @@ int fmi2_xml_set_attr_int(fmi2_xml_parser_context_t *context, fmi2_xml_elm_enu_t ret = fmi2_xml_get_attr_str(context, elmID, attrID,required,&strVal); if(ret) return ret; if(!strVal && !required) { - *field = defaultVal; + *field = defaultVal; return 0; } @@ -372,11 +372,11 @@ int fmi2_create_elm_map(fmi2_xml_parser_context_t* context) { void fmi2_xml_set_element_handle(fmi2_xml_parser_context_t *context, const char* elm, fmi2_xml_elm_enu_t id) { fmi2_xml_element_handle_map_t keyEl; fmi2_xml_element_handle_map_t* currentElMap; - keyEl.elementName = elm; + keyEl.elementName = elm; currentElMap = jm_vector_bsearch(fmi2_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi2_xml_compare_elmName); - - currentElMap->elementHandle = fmi2_element_handle_map[id].elementHandle;; - currentElMap->elemID = id; + + currentElMap->elementHandle = fmi2_element_handle_map[id].elementHandle;; + currentElMap->elemID = id; } @@ -385,79 +385,79 @@ static void XMLCALL fmi2_parse_element_start(void *c, const char *elm, const cha fmi2_xml_element_handle_map_t keyEl; fmi2_xml_element_handle_map_t* currentElMap; jm_named_ptr* currentMap; - fmi2_xml_elm_enu_t currentID; + fmi2_xml_elm_enu_t currentID; int i; fmi2_xml_parser_context_t *context = c; context->has_produced_data_warning = 0; - if(context->useAnyHandleFlg) { - fmi2_xml_callbacks_t* anyH = context->anyHandle; - context->anyElmCount++; - if(anyH && anyH->startHandle) { + if(context->useAnyHandleFlg) { + fmi2_xml_callbacks_t* anyH = context->anyHandle; + context->anyElmCount++; + if(anyH && anyH->startHandle) { int ret = anyH->startHandle(anyH->context, context->anyToolName, context->anyParent, elm, attr); - if(ret != 0) { - fmi2_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); - } - } - return; - } - - if(context->skipElementCnt) { - context->skipElementCnt++; + if(ret != 0) { + fmi2_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); + } + } + return; + } + + if(context->skipElementCnt) { + context->skipElementCnt++; jm_log_warning(context->callbacks, module, "[Line:%u] Skipping nested XML element '%s'", - XML_GetCurrentLineNumber(context->parser), elm); - return; - } - - keyEl.elementName = elm; - /* find the element handle by name */ + XML_GetCurrentLineNumber(context->parser), elm); + return; + } + + keyEl.elementName = elm; + /* find the element handle by name */ currentElMap = jm_vector_bsearch(fmi2_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi2_xml_compare_elmName); if(!currentElMap) { /* not found error*/ jm_log_error(context->callbacks, module, "[Line:%u] Unknown element '%s' in XML, skipping", - XML_GetCurrentLineNumber(context->parser), elm); - context->skipElementCnt = 1; + XML_GetCurrentLineNumber(context->parser), elm); + context->skipElementCnt = 1; return; } currentID = currentElMap->elemID; - /* Check that parent-child & siblings are fine */ - { - fmi2_xml_elm_enu_t parentID = context->currentElmID; - fmi2_xml_elm_enu_t siblingID = context->lastElmID; - - if(fmi2_xml_scheme_info[currentID].parentID != parentID) { - jm_log_error(context->callbacks, module, - "[Line:%u] XML element '%s' cannot be placed inside '%s', skipping", - XML_GetCurrentLineNumber(context->parser), elm, fmi2_element_handle_map[parentID].elementName); - context->skipElementCnt = 1; - return; - } - if(siblingID != fmi2_xml_elmID_none) { - if(siblingID == currentID) { - if(!fmi2_xml_scheme_info[currentID].multipleAllowed) { - jm_log_error(context->callbacks, module, - "[Line:%u] Multiple instances of XML element '%s' are not allowed, skipping", - XML_GetCurrentLineNumber(context->parser), elm); - context->skipElementCnt = 1; - return; - } - } - else { - int lastSiblingIndex = fmi2_xml_scheme_info[siblingID].siblingIndex; - int curSiblingIndex = fmi2_xml_scheme_info[currentID].siblingIndex; - - if(lastSiblingIndex >= curSiblingIndex) { - jm_log_error(context->callbacks, module, - "[Line:%u] XML element '%s' cannot be placed after element '%s', skipping", - XML_GetCurrentLineNumber(context->parser), elm, fmi2_element_handle_map[siblingID].elementName); - context->skipElementCnt = 1; - return; - } - } - } - context->lastElmID = fmi2_xml_elmID_none; - } + /* Check that parent-child & siblings are fine */ + { + fmi2_xml_elm_enu_t parentID = context->currentElmID; + fmi2_xml_elm_enu_t siblingID = context->lastElmID; + + if(fmi2_xml_scheme_info[currentID].parentID != parentID) { + jm_log_error(context->callbacks, module, + "[Line:%u] XML element '%s' cannot be placed inside '%s', skipping", + XML_GetCurrentLineNumber(context->parser), elm, fmi2_element_handle_map[parentID].elementName); + context->skipElementCnt = 1; + return; + } + if(siblingID != fmi2_xml_elmID_none) { + if(siblingID == currentID) { + if(!fmi2_xml_scheme_info[currentID].multipleAllowed) { + jm_log_error(context->callbacks, module, + "[Line:%u] Multiple instances of XML element '%s' are not allowed, skipping", + XML_GetCurrentLineNumber(context->parser), elm); + context->skipElementCnt = 1; + return; + } + } + else { + int lastSiblingIndex = fmi2_xml_scheme_info[siblingID].siblingIndex; + int curSiblingIndex = fmi2_xml_scheme_info[currentID].siblingIndex; + + if(lastSiblingIndex >= curSiblingIndex) { + jm_log_error(context->callbacks, module, + "[Line:%u] XML element '%s' cannot be placed after element '%s', skipping", + XML_GetCurrentLineNumber(context->parser), elm, fmi2_element_handle_map[siblingID].elementName); + context->skipElementCnt = 1; + return; + } + } + } + context->lastElmID = fmi2_xml_elmID_none; + } /* process the attributes */ i = 0; @@ -467,40 +467,40 @@ static void XMLCALL fmi2_parse_element_start(void *c, const char *elm, const cha currentMap = jm_vector_bsearch(jm_named_ptr)(context->attrMap, &key, jm_compare_named); if(!currentMap) { #define XMLSchema_instance "http://www.w3.org/2001/XMLSchema-instance" - const size_t stdNSlen = strlen(XMLSchema_instance); + const size_t stdNSlen = strlen(XMLSchema_instance); const size_t attrStrLen = strlen(attr[i]); - if((attrStrLen > stdNSlen) && (attr[i][stdNSlen] == '|') && (strncmp(attr[i], XMLSchema_instance, stdNSlen) == 0)) { - const char* localName = attr[i] + stdNSlen + 1; - if( strcmp(localName, "noNamespaceSchemaLocation") == 0) - jm_log_warning(context->callbacks, module, "Attribute noNamespaceSchemaLocation='%s' is ignored. Using standard fmiModelDescription.xsd.", - attr[i+1]); - else if((strcmp(localName, "nil") == 0) - || (strcmp(localName, "type") == 0)) { - jm_log_warning(context->callbacks, module, "Attribute {" XMLSchema_instance "}%s=%s is ignored", - localName, attr[i+1]); - } - else if(strcmp(localName, "schemaLocation") == 0) { - /* just skip this */ - } - else { - jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); - } - } - else if( - (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_States", attr[i]) == 0) || - (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_Inputs", attr[i]) == 0) || - (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_States", attr[i]) == 0) || - (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_Inputs", attr[i]) == 0) - ) { - jm_log_warning(context->callbacks, module, - "FMI API function fmiGetPartialDerivatives is removed from the specification. Attribute %s will be ignored.", attr[i]); - } - else { - /* not found error*/ - jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); - } + if((attrStrLen > stdNSlen) && (attr[i][stdNSlen] == '|') && (strncmp(attr[i], XMLSchema_instance, stdNSlen) == 0)) { + const char* localName = attr[i] + stdNSlen + 1; + if( strcmp(localName, "noNamespaceSchemaLocation") == 0) + jm_log_warning(context->callbacks, module, "Attribute noNamespaceSchemaLocation='%s' is ignored. Using standard fmiModelDescription.xsd.", + attr[i+1]); + else if((strcmp(localName, "nil") == 0) + || (strcmp(localName, "type") == 0)) { + jm_log_warning(context->callbacks, module, "Attribute {" XMLSchema_instance "}%s=%s is ignored", + localName, attr[i+1]); + } + else if(strcmp(localName, "schemaLocation") == 0) { + /* just skip this */ + } + else { + jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); + } + } + else if( + (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_States", attr[i]) == 0) || + (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_Inputs", attr[i]) == 0) || + (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_States", attr[i]) == 0) || + (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_Inputs", attr[i]) == 0) + ) { + jm_log_warning(context->callbacks, module, + "FMI API function fmiGetPartialDerivatives is removed from the specification. Attribute %s will be ignored.", attr[i]); + } + else { + /* not found error*/ + jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); + } } - else { + else { /* save attr value (still as string) for further handling */ const char** mapItem = (const char**)currentMap->ptr; *mapItem = attr[i+1]; @@ -509,11 +509,11 @@ static void XMLCALL fmi2_parse_element_start(void *c, const char *elm, const cha } /* handle the element */ - if( currentElMap->elementHandle(context, 0) ) { - /* try to skip and continue anyway */ + if( currentElMap->elementHandle(context, 0) ) { + /* try to skip and continue anyway */ if(!context->skipElementCnt) context->skipElementCnt = 1; } - if(context->skipElementCnt) return; + if(context->skipElementCnt) return; /* check that the element handle had process all the attributes */ for(i = 0; i < fmi2_xml_attr_number; i++) { if(jm_vector_get_item(jm_string)(context->attrBuffer, i)) { @@ -532,25 +532,25 @@ static void XMLCALL fmi2_parse_element_end(void* c, const char *elm) { fmi2_xml_element_handle_map_t keyEl; fmi2_xml_element_handle_map_t* currentElMap; - fmi2_xml_elm_enu_t currentID; + fmi2_xml_elm_enu_t currentID; fmi2_xml_parser_context_t *context = c; - if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { - fmi2_xml_callbacks_t* anyH = context->anyHandle; - context->anyElmCount--; - if(anyH && anyH->endHandle) { - int ret = anyH->endHandle(anyH->context, elm); - if(ret != 0) { - fmi2_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); - } - } - return; - } - - if(context->skipElementCnt) { - context->skipElementCnt--; - return; - } + if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { + fmi2_xml_callbacks_t* anyH = context->anyHandle; + context->anyElmCount--; + if(anyH && anyH->endHandle) { + int ret = anyH->endHandle(anyH->context, elm); + if(ret != 0) { + fmi2_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); + } + } + return; + } + + if(context->skipElementCnt) { + context->skipElementCnt--; + return; + } keyEl.elementName = elm; currentElMap = jm_vector_bsearch(fmi2_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi2_xml_compare_elmName); @@ -564,13 +564,13 @@ static void XMLCALL fmi2_parse_element_end(void* c, const char *elm) { if(currentID != context -> currentElmID) { /* missmatch error*/ fmi2_xml_parse_fatal(context, "Element end '%s' does not match element start '%s' in XML", elm, - fmi2_element_handle_map[context -> currentElmID].elementName); + fmi2_element_handle_map[context -> currentElmID].elementName); return; } jm_vector_push_back(char)(&context->elmData, 0); - if( currentElMap->elementHandle(context, jm_vector_get_itemp(char)(&context->elmData, 0) )) { + if( currentElMap->elementHandle(context, jm_vector_get_itemp(char)(&context->elmData, 0) )) { return; } jm_vector_resize(char)(&context->elmData, 0); @@ -595,33 +595,33 @@ static void XMLCALL fmi2_parse_element_end(void* c, const char *elm) { * to replace this with the empty string whenever we encounter "\n". */ static void XMLCALL fmi2_parse_element_data(void* c, const XML_Char *s, int len) { - int i; + int i; fmi2_xml_parser_context_t *context = c; - if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { - fmi2_xml_callbacks_t* anyH = context->anyHandle; - if(anyH && anyH->dataHandle) { - int ret = anyH->dataHandle(anyH->context, s, len); - if(ret != 0) { - fmi2_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); - } - } - return; - } - if(context->skipElementCnt) { - return; - } - for(i = 0; i< len;i++) { + if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { + fmi2_xml_callbacks_t* anyH = context->anyHandle; + if(anyH && anyH->dataHandle) { + int ret = anyH->dataHandle(anyH->context, s, len); + if(ret != 0) { + fmi2_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); + } + } + return; + } + if(context->skipElementCnt) { + return; + } + for(i = 0; i< len;i++) { char ch = s[i]; if((ch != '\n') && (ch != ' ') && (ch != '\t')) { break; } } - if((i != len) && !context->has_produced_data_warning) { - jm_log_warning(context->callbacks, module, "[Line:%u] Skipping unexpected XML element data", - XML_GetCurrentLineNumber(context->parser)); - context->has_produced_data_warning = 1; - } + if((i != len) && !context->has_produced_data_warning) { + jm_log_warning(context->callbacks, module, "[Line:%u] Skipping unexpected XML element data", + XML_GetCurrentLineNumber(context->parser)); + context->has_produced_data_warning = 1; + } } void fmi2_check_variable_naming_conventions(fmi2_xml_model_description_t *md) { @@ -678,15 +678,15 @@ int fmi2_xml_parse_model_description(fmi2_xml_model_description_t* md, } context->lastBaseUnit = 0; context->skipOneVariableFlag = 0; - context->skipElementCnt = 0; + context->skipElementCnt = 0; jm_stack_init(int)(&context->elmStack, context->callbacks); jm_vector_init(char)(&context->elmData, 0, context->callbacks); context->lastElmID = fmi2_xml_elmID_none; context->currentElmID = fmi2_xml_elmID_none; - context->anyElmCount = 0; - context->useAnyHandleFlg = 0; + context->anyElmCount = 0; + context->useAnyHandleFlg = 0; context->anyParent = 0; - context->anyHandle = xml_callbacks; + context->anyHandle = xml_callbacks; /* Set locale such that parsing does not depend on the environment. * For example, LC_NUMERIC affects what sscanf identifies as the floating @@ -726,7 +726,7 @@ int fmi2_xml_parse_model_description(fmi2_xml_model_description_t* md, if(ferror(file)) { fmi2_xml_parse_fatal(context, "Error reading from file %s", filename); fclose(file); - fmi2_xml_parse_free_context(context); + fmi2_xml_parse_free_context(context); return -1; } if (!XML_Parse(parser, text, n, feof(file))) { @@ -734,7 +734,7 @@ int fmi2_xml_parse_model_description(fmi2_xml_model_description_t* md, (int)XML_GetCurrentLineNumber(parser), XML_ErrorString(XML_GetErrorCode(parser))); fclose(file); - fmi2_xml_parse_free_context(context); + fmi2_xml_parse_free_context(context); return -1; /* failure */ } } diff --git a/src/XML/src/FMI2/fmi2_xml_parser.h b/src/XML/src/FMI2/fmi2_xml_parser.h index 6a07a40d..1de15dc6 100644 --- a/src/XML/src/FMI2/fmi2_xml_parser.h +++ b/src/XML/src/FMI2/fmi2_xml_parser.h @@ -35,7 +35,7 @@ extern "C" { EXPAND_XML_ATTRNAME(fmiVersion) \ EXPAND_XML_ATTRNAME(factor) \ EXPAND_XML_ATTRNAME(offset) \ - FMI2_SI_BASE_UNITS(EXPAND_XML_ATTRNAME) \ + FMI2_SI_BASE_UNITS(EXPAND_XML_ATTRNAME) \ EXPAND_XML_ATTRNAME(name) \ EXPAND_XML_ATTRNAME(description) \ EXPAND_XML_ATTRNAME(quantity) \ @@ -43,7 +43,7 @@ extern "C" { EXPAND_XML_ATTRNAME(displayUnit) \ EXPAND_XML_ATTRNAME(relativeQuantity) \ EXPAND_XML_ATTRNAME(unbounded) \ - EXPAND_XML_ATTRNAME(min) \ + EXPAND_XML_ATTRNAME(min) \ EXPAND_XML_ATTRNAME(max) \ EXPAND_XML_ATTRNAME(nominal) \ EXPAND_XML_ATTRNAME(declaredType) \ @@ -78,13 +78,13 @@ extern "C" { EXPAND_XML_ATTRNAME(input) \ EXPAND_XML_ATTRNAME(needsExecutionTool) \ EXPAND_XML_ATTRNAME(canHandleVariableCommunicationStepSize) \ - EXPAND_XML_ATTRNAME(completedIntegratorStepNotNeeded) \ - EXPAND_XML_ATTRNAME(canBeInstantiatedOnlyOncePerProcess) \ - EXPAND_XML_ATTRNAME(canNotUseMemoryManagementFunctions) \ - EXPAND_XML_ATTRNAME(canGetAndSetFMUstate) \ - EXPAND_XML_ATTRNAME(canSerializeFMUstate) \ - EXPAND_XML_ATTRNAME(providesDirectionalDerivatives) /* used for verification: checks that this attribute does not exist */ \ - EXPAND_XML_ATTRNAME(providesDirectionalDerivative) \ + EXPAND_XML_ATTRNAME(completedIntegratorStepNotNeeded) \ + EXPAND_XML_ATTRNAME(canBeInstantiatedOnlyOncePerProcess) \ + EXPAND_XML_ATTRNAME(canNotUseMemoryManagementFunctions) \ + EXPAND_XML_ATTRNAME(canGetAndSetFMUstate) \ + EXPAND_XML_ATTRNAME(canSerializeFMUstate) \ + EXPAND_XML_ATTRNAME(providesDirectionalDerivatives) /* used for verification: checks that this attribute does not exist */ \ + EXPAND_XML_ATTRNAME(providesDirectionalDerivative) \ EXPAND_XML_ATTRNAME(canInterpolateInputs) \ EXPAND_XML_ATTRNAME(maxOutputDerivativeOrder) \ EXPAND_XML_ATTRNAME(canRunAsynchronuously) @@ -98,7 +98,7 @@ typedef enum fmi2_xml_attr_enu_t { /** \brief Element names used in XML */ #define FMI2_XML_ELMLIST(EXPAND_XML_ELMNAME) \ EXPAND_XML_ELMNAME(fmiModelDescription) \ - EXPAND_XML_ELMNAME(ModelExchange) \ + EXPAND_XML_ELMNAME(ModelExchange) \ EXPAND_XML_ELMNAME(CoSimulation) \ EXPAND_XML_ELMNAME(SourceFiles) \ EXPAND_XML_ELMNAME(File) \ @@ -115,8 +115,8 @@ typedef enum fmi2_xml_attr_enu_t { EXPAND_XML_ELMNAME(ModelVariables) \ EXPAND_XML_ELMNAME(ScalarVariable) \ EXPAND_XML_ELMNAME(Annotations) \ - EXPAND_XML_ELMNAME(LogCategories) \ - EXPAND_XML_ELMNAME(Category) \ + EXPAND_XML_ELMNAME(LogCategories) \ + EXPAND_XML_ELMNAME(Category) \ EXPAND_XML_ELMNAME(Real) \ EXPAND_XML_ELMNAME(Integer) \ EXPAND_XML_ELMNAME(Boolean) \ @@ -153,10 +153,10 @@ FMI2_XML_ELMLIST_ALT(EXPAND_ELM_HANDLE) #define FMI2_XML_ELM_ID(elm) fmi2_xml_elmID_##elm #define FMI2_XML_LIST_ELM_ID(elm) ,FMI2_XML_ELM_ID(elm) typedef enum fmi2_xml_elm_enu_t { - fmi2_xml_elmID_none = -1 + fmi2_xml_elmID_none = -1 FMI2_XML_ELMLIST(FMI2_XML_LIST_ELM_ID) - ,fmi2_xml_elm_actual_number - FMI2_XML_ELMLIST_ALT(FMI2_XML_LIST_ELM_ID) + ,fmi2_xml_elm_actual_number + FMI2_XML_ELMLIST_ALT(FMI2_XML_LIST_ELM_ID) ,fmi2_xml_elm_number } fmi2_xml_elm_enu_t; @@ -165,18 +165,18 @@ typedef int (*fmi2_xml_element_handle_ft)(fmi2_xml_parser_context_t *context, co typedef struct fmi2_xml_element_handle_map_t fmi2_xml_element_handle_map_t; /** Keeps information about the allowed parent element ID, index among siblings in a sequence and if - multiple elements of this type are allowed in a sequence. + multiple elements of this type are allowed in a sequence. */ typedef struct { - fmi2_xml_elm_enu_t parentID; /* expected parent ID for an element */ - int siblingIndex; /* index among siblings */ - int multipleAllowed; /* multiple elements of this kind kan come in a sequence as siblings*/ + fmi2_xml_elm_enu_t parentID; /* expected parent ID for an element */ + int siblingIndex; /* index among siblings */ + int multipleAllowed; /* multiple elements of this kind kan come in a sequence as siblings*/ } fmi2_xml_scheme_info_t; struct fmi2_xml_element_handle_map_t { const char* elementName; fmi2_xml_element_handle_ft elementHandle; - fmi2_xml_elm_enu_t elemID; + fmi2_xml_elm_enu_t elemID; }; @@ -234,14 +234,14 @@ struct fmi2_xml_parser_context_t { * Incremented when an invalid element(or nested elements of invalid root * element) is found. Decremented when invalid element end tags are parsed. */ - int skipElementCnt; + int skipElementCnt; /** * There is no guarantee that all text will be handled in one call to the * function implementing the XML_CharacterDataHandler, and this variable * saves if a warning has already been generated. */ - int has_produced_data_warning; + int has_produced_data_warning; /** * Used to get parent element. @@ -267,7 +267,7 @@ struct fmi2_xml_parser_context_t { * Element ID of the last processed sibling, or fmi3_xml_elmID_none if * no siblings have been processed. */ - fmi2_xml_elm_enu_t lastElmID; + fmi2_xml_elm_enu_t lastElmID; /** * Used for error checking and scheme verification. @@ -279,14 +279,14 @@ struct fmi2_xml_parser_context_t { * on enter: self * on exit: parent */ - fmi2_xml_elm_enu_t currentElmID; + fmi2_xml_elm_enu_t currentElmID; /* Variables for handling tool-specific XML elements */ - int anyElmCount; - int useAnyHandleFlg; - char* anyToolName; - void* anyParent; - fmi2_xml_callbacks_t* anyHandle; + int anyElmCount; + int useAnyHandleFlg; + char* anyToolName; + void* anyParent; + fmi2_xml_callbacks_t* anyHandle; /* Data for restoring locale after parsing */ jm_locale_t* jm_locale; diff --git a/src/XML/src/FMI2/fmi2_xml_query.c b/src/XML/src/FMI2/fmi2_xml_query.c index 43589cc9..1961679e 100644 --- a/src/XML/src/FMI2/fmi2_xml_query.c +++ b/src/XML/src/FMI2/fmi2_xml_query.c @@ -23,31 +23,31 @@ jm_name_ID_map_t fmi2_xml_q_elementary_map[fmi2_xml_elementary_enu_num+1] = { - #define FMI2_XML_Q_ELEMENTARY_MAP(name) {#name , fmi2_xml_q_elmentary_enu_##name}, + #define FMI2_XML_Q_ELEMENTARY_MAP(name) {#name , fmi2_xml_q_elmentary_enu_##name}, FMI2_XML_Q_ELEMENTARY(FMI2_XML_Q_ELEMENTARY_MAP) - {0,0} + {0,0} }; fmi2_xml_q_scan_elementary_ft fmi2_xml_q_scan_elementary_handles[fmi2_xml_elementary_enu_num + 1] = { - #define FMI2_XML_Q_ELEMENTARY_SCAN(name) fmi2_xml_q_scan_elementary_##name, + #define FMI2_XML_Q_ELEMENTARY_SCAN(name) fmi2_xml_q_scan_elementary_##name, FMI2_XML_Q_ELEMENTARY(FMI2_XML_Q_ELEMENTARY_SCAN) - 0 + 0 }; fmi2_xml_q_eval_elementary_ft fmi2_xml_q_eval_elementary_handles[fmi2_xml_elementary_enu_num + 1] = { - #define FMI2_XML_Q_ELEMENTARY_EVAL(name) fmi2_xml_q_eval_elementary_##name, + #define FMI2_XML_Q_ELEMENTARY_EVAL(name) fmi2_xml_q_eval_elementary_##name, FMI2_XML_Q_ELEMENTARY(FMI2_XML_Q_ELEMENTARY_EVAL) - 0 + 0 }; jm_name_ID_map_t fmi2_xml_q_op_map[] = { - {"or", fmi2_xml_q_term_enu_OR}, - {"and", fmi2_xml_q_term_enu_AND}, - {"not", fmi2_xml_q_term_enu_NOT}, - {"&&", fmi2_xml_q_term_enu_AND}, - {"||", fmi2_xml_q_term_enu_OR}, - {"!", fmi2_xml_q_term_enu_NOT}, - {0,-1} + {"or", fmi2_xml_q_term_enu_OR}, + {"and", fmi2_xml_q_term_enu_AND}, + {"not", fmi2_xml_q_term_enu_NOT}, + {"&&", fmi2_xml_q_term_enu_AND}, + {"||", fmi2_xml_q_term_enu_OR}, + {"!", fmi2_xml_q_term_enu_NOT}, + {0,-1} }; static void fmi2_xml_q_skip_space(jm_string* cur) { @@ -62,139 +62,139 @@ static void fmi2_xml_q_skip_space(jm_string* cur) { } int fmi2_xml_q_scan_string(fmi2_xml_q_context_t* context, char** param_str) { - fmi2_xml_q_expression_t* expr = &context->expr; - char* dest; - jm_string cur = context->query + context->curCh; + fmi2_xml_q_expression_t* expr = &context->expr; + char* dest; + jm_string cur = context->query + context->curCh; char ch = *cur; char strterm ; size_t strlen = 0; - if((ch == '\'') || (ch == '"')) /* either ' or " can be used as string terminator */ - strterm = ch; + if((ch == '\'') || (ch == '"')) /* either ' or " can be used as string terminator */ + strterm = ch; else - return -1; + return -1; do { ch = cur[strlen+1]; dest = jm_vector_push_back(char)(&expr->strbuf, ch); - assert(dest); + assert(dest); strlen++; } while((ch != strterm) && ch); if(!ch) return -1; /* string is not terminated */ - *dest = 0; /* put terminating 0*/ - strlen--; /* last zero is not a part of the string */ - *param_str = dest - strlen; + *dest = 0; /* put terminating 0*/ + strlen--; /* last zero is not a part of the string */ + *param_str = dest - strlen; return strlen; } int fmi2_xml_q_scan_elementary_name(fmi2_xml_q_context_t* context, fmi2_xml_q_terminal_t* term) { - jm_string startCh = &context->query[context->curCh]; - jm_string curCh = startCh; - size_t len; - - /* expecting: []'='[] */ - - fmi2_xml_q_skip_space(&curCh); - if(*curCh != '=') - return (int)(startCh - curCh); - curCh++; - fmi2_xml_q_skip_space(&curCh); - - len = (int)(curCh - startCh); - - context->curCh += len; - startCh += len; - - if( fmi2_xml_q_scan_string(context, &term->param_str) < 0) - return (int)(startCh - curCh); - - /* treat as regexp - > skip for now - if(term->param_str[0] == '^') { - - } - else */ - { - term->param_i = strlen(term->param_str); - if( (strchr ( term->param_str, '*') != 0) || (strchr ( term->param_str, '?') != 0) ){ - /* treat as wildcard */ - term->param_i *= -1; - } - } - return (int)(curCh - startCh); + jm_string startCh = &context->query[context->curCh]; + jm_string curCh = startCh; + size_t len; + + /* expecting: []'='[] */ + + fmi2_xml_q_skip_space(&curCh); + if(*curCh != '=') + return (int)(startCh - curCh); + curCh++; + fmi2_xml_q_skip_space(&curCh); + + len = (int)(curCh - startCh); + + context->curCh += len; + startCh += len; + + if( fmi2_xml_q_scan_string(context, &term->param_str) < 0) + return (int)(startCh - curCh); + + /* treat as regexp - > skip for now + if(term->param_str[0] == '^') { + + } + else */ + { + term->param_i = strlen(term->param_str); + if( (strchr ( term->param_str, '*') != 0) || (strchr ( term->param_str, '?') != 0) ){ + /* treat as wildcard */ + term->param_i *= -1; + } + } + return (int)(curCh - startCh); } int fmi2_xml_q_eval_elementary_name(fmi2_xml_variable_t* var, fmi2_xml_q_terminal_t* term) { - assert(term->specific == fmi2_xml_q_elmentary_enu_name); - - if(term->param_i < 0) { - return jm_wc_match(term->param_str, fmi2_xml_get_variable_name(var)); - } - else - return (strncmp(term->param_str, fmi2_xml_get_variable_name(var), term->param_i) == 0); - return 0; + assert(term->specific == fmi2_xml_q_elmentary_enu_name); + + if(term->param_i < 0) { + return jm_wc_match(term->param_str, fmi2_xml_get_variable_name(var)); + } + else + return (strncmp(term->param_str, fmi2_xml_get_variable_name(var), term->param_i) == 0); + return 0; } int fmi2_xml_q_scan_elementary_unit(fmi2_xml_q_context_t* context, fmi2_xml_q_terminal_t* term) { - jm_string startCh = &context->query[context->curCh]; - jm_string curCh = startCh; - size_t len; + jm_string startCh = &context->query[context->curCh]; + jm_string curCh = startCh; + size_t len; - /* expecting: []'='[] */ + /* expecting: []'='[] */ - fmi2_xml_q_skip_space(&curCh); - if(*curCh != '=') - return (int)(startCh - curCh); - curCh++; - fmi2_xml_q_skip_space(&curCh); + fmi2_xml_q_skip_space(&curCh); + if(*curCh != '=') + return (int)(startCh - curCh); + curCh++; + fmi2_xml_q_skip_space(&curCh); - len = (int)(curCh - startCh); + len = (int)(curCh - startCh); - context->curCh += len; - startCh += len; + context->curCh += len; + startCh += len; - if( fmi2_xml_q_scan_string(context, &term->param_str) < 0) - return (int)(startCh - curCh); - return (int)(curCh - startCh); + if( fmi2_xml_q_scan_string(context, &term->param_str) < 0) + return (int)(startCh - curCh); + return (int)(curCh - startCh); } int fmi2_xml_q_eval_elementary_unit(fmi2_xml_variable_t* var, fmi2_xml_q_terminal_t* term) { - return 0; + return 0; } int fmi2_xml_q_get_number(fmi2_xml_q_context_t* context, char* cur, double* val, char* buf) { - int len; - if(sscanf(cur, "%lg%s", val, buf) != 2) return 0; - len = strlen(cur) - strlen(buf); - return len; + int len; + if(sscanf(cur, "%lg%s", val, buf) != 2) return 0; + len = strlen(cur) - strlen(buf); + return len; } int fmi2_xml_q_get_keyword(fmi2_xml_q_context_t* context, char* cur, size_t* len, char* buf) { char ch = *cur; size_t i = 0, id; *len = 0; - if( (ch == '|') || (ch == '&') ) { - if(ch == cur[i+1]) { - buf[i++] = ch; - buf[i++] = ch; - } - } - else { - while(isalpha(ch)) { - buf[i++] = tolower(ch); - ch = cur[i]; - } - } - + if( (ch == '|') || (ch == '&') ) { + if(ch == cur[i+1]) { + buf[i++] = ch; + buf[i++] = ch; + } + } + else { + while(isalpha(ch)) { + buf[i++] = tolower(ch); + ch = cur[i]; + } + } + if(!i) return -1; - { - jm_name_ID_map_t key; - jm_name_ID_map_t* map; - key.name = buf; - map = jm_vector_bsearch(jm_name_ID_map_t)(&context->elementary_map, &key,jm_compare_name); - if(!map) return -1; - id = map->ID; - } + { + jm_name_ID_map_t key; + jm_name_ID_map_t* map; + key.name = buf; + map = jm_vector_bsearch(jm_name_ID_map_t)(&context->elementary_map, &key,jm_compare_name); + if(!map) return -1; + id = map->ID; + } *len = i; return id; } @@ -227,18 +227,18 @@ int pattern2regexp(const char* pattern, jm_vector(char)* re) { } int fmi2_xml_evaluate_terminal(fmi2_xml_variable_t* var, fmi2_xml_q_terminal_t* term) { - return fmi2_xml_q_eval_elementary_handles[term->specific](var, term); + return fmi2_xml_q_eval_elementary_handles[term->specific](var, term); } int fmi2_xml_q_filter_variable(fmi2_xml_variable_t* var, fmi2_xml_q_expression_t* expr) { size_t cur, len = jm_vector_get_size(jm_voidp)(&expr->expression); - jm_vector(jm_voidp)* stack = &expr->stack; - fmi2_xml_q_terminal_t * term; + jm_vector(jm_voidp)* stack = &expr->stack; + fmi2_xml_q_terminal_t * term; for(cur = 0; cur < len; cur++) { fmi2_xml_q_terminal_t *argL, *argR; size_t curlen = jm_vector_get_size(jm_voidp)(stack); - term = (fmi2_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(&expr->expression, cur); + term = (fmi2_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(&expr->expression, cur); argL = (curlen > 0) ? (fmi2_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,curlen -1):0; argR = (curlen > 1) ? (fmi2_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,curlen -2):0; @@ -262,140 +262,140 @@ int fmi2_xml_q_filter_variable(fmi2_xml_variable_t* var, fmi2_xml_q_expression_t } break; case fmi2_xml_q_term_enu_NOT: - assert(argL); + assert(argL); jm_vector_resize(jm_voidp)(stack, curlen -1); if(argL->kind == fmi2_xml_q_term_enu_TRUE) jm_vector_push_back(jm_voidp)(stack, &expr->termFalse); - else if(argL->kind == fmi2_xml_q_term_enu_TRUE) + else if(argL->kind == fmi2_xml_q_term_enu_TRUE) jm_vector_push_back(jm_voidp)(stack, &expr->termTrue); else { jm_vector_push_back(jm_voidp)(stack, (fmi2_xml_evaluate_terminal(var, argL)? &expr->termFalse: &expr->termTrue)); } - break; - case fmi2_xml_q_term_enu_LP: - case fmi2_xml_q_term_enu_RP: - assert(0); - break; + break; + case fmi2_xml_q_term_enu_LP: + case fmi2_xml_q_term_enu_RP: + assert(0); + break; default: jm_vector_push_back(jm_voidp)(stack, term); /* only evaluate when needed. push as is at first */ } } assert(jm_vector_get_size(jm_voidp)(stack) == 1); - + term = (fmi2_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,0); if(term->kind == fmi2_xml_q_term_enu_FALSE) return 0; - assert(term->kind == fmi2_xml_q_term_enu_TRUE); + assert(term->kind == fmi2_xml_q_term_enu_TRUE); return 1; } fmi2_xml_q_expression_t* fmi2_xml_alloc_expression(jm_string query) { - return 0; + return 0; } int fmi2_xml_q_parse_elementary(fmi2_xml_q_context_t* context, fmi2_xml_q_terminal_t* term) { - return 0; + return 0; } void fmi2_xml_q_init_context(fmi2_xml_q_context_t* c, jm_callbacks* cb) { - size_t l = jm_vector_init(jm_name_ID_map_t)(&c->elementary_map, fmi2_xml_elementary_enu_num, cb); - assert(l); - for(l = 0; l < fmi2_xml_elementary_enu_num; l++) { - jm_vector_set_item(jm_name_ID_map_t)(&c->elementary_map, l,fmi2_xml_q_elementary_map[l]); - } - jm_vector_qsort(jm_name_ID_map_t)(&c->elementary_map,jm_compare_name); - c->query = 0; - c->qlen = 0; - c->curCh = 0; - jm_vector_init(char)(&c->buf,0,cb); - - { - fmi2_xml_q_expression_t* expr = &c->expr; - jm_vector_init(jm_voidp)(&expr->expression,0,cb); - jm_vector_init(jm_voidp)(&expr->stack,0,cb); - expr->termFalse.kind = fmi2_xml_q_term_enu_FALSE; - expr->termTrue.kind = fmi2_xml_q_term_enu_TRUE; - jm_vector_init(fmi2_xml_q_terminal_t)(&expr->terms,0,cb); - jm_vector_init(char)(&expr->strbuf, 0, cb); - } + size_t l = jm_vector_init(jm_name_ID_map_t)(&c->elementary_map, fmi2_xml_elementary_enu_num, cb); + assert(l); + for(l = 0; l < fmi2_xml_elementary_enu_num; l++) { + jm_vector_set_item(jm_name_ID_map_t)(&c->elementary_map, l,fmi2_xml_q_elementary_map[l]); + } + jm_vector_qsort(jm_name_ID_map_t)(&c->elementary_map,jm_compare_name); + c->query = 0; + c->qlen = 0; + c->curCh = 0; + jm_vector_init(char)(&c->buf,0,cb); + + { + fmi2_xml_q_expression_t* expr = &c->expr; + jm_vector_init(jm_voidp)(&expr->expression,0,cb); + jm_vector_init(jm_voidp)(&expr->stack,0,cb); + expr->termFalse.kind = fmi2_xml_q_term_enu_FALSE; + expr->termTrue.kind = fmi2_xml_q_term_enu_TRUE; + jm_vector_init(fmi2_xml_q_terminal_t)(&expr->terms,0,cb); + jm_vector_init(char)(&expr->strbuf, 0, cb); + } } void fmi2_xml_q_free_context_data(fmi2_xml_q_context_t* c){ - fmi2_xml_q_expression_t* expr = &c->expr; - jm_vector_free_data(jm_name_ID_map_t)(&c->elementary_map); - jm_vector_free_data(char)(&c->buf); - jm_vector_free_data(jm_voidp)(&expr->expression); - jm_vector_free_data(jm_voidp)(&expr->stack); - jm_vector_free_data(fmi2_xml_q_terminal_t)(&expr->terms); - jm_vector_free_data(char)(&expr->strbuf); + fmi2_xml_q_expression_t* expr = &c->expr; + jm_vector_free_data(jm_name_ID_map_t)(&c->elementary_map); + jm_vector_free_data(char)(&c->buf); + jm_vector_free_data(jm_voidp)(&expr->expression); + jm_vector_free_data(jm_voidp)(&expr->stack); + jm_vector_free_data(fmi2_xml_q_terminal_t)(&expr->terms); + jm_vector_free_data(char)(&expr->strbuf); } int fmi2_xml_q_parse_terminal(fmi2_xml_q_context_t* context, fmi2_xml_q_terminal_t** ppterm) { - int offset = 0; + int offset = 0; fmi2_xml_q_terminal_t* pterm; - jm_string startCh = context->query + context->curCh; - jm_string cur = startCh; - pterm = jm_vector_resize1(fmi2_xml_q_terminal_t)(&context->expr.terms); + jm_string startCh = context->query + context->curCh; + jm_string cur = startCh; + pterm = jm_vector_resize1(fmi2_xml_q_terminal_t)(&context->expr.terms); if(!pterm) return -1; - *ppterm = pterm; + *ppterm = pterm; fmi2_xml_q_skip_space(&cur); switch(*cur) { case '(': - pterm->kind = fmi2_xml_q_term_enu_LP; - break; + pterm->kind = fmi2_xml_q_term_enu_LP; + break; case ')': - pterm->kind = fmi2_xml_q_term_enu_RP; - break; + pterm->kind = fmi2_xml_q_term_enu_RP; + break; case '&': - pterm->kind = fmi2_xml_q_term_enu_AND; - break; + pterm->kind = fmi2_xml_q_term_enu_AND; + break; case '|': - pterm->kind = fmi2_xml_q_term_enu_OR; - break; + pterm->kind = fmi2_xml_q_term_enu_OR; + break; case '!': - pterm->kind = fmi2_xml_q_term_enu_NOT; - break; + pterm->kind = fmi2_xml_q_term_enu_NOT; + break; case 0: - pterm->kind = fmi2_xml_q_term_enu_END; - break; + pterm->kind = fmi2_xml_q_term_enu_END; + break; default: fmi2_xml_q_parse_elementary(context, pterm); } - fmi2_xml_q_skip_space(&cur); - return (int)(cur - startCh); + fmi2_xml_q_skip_space(&cur); + return (int)(cur - startCh); } int fmi2_xml_q_parse_query(fmi2_xml_q_context_t* context, jm_string query) { - fmi2_xml_q_expression_t* expr = &context->expr; + fmi2_xml_q_expression_t* expr = &context->expr; int qlen = strlen(query); - int offset = 0, curCh = 0; - int expectOperand = 1; - size_t stacklen = 0; + int offset = 0, curCh = 0; + int expectOperand = 1; + size_t stacklen = 0; fmi2_xml_q_terminal_t* stackTop = 0; - context->query = query; - context->qlen = qlen; - if(jm_vector_reserve(char)(&context->buf, qlen) < (size_t)qlen) return -1; - if(jm_vector_reserve(char)(&context->expr.strbuf, qlen) < (size_t)qlen) return -1; + context->query = query; + context->qlen = qlen; + if(jm_vector_reserve(char)(&context->buf, qlen) < (size_t)qlen) return -1; + if(jm_vector_reserve(char)(&context->expr.strbuf, qlen) < (size_t)qlen) return -1; while(curCh < qlen) { fmi2_xml_q_terminal_t* term; size_t explen = jm_vector_get_size(jm_voidp)(&expr->expression); fmi2_xml_q_terminal_t* expTop = explen? (fmi2_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->expression,explen -1):0; - offset = fmi2_xml_q_parse_terminal(context, &term); + offset = fmi2_xml_q_parse_terminal(context, &term); - if(offset < 0) return -curCh; + if(offset < 0) return -curCh; - stacklen = jm_vector_get_size(jm_voidp)(&expr->stack); + stacklen = jm_vector_get_size(jm_voidp)(&expr->stack); stackTop = stacklen ? (fmi2_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->stack,stacklen -1):(fmi2_xml_q_terminal_t*)0; switch(term -> kind) { case fmi2_xml_q_term_enu_LP: - if(!expectOperand) return -curCh; + if(!expectOperand) return -curCh; jm_vector_push_back(jm_voidp)(&expr->stack, term); break; case fmi2_xml_q_term_enu_RP: - if(expectOperand) return -curCh; + if(expectOperand) return -curCh; while(stackTop && (stackTop->kind != fmi2_xml_q_term_enu_LP)) { jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); stacklen--; @@ -407,8 +407,8 @@ int fmi2_xml_q_parse_query(fmi2_xml_q_context_t* context, jm_string query) { break; case fmi2_xml_q_term_enu_AND: - if(expectOperand) return -curCh; - expectOperand = 1; + if(expectOperand) return -curCh; + expectOperand = 1; if(!expTop) return -curCh; if(stackTop && (stackTop->kind == fmi2_xml_q_term_enu_AND)) jm_vector_push_back(jm_voidp)(&expr->expression, term); @@ -416,8 +416,8 @@ int fmi2_xml_q_parse_query(fmi2_xml_q_context_t* context, jm_string query) { jm_vector_push_back(jm_voidp)(&expr->stack, term); break; case fmi2_xml_q_term_enu_OR: - if(expectOperand) return -curCh; - expectOperand = 1; + if(expectOperand) return -curCh; + expectOperand = 1; if(!expTop) return -curCh; while(stackTop && ((stackTop->kind == fmi2_xml_q_term_enu_AND)||(stackTop->kind == fmi2_xml_q_term_enu_OR))) { jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); @@ -428,17 +428,17 @@ int fmi2_xml_q_parse_query(fmi2_xml_q_context_t* context, jm_string query) { jm_vector_push_back(jm_voidp)(&expr->stack, term); break; default: - if(!expectOperand) return -curCh; - expectOperand = 0; + if(!expectOperand) return -curCh; + expectOperand = 0; jm_vector_push_back(jm_voidp)(&expr->expression, term); } - curCh += offset; - context->curCh = curCh; + curCh += offset; + context->curCh = curCh; } - if(expectOperand) return -curCh; + if(expectOperand) return -curCh; while(stackTop && (stackTop->kind != fmi2_xml_q_term_enu_LP)) { - jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); + jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); jm_vector_resize(jm_voidp)(&expr->stack, stacklen -1); stacklen--; stackTop = stacklen? (fmi2_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->stack,stacklen -1):0; diff --git a/src/XML/src/FMI2/fmi2_xml_query.h b/src/XML/src/FMI2/fmi2_xml_query.h index 7ecc0a81..919330a7 100644 --- a/src/XML/src/FMI2/fmi2_xml_query.h +++ b/src/XML/src/FMI2/fmi2_xml_query.h @@ -77,27 +77,27 @@ typedef int (*fmi2_xml_q_eval_elementary_ft)(fmi2_xml_variable_t* var, fmi2_xml_ FMI2_XML_Q_ELEMENTARY(FMI2_XML_Q_ELEMENTARY_DECLARE_EVAL) typedef enum fmi2_xml_q_term_enu_t { - fmi2_xml_q_term_enu_elementary, - fmi2_xml_q_term_enu_LP, - fmi2_xml_q_term_enu_RP, - fmi2_xml_q_term_enu_OR, - fmi2_xml_q_term_enu_AND, - fmi2_xml_q_term_enu_NOT, - fmi2_xml_q_term_enu_END, - fmi2_xml_q_term_enu_TRUE, - fmi2_xml_q_term_enu_FALSE + fmi2_xml_q_term_enu_elementary, + fmi2_xml_q_term_enu_LP, + fmi2_xml_q_term_enu_RP, + fmi2_xml_q_term_enu_OR, + fmi2_xml_q_term_enu_AND, + fmi2_xml_q_term_enu_NOT, + fmi2_xml_q_term_enu_END, + fmi2_xml_q_term_enu_TRUE, + fmi2_xml_q_term_enu_FALSE } fmi2_xml_q_terminal_enu_t; struct fmi2_xml_q_terminal_t { - fmi2_xml_q_terminal_enu_t kind; + fmi2_xml_q_terminal_enu_t kind; - fmi2_xml_elementary_enu_t specific; + fmi2_xml_elementary_enu_t specific; - int param_i; - double param_d; - void* param_p; - char* param_str; + int param_i; + double param_d; + void* param_p; + char* param_str; }; @@ -114,20 +114,20 @@ struct fmi2_xml_q_expression_t { fmi2_xml_q_terminal_t termFalse, termTrue; fmi2_xml_q_term_vt terms; - jm_vector(char) strbuf; + jm_vector(char) strbuf; }; struct fmi2_xml_q_context_t { jm_vector(jm_name_ID_map_t) elementary_map; - jm_string query; + jm_string query; - size_t qlen; - int curCh; + size_t qlen; + int curCh; - jm_vector(char) buf; + jm_vector(char) buf; - fmi2_xml_q_expression_t expr; + fmi2_xml_q_expression_t expr; }; void fmi2_xml_q_init_context(fmi2_xml_q_context_t*, jm_callbacks* cb); diff --git a/src/XML/src/FMI2/fmi2_xml_type.c b/src/XML/src/FMI2/fmi2_xml_type.c index f3922cf3..1a4994bd 100644 --- a/src/XML/src/FMI2/fmi2_xml_type.c +++ b/src/XML/src/FMI2/fmi2_xml_type.c @@ -29,7 +29,7 @@ fmi2_xml_display_unit_t* fmi2_xml_get_type_display_unit(fmi2_xml_real_typedef_t* fmi2_xml_variable_typedef_t* vt = (void*)t; fmi2_xml_real_type_props_t * props = (fmi2_xml_real_type_props_t*)vt->super.nextLayer; fmi2_xml_display_unit_t* du = props->displayUnit; - if(!du || (&du->baseUnit->defaultDisplay == du)) return 0; + if(!du || (&du->baseUnit->defaultDisplay == du)) return 0; return du; } @@ -47,7 +47,7 @@ const char* fmi2_xml_get_type_name(fmi2_xml_variable_typedef_t* t) { } const char* fmi2_xml_get_type_description(fmi2_xml_variable_typedef_t* t) { - const char * ret = t->description; + const char * ret = t->description; return (ret ? ret : ""); } @@ -71,26 +71,26 @@ fmi2_xml_enumeration_typedef_t* fmi2_xml_get_type_as_enum(fmi2_xml_variable_type const char* fmi2_xml_get_type_quantity(fmi2_xml_variable_typedef_t* t) { fmi2_xml_variable_type_base_t* props = t->super.nextLayer; - const char * ret; + const char * ret; if(props->structKind != fmi2_xml_type_struct_enu_props) return 0; switch(props->baseType) { case fmi2_base_type_real: ret = ((fmi2_xml_real_type_props_t*)props)->quantity; - break; + break; case fmi2_base_type_int: ret = ((fmi2_xml_integer_type_props_t*)props)->quantity; - break; + break; case fmi2_base_type_bool: return 0; case fmi2_base_type_str: return 0; case fmi2_base_type_enum: - ret = ((fmi2_xml_enum_variable_props_t*)props)->quantity; - break; + ret = ((fmi2_xml_enum_variable_props_t*)props)->quantity; + break; default: return 0; } - return (ret ? ret : 0); + return (ret ? ret : 0); } double fmi2_xml_get_real_type_min(fmi2_xml_real_typedef_t* t) { @@ -122,13 +122,13 @@ fmi2_xml_unit_t* fmi2_xml_get_real_type_unit(fmi2_xml_real_typedef_t* t) { int fmi2_xml_get_real_type_is_relative_quantity(fmi2_xml_real_typedef_t* t) { fmi2_xml_variable_typedef_t* vt = (void*)t; fmi2_xml_real_type_props_t* props = (fmi2_xml_real_type_props_t*)(vt->super.nextLayer); - return props->super.isRelativeQuantity; + return props->super.isRelativeQuantity; } int fmi2_xml_get_real_type_is_unbounded(fmi2_xml_real_typedef_t* t) { fmi2_xml_variable_typedef_t* vt = (void*)t; fmi2_xml_real_type_props_t* props = (fmi2_xml_real_type_props_t*)(vt->super.nextLayer); - return props->super.isUnbounded; + return props->super.isUnbounded; } @@ -147,20 +147,20 @@ fmi2_integer_t fmi2_xml_get_integer_type_max(fmi2_xml_integer_typedef_t* t){ int fmi2_xml_get_enum_type_min(fmi2_xml_enumeration_typedef_t* t){ fmi2_xml_variable_typedef_t* vt = (void*)t; fmi2_xml_enum_typedef_props_t* props = (fmi2_xml_enum_typedef_props_t*)(vt->super.nextLayer); - fmi2_xml_enum_type_item_t* item; - if(jm_vector_get_size(jm_named_ptr)(&props->enumItems) == 0) return 0; - item = jm_vector_get_item(jm_named_ptr)(&props->enumItems, 0).ptr; - return item->value; + fmi2_xml_enum_type_item_t* item; + if(jm_vector_get_size(jm_named_ptr)(&props->enumItems) == 0) return 0; + item = jm_vector_get_item(jm_named_ptr)(&props->enumItems, 0).ptr; + return item->value; } int fmi2_xml_get_enum_type_max(fmi2_xml_enumeration_typedef_t* t){ fmi2_xml_variable_typedef_t* vt = (void*)t; fmi2_xml_enum_typedef_props_t* props = (fmi2_xml_enum_typedef_props_t*)(vt->super.nextLayer); - jm_named_ptr* itemp = jm_vector_get_lastp(jm_named_ptr)(&props->enumItems); - fmi2_xml_enum_type_item_t* item; - if(!itemp) return 0; - item = itemp->ptr; - return item->value; + jm_named_ptr* itemp = jm_vector_get_lastp(jm_named_ptr)(&props->enumItems); + fmi2_xml_enum_type_item_t* item; + if(!itemp) return 0; + item = itemp->ptr; + return item->value; } unsigned int fmi2_xml_get_enum_type_size(fmi2_xml_enumeration_typedef_t* t) { @@ -179,22 +179,22 @@ const char* fmi2_xml_get_enum_type_item_name(fmi2_xml_enumeration_typedef_t* t, int fmi2_xml_get_enum_type_item_value(fmi2_xml_enumeration_typedef_t* t, unsigned int item) { fmi2_xml_variable_typedef_t* vt = (fmi2_xml_variable_typedef_t*)(void*)t; fmi2_xml_enum_typedef_props_t* props = (fmi2_xml_enum_typedef_props_t*)(vt->super.nextLayer); - fmi2_xml_enum_type_item_t* eitem; + fmi2_xml_enum_type_item_t* eitem; if((item == 0) || (item > fmi2_xml_get_enum_type_size(t) )) return 0; - eitem = jm_vector_get_item(jm_named_ptr)(&props->enumItems,item-1).ptr; + eitem = jm_vector_get_item(jm_named_ptr)(&props->enumItems,item-1).ptr; return eitem->value; } const char* fmi2_xml_get_enum_type_value_name(fmi2_xml_enumeration_typedef_t* t, int value) { fmi2_xml_variable_typedef_t* vt = (fmi2_xml_variable_typedef_t*)(void*)t; fmi2_xml_enum_typedef_props_t* props = (fmi2_xml_enum_typedef_props_t*)(vt->super.nextLayer); - fmi2_xml_enum_type_item_t keyitem; - jm_named_ptr* itemp, key; - keyitem.value = value; - key.ptr = &keyitem; - itemp = jm_vector_bsearch(jm_named_ptr)(&props->enumItems, &key, fmi1_xml_compare_enum_val); + fmi2_xml_enum_type_item_t keyitem; + jm_named_ptr* itemp, key; + keyitem.value = value; + key.ptr = &keyitem; + itemp = jm_vector_bsearch(jm_named_ptr)(&props->enumItems, &key, fmi1_xml_compare_enum_val); if(!itemp) return 0; - return itemp->name; + return itemp->name; } @@ -212,8 +212,8 @@ void fmi2_xml_init_variable_type_base(fmi2_xml_variable_type_base_t* type, fmi2_ type->next = 0; type->structKind = kind; type->baseType = baseType; - type->isRelativeQuantity = 0; - type->isUnbounded = 0; + type->isRelativeQuantity = 0; + type->isUnbounded = 0; } void fmi2_xml_init_real_type_properties(fmi2_xml_real_type_props_t* type) { @@ -234,13 +234,13 @@ void fmi2_xml_init_integer_type_properties(fmi2_xml_integer_type_props_t* type) void fmi2_xml_init_enumeration_variable_properties(fmi2_xml_enum_variable_props_t* type, jm_callbacks* cb) { fmi2_xml_init_variable_type_base(&type->super, fmi2_xml_type_struct_enu_props,fmi2_base_type_enum); - type->quantity = 0; + type->quantity = 0; type->typeMin = 0; type->typeMax = 0; } void fmi2_xml_init_enumeration_type_properties(fmi2_xml_enum_typedef_props_t* type, jm_callbacks* cb) { - fmi2_xml_init_enumeration_variable_properties(&type->base, cb); + fmi2_xml_init_enumeration_variable_properties(&type->base, cb); jm_vector_init(jm_named_ptr)(&type->enumItems,0,cb); } @@ -275,16 +275,16 @@ void fmi2_xml_free_type_definitions_data(fmi2_xml_type_definitions_t* td) { while(cur) { next = cur->next; if( (cur->baseType == fmi2_base_type_enum) - && (cur->structKind == fmi2_xml_type_struct_enu_props) - && (cur->nextLayer == 0) - ) { + && (cur->structKind == fmi2_xml_type_struct_enu_props) + && (cur->nextLayer == 0) + ) { fmi2_xml_enum_typedef_props_t* props = (fmi2_xml_enum_typedef_props_t*)cur; fmi2_xml_free_enumeration_type_props(props); } cb->free(cur); cur = next; } - td->typePropsList = 0; + td->typePropsList = 0; } jm_named_vector_free_data(&td->typeDefinitions); @@ -292,7 +292,7 @@ void fmi2_xml_free_type_definitions_data(fmi2_xml_type_definitions_t* td) { int fmi2_xml_handle_TypeDefinitions(fmi2_xml_parser_context_t *context, const char* data) { if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element TypeDefinitions"); + jm_log_verbose(context->callbacks, module, "Parsing XML element TypeDefinitions"); } else { fmi2_xml_type_definitions_t* defs = &context->modelDescription->typeDefinitions; @@ -320,7 +320,7 @@ int fmi2_xml_handle_SimpleType(fmi2_xml_parser_context_t *context, const char* d fmi2_xml_set_attr_string(context, fmi2_xml_elmID_SimpleType, fmi_attr_id_description, 0, bufDescr) ) return -1; named.ptr = 0; - named.name = 0; + named.name = 0; pnamed = jm_vector_push_back(jm_named_ptr)(&td->typeDefinitions,named); if(pnamed) { fmi2_xml_variable_typedef_t dummy; @@ -423,7 +423,7 @@ fmi2_xml_real_type_props_t* fmi2_xml_parse_real_type_properties(fmi2_xml_parser_ } if( /* */ fmi2_xml_set_attr_boolean(context, elmID, fmi_attr_id_relativeQuantity, 0, &relQuanBuf, 0) || - /* */ + /* */ fmi2_xml_set_attr_boolean(context, elmID, fmi_attr_id_unbounded, 0, &unboundedBuf, 0) || /* */ fmi2_xml_set_attr_double(context, elmID, fmi_attr_id_min, 0, &props->typeMin, -DBL_MAX) || @@ -432,8 +432,8 @@ fmi2_xml_real_type_props_t* fmi2_xml_parse_real_type_properties(fmi2_xml_parser_ /* */ fmi2_xml_set_attr_double(context, elmID, fmi_attr_id_nominal, 0, &props->typeNominal, 1) ) return 0; - props->super.isRelativeQuantity = (relQuanBuf) ? 1:0; - props->super.isUnbounded = (unboundedBuf) ? 1 : 0; + props->super.isRelativeQuantity = (relQuanBuf) ? 1:0; + props->super.isUnbounded = (unboundedBuf) ? 1 : 0; return props; } @@ -557,9 +557,9 @@ int fmi2_xml_handle_Enumeration(fmi2_xml_parser_context_t *context, const char* jm_vector(char)* bufQuantity = fmi2_xml_reserve_parse_buffer(context,3,100); props = (fmi2_xml_enum_typedef_props_t*)fmi2_xml_alloc_variable_type_props( - &md->typeDefinitions, - &md->typeDefinitions.defaultEnumType.base.super, - sizeof(fmi2_xml_enum_typedef_props_t)); + &md->typeDefinitions, + &md->typeDefinitions.defaultEnumType.base.super, + sizeof(fmi2_xml_enum_typedef_props_t)); if(props) { /* the init call will override the 'next' field which has been set when the properties were allocated, @@ -583,22 +583,22 @@ int fmi2_xml_handle_Enumeration(fmi2_xml_parser_context_t *context, const char* type->super.baseType = fmi2_base_type_enum; type->super.nextLayer = &props->base.super; } else { - /* sort enum items, check that there are no duplicates */ + /* sort enum items, check that there are no duplicates */ fmi2_xml_enum_type_item_t *min, *max; - jm_named_ptr named = jm_vector_get_last(jm_named_ptr)(&context->modelDescription->typeDefinitions.typeDefinitions); - fmi2_xml_variable_typedef_t* type = named.ptr; - fmi2_xml_enum_typedef_props_t * props = (fmi2_xml_enum_typedef_props_t *)type->super.nextLayer; - jm_vector(jm_named_ptr)* items = &props->enumItems; - size_t i, n = jm_vector_get_size(jm_named_ptr)(items); - jm_vector_qsort(jm_named_ptr)(items, fmi1_xml_compare_enum_val); - for(i = 1; i < n; i++) { - fmi2_xml_enum_type_item_t* a = jm_vector_get_itemp(jm_named_ptr)(items, i-1)->ptr; - fmi2_xml_enum_type_item_t* b = jm_vector_get_itemp(jm_named_ptr)(items, i)->ptr; - if(a->value == b->value) { - jm_log_error(context->callbacks, module, "Enum items '%s' and '%s' within enumeration '%s' have the same value %d", - a->itemName, b->itemName, type->typeName, a->value); - } - } + jm_named_ptr named = jm_vector_get_last(jm_named_ptr)(&context->modelDescription->typeDefinitions.typeDefinitions); + fmi2_xml_variable_typedef_t* type = named.ptr; + fmi2_xml_enum_typedef_props_t * props = (fmi2_xml_enum_typedef_props_t *)type->super.nextLayer; + jm_vector(jm_named_ptr)* items = &props->enumItems; + size_t i, n = jm_vector_get_size(jm_named_ptr)(items); + jm_vector_qsort(jm_named_ptr)(items, fmi1_xml_compare_enum_val); + for(i = 1; i < n; i++) { + fmi2_xml_enum_type_item_t* a = jm_vector_get_itemp(jm_named_ptr)(items, i-1)->ptr; + fmi2_xml_enum_type_item_t* b = jm_vector_get_itemp(jm_named_ptr)(items, i)->ptr; + if(a->value == b->value) { + jm_log_error(context->callbacks, module, "Enum items '%s' and '%s' within enumeration '%s' have the same value %d", + a->itemName, b->itemName, type->typeName, a->value); + } + } /* Set type min/max to smallest/largest enum value. */ min = jm_vector_get_itemp(jm_named_ptr)(items, 0)->ptr; @@ -620,10 +620,10 @@ int fmi2_xml_handle_Item(fmi2_xml_parser_context_t *context, const char* data) { fmi2_xml_enum_type_item_t * item; jm_named_ptr named, *pnamed; size_t descrlen; - int value; + int value; assert((enumProps->base.super.structKind == fmi2_xml_type_struct_enu_props) - && (enumProps->base.super.baseType == fmi2_base_type_enum)); + && (enumProps->base.super.baseType == fmi2_base_type_enum)); if(!bufName || !bufDescr || /* */ @@ -631,12 +631,12 @@ int fmi2_xml_handle_Item(fmi2_xml_parser_context_t *context, const char* data) { /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_Item, fmi_attr_id_description, 0, bufDescr) || /* */ - fmi2_xml_set_attr_int(context, fmi2_xml_elmID_Item, fmi_attr_id_value, 1, &value, 0) + fmi2_xml_set_attr_int(context, fmi2_xml_elmID_Item, fmi_attr_id_value, 1, &value, 0) ) return -1; descrlen = jm_vector_get_size(char)(bufDescr); named.ptr = 0; - named.name = 0; + named.name = 0; pnamed = jm_vector_push_back(jm_named_ptr)(&enumProps->enumItems, named); if(pnamed) *pnamed = named = jm_named_alloc_v(bufName,sizeof(fmi2_xml_enum_type_item_t)+descrlen+1,sizeof(fmi2_xml_enum_type_item_t)+descrlen,context->callbacks); @@ -646,7 +646,7 @@ int fmi2_xml_handle_Item(fmi2_xml_parser_context_t *context, const char* data) { return -1; } item->itemName = named.name; - item->value = value; + item->value = value; if(descrlen) memcpy(item->itemDesciption,jm_vector_get_itemp(char)(bufDescr,0), descrlen); item->itemDesciption[descrlen] = 0; diff --git a/src/XML/src/FMI2/fmi2_xml_type_impl.h b/src/XML/src/FMI2/fmi2_xml_type_impl.h index 18ec1307..91202a7f 100644 --- a/src/XML/src/FMI2/fmi2_xml_type_impl.h +++ b/src/XML/src/FMI2/fmi2_xml_type_impl.h @@ -72,15 +72,15 @@ struct fmi2_xml_variable_type_base_t { fmi2_xml_type_struct_kind_enu_t structKind; /* the actual (sub) type */ fmi2_base_type_enu_t baseType; /* the FMI base type */ char isRelativeQuantity; /* relativeQuantity flag (only used in fmi2_xml_real_type_props_t) */ - char isUnbounded; /* unbounded flag (only used in fmi2_xml_real_type_props_t) */ + char isUnbounded; /* unbounded flag (only used in fmi2_xml_real_type_props_t) */ fmi2_xml_variable_type_base_t* next; /* should only be used for deallocation */ }; /* - Variable type definition is general and is used for all types. - This is done to enable easy handling of SimpleType XML element - (specific type element comes next). + Variable type definition is general and is used for all types. + This is done to enable easy handling of SimpleType XML element + (specific type element comes next). */ struct fmi2_xml_variable_typedef_t { fmi2_xml_variable_type_base_t super; @@ -113,16 +113,16 @@ typedef fmi2_xml_variable_type_base_t fmi2_xml_bool_type_props_t; typedef struct fmi2_xml_enum_type_item_t { jm_string itemName; - int value; + int value; char itemDesciption[1]; } fmi2_xml_enum_type_item_t; static int fmi1_xml_compare_enum_val (const void* first, const void* second) { - const jm_named_ptr* a = first; - const jm_named_ptr* b = second; - fmi2_xml_enum_type_item_t* ai = a->ptr; - fmi2_xml_enum_type_item_t* bi = b->ptr; - return (ai->value - bi->value); + const jm_named_ptr* a = first; + const jm_named_ptr* b = second; + fmi2_xml_enum_type_item_t* ai = a->ptr; + fmi2_xml_enum_type_item_t* bi = b->ptr; + return (ai->value - bi->value); } typedef struct fmi2_xml_enum_variable_props_t { @@ -135,7 +135,7 @@ typedef struct fmi2_xml_enum_variable_props_t { } fmi2_xml_enum_variable_props_t; typedef struct fmi2_xml_enum_typedef_props_t { - fmi2_xml_enum_variable_props_t base; + fmi2_xml_enum_variable_props_t base; jm_vector(jm_named_ptr) enumItems; } fmi2_xml_enum_typedef_props_t; diff --git a/src/XML/src/FMI2/fmi2_xml_unit.c b/src/XML/src/FMI2/fmi2_xml_unit.c index fdb9d811..647f2b31 100644 --- a/src/XML/src/FMI2/fmi2_xml_unit.c +++ b/src/XML/src/FMI2/fmi2_xml_unit.c @@ -28,41 +28,41 @@ const char* fmi2_xml_get_unit_name(fmi2_xml_unit_t* u) { } /** - \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit. + \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit. */ const int* fmi2_xml_get_SI_unit_exponents(fmi2_xml_unit_t* u) { - return u->SI_base_unit_exp; + return u->SI_base_unit_exp; } /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ double fmi2_xml_get_SI_unit_factor(fmi2_xml_unit_t* u){ - return u->factor; + return u->factor; } /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ double fmi2_xml_get_SI_unit_offset(fmi2_xml_unit_t* u) { - return u->offset; + return u->offset; } /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ double fmi2_xml_convert_to_SI_base_unit(double uv, fmi2_xml_unit_t* u) { - return u->factor * uv + u->offset; + return u->factor * uv + u->offset; } /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ double fmi2_xml_convert_from_SI_base_unit(double SIv, fmi2_xml_unit_t* u) { - return (SIv - u->offset)/u->factor; + return (SIv - u->offset)/u->factor; } unsigned int fmi2_xml_get_unit_display_unit_number(fmi2_xml_unit_t* u) { @@ -112,8 +112,8 @@ double fmi2_xml_convert_from_display_unit(double val, fmi2_xml_display_unit_t* d int fmi2_xml_handle_UnitDefinitions(fmi2_xml_parser_context_t *context, const char* data) { fmi2_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element UnitDefinitions"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element UnitDefinitions"); + } else { jm_vector_qsort(jm_named_ptr)(&(md->unitDefinitions),jm_compare_named); jm_vector_qsort(jm_named_ptr)(&(md->displayUnitDefinitions),jm_compare_named); @@ -127,13 +127,13 @@ fmi2_xml_display_unit_t* fmi2_xml_get_parsed_unit(fmi2_xml_parser_context_t *con fmi2_xml_unit_t dummy, *unit; jm_named_ptr named, *pnamed; fmi2_xml_model_description_t* md = context->modelDescription; - int i; - if(jm_vector_get_size(char)(name)) - named.name = jm_vector_get_itemp(char)(name,0); - else - named.name = ""; + int i; + if(jm_vector_get_size(char)(name)) + named.name = jm_vector_get_itemp(char)(name,0); + else + named.name = ""; - if(sorted) + if(sorted) pnamed = jm_vector_bsearch(jm_named_ptr)(&(md->unitDefinitions), &named,jm_compare_named); else pnamed = jm_vector_find(jm_named_ptr)(&(md->unitDefinitions), &named,jm_compare_named); @@ -153,10 +153,10 @@ fmi2_xml_display_unit_t* fmi2_xml_get_parsed_unit(fmi2_xml_parser_context_t *con } unit = named.ptr; - unit->factor = 1.0; - unit->offset = 0.0; - for(i = 0; i < fmi2_SI_base_units_Num; i++) - unit->SI_base_unit_exp[i] = 0; + unit->factor = 1.0; + unit->offset = 0.0; + for(i = 0; i < fmi2_SI_base_units_Num; i++) + unit->SI_base_unit_exp[i] = 0; unit->defaultDisplay.baseUnit = unit; unit->defaultDisplay.offset = 0; unit->defaultDisplay.factor = 1.0; @@ -169,29 +169,29 @@ fmi2_xml_display_unit_t* fmi2_xml_get_parsed_unit(fmi2_xml_parser_context_t *con int fmi2_xml_handle_BaseUnit(fmi2_xml_parser_context_t *context, const char* data) { if(!data) { - int ret; + int ret; /* fmi2_xml_model_description_t* md = context->modelDescription; */ /* this base unit belongs to the last created base unit */ fmi2_xml_unit_t* unit = context->lastBaseUnit; /* process the attributes */ - /* */ + /* */ #define FMI2_PARSE_SI_BASE_UNIT_ENU(c) \ - fmi2_xml_set_attr_int(context, fmi2_xml_elmID_BaseUnit, fmi_attr_id_ ## c,0,&(unit->SI_base_unit_exp[fmi2_SI_base_unit_ ## c]),0) || - ret = - FMI2_SI_BASE_UNITS(FMI2_PARSE_SI_BASE_UNIT_ENU) - /* */ + fmi2_xml_set_attr_int(context, fmi2_xml_elmID_BaseUnit, fmi_attr_id_ ## c,0,&(unit->SI_base_unit_exp[fmi2_SI_base_unit_ ## c]),0) || + ret = + FMI2_SI_BASE_UNITS(FMI2_PARSE_SI_BASE_UNIT_ENU) + /* */ fmi2_xml_set_attr_double(context, fmi2_xml_elmID_BaseUnit, fmi_attr_id_factor, 0, &unit->factor, 1) || /* */ fmi2_xml_set_attr_double(context, fmi2_xml_elmID_BaseUnit, fmi_attr_id_offset, 0, &unit->offset, 0); - if(unit->factor == 0) { - unit->factor = 1.0; - if(!ret) { - fmi2_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); - } - } + if(unit->factor == 0) { + unit->factor = 1.0; + if(!ret) { + fmi2_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); + } + } return ( ret ); } @@ -211,7 +211,7 @@ int fmi2_xml_handle_Unit(fmi2_xml_parser_context_t *context, const char* data) { if(!buf) return -1; if( - /* */ + /* */ fmi2_xml_set_attr_string(context, fmi2_xml_elmID_BaseUnit, fmi_attr_id_name, 1, buf) || !(unit = fmi2_xml_get_parsed_unit(context, buf, 0)) ) return -1; @@ -226,7 +226,7 @@ int fmi2_xml_handle_Unit(fmi2_xml_parser_context_t *context, const char* data) { int fmi2_xml_handle_DisplayUnit(fmi2_xml_parser_context_t *context, const char* data) { if(!data) { - int ret; + int ret; fmi2_xml_model_description_t* md = context->modelDescription; jm_vector(char)* buf = fmi2_xml_reserve_parse_buffer(context,1,100); /* this display unit belongs to the last created base unit */ @@ -252,17 +252,17 @@ int fmi2_xml_handle_DisplayUnit(fmi2_xml_parser_context_t *context, const char* } dispUnit->baseUnit = unit; /* finally process the attributes */ - ret = - /* */ + ret = + /* */ fmi2_xml_set_attr_double(context, fmi2_xml_elmID_DisplayUnit, fmi_attr_id_factor, 0, &dispUnit->factor, 1) || /* */ fmi2_xml_set_attr_double(context, fmi2_xml_elmID_DisplayUnit, fmi_attr_id_offset, 0, &dispUnit->offset, 0); - if(dispUnit->factor == 0) { - dispUnit->factor = 1.0; - if(!ret) { - fmi2_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); - } - } + if(dispUnit->factor == 0) { + dispUnit->factor = 1.0; + if(!ret) { + fmi2_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); + } + } return ( ret ); } diff --git a/src/XML/src/FMI2/fmi2_xml_unit_impl.h b/src/XML/src/FMI2/fmi2_xml_unit_impl.h index 8a92cbda..8e71b51b 100644 --- a/src/XML/src/FMI2/fmi2_xml_unit_impl.h +++ b/src/XML/src/FMI2/fmi2_xml_unit_impl.h @@ -35,9 +35,9 @@ struct fmi2_xml_display_unit_t { struct fmi2_xml_unit_t { jm_vector(jm_voidp) displayUnits; - int SI_base_unit_exp[fmi2_SI_base_units_Num]; - double factor; - double offset; + int SI_base_unit_exp[fmi2_SI_base_units_Num]; + double factor; + double offset; fmi2_xml_display_unit_t defaultDisplay; char baseUnit[1]; }; diff --git a/src/XML/src/FMI2/fmi2_xml_variable_impl.h b/src/XML/src/FMI2/fmi2_xml_variable_impl.h index 022adf04..212074b3 100644 --- a/src/XML/src/FMI2/fmi2_xml_variable_impl.h +++ b/src/XML/src/FMI2/fmi2_xml_variable_impl.h @@ -30,9 +30,9 @@ extern "C" { struct fmi2_xml_variable_t { fmi2_xml_variable_type_base_t* type; /** \brief Type information of the variable */ - const char* description; /** \brief Associate description */ + const char* description; /** \brief Associate description */ - size_t originalIndex; /** \brief Index in the model description */ + size_t originalIndex; /** \brief Index in the model description */ /* NB: before parsing of has finished, derivativeOf and previous are stored as integer indices cast to pointers, @@ -40,7 +40,7 @@ struct fmi2_xml_variable_t { fmi2_xml_variable_t *derivativeOf; /** \brief Only for continuous Real variables. If non-NULL, the variable that this is the derivative of. */ fmi2_xml_variable_t *previous; /** \brief If non-NULL, the variable that holds the value of this variable at the previous super-dense time instant. */ - fmi2_value_reference_t vr; /** \brief Value reference */ + fmi2_value_reference_t vr; /** \brief Value reference */ char aliasKind; char initial; char variability; @@ -56,8 +56,8 @@ static int fmi2_xml_compare_vr (const void* first, const void* second) { fmi2_xml_variable_t* b = *(fmi2_xml_variable_t**)second; fmi2_base_type_enu_t at = fmi2_xml_get_variable_base_type(a); fmi2_base_type_enu_t bt = fmi2_xml_get_variable_base_type(b); - if(at == fmi2_base_type_enum) at = fmi2_base_type_int; - if(bt == fmi2_base_type_enum) bt = fmi2_base_type_int; + if(at == fmi2_base_type_enum) at = fmi2_base_type_int; + if(bt == fmi2_base_type_enum) bt = fmi2_base_type_int; if(at!=bt) return at - bt; if(a->vr < b->vr) return -1; if(a->vr > b->vr) return 1; diff --git a/src/XML/src/FMI2/fmi2_xml_vendor_annotations.c b/src/XML/src/FMI2/fmi2_xml_vendor_annotations.c index 4ed81573..aa477566 100644 --- a/src/XML/src/FMI2/fmi2_xml_vendor_annotations.c +++ b/src/XML/src/FMI2/fmi2_xml_vendor_annotations.c @@ -23,8 +23,8 @@ static const char* module = "FMI2XML"; int fmi2_xml_handle_VendorAnnotations(fmi2_xml_parser_context_t *context, const char* data) { if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations"); + } else { /* might give out a warning if(data[0] != 0) */ } @@ -33,8 +33,8 @@ int fmi2_xml_handle_VendorAnnotations(fmi2_xml_parser_context_t *context, const int fmi2_xml_handle_Annotations(fmi2_xml_parser_context_t *context, const char* data) { if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element Annotations"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element Annotations"); + } else { /* might give out a warning if(data[0] != 0) */ } @@ -43,34 +43,34 @@ int fmi2_xml_handle_Annotations(fmi2_xml_parser_context_t *context, const char* int fmi2_xml_handle_VariableTool(fmi2_xml_parser_context_t *context, const char* data) { if(!data) { - size_t len; + size_t len; fmi2_xml_model_description_t* md = context->modelDescription; jm_vector(char)* bufName = fmi2_xml_reserve_parse_buffer(context,1,100); jm_string *pvendor; - char* vendor = 0; - + char* vendor = 0; + if(!bufName) return -1; /* */ if( fmi2_xml_set_attr_string(context, fmi2_xml_elmID_Tool, fmi_attr_id_name, 1, bufName)) - return -1; + return -1; pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor); - len = jm_vector_get_size(char)(bufName); + len = jm_vector_get_size(char)(bufName); if(pvendor ) *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1)); - if(!pvendor || !vendor) { - fmi2_xml_parse_fatal(context, "Could not allocate memory"); - return -1; - } + if(!pvendor || !vendor) { + fmi2_xml_parse_fatal(context, "Could not allocate memory"); + return -1; + } memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len); vendor[len] = 0; - context->anyToolName = vendor; - context->anyParent = jm_vector_get_last(jm_named_ptr)(&md->variablesByName).ptr; - context->useAnyHandleFlg = 1; + context->anyToolName = vendor; + context->anyParent = jm_vector_get_last(jm_named_ptr)(&md->variablesByName).ptr; + context->useAnyHandleFlg = 1; } else { /* don't do anything. might give out a warning if(data[0] != 0) */ - context->useAnyHandleFlg = 0; + context->useAnyHandleFlg = 0; return 0; } return 0; @@ -78,34 +78,34 @@ int fmi2_xml_handle_VariableTool(fmi2_xml_parser_context_t *context, const char* int fmi2_xml_handle_Tool(fmi2_xml_parser_context_t *context, const char* data) { if(!data) { - size_t len; + size_t len; fmi2_xml_model_description_t* md = context->modelDescription; jm_vector(char)* bufName = fmi2_xml_reserve_parse_buffer(context,1,100); jm_string *pvendor; - char* vendor = 0; - + char* vendor = 0; + if(!bufName) return -1; /* */ if( fmi2_xml_set_attr_string(context, fmi2_xml_elmID_Tool, fmi_attr_id_name, 1, bufName)) - return -1; + return -1; pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor); - len = jm_vector_get_size(char)(bufName); + len = jm_vector_get_size(char)(bufName); if(pvendor ) *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1)); - if(!pvendor || !vendor) { - fmi2_xml_parse_fatal(context, "Could not allocate memory"); - return -1; - } + if(!pvendor || !vendor) { + fmi2_xml_parse_fatal(context, "Could not allocate memory"); + return -1; + } memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len); vendor[len] = 0; - context->anyToolName = vendor; - context->anyParent = 0; - context->useAnyHandleFlg = 1; + context->anyToolName = vendor; + context->anyParent = 0; + context->useAnyHandleFlg = 1; } else { /* don't do anything. might give out a warning if(data[0] != 0) */ - context->useAnyHandleFlg = 0; + context->useAnyHandleFlg = 0; return 0; } return 0; diff --git a/src/XML/src/FMI3/fmi3_xml_model_description_impl.h b/src/XML/src/FMI3/fmi3_xml_model_description_impl.h index 928c697c..38e2f59c 100644 --- a/src/XML/src/FMI3/fmi3_xml_model_description_impl.h +++ b/src/XML/src/FMI3/fmi3_xml_model_description_impl.h @@ -72,9 +72,9 @@ struct fmi3_xml_model_description_t { jm_vector(char) modelIdentifierME; - jm_vector(char) modelIdentifierCS; + jm_vector(char) modelIdentifierCS; - jm_vector(char) modelIdentifierSE; + jm_vector(char) modelIdentifierSE; jm_vector(jm_string) sourceFilesME; jm_vector(jm_string) sourceFilesCS; @@ -82,7 +82,7 @@ struct fmi3_xml_model_description_t { jm_vector(jm_string) logCategories; jm_vector(jm_string) logCategoryDescriptions; - jm_vector(jm_string) vendorList; + jm_vector(jm_string) vendorList; jm_vector(jm_named_ptr) unitDefinitions; jm_vector(jm_named_ptr) displayUnitDefinitions; @@ -91,17 +91,17 @@ struct fmi3_xml_model_description_t { jm_string_set descriptions; - jm_vector(jm_named_ptr) variablesByName; + jm_vector(jm_named_ptr) variablesByName; jm_vector(jm_voidp)* variablesOrigOrder; - jm_vector(jm_voidp)* variablesByVR; + jm_vector(jm_voidp)* variablesByVR; fmi3_fmu_kind_enu_t fmuKind; unsigned int capabilities[fmi3_capabilities_Num]; - fmi3_xml_model_structure_t* modelStructure; + fmi3_xml_model_structure_t* modelStructure; }; #ifdef __cplusplus diff --git a/src/XML/src/FMI3/fmi3_xml_model_structure.c b/src/XML/src/FMI3/fmi3_xml_model_structure.c index 36e124b3..4baa997d 100644 --- a/src/XML/src/FMI3/fmi3_xml_model_structure.c +++ b/src/XML/src/FMI3/fmi3_xml_model_structure.c @@ -26,60 +26,60 @@ static const char * module = "FMI3XML"; fmi3_xml_model_structure_t* fmi3_xml_allocate_model_structure(jm_callbacks* cb) { - fmi3_xml_model_structure_t* ms = (fmi3_xml_model_structure_t*)(cb->calloc(1, sizeof(fmi3_xml_model_structure_t))); - if(!ms) return 0; + fmi3_xml_model_structure_t* ms = (fmi3_xml_model_structure_t*)(cb->calloc(1, sizeof(fmi3_xml_model_structure_t))); + if(!ms) return 0; - jm_vector_init(jm_voidp)(&ms->outputs,0,cb); - jm_vector_init(jm_voidp)(&ms->derivatives,0,cb); - jm_vector_init(jm_voidp)(&ms->discreteStates,0,cb); - jm_vector_init(jm_voidp)(&ms->initialUnknowns,0,cb); + jm_vector_init(jm_voidp)(&ms->outputs,0,cb); + jm_vector_init(jm_voidp)(&ms->derivatives,0,cb); + jm_vector_init(jm_voidp)(&ms->discreteStates,0,cb); + jm_vector_init(jm_voidp)(&ms->initialUnknowns,0,cb); - ms->isValidFlag = 1; + ms->isValidFlag = 1; ms->outputDeps = fmi3_xml_allocate_dependencies(cb); ms->derivativeDeps = fmi3_xml_allocate_dependencies(cb); ms->discreteStateDeps = fmi3_xml_allocate_dependencies(cb); ms->initialUnknownDeps = fmi3_xml_allocate_dependencies(cb); - if(!ms->outputDeps || !ms->derivativeDeps || !ms->discreteStateDeps || !ms->initialUnknownDeps) { - fmi3_xml_free_model_structure(ms); - return 0; - } + if(!ms->outputDeps || !ms->derivativeDeps || !ms->discreteStateDeps || !ms->initialUnknownDeps) { + fmi3_xml_free_model_structure(ms); + return 0; + } - return ms; + return ms; } void fmi3_xml_free_model_structure(fmi3_xml_model_structure_t* ms) { - jm_callbacks* cb; - if(!ms) return; - cb = ms->outputs.callbacks; + jm_callbacks* cb; + if(!ms) return; + cb = ms->outputs.callbacks; - jm_vector_free_data(jm_voidp)(&ms->outputs); - jm_vector_free_data(jm_voidp)(&ms->derivatives); - jm_vector_free_data(jm_voidp)(&ms->discreteStates); - jm_vector_free_data(jm_voidp)(&ms->initialUnknowns); + jm_vector_free_data(jm_voidp)(&ms->outputs); + jm_vector_free_data(jm_voidp)(&ms->derivatives); + jm_vector_free_data(jm_voidp)(&ms->discreteStates); + jm_vector_free_data(jm_voidp)(&ms->initialUnknowns); fmi3_xml_free_dependencies(ms->outputDeps); fmi3_xml_free_dependencies(ms->derivativeDeps); fmi3_xml_free_dependencies(ms->discreteStateDeps); fmi3_xml_free_dependencies(ms->initialUnknownDeps); - cb->free(ms); + cb->free(ms); } jm_vector(jm_voidp)* fmi3_xml_get_outputs(fmi3_xml_model_structure_t* ms) { - return &ms->outputs; + return &ms->outputs; } jm_vector(jm_voidp)* fmi3_xml_get_derivatives(fmi3_xml_model_structure_t* ms){ - return &ms->derivatives; + return &ms->derivatives; } jm_vector(jm_voidp)* fmi3_xml_get_discrete_states(fmi3_xml_model_structure_t* ms){ - return &ms->discreteStates; + return &ms->discreteStates; } jm_vector(jm_voidp)* fmi3_xml_get_initial_unknowns(fmi3_xml_model_structure_t* ms){ - return &ms->initialUnknowns; + return &ms->initialUnknowns; } @@ -122,73 +122,73 @@ void fmi3_xml_get_initial_unknowns_dependencies(fmi3_xml_model_structure_t* ms, fmi3_xml_dependencies_t* fmi3_xml_allocate_dependencies(jm_callbacks* cb) { - fmi3_xml_dependencies_t* dep = (fmi3_xml_dependencies_t*)(cb->malloc(sizeof(fmi3_xml_dependencies_t))); - if(!dep) return 0; - jm_vector_init(size_t)(&dep->startIndex, 0, cb); - jm_vector_push_back(size_t)(&dep->startIndex, 0); + fmi3_xml_dependencies_t* dep = (fmi3_xml_dependencies_t*)(cb->malloc(sizeof(fmi3_xml_dependencies_t))); + if(!dep) return 0; + jm_vector_init(size_t)(&dep->startIndex, 0, cb); + jm_vector_push_back(size_t)(&dep->startIndex, 0); - jm_vector_init(size_t)(&dep->dependencyIndex, 0, cb); - jm_vector_init(char)(&dep->dependencyFactorKind, 0, cb); + jm_vector_init(size_t)(&dep->dependencyIndex, 0, cb); + jm_vector_init(char)(&dep->dependencyFactorKind, 0, cb); - dep->isRowMajor = 1; + dep->isRowMajor = 1; - return dep; + return dep; } void fmi3_xml_zero_empty_dependencies(fmi3_xml_dependencies_t** pdep) { - fmi3_xml_dependencies_t* dep =*pdep; - size_t ndep = jm_vector_get_size(size_t)(&dep->dependencyIndex); - size_t i; - if(!dep) return; - for(i = 0; idependencyIndex, i)) break; - } - if(i == ndep) { - fmi3_xml_free_dependencies(dep); - *pdep = 0; - } + fmi3_xml_dependencies_t* dep =*pdep; + size_t ndep = jm_vector_get_size(size_t)(&dep->dependencyIndex); + size_t i; + if(!dep) return; + for(i = 0; idependencyIndex, i)) break; + } + if(i == ndep) { + fmi3_xml_free_dependencies(dep); + *pdep = 0; + } } void fmi3_xml_free_dependencies(fmi3_xml_dependencies_t* dep) { jm_callbacks* cb; - if(!dep) return; + if(!dep) return; cb = dep->startIndex.callbacks; - jm_vector_free_data(size_t)(&dep->startIndex); + jm_vector_free_data(size_t)(&dep->startIndex); - jm_vector_free_data(size_t)(&dep->dependencyIndex); - jm_vector_free_data(char)(&dep->dependencyFactorKind); + jm_vector_free_data(size_t)(&dep->dependencyIndex); + jm_vector_free_data(char)(&dep->dependencyFactorKind); cb->free(dep); } int fmi3_xml_check_model_structure(fmi3_xml_model_description_t* md) { - fmi3_xml_model_structure_t* ms = md->modelStructure; + fmi3_xml_model_structure_t* ms = md->modelStructure; - if(!ms || !ms->isValidFlag) return 0; + if(!ms || !ms->isValidFlag) return 0; - return ms->isValidFlag; + return ms->isValidFlag; } int fmi3_xml_handle_ModelStructure(fmi3_xml_parser_context_t *context, const char* data) { fmi3_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_verbose(context->callbacks, module,"Parsing XML element ModelStructure"); - /** allocate model structure */ - md->modelStructure = fmi3_xml_allocate_model_structure(md->callbacks); - if(!md->modelStructure) { - fmi3_xml_parse_fatal(context, module, "Could not allocate memory"); - return -1; - } + jm_log_verbose(context->callbacks, module,"Parsing XML element ModelStructure"); + /** allocate model structure */ + md->modelStructure = fmi3_xml_allocate_model_structure(md->callbacks); + if(!md->modelStructure) { + fmi3_xml_parse_fatal(context, module, "Could not allocate memory"); + return -1; + } } else { - /** make sure model structure information is consistent */ + /** make sure model structure information is consistent */ - if(!fmi3_xml_check_model_structure(md)) { - fmi3_xml_parse_fatal(context, "Model structure is not valid due to detected errors. Cannot continue."); - return -1; - } -/* md->numberOfContinuousStates = jm_vector_get_size(jm_voidp)(&md->modelStructure->states); */ + if(!fmi3_xml_check_model_structure(md)) { + fmi3_xml_parse_fatal(context, "Model structure is not valid due to detected errors. Cannot continue."); + return -1; + } +/* md->numberOfContinuousStates = jm_vector_get_size(jm_voidp)(&md->modelStructure->states); */ } return 0; @@ -241,7 +241,7 @@ int fmi3_xml_handle_InitialUnknowns(fmi3_xml_parser_context_t *context, const ch */ int fmi3_xml_parse_dependencies(fmi3_xml_parser_context_t *context, fmi3_xml_elm_enu_t parentElmID, - fmi3_xml_dependencies_t* deps) + fmi3_xml_dependencies_t* deps) { fmi3_xml_model_description_t* md = context->modelDescription; fmi3_xml_model_structure_t* ms = md->modelStructure; diff --git a/src/XML/src/FMI3/fmi3_xml_model_structure_impl.h b/src/XML/src/FMI3/fmi3_xml_model_structure_impl.h index caaa48a6..cfaa3463 100644 --- a/src/XML/src/FMI3/fmi3_xml_model_structure_impl.h +++ b/src/XML/src/FMI3/fmi3_xml_model_structure_impl.h @@ -29,33 +29,33 @@ extern "C" { /** \brief Structure for keeping information about variable dependencies. */ typedef struct fmi3_xml_dependencies_t { - int isRowMajor; /** Information is stored in row-major format flag */ + int isRowMajor; /** Information is stored in row-major format flag */ - /** Start index in dependency data for the corresponding row (isRowMajor=1) or column (isRowMajor = 0) */ - jm_vector(size_t) startIndex; + /** Start index in dependency data for the corresponding row (isRowMajor=1) or column (isRowMajor = 0) */ + jm_vector(size_t) startIndex; - /** Column indices (isRowMajor=1) or row indices (isRowMajor=0) - Note that indices are 1-based. 0 has a special meaning - depends on all. - */ - jm_vector(size_t) dependencyIndex; - jm_vector(char) dependencyFactorKind; + /** Column indices (isRowMajor=1) or row indices (isRowMajor=0) + Note that indices are 1-based. 0 has a special meaning - depends on all. + */ + jm_vector(size_t) dependencyIndex; + jm_vector(char) dependencyFactorKind; } fmi3_xml_dependencies_t; fmi3_xml_dependencies_t* fmi3_xml_allocate_dependencies(jm_callbacks* cb); void fmi3_xml_free_dependencies(fmi3_xml_dependencies_t* dep); - + struct fmi3_xml_model_structure_t { - jm_vector(jm_voidp) outputs; - jm_vector(jm_voidp) derivatives; - jm_vector(jm_voidp) discreteStates; - jm_vector(jm_voidp) initialUnknowns; + jm_vector(jm_voidp) outputs; + jm_vector(jm_voidp) derivatives; + jm_vector(jm_voidp) discreteStates; + jm_vector(jm_voidp) initialUnknowns; fmi3_xml_dependencies_t* outputDeps; fmi3_xml_dependencies_t* derivativeDeps; fmi3_xml_dependencies_t* discreteStateDeps; fmi3_xml_dependencies_t* initialUnknownDeps; - int isValidFlag; /**\ brief The flag is used to signal if an error was discovered and the model structure is not usable */ + int isValidFlag; /**\ brief The flag is used to signal if an error was discovered and the model structure is not usable */ }; #ifdef __cplusplus diff --git a/src/XML/src/FMI3/fmi3_xml_parser.c b/src/XML/src/FMI3/fmi3_xml_parser.c index b1cc0f97..0a884ed9 100644 --- a/src/XML/src/FMI3/fmi3_xml_parser.c +++ b/src/XML/src/FMI3/fmi3_xml_parser.c @@ -131,9 +131,9 @@ const char *fmi3_xmlAttrNames[fmi3_xml_attr_number] = { /* Global array of all scheme_info_t. Index it with fmi3_xml_elm_enu_t entries. */ fmi3_xml_scheme_info_t fmi3_xml_scheme_info[fmi3_xml_elm_number] = { FMI3_XML_ELMLIST(EXPAND_ELM_SCHEME) - {fmi3_xml_elm_actual_number,0,0}, - FMI3_XML_ELMLIST_ALT(EXPAND_ELM_SCHEME) - FMI3_XML_ELMLIST_ABSTRACT(EXPAND_ELM_SCHEME) + {fmi3_xml_elm_actual_number,0,0}, + FMI3_XML_ELMLIST_ALT(EXPAND_ELM_SCHEME) + FMI3_XML_ELMLIST_ABSTRACT(EXPAND_ELM_SCHEME) }; #define EXPAND_ELM_NAME(elm) { #elm, fmi3_xml_handle_##elm, fmi3_xml_elmID_##elm}, @@ -146,9 +146,9 @@ fmi3_xml_scheme_info_t fmi3_xml_scheme_info[fmi3_xml_elm_number] = { */ fmi3_xml_element_handle_map_t fmi3_element_handle_map[fmi3_xml_elm_number] = { FMI3_XML_ELMLIST(EXPAND_ELM_NAME) - { NULL, NULL, fmi3_xml_elm_actual_number}, - FMI3_XML_ELMLIST_ALT(EXPAND_ELM_NAME) - FMI3_XML_ELMLIST_ABSTRACT(EXPAND_ELM_NAME) + { NULL, NULL, fmi3_xml_elm_actual_number}, + FMI3_XML_ELMLIST_ALT(EXPAND_ELM_NAME) + FMI3_XML_ELMLIST_ABSTRACT(EXPAND_ELM_NAME) }; const fmi3_xml_primitive_types_t PRIMITIVE_TYPES = { @@ -258,7 +258,7 @@ void fmi3_xml_parse_free_context(fmi3_xml_parser_context_t *context) { void fmi3_xml_parse_fatal(fmi3_xml_parser_context_t *context, const char* fmt, ...) { va_list args; va_start (args, fmt); - jm_log_fatal_v(context->callbacks, module, fmt, args); + jm_log_fatal_v(context->callbacks, module, fmt, args); va_end (args); XML_StopParser(context->parser,0); } @@ -266,9 +266,9 @@ void fmi3_xml_parse_fatal(fmi3_xml_parser_context_t *context, const char* fmt, . void fmi3_xml_parse_error(fmi3_xml_parser_context_t *context, const char* fmt, ...) { va_list args; va_start (args, fmt); - if(context->parser) - jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser)); - jm_log_error_v(context->callbacks, module, fmt, args); + if(context->parser) + jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser)); + jm_log_error_v(context->callbacks, module, fmt, args); va_end (args); } @@ -853,11 +853,11 @@ int fmi3_create_elm_map(fmi3_xml_parser_context_t* context) { void fmi3_xml_set_element_handle(fmi3_xml_parser_context_t *context, const char* elm, fmi3_xml_elm_enu_t id) { fmi3_xml_element_handle_map_t keyEl; fmi3_xml_element_handle_map_t* currentElMap; - keyEl.elementName = elm; + keyEl.elementName = elm; currentElMap = jm_vector_bsearch(fmi3_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi3_xml_compare_elmName); - currentElMap->elementHandle = fmi3_element_handle_map[id].elementHandle;; - currentElMap->elemID = id; + currentElMap->elementHandle = fmi3_element_handle_map[id].elementHandle;; + currentElMap->elemID = id; } /** @@ -895,85 +895,85 @@ int fmi3_xml_are_same_type(fmi3_xml_elm_enu_t id1, fmi3_xml_elm_enu_t id2) { static void XMLCALL fmi3_parse_element_start(void *c, const char *elm, const char **attr) { fmi3_xml_element_handle_map_t keyEl; fmi3_xml_element_handle_map_t* currentElMap; - fmi3_xml_elm_enu_t currentID; + fmi3_xml_elm_enu_t currentID; int i; fmi3_xml_parser_context_t *context = c; context->has_produced_data_warning = 0; - if (context->useAnyHandleFlg) { - fmi3_xml_callbacks_t* anyH = context->anyHandle; - context->anyElmCount++; - if(anyH && anyH->startHandle) { + if (context->useAnyHandleFlg) { + fmi3_xml_callbacks_t* anyH = context->anyHandle; + context->anyElmCount++; + if(anyH && anyH->startHandle) { int ret = anyH->startHandle(anyH->context, context->anyToolName, context->anyParent, elm, attr); - if(ret != 0) { - fmi3_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); - } - } - return; - } - - if (context->skipElementCnt) { - context->skipElementCnt++; + if(ret != 0) { + fmi3_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); + } + } + return; + } + + if (context->skipElementCnt) { + context->skipElementCnt++; jm_log_warning(context->callbacks, module, "[Line:%u] Skipping nested XML element '%s'", - XML_GetCurrentLineNumber(context->parser), elm); - return; - } + XML_GetCurrentLineNumber(context->parser), elm); + return; + } - keyEl.elementName = elm; - /* find the element handle by name */ + keyEl.elementName = elm; + /* find the element handle by name */ currentElMap = jm_vector_bsearch(fmi3_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi3_xml_compare_elmName); if (!currentElMap) { /* not found error*/ jm_log_error(context->callbacks, module, "[Line:%u] Unknown element '%s' in XML, skipping", - XML_GetCurrentLineNumber(context->parser), elm); + XML_GetCurrentLineNumber(context->parser), elm); /* skipElementCnt: * Instead of calling exit when we find a first 'Unknown' element, we set skipElementCnt to 1, and continue parsing. * We then increase 'skipElementCnt' by 1 for each nested element we encounter (and decrease by 1 when leaving it). * 'skipElementCnt' will be 0 when we leave the root 'Unknown' element. */ - context->skipElementCnt = 1; + context->skipElementCnt = 1; return; } currentID = currentElMap->elemID; context->currentElemIdStartTag = currentID; - /* Check that parent-child & siblings are fine */ - { - fmi3_xml_elm_enu_t parentID = context->currentElmID; - fmi3_xml_elm_enu_t siblingID = context->lastElmID; - - if (!fmi3_xml_is_valid_parent(currentID, parentID)) { - jm_log_error(context->callbacks, module, - "[Line:%u] XML element '%s' cannot be placed inside '%s', skipping", - XML_GetCurrentLineNumber(context->parser), elm, fmi3_element_handle_map[parentID].elementName); - context->skipElementCnt = 1; - return; - } - if (siblingID != fmi3_xml_elmID_none) { + /* Check that parent-child & siblings are fine */ + { + fmi3_xml_elm_enu_t parentID = context->currentElmID; + fmi3_xml_elm_enu_t siblingID = context->lastElmID; + + if (!fmi3_xml_is_valid_parent(currentID, parentID)) { + jm_log_error(context->callbacks, module, + "[Line:%u] XML element '%s' cannot be placed inside '%s', skipping", + XML_GetCurrentLineNumber(context->parser), elm, fmi3_element_handle_map[parentID].elementName); + context->skipElementCnt = 1; + return; + } + if (siblingID != fmi3_xml_elmID_none) { if (fmi3_xml_are_same_type(currentID, siblingID)) { - if (!(fmi3_xml_scheme_info[currentID].multipleAllowed && fmi3_xml_scheme_info[siblingID].multipleAllowed)) { - jm_log_error(context->callbacks, module, - "[Line:%u] Multiple instances of XML element '%s' are not allowed, skipping", - XML_GetCurrentLineNumber(context->parser), elm); - context->skipElementCnt = 1; - return; - } - } else { - int lastSiblingIndex = fmi3_xml_scheme_info[siblingID].siblingIndex; - int curSiblingIndex = fmi3_xml_scheme_info[currentID].siblingIndex; + if (!(fmi3_xml_scheme_info[currentID].multipleAllowed && fmi3_xml_scheme_info[siblingID].multipleAllowed)) { + jm_log_error(context->callbacks, module, + "[Line:%u] Multiple instances of XML element '%s' are not allowed, skipping", + XML_GetCurrentLineNumber(context->parser), elm); + context->skipElementCnt = 1; + return; + } + } else { + int lastSiblingIndex = fmi3_xml_scheme_info[siblingID].siblingIndex; + int curSiblingIndex = fmi3_xml_scheme_info[currentID].siblingIndex; if (lastSiblingIndex >= curSiblingIndex) { - jm_log_error(context->callbacks, module, - "[Line:%u] XML element '%s' cannot be placed after element '%s', skipping", - XML_GetCurrentLineNumber(context->parser), elm, fmi3_element_handle_map[siblingID].elementName); - context->skipElementCnt = 1; - return; - } - } - } + jm_log_error(context->callbacks, module, + "[Line:%u] XML element '%s' cannot be placed after element '%s', skipping", + XML_GetCurrentLineNumber(context->parser), elm, fmi3_element_handle_map[siblingID].elementName); + context->skipElementCnt = 1; + return; + } + } + } /* lastElmID references the previous sibling-element's id - set it to 'none' before handling children. TODO: rename lastElmName --> lastSiblingElemId */ - context->lastElmID = fmi3_xml_elmID_none; - } + context->lastElmID = fmi3_xml_elmID_none; + } /* process the attributes */ i = 0; @@ -986,38 +986,38 @@ static void XMLCALL fmi3_parse_element_start(void *c, const char *elm, const cha attrMapping = jm_vector_bsearch(jm_named_ptr)(context->attrMap, &key, jm_compare_named); if (!attrMapping) { #define XMLSchema_instance "http://www.w3.org/2001/XMLSchema-instance" - const size_t stdNSlen = strlen(XMLSchema_instance); + const size_t stdNSlen = strlen(XMLSchema_instance); const size_t attrStrLen = strlen(attr[i]); - if((attrStrLen > stdNSlen) && (attr[i][stdNSlen] == '|') && (strncmp(attr[i], XMLSchema_instance, stdNSlen) == 0)) { - const char* localName = attr[i] + stdNSlen + 1; - if( strcmp(localName, "noNamespaceSchemaLocation") == 0) - jm_log_warning(context->callbacks, module, "Attribute noNamespaceSchemaLocation='%s' is ignored. Using standard fmiModelDescription.xsd.", - attr[i+1]); - else if((strcmp(localName, "nil") == 0) - || (strcmp(localName, "type") == 0)) { - jm_log_warning(context->callbacks, module, "Attribute {" XMLSchema_instance "}%s=%s is ignored", - localName, attr[i+1]); - } - else if(strcmp(localName, "schemaLocation") == 0) { - /* just skip this */ - } - else { - jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); - } - } - else if( - (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_States", attr[i]) == 0) || - (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_Inputs", attr[i]) == 0) || - (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_States", attr[i]) == 0) || - (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_Inputs", attr[i]) == 0) - ) { - jm_log_warning(context->callbacks, module, - "FMI API function fmiGetPartialDerivatives is removed from the specification. Attribute %s will be ignored.", attr[i]); - } - else { - /* not found error*/ - jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); - } + if((attrStrLen > stdNSlen) && (attr[i][stdNSlen] == '|') && (strncmp(attr[i], XMLSchema_instance, stdNSlen) == 0)) { + const char* localName = attr[i] + stdNSlen + 1; + if( strcmp(localName, "noNamespaceSchemaLocation") == 0) + jm_log_warning(context->callbacks, module, "Attribute noNamespaceSchemaLocation='%s' is ignored. Using standard fmiModelDescription.xsd.", + attr[i+1]); + else if((strcmp(localName, "nil") == 0) + || (strcmp(localName, "type") == 0)) { + jm_log_warning(context->callbacks, module, "Attribute {" XMLSchema_instance "}%s=%s is ignored", + localName, attr[i+1]); + } + else if(strcmp(localName, "schemaLocation") == 0) { + /* just skip this */ + } + else { + jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); + } + } + else if( + (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_States", attr[i]) == 0) || + (strcmp("providesPartialDerivativesOf_DerivativeFunction_wrt_Inputs", attr[i]) == 0) || + (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_States", attr[i]) == 0) || + (strcmp("providesPartialDerivativesOf_OutputFunction_wrt_Inputs", attr[i]) == 0) + ) { + jm_log_warning(context->callbacks, module, + "FMI API function fmiGetPartialDerivatives is removed from the specification. Attribute %s will be ignored.", attr[i]); + } + else { + /* not found error*/ + jm_log_error(context->callbacks, module, "Unknown attribute '%s=%s' in XML", attr[i], attr[i+1]); + } } else { /* save attr value (still as string) for further handling */ const char** mapItem = (const char**)attrMapping->ptr; @@ -1027,11 +1027,11 @@ static void XMLCALL fmi3_parse_element_start(void *c, const char *elm, const cha } /* handle the element */ - if ( currentElMap->elementHandle(context, 0) ) { - /* try to skip and continue anyway */ + if ( currentElMap->elementHandle(context, 0) ) { + /* try to skip and continue anyway */ if(!context->skipElementCnt) context->skipElementCnt = 1; } - if (context->skipElementCnt) return; + if (context->skipElementCnt) return; /* check that the element handler has processed all the attributes */ for (i = 0; i < fmi3_xml_attr_number; i++) { if (jm_vector_get_item(jm_string)(context->attrBuffer, i)) { @@ -1050,25 +1050,25 @@ static void XMLCALL fmi3_parse_element_end(void* c, const char *elm) { fmi3_xml_element_handle_map_t keyEl; fmi3_xml_element_handle_map_t* currentElMap; - fmi3_xml_elm_enu_t currentID; + fmi3_xml_elm_enu_t currentID; fmi3_xml_parser_context_t *context = c; - if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { - fmi3_xml_callbacks_t* anyH = context->anyHandle; - context->anyElmCount--; - if(anyH && anyH->endHandle) { - int ret = anyH->endHandle(anyH->context, elm); - if(ret != 0) { - fmi3_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); - } - } - return; - } - - if(context->skipElementCnt) { - context->skipElementCnt--; - return; - } + if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { + fmi3_xml_callbacks_t* anyH = context->anyHandle; + context->anyElmCount--; + if(anyH && anyH->endHandle) { + int ret = anyH->endHandle(anyH->context, elm); + if(ret != 0) { + fmi3_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); + } + } + return; + } + + if(context->skipElementCnt) { + context->skipElementCnt--; + return; + } keyEl.elementName = elm; currentElMap = jm_vector_bsearch(fmi3_xml_element_handle_map_t)(context->elmMap, &keyEl, fmi3_xml_compare_elmName); @@ -1082,13 +1082,13 @@ static void XMLCALL fmi3_parse_element_end(void* c, const char *elm) { if(currentID != context -> currentElmID) { /* missmatch error */ fmi3_xml_parse_fatal(context, "Element end '%s' does not match element start '%s' in XML", elm, - fmi3_element_handle_map[context -> currentElmID].elementName); + fmi3_element_handle_map[context -> currentElmID].elementName); return; } jm_vector_push_back(char)(&context->elmData, 0); - if( currentElMap->elementHandle(context, jm_vector_get_itemp(char)(&context->elmData, 0) )) { + if( currentElMap->elementHandle(context, jm_vector_get_itemp(char)(&context->elmData, 0) )) { /* context->modelDescription->hasParsingError = 1;*/ return; } @@ -1114,33 +1114,33 @@ static void XMLCALL fmi3_parse_element_end(void* c, const char *elm) { * to replace this with the empty string whenever we encounter "\n". */ static void XMLCALL fmi3_parse_element_data(void* c, const XML_Char *s, int len) { - int i; + int i; fmi3_xml_parser_context_t *context = c; - if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { - fmi3_xml_callbacks_t* anyH = context->anyHandle; - if(anyH && anyH->dataHandle) { - int ret = anyH->dataHandle(anyH->context, s, len); - if(ret != 0) { - fmi3_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); - } - } - return; - } - if(context->skipElementCnt) { - return; - } - for(i = 0; i< len;i++) { + if(context->useAnyHandleFlg && (context->anyElmCount > 0)) { + fmi3_xml_callbacks_t* anyH = context->anyHandle; + if(anyH && anyH->dataHandle) { + int ret = anyH->dataHandle(anyH->context, s, len); + if(ret != 0) { + fmi3_xml_parse_fatal(context, "User element handle returned non-zero error code %d", ret); + } + } + return; + } + if(context->skipElementCnt) { + return; + } + for(i = 0; i< len;i++) { char ch = s[i]; if((ch != '\n') && (ch != ' ') && (ch != '\t')) { break; } } - if((i != len) && !context->has_produced_data_warning) { - jm_log_warning(context->callbacks, module, "[Line:%u] Skipping unexpected XML element data", - XML_GetCurrentLineNumber(context->parser)); - context->has_produced_data_warning = 1; - } + if((i != len) && !context->has_produced_data_warning) { + jm_log_warning(context->callbacks, module, "[Line:%u] Skipping unexpected XML element data", + XML_GetCurrentLineNumber(context->parser)); + context->has_produced_data_warning = 1; + } } void fmi3_check_variable_naming_conventions(fmi3_xml_model_description_t *md) { @@ -1197,15 +1197,15 @@ int fmi3_xml_parse_model_description(fmi3_xml_model_description_t* md, } context->lastBaseUnit = 0; context->skipOneVariableFlag = 0; - context->skipElementCnt = 0; + context->skipElementCnt = 0; jm_stack_init(int)(&context->elmStack, context->callbacks); jm_vector_init(char)(&context->elmData, 0, context->callbacks); context->lastElmID = fmi3_xml_elmID_none; context->currentElmID = fmi3_xml_elmID_none; - context->anyElmCount = 0; - context->useAnyHandleFlg = 0; + context->anyElmCount = 0; + context->useAnyHandleFlg = 0; context->anyParent = 0; - context->anyHandle = xml_callbacks; + context->anyHandle = xml_callbacks; /* Set locale such that parsing does not depend on the environment. * For example, LC_NUMERIC affects what sscanf identifies as the floating @@ -1245,7 +1245,7 @@ int fmi3_xml_parse_model_description(fmi3_xml_model_description_t* md, if(ferror(file)) { fmi3_xml_parse_fatal(context, "Error reading from file %s", filename); fclose(file); - fmi3_xml_parse_free_context(context); + fmi3_xml_parse_free_context(context); return -1; } if (!XML_Parse(parser, text, n, feof(file))) { @@ -1253,7 +1253,7 @@ int fmi3_xml_parse_model_description(fmi3_xml_model_description_t* md, (int)XML_GetCurrentLineNumber(parser), XML_ErrorString(XML_GetErrorCode(parser))); fclose(file); - fmi3_xml_parse_free_context(context); + fmi3_xml_parse_free_context(context); return -1; /* failure */ } } diff --git a/src/XML/src/FMI3/fmi3_xml_parser.h b/src/XML/src/FMI3/fmi3_xml_parser.h index 5363db79..a28de547 100644 --- a/src/XML/src/FMI3/fmi3_xml_parser.h +++ b/src/XML/src/FMI3/fmi3_xml_parser.h @@ -36,7 +36,7 @@ extern "C" { EXPAND_XML_ATTRNAME(fmiVersion) \ EXPAND_XML_ATTRNAME(factor) \ EXPAND_XML_ATTRNAME(offset) \ - FMI3_SI_BASE_UNITS(EXPAND_XML_ATTRNAME) \ + FMI3_SI_BASE_UNITS(EXPAND_XML_ATTRNAME) \ EXPAND_XML_ATTRNAME(name) \ EXPAND_XML_ATTRNAME(description) \ EXPAND_XML_ATTRNAME(quantity) \ @@ -44,7 +44,7 @@ extern "C" { EXPAND_XML_ATTRNAME(displayUnit) \ EXPAND_XML_ATTRNAME(relativeQuantity) \ EXPAND_XML_ATTRNAME(unbounded) \ - EXPAND_XML_ATTRNAME(min) \ + EXPAND_XML_ATTRNAME(min) \ EXPAND_XML_ATTRNAME(max) \ EXPAND_XML_ATTRNAME(nominal) \ EXPAND_XML_ATTRNAME(declaredType) \ @@ -79,13 +79,13 @@ extern "C" { EXPAND_XML_ATTRNAME(input) \ EXPAND_XML_ATTRNAME(needsExecutionTool) \ EXPAND_XML_ATTRNAME(canHandleVariableCommunicationStepSize) \ - EXPAND_XML_ATTRNAME(completedIntegratorStepNotNeeded) \ - EXPAND_XML_ATTRNAME(canBeInstantiatedOnlyOncePerProcess) \ - EXPAND_XML_ATTRNAME(canNotUseMemoryManagementFunctions) \ - EXPAND_XML_ATTRNAME(canGetAndSetFMUstate) \ - EXPAND_XML_ATTRNAME(canSerializeFMUstate) \ - EXPAND_XML_ATTRNAME(providesDirectionalDerivatives) /* used for verification: checks that this attribute does not exist */ \ - EXPAND_XML_ATTRNAME(providesDirectionalDerivative) \ + EXPAND_XML_ATTRNAME(completedIntegratorStepNotNeeded) \ + EXPAND_XML_ATTRNAME(canBeInstantiatedOnlyOncePerProcess) \ + EXPAND_XML_ATTRNAME(canNotUseMemoryManagementFunctions) \ + EXPAND_XML_ATTRNAME(canGetAndSetFMUstate) \ + EXPAND_XML_ATTRNAME(canSerializeFMUstate) \ + EXPAND_XML_ATTRNAME(providesDirectionalDerivatives) /* used for verification: checks that this attribute does not exist */ \ + EXPAND_XML_ATTRNAME(providesDirectionalDerivative) \ EXPAND_XML_ATTRNAME(canInterpolateInputs) \ EXPAND_XML_ATTRNAME(maxOutputDerivativeOrder) \ EXPAND_XML_ATTRNAME(canRunAsynchronuously) @@ -99,7 +99,7 @@ typedef enum fmi3_xml_attr_enu_t { /** \brief Element names used in XML */ #define FMI3_XML_ELMLIST(EXPAND_XML_ELMNAME) \ EXPAND_XML_ELMNAME(fmiModelDescription) \ - EXPAND_XML_ELMNAME(ModelExchange) \ + EXPAND_XML_ELMNAME(ModelExchange) \ EXPAND_XML_ELMNAME(CoSimulation) \ EXPAND_XML_ELMNAME(ScheduledExecution) \ EXPAND_XML_ELMNAME(SourceFiles) \ @@ -117,8 +117,8 @@ typedef enum fmi3_xml_attr_enu_t { EXPAND_XML_ELMNAME(ModelVariables) \ EXPAND_XML_ELMNAME(Dimension) \ EXPAND_XML_ELMNAME(Annotations) \ - EXPAND_XML_ELMNAME(LogCategories) \ - EXPAND_XML_ELMNAME(Category) \ + EXPAND_XML_ELMNAME(LogCategories) \ + EXPAND_XML_ELMNAME(Category) \ EXPAND_XML_ELMNAME(Float64) \ EXPAND_XML_ELMNAME(Float32) \ EXPAND_XML_ELMNAME(Int64) \ @@ -182,11 +182,11 @@ FMI3_XML_ELMLIST_ABSTRACT(EXPAND_ELM_HANDLE) #define FMI3_XML_ELM_ID(elm) fmi3_xml_elmID_##elm #define FMI3_XML_LIST_ELM_ID(elm) ,FMI3_XML_ELM_ID(elm) typedef enum fmi3_xml_elm_enu_t { - fmi3_xml_elmID_none = -1 + fmi3_xml_elmID_none = -1 FMI3_XML_ELMLIST(FMI3_XML_LIST_ELM_ID) - ,fmi3_xml_elm_actual_number - FMI3_XML_ELMLIST_ALT(FMI3_XML_LIST_ELM_ID) - FMI3_XML_ELMLIST_ABSTRACT(FMI3_XML_LIST_ELM_ID) + ,fmi3_xml_elm_actual_number + FMI3_XML_ELMLIST_ALT(FMI3_XML_LIST_ELM_ID) + FMI3_XML_ELMLIST_ABSTRACT(FMI3_XML_LIST_ELM_ID) ,fmi3_xml_elm_number } fmi3_xml_elm_enu_t; @@ -195,19 +195,19 @@ typedef int (*fmi3_xml_element_handle_ft)(fmi3_xml_parser_context_t *context, co typedef struct fmi3_xml_element_handle_map_t fmi3_xml_element_handle_map_t; /** Keeps information about the allowed parent element ID, index among siblings in a sequence and if - multiple elements of this type are allowed in a sequence. + multiple elements of this type are allowed in a sequence. */ typedef struct { - fmi3_xml_elm_enu_t superID; /* ID of super type or NULL if none */ - fmi3_xml_elm_enu_t parentID; /* expected parent ID for an element */ - int siblingIndex; /* index among siblings */ - int multipleAllowed; /* multiple elements of this kind kan come in a sequence as siblings*/ + fmi3_xml_elm_enu_t superID; /* ID of super type or NULL if none */ + fmi3_xml_elm_enu_t parentID; /* expected parent ID for an element */ + int siblingIndex; /* index among siblings */ + int multipleAllowed; /* multiple elements of this kind kan come in a sequence as siblings*/ } fmi3_xml_scheme_info_t; struct fmi3_xml_element_handle_map_t { const char* elementName; fmi3_xml_element_handle_ft elementHandle; - fmi3_xml_elm_enu_t elemID; + fmi3_xml_elm_enu_t elemID; }; @@ -266,14 +266,14 @@ struct fmi3_xml_parser_context_t { * Incremented when an invalid element(or nested elements of invalid root * element) is found. Decremented when invalid element end tags are parsed. */ - int skipElementCnt; + int skipElementCnt; /** * There is no guarantee that all text will be handled in one call to the * function implementing the XML_CharacterDataHandler, and this variable * saves if a warning has already been generated. */ - int has_produced_data_warning; + int has_produced_data_warning; /** * Used to get parent element. @@ -299,7 +299,7 @@ struct fmi3_xml_parser_context_t { * Element ID of the last processed sibling, or fmi3_xml_elmID_none if * no siblings have been processed. */ - fmi3_xml_elm_enu_t lastElmID; + fmi3_xml_elm_enu_t lastElmID; /** * Used for error checking and scheme verification. @@ -311,16 +311,16 @@ struct fmi3_xml_parser_context_t { * on enter: self * on exit: parent */ - fmi3_xml_elm_enu_t currentElmID; + fmi3_xml_elm_enu_t currentElmID; fmi3_xml_elm_enu_t currentElemIdStartTag; /* Variables for handling tool-specific XML elements */ - int anyElmCount; - int useAnyHandleFlg; - char* anyToolName; - void* anyParent; - fmi3_xml_callbacks_t* anyHandle; + int anyElmCount; + int useAnyHandleFlg; + char* anyToolName; + void* anyParent; + fmi3_xml_callbacks_t* anyHandle; /* Data for restoring locale after parsing */ jm_locale_t* jm_locale; diff --git a/src/XML/src/FMI3/fmi3_xml_query.c b/src/XML/src/FMI3/fmi3_xml_query.c index 5acad7fc..bcdf9239 100644 --- a/src/XML/src/FMI3/fmi3_xml_query.c +++ b/src/XML/src/FMI3/fmi3_xml_query.c @@ -23,31 +23,31 @@ jm_name_ID_map_t fmi3_xml_q_elementary_map[fmi3_xml_elementary_enu_num+1] = { - #define FMI3_XML_Q_ELEMENTARY_MAP(name) {#name , fmi3_xml_q_elmentary_enu_##name}, + #define FMI3_XML_Q_ELEMENTARY_MAP(name) {#name , fmi3_xml_q_elmentary_enu_##name}, FMI3_XML_Q_ELEMENTARY(FMI3_XML_Q_ELEMENTARY_MAP) - {0,0} + {0,0} }; fmi3_xml_q_scan_elementary_ft fmi3_xml_q_scan_elementary_handles[fmi3_xml_elementary_enu_num + 1] = { - #define FMI3_XML_Q_ELEMENTARY_SCAN(name) fmi3_xml_q_scan_elementary_##name, + #define FMI3_XML_Q_ELEMENTARY_SCAN(name) fmi3_xml_q_scan_elementary_##name, FMI3_XML_Q_ELEMENTARY(FMI3_XML_Q_ELEMENTARY_SCAN) - 0 + 0 }; fmi3_xml_q_eval_elementary_ft fmi3_xml_q_eval_elementary_handles[fmi3_xml_elementary_enu_num + 1] = { - #define FMI3_XML_Q_ELEMENTARY_EVAL(name) fmi3_xml_q_eval_elementary_##name, + #define FMI3_XML_Q_ELEMENTARY_EVAL(name) fmi3_xml_q_eval_elementary_##name, FMI3_XML_Q_ELEMENTARY(FMI3_XML_Q_ELEMENTARY_EVAL) - 0 + 0 }; jm_name_ID_map_t fmi3_xml_q_op_map[] = { - {"or", fmi3_xml_q_term_enu_OR}, - {"and", fmi3_xml_q_term_enu_AND}, - {"not", fmi3_xml_q_term_enu_NOT}, - {"&&", fmi3_xml_q_term_enu_AND}, - {"||", fmi3_xml_q_term_enu_OR}, - {"!", fmi3_xml_q_term_enu_NOT}, - {0,-1} + {"or", fmi3_xml_q_term_enu_OR}, + {"and", fmi3_xml_q_term_enu_AND}, + {"not", fmi3_xml_q_term_enu_NOT}, + {"&&", fmi3_xml_q_term_enu_AND}, + {"||", fmi3_xml_q_term_enu_OR}, + {"!", fmi3_xml_q_term_enu_NOT}, + {0,-1} }; static void fmi3_xml_q_skip_space(jm_string* cur) { @@ -62,139 +62,139 @@ static void fmi3_xml_q_skip_space(jm_string* cur) { } int fmi3_xml_q_scan_string(fmi3_xml_q_context_t* context, char** param_str) { - fmi3_xml_q_expression_t* expr = &context->expr; - char* dest; - jm_string cur = context->query + context->curCh; + fmi3_xml_q_expression_t* expr = &context->expr; + char* dest; + jm_string cur = context->query + context->curCh; char ch = *cur; char strterm ; size_t strlen = 0; - if((ch == '\'') || (ch == '"')) /* either ' or " can be used as string terminator */ - strterm = ch; + if((ch == '\'') || (ch == '"')) /* either ' or " can be used as string terminator */ + strterm = ch; else - return -1; + return -1; do { ch = cur[strlen+1]; dest = jm_vector_push_back(char)(&expr->strbuf, ch); - assert(dest); + assert(dest); strlen++; } while((ch != strterm) && ch); if(!ch) return -1; /* string is not terminated */ - *dest = 0; /* put terminating 0*/ - strlen--; /* last zero is not a part of the string */ - *param_str = dest - strlen; + *dest = 0; /* put terminating 0*/ + strlen--; /* last zero is not a part of the string */ + *param_str = dest - strlen; return strlen; } int fmi3_xml_q_scan_elementary_name(fmi3_xml_q_context_t* context, fmi3_xml_q_terminal_t* term) { - jm_string startCh = &context->query[context->curCh]; - jm_string curCh = startCh; - size_t len; - - /* expecting: []'='[] */ - - fmi3_xml_q_skip_space(&curCh); - if(*curCh != '=') - return (int)(startCh - curCh); - curCh++; - fmi3_xml_q_skip_space(&curCh); - - len = (int)(curCh - startCh); - - context->curCh += len; - startCh += len; - - if( fmi3_xml_q_scan_string(context, &term->param_str) < 0) - return (int)(startCh - curCh); - - /* treat as regexp - > skip for now - if(term->param_str[0] == '^') { - - } - else */ - { - term->param_i = strlen(term->param_str); - if( (strchr ( term->param_str, '*') != 0) || (strchr ( term->param_str, '?') != 0) ){ - /* treat as wildcard */ - term->param_i *= -1; - } - } - return (int)(curCh - startCh); + jm_string startCh = &context->query[context->curCh]; + jm_string curCh = startCh; + size_t len; + + /* expecting: []'='[] */ + + fmi3_xml_q_skip_space(&curCh); + if(*curCh != '=') + return (int)(startCh - curCh); + curCh++; + fmi3_xml_q_skip_space(&curCh); + + len = (int)(curCh - startCh); + + context->curCh += len; + startCh += len; + + if( fmi3_xml_q_scan_string(context, &term->param_str) < 0) + return (int)(startCh - curCh); + + /* treat as regexp - > skip for now + if(term->param_str[0] == '^') { + + } + else */ + { + term->param_i = strlen(term->param_str); + if( (strchr ( term->param_str, '*') != 0) || (strchr ( term->param_str, '?') != 0) ){ + /* treat as wildcard */ + term->param_i *= -1; + } + } + return (int)(curCh - startCh); } int fmi3_xml_q_eval_elementary_name(fmi3_xml_variable_t* var, fmi3_xml_q_terminal_t* term) { - assert(term->specific == fmi3_xml_q_elmentary_enu_name); - - if(term->param_i < 0) { - return jm_wc_match(term->param_str, fmi3_xml_get_variable_name(var)); - } - else - return (strncmp(term->param_str, fmi3_xml_get_variable_name(var), term->param_i) == 0); - return 0; + assert(term->specific == fmi3_xml_q_elmentary_enu_name); + + if(term->param_i < 0) { + return jm_wc_match(term->param_str, fmi3_xml_get_variable_name(var)); + } + else + return (strncmp(term->param_str, fmi3_xml_get_variable_name(var), term->param_i) == 0); + return 0; } int fmi3_xml_q_scan_elementary_unit(fmi3_xml_q_context_t* context, fmi3_xml_q_terminal_t* term) { - jm_string startCh = &context->query[context->curCh]; - jm_string curCh = startCh; - size_t len; + jm_string startCh = &context->query[context->curCh]; + jm_string curCh = startCh; + size_t len; - /* expecting: []'='[] */ + /* expecting: []'='[] */ - fmi3_xml_q_skip_space(&curCh); - if(*curCh != '=') - return (int)(startCh - curCh); - curCh++; - fmi3_xml_q_skip_space(&curCh); + fmi3_xml_q_skip_space(&curCh); + if(*curCh != '=') + return (int)(startCh - curCh); + curCh++; + fmi3_xml_q_skip_space(&curCh); - len = (int)(curCh - startCh); + len = (int)(curCh - startCh); - context->curCh += len; - startCh += len; + context->curCh += len; + startCh += len; - if( fmi3_xml_q_scan_string(context, &term->param_str) < 0) - return (int)(startCh - curCh); - return (int)(curCh - startCh); + if( fmi3_xml_q_scan_string(context, &term->param_str) < 0) + return (int)(startCh - curCh); + return (int)(curCh - startCh); } int fmi3_xml_q_eval_elementary_unit(fmi3_xml_variable_t* var, fmi3_xml_q_terminal_t* term) { - return 0; + return 0; } int fmi3_xml_q_get_number(fmi3_xml_q_context_t* context, char* cur, double* val, char* buf) { - int len; - if(sscanf(cur, "%lg%s", val, buf) != 2) return 0; - len = strlen(cur) - strlen(buf); - return len; + int len; + if(sscanf(cur, "%lg%s", val, buf) != 2) return 0; + len = strlen(cur) - strlen(buf); + return len; } int fmi3_xml_q_get_keyword(fmi3_xml_q_context_t* context, char* cur, size_t* len, char* buf) { char ch = *cur; size_t i = 0, id; *len = 0; - if( (ch == '|') || (ch == '&') ) { - if(ch == cur[i+1]) { - buf[i++] = ch; - buf[i++] = ch; - } - } - else { - while(isalpha(ch)) { - buf[i++] = tolower(ch); - ch = cur[i]; - } - } - + if( (ch == '|') || (ch == '&') ) { + if(ch == cur[i+1]) { + buf[i++] = ch; + buf[i++] = ch; + } + } + else { + while(isalpha(ch)) { + buf[i++] = tolower(ch); + ch = cur[i]; + } + } + if(!i) return -1; - { - jm_name_ID_map_t key; - jm_name_ID_map_t* map; - key.name = buf; - map = jm_vector_bsearch(jm_name_ID_map_t)(&context->elementary_map, &key,jm_compare_name); - if(!map) return -1; - id = map->ID; - } + { + jm_name_ID_map_t key; + jm_name_ID_map_t* map; + key.name = buf; + map = jm_vector_bsearch(jm_name_ID_map_t)(&context->elementary_map, &key,jm_compare_name); + if(!map) return -1; + id = map->ID; + } *len = i; return id; } @@ -227,18 +227,18 @@ int pattern2regexp(const char* pattern, jm_vector(char)* re) { } int fmi3_xml_evaluate_terminal(fmi3_xml_variable_t* var, fmi3_xml_q_terminal_t* term) { - return fmi3_xml_q_eval_elementary_handles[term->specific](var, term); + return fmi3_xml_q_eval_elementary_handles[term->specific](var, term); } int fmi3_xml_q_filter_variable(fmi3_xml_variable_t* var, fmi3_xml_q_expression_t* expr) { size_t cur, len = jm_vector_get_size(jm_voidp)(&expr->expression); - jm_vector(jm_voidp)* stack = &expr->stack; - fmi3_xml_q_terminal_t * term; + jm_vector(jm_voidp)* stack = &expr->stack; + fmi3_xml_q_terminal_t * term; for(cur = 0; cur < len; cur++) { fmi3_xml_q_terminal_t *argL, *argR; size_t curlen = jm_vector_get_size(jm_voidp)(stack); - term = (fmi3_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(&expr->expression, cur); + term = (fmi3_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(&expr->expression, cur); argL = (curlen > 0) ? (fmi3_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,curlen -1):0; argR = (curlen > 1) ? (fmi3_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,curlen -2):0; @@ -262,140 +262,140 @@ int fmi3_xml_q_filter_variable(fmi3_xml_variable_t* var, fmi3_xml_q_expression_t } break; case fmi3_xml_q_term_enu_NOT: - assert(argL); + assert(argL); jm_vector_resize(jm_voidp)(stack, curlen -1); if(argL->kind == fmi3_xml_q_term_enu_TRUE) jm_vector_push_back(jm_voidp)(stack, &expr->termFalse); - else if(argL->kind == fmi3_xml_q_term_enu_TRUE) + else if(argL->kind == fmi3_xml_q_term_enu_TRUE) jm_vector_push_back(jm_voidp)(stack, &expr->termTrue); else { jm_vector_push_back(jm_voidp)(stack, (fmi3_xml_evaluate_terminal(var, argL)? &expr->termFalse: &expr->termTrue)); } - break; - case fmi3_xml_q_term_enu_LP: - case fmi3_xml_q_term_enu_RP: - assert(0); - break; + break; + case fmi3_xml_q_term_enu_LP: + case fmi3_xml_q_term_enu_RP: + assert(0); + break; default: jm_vector_push_back(jm_voidp)(stack, term); /* only evaluate when needed. push as is at first */ } } assert(jm_vector_get_size(jm_voidp)(stack) == 1); - + term = (fmi3_xml_q_terminal_t *)jm_vector_get_item(jm_voidp)(stack,0); if(term->kind == fmi3_xml_q_term_enu_FALSE) return 0; - assert(term->kind == fmi3_xml_q_term_enu_TRUE); + assert(term->kind == fmi3_xml_q_term_enu_TRUE); return 1; } fmi3_xml_q_expression_t* fmi3_xml_alloc_expression(jm_string query) { - return 0; + return 0; } int fmi3_xml_q_parse_elementary(fmi3_xml_q_context_t* context, fmi3_xml_q_terminal_t* term) { - return 0; + return 0; } void fmi3_xml_q_init_context(fmi3_xml_q_context_t* c, jm_callbacks* cb) { - size_t l = jm_vector_init(jm_name_ID_map_t)(&c->elementary_map, fmi3_xml_elementary_enu_num, cb); - assert(l); - for(l = 0; l < fmi3_xml_elementary_enu_num; l++) { - jm_vector_set_item(jm_name_ID_map_t)(&c->elementary_map, l,fmi3_xml_q_elementary_map[l]); - } - jm_vector_qsort(jm_name_ID_map_t)(&c->elementary_map,jm_compare_name); - c->query = 0; - c->qlen = 0; - c->curCh = 0; - jm_vector_init(char)(&c->buf,0,cb); - - { - fmi3_xml_q_expression_t* expr = &c->expr; - jm_vector_init(jm_voidp)(&expr->expression,0,cb); - jm_vector_init(jm_voidp)(&expr->stack,0,cb); - expr->termFalse.kind = fmi3_xml_q_term_enu_FALSE; - expr->termTrue.kind = fmi3_xml_q_term_enu_TRUE; - jm_vector_init(fmi3_xml_q_terminal_t)(&expr->terms,0,cb); - jm_vector_init(char)(&expr->strbuf, 0, cb); - } + size_t l = jm_vector_init(jm_name_ID_map_t)(&c->elementary_map, fmi3_xml_elementary_enu_num, cb); + assert(l); + for(l = 0; l < fmi3_xml_elementary_enu_num; l++) { + jm_vector_set_item(jm_name_ID_map_t)(&c->elementary_map, l,fmi3_xml_q_elementary_map[l]); + } + jm_vector_qsort(jm_name_ID_map_t)(&c->elementary_map,jm_compare_name); + c->query = 0; + c->qlen = 0; + c->curCh = 0; + jm_vector_init(char)(&c->buf,0,cb); + + { + fmi3_xml_q_expression_t* expr = &c->expr; + jm_vector_init(jm_voidp)(&expr->expression,0,cb); + jm_vector_init(jm_voidp)(&expr->stack,0,cb); + expr->termFalse.kind = fmi3_xml_q_term_enu_FALSE; + expr->termTrue.kind = fmi3_xml_q_term_enu_TRUE; + jm_vector_init(fmi3_xml_q_terminal_t)(&expr->terms,0,cb); + jm_vector_init(char)(&expr->strbuf, 0, cb); + } } void fmi3_xml_q_free_context_data(fmi3_xml_q_context_t* c){ - fmi3_xml_q_expression_t* expr = &c->expr; - jm_vector_free_data(jm_name_ID_map_t)(&c->elementary_map); - jm_vector_free_data(char)(&c->buf); - jm_vector_free_data(jm_voidp)(&expr->expression); - jm_vector_free_data(jm_voidp)(&expr->stack); - jm_vector_free_data(fmi3_xml_q_terminal_t)(&expr->terms); - jm_vector_free_data(char)(&expr->strbuf); + fmi3_xml_q_expression_t* expr = &c->expr; + jm_vector_free_data(jm_name_ID_map_t)(&c->elementary_map); + jm_vector_free_data(char)(&c->buf); + jm_vector_free_data(jm_voidp)(&expr->expression); + jm_vector_free_data(jm_voidp)(&expr->stack); + jm_vector_free_data(fmi3_xml_q_terminal_t)(&expr->terms); + jm_vector_free_data(char)(&expr->strbuf); } int fmi3_xml_q_parse_terminal(fmi3_xml_q_context_t* context, fmi3_xml_q_terminal_t** ppterm) { - int offset = 0; + int offset = 0; fmi3_xml_q_terminal_t* pterm; - jm_string startCh = context->query + context->curCh; - jm_string cur = startCh; - pterm = jm_vector_resize1(fmi3_xml_q_terminal_t)(&context->expr.terms); + jm_string startCh = context->query + context->curCh; + jm_string cur = startCh; + pterm = jm_vector_resize1(fmi3_xml_q_terminal_t)(&context->expr.terms); if(!pterm) return -1; - *ppterm = pterm; + *ppterm = pterm; fmi3_xml_q_skip_space(&cur); switch(*cur) { case '(': - pterm->kind = fmi3_xml_q_term_enu_LP; - break; + pterm->kind = fmi3_xml_q_term_enu_LP; + break; case ')': - pterm->kind = fmi3_xml_q_term_enu_RP; - break; + pterm->kind = fmi3_xml_q_term_enu_RP; + break; case '&': - pterm->kind = fmi3_xml_q_term_enu_AND; - break; + pterm->kind = fmi3_xml_q_term_enu_AND; + break; case '|': - pterm->kind = fmi3_xml_q_term_enu_OR; - break; + pterm->kind = fmi3_xml_q_term_enu_OR; + break; case '!': - pterm->kind = fmi3_xml_q_term_enu_NOT; - break; + pterm->kind = fmi3_xml_q_term_enu_NOT; + break; case 0: - pterm->kind = fmi3_xml_q_term_enu_END; - break; + pterm->kind = fmi3_xml_q_term_enu_END; + break; default: fmi3_xml_q_parse_elementary(context, pterm); } - fmi3_xml_q_skip_space(&cur); - return (int)(cur - startCh); + fmi3_xml_q_skip_space(&cur); + return (int)(cur - startCh); } int fmi3_xml_q_parse_query(fmi3_xml_q_context_t* context, jm_string query) { - fmi3_xml_q_expression_t* expr = &context->expr; + fmi3_xml_q_expression_t* expr = &context->expr; int qlen = strlen(query); - int offset = 0, curCh = 0; - int expectOperand = 1; - size_t stacklen = 0; + int offset = 0, curCh = 0; + int expectOperand = 1; + size_t stacklen = 0; fmi3_xml_q_terminal_t* stackTop = 0; - context->query = query; - context->qlen = qlen; - if(jm_vector_reserve(char)(&context->buf, qlen) < (size_t)qlen) return -1; - if(jm_vector_reserve(char)(&context->expr.strbuf, qlen) < (size_t)qlen) return -1; + context->query = query; + context->qlen = qlen; + if(jm_vector_reserve(char)(&context->buf, qlen) < (size_t)qlen) return -1; + if(jm_vector_reserve(char)(&context->expr.strbuf, qlen) < (size_t)qlen) return -1; while(curCh < qlen) { fmi3_xml_q_terminal_t* term; size_t explen = jm_vector_get_size(jm_voidp)(&expr->expression); fmi3_xml_q_terminal_t* expTop = explen? (fmi3_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->expression,explen -1):0; - offset = fmi3_xml_q_parse_terminal(context, &term); + offset = fmi3_xml_q_parse_terminal(context, &term); - if(offset < 0) return -curCh; + if(offset < 0) return -curCh; - stacklen = jm_vector_get_size(jm_voidp)(&expr->stack); + stacklen = jm_vector_get_size(jm_voidp)(&expr->stack); stackTop = stacklen ? (fmi3_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->stack,stacklen -1):(fmi3_xml_q_terminal_t*)0; switch(term -> kind) { case fmi3_xml_q_term_enu_LP: - if(!expectOperand) return -curCh; + if(!expectOperand) return -curCh; jm_vector_push_back(jm_voidp)(&expr->stack, term); break; case fmi3_xml_q_term_enu_RP: - if(expectOperand) return -curCh; + if(expectOperand) return -curCh; while(stackTop && (stackTop->kind != fmi3_xml_q_term_enu_LP)) { jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); stacklen--; @@ -407,8 +407,8 @@ int fmi3_xml_q_parse_query(fmi3_xml_q_context_t* context, jm_string query) { break; case fmi3_xml_q_term_enu_AND: - if(expectOperand) return -curCh; - expectOperand = 1; + if(expectOperand) return -curCh; + expectOperand = 1; if(!expTop) return -curCh; if(stackTop && (stackTop->kind == fmi3_xml_q_term_enu_AND)) jm_vector_push_back(jm_voidp)(&expr->expression, term); @@ -416,8 +416,8 @@ int fmi3_xml_q_parse_query(fmi3_xml_q_context_t* context, jm_string query) { jm_vector_push_back(jm_voidp)(&expr->stack, term); break; case fmi3_xml_q_term_enu_OR: - if(expectOperand) return -curCh; - expectOperand = 1; + if(expectOperand) return -curCh; + expectOperand = 1; if(!expTop) return -curCh; while(stackTop && ((stackTop->kind == fmi3_xml_q_term_enu_AND)||(stackTop->kind == fmi3_xml_q_term_enu_OR))) { jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); @@ -428,17 +428,17 @@ int fmi3_xml_q_parse_query(fmi3_xml_q_context_t* context, jm_string query) { jm_vector_push_back(jm_voidp)(&expr->stack, term); break; default: - if(!expectOperand) return -curCh; - expectOperand = 0; + if(!expectOperand) return -curCh; + expectOperand = 0; jm_vector_push_back(jm_voidp)(&expr->expression, term); } - curCh += offset; - context->curCh = curCh; + curCh += offset; + context->curCh = curCh; } - if(expectOperand) return -curCh; + if(expectOperand) return -curCh; while(stackTop && (stackTop->kind != fmi3_xml_q_term_enu_LP)) { - jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); + jm_vector_push_back(jm_voidp)(&expr->expression, stackTop); jm_vector_resize(jm_voidp)(&expr->stack, stacklen -1); stacklen--; stackTop = stacklen? (fmi3_xml_q_terminal_t*)jm_vector_get_item(jm_voidp)(&expr->stack,stacklen -1):0; diff --git a/src/XML/src/FMI3/fmi3_xml_query.h b/src/XML/src/FMI3/fmi3_xml_query.h index f5c35fcc..9867432f 100644 --- a/src/XML/src/FMI3/fmi3_xml_query.h +++ b/src/XML/src/FMI3/fmi3_xml_query.h @@ -80,27 +80,27 @@ typedef int (*fmi3_xml_q_eval_elementary_ft)(fmi3_xml_variable_t* var, fmi3_xml_ FMI3_XML_Q_ELEMENTARY(FMI3_XML_Q_ELEMENTARY_DECLARE_EVAL) typedef enum fmi3_xml_q_term_enu_t { - fmi3_xml_q_term_enu_elementary, - fmi3_xml_q_term_enu_LP, - fmi3_xml_q_term_enu_RP, - fmi3_xml_q_term_enu_OR, - fmi3_xml_q_term_enu_AND, - fmi3_xml_q_term_enu_NOT, - fmi3_xml_q_term_enu_END, - fmi3_xml_q_term_enu_TRUE, - fmi3_xml_q_term_enu_FALSE + fmi3_xml_q_term_enu_elementary, + fmi3_xml_q_term_enu_LP, + fmi3_xml_q_term_enu_RP, + fmi3_xml_q_term_enu_OR, + fmi3_xml_q_term_enu_AND, + fmi3_xml_q_term_enu_NOT, + fmi3_xml_q_term_enu_END, + fmi3_xml_q_term_enu_TRUE, + fmi3_xml_q_term_enu_FALSE } fmi3_xml_q_terminal_enu_t; struct fmi3_xml_q_terminal_t { - fmi3_xml_q_terminal_enu_t kind; + fmi3_xml_q_terminal_enu_t kind; - fmi3_xml_elementary_enu_t specific; + fmi3_xml_elementary_enu_t specific; - int param_i; - double param_d; - void* param_p; - char* param_str; + int param_i; + double param_d; + void* param_p; + char* param_str; }; @@ -117,20 +117,20 @@ struct fmi3_xml_q_expression_t { fmi3_xml_q_terminal_t termFalse, termTrue; fmi3_xml_q_term_vt terms; - jm_vector(char) strbuf; + jm_vector(char) strbuf; }; struct fmi3_xml_q_context_t { jm_vector(jm_name_ID_map_t) elementary_map; - jm_string query; + jm_string query; - size_t qlen; - int curCh; + size_t qlen; + int curCh; - jm_vector(char) buf; + jm_vector(char) buf; - fmi3_xml_q_expression_t expr; + fmi3_xml_q_expression_t expr; }; void fmi3_xml_q_init_context(fmi3_xml_q_context_t*, jm_callbacks* cb); diff --git a/src/XML/src/FMI3/fmi3_xml_type_impl.h b/src/XML/src/FMI3/fmi3_xml_type_impl.h index 2ed68853..581b440e 100644 --- a/src/XML/src/FMI3/fmi3_xml_type_impl.h +++ b/src/XML/src/FMI3/fmi3_xml_type_impl.h @@ -72,15 +72,15 @@ struct fmi3_xml_variable_type_base_t { fmi3_xml_type_struct_kind_enu_t structKind; /* the actual (sub) type */ fmi3_base_type_enu_t baseType; /* the FMI base type */ char isRelativeQuantity; /* relativeQuantity flag (only used in fmi3_xml_real_type_props_t) */ - char isUnbounded; /* unbounded flag (only used in fmi3_xml_real_type_props_t) */ + char isUnbounded; /* unbounded flag (only used in fmi3_xml_real_type_props_t) */ fmi3_xml_variable_type_base_t* next; /* should only be used for deallocation */ }; /* - Variable type definition is general and is used for all types. - This is done to enable easy handling of SimpleType XML element - (specific type element comes next). + Variable type definition is general and is used for all types. + This is done to enable easy handling of SimpleType XML element + (specific type element comes next). */ struct fmi3_xml_variable_typedef_t { fmi3_xml_variable_type_base_t super; @@ -142,16 +142,16 @@ typedef fmi3_xml_variable_type_base_t fmi3_xml_bool_type_props_t; typedef struct fmi3_xml_enum_type_item_t { jm_string itemName; - int value; + int value; char itemDesciption[1]; } fmi3_xml_enum_type_item_t; static int fmi1_xml_compare_enum_val (const void* first, const void* second) { - const jm_named_ptr* a = first; - const jm_named_ptr* b = second; - fmi3_xml_enum_type_item_t* ai = a->ptr; - fmi3_xml_enum_type_item_t* bi = b->ptr; - return (ai->value - bi->value); + const jm_named_ptr* a = first; + const jm_named_ptr* b = second; + fmi3_xml_enum_type_item_t* ai = a->ptr; + fmi3_xml_enum_type_item_t* bi = b->ptr; + return (ai->value - bi->value); } typedef struct fmi3_xml_enum_variable_props_t { @@ -164,7 +164,7 @@ typedef struct fmi3_xml_enum_variable_props_t { } fmi3_xml_enum_variable_props_t; typedef struct fmi3_xml_enum_typedef_props_t { - fmi3_xml_enum_variable_props_t base; + fmi3_xml_enum_variable_props_t base; jm_vector(jm_named_ptr) enumItems; } fmi3_xml_enum_typedef_props_t; diff --git a/src/XML/src/FMI3/fmi3_xml_unit.c b/src/XML/src/FMI3/fmi3_xml_unit.c index 136a3333..23edf6fc 100644 --- a/src/XML/src/FMI3/fmi3_xml_unit.c +++ b/src/XML/src/FMI3/fmi3_xml_unit.c @@ -28,41 +28,41 @@ const char* fmi3_xml_get_unit_name(fmi3_xml_unit_t* u) { } /** - \brief Get fmi3_SI_base_units_Num SI base units exponents associated with the unit. + \brief Get fmi3_SI_base_units_Num SI base units exponents associated with the unit. */ const int* fmi3_xml_get_SI_unit_exponents(fmi3_xml_unit_t* u) { - return u->SI_base_unit_exp; + return u->SI_base_unit_exp; } /** - \brief Get factor to the corresponding SI base units. + \brief Get factor to the corresponding SI base units. */ double fmi3_xml_get_SI_unit_factor(fmi3_xml_unit_t* u){ - return u->factor; + return u->factor; } /** - \brief Get offset to the corresponding SI base units. + \brief Get offset to the corresponding SI base units. */ double fmi3_xml_get_SI_unit_offset(fmi3_xml_unit_t* u) { - return u->offset; + return u->offset; } /** - \brief Convert a value with respect to the unit to the - value with respect to the SI base unit. + \brief Convert a value with respect to the unit to the + value with respect to the SI base unit. */ double fmi3_xml_convert_to_SI_base_unit(double uv, fmi3_xml_unit_t* u) { - return u->factor * uv + u->offset; + return u->factor * uv + u->offset; } /** - \brief Convert a value with respect to the SI base unit to the - value with respect to the unit. + \brief Convert a value with respect to the SI base unit to the + value with respect to the unit. */ double fmi3_xml_convert_from_SI_base_unit(double SIv, fmi3_xml_unit_t* u) { - return (SIv - u->offset)/u->factor; + return (SIv - u->offset)/u->factor; } unsigned int fmi3_xml_get_unit_display_unit_number(fmi3_xml_unit_t* u) { @@ -112,8 +112,8 @@ double fmi3_xml_convert_from_display_unit(double val, fmi3_xml_display_unit_t* d int fmi3_xml_handle_UnitDefinitions(fmi3_xml_parser_context_t *context, const char* data) { fmi3_xml_model_description_t* md = context->modelDescription; if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element UnitDefinitions"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element UnitDefinitions"); + } else { jm_vector_qsort(jm_named_ptr)(&(md->unitDefinitions),jm_compare_named); jm_vector_qsort(jm_named_ptr)(&(md->displayUnitDefinitions),jm_compare_named); @@ -127,13 +127,13 @@ fmi3_xml_display_unit_t* fmi3_xml_get_parsed_unit(fmi3_xml_parser_context_t *con fmi3_xml_unit_t dummy, *unit; jm_named_ptr named, *pnamed; fmi3_xml_model_description_t* md = context->modelDescription; - int i; - if(jm_vector_get_size(char)(name)) - named.name = jm_vector_get_itemp(char)(name,0); - else - named.name = ""; + int i; + if(jm_vector_get_size(char)(name)) + named.name = jm_vector_get_itemp(char)(name,0); + else + named.name = ""; - if(sorted) + if(sorted) pnamed = jm_vector_bsearch(jm_named_ptr)(&(md->unitDefinitions), &named,jm_compare_named); else pnamed = jm_vector_find(jm_named_ptr)(&(md->unitDefinitions), &named,jm_compare_named); @@ -153,10 +153,10 @@ fmi3_xml_display_unit_t* fmi3_xml_get_parsed_unit(fmi3_xml_parser_context_t *con } unit = named.ptr; - unit->factor = 1.0; - unit->offset = 0.0; - for(i = 0; i < fmi3_SI_base_units_Num; i++) - unit->SI_base_unit_exp[i] = 0; + unit->factor = 1.0; + unit->offset = 0.0; + for(i = 0; i < fmi3_SI_base_units_Num; i++) + unit->SI_base_unit_exp[i] = 0; unit->defaultDisplay.baseUnit = unit; unit->defaultDisplay.offset = 0; unit->defaultDisplay.factor = 1.0; @@ -169,29 +169,29 @@ fmi3_xml_display_unit_t* fmi3_xml_get_parsed_unit(fmi3_xml_parser_context_t *con int fmi3_xml_handle_BaseUnit(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { - int ret; + int ret; /* fmi3_xml_model_description_t* md = context->modelDescription; */ /* this base unit belongs to the last created base unit */ fmi3_xml_unit_t* unit = context->lastBaseUnit; /* process the attributes */ - /* */ + /* */ #define FMI3_PARSE_SI_BASE_UNIT_ENU(c) \ - fmi3_xml_set_attr_int32(context, fmi3_xml_elmID_BaseUnit, fmi_attr_id_ ## c, 0, &(unit->SI_base_unit_exp[fmi3_SI_base_unit_ ## c]), 0) || - ret = - FMI3_SI_BASE_UNITS(FMI3_PARSE_SI_BASE_UNIT_ENU) - /* */ + fmi3_xml_set_attr_int32(context, fmi3_xml_elmID_BaseUnit, fmi_attr_id_ ## c, 0, &(unit->SI_base_unit_exp[fmi3_SI_base_unit_ ## c]), 0) || + ret = + FMI3_SI_BASE_UNITS(FMI3_PARSE_SI_BASE_UNIT_ENU) + /* */ fmi3_xml_set_attr_float64(context, fmi3_xml_elmID_BaseUnit, fmi_attr_id_factor, 0, &unit->factor, 1) || /* */ fmi3_xml_set_attr_float64(context, fmi3_xml_elmID_BaseUnit, fmi_attr_id_offset, 0, &unit->offset, 0); - if(unit->factor == 0) { - unit->factor = 1.0; - if(!ret) { - fmi3_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); - } - } + if(unit->factor == 0) { + unit->factor = 1.0; + if(!ret) { + fmi3_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); + } + } return ( ret ); } @@ -211,7 +211,7 @@ int fmi3_xml_handle_Unit(fmi3_xml_parser_context_t *context, const char* data) { if(!buf) return -1; if( - /* */ + /* */ fmi3_xml_set_attr_string(context, fmi3_xml_elmID_BaseUnit, fmi_attr_id_name, 1, buf) || !(unit = fmi3_xml_get_parsed_unit(context, buf, 0)) ) return -1; @@ -226,7 +226,7 @@ int fmi3_xml_handle_Unit(fmi3_xml_parser_context_t *context, const char* data) { int fmi3_xml_handle_DisplayUnit(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { - int ret; + int ret; fmi3_xml_model_description_t* md = context->modelDescription; jm_vector(char)* buf = fmi3_xml_reserve_parse_buffer(context,1,100); /* this display unit belongs to the last created base unit */ @@ -252,17 +252,17 @@ int fmi3_xml_handle_DisplayUnit(fmi3_xml_parser_context_t *context, const char* } dispUnit->baseUnit = unit; /* finally process the attributes */ - ret = - /* */ + ret = + /* */ fmi3_xml_set_attr_float64(context, fmi3_xml_elmID_DisplayUnit, fmi_attr_id_factor, 0, &dispUnit->factor, 1) || /* */ fmi3_xml_set_attr_float64(context, fmi3_xml_elmID_DisplayUnit, fmi_attr_id_offset, 0, &dispUnit->offset, 0); - if(dispUnit->factor == 0) { - dispUnit->factor = 1.0; - if(!ret) { - fmi3_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); - } - } + if(dispUnit->factor == 0) { + dispUnit->factor = 1.0; + if(!ret) { + fmi3_xml_parse_error(context, "Attribute 'factor' cannot be equal to zero"); + } + } return ( ret ); } diff --git a/src/XML/src/FMI3/fmi3_xml_unit_impl.h b/src/XML/src/FMI3/fmi3_xml_unit_impl.h index 60a40349..b001bfa2 100644 --- a/src/XML/src/FMI3/fmi3_xml_unit_impl.h +++ b/src/XML/src/FMI3/fmi3_xml_unit_impl.h @@ -35,9 +35,9 @@ struct fmi3_xml_display_unit_t { struct fmi3_xml_unit_t { jm_vector(jm_voidp) displayUnits; - int SI_base_unit_exp[fmi3_SI_base_units_Num]; - double factor; - double offset; + int SI_base_unit_exp[fmi3_SI_base_units_Num]; + double factor; + double offset; fmi3_xml_display_unit_t defaultDisplay; char baseUnit[1]; }; diff --git a/src/XML/src/FMI3/fmi3_xml_variable_impl.h b/src/XML/src/FMI3/fmi3_xml_variable_impl.h index 15b8e59b..ea2d1b9c 100644 --- a/src/XML/src/FMI3/fmi3_xml_variable_impl.h +++ b/src/XML/src/FMI3/fmi3_xml_variable_impl.h @@ -31,9 +31,9 @@ extern "C" { struct fmi3_xml_variable_t { fmi3_xml_variable_type_base_t* type; /** \brief Type information of the variable */ - const char* description; /** \brief Associate description */ + const char* description; /** \brief Associate description */ - size_t originalIndex; /** \brief Index in the model description */ + size_t originalIndex; /** \brief Index in the model description */ /* NB: before parsing of has finished, derivativeOf and previous are stored as integer indices cast to pointers, @@ -41,7 +41,7 @@ struct fmi3_xml_variable_t { fmi3_xml_variable_t *derivativeOf; /** \brief Only for continuous FloatXX variables. If non-NULL, the variable that this is the derivative of. */ fmi3_xml_variable_t *previous; /** \brief If non-NULL, the variable that holds the value of this variable at the previous super-dense time instant. */ - fmi3_value_reference_t vr; /** \brief Value reference */ + fmi3_value_reference_t vr; /** \brief Value reference */ char aliasKind; char initial; char variability; @@ -70,8 +70,8 @@ static int fmi3_xml_compare_vr (const void* first, const void* second) { fmi3_xml_variable_t* b = *(fmi3_xml_variable_t**)second; fmi3_base_type_enu_t at = fmi3_xml_get_variable_base_type(a); fmi3_base_type_enu_t bt = fmi3_xml_get_variable_base_type(b); - if(at == fmi3_base_type_enum) at = fmi3_base_type_int32; - if(bt == fmi3_base_type_enum) bt = fmi3_base_type_int32; + if(at == fmi3_base_type_enum) at = fmi3_base_type_int32; + if(bt == fmi3_base_type_enum) bt = fmi3_base_type_int32; if(at!=bt) return at - bt; if(a->vr < b->vr) return -1; if(a->vr > b->vr) return 1; diff --git a/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c b/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c index f0492d0a..c0305987 100644 --- a/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c +++ b/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c @@ -23,8 +23,8 @@ static const char* module = "FMI3XML"; int fmi3_xml_handle_VendorAnnotations(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations"); + } else { /* might give out a warning if(data[0] != 0) */ } @@ -33,8 +33,8 @@ int fmi3_xml_handle_VendorAnnotations(fmi3_xml_parser_context_t *context, const int fmi3_xml_handle_Annotations(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { - jm_log_verbose(context->callbacks, module, "Parsing XML element Annotations"); - } + jm_log_verbose(context->callbacks, module, "Parsing XML element Annotations"); + } else { /* might give out a warning if(data[0] != 0) */ } @@ -43,34 +43,34 @@ int fmi3_xml_handle_Annotations(fmi3_xml_parser_context_t *context, const char* int fmi3_xml_handle_VariableTool(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { - size_t len; + size_t len; fmi3_xml_model_description_t* md = context->modelDescription; jm_vector(char)* bufName = fmi3_xml_reserve_parse_buffer(context,1,100); jm_string *pvendor; - char* vendor = 0; - + char* vendor = 0; + if(!bufName) return -1; /* */ if( fmi3_xml_set_attr_string(context, fmi3_xml_elmID_Tool, fmi_attr_id_name, 1, bufName)) - return -1; + return -1; pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor); - len = jm_vector_get_size(char)(bufName); + len = jm_vector_get_size(char)(bufName); if(pvendor ) *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1)); - if(!pvendor || !vendor) { - fmi3_xml_parse_fatal(context, "Could not allocate memory"); - return -1; - } + if(!pvendor || !vendor) { + fmi3_xml_parse_fatal(context, "Could not allocate memory"); + return -1; + } memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len); vendor[len] = 0; - context->anyToolName = vendor; - context->anyParent = jm_vector_get_last(jm_named_ptr)(&md->variablesByName).ptr; - context->useAnyHandleFlg = 1; + context->anyToolName = vendor; + context->anyParent = jm_vector_get_last(jm_named_ptr)(&md->variablesByName).ptr; + context->useAnyHandleFlg = 1; } else { /* don't do anything. might give out a warning if(data[0] != 0) */ - context->useAnyHandleFlg = 0; + context->useAnyHandleFlg = 0; return 0; } return 0; @@ -78,34 +78,34 @@ int fmi3_xml_handle_VariableTool(fmi3_xml_parser_context_t *context, const char* int fmi3_xml_handle_Tool(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { - size_t len; + size_t len; fmi3_xml_model_description_t* md = context->modelDescription; jm_vector(char)* bufName = fmi3_xml_reserve_parse_buffer(context,1,100); jm_string *pvendor; - char* vendor = 0; - + char* vendor = 0; + if(!bufName) return -1; /* */ if( fmi3_xml_set_attr_string(context, fmi3_xml_elmID_Tool, fmi_attr_id_name, 1, bufName)) - return -1; + return -1; pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor); - len = jm_vector_get_size(char)(bufName); + len = jm_vector_get_size(char)(bufName); if(pvendor ) *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1)); - if(!pvendor || !vendor) { - fmi3_xml_parse_fatal(context, "Could not allocate memory"); - return -1; - } + if(!pvendor || !vendor) { + fmi3_xml_parse_fatal(context, "Could not allocate memory"); + return -1; + } memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len); vendor[len] = 0; - context->anyToolName = vendor; - context->anyParent = 0; - context->useAnyHandleFlg = 1; + context->anyToolName = vendor; + context->anyParent = 0; + context->useAnyHandleFlg = 1; } else { /* don't do anything. might give out a warning if(data[0] != 0) */ - context->useAnyHandleFlg = 0; + context->useAnyHandleFlg = 0; return 0; } return 0; diff --git a/src/ZIP/include/FMI/fmi_zip_zip.h b/src/ZIP/include/FMI/fmi_zip_zip.h index 1d4382f8..a9d5846a 100644 --- a/src/ZIP/include/FMI/fmi_zip_zip.h +++ b/src/ZIP/include/FMI/fmi_zip_zip.h @@ -28,7 +28,7 @@ extern "C" { \addtogroup fmi_zip Interface to zlib \brief Interface to Zlib library and Minizip - to support zip and unzip of FMU modules. + to support zip and unzip of FMU modules. @{ */ diff --git a/src/ZIP/src/fmi_zip_unzip.c b/src/ZIP/src/fmi_zip_unzip.c index 1a851455..9950029c 100644 --- a/src/ZIP/src/fmi_zip_unzip.c +++ b/src/ZIP/src/fmi_zip_unzip.c @@ -30,56 +30,56 @@ static const char* module = "FMIZIP"; jm_status_enu_t fmi_zip_unzip(const char* zip_file_path, const char* output_folder, jm_callbacks* callbacks) { - /* - Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir] - -e Extract without pathname (junk paths) - -x Extract with pathname - -v list files - -l list files - -d directory to extract into - -o overwrite files without prompting - -p extract crypted file using password - */ - - /* A call to minunz may change the current directory and therefore we must change it back */ - char cd[FILENAME_MAX]; - - int argc = 6; - const char *argv[6]; - int status; - - jm_log_verbose(callbacks, module, "Unpacking FMU into %s", output_folder); - - argv[0]="miniunz"; - argv[1]="-x"; - argv[2]="-o"; - argv[3]=zip_file_path; - argv[4]="-d"; - argv[5]=output_folder; - - - /* Temporary save the current directory */ - if (jm_portability_get_current_working_directory(cd, sizeof(cd) / sizeof(char)) == jm_status_error) { - jm_log_fatal(callbacks, module, "Could not get Current Directory"); - return jm_status_error; - } - - /* Unzip */ - status = miniunz(argc, (char**)argv); - - /* Reset the current directory */ - if (jm_portability_set_current_working_directory(cd) == jm_status_error) { - jm_log_warning(callbacks, module, "Could not restore Current Directory after unpacking"); - return jm_status_warning; - } - - /* Return error status */ - if (status == 0) { - return jm_status_success; - } else { - jm_log_fatal(callbacks, "FMIZIP", "Unpacking of FMU %s into %s failed", zip_file_path, output_folder); - return jm_status_error; - } + /* + Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir] + -e Extract without pathname (junk paths) + -x Extract with pathname + -v list files + -l list files + -d directory to extract into + -o overwrite files without prompting + -p extract crypted file using password + */ + + /* A call to minunz may change the current directory and therefore we must change it back */ + char cd[FILENAME_MAX]; + + int argc = 6; + const char *argv[6]; + int status; + + jm_log_verbose(callbacks, module, "Unpacking FMU into %s", output_folder); + + argv[0]="miniunz"; + argv[1]="-x"; + argv[2]="-o"; + argv[3]=zip_file_path; + argv[4]="-d"; + argv[5]=output_folder; + + + /* Temporary save the current directory */ + if (jm_portability_get_current_working_directory(cd, sizeof(cd) / sizeof(char)) == jm_status_error) { + jm_log_fatal(callbacks, module, "Could not get Current Directory"); + return jm_status_error; + } + + /* Unzip */ + status = miniunz(argc, (char**)argv); + + /* Reset the current directory */ + if (jm_portability_set_current_working_directory(cd) == jm_status_error) { + jm_log_warning(callbacks, module, "Could not restore Current Directory after unpacking"); + return jm_status_warning; + } + + /* Return error status */ + if (status == 0) { + return jm_status_success; + } else { + jm_log_fatal(callbacks, "FMIZIP", "Unpacking of FMU %s into %s failed", zip_file_path, output_folder); + return jm_status_error; + } } #ifdef __cplusplus diff --git a/src/ZIP/src/fmi_zip_zip.c b/src/ZIP/src/fmi_zip_zip.c index 945fd331..6d4413dd 100644 --- a/src/ZIP/src/fmi_zip_zip.c +++ b/src/ZIP/src/fmi_zip_zip.c @@ -23,69 +23,69 @@ jm_status_enu_t fmi_zip_zip(const char* zip_file_path, int n_files_to_zip, const char** files_to_zip, jm_callbacks* callbacks) { - /* A call to minizip may change the current directory and therefore we must change it back */ - char cd[FILENAME_MAX]; + /* A call to minizip may change the current directory and therefore we must change it back */ + char cd[FILENAME_MAX]; #define N_BASIC_ARGS 4 - int argc; - char** argv; - int k; - int status; + int argc; + char** argv; + int k; + int status; - /* Temporary save the current directory */ - if (jm_portability_get_current_working_directory(cd, sizeof(cd) / sizeof(char)) == jm_status_error) { - jm_log(callbacks, "UNZIP", jm_log_level_error, "Could not get Current Directory"); - return jm_status_error; - } + /* Temporary save the current directory */ + if (jm_portability_get_current_working_directory(cd, sizeof(cd) / sizeof(char)) == jm_status_error) { + jm_log(callbacks, "UNZIP", jm_log_level_error, "Could not get Current Directory"); + return jm_status_error; + } - argc = N_BASIC_ARGS + n_files_to_zip; - argv = callbacks->calloc(sizeof(char*), argc); - /* Failed to allocate memory, return error */ - if (argv == NULL) { - callbacks->logger(NULL, "FMIZIP", jm_log_level_error, "Failed to allocate memory."); - return jm_status_error; - } + argc = N_BASIC_ARGS + n_files_to_zip; + argv = callbacks->calloc(sizeof(char*), argc); + /* Failed to allocate memory, return error */ + if (argv == NULL) { + callbacks->logger(NULL, "FMIZIP", jm_log_level_error, "Failed to allocate memory."); + return jm_status_error; + } - /* Input arguments to the corresponding minizip main() function call */ - /* - Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add] + /* Input arguments to the corresponding minizip main() function call */ + /* + Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add] - -o Overwrite existing file.zip - -a Append to existing file.zip - -0 Store only - -1 Compress faster - -9 Compress better + -o Overwrite existing file.zip + -a Append to existing file.zip + -0 Store only + -1 Compress faster + -9 Compress better - -j exclude path. store only the file name. - */ - argv[0]="minizip"; - argv[1]="-o"; - argv[2]="-1"; - argv[3]=(char*)zip_file_path; + -j exclude path. store only the file name. + */ + argv[0]="minizip"; + argv[1]="-o"; + argv[2]="-1"; + argv[3]=(char*)zip_file_path; - /* Append the input argument list with the files to unzip */ - jm_log_info(callbacks, "FMIZIP", "Will compress following files: \n"); - for (k = 0; k < n_files_to_zip; k++) { - jm_log_info(callbacks, "FMIZIP", "\t%s\n", files_to_zip[k]); - argv[N_BASIC_ARGS + k] = (char*)files_to_zip[k]; - } + /* Append the input argument list with the files to unzip */ + jm_log_info(callbacks, "FMIZIP", "Will compress following files: \n"); + for (k = 0; k < n_files_to_zip; k++) { + jm_log_info(callbacks, "FMIZIP", "\t%s\n", files_to_zip[k]); + argv[N_BASIC_ARGS + k] = (char*)files_to_zip[k]; + } - /* Zip */ - status = minizip(argc, (char**)argv); + /* Zip */ + status = minizip(argc, (char**)argv); - /* Free allocated memory */ - callbacks->free(argv); + /* Free allocated memory */ + callbacks->free(argv); - /* Reset the current directory */ - if (jm_portability_set_current_working_directory(cd) == jm_status_error) { - jm_log(callbacks, "UNZIP", jm_log_level_warning, "Could not change back Current Directory"); - return jm_status_warning; - } + /* Reset the current directory */ + if (jm_portability_set_current_working_directory(cd) == jm_status_error) { + jm_log(callbacks, "UNZIP", jm_log_level_warning, "Could not change back Current Directory"); + return jm_status_warning; + } - /* Return error status */ - if (status == 0) { - return jm_status_success; - } else { - return jm_status_error; - } + /* Return error status */ + if (status == 0) { + return jm_status_success; + } else { + return jm_status_error; + } }