Opened 11 years ago

Closed 11 years ago

Last modified 4 years ago

#2131 closed defect (fixed)

Multiple FMU's not supported

Reported by: Karim Kanso <kkanso@…> Owned by: adeas31
Priority: normal Milestone: 1.9.0
Component: FMI Version: trunk
Keywords: Cc:

Description

When simulating using OMEdit, it is not possible to simulate with more than one imported FMU.

It is not clear what the problem is, no error/warning/info is displayed in the information window, nothing is output to stderr.

Symptom: once simulation is started, and compilation of the models are complete, then simulation stops at 0%. The results (.mat) structure is empty.

Change History (11)

comment:1 Changed 11 years ago by Karim Kanso <kkanso@…>

Just tested on head and got same issues.

comment:2 follow-up: Changed 11 years ago by Karim Kanso <kkanso@…>

After much debugging, I've tracked down the problem to an issue with the FMI handling in the SimulationRuntime environment.

It appears that a few functions in the files:
SimulationRuntime/c/fmi/FMI1ModelExchange.c
SimulationRuntime/c/fmi/FMI1Common.c

Use a static variable to ensure that they are evaluated only once, this however causes a problem when more than one FMU is active in the same simulation.

The first change below is not optimal, it would be best to use an if statement with the guard:
!((fmi1_import_t*)fmi)->capi->c
But I did not successfully change the import directives to allow for this change to be accepted.

Also the logger was tweaked to print out the component id, which was of use when there was more than one FMU in the project.

See below for output of svn diff:

Index: SimulationRuntime/c/fmi/FMI1ModelExchange.c
===================================================================
--- SimulationRuntime/c/fmi/FMI1ModelExchange.c	(revision 15723)
+++ SimulationRuntime/c/fmi/FMI1ModelExchange.c	(working copy)
@@ -41,12 +41,12 @@
  */
 double fmi1InstantiateModel_OMC(void* fmi, char* instanceName, int debugLogging)
 {
-  static int init = 0;
-  if (!init) {
-    init = 1;
+  /* static int init = 0; */
+  /* if (!init) { */
+  /*   init = 1; */
     fmi1_import_instantiate_model((fmi1_import_t*)fmi, instanceName);
     fmi1_import_set_debug_logging((fmi1_import_t*)fmi, debugLogging);
-  }
+  /* } */
   return 1;
 }
 
@@ -66,9 +66,7 @@
  */
 void* fmi1Initialize_OMC(void* fmi, void* inEventInfo)
 {
-  static int init = 0;
-  if (!init) {
-    init = 1;
+  if (!inEventInfo) {
     fmi1_boolean_t toleranceControlled = fmi1_true;
     fmi1_real_t relativeTolerance = 0.001;
     fmi1_event_info_t* eventInfo = malloc(sizeof(fmi1_event_info_t));
Index: SimulationRuntime/c/fmi/FMI1Common.c
===================================================================
--- SimulationRuntime/c/fmi/FMI1Common.c	(revision 15723)
+++ SimulationRuntime/c/fmi/FMI1Common.c	(working copy)
@@ -51,7 +51,7 @@
   va_list argp;
   va_start(argp, message);
   vsprintf(msg, message, argp);
-  printf("fmiStatus = %d;  %s (%s): %s\n", status, instanceName, category, msg);
+  printf("<%d> fmiStatus = %d;  %s (%s): %s\n",c , status, instanceName, category, msg);
 }
 
 /*
@@ -93,7 +93,7 @@
 {
   // FMI callback functions
   static int init = 0;
-  fmi1_callback_functions_t callback_functions;
+  static fmi1_callback_functions_t callback_functions;
   if (!init) {
     init = 1;
     callback_functions.logger = fmilogger;

comment:3 in reply to: ↑ 2 Changed 11 years ago by Karim Kanso <kkanso@…>

Also, this bug should be reclassified from OMEdit to something more appropriate.

comment:4 Changed 11 years ago by adeas31

  • Component changed from OMEdit to FMI
  • Status changed from new to accepted

comment:5 Changed 11 years ago by sjoelund.se

Adeel: Any progress?

comment:6 Changed 11 years ago by adeas31

Fixed in r16576.
I will keep the ticket open. Perhaps you can test and if there are any errors then report them.

comment:7 follow-up: Changed 11 years ago by sjoelund.se

  • Milestone changed from 1.9.0 to 1.9.1

Postponed until 1.9.1

comment:8 in reply to: ↑ 7 Changed 11 years ago by adeas31

Replying to sjoelund.se:

Postponed until 1.9.1

I think we should close this ticket. Its fixed a long time ago.

comment:9 Changed 11 years ago by sjoelund.se

Then close it and change milestone to 1.9.0

comment:10 Changed 11 years ago by adeas31

  • Milestone 1.9.1 deleted
  • Resolution set to fixed
  • Status changed from accepted to closed

comment:11 Changed 4 years ago by lochel

  • Milestone set to 1.9.0
Note: See TracTickets for help on using tickets.