Opened 12 years ago

Closed 11 years ago

Last modified 5 years ago

#2131 closed defect (fixed)

Multiple FMU's not supported

Reported by: Karim Kanso <kkanso@…> Owned by: Adeel Asghar
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 by Karim Kanso <kkanso@…>, 12 years ago

Just tested on head and got same issues.

comment:2 by Karim Kanso <kkanso@…>, 12 years ago

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;

in reply to:  2 comment:3 by Karim Kanso <kkanso@…>, 12 years ago

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

comment:4 by Adeel Asghar, 12 years ago

Component: OMEditFMI
Status: newaccepted

comment:5 by Martin Sjölund, 12 years ago

Adeel: Any progress?

comment:6 by Adeel Asghar, 11 years ago

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

comment:7 by Martin Sjölund, 11 years ago

Milestone: 1.9.01.9.1

Postponed until 1.9.1

in reply to:  7 comment:8 by Adeel Asghar, 11 years ago

Replying to sjoelund.se:

Postponed until 1.9.1

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

comment:9 by Martin Sjölund, 11 years ago

Then close it and change milestone to 1.9.0

comment:10 by Adeel Asghar, 11 years ago

Milestone: 1.9.1
Resolution: fixed
Status: acceptedclosed

comment:11 by Lennart Ochel, 5 years ago

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