Commit 5c4f62d1 authored by Jacob Wikmark's avatar Jacob Wikmark
Browse files

formatting

parent f3f7db1e
...@@ -12,7 +12,7 @@ using Parameters ...@@ -12,7 +12,7 @@ using Parameters
#struct BC #struct BC
#ar::Array{Float64, 1} #ar::Array{Float64, 1}
#end #end
#bc = BC([]) #bc = BC([])
...@@ -246,9 +246,10 @@ function qu(p, u) ...@@ -246,9 +246,10 @@ function qu(p, u)
end end
function control(p::DoubleTankSimulator, u::Number) 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 @unpack a1, a2, g, x, A, h, scale = p
x *= scale x *= scale
#The simulator should operate on physical values but u should be in [0,1]
u = clamp(u, inputrange(p)[1]...) u = clamp(u, inputrange(p)[1]...)
qut = a1*sqrt(2*g*x[1]) #m^3/s qut = a1*sqrt(2*g*x[1]) #m^3/s
...@@ -265,8 +266,8 @@ function control(p::DoubleTankSimulator, u::Number) ...@@ -265,8 +266,8 @@ function control(p::DoubleTankSimulator, u::Number)
if(-dA2*h>x[2]*A) if(-dA2*h>x[2]*A)
dA2 = -x[2]*A/h dA2 = -x[2]*A/h
end end
x[1] += (dA1*h)/A #m change later x[1] += (dA1*h)/A
x[2] += (dA2*h)/A #m change later x[2] += (dA2*h)/A
x /= scale x /= scale
@pack p = a1, a2, g, x, A, h @pack p = a1, a2, g, x, A, h
...@@ -277,5 +278,8 @@ measure(p::DoubleTankSimulator) = p.x + p.σ*p.scale*randn(2) ...@@ -277,5 +278,8 @@ measure(p::DoubleTankSimulator) = p.x + p.σ*p.scale*randn(2)
LabProcesses.initialize(p::DoubleTankSimulator) = nothing 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
...@@ -3,7 +3,7 @@ include("tankgraphic.jl") ...@@ -3,7 +3,7 @@ include("tankgraphic.jl")
include("DoubleTank.jl") include("DoubleTank.jl")
include("tanklabgui.jl") include("tanklabgui.jl")
const simulated = false const simulated = true
const webservice = true const webservice = true
#Just for testing #Just for testing
...@@ -22,8 +22,10 @@ else ...@@ -22,8 +22,10 @@ else
end end
if simulated if simulated
print("Running simulated process\n")
R = DoubleTankSimulator(σ = 0.001) R = DoubleTankSimulator(σ = 0.001)
else else
print("Running physical process\n")
using LabConnections using LabConnections
R = DoubleTank() R = DoubleTank()
end end
...@@ -35,7 +37,7 @@ function prbs_experiment(P, gui, pidcontroller, ;amplitude = 1, duration = 10000 ...@@ -35,7 +37,7 @@ function prbs_experiment(P, gui, pidcontroller, ;amplitude = 1, duration = 10000
y = zeros(0:P.h:duration) y = zeros(0:P.h:duration)
u = zeros(0:P.h:duration) u = zeros(0:P.h:duration)
n = 1 n = 1
#LabProcesses.initialize(P) LabProcesses.initialize(P)
#initialize(P) #initialize(P)
for (i,t) = enumerate(0:P.h:duration) for (i,t) = enumerate(0:P.h:duration)
@periodically P.h begin @periodically P.h begin
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment