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 to create graphical custom components

How to create graphical custom components

I face difficulties to find a tutorial or a method  to create graphical custom components.
For example, I have a basic code below that works, but I would like to see and connect the components in the graphical interface. 
I know that I should use the "annotation" statements , but how to do it ?
Thanks by advance for any help on this topic.


**************************************************
package Essai3

type Voltage=Real(unit="V");
type Current=Real(unit="A");

connector Pin
  Voltage v;
  flow Current i;
end Pin;

partial model TwoPin
Pin p,n;
Voltage v "Différence de potentiel";
Current i "Intensité";
equation
  v=p.v-n.v;
  p.i+n.i=0;
  i=p.i;
end TwoPin;

model TensionSinusoidale "source tension sinusoidale"
extends TwoPin;
parameter Real Ac (start=10);
parameter Real f (start=10);
          Real MonPi=3.1416;
equation
  v=Ac*sin(2*MonPi*f*time);
end TensionSinusoidale;

model Resistor
extends TwoPin;
parameter Real R(start=10);
equation
  v=R*i;
end Resistor;


model Ground "masse idéale"
Pin P;
equation
P.v=0.0;
end Ground;


  model Circuit
    // Déclaration des composants
    TensionSinusoidale Alim(Ac = 200, f = 50);
    Resistor R1(R = 2);
    Ground G;
  equation
// Description des connexions
    connect(Alim.p, R1.p);
    connect(Alim.n, G.P);
    connect(R1.n, G.P);
  end Circuit;

end Essai3;


Re: How to create graphical custom components

Objects in Modelica have two graphical Views: Icon and Diagram View. To create a custom component, there are quite a few steps involved from making a graphical sketchg/icon and then connecting variables using connectors(if needed). I suggest a good place to start would be ModelicaByExample, where the Graphiical annotations have been explained.

ModelicaByExample

ModelicaByExample - Graphical Annotations

Re: How to create graphical custom components

Many thanks.I'm going to read this carefully
Anyway, it seems to me a little bit complex and quite prehistoric to build icons line by line with text code ....
I imagined that it would be easier with some intergated easy tools ....

Re: How to create graphical custom components

It's ok now. I've read the book and have created my very first 100% graphical custom circuit model. This kind of "hello world" finally works. Thanks again.

Re: How to create graphical custom components

Thats great. Cheers!

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