From c80a86a7f4916747b0248f36d70bd1d99b20b394 Mon Sep 17 00:00:00 2001 From: Anton Haumer Date: Wed, 14 Dec 2022 19:36:43 +0100 Subject: [PATCH] Replaced state events by time events --- Modelica/Blocks/Sources.mo | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Modelica/Blocks/Sources.mo b/Modelica/Blocks/Sources.mo index 058c0992a8..7d7f4c8253 100644 --- a/Modelica/Blocks/Sources.mo +++ b/Modelica/Blocks/Sources.mo @@ -413,13 +413,13 @@ The Real output y is a cosine signal: transformation( extent={{-2,-2},{2,2}}, origin={-80,-60}))); - Blocks.Sources.Constant amplitude_constant(final k=constantAmplitude) if - useConstantAmplitude + Blocks.Sources.Constant amplitude_constant(final k=constantAmplitude) + if useConstantAmplitude annotation (Placement(transformation(extent={{-10,-10},{10,10}}, rotation=90, origin={-80,30}))); - Blocks.Sources.Constant f_constant(final k=constantFrequency) if - useConstantFrequency + Blocks.Sources.Constant f_constant(final k=constantFrequency) + if useConstantFrequency annotation (Placement(transformation(extent={{10,-10},{-10,10}}, rotation=90, origin={-80,-30}))); @@ -516,13 +516,13 @@ and that the parameter startTime is omitted since the voltage can b transformation( extent={{-2,-2},{2,2}}, origin={-80,-60}))); - Blocks.Sources.Constant amplitude_constant(final k=constantAmplitude) if - useConstantAmplitude + Blocks.Sources.Constant amplitude_constant(final k=constantAmplitude) + if useConstantAmplitude annotation (Placement(transformation(extent={{-10,-10},{10,10}}, rotation=90, origin={-80,30}))); - Blocks.Sources.Constant f_constant(final k=constantFrequency) if - useConstantFrequency + Blocks.Sources.Constant f_constant(final k=constantFrequency) + if useConstantFrequency annotation (Placement(transformation(extent={{10,-10},{-10,10}}, rotation=90, origin={-80,-30}))); @@ -768,7 +768,8 @@ by a falling exponential signal: count := integer((time - startTime)/period); T_start := startTime + count*period; equation - when integer((time - startTime)/period) > pre(count) then + //when integer((time - startTime)/period) > pre(count) then + when time >= (pre(count) + 1)*period + startTime then count = pre(count) + 1; T_start = time; end when; @@ -823,7 +824,8 @@ The Real output y is a pulse signal: count := integer((time - startTime)/period); T_start := startTime + count*period; equation - when integer((time - startTime)/period) > pre(count) then + //when integer((time - startTime)/period) > pre(count) then + when time >= (pre(count) + 1)*period + startTime then count = pre(count) + 1; T_start = time; end when; @@ -888,7 +890,8 @@ The Real output y is a saw tooth signal: count := integer((time - startTime)/period); T_start := startTime + count*period; equation - when integer((time - startTime)/period) > pre(count) then + //when integer((time - startTime)/period) > pre(count) then + when time >= (pre(count) + 1)*period + startTime then count = pre(count) + 1; T_start = time; end when;