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
processes
LabProcesses.jl
Commits
03264932
Commit
03264932
authored
Aug 20, 2017
by
Fredrik Bagge Carlson
Browse files
Update
parent
017bbe7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/LabProcesses.jl
View file @
03264932
module
LabProcesses
export
AbstractProcess
,
PhycicalProcess
,
SimulatedProcess
,
BallAndBeam
,
BallAndBeamSimulator
,
BallAndBeamType
export
num_outputs
,
num_inputs
,
outputrange
,
inputrange
,
isstable
,
sampletime
,
control
,
measure
include
(
"utilities.jl"
)
# Interface specification ===================================================================
abstract type
AbstractProcess
end
abstract type
PhycicalProcess
<:
AbstractProcess
end
abstract type
SimulatedProcess
<:
AbstractProcess
end
num_outputs
(
p
::
AbstractProcess
)
=
p
.
ny
num_inputs
(
p
::
AbstractProcess
)
=
p
.
nu
num_outputs
(
p
::
AbstractProcess
)
=
error
(
"Function not implemented for
$
(typeof(p))"
)
num_inputs
(
p
::
AbstractProcess
)
=
error
(
"Function not implemented for
$
(typeof(p))"
)
outputrange
(
p
::
AbstractProcess
)
=
error
(
"Function not implemented for
$
(typeof(p))"
)
inputrange
(
p
::
AbstractProcess
)
=
error
(
"Function not implemented for
$
(typeof(p))"
)
isstable
(
p
::
AbstractProcess
)
=
error
(
"Function not implemented for
$
(typeof(p))"
)
...
...
@@ -39,13 +51,12 @@ control(p::BallAndBeam, u) = ccall((:comedi_write, comedipath),Int32,
measure
(
p
::
BallAndBeam
)
=
io2num
(
ccall
((
:
comedi_read
,
comedipath
),
Int32
,
(
Int32
,
Int32
,
Int32
),
0
,
0
,
0
))
control
(
p
::
BallAndBeamSimulator
,
u
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
BallAndBeamSimulator
)
=
error
(
"Not yet implemented"
)
const
comedipath
=
"../c/comedi_bridge.so"
const
conversion
=
65535
/
20
io2num
(
x
)
=
x
/
conversion
-
10
# Converts from io to float
num2io
(
x
)
=
round
(
Int32
,
x
*
100
+
2050
)
# Converts from regular number to io
control
(
p
::
BallAndBeamSimulator
,
u
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
BallAndBeamSimulator
)
=
error
(
"Not yet implemented"
)
end
# module
src/utilities.jl
0 → 100644
View file @
03264932
export
periodically
"""
@periodically(h, body)
Ensures that the body is run with an interval of `h >= 0.001` seconds.
"""
macro
periodically
(
h
,
body
)
quote
local
start_time
=
time
()
$
(
esc
(
body
))
local
execution_time
=
time
()
-
start_time
sleep
(
max
(
0
,
$
h
-
execution_time
))
end
end
Write
Preview
Markdown
is supported
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