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

file

parents
using ControlSystems, InteractNext, Plots, LabGUI, Mux
inspectdr(show=false, size=(800,800))
setPlotScale("log10")
const Ω = logspace(-2,2,100)
struct session
ui::WebIO.Node{WebIO.DOM}
widgets::Array{WebIO.Scope, 1}
defaults::Vector{Float64}
end
function zerosession(s::session)
for i in 1:length(s.widgets)
obs(s.widgets[i])[] = s.defaults[i]
end
end
function session()
ui = InteractNext.@manipulate for ζ = linspace(0,1.5,30), ω = linspace(0.001,2,20), g = linspace(0.001,8,20)
G = tf([g*ω^2], [1, 2ζ*ω, ω^2])
bp = bodeplot(G, Ω, l=(3,), ylims=(0.01,20), plotphase=false);
vline!([ω], l=(:dash,:black), text=["w"]);
hline!([g], l=(:dash,:black), text=["g"])
np = nyquistplot(G, Ω, l=(3,), logspace(-3,3,100), xlims = (-3,3), ylims=(-8,2))
pzp = pzmap(G, xlims = (-2,0), ylims = (-(2),(2)))
sp = stepplot(c2d(G,0.1), 20, l=(3,), ylims=(0,8))
hline!([g], l=(:dash,:black), text=["g"])
vline!([2/ω], l=(:dash,:black), text=["2/w"])
plot(bp,sp,pzp,np, size = (800,800))#, layout = @layout([[a c{0.6h}] b d]))
end
widgets = [ζ, ω, g]
session(ui, widgets, [obs(i)[] for i in widgets])
end
const nsessions = 1000
global n = 1
const sessions = session[]
@async for i in 1:nsessions
print("Creating session $i...\n")
push!(sessions, session())
end
function responder(req)
global n
print("User accessing session $n...\n")
outp = Node(:div, "Service unavailable :(\n")
try
outp = sessions[n].ui
@async (sleep(1.0); zerosession(sessions[n]))
catch
print("Failed to serve user session $n\n")
end
n = (n%nsessions)+1
outp
end
webio_serve(page("/", responder), 8020)
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