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

Elements and Connection Command

Elements and Connection Command

Hi.

I'm trying to retrieve all the elements and connections from a model through OMC expression. I try with list(model) expression the result is ok, but i wonder is there any expression to retrieve all this information in a more structured way.

Thank you.

Re: Elements and Connection Command

Code:

getComponents(model)

gives the list of elements.

Code:

getConnectionCount(model)

and

Code:

getNthConnection(model, index)

gives the connections.

Adeel.

Re: Elements and Connection Command

Ok. Thank you for you reply. I didn't think combining getConnectionCount with getNthConnection(model, index) great idea, but with getComponnets(model) i got an issue and that is i need the components attributes, i already try with getElementsInfo(model) is usefull but got the same problem with not retrieving attributes. If you can help me with this, i really appreciate.

Thank you.

Re: Elements and Connection Command

Use getComponentModifierNames(model, "component") https://build.openmodelica.org/Document … Names.html and then getComponentModifierValue(model, modifier) https://build.openmodelica.org/Document … Value.html

Adeel.

Re: Elements and Connection Command

Ok thank you really appreciate your help was really useful.

Re: Elements and Connection Command

Hi Adeel.

Thank you for your help the last time. I wonder if you can tell me if any command return the connection type or the connector type or the interface used for the connection. Also wonder if any command return an image in byte array or any image format like .jpg to store it.

Hope you can help me with that.

Re: Elements and Connection Command

There isn't any command that returns connection or connector type. You could use getNthConnection(model, index) and then read the connector and check the type of the connector manually using is* like commands e.g., https://build.openmodelica.org/Document … Model.html

We don't have any command that returns image in any format.

What are you trying to achieve?

Adeel.

Re: Elements and Connection Command

Im trying to return the model in a more structured way, so when i execute the command getNthConnection(dcmotor, 1) for example i get ("resistor1.n","inductor1.p"). I understand that ".n" and ".p" are interfaces but how i do get that interfaces and their type and how to know the connection between them and the connection type. Is there any way to do this.

Re: Elements and Connection Command

Well there isn't any command to get this information straight away. You need to run several commands e.g.,

getComponents(dcmotor)
Gives you list of componets including resistor1 and its type i.e., Modelica.Electrical.Analog.Basic.Resistor. Now ask for its components Modelica.Electrical.Analog.Basic.Resistor

getComponents(Modelica.Electrical.Analog.Basic.Resistor)
In most cases the interface is a class component but you notice that n is not listed as class direct component so you need to read the inherited classes.

getInheritedClasses(Modelica.Electrical.Analog.Basic.Resistor)
{Modelica.Electrical.Analog.Interfaces.OnePort,Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort}

Now read the components of inherited classes,

getComponents(Modelica.Electrical.Analog.Interfaces.OnePort)
{{Modelica.SIunits.Voltage,v,"Voltage drop between the two pins (= p.v - n.v)", "public", false, false, false, false, "unspecified", "none", "unspecified",{}},{Modelica.SIunits.Current,i,"Current flowing from pin p to pin n", "public", false, false, false, false, "unspecified", "none", "unspecified",{}},{Modelica.Electrical.Analog.Interfaces.PositivePin,p,"Positive pin (potential p.v > n.v for positive voltage drop v)", "public", false, false, false, false, "unspecified", "none", "unspecified",{}},{Modelica.Electrical.Analog.Interfaces.NegativePin,n,"Negative pin", "public", false, false, false, false, "unspecified", "none", "unspecified",{}}}

n is listed in the above output (I have made it bold) and its type is Modelica.Electrical.Analog.Interfaces.NegativePin.

What do you mean by connection type?

Adeel.




Re: Elements and Connection Command

I mean they way components are connected. For example resistor can be connected in series or in parallel, is there anyway to get this type of connection.

Re: Elements and Connection Command

I don't know about it.

Adeel.

Re: Elements and Connection Command

Ok really appreciate your help. Thank you so much.

Re: Elements and Connection Command

You can find out if is a serial / parallel connection by analyzing the connections you have in a model.
So basically this is parallel:
connect(resistor1.n, a);
connect(resistor2.n, a);
connect(resistor1.p, b);
connect(resistor2.p, b);

But I guess you need to build a graph of the connections and analyze that.

Re: Elements and Connection Command

ok i see but this is really complicated considering the different connections between all the different OpenModelica components so i was wonder is there any command to get the connection between two components for example something like getConnectionType(resistor1,resistor2).

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