-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e7e5c4
commit 4a50f3d
Showing
11 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
within InteractiveSimulation.Examples.System; | ||
|
||
model getCPUclock_ex01 | ||
extends Modelica.Icons.Example; | ||
InteractiveSimulation.System.getCPUclock CPUtime annotation( | ||
Placement(transformation(origin = {-22, 56}, extent = {{-10, -10}, {10, 10}}))); | ||
equation | ||
|
||
annotation( | ||
experiment(StartTime = 0, StopTime = 100, Tolerance = 1e-06, Interval = 0.001)); | ||
end getCPUclock_ex01; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
RunPyScript00_ex01 | ||
RunPyScript01_ex01 | ||
C_runPyScript00_ex01 | ||
getCPUclock_ex01 | ||
terminateWhenTriggered_ex01 | ||
terminateByCPUtimer_ex01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
within InteractiveSimulation.Examples.System; | ||
|
||
model terminateByCPUtimer_ex01 | ||
extends Modelica.Icons.Example; | ||
InteractiveSimulation.System.terminateByCPUtimer terminateByCPUtimer(tTerminate = 5) annotation( | ||
Placement(transformation(origin = {-32, 48}, extent = {{-10, -10}, {10, 10}}))); | ||
InteractiveSimulation.System.getCPUclock CPUtime annotation( | ||
Placement(transformation(origin = {-62, 76}, extent = {{-10, -10}, {10, 10}}))); | ||
equation | ||
|
||
annotation( | ||
experiment(StartTime = 0, StopTime = 1000, Tolerance = 1e-06, Interval = 0.001)); | ||
end terminateByCPUtimer_ex01; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
within InteractiveSimulation.Examples.System; | ||
|
||
model terminateWhenTriggered_ex01 | ||
extends Modelica.Icons.Example; | ||
InteractiveSimulation.System.terminateWhenTriggered TerminateWhenTriggered annotation( | ||
Placement(transformation(origin = {22, 38}, extent = {{-10, -10}, {10, 10}}))); | ||
Modelica.Blocks.Sources.BooleanStep sourceTrigger(startTime = 50) annotation( | ||
Placement(transformation(origin = {-22, 38}, extent = {{-10, -10}, {10, 10}}))); | ||
equation | ||
connect(sourceTrigger.y, TerminateWhenTriggered.u_trigger) annotation( | ||
Line(points = {{-10, 38}, {10, 38}}, color = {255, 0, 255})); | ||
annotation( | ||
experiment(StartTime = 0, StopTime = 100, Tolerance = 1e-06, Interval = 0.001)); | ||
end terminateWhenTriggered_ex01; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
within InteractiveSimulation.Input; | ||
|
||
block getCPUclock | ||
|
||
|
||
|
||
|
||
end getCPUclock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
within InteractiveSimulation.System; | ||
|
||
model getCPUclock | ||
"CPU time since commence of simulation" | ||
parameter Integer sigDigits=4; | ||
|
||
import units= Modelica.Units.SI; | ||
|
||
discrete units.Time tCPUsimBegin; | ||
units.Time tCPUnow; | ||
|
||
|
||
Modelica.Blocks.Interfaces.RealOutput y_CPUtime(quantity = "Time", unit = "s", displayUnit = "s") "[s]" annotation( | ||
Placement(transformation(origin = {110, -2}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}))); | ||
|
||
//*************************************************************************** | ||
initial algorithm | ||
|
||
tCPUsimBegin:= Modelica_DeviceDrivers.OperatingSystem.clock(dummy=0.0) /1000.0; | ||
|
||
algorithm | ||
tCPUnow:= Modelica_DeviceDrivers.OperatingSystem.clock(dummy=0.0) /1000.0; | ||
|
||
//----------------------------------- | ||
when (time==0.0)then | ||
tCPUsimBegin:= tCPUnow; | ||
end when; | ||
//----------------------------------- | ||
|
||
y_CPUtime:= tCPUnow-tCPUsimBegin; | ||
|
||
annotation( | ||
defaultComponentName = "CPUtime", | ||
Icon(graphics = {Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {-1, 34}, extent = {{-95, 22}, {95, -22}}, textString = "CPU time"), Text(origin = {0, -27}, extent = {{-80, 13}, {80, -13}}, textString = DynamicSelect("0.0", String(y_CPUtime, sigDigits, 0, true))), Text(origin = {65, -46}, extent = {{-19, 10}, {19, -10}}, textString = "[s]")})); | ||
|
||
|
||
end getCPUclock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
Functions | ||
getCPUclock | ||
terminateWhenTriggered | ||
terminateByCPUtimer | ||
RunPyScript00 | ||
RunPyScript01 | ||
RunPyScript02 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
within InteractiveSimulation.System; | ||
|
||
model terminateByCPUtimer | ||
import units= Modelica.Units.SI; | ||
|
||
parameter units.Time tTerminate=100; | ||
parameter Integer sigDigits=4; | ||
|
||
|
||
getCPUclock CPUtime annotation( | ||
Placement(transformation(origin = {-38, 50}, extent = {{-10, -10}, {10, 10}}))); | ||
terminateWhenTriggered TerminateWhenTriggered annotation( | ||
Placement(transformation(origin = {34, 50}, extent = {{-10, -10}, {10, 10}}))); | ||
|
||
algorithm | ||
|
||
if(tTerminate<=CPUtime.y_CPUtime)then | ||
TerminateWhenTriggered.u_trigger:=true; | ||
else | ||
TerminateWhenTriggered.u_trigger:=false; | ||
end if; | ||
|
||
annotation( | ||
Icon(graphics = {Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {1, 49}, extent = {{-93, 33}, {93, -33}}, textString = "terminate | ||
by CPU timer"), Text(origin = {0, -51}, extent = {{-80, 13}, {80, -13}}, textString = DynamicSelect("0.0", String(CPUtime.y_CPUtime, sigDigits, 0, true))), Text(origin = {65, -70}, extent = {{-19, 10}, {19, -10}}, textString = "[s]"), Text(origin = {-60, -22}, extent = {{-26, 12}, {26, -12}}, textString = "current:")})); | ||
end terminateByCPUtimer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
within InteractiveSimulation.System; | ||
|
||
model terminateWhenTriggered | ||
Modelica.Blocks.Interfaces.BooleanInput u_trigger annotation( | ||
Placement(transformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}))); | ||
|
||
algorithm | ||
|
||
when(u_trigger==true)then | ||
terminate("terminate trigger is set true"); | ||
end when; | ||
|
||
annotation( | ||
defaultComponentName = "TerminateWhenTriggered", | ||
Icon(graphics = {Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {-1, 0}, extent = {{-93, 40}, {93, -40}}, textString = "Terminate | ||
by trigger")})); | ||
end terminateWhenTriggered; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters