-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Demonstration of units on signals and use of VehicleInterfaces #40
base: main
Are you sure you want to change the base?
Conversation
Modelica.Blocks.Interfaces.RealOutput y annotation( | ||
Placement(visible = true, transformation(origin = {-48, 14}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-48, 14}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dietmarw - How would you recommend combining an interface like Modelica.Blocks.Interfaces.RealOutput
with a type like Modelica.Units.SI.AbsolutePressure
to specify quantity
, unit
, displayUnit
, min
, nominal
, etc. by just referring to the type identifier Modelica.Units.SI.AbsolutePressure
without copying all parameters into the instantiation like this:
Modelica.Blocks.Interfaces.RealOutput y(quantity="Pressure", unit="Pa", displayUnit="bar", min=0.0, nominal=1e5);
Copying the other way is not much better:
output Modelica.Units.SI.AbsolutePressure y annotation(...);
Then all the graphical annotations from the interface Modelica.Blocks.Interfaces.RealOutput
must be copied.
I'm seeking a way to combine the interface identifier with the type identifier. I would expect something like this should work, but it doesn't seem to compile (Syntax Error):
Modelica.Blocks.Interfaces.RealOutput y(type=Modelica.Units.SI.AbsolutePressure);
I use many combinations of interfaces and types, and want to combine existing declarations in an efficient way to avoid code duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kvid Ideally having to set the unit of an output should not be necessary and the tool should be able to deduce the type based on the (typed) variables and parameters involved in calculating the output's signal. Now that is the ideal solution which of course also needs support from the tool. OMEdit will check for unit conflicts (when you press "check model") but will (as of now) not go as far as propagate units so that for example plots show the units. For these cases you need to specify the unit manually but you do not really need to go as far as also specifying quantity
and nominal
.
So for now, the recommended way is
Modelica.Blocks.Interfaces.RealOutput y(unit="Pa", displayUnit="bar");
See also https://github.com/modelica/ModelicaStandardLibrary/pull/2197/files as an example how the MSL did it.
Just very simple concepts. Most likely not worth merging.