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
DoubleTankLab.jl
Commits
5c4f62d1
Commit
5c4f62d1
authored
Mar 09, 2018
by
Jacob Wikmark
Browse files
formatting
parent
f3f7db1e
Changes
3
Show whitespace changes
Inline
Side-by-side
src/DoubleTank.jl
View file @
5c4f62d1
...
...
@@ -12,7 +12,7 @@ using Parameters
#struct BC
#ar::Array{Float64, 1}
#ar::Array{Float64, 1}
#end
#bc = BC([])
...
...
@@ -246,9 +246,10 @@ function qu(p, u)
end
function
control
(
p
::
DoubleTankSimulator
,
u
::
Number
)
#The simulator should operate on physical values but u should be in [0,1]
@unpack
a1
,
a2
,
g
,
x
,
A
,
h
,
scale
=
p
x
*=
scale
#The simulator should operate on physical values but u should be in [0,1]
u
=
clamp
(
u
,
inputrange
(
p
)[
1
]
...
)
qut
=
a1
*
sqrt
(
2
*
g
*
x
[
1
])
#m^3/s
...
...
@@ -265,8 +266,8 @@ function control(p::DoubleTankSimulator, u::Number)
if
(
-
dA2
*
h
>
x
[
2
]
*
A
)
dA2
=
-
x
[
2
]
*
A
/
h
end
x
[
1
]
+=
(
dA1
*
h
)
/
A
#m change later
x
[
2
]
+=
(
dA2
*
h
)
/
A
#m change later
x
[
1
]
+=
(
dA1
*
h
)
/
A
x
[
2
]
+=
(
dA2
*
h
)
/
A
x
/=
scale
@pack
p
=
a1
,
a2
,
g
,
x
,
A
,
h
...
...
@@ -277,5 +278,8 @@ measure(p::DoubleTankSimulator) = p.x + p.σ*p.scale*randn(2)
LabProcesses
.
initialize
(
p
::
DoubleTankSimulator
)
=
nothing
#finalize(p::DoubleTankSimulator) = nothing
LabProcesses
.
finalize
(
p
::
DoubleTankSimulator
)
=
nothing
LabProcesses
.
initialize
(
p
::
DoubleTank
)
=
nothing
#change later
LabProcesses
.
finalize
(
p
::
DoubleTank
)
=
nothing
#change later
src/tankdemo.jl
View file @
5c4f62d1
...
...
@@ -3,7 +3,7 @@ include("tankgraphic.jl")
include
(
"DoubleTank.jl"
)
include
(
"tanklabgui.jl"
)
const
simulated
=
fals
e
const
simulated
=
tru
e
const
webservice
=
true
#Just for testing
...
...
@@ -22,8 +22,10 @@ else
end
if
simulated
print
(
"Running simulated process
\n
"
)
R
=
DoubleTankSimulator
(
σ
=
0.001
)
else
print
(
"Running physical process
\n
"
)
using
LabConnections
R
=
DoubleTank
()
end
...
...
@@ -35,7 +37,7 @@ function prbs_experiment(P, gui, pidcontroller, ;amplitude = 1, duration = 10000
y
=
zeros
(
0
:
P
.
h
:
duration
)
u
=
zeros
(
0
:
P
.
h
:
duration
)
n
=
1
#
LabProcesses.initialize(P)
LabProcesses
.
initialize
(
P
)
#initialize(P)
for
(
i
,
t
)
=
enumerate
(
0
:
P
.
h
:
duration
)
@periodically
P
.
h
begin
...
...
src/tanklabgui.jl
View file @
5c4f62d1
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