Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Usage of the extends command

Usage of the extends command

Hello

I'm creating a custom library in OMEdit 1.9.0 and I want to have a component wherein I can enter all my parameters which will be used throughout other components i.e The parameters would be globally accessible. I also want to avoid the usage of connectors as it would make the final model very messy and would require a lot of connections.
I am currently trying to use the extends command which seems to work fine but it also inherits the Icon profile of the component and overrides it over the icons of the other components. Is there any way I can avoid this ? Also is there a better way of having globally accessible variables which can be entered in through a component ?

I unfortunately cannot attach the original code but I have made a small similar example of the same. Hope it explains the problem well enough.

Thank You
Pratyush

This is Package which has all the components -

Code:


package Package

  model a
  annotation(Icon(graphics = {Rectangle(rotation = 0, lineColor = {0,0,255}, fillColor = {0,0,0}, pattern = LinePattern.Solid, fillPattern = FillPattern.None, lineThickness = 0.25, extent = {{-100,50},{100,-50}})}));
  parameter Real x(start = 4);
  parameter Real x1(start = 41);
  end a;

  model b
  annotation(Icon(graphics = {Rectangle(rotation = 0, lineColor = {0,0,255}, fillColor = {0,0,0}, pattern = LinePattern.Solid, fillPattern = FillPattern.None, lineThickness = 0.25, extent = {{-50,100},{50,-100}})}));
  parameter Real p(start = 15);
  Real q;
  Real r;
  extends Package.a;
  equation
    q = x * x1;
    r = q * p;
  end b;
 
end Package;

This is the model which contains the components from the Package

Code:



model Test
  Package.a a1 annotation(Placement(visible = true, transformation(origin = {-20,60}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Package.b b1 annotation(Placement(visible = true, transformation(origin = {-20,15}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  annotation(experiment(StartTime = 0.0, StopTime = 4, Tolerance = 0.000001));
end Test;

Re: Usage of the extends command

The standard library (MultiBody and World object) uses inner and outer components for the purpose of globally accessible variables.

Re: Usage of the extends command

Yup, I got it !
Thanks a lot !!

Pratyush

There are 0 guests and 0 other users also viewing this topic
You are here: