Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Martin Heyden
LabProcesses.jl
Commits
7d4d8901
Commit
7d4d8901
authored
Aug 23, 2017
by
Fredrik Bagge Carlson
Browse files
No sleep in control loop for simulated process
parent
e62aa7b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/controllers.jl
View file @
7d4d8901
...
...
@@ -30,9 +30,10 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10
ui
+
bias
(
P
)
end
simulation
=
isa
(
P
,
SimulatedProcess
)
initialize
(
P
)
for
(
i
,
t
)
=
enumerate
(
0
:
h
:
duration
)
@periodically
h
begin
@periodically
h
simulation
begin
y
[
:
,
i
]
=
measure
(
P
)
r
[
:
,
i
]
=
reference
(
t
)
u
[
:
,
i
]
=
calc_control
(
i
)
# y,r must be updated before u
...
...
src/interface_implementations/ballandbeam.jl
View file @
7d4d8901
...
...
@@ -87,5 +87,5 @@ initialize(p::AbstractBeamOrBallAndBeam) = ccall((:comedi_start, comedipath),Int
finalize
(
p
::
AbstractBeamOrBallAndBeam
)
=
(
control
(
p
,
0
);
ccall
((
:
comedi_stop
,
comedipath
),
Int32
,(
Int32
,),
0
))
initialize
(
p
::
BallAndBeamSimulator
)
=
nothing
finalize
(
p
::
BallAndBeamSimulator
)
=
nothing
initialize
(
p
::
BeamSimulator
)
=
nothing
initialize
(
p
::
BeamSimulator
)
=
p
.
state
.*=
0
finalize
(
p
::
BeamSimulator
)
=
nothing
src/utilities.jl
View file @
7d4d8901
...
...
@@ -13,6 +13,20 @@ macro periodically(h, body)
end
end
"""
@periodically(h, simulation::Bool, body)
Ensures that the body is run with an interval of `h >= 0.001` seconds.
If `simulation == false`, no sleep is done
"""
macro
periodically
(
h
,
simulation
,
body
)
quote
local
start_time
=
time
()
$
(
esc
(
body
))
local
execution_time
=
time
()
-
start_time
$
(
esc
(
simulation
))
||
sleep
(
max
(
0
,
$
(
esc
(
h
))
-
execution_time
))
end
end
"""
state = init_sysfilter(sys::StateSpace)
Use together with [`sysfilter!`](@ref)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment