Commit 4cc4fbb1 authored by Jacob Wikmark's avatar Jacob Wikmark
Browse files

threading

parent 89039c80
using ControlSystems, InteractNext, Plots, LabGUI, Mux
@everywhere using ControlSystems, InteractNext, Plots, LabGUI, Mux
@everywhere inspectdr(show=false, size=(800,800))
inspectdr(show=false, size=(800,800))
setPlotScale("log10")
@everywhere setPlotScale("log10")
const Ω = logspace(-2,2,100)
@everywhere const Ω = logspace(-2,2,100)
struct session
if length(workers())==1
warn("Only one worker!")
end
struct Session
ui::WebIO.Node{WebIO.DOM}
widgets::Array{WebIO.Scope, 1}
defaults::Vector{Float64}
end
function zerosession(s::session)
function zerosession(s::Session)
for i in 1:length(s.widgets)
obs(s.widgets[i])[] = s.defaults[i]
observe(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])
@everywhere function makeplot(ζ, ω, g)
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"])
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))
np = nyquistplot(G, Ω, l=(3,), logspace(-3,3,100), xlims = (-3,3), ylims=(-8,2))
pzp = pzmap(G, xlims = (-2,0), ylims = (-(2),(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"])
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]))
plot(bp,sp,pzp,np, size = (800,800))#, layout = @layout([[a c{0.6h}] b d]))
end
function Session()
ui = InteractNext.@manipulate for ζ = linspace(0,1.5,30), ω = linspace(0.001,2,20), g = linspace(0.001,8,20)
@fetch(makeplot(ζ, ω, g))
end
widgets = [ζ, ω, g]
session(ui, widgets, [obs(i)[] for i in widgets])
Session(ui, widgets, [observe(i)[] for i in widgets])
end
const nsessions = 1000
global n = 1
const sessions = session[]
const sessions = Array{Session,1}(nsessions)
@async for i in 1:nsessions
print("Creating session $i...\n")
push!(sessions, session())
@async (sleep(1.0); print("\nSessions are being created, this may take a while\n"))
for i in 1:nsessions
@async (sessions[i] = Session(); print("Created session $i\n"))
end
function responder(req)
......
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