Skip to content
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

Implementation and demo of IntervalTest #3913

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

AHaumer
Copy link
Contributor

@AHaumer AHaumer commented Dec 13, 2021

In Simulink a block IntervalTest (i.e. checking whether the input lies within or without the specified interval) exists, in Modelica you have to implement it again and again using Modelica.Blocks.Logical.{And, Or, GreaterThreshold, GreaterEqualThreshold, LessTreshold, LessEqualThreshold, Greater, GreaterEqual, Less, LessEqual}.
I'm pretty sure that this is a block used in many applications, here is a convenient implementation of this functionality.

@AHaumer AHaumer added enhancement New feature or enhancement L: Blocks Issue addresses Modelica.Blocks labels Dec 13, 2021
@AHaumer AHaumer self-assigned this Dec 13, 2021
@AHaumer AHaumer requested a review from dietmarw December 13, 2021 16:30
@beutlich beutlich removed their request for review December 13, 2021 21:35
Copy link
Contributor

@christiankral christiankral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK from my side.

@@ -0,0 +1,3 @@
time
and1.y
intervallTest.y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
intervallTest.y
intervalTest.y

connect(upperLimitInternal, upperLimit);
connect(lowerLimitInternal, lowerLimit);
end if;
assert(upperLimitInternal>lowerLimitInternal, "Erroneous interval limits");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this assertion is really needed, I would set this as a warning only - insted of hard termination of the simulation. Optionally, a parameter of type "AssertionLevel" could be add to give the user an opportunity to decide - but this approach is not used elsewhere in MSL so maybe not that good idea.

Comment on lines +379 to +384
Modelica.Blocks.Interfaces.RealInput lowerLimitInternal annotation (Placement(
transformation(extent={{-94,-84},{-86,-76}}), iconTransformation(extent={
{-94,56},{-86,64}})));
Modelica.Blocks.Interfaces.RealInput upperLimitInternal annotation (Placement(
transformation(extent={{-94,76},{-86,84}}), iconTransformation(extent={{-94,76},
{-86,84}})));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could be considered good style to at least not have an iconTransformation on a protected component? Maybe remove the entire Placement annotation?

@dietmarw dietmarw removed their request for review January 18, 2022 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement L: Blocks Issue addresses Modelica.Blocks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants