FMI Library: part of JModelica.org
fmi1_capi_me_test.c
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Modelon AB
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the BSD style license.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  FMILIB_License.txt file for more details.
11 
12  You should have received a copy of the FMILIB_License.txt file
13  along with this program. If not, contact Modelon AB <http://www.modelon.com>.
14 */
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <stdarg.h>
19 #include <string.h>
20 #include <errno.h>
21 
22 #include <fmilib.h>
23 #include "config_test.h"
24 /*#include <JM/jm_types.h>
25 #include <JM/jm_portability.h>
26 #include <FMI1/fmi1_types.h>
27 #include <FMI1/fmi1_functions.h>
28 #include <FMI1/fmi1_capi.h>
29 #include <JM/jm_callbacks.h> */
30 #include <FMI1/fmi1_capi.h>
32 
33 
34 #define MODEL_IDENTIFIER FMU_DUMMY_ME_MODEL_IDENTIFIER
35 
36 /* #define PRINT_VERBOSE */
37 #define INSTANCE_NAME "Test Model"
38 
39 fmi1_capi_t* fmu; /* Pointer to the C-API struct that is used in all tests */
40 
41 /* Logger function used by the C-API */
43 {
44  printf("module = %s, log level = %d: %s\n", module, log_level, message);
45 }
46 
47 /* Logger function used by the FMU internally */
48 void fmilogger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message, ...)
49 {
50  char msg[BUFFER];
51  int len;
52  va_list argp;
53  va_start(argp, message);
54  len = jm_vsnprintf(msg, BUFFER, message, argp);
55  printf("fmiStatus = %d; %s (%s): %s\n", status, instanceName, category, msg);
56  if(len > BUFFER) {
57  printf("Warning: Message was truncated");
58  }
59 }
60 
61 /* Pause and exit function. Useally called when an error occured */
62 void do_exit(int code)
63 {
64  printf("Press any key to exit\n");
65  /* getchar(); */
66  exit(code);
67 }
68 
70 
76 {
77  fmi1_callback_functions_t callBackFunctions;
79 
80  callbacks = calloc(1, sizeof(jm_callbacks));
81 
82  callbacks->malloc = malloc;
83  callbacks->calloc = calloc;
84  callbacks->realloc = realloc;
85  callbacks->free = free;
86  callbacks->logger = importlogger;
87  callbacks->context = 0;
88 
89  callBackFunctions.logger = fmilogger;
90  callBackFunctions.allocateMemory = calloc;
91  callBackFunctions.freeMemory = free;
92 
93  printf("fmi1_capi_create_dllfmu: ");
94  fmu = fmi1_capi_create_dllfmu(callbacks, FMU1_DLL_ME_PATH, MODEL_IDENTIFIER_STR, callBackFunctions, standard);
95  if (fmu == NULL) {
96  printf("An error occured while fmi1_capi_create_dllfmu was called, an error message should been printed.\n");
97  do_exit(CTEST_RETURN_FAIL);;
98  } else {
99  printf("Success\n");
100  }
101  return 0;
102 }
103 
109 {
110  jm_status_enu_t status;
111 
112  printf("fmi1_capi_load_dll: ");
113  status = fmi1_capi_load_dll(fmu);
114  if (status == jm_status_error) {
115  printf("Error in fmi1_capi_load_dll: %s\n", "fmi1_capi_get_last_error(fmu)");
116  do_exit(CTEST_RETURN_FAIL);;
117  } else {
118  printf("Success\n");
119  }
120  return 0;
121 }
122 
128 {
129  jm_status_enu_t status;
130 
131  printf("fmi1_capi_load_fcn: ");
132  status = fmi1_capi_load_fcn(fmu);
133  if (status == jm_status_error) {
134  printf("\n");
135  printf("Error in fmi1_capi_load_fcn: %s\n", "fmi1_capi_get_last_error(fmu)");
136  do_exit(CTEST_RETURN_FAIL);;
137  } else {
138  printf("Success\n");
139  }
140  return 0;
141 }
142 
148 {
149  const char* version = fmi1_capi_get_version(fmu);
150 
151  printf("fmi1_capi_get_version: ");
152  if (strcmp(FMI_VERSION, version) != 0) {
153  printf("Expected \"%s\" but returned \"%s\"", FMI_VERSION, version);
154  do_exit(CTEST_RETURN_FAIL);;
155  } else {
156  printf("Success\n");
157  }
158  return 0;
159 }
160 
166 {
167  const char* platformtype = fmi1_capi_get_model_types_platform(fmu);
168 
169  printf("fmi1_capi_get_model_types_platform: ");
170  if (strcmp(FMI_PLATFORM_TYPE, platformtype) != 0) {
171  printf("Expected \"%s\" but returned \"%s\"", FMI_PLATFORM_TYPE, platformtype);
172  do_exit(CTEST_RETURN_FAIL);;
173  } else {
174  printf("Success\n");
175  }
176  return 0;
177 }
178 
184 {
185  fmi1_boolean_t loggingOn = fmi1_true;
186 
187  if (fmi1_capi_instantiate_model(fmu, INSTANCE_NAME, FMI_GUID, loggingOn) == NULL) {
188  printf("fmi1_capi_instantiate_model: Failed\n");
189  do_exit(CTEST_RETURN_FAIL);;
190  } else {
191  printf("fmi1_capi_instantiate_model: Success\n");
192  }
193  return 0;
194 }
195 
201 {
202  fmi1_status_t status;
203  status = fmi1_capi_set_time(fmu, 0.1);
204  if (status == fmi1_status_error || status == fmi1_status_fatal) {
205  printf("fmi1_capi_set_time: Failed\n");
206  do_exit(CTEST_RETURN_FAIL);;
207  } else {
208  printf("fmi1_capi_set_time: Success\n");
209  }
210  return 0;
211 }
212 
218 {
219  fmi1_status_t status;
220  size_t k;
221  fmi1_real_t states[N_STATES];
222 
223  for (k = 0; k < N_STATES; k++) {
224  states[k] = (fmi1_real_t)(k + 1) * 12;
225  }
226 
227  status = fmi1_capi_set_continuous_states(fmu, states, N_STATES);
228  if (status == fmi1_status_error || status == fmi1_status_fatal) {
229  printf("fmi1_capi_set_continuous_states: Failed\n");
230  do_exit(CTEST_RETURN_FAIL);;
231  } else {
232  printf("fmi1_capi_set_continuous_states: Success\n");
233 #ifdef PRINT_VERBOSE
234  for (k=0; k < N_STATES; k++) {
235  printf("\t x[%d] = %f\n",k, states[k]);
236  }
237 #endif
238  }
239  return 0;
240 }
241 
247 {
248  fmi1_status_t status;
249  fmi1_boolean_t toleranceControlled;
250  fmi1_real_t relativeTolerance;
251  fmi1_event_info_t eventInfo;
252 
253  relativeTolerance = 1e-5;
254  toleranceControlled = fmi1_true;
255  status = fmi1_capi_initialize(fmu, toleranceControlled, relativeTolerance, &eventInfo);
256  if (status == fmi1_status_error || status == fmi1_status_fatal) {
257  printf("fmi1_capi_initialize: Failed\n");
258  do_exit(CTEST_RETURN_FAIL);;
259  } else {
260  printf("fmi1_capi_initialize: Success\n");
261 #ifdef PRINT_VERBOSE
262  printf("\t fmiEventInfo.iterationConverged = %s\n", eventInfo.iterationConverged ? "True" : "False");
263  printf("\t fmiEventInfo.stateValueReferencesChanged = %s\n", eventInfo.stateValueReferencesChanged ? "True" : "False");
264  printf("\t fmiEventInfo.stateValuesChanged = %s\n", eventInfo.stateValuesChanged ? "True" : "False");
265  printf("\t fmiEventInfo.terminateSimulation = %s\n", eventInfo.terminateSimulation ? "True" : "False");
266  printf("\t fmiEventInfo.upcomingTimeEvent = %s\n", eventInfo.upcomingTimeEvent ? "True" : "False");
267  printf("\t fmiEventInfo.nextEventTime = %f\n", eventInfo.nextEventTime);
268 #endif
269  }
270  return 0;
271 }
272 
278 {
279  fmi1_status_t status;
280  fmi1_boolean_t callEventUpdate;
281 
282  status = fmi1_capi_completed_integrator_step(fmu, &callEventUpdate);
283  if (status == fmi1_status_error || status == fmi1_status_fatal) {
284  printf("fmi1_capi_completed_integrator_step: Failed\n");
285  do_exit(CTEST_RETURN_FAIL);;
286  } else {
287  printf("fmi1_capi_completed_integrator_step: Success\n");
288 #ifdef PRINT_VERBOSE
289  printf("\t callEventUpdate = %s\n", callEventUpdate ? "True" : "False");
290 #endif
291  }
292  return 0;
293 }
294 
300 {
301  fmi1_status_t status;
302 
303  fmi1_real_t dstates[N_STATES];
304 
305  status = fmi1_capi_get_derivatives(fmu, dstates, N_STATES);
306  if (status == fmi1_status_error || status == fmi1_status_fatal) {
307  printf("fmi1_capi_get_derivatives: Failed\n");
308  do_exit(CTEST_RETURN_FAIL);;
309  } else {
310  printf("fmi1_capi_get_derivatives: Success\n");
311 #ifdef PRINT_VERBOSE
312  for (k=0; k < N_STATES; k++) {
313  printf("\t dx[%d] = %f\n", k, dstates[k]);
314  }
315 #endif
316  }
317  return 0;
318 }
319 
321 {
322  fmi1_status_t status;
323 
324  fmi1_real_t zerocrossing[N_EVENT_INDICATORS];
325 
326  status = fmi1_capi_get_event_indicators(fmu, zerocrossing, N_EVENT_INDICATORS);
327  if (status == fmi1_status_error || status == fmi1_status_fatal) {
328  printf("fmi1_capi_get_event_indicators: Failed\n");
329  do_exit(CTEST_RETURN_FAIL);;
330  } else {
331  printf("fmi1_capi_get_event_indicators: Success\n");
332 #ifdef PRINT_VERBOSE
333  for (k=0; k < N_EVENT_INDICATORS; k++) {
334  printf("\t nz[%d] = %f\n",k, zerocrossing[k]);
335  }
336 #endif
337  }
338  return 0;
339 }
340 
346 {
347  fmi1_status_t status;
348  fmi1_boolean_t intermediateResults = fmi1_false;
349  fmi1_event_info_t eventInfo;
350 
351  status = fmi1_capi_eventUpdate(fmu, intermediateResults, &eventInfo);
352  if (status == fmi1_status_error || status == fmi1_status_fatal) {
353  printf("fmi1_capi_eventUpdate: Failed\n");
354  do_exit(CTEST_RETURN_FAIL);;
355  } else {
356  printf("fmi1_capi_eventUpdate: Success\n");
357 #ifdef PRINT_VERBOSE
358  printf("\t fmiEventInfo.iterationConverged = %s\n", eventInfo.iterationConverged ? "True" : "False");
359  printf("\t fmiEventInfo.stateValueReferencesChanged = %s\n", eventInfo.stateValueReferencesChanged ? "True" : "False");
360  printf("\t fmiEventInfo.stateValuesChanged = %s\n", eventInfo.stateValuesChanged ? "True" : "False");
361  printf("\t fmiEventInfo.terminateSimulation = %s\n", eventInfo.terminateSimulation ? "True" : "False");
362  printf("\t fmiEventInfo.upcomingTimeEvent = %s\n", eventInfo.upcomingTimeEvent ? "True" : "False");
363  printf("\t fmiEventInfo.nextEventTime = %f\n", eventInfo.nextEventTime);
364 #endif
365  }
366  return 0;
367 }
368 
374 {
375  fmi1_status_t status;
376  fmi1_real_t states[N_STATES];
377 
378 
379  status = fmi1_capi_get_continuous_states(fmu, states, N_STATES);
380  if (status == fmi1_status_error || status == fmi1_status_fatal) {
381  printf("fmi1_capi_get_continuous_states: Failed\n");
382  do_exit(CTEST_RETURN_FAIL);;
383  } else {
384  printf("fmi1_capi_get_continuous_states: Success\n");
385 #ifdef PRINT_VERBOSE
386  for (k = 0; k < N_STATES; k++) {
387  printf("\t x[%d] = %f\n",k, states[k]);
388  }
389 #endif
390  }
391  return 0;
392 }
393 
399 {
400  fmi1_status_t status;
401 
402  fmi1_real_t states[N_STATES];
403 
404  status = fmi1_capi_get_nominal_continuous_states(fmu, states, N_STATES);
405  if (status == fmi1_status_error || status == fmi1_status_fatal) {
406  printf("fmi1_capi_get_nominal_continuous_states: Failed\n");
407  do_exit(CTEST_RETURN_FAIL);;
408  } else {
409  printf("fmi1_capi_get_nominal_continuous_states: Success\n");
410 #ifdef PRINT_VERBOSE
411  for (k = 0; k < N_STATES; k++) {
412  printf("\t x[%d] = %f\n",k, states[k]);
413  }
414 #endif
415  }
416  return 0;
417 }
418 
424 {
425  fmi1_status_t status;
426 
427  fmi1_value_reference_t vrs[N_STATES];
428 
429  status = fmi1_capi_get_state_value_references(fmu, vrs, N_STATES);
430  if (status == fmi1_status_error || status == fmi1_status_fatal) {
431  printf("fmi1_capi_get_state_value_references: Failed\n");
432  do_exit(CTEST_RETURN_FAIL);;
433  } else {
434  printf("fmi1_capi_get_state_value_references: Success\n");
435 #ifdef PRINT_VERBOSE
436  for (k=0; k < N_STATES; k++) {
437  printf("\t vrs[%u] = %u\n", k, vrs[k]);
438  }
439 #endif
440  }
441  return 0;
442 }
443 
449 {
450  fmi1_status_t status;
451  status = fmi1_capi_set_debug_logging(fmu, fmi1_true);
452  if (status == fmi1_status_error || status == fmi1_status_fatal) {
453  printf("fmi1_capi_set_debug_logging: Failed\n");
454  do_exit(CTEST_RETURN_FAIL);;
455  } else {
456  printf("fmi1_capi_set_debug_logging: Success\n");
457  }
458  return 0;
459 }
460 
466 {
467  fmi1_status_t status;
468  fmi1_value_reference_t vrs[N_STRING];
469  fmi1_string_t values[N_STRING];
470  fmi1_string_t values_ref[N_STRING];
471  size_t k;
472 
473  for (k = 0; k < N_STRING; k++) {
474  vrs[k] = (fmi1_value_reference_t)k;
475  values[k] = "hej";
476  values_ref[k] = values[k];
477  }
478 
479  /* Test fmi1_capi_set_string */
480  status = fmi1_capi_set_string(fmu, vrs, N_STRING, values);
481  if (status == fmi1_status_error || status == fmi1_status_fatal) {
482  printf("fmi1_capi_set_string: Failed\n");
483  do_exit(CTEST_RETURN_FAIL);;
484  } else {
485  printf("fmi1_capi_set_string: Success\n");
486  }
487 
488  /* Test fmi1_capi_get_string */
489  status = fmi1_capi_get_string(fmu, vrs, N_STRING, values);
490  if (status == fmi1_status_error || status == fmi1_status_fatal) {
491  printf("fmi1_capi_get_string: Failed\n");
492  do_exit(CTEST_RETURN_FAIL);;
493  } else {
494  for (k = 0; k < N_STRING; k++) {
495  if (strcmp(values_ref[k], values[k]) != 0) {
496  printf("fmi1_capi_get_string returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k], values_ref[k]);
497  do_exit(CTEST_RETURN_FAIL);;
498  }
499  }
500  printf("fmi1_capi_get_string: Success\n");
501  }
502 
503  return 0;
504 }
505 
511 {
512  fmi1_status_t status;
513  fmi1_value_reference_t vrs[N_INTEGER];
514  fmi1_integer_t values[N_INTEGER];
515  fmi1_integer_t values_ref[N_INTEGER];
516  int k;
517 
518  for (k = 0; k < N_INTEGER; k++) {
519  vrs[k] = (fmi1_value_reference_t)k;
520  values[k] = (k + 1) * 12;
521  values_ref[k] = values[k];
522  }
523 
524  /* Test fmi1_capi_set_integer */
525  status = fmi1_capi_set_integer(fmu, vrs, N_INTEGER, values);
526  if (status == fmi1_status_error || status == fmi1_status_fatal) {
527  printf("fmi1_capi_set_integer: Failed\n");
528  do_exit(CTEST_RETURN_FAIL);;
529  } else {
530  printf("fmi1_capi_set_integer: Success\n");
531  }
532 
533  /* Test fmi1_capi_get_integer */
534  status = fmi1_capi_get_integer(fmu, vrs, N_INTEGER, values);
535  if (status == fmi1_status_error || status == fmi1_status_fatal) {
536  printf("fmi1_capi_get_integer: Failed\n");
537  do_exit(CTEST_RETURN_FAIL);;
538  } else {
539  for (k = 0; k < N_INTEGER; k++) {
540  if (values_ref[k] != values[k]) {
541  printf("fmi1_capi_get_integer returned values[%d] = \"%d\" expected \"%d\"\n", k, values[k], values_ref[k]);
542  do_exit(CTEST_RETURN_FAIL);;
543  }
544  }
545  printf("fmi1_capi_get_integer: Success\n");
546  }
547 
548  return 0;
549 }
550 
556 {
557  fmi1_status_t status;
558  fmi1_value_reference_t vrs[N_BOOLEAN];
559  fmi1_boolean_t values[N_BOOLEAN];
560  fmi1_boolean_t values_ref[N_BOOLEAN];
561  size_t k;
562 
563  for (k = 0; k < N_INTEGER; k++) {
564  vrs[k] = (fmi1_value_reference_t)k;
565  values[k] = fmi1_true;
566  values_ref[k] = values[k];
567  }
568 
569  /* Test fmi1_capi_set_boolean */
570  status = fmi1_capi_set_boolean(fmu, vrs, N_BOOLEAN, values);
571  if (status == fmi1_status_error || status == fmi1_status_fatal) {
572  printf("fmi1_capi_set_boolean: Failed\n");
573  do_exit(CTEST_RETURN_FAIL);;
574  } else {
575  printf("fmi1_capi_set_boolean: Success\n");
576  }
577 
578  /* Test fmi1_capi_get_boolean */
579  status = fmi1_capi_get_boolean(fmu, vrs, N_BOOLEAN, values);
580  if (status == fmi1_status_error || status == fmi1_status_fatal) {
581  printf("fmi1_capi_get_boolean: Failed\n");
582  do_exit(CTEST_RETURN_FAIL);;
583  } else {
584  for (k = 0; k < N_BOOLEAN; k++) {
585  if (values_ref[k] != values[k]) {
586  printf("fmi1_capi_get_boolean returned values[%u] = \"%s\" expected \"%s\"\n", (unsigned)k, values[k] ? "fmiTrue" : "fmiFalse", values_ref[k] ? "fmiTrue" : "fmiFalse");
587  do_exit(CTEST_RETURN_FAIL);;
588  }
589  }
590  printf("fmi1_capi_get_boolean: Success\n");
591  }
592 
593  return 0;
594 }
595 
601 {
602  fmi1_status_t status;
603  fmi1_value_reference_t vrs[N_REAL];
604  fmi1_real_t values[N_REAL];
605  fmi1_real_t values_ref[N_REAL];
606  size_t k;
607 
608  for (k = 0; k < N_REAL; k++) {
609  vrs[k] = (fmi1_value_reference_t)(N_STATES + k);
610  values[k] = (fmi1_real_t)(k + 1) * 12;
611  values_ref[k] = values[k];
612  }
613 
614  /* Test fmi1_capi_set_real */
615  status = fmi1_capi_set_real(fmu, vrs, N_REAL, values);
616  if (status == fmi1_status_error || status == fmi1_status_fatal) {
617  printf("fmi1_capi_set_real: Failed\n");
618  do_exit(CTEST_RETURN_FAIL);;
619  } else {
620  printf("fmi1_capi_set_real: Success\n");
621  }
622 
623  /* Test fmi1_capi_get_real */
624  status = fmi1_capi_get_real(fmu, vrs, N_REAL, values);
625  if (status == fmi1_status_error || status == fmi1_status_fatal) {
626  printf("fmi1_capi_get_real: Failed\n");
627  do_exit(CTEST_RETURN_FAIL);;
628  } else {
629  for (k = 0; k < N_REAL; k++) {
630  if (values_ref[k] != values[k]) {
631  printf("%f\n",12.0);
632  printf("fmi1_capi_get_real returned values[%u] = \"%f\" expected \"%f\"\n", (unsigned)k, (double)values[k], (double)values_ref[k]);
633  do_exit(CTEST_RETURN_FAIL);;
634  }
635  }
636  printf("fmi1_capi_get_real: Success\n");
637  }
638 
639  return 0;
640 }
641 
647 {
648  fmi1_status_t status;
649 
650  status = fmi1_capi_terminate(fmu);
651  if (status == fmi1_status_error || status == fmi1_status_fatal) {
652  printf("fmi1_capi_terminate: Failed\n");
653  do_exit(CTEST_RETURN_FAIL);;
654  } else {
655  printf("fmi1_capi_terminate: Success\n");
656  }
657  return 0;
658 }
659 
665 {
666  fmi1_capi_free_model_instance(fmu);
667  printf("fmi1_capi_instantiate_model: Success\n");
668  return 0;
669 }
670 
676 {
677  fmi1_capi_free_dll(fmu);
678  printf("fmi1_capi_free_dll: Success\n");
679  return 0;
680 }
681 
687 {
688  fmi1_capi_destroy_dllfmu(fmu);
689  printf("fmi1_capi_destroy_dllfmu: Success\n");
690  return 0;
691 }
692 
698 int main(int argc, char *argv[])
699 {
700  /* Test CAPI constructor functions */
702  test_load_dll();
704 
705  /* FMI ME 1.0 functions */
710  test_initialize();
718 
725 
726  test_terminate();
728 
729  /* Test CAPI destructor functions */
730  test_free_dll();
732  free(callbacks);
733  printf("\n");
734  printf("Everything seems to be ok!\n");
735  printf("\n");
736  do_exit(CTEST_RETURN_SUCCESS);
737  return 0;
738 }
739 
740 
#define N_STATES
#define FMI_VERSION
int test_create_dllfmu()
Tests fmi1_capi_create_dllfmu.
int test_set_get_string()
Tests fmi1_capi_set_string and fmi1_capi_get_string Some values are set with fmi1_capi_set_string. The same values are retrived with fmi1_capi_get_string and tested to be the same as thoughs that were set.
int test_get_event_indicators()
jm_calloc_f calloc
Allocate zero initialized memory.
Definition: jm_callbacks.h:77
size_t jm_callbacks * c
#define N_REAL
int test_set_continuous_states()
Tests fmi1_capi_set_continuous_states.
fmi1_callback_logger_ft logger
int test_set_debug_logging()
Tests fmi1_capi_set_debug_logging.
void fmilogger(fmi1_component_t c, fmi1_string_t instanceName, fmi1_status_t status, fmi1_string_t category, fmi1_string_t message,...)
int test_completed_integrator_step()
Tests fmi1_capi_completed_integrator_step.
int test_fmi_set_time()
Tests fmi1_capi_set_time.
jm_log_level_enu_t
Log levels supported via the logger functions in jm_callbacks.
Definition: jm_types.h:51
int test_free_model_instance()
Tests fmi1_capi_free_model_instance.
fmi1_callback_allocate_memory_ft allocateMemory
#define INSTANCE_NAME
int test_fmi_get_version()
Tests fmi1_capi_get_version.
fmi1_real_t nextEventTime
fmi1_boolean_t stateValueReferencesChanged
#define N_STRING
fmi1_boolean_t upcomingTimeEvent
fmi1_status_t
jm_callbacks * callbacks
int test_get_derivatives()
Tests fmi1_capi_get_derivatives.
#define BUFFER
#define FMI_GUID
int test_get_continuous_states()
Tests fmi1_capi_get_continuous_states.
Include file to be used in client applications of the FMI Library.
jm_malloc_f malloc
Allocate non-initialized memory.
Definition: jm_callbacks.h:75
int test_get_nominal_continuous_states()
Tests fmi1_capi_get_nominal_continuous_states.
fmi1_capi_t * fmu
fmi1_boolean_t stateValuesChanged
jm_voidp context
Arbitrary context pointer passed to the logger function.
Definition: jm_callbacks.h:87
const char * jm_string
A constant string.
Definition: jm_types.h:33
#define N_INTEGER
int test_fmi_get_model_types_platform()
Tests fmi1_capi_get_model_types_platform.
#define MODEL_IDENTIFIER_STR
int main(int argc, char *argv[])
Tests the C-API for FMI 1.0 Model Exchange. The tests are performed using a test-dll. The functions are called and the values are set or returned are validated either in the test function(output functions) or inside the dll(input functions). If any error occures, the program exits.
The callbacks struct is sent to all the modules in the library.
Definition: jm_callbacks.h:73
int test_get_state_value_references()
Tests fmi1_capi_get_state_value_references.
int test_load_dll_fcn()
Tests fmi1_capi_load_fcn.
int test_event_update()
Tests fmi1_capi_eventUpdate.
int test_destroy_dllfmu()
Tests fmi1_capi_destroy_dllfmu.
fmi1_callback_free_memory_ft freeMemory
void importlogger(jm_callbacks *c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
#define N_BOOLEAN
int test_set_get_real()
Tests fmi1_capi_set_real and fmi1_capi_get_real Some values are set with fmi1_capi_set_real. The same values are retrived with fmi1_capi_get_real and tested to be the same as thoughs that were set.
int test_initialize()
Tests fmi1_capi_initialize.
int test_free_dll()
Tests fmi1_capi_free_dll.
fmi1_boolean_t iterationConverged
fmi1_fmu_kind_enu_t
FMU 1.0 kinds.
Definition: fmi1_enums.h:49
#define N_EVENT_INDICATORS
int test_set_get_boolean()
Tests fmi1_capi_set_boolean and fmi1_capi_get_boolean Some values are set with fmi1_capi_set_boolean...
jm_realloc_f realloc
Re-allocate memory.
Definition: jm_callbacks.h:79
jm_status_enu_t
Return status codes.
Definition: jm_types.h:44
void do_exit(int code)
jm_free_f free
Free-allocated memory.
Definition: jm_callbacks.h:81
fmi1_boolean_t terminateSimulation
jm_logger_f logger
Logging callback.
Definition: jm_callbacks.h:83
int test_load_dll()
Tests fmi1_capi_load_dll.
int test_set_get_integer()
Tests fmi1_capi_set_integer and fmi1_capi_get_integer Some values are set with fmi1_capi_set_integer...
int test_instantiate_model()
Tests fmi1_capi_instantiate_model.
int test_terminate()
Tests fmi1_capi_terminate.
FMILIB_EXPORT int jm_vsnprintf(char *str, size_t size, const char *fmt, va_list al)
C89 compatible implementation of C99 vsnprintf.