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

update of unit tests #102

Merged
merged 11 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions resources/modelica_libraries/CRML.mo
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ into your model.
ETL.Connectors.WhileInput tl "Master time period" annotation(
Placement(transformation(extent = {{-10, 90}, {10, 110}})));
ETL.Connectors.RealInput duration "Duration" annotation(
Placement(transformation(extent = {{-120, -90}, {-100, -70}}), visible = not periods.durationSpecified));
Placement(transformation(extent = {{-120, -90}, {-100, -70}}), visible = periods.durationSpecified));
public
ETL.Connectors.TimeLocatorOutput[N] y(timePeriod(each fixed = true, each start = false)) "Vector of time periods" annotation(
Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = -90, origin = {0, -100}), iconTransformation(extent = {{-10, -10}, {10, 10}}, rotation = -90, origin = {0, -100})));
Expand Down Expand Up @@ -5038,12 +5038,13 @@ which is only valid in the rotor-fixed coordinate system.
// fillColor={28,108,200},
// fillPattern=FillPattern.Solid,
// textString=boxName),
connect(evaluateOver.tl, tl) annotation(
Line(points = {{0, 10}, {0, 100}}, color = {0, 0, 255}));
connect(evaluateOver.u, boolean4Replicator.y) annotation(
Line(points = {{-11, 0}, {-39, 0}}, color = {162, 29, 33}));
connect(evaluateOver.y, and4.u) annotation(
Line(points = {{11, 0}, {39, 0}}, color = {162, 29, 33}));
connect(
evaluateOver.tl, tl) annotation (
Line(points = {{0, 10}, {0, 100}}, color = {0, 0, 255}, thickness = 0.5));
annotation(
Icon(coordinateSystem(preserveAspectRatio = false), graphics = {Rectangle(extent = {{-100, 100}, {100, -100}}, fillColor = {162, 29, 33}, lineThickness = 5, fillPattern = FillPattern.Solid, borderPattern = BorderPattern.Raised, lineColor = {0, 0, 0}), Rectangle(extent = {{-78, 80}, {82, -80}}, lineColor = {175, 175, 175}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid), Text(extent = {{-70, 72}, {70, 44}}, lineColor = {28, 108, 200}, textString = "check"), Text(extent = {{-70, 18}, {70, -10}}, lineColor = {28, 108, 200}, textString = "over")}),
Diagram(coordinateSystem(preserveAspectRatio = false)),
Expand Down Expand Up @@ -8987,7 +8988,6 @@ unvailability should be less of 1 hour in a sliding time period of one month

record CRMLClock
//constant Integer buffer_size=50; // number of events that can be logged

CRML.ETL.Types.Boolean4 b( start= CRML.ETL.Types.Boolean4.false4);

Real ticks[50](each start = -1, each fixed = true);
Expand Down
31 changes: 10 additions & 21 deletions resources/modelica_libraries/CRML_test/ETL/CheckOver/CheckOver.mo
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
within CRML_test.ETL.CheckOver;
partial block CheckOver

protected
parameter Integer N=CRML.ETL.Types.nMaxOverlap;

public
Utilities.Boolean4Connector phi1 "Boolean4 condition" annotation (Placement(
transformation(extent={{-120,-10},{-100,10}}), iconTransformation(
extent={{-120,-10},{-100,10}})));
Expand All @@ -13,29 +8,23 @@ public
110}})));
CRML.ETL.Connectors.Boolean4Output b_check_over
annotation (Placement(transformation(extent={{100,-10},{120,10}})));
CRML.Blocks.Logical4.And4_n and4(N=N)
annotation (Placement(transformation(extent={{40,-10},{60,10}})));
CRML.Blocks.Routing.Boolean4Replicator boolean4Replicator(nout=N)
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
CRML.ETL.Requirements.EvaluateOver[N] evaluateOver
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
CRML.ETL.Requirements.CheckOver checkOver annotation(
Placement(transformation(extent = {{-10, -10}, {10, 10}})));
protected
parameter Integer N=CRML.ETL.Types.nMaxOverlap;
equation
connect(phi1, boolean4Replicator.u)
annotation (Line(points={{-110,0},{-62,0}}, color={162,29,33}));
connect(and4.y, b_check_over)
annotation (Line(points={{61,0},{110,0}}, color={162,29,33}));
// Text(
// extent={{-74,32},{74,-36}},
// lineColor={0,0,0},
// fillColor={28,108,200},
// fillPattern=FillPattern.Solid,
// textString=boxName),
connect(evaluateOver.tl, P1)
annotation (Line(points={{0,10},{0,100}}, color={0,0,255}));
connect(evaluateOver.u, boolean4Replicator.y)
annotation (Line(points={{-11,0},{-39,0}}, color={162,29,33}));
connect(evaluateOver.y, and4.u)
annotation (Line(points={{11,0},{39,0}}, color={162,29,33}));
connect(checkOver.y, b_check_over) annotation(
Line(points = {{12, 0}, {110, 0}}, color = {162, 29, 33}));
connect(checkOver.tl, P1) annotation(
Line(points = {{0, 10}, {0, 100}}, color = {0, 0, 255}, thickness = 0.5));
connect(checkOver.u, phi1) annotation(
Line(points = {{-10, 0}, {-110, 0}}, color = {162, 29, 33}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Rectangle(
extent={{-100,100},{100,-100}},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
within CRML_test.FORML.AfterBefore;
block AfterBefore
protected
parameter Integer N = CRML.ETL.Types.nMaxOverlap;
CRML.ETL.Connectors.WhileOutput tl1 = tl;
public
CRML.ETL.Connectors.ClockInput ck1 "Boolean4 condition" annotation(
Placement(transformation(extent = {{-120, 30}, {-100, 50}}), iconTransformation(extent = {{-120, 30}, {-100, 50}})));
CRML.ETL.Connectors.WhileInput tl annotation(
Placement(transformation(extent = {{-10, 90}, {10, 110}}), iconTransformation(extent = {{-10, 90}, {10, 110}})));
CRML.ETL.Connectors.TimeLocatorOutput[N] p_after_b1_before_b2
annotation (Placement(transformation(extent={{100,-10},{120,10}})));
CRML.ETL.TimeLocators.Periods periods(leftBoundaryIncluded = false, rightBoundaryIncluded = false) annotation(
Placement(transformation(extent = {{-10, -10}, {10, 10}})));
Modelica.Clocked.BooleanSignals.NonPeriodic.ClockToBoolean clockToBoolean_ck1 annotation(
Placement(transformation(extent = {{-80, 30}, {-60, 50}})));
CRML.Blocks.Logical4.BooleanToBoolean4 booleanToBoolean4_ck1 annotation(
Placement(transformation(extent = {{-44, 36}, {-36, 44}})));
Modelica.Clocked.BooleanSignals.NonPeriodic.ClockToBoolean clockToBoolean_ck2 annotation(
Placement(transformation(extent = {{-80, -50}, {-60, -30}})));
CRML.Blocks.Logical4.BooleanToBoolean4 booleanToBoolean4_ck2 annotation(
Placement(transformation(extent = {{-44, -44}, {-36, -36}})));

public
CRML.ETL.Connectors.ClockInput ck2 "Boolean4 condition" annotation(
Placement(transformation(extent={{-120,-50},{-100,-30}}), iconTransformation(extent={{-120,
-50},{-100,-30}})));
equation
if (cardinality(tl) == 0) then
tl.timePeriod = true;
tl.clock = CRML.ETL.Types.Boolean4.true4;
tl.isLeftBoundaryIncluded = true;
tl.isRightBoundaryIncluded = true;
end if;
connect(ck1, clockToBoolean_ck1.u) annotation(
Line(points = {{-110, 40}, {-82, 40}}, color = {175, 175, 175}, pattern = LinePattern.Dot, thickness = 0.5));
connect(clockToBoolean_ck1.y, booleanToBoolean4_ck1.u) annotation(
Line(points = {{-59, 40}, {-44.4, 40}}, color = {255, 0, 255}));
connect(booleanToBoolean4_ck1.y, periods.u1) annotation(
Line(points = {{-35.6, 40}, {-20, 40}, {-20, 0}, {-11, 0}}, color = {162, 29, 33}));
connect(clockToBoolean_ck2.y, booleanToBoolean4_ck2.u) annotation(
Line(points = {{-59, -40}, {-44.4, -40}}, color = {255, 0, 255}));
connect(booleanToBoolean4_ck2.y, periods.u2) annotation(
Line(points = {{-35.6, -40}, {-20, -40}, {-20, -8}, {-11, -8}}, color = {162, 29, 33}));
connect(periods.y, p_after_b1_before_b2) annotation (Line(points={{0,-10},{0,-20},
{80,-20},{80,0},{110,0}}, color={0,0,255}));
connect(tl1, periods.tl) annotation(
Line(points = {{0, 100}, {0, 10}}, color = {0, 0, 255}));
connect(clockToBoolean_ck2.u, ck2) annotation (Line(
points={{-82,-40},{-110,-40}},
color={175,175,175},
pattern=LinePattern.Dot,
thickness=0.5));
annotation(
Icon(coordinateSystem(preserveAspectRatio = false), graphics = {Rectangle(fillColor = {85, 170, 255}, fillPattern = FillPattern.Solid, lineThickness = 5, borderPattern = BorderPattern.Raised, extent = {{-100, 100}, {100, -100}}), Rectangle(lineColor = {175, 175, 175}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-70, 30}, {70, -52}}), Line(points = {{-50, -34}, {-50, -12}}, pattern = LinePattern.Dash), Line(points = {{-48, -12}, {52, -12}}, pattern = LinePattern.Dash), Line(points = {{52, -12}, {52, -34}}, pattern = LinePattern.Dash), Line(points = {{-62, -34}, {58, -34}}, color = {175, 175, 175}), Line(points = {{-50, -12}, {-50, 10}}, pattern = LinePattern.Dash), Rectangle(fillColor = {175, 175, 175}, fillPattern = FillPattern.Solid, extent = {{22, 2}, {52, -12}}), Line(points = {{-50, 10}, {22, 10}}, pattern = LinePattern.Dash), Line(points = {{22, 10}, {22, -12}}, pattern = LinePattern.Dash), Line(points = {{22, -12}, {20, -10}}, pattern = LinePattern.Dash), Line(points = {{22, -12}, {24, -10}}, pattern = LinePattern.Dash), Line(points = {{-50, -12}, {-52, -10}}, pattern = LinePattern.Dash), Line(points = {{-50, -12}, {-48, -10}}, pattern = LinePattern.Dash), Line(points = {{-50, 30}, {-70, 30}, {-70, -52}, {-50, -52}}), Line(points = {{50, 30}, {70, 30}, {70, -52}, {50, -52}}), Text(textColor = {175, 175, 175}, extent = {{-28, -10}, {22, -34}}, textString = "%u"), Text(extent = {{-78, 86}, {76, 38}}, textString = "after before")}),
Diagram(coordinateSystem(preserveAspectRatio = false)),
Documentation(info = "<html>
<p><b><span style=\"font-family: MS Shell Dlg 2;\">Syntax</span></b> </p>
<blockquote><b>y</b> = <b>CheckAtEnd </b>(<b>u</b> = condition, <b>tl</b> = time_period, <b>checkAtEnd</b>); </blockquote>
<p><b><span style=\"font-family: MS Shell Dlg 2;\">Description</span></b> </p>
<p><span style=\"font-family: MS Shell Dlg 2;\">Each instance of this block creates a requirement that evaluates whether the condition <b>u</b> is satisfied (true) at the end of the time period <b>tl</b> (which can be a continuous or discrete time period). The condition is a <a href=\"modelica://CRML.ETL.Types.Boolean4\">Boolean4</a> that takes its values in the { true, false, undecided, undefined } set.</span></p>
<p><span style=\"font-family: MS Shell Dlg 2;\">To create time locators, refer to the <a href=\"modelica://CRML.ETL.TimeLocators.Periods\">Periods</a> block.</span></p>
<p><span style=\"font-family: MS Shell Dlg 2;\">The value of a requirement is a <a href=\"modelica://CRML.ETL.Types.Boolean4\">Boolean4</a> that can be used as input of another Ensure block. It is therefore possible to express requirements on requirements.</span></p>
<p><span style=\"font-family: MS Shell Dlg 2;\">Requirements can be combined using <a href=\"modelica://CRML.ETL.Types.Boolean4\">Boolean4</a> operators, refer to the <a href=\"modelica://CRML.Blocks.Logical4\">Logical4</a> package.</span></p>
<p>The condition <b>u</b> can be generated by converting Boolean signals to Boolean4 signals with the block <a href=\"modelica://CRML.Blocks.Logical4.BooleanToBoolean4\">BooleanToBoolean4</a>, or by using the output y of another <a href=\"modelica://CRML.ETL.Requirements.Check\">Check</a>, <a href=\"modelica://CRML.ETL.Requirements.CheckInteger\">CheckInteger</a> or <a href=\"modelica://CRML.ETL.Requirements.CheckReal\">CheckReal</a> block.</p>
<p><br><b><span style=\"font-family: MS Shell Dlg 2;\">Example</span></b> </p>
<p><span style=\"font-family: MS Shell Dlg 2;\">This block is demonstrated with the following <a href=\"modelica://ReqSysPro.Examples.TimeLocators.Continuous.After\">example</a>:</span></p>
</html>"));
end AfterBefore;
Loading
Loading