2 Copyright (C) 2012 Modelon AB
\r
4 This program is free software: you can redistribute it and/or modify
\r
5 it under the terms of the BSD style license.
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
10 FMILIB_License.txt file for more details.
\r
12 You should have received a copy of the FMILIB_License.txt file
\r
13 along with this program. If not, contact Modelon AB <http://www.modelon.com>.
\r
20 #include <config_test.h>
\r
22 #include <JM/jm_portability.h>
\r
26 /* Logger function used by the FMU internally */
\r
27 static void fmi1logger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...)
\r
32 va_start(argp, message);
\r
33 len = jm_vsnprintf(msg, BUFFER, message, argp);
\r
34 printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg);
\r
38 int fmi1_test(fmi_import_context_t* context, const char* dirPath)
\r
40 fmi1_callback_functions_t callBackFunctions;
\r
41 const char* modelIdentifier;
\r
42 const char* modelName;
\r
44 jm_status_enu_t status;
\r
46 fmi1_import_t* fmu;
\r
48 callBackFunctions.logger = fmi1logger;
\r
49 callBackFunctions.allocateMemory = calloc;
\r
50 callBackFunctions.freeMemory = free;
\r
52 fmu = fmi1_import_parse_xml(context, dirPath);
\r
55 printf("Error parsing XML, exiting\n");
\r
56 return (CTEST_RETURN_FAIL);
\r
58 modelIdentifier = fmi1_import_get_model_identifier(fmu);
\r
59 modelName = fmi1_import_get_model_name(fmu);
\r
60 GUID = fmi1_import_get_GUID(fmu);
\r
62 printf("Model name: %s\n", modelName);
\r
63 printf("Model identifier: %s\n", modelIdentifier);
\r
64 printf("Model GUID: %s\n", GUID);
\r
66 status = fmi1_import_create_dllfmu(fmu, callBackFunctions, 0);
\r
67 if (status == jm_status_error) {
\r
68 printf("Could not create the DLL loading mechanism(C-API).\n");
\r
69 return(CTEST_RETURN_FAIL);
\r
72 printf("Version returned from FMU: %s\n", fmi1_import_get_version(fmu));
\r
74 fmi1_import_destroy_dllfmu(fmu);
\r
76 fmi1_import_free(fmu);
\r
78 return (CTEST_RETURN_SUCCESS);
\r