modelicaopenmodelicagraphical-interaction

Modelica GUI representation of imported package?


I would like to see a clear representation of imported package in the GUI for a component. In OpenModelica you can select a component icon and right click for Parameters. Here you get two fields:

Path - describes from where the component is taken

Parameters - if the package has a redeclared package it is shown here

I think it would be good to in both fields show from where the import is made from. Today you only see that in the field Path and not in the field Parameters.

The small example below illustrate the question with the package DEMO_v91 and the two different model-files D91_1 and D91_3 that only differs how import is made. Note the convenience in file D91_3 when we want to re-use this file for another package, say DEMO_v92. You only change one line of code, instead of five as in D91_1.

package DEMO_v91
   package A
       constant Real a=1;
       constant Real b=2;
       constant Real c=3;
   end A;   
   model M1
       replaceable package A = DEMO_v91.A;
       Real x, y, z;
   equation
       x = A.a;
       y = A.b;
       z = A.c;
       annotation(Diagram,Icon(graphics = {Rectangle(origin = {1, 0}, extent = {{-39, 40}, {39, -40}})}));
   end M1;
   model M2
       replaceable package A = DEMO_v91.A;
       Real x, y, z;
   equation
       x = 2*A.a;
       y = 2*A.b;
       z = 2*A.c;
       annotation(Diagram,Icon(graphics = {Rectangle(extent = {{-38, 40}, {38, -40}})}));
   end M2;
end DEMO_v91;

The model file D91_1

model D91_1
  DEMO_v91.M1 m1(redeclare package A = DEMO_v91.A) 
  annotation(Placement(transformation(origin = {-76, -4}, extent = {{-10, -10}, {10, 10}})));
  DEMO_v91.M2 m2(redeclare package A = DEMO_v91.A) 
  annotation(Placement(transformation(origin = {40, -4}, extent = {{-10, -10}, {10, 10}})));
equation
end D91_1;

The model file D91_3 with more convenient import

model D91_3
   import DEMO_v91.*;
   M1 m1(redeclare package A = A) 
   annotation(Placement(transformation(origin = {-76, -4}, extent = {{-10, -10}, {10, 10}})));
   M2 m2(redeclare package A = A) 
   annotation(Placement(transformation(origin = {40, -4}, extent = {{-10, -10}, {10, 10}})));
equation
end D91_3;

Screenshot that compare the Parameter interface in OpenModelica for the two implementations D91_1 and D91_3

enter image description here

Why can not the field Parameters for D91_3 contain the full path as for D91_1?

(Note that in general M1 and M2 may be taken from another package than from where the package A is taken. )


Solution

  • Seems like a choice in OpenModelica. If you modify Demo_v91 as follows:

    replaceable package A = DEMO_v91.A annotation(choicesAllMatching=true);
    

    Which is a standard Modelica annotation for allowing more convenient choices, then Dymola will at least show DEMO_v91.A as a tool-tip for the input fields in both cases (and shorten the choices).