Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
processes
DoubleTankLab.jl
Commits
36689447
Commit
36689447
authored
Mar 08, 2018
by
Jacob Wikmark
Browse files
testing
parent
c4df1bdc
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/tankgraphic.jl
View file @
36689447
...
...
@@ -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)
=#
src/tanklabgui.jl
View file @
36689447
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
test/runtests.jl
View file @
36689447
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
(
"
\n
Testing 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
,
2
pi
),
sin
.
(
gui
[
:
lower
]
*
linspace
(
0
,
2
pi
)))
plot!
(
linspace
(
0
,
2
pi
),
cos
.
(
gui
[
:
upper
]
*
linspace
(
0
,
2
pi
)))
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment