Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabProcesses.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Heyden
LabProcesses.jl
Commits
7144dbc5
Commit
7144dbc5
authored
7 years ago
by
Fredrik Bagge Carlson
Browse files
Options
Downloads
Patches
Plain Diff
Implement LabConnection for ballandbeam
parent
b8b24b14
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
REQUIRE
+1
-0
1 addition, 0 deletions
REQUIRE
src/LabProcesses.jl
+1
-1
1 addition, 1 deletion
src/LabProcesses.jl
src/interface_implementations/ballandbeam.jl
+28
-35
28 additions, 35 deletions
src/interface_implementations/ballandbeam.jl
with
30 additions
and
36 deletions
REQUIRE
+
1
−
0
View file @
7144dbc5
julia 0.6
julia 0.6
ControlSystems
ControlSystems
Parameters
This diff is collapsed.
Click to expand it.
src/LabProcesses.jl
+
1
−
1
View file @
7144dbc5
...
@@ -7,7 +7,7 @@ end
...
@@ -7,7 +7,7 @@ end
module
LabProcesses
module
LabProcesses
using
ControlSystems
,
LabConnection
.
Computer
using
ControlSystems
,
LabConnection
.
Computer
,
Parameters
include
(
"utilities.jl"
)
include
(
"utilities.jl"
)
...
...
This diff is collapsed.
Click to expand it.
src/interface_implementations/ballandbeam.jl
+
28
−
35
View file @
7144dbc5
...
@@ -11,11 +11,13 @@
...
@@ -11,11 +11,13 @@
export
Beam
,
BeamSimulator
,
AbstractBeam
,
BallAndBeam
,
BallAndBeamSimulator
,
AbstractBeamOrBallAndBeam
export
Beam
,
BeamSimulator
,
AbstractBeam
,
BallAndBeam
,
BallAndBeamSimulator
,
AbstractBeamOrBallAndBeam
struct
Beam
<:
PhysicalProcess
@with_kw
struct
Beam
<:
PhysicalProcess
h
::
Float64
h
::
Float64
=
0.01
bias
::
Float64
bias
::
Float64
=
0.0
stream
::
LabStream
=
ComediStream
()
measure
::
AnalogInput10V
=
AnalogInput10V
(
0
)
control
::
AnalogOutput10V
=
AnalogOutput10V
(
1
)
end
end
Beam
()
=
Beam
(
0.01
,
0.0
)
include
(
"define_beam_system.jl"
)
include
(
"define_beam_system.jl"
)
const
beam_system
,
nice_beam_controller
=
define_beam_system
()
const
beam_system
,
nice_beam_controller
=
define_beam_system
()
...
@@ -27,24 +29,24 @@ struct BeamSimulator <: SimulatedProcess
...
@@ -27,24 +29,24 @@ struct BeamSimulator <: SimulatedProcess
BeamSimulator
(
h
::
Real
)
=
new
(
Float64
(
h
),
SysFilter
(
beam_system
,
h
))
BeamSimulator
(
h
::
Real
)
=
new
(
Float64
(
h
),
SysFilter
(
beam_system
,
h
))
end
end
struct
BallAndBeam
<:
PhysicalProcess
@with_kw
struct
BallAndBeam
<:
PhysicalProcess
h
::
Float64
h
::
Float64
=
0.01
bias
::
Float64
bias
::
Float64
=
0.0
stream
::
LabStream
=
ComediStream
()
measure1
::
AnalogInput10V
=
AnalogInput10V
(
0
)
measure2
::
AnalogInput10V
=
AnalogInput10V
(
1
)
control
::
AnalogOutput10V
=
AnalogOutput10V
(
0
)
end
end
BallAndBeam
()
=
BallAndBeam
(
0.01
,
0.0
)
struct
BallAndBeamSimulator
<:
SimulatedProcess
struct
BallAndBeamSimulator
<:
SimulatedProcess
h
::
Float64
h
::
Float64
s
::
SysFilter
s
::
SysFilter
end
end
const
AbstractBeam
=
Union
{
Beam
,
BeamSimulator
}
const
AbstractBeam
=
Union
{
Beam
,
BeamSimulator
}
const
AbstractBallAndBeam
=
Union
{
BallAndBeam
,
BallAndBeamSimulator
}
const
AbstractBallAndBeam
=
Union
{
BallAndBeam
,
BallAndBeamSimulator
}
const
AbstractBeamOrBallAndBeam
=
Union
{
AbstractBeam
,
AbstractBallAndBeam
}
const
AbstractBeamOrBallAndBeam
=
Union
{
AbstractBeam
,
AbstractBallAndBeam
}
num_outputs
(
p
::
AbstractBeam
)
=
1
num_outputs
(
p
::
AbstractBeam
)
=
1
num_outputs
(
p
::
AbstractBallAndBeam
)
=
2
num_outputs
(
p
::
AbstractBallAndBeam
)
=
2
num_inputs
(
p
::
AbstractBeamOrBallAndBeam
)
=
1
num_inputs
(
p
::
AbstractBeamOrBallAndBeam
)
=
1
...
@@ -60,29 +62,20 @@ bias(p::BeamSimulator) = 0
...
@@ -60,29 +62,20 @@ bias(p::BeamSimulator) = 0
bias
(
p
::
BallAndBeamSimulator
)
=
0
bias
(
p
::
BallAndBeamSimulator
)
=
0
control
(
p
::
AbstractBeamOrBallAndBeam
,
u
)
=
ccall
((
:
comedi_write
,
comedipath
),
Int32
,
control
(
p
::
AbstractBeamOrBallAndBeam
,
u
)
=
send
(
p
.
control
,
u
)
(
Int32
,
Int32
,
Int32
,
Int32
),
0
,
1
,
1
,
num2io
(
u
[
1
]
+
p
.
bias
))
control
(
p
::
BeamSimulator
,
u
)
=
p
.
s
(
u
)
control
(
p
::
BeamSimulator
,
u
)
=
p
.
s
(
u
)
control
(
p
::
BallAndBeamSimulator
,
u
)
=
error
(
"Not yet implemented"
)
control
(
p
::
BallAndBeamSimulator
,
u
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
Beam
)
=
io2num
(
ccall
((
:
comedi_read
,
comedipath
),
Int32
,
measure
(
p
::
Beam
)
=
read
(
p
.
measure
)
(
Int32
,
Int32
,
Int32
),
0
,
0
,
0
))
measure
(
p
::
BallAndBeam
)
=
[
read
(
p
.
measure1
),
read
(
p
.
measure2
)]
measure
(
p
::
BallAndBeam
)
=
[
io2num
(
ccall
((
:
comedi_read
,
comedipath
),
Int32
,
(
Int32
,
Int32
,
Int32
),
0
,
0
,
i
))
for
i
=
0
:
1
]
measure
(
p
::
BeamSimulator
)
=
vecdot
(
p
.
s
.
sys
.
C
,
p
.
s
.
state
)
measure
(
p
::
BeamSimulator
)
=
vecdot
(
p
.
s
.
sys
.
C
,
p
.
s
.
state
)
measure
(
p
::
BallAndBeamSimulator
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
BallAndBeamSimulator
)
=
error
(
"Not yet implemented"
)
const
comedipath
=
Pkg
.
dir
(
"LabProcesses"
,
"c"
,
"comedi_bridge.so"
)
initialize
(
p
::
Beam
)
=
init_devices!
(
p
.
stream
,
p
.
measure
,
p
.
control
)
const
conversion
=
65535
/
20
initialize
(
p
::
BallAndBeam
)
=
init_devices!
(
p
.
stream
,
p
.
measure1
,
io2num
(
x
)
=
x
/
conversion
-
10
# Converts from io to float
p
.
measure2
,
p
.
control
)
num2io
(
x
)
=
round
(
Int32
,
x
*
100
+
2048
)
# Converts from regular number to io
finalize
(
p
::
AbstractBeamOrBallAndBeam
)
=
close
(
p
.
stream
)
initialize
(
p
::
AbstractBeamOrBallAndBeam
)
=
ccall
((
:
comedi_start
,
comedipath
),
Int32
,(
Int32
,),
0
)
finalize
(
p
::
AbstractBeamOrBallAndBeam
)
=
(
control
(
p
,
0
);
ccall
((
:
comedi_stop
,
comedipath
),
Int32
,(
Int32
,),
0
))
initialize
(
p
::
BallAndBeamSimulator
)
=
nothing
initialize
(
p
::
BallAndBeamSimulator
)
=
nothing
finalize
(
p
::
BallAndBeamSimulator
)
=
nothing
finalize
(
p
::
BallAndBeamSimulator
)
=
nothing
initialize
(
p
::
BeamSimulator
)
=
p
.
s
.
state
.*=
0
initialize
(
p
::
BeamSimulator
)
=
p
.
s
.
state
.*=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment