Commit dafb0137 authored by Jacob Wikmark's avatar Jacob Wikmark
Browse files

minor fixes

parent bb8bb5ee
1
2
3
1
2
3
1
2
3
This source diff could not be displayed because it is too large. You can view the blob instead.
using InteractNext, Mux, Plots, LabProcesses, LabConnections, LabGUI
include("tankgraphic.jl")
include("DoubleTank.jl")
include("tanklabgui.jl")
R = DoubleTank()
inspectdr(show=false)
manual = false
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)
#initialize(P)
for (i,t) = enumerate(0:P.h:duration)
@periodically P.h begin
y[i] = measure(P)[n]
r = gui[:r]
if gui[:tankno]=="Upper"
n = 1
else
n = 2
end
onv = Int.([gui[s]=="On" for s in [:pOn, :iOn, :dOn]])
rv = pidcontroller(r, y[i], onv)
if gui[:mode]=="Automatic"
obs(gui.widgets[:u]).val = clamp(round(rv,2), 0, 1)
control(P, rv)
elseif gui[:mode]=="Manual"
control(P, gui[:u])
#bumpless transfer:
pidcontroller.I = gui[:u]-pidcontroller.P-pidcontroller.D
end
push!(gui, y[i], 1)
push!(gui, r, 2)
push!(gui, pidcontroller.P, 3)
push!(gui, pidcontroller.I, 4)
push!(gui, pidcontroller.D, 5)
push!(gui, pidcontroller.Tot, 6)
end
end
finalize(P)
y,u
end
g1, r1, tp = makegui(R)
webio_serve(page("/", r1), 8004)
......@@ -3,7 +3,23 @@ include("tankgraphic.jl")
include("DoubleTank.jl")
include("tanklabgui.jl")
R = DoubleTankSimulator(σ = 0.001)
const simulated = true
const webservice = true
#Just for testing
global port
try
port += 1
catch
port = 8000
end
if simulated
R = DoubleTankSimulator(σ = 0.001)
else
using LabConnections
R = DoubleTank()
end
inspectdr(show=false)
......@@ -11,16 +27,17 @@ manual = false
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)
#initialize(P)
for (i,t) = enumerate(0:P.h:duration)
@periodically P.h begin
y[i] = measure(P)[P.n]
y[i] = measure(P)[n]
r = gui[:r]
if gui[:tankno]=="Upper"
P.n = 1
n = 1
else
P.n = 2
n = 2
end
onv = Int.([gui[s]=="On" for s in [:pOn, :iOn, :dOn]])
rv = pidcontroller(r, y[i], onv)
......@@ -46,4 +63,11 @@ end
g1, r1, tp = makegui(R)
webio_serve(page("/", r1), 8013)
if webservice
webio_serve(page("/", r1), port)
else
using Blink
w = Window()
body!(w, r1)
end
......@@ -115,6 +115,7 @@ function tank_construct(upper, lower, pump_speed = 1, tnum = 0, r = -1)
end
#=
#Testing of graphic and rudimentary functionality
gui = GUI()
widgets, garbage = @construct for upper in 0:16,
lower in 0:16
......
......@@ -85,12 +85,8 @@ function makegui(P, plottingframerate = 10, guiframerate = 10)
end
#-----------------------------------------------#
on(obs(expcsv)) do val
writecsv("datatanklab.csv", [gui.data[1]
gui.data[2]
gui.data[3]
gui.data[4]
gui.data[5]
gui.data[6]])
writecsv("datatanklab.csv",
[gui.data[1] gui.data[2] gui.data[3] gui.data[4] gui.data[5] gui.data[6]])
print("Data exported to datatanklab.csv\n")
end
......@@ -143,7 +139,8 @@ function makegui(P, plottingframerate = 10, guiframerate = 10)
LabGUI.animate(gui, :svgdummy, 1/guiframerate)
LabGUI.animate(gui, :plotdummy, 1/plottingframerate)
function responder(req)
function responder(req)
@async (sleep(1); gui[:rbox] = "0.5")
gui() #With Mux
end
return (gui, responder, tankpid)
......
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