Commit 45af3490 authored by Jacob Wikmark's avatar Jacob Wikmark
Browse files

splitting up settings and graphics to different construct calls, r => textbox

parent 507ecafc
......@@ -46,4 +46,4 @@ end
g1, r1, tp = makegui(R)
webio_serve(page("/", r1), 8008)
webio_serve(page("/", r1), 8011)
......@@ -78,7 +78,7 @@ function tank_construct(upper, lower, pump_speed = 1, tnum = 0, r = -1)
pd = (pipe_thickness-mouth_width)/2
pt = pipe_thickness/2
if r>=0 && r<=1
if tnum != 0
arrowwidth = 20
end
redarrow = svg_polygon([(upper_x+width, 50+tnum*(height+50)-r*height),
......
function makegui(P, plottingframerate = 10, guiframerate = 10)
#tankpid = PID(1.0, 1.0, R.h, 1.0, 1.0, 0.51, 10, P)
tankpid = PID()
scale = 100/16
boundsupper = (0,1)
boundslower = (-2,2)
maxplotlength = 800
gui = GUI()
#ptfr = P.α/(P.a1*sqrt(2*P.g*(outputrange(P)[1][2]))) #pump to flow ratio
ptfr = 3.8 #the accuracy here isn't very important
widgets, graphic1 = @construct for
u in slider(0:0.01:1, label=" u"),
#This allows external access to the r value
rcont, dummygraphic1 = @construct for
r in slider(0.0:0.01:1.0)
Node(:div)
end
#This contains all settings
w0, dummygraphic2 = @construct for
u in slider(0:0.01:1, label=" um"),
run in button("Run"), #This should only exist in the simulated version
K in slider(0:50, label="K"),
Ti in slider(0:50, label="Ti"),
Td in slider(0:50, label="Td"),
r in slider(0:0.01:1.0, label=" r"),
mode in togglebuttons(["Manual", "Automatic"], label=""),
tankno in togglebuttons(["Upper", "Lower"], label=""),
pOn in togglebuttons(["On", "Off"], label="P"),
iOn in togglebuttons(["On", "Off"], label="I"),
dOn in togglebuttons(["On", "Off"], label="D")
tankpid.K = K
tankpid.Ti = Ti
tankpid.Td = Td
if tankno=="Upper"
tankg = tank_construct(measure(P)..., u*ptfr, 1, r)
elseif tankno=="Lower"
tankg = tank_construct(measure(P)..., u*ptfr, 2, r)
dOn in togglebuttons(["On", "Off"], label="D"),
rbox in textbox(" r ")
if !endswith(rbox, ".") && rbox != "0"
try
obs(r).val = parse(Float64, rbox)
end
end
Node(:div)
end
widgets, graphic1 = @construct for
svgdummy in checkbox(false, label="This button does nothing")
tankpid.K = obs(K)[]
tankpid.Ti = obs(Ti)[]
tankpid.Td = obs(Td)[]
if obs(tankno)[]=="Upper"
tankg = tank_construct(measure(P)..., obs(u)[]*ptfr, 1, obs(r).val)
elseif obs(tankno)[]=="Lower"
tankg = tank_construct(measure(P)..., obs(u)[]*ptfr, 2, obs(r).val)
else
tankg = tank_construct(measure(P)..., u*ptfr)
tankg = tank_construct(measure(P)..., obs(u)[]*ptfr)
end
Node(:div, tankg, id="tanks")
end
w2, graphic2 = @construct for
dummy in checkbox(false, label="This button does nothing")
plotdummy in checkbox(false, label="This button does nothing")
if length(gui.data[1])>maxplotlength
start = length(gui.data[1])-maxplotlength
else
......@@ -62,6 +77,11 @@ function makegui(P, plottingframerate = 10, guiframerate = 10)
end
#-----------------------------------------------#
LabGUI.set!(gui, widgets)
add!(gui, rcont)
add!(gui, w0)
add!(gui, w2)
layout = make_grid(1, 2)
left_element = make_grid(2,1)
settings_element = make_grid(5,1)
......@@ -80,15 +100,12 @@ function makegui(P, plottingframerate = 10, guiframerate = 10)
d_element = setindex_(d_element, dom"div"(widgets[:dOn]), 1, 1)
d_element = setindex_(d_element, dom"div"(widgets[:Td]), 2, 1)
settings_element = setindex_(settings_element, dom"div"(widgets[:run]), 1, 1)
#settings_element = setindex_(settings_element, runbutton, 1, 1)
settings_element = setindex_(settings_element, dom"div"(widgets[:tankno]), 2, 1)
settings_element = setindex_(settings_element, dom"div"(widgets[:mode]), 3, 1)
settings_element = setindex_(settings_element, dom"div"(widgets[:r]), 4, 1)
settings_element = setindex_(settings_element, dom"div"(widgets[:rbox]), 4, 1)
settings_element = setindex_(settings_element, dom"div"(widgets[:u]), 5, 1)
corner_element = setindex_(corner_element, settings_element, 1, 1)
corner_element = setindex_(corner_element, p_element, 1, 2)
corner_element = setindex_(corner_element, i_element, 1, 3)
......@@ -97,16 +114,13 @@ function makegui(P, plottingframerate = 10, guiframerate = 10)
left_element = setindex_(left_element, corner_element, 1, 1)
left_element = setindex_(left_element, graphic2, 2, 1)
layout = setindex_(layout, left_element, 1, 1)
layout = setindex_(layout, graphic1, 1, 2)
layout = setindex_(layout, Node(:div, graphic1, dummygraphic1, dummygraphic2), 1, 2)
LabGUI.set!(gui, widgets)
LabGUI.set!(gui, layout)
add!(gui, w2)
LabGUI.animate(gui, :u, 1/guiframerate)
LabGUI.animate(gui, :dummy, 1/plottingframerate)
LabGUI.animate(gui, :svgdummy, 1/guiframerate)
LabGUI.animate(gui, :plotdummy, 1/plottingframerate)
function responder(req)
gui() #With Mux
end
......
Markdown is supported
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