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

API to retrieve getExtendsModifierNames

API to retrieve getExtendsModifierNames

I would like to retrieve the modifications associated with a class extends redeclaration mechanism.

I used as test model the one from GitHub (https://github.com/OpenModelica/OpenMod … _calls.mo)

and I performed the call

getExtendsModifierNames(D2,B2)

as documented in this test case (https://github.com/OpenModelica/OpenMod … param.mos)

but the result was "Error" and the getErrorString() call returned an empty string. Is this normal?

Re: API to retrieve getExtendsModifierNames

Hi,

It works OK for me:

Code:


adrpo@ida-liu050 /f/dev/testing/scale
$ ../../OpenModelica/build/bin/omc iac.mos
true
""
{a.x, f}
""
= 1
""
(x = 2 * y)
""

iac.mos

Code:


loadFile("iac.mo"); getErrorString();
getExtendsModifierNames(D2,B2); getErrorString();
getExtendsModifierValue(D2,B2,f); getErrorString();
getExtendsModifierValue(D2,B2,a); getErrorString();

iac.mo

Code:


model Resistor
    Real r=1;
end Resistor;

model K
  extends Resistor(R.start=5);
end K;

model K2
  extends  Resistor(R(start=5,fixed=true)=2);
end K2;

model K3
  extends  Resistor(R(start=5,fixed=true));
end K3;

model K4
  extends Resistor(x(start=2,fixed=true)=1);
end K4;

model K5
  extends Resistor(x.fixed=true,x.start=2,x=1);
end K5;

model K6
  extends Resistor(final x.fixed=true,x.start=2,final x=1);
end K6;

model M
  Real x(start=2)=1;
end M;

model M2
  Real x=1;
end M2;

model M3
  Real x(start=2)=1;
end M3;

model M4
  Real x;
end M4;

model M5
  Real x;
end M5;


model M6
  Real x(start=1,fixed=false);
end M6;

model M7
  A a1(x.fixed=true);
end M7;

package Modelica
  package Blocks
    package Interfaces
      connector BooleanSignal = Boolean "Boolean port (both input/output possible)";
      connector BooleanInput =input  BooleanSignal "'input Boolean' as connector" annotation (defaultComponentName="u",Icon(coordinateSystem(extent={{-100.,-100.},{100.,100.}}),graphics={Polygon(points={{-100.,100.},{100.,0.},{-100.,-100.},{-100.,100.}},lineColor={255,0,255},fillColor={255,0,255},fillPattern=FillPattern.Solid)}),Diagram(coordinateSystem(extent={{-100.,-100.},{100.,100.}}),graphics={Polygon(points={{0.,50.},{100.,0.},{0.,-50.},{0.,50.}},lineColor={255,0,255},fillColor={255,0,255},fillPattern=FillPattern.Solid),Text(extent={{-140.,120.},{100.,60.}},textString="%name",fillColor={255,0,255})}));
  end  Interfaces;
end Blocks;
end Modelica;


model Q
    Real x=1;
end Q;


type T1 = Real;
type T2 = Real[4];

type Resistance
  extends Real(unit="ohm");
end Resistance;

package Types
  type T2 = T1(unit="foo");
  type T1 = Integer;
end Types;

model A
  parameter Integer p1=35;
  parameter Integer p2=32,p4;
end A;

model B
  A a1;
  A a2;
end B;

model C
  B b1(a1(p1=0,p2=0),a2.p2=3);
end C;

model A2
  parameter Real x=1;
  Real y=11;
end A2;

model B2
  parameter Real f=1;
  A2 a(x=3);
end B2;

model C2
  Real m = 1;
  parameter Real n=2;
end C2;

model D2
  Real y = 2;
  extends B2(a(x=2*y),f=1);
  extends C2(m=1,n=2);
end D2;

model E
  A a(p1=1,p2=2);
end E;

How did you tested?

Re: API to retrieve getExtendsModifierNames

Thanks! Actually, I think that I asked the wrong question. Sorry!

Can I use the OMC Scritping API to parse redeclare statements in an extends clause, as shown below?

Code:


model MyModel
      extends MyClass(redeclare MySubComponentClass1 specificComponent1, redeclare MySubComponentClass2 specificComponent2);
end MyModel;

Re: API to retrieve getExtendsModifierNames


Ok, for that we don't have an API yet. We don't handle any redeclares in the query API.

Re: API to retrieve getExtendsModifierNames

Thanks for clarifying this!

Re: API to retrieve getExtendsModifierNames

Hi,

I now opened a ticket about this:
https://trac.openmodelica.org/OpenModelica/ticket/3696
we should add an API for that as we need it also for OMEdit.

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