Ed Tate
Ed Tate

Reputation: 345

How to parameterize a Modelica Block Connector

I'd like to parameterize the min and max attributes of a block connector.

I tried this, but it is not compatible with the existing block connectors.

connector myRealInput2 "'input Real' as connector"
input Real u(min=uMax,max=uMin) "'input Real' as connector";
parameter Real uMax=1  "Maximum expected input value";
parameter Real uMin=-1 "Minimum expected input value";
end myRealInput2;

I also tried this, but could not figure out how to parameterize min and max:

connector myRealInput = input Real(min=-1,max=1) "'input Real' as connector"

Is there a way to parameterize the value used for min and max?

Upvotes: 0

Views: 54

Answers (1)

Adrian Pop
Adrian Pop

Reputation: 4231

I guess it would work like this:

package MyPack
 constant Real mmin = -100;
 constant Real mmax = 100;
 connector myRealInput = input Real(min=mmin, max=mmax);
end MyPack;

// usage
package P = MyPack(mmin = -10, mmax=10);

P.myRealInput c1; // -10, 10
MyPack.myRealInput c2; // -100, 100

Upvotes: 2

Related Questions