Modelica - Icon Creation

I want to create an icon for a model that integrates two components from the Modelica standard library. The two components are Modelica.Blocks.Sources.Sine and Modelica.Electrical.Analog.Sources.SignalVoltage. I connected these two components so that the code looks like this:

model test
 Modelica.Blocks.Sources.Sine sine1(freqHz = 5, amplitude = 1, offset = 10) annotation(Placement(visible = true, transformation(origin = {-51.0325,-0.884933}, extent = {{-12,-12},{12,12}}, rotation = 0)));
 Modelica.Electrical.Analog.Sources.SignalVoltage signalvoltage1 annotation(Placement(visible = true, transformation(origin = {-4.12979,-1.17994}, extent = {{12,-12},{-12,12}}, rotation = 90)));
equation
 connect(sine1.y,signalvoltage1.v) annotation(Line(points = {{-37.8325,-0.884933},{-12.9794,-0.884933},{-12.9794,-1.17994},{-12.5298,-1.17994}}));
end test;

      

Annotations are done automatically using OMEdit.

Now I want to achieve the following: I want to create an icon that

  • contains the signalvoltage1 pins
  • which gives double access to sine1 properties.

I know about annotation (Icon (...)) and annotation (Placement (...)), but I don't know how to cast signalvoltage1.p and signalvoltage1.n to icon layer. And I don't know how to access the properties of sine1 by double clicking on, for example, a rectangle that I can easily draw with OMEdit.

Thanks in advance.

+3


source to share


1 answer


Now I want to achieve the following: I want to create an icon that

contains signal voltage1 contacts which gives access to the properties of sine1 by double clicking.

OK for pins: Typically a graphical editor should give you the ability to automatically create a connector when you root from an existing connector to an empty spot in the diagram. However OMEdit is wrong (yet?). Therefore, you need to drag the appropriate connectors from MSL into your model diagram. In your case, Modelica.Electrical.Analog.Interfaces.NegativePin

and Modelica.Electrical.Analog.Interfaces.PositivePin

, and then connect them appropriately. The type connector component will (should) automatically appear on the AND diagram layer so that it can be connected "outside".



With regard to access. you create a new parameter at the level of your model and allow components within your new model to use those parameters. Probably best explained by taking your example from above:

model Test
  parameter Real myfreqHz = 5 "Frequency of the sinewave";
  parameter Real myamplitude = 1 "Amplitude of the sinewave";    
  parameter Real myoffset = 1 "Offset of the sinewave";
  Modelica.Blocks.Sources.Sine sine1(freqHz = myfreqHz, 
                               amplitude = myamplitude, offset = myoffset);
  Modelica.Electrical.Analog.Sources.SignalVoltage signalvoltage1;
equation
...
end Test;

      

+4


source







All Articles