Skip to content

Commit

Permalink
change signatures in CRMLtoModelica library
Browse files Browse the repository at this point in the history
  • Loading branch information
lenaRB committed Apr 19, 2024
1 parent 849f94e commit 8523e60
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
53 changes: 43 additions & 10 deletions resources/modelica_libraries/CRMLtoModelica.mo
Original file line number Diff line number Diff line change
Expand Up @@ -699,22 +699,23 @@ end cvBooleanToBoolean4;
Boolean x(start=false, fixed=true);

public
input Boolean r1//u
input Types.CRMLClock r1//u
annotation (Placement(transformation(extent={{-120,-10},{-100,10}})));
output Boolean out(start=false, fixed=true) annotation (
output Types.CRMLClock out annotation (
Placement(transformation(extent={{100,-10},{120,10}}),
iconTransformation(extent={{100,-10},{120,10}})));

input Boolean r2 //cond
input Types.Boolean4 r2 //cond
"Condition" annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={-110,80})));
equation

x = r1 and r2;
out = edge(x);
// x = r2;
//x = r1 and r2;
//out = edge(x);

annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Rectangle(
Expand Down Expand Up @@ -784,10 +785,10 @@ end cvBooleanToBoolean4;
end Integrate;

block ClockTick "Generates an event when the integer input changes"
input Integer r1;
output Boolean out;
input Types.CRMLClock r1;
output Integer out;
equation
out = r1 <> pre(r1);
// out = r1 <> pre(r1);
annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, initialScale=0.06),
graphics={
Expand Down Expand Up @@ -888,12 +889,44 @@ end cvBooleanToBoolean4;

model Card

CRMLtoModelica.Types.Boolean4 r1;
CRMLtoModelica.Types.CRMLClock r1;

Boolean out;
Integer out;
equation

end Card;

block BoolTick "Generates an event when the integer input changes"
input Integer r1;
output Boolean out;
equation
out = r1 <> pre(r1);
annotation(
Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}, initialScale = 0.06), graphics = {Ellipse(extent = {{-100, 100}, {100, -100}}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, lineColor = {217, 67, 180}), Ellipse(extent = {{9, -10}, {-11, 10}}, lineColor = {217, 67, 180}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid), Line(points = {{-1, 0}, {52, 50}}, color = {217, 67, 180}), Rectangle(extent = {{80, 6}, {100, -6}}, fillPattern = FillPattern.Solid, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Rectangle(extent = {{-100, 6}, {-80, -6}}, fillPattern = FillPattern.Solid, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Rectangle(extent = {{20, 58}, {40, 46}}, fillPattern = FillPattern.Solid, rotation = 90, origin = {52, -120}, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Rectangle(extent = {{20, 58}, {40, 46}}, fillPattern = FillPattern.Solid, rotation = 45, origin = {80, 6}, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Rectangle(extent = {{20, 58}, {40, 46}}, fillPattern = FillPattern.Solid, rotation = 135, origin = {-6, 80}, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Rectangle(extent = {{20, 58}, {40, 46}}, fillPattern = FillPattern.Solid, rotation = 135, origin = {122, -48}, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Rectangle(extent = {{20, 58}, {40, 46}}, fillPattern = FillPattern.Solid, rotation = 90, origin = {52, 60}, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Rectangle(extent = {{20, 58}, {40, 46}}, fillPattern = FillPattern.Solid, rotation = 45, origin = {-52, -118}, lineColor = {217, 67, 180}, fillColor = {217, 67, 180}), Text(extent = {{-51, 150}, {51, 114}}, lineColor = {0, 0, 255}, lineThickness = 0.5, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, textString = "%name")}),
Documentation(info = "<html>
<p>
This component generates a clock signal triggered by a continuous-time
Boolean input signal u: Whenever the Boolean input signal <b>u</b>
changes from <b>false</b> to <b>true</b>, then the output
clock signal <b>y</b> ticks.
</p>
<p>
For an introduction to clocks see
<a href=\"modelica://Modelica_Synchronous.UsersGuide.Clocks\">UsersGuide.Clocks</a>.
</p>
<p>
If a clock is associated to a clocked continuous-time partition, then an <b>integrator</b>
has to be defined that is used to integrate the partition from the previous
to the current clock tick. This is performed by setting parameter <b>useSolver</b>
= <b>true</b> and defining the integration method as String with
parameter <b>solver</b>. Both parameters are in tab <b>Advanced</b>.
For an example, see
<a href=\"modelica://Modelica_Synchronous.Examples.Systems.ControlledMixingUnit\">Examples.Systems.ControlledMixingUnit</a>.
</p>
</html>"));
end BoolTick;



Expand Down
4 changes: 2 additions & 2 deletions src/main/java/crml/compiler/crmlVisitorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ private Value apply_user_operator(String op, List<ExpContext> exp) {
Value left = visit(exp.get(0));
Value right = visit(exp.get(1));

res = sign.function_name + " " + name+ "(" + sign.variable_names.get(0) + "="+left.contents+"," +
sign.variable_names.get(1)+ "="+right.contents+");\n";
res = sign.function_name + " " + name+ "(" + sign.variable_names.get(1) + "="+left.contents+"," +
sign.variable_names.get(0)+ "="+right.contents+");\n";
} else {
Value operand = visit(exp.get(0));

Expand Down

0 comments on commit 8523e60

Please sign in to comment.