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

How do I add a graphical input in my model?

How do I add a graphical input in my model?

Hi!

I trying to build my own library in OpenModelica. It going to be a hydraulic library. Right know I have build a tank, but no signal cannot connect to it as you see.


https://www.openmodelica.org/images/agorapro/attachments/5412/mini_Tank-symbol.png


My code for this tank is:

Code:

model Tank

  parameter EasyHydraulics.Setup.PressureUnit P;
  EasyHydraulics.Setup.Connecter C;
 
  annotation(
    Diagram(graphics = {Rectangle(origin = {-53, -12}, fillColor = {0, 0, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-7, 32}, {13, -48}}), Rectangle(origin = {0, -49}, fillColor = {0, 8, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-40, 9}, {40, -11}}), Rectangle(origin = {50, -21}, fillColor = {8, 15, 251}, fillPattern = FillPattern.VerticalCylinder, extent = {{10, -39}, {-10, 41}}), Rectangle(origin = {0, 20}, fillColor = {1, 6, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-10, 40}, {10, -22}})}, coordinateSystem(initialScale = 0.1)),
    Icon(graphics = {Rectangle(origin = {-53, -12}, fillColor = {0, 0, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-7, 32}, {13, -48}}), Rectangle(origin = {0, -49}, fillColor = {0, 8, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-40, 9}, {40, -11}}), Rectangle(origin = {50, -21}, fillColor = {8, 15, 251}, fillPattern = FillPattern.VerticalCylinder, extent = {{10, -39}, {-10, 41}}), Rectangle(origin = {0, 20}, fillColor = {1, 6, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-10, 40}, {10, -22}})}, coordinateSystem(initialScale = 0.1)));
end Tank;

If I insert this code

Code:

Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a

    annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));

So it would look like this:

Code:

model Tank

  parameter EasyHydraulics.Setup.PressureUnit P;
  EasyHydraulics.Setup.Connecter C;

  Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a
    annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
 
  annotation(
    Diagram(graphics = {Rectangle(origin = {-53, -12}, fillColor = {0, 0, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-7, 32}, {13, -48}}), Rectangle(origin = {0, -49}, fillColor = {0, 8, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-40, 9}, {40, -11}}), Rectangle(origin = {50, -21}, fillColor = {8, 15, 251}, fillPattern = FillPattern.VerticalCylinder, extent = {{10, -39}, {-10, 41}}), Rectangle(origin = {0, 20}, fillColor = {1, 6, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-10, 40}, {10, -22}})}, coordinateSystem(initialScale = 0.1)),
    Icon(graphics = {Rectangle(origin = {-53, -12}, fillColor = {0, 0, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-7, 32}, {13, -48}}), Rectangle(origin = {0, -49}, fillColor = {0, 8, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-40, 9}, {40, -11}}), Rectangle(origin = {50, -21}, fillColor = {8, 15, 251}, fillPattern = FillPattern.VerticalCylinder, extent = {{10, -39}, {-10, 41}}), Rectangle(origin = {0, 20}, fillColor = {1, 6, 255}, fillPattern = FillPattern.VerticalCylinder, extent = {{-10, 40}, {10, -22}})}, coordinateSystem(initialScale = 0.1)));
end Tank;

The tank will look like this then:


https://www.openmodelica.org/images/agorapro/attachments/5412/mini_Tank-symbol-with-input.png

So my question is: How do I insert a graphical input so it can be connected to a variable?

I have attached my library.
EasyHydraulics.mo

The reason why I'm writing a library is to learn both hydraulics and programming with modelica.

Edited by: Volvo742 - Nov-12-17 19:43:55

Re: How do I add a graphical input in my model?

Hi!

your Connector in the tank model is missing an annotation. If you drag the connector Connecter from the library into the tank model then you can use it as desired.
You can add the input from the connector to a variable like this:

Code:


  EasyHydraulics.Setup.Connecter C
  Modelica.SIunits.Pressure P;
equation
  P = C.P;

Re: How do I add a graphical input in my model?

Leonard wrote:


Hi!

your Connector in the tank model is missing an annotation. If you drag the connector Connecter from the library into the tank model then you can use it as desired.
You can add the input from the connector to a variable like this:

Code:


  EasyHydraulics.Setup.Connecter C
  Modelica.SIunits.Pressure P;
equation
  P = C.P;

Thanks! It working now.

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