diff --git a/src/tankgraphic.jl b/src/tankgraphic.jl index be145d4c1bf9773408647124dafd477923107d36..ca25ea465ea94e5542632409ec99561e5ba136c0 100644 --- a/src/tankgraphic.jl +++ b/src/tankgraphic.jl @@ -113,53 +113,3 @@ function tank_construct(upper, lower, pump_speed = 1, tnum = 0, r = -1) id = "tank", attributes = stdattr) end - -#= -#Testing of graphic and rudimentary functionality -gui = GUI() -widgets, garbage = @construct for upper in 0:16, - lower in 0:16 - Node(:div, "", id = "blarf") -end - -set!(gui, widgets) - -dummy, graphic = @construct for tankvar in 0:1 - tank_construct(gui[:upper]/16, gui[:lower]/16) -end - -add!(gui, dummy) - -widgets2, graphic2 = @construct for t in 0:0.1:10 - plot(linspace(0,2pi), sin.(gui[:lower]*linspace(0,2pi))) - plot!(linspace(0,2pi), cos.(gui[:upper]*linspace(0,2pi))) -end - -add!(gui, widgets2) - -layout = make_grid(2,2) -options_grid = make_grid(2,1) -options_grid = setindex_(options_grid, widgets[1], 1, 1) -options_grid = setindex_(options_grid, widgets[2], 2, 1) -layout = setindex_(layout, options_grid, 1, 1) -layout = setindex_(layout, graphic, 1, 2) -layout = setindex_(layout, garbage, 2, 1) -layout = setindex_(layout, graphic2, 2, 2) - -set!(gui, layout) - - -function initialize() - print("Initializing...\n") - #WebIO.newid() - LabGUI.animate(gui, [:tankvar, :t], [:upper, :lower]) - #animate(gui, :tankvar, 1) -end - -function responder(req) - initialize() - gui.dom -end - -webio_serve(page("/", responder), 8004) -=# diff --git a/src/tanklabgui.jl b/src/tanklabgui.jl index 6b6e555b10919802417f9820ddd3b12b776b7fb6..1e40fbf36f6d7599ad4a27527704cdedbec7ea12 100644 --- a/src/tanklabgui.jl +++ b/src/tanklabgui.jl @@ -1,6 +1,5 @@ function makegui(P, plottingframerate = 10, guiframerate = 10) tankpid = PID() - scale = 100/16 boundsupper = (0,1) boundslower = (-2,2) maxplotlength = 800 @@ -140,8 +139,8 @@ function makegui(P, plottingframerate = 10, guiframerate = 10) LabGUI.animate(gui, :svgdummy, 1/guiframerate) LabGUI.animate(gui, :plotdummy, 1/plottingframerate) function responder(req) - @async (sleep(1); gui[:rbox] = "0.5") - gui() #With Mux + @async (sleep(1); gui[:rbox] = "0.5") #Inits r textbox, must be done after dom is loaded in browser + gui() end return (gui, responder, tankpid) end diff --git a/test/runtests.jl b/test/runtests.jl index 2ab220e94ec034981485f816074281134c22e601..00d00ef6fb98fd632d710095081d21ba95399785 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,57 @@ -using DoubleTank -using Base.Test +#using DoubleTank +using LabGUI, InteractNext, Mux, Plots +#using Base.Test -# write your own tests here -@test 1 == 2 +## write your own tests here +#@test 1 == 2 + +print("\nTesting of graphics and rudimentary functionality\n") +print("What should work:\n") +print("- Sliders should affect the water levels in the SVG tanks as well as the flow (which should be animated)\n") +print("- A plot should be shown somewhere\n\n") + +gui = GUI() +widgets, garbage = @construct for upper in 0:16, + lower in 0:16 + Node(:div, "", id = "blarf") +end + +LabGUI.set!(gui, widgets) + +dummy, graphic = @construct for tankvar in 0:1 + tank_construct(gui[:upper]/16, gui[:lower]/16) +end + +LabGUI.add!(gui, dummy) + +widgets2, graphic2 = @construct for t in 0:0.1:10 + plot(linspace(0,2pi), sin.(gui[:lower]*linspace(0,2pi))) + plot!(linspace(0,2pi), cos.(gui[:upper]*linspace(0,2pi))) +end + +LabGUI.add!(gui, widgets2) + +layout = make_grid(2,2) +options_grid = make_grid(2,1) +options_grid = setindex_(options_grid, widgets[1], 1, 1) +options_grid = setindex_(options_grid, widgets[2], 2, 1) +layout = setindex_(layout, options_grid, 1, 1) +layout = setindex_(layout, graphic, 1, 2) +layout = setindex_(layout, garbage, 2, 1) +layout = setindex_(layout, graphic2, 2, 2) + +LabGUI.set!(gui, layout) + + +function initialize() + print("Initializing...\n") + #LabGUI.animate(gui, [:tankvar, :t], [:upper, :lower]) + LabGUI.animate(gui, :tankvar, 0.2) +end + +function responder(req) + initialize() + gui() +end + +webio_serve(page("/", responder), 8009)