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

formatting

parent f3f7db1e
......@@ -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
......@@ -3,7 +3,7 @@ include("tankgraphic.jl")
include("DoubleTank.jl")
include("tanklabgui.jl")
const simulated = false
const simulated = true
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
......
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