Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grains
grains-web
Commits
2f67e6cc
Commit
2f67e6cc
authored
May 29, 2017
by
Jens-Christian Fischer
Browse files
Added Msg Counter and msg/sec information
parent
16adf8d0
Changes
12
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
2f67e6cc
...
@@ -22,3 +22,5 @@ erl_crash.dump
...
@@ -22,3 +22,5 @@ erl_crash.dump
# secrets file as long as you replace its contents by environment
# secrets file as long as you replace its contents by environment
# variables.
# variables.
/config/prod.secret.exs
/config/prod.secret.exs
.DS_Store
/log
lib/grains.ex
View file @
2f67e6cc
...
@@ -13,6 +13,7 @@ defmodule Grains do
...
@@ -13,6 +13,7 @@ defmodule Grains do
# Start your own worker by calling: Grains.Worker.start_link(arg1, arg2, arg3)
# Start your own worker by calling: Grains.Worker.start_link(arg1, arg2, arg3)
# worker(Grains.Worker, [arg1, arg2, arg3]),
# worker(Grains.Worker, [arg1, arg2, arg3]),
worker
(
Grains
.
CounterAgent
,
[]),
worker
(
Grains
.
CounterAgent
,
[]),
worker
(
Grains
.
MsgCounterAgent
,
[]),
worker
(
Grains
.
StatefulMap
,
[]),
worker
(
Grains
.
StatefulMap
,
[]),
worker
(
Grains
.
Beat
,
[
60
]),
worker
(
Grains
.
Beat
,
[
60
]),
supervisor
(
Grains
.
Presence
,
[]),
supervisor
(
Grains
.
Presence
,
[]),
...
...
mix.exs
View file @
2f67e6cc
...
@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
...
@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def
project
do
def
project
do
[
app:
:grains
,
[
app:
:grains
,
version:
"0.0.9
7
"
,
version:
"0.0.9
8
"
,
elixir:
"~> 1.2"
,
elixir:
"~> 1.2"
,
elixirc_paths:
elixirc_paths
(
Mix
.
env
),
elixirc_paths:
elixirc_paths
(
Mix
.
env
),
compilers:
[
:phoenix
,
:gettext
]
++
Mix
.
compilers
,
compilers:
[
:phoenix
,
:gettext
]
++
Mix
.
compilers
,
...
...
web/channels/acceleration_channel.ex
View file @
2f67e6cc
...
@@ -11,7 +11,8 @@ defmodule Grains.AccelerationChannel do
...
@@ -11,7 +11,8 @@ defmodule Grains.AccelerationChannel do
end
end
def
handle_in
(
"acceleration"
,
params
,
socket
)
do
def
handle_in
(
"acceleration"
,
params
,
socket
)
do
Logger
.
info
(
"acceleration
#{
inspect
(
params
)
}
"
)
Grains
.
MsgCounterAgent
.
click
()
uuid
=
socket
.
assigns
.
user_uuid
uuid
=
socket
.
assigns
.
user_uuid
z
=
params
[
"z"
]
z
=
params
[
"z"
]
...
...
web/channels/xy_channel.ex
View file @
2f67e6cc
...
@@ -3,8 +3,8 @@ defmodule Grains.XyChannel do
...
@@ -3,8 +3,8 @@ defmodule Grains.XyChannel do
require
Logger
require
Logger
alias
Grains
.
StatefulMap
alias
Grains
.
{
StatefulMap
,
MsgCounterAgent
}
alias
Grains
.
ValueView
def
join
(
"xy:"
<>
_xy_id
,
_params
,
socket
)
do
def
join
(
"xy:"
<>
_xy_id
,
_params
,
socket
)
do
Logger
.
info
(
"joined xy"
)
Logger
.
info
(
"joined xy"
)
...
@@ -16,6 +16,7 @@ defmodule Grains.XyChannel do
...
@@ -16,6 +16,7 @@ defmodule Grains.XyChannel do
end
end
def
handle_in
(
"xy"
,
params
,
socket
)
do
def
handle_in
(
"xy"
,
params
,
socket
)
do
nr
=
MsgCounterAgent
.
click
()
uuid
=
socket
.
assigns
.
user_uuid
uuid
=
socket
.
assigns
.
user_uuid
x
=
params
[
"x"
]
x
=
params
[
"x"
]
y
=
params
[
"y"
]
y
=
params
[
"y"
]
...
@@ -26,7 +27,7 @@ defmodule Grains.XyChannel do
...
@@ -26,7 +27,7 @@ defmodule Grains.XyChannel do
}
}
)
)
Grains
.
Endpoint
.
broadcast
"visuals:data"
,
"velocity"
,
%{
user:
uuid
,
dx:
x
,
dy:
y
}
Grains
.
Endpoint
.
broadcast
"visuals:data"
,
"velocity"
,
%{
user:
uuid
,
dx:
x
,
dy:
y
,
msgs:
nr
}
{
:reply
,
:ok
,
socket
}
{
:reply
,
:ok
,
socket
}
...
...
web/static/css/app.css
View file @
2f67e6cc
...
@@ -8,6 +8,37 @@
...
@@ -8,6 +8,37 @@
margin-top
:
40px
;
margin-top
:
40px
;
}
}
.mixerPanel
{
display
:
block
;
position
:
fixed
;
top
:
50px
;
right
:
0
;
height
:
300px
;
width
:
300px
;
}
#counter
{
position
:
fixed
;
top
:
400px
;
right
:
0
;
width
:
300
p
;
height
:
200px
;
background-color
:
#ddd
;
font-size
:
2em
;
margin
:
auto
;
}
#counter
table
th
{
width
:
5em
;
}
#counter
table
td
{
text-align
:
right
;
width
:
5em
;
}
.interfacePanel_hidden
{
.interfacePanel_hidden
{
display
:
none
;
display
:
none
;
}
}
...
...
web/static/js/bpm.js
View file @
2f67e6cc
...
@@ -8,69 +8,69 @@ let BpmPanel = {
...
@@ -8,69 +8,69 @@ let BpmPanel = {
init
(
socket
,
domId
)
{
init
(
socket
,
domId
)
{
if
(
!
document
.
getElementById
(
domId
))
{
if
(
!
document
.
getElementById
(
domId
))
{
console
.
log
(
"
No element found:
"
+
domId
);
console
.
log
(
"
No element found:
"
+
domId
);
return
;
return
;
}
}
let
that
=
this
;
let
that
=
this
;
socket
.
connect
();
socket
.
connect
();
this
.
sliderChannel
=
socket
.
channel
(
"
conductor:
"
+
domId
);
this
.
sliderChannel
=
socket
.
channel
(
"
conductor:
"
+
domId
);
this
.
sliderChannel
.
join
()
this
.
sliderChannel
.
join
()
.
receive
(
"
ok
"
,
response
=>
{
.
receive
(
"
ok
"
,
response
=>
{
that
.
bpmLabel
.
setValue
(
response
.
bpm
);
that
.
bpmSlider
.
setValue
(
response
.
bpm
);
})
.
receive
(
"
error
"
,
reason
=>
console
.
log
(
"
join failed
"
,
reason
));
this
.
sliderChannel
.
on
(
"
set_bpm
"
,
response
=>
{
that
.
bpmLabel
.
setValue
(
response
.
bpm
);
that
.
bpmLabel
.
setValue
(
response
.
bpm
);
console
.
log
(
"
set bpm
"
,
response
.
bpm
);
that
.
bpmSlider
.
setValue
(
response
.
bpm
);
});
})
.
receive
(
"
error
"
,
reason
=>
console
.
log
(
"
join failed
"
,
reason
));
this
.
sliderChannel
.
on
(
"
set_bpm
"
,
response
=>
{
that
.
bpmLabel
.
setValue
(
response
.
bpm
);
console
.
log
(
"
set bpm
"
,
response
.
bpm
);
});
let
a
=
new
Interface
.
Panel
({
let
a
=
new
Interface
.
Panel
({
container
:
document
.
getElementById
(
domId
)
container
:
document
.
getElementById
(
domId
)
});
});
this
.
bpmLabel
=
new
Interface
.
Label
({
this
.
bpmLabel
=
new
Interface
.
Label
({
bounds
:
[.
8
,
.
1
,
.
2
,
.
9
],
bounds
:
[.
8
,
.
1
,
.
2
,
.
9
],
hAlign
:
'
center
'
,
hAlign
:
'
center
'
,
value
:
'
0
'
,
value
:
'
0
'
,
size
:
28
,
size
:
28
,
style
:
'
bold
'
style
:
'
bold
'
});
});
this
.
bpmSlider
=
new
Interface
.
Slider
({
this
.
bpmSlider
=
new
Interface
.
Slider
({
bounds
:
[.
05
,
.
05
,
.
7
,
0.9
],
bounds
:
[.
05
,
.
05
,
.
7
,
0.9
],
label
:
'
BPM
'
,
label
:
'
BPM
'
,
min
:
30
,
min
:
30
,
max
:
180
,
max
:
180
,
isVertical
:
false
,
isVertical
:
false
,
onvaluechange
:
function
()
{
onvaluechange
:
function
()
{
that
.
send_value
(
this
.
value
);
that
.
send_value
(
this
.
value
);
}
}
});
});
a
.
add
(
this
.
bpmSlider
,
this
.
bpmLabel
);
a
.
add
(
this
.
bpmSlider
,
this
.
bpmLabel
);
a
.
background
=
'
black
'
;
a
.
background
=
'
black
'
;
console
.
log
(
"
initialized bpm
"
);
console
.
log
(
"
initialized bpm
"
);
},
},
send_value
(
value
)
{
send_value
(
value
)
{
let
payload
=
{
slider
:
'
bpm
'
,
value
:
value
};
let
payload
=
{
slider
:
'
bpm
'
,
value
:
value
};
this
.
sliderChannel
.
push
(
"
master
"
,
payload
)
this
.
sliderChannel
.
push
(
"
master
"
,
payload
)
.
receive
(
"
error
"
,
e
=>
console
.
log
(
e
));
.
receive
(
"
error
"
,
e
=>
console
.
log
(
e
));
},
},
};
};
...
...
web/static/js/mixerpanel.js
View file @
2f67e6cc
...
@@ -2,7 +2,6 @@ import Interface from "interface.js";
...
@@ -2,7 +2,6 @@ import Interface from "interface.js";
let
MixerPanel
=
{
let
MixerPanel
=
{
visualsChannel
:
null
,
presence
:
{},
presence
:
{},
sliders
:
{},
sliders
:
{},
...
@@ -16,18 +15,8 @@ let MixerPanel = {
...
@@ -16,18 +15,8 @@ let MixerPanel = {
let
that
=
this
;
let
that
=
this
;
socket
.
connect
();
console
.
log
(
presence
);
console
.
log
(
presence
);
this
.
presence
=
presence
;
this
.
presence
=
presence
;
this
.
sliderChannel
=
socket
.
channel
(
"
slider:
"
+
domId
);
this
.
sliderChannel
.
join
()
.
receive
(
"
ok
"
,
resp
=>
{
resp
.
values
.
forEach
(
(
element
)
=>
{
this
.
setSliderValue
(
element
);
}
);
})
.
receive
(
"
error
"
,
reason
=>
console
.
log
(
"
join failed
"
,
reason
));
let
a
=
new
Interface
.
Panel
({
let
a
=
new
Interface
.
Panel
({
...
...
web/static/js/presencesketch.js
View file @
2f67e6cc
...
@@ -296,8 +296,8 @@ Master.prototype.send_osc = function() {
...
@@ -296,8 +296,8 @@ Master.prototype.send_osc = function() {
let
v
=
[
0
,
0
];
let
v
=
[
0
,
0
];
if
(
this
.
absolute
)
{
if
(
this
.
absolute
)
{
v
[
0
]
=
(
this
.
position
.
x
*
PresenceSketch
.
scale_x
)
+
3.
14
;
v
[
0
]
=
(
this
.
position
.
x
*
PresenceSketch
.
scale_x
)
+
3.
0
;
v
[
1
]
=
(
this
.
position
.
y
*
PresenceSketch
.
scale_y
)
+
3.
14
;
v
[
1
]
=
(
this
.
position
.
y
*
PresenceSketch
.
scale_y
)
+
3.
0
;
}
else
{
}
else
{
v
=
this
.
velocity
.
array
();
v
=
this
.
velocity
.
array
();
...
@@ -581,8 +581,8 @@ let PresenceSketch = {
...
@@ -581,8 +581,8 @@ let PresenceSketch = {
PresenceSketch
.
width
=
w
;
PresenceSketch
.
width
=
w
;
PresenceSketch
.
height
=
h
;
PresenceSketch
.
height
=
h
;
PresenceSketch
.
scale_x
=
-
6.
28
/
w
;
PresenceSketch
.
scale_x
=
-
6.
0
/
w
;
PresenceSketch
.
scale_y
=
-
6.
28
/
h
;
PresenceSketch
.
scale_y
=
-
6.
0
/
h
;
PresenceSketch
.
osc
=
new
OSC
();
PresenceSketch
.
osc
=
new
OSC
();
PresenceSketch
.
osc
.
open
();
// connect to ws://localhost:8080
PresenceSketch
.
osc
.
open
();
// connect to ws://localhost:8080
...
...
web/static/js/views/conductor.js
View file @
2f67e6cc
...
@@ -6,6 +6,8 @@ import socket from "../socket";
...
@@ -6,6 +6,8 @@ import socket from "../socket";
import
BpmPanel
from
"
../bpm.js
"
;
import
BpmPanel
from
"
../bpm.js
"
;
import
PresenceSketch
from
"
../presencesketch
"
;
import
PresenceSketch
from
"
../presencesketch
"
;
import
MixerPanel
from
"
../mixerpanel
"
;
import
MixerPanel
from
"
../mixerpanel
"
;
import
Counter
from
"
../counter
"
;
...
@@ -15,8 +17,9 @@ export default class View extends MainView {
...
@@ -15,8 +17,9 @@ export default class View extends MainView {
BpmPanel
.
init
(
socket
,
"
bpmPanel
"
);
BpmPanel
.
init
(
socket
,
"
bpmPanel
"
);
PresenceSketch
.
init
(
socket
,
"
sketch
"
,
window
.
innerWidth
,
window
.
innerHeight
);
PresenceSketch
.
init
(
socket
,
"
sketch
"
,
window
.
innerWidth
-
300
,
window
.
innerHeight
);
MixerPanel
.
init
(
socket
,
"
mixer
"
,
[
"
circle
"
,
"
square
"
,
"
triangle
"
,
"
star
"
],
PresenceSketch
);
MixerPanel
.
init
(
socket
,
"
mixer
"
,
[
"
circle
"
,
"
square
"
,
"
triangle
"
,
"
star
"
],
PresenceSketch
);
Counter
.
init
(
"
counter
"
);
...
@@ -25,8 +28,9 @@ export default class View extends MainView {
...
@@ -25,8 +28,9 @@ export default class View extends MainView {
let
visuals
=
socket
.
channel
(
"
visuals:data
"
,
{});
let
visuals
=
socket
.
channel
(
"
visuals:data
"
,
{});
visuals
.
on
(
"
velocity
"
,
state
=>
{
visuals
.
on
(
"
velocity
"
,
state
=>
{
// console.log("velocity: ", state);
// console.log("velocity: ", state);
PresenceSketch
.
set_velocity
(
state
.
user
,
state
.
dy
,
state
.
dx
);
PresenceSketch
.
set_velocity
(
state
.
user
,
state
.
dy
,
state
.
dx
);
Counter
.
set_nr_messages
(
state
.
msgs
);
});
});
visuals
.
on
(
"
acceleration
"
,
state
=>
{
visuals
.
on
(
"
acceleration
"
,
state
=>
{
...
@@ -47,7 +51,7 @@ export default class View extends MainView {
...
@@ -47,7 +51,7 @@ export default class View extends MainView {
unmount
()
{
unmount
()
{
super
.
unmount
();
super
.
unmount
();
Mixer
.
unmount
();
console
.
log
(
"
ConductorIndexView unmounted
"
);
console
.
log
(
"
ConductorIndexView unmounted
"
);
}
}
...
...
web/static/js/xypanel.js
View file @
2f67e6cc
...
@@ -11,6 +11,7 @@ let XyPanel = {
...
@@ -11,6 +11,7 @@ let XyPanel = {
old_y
:
0
,
old_y
:
0
,
dot_id
:
'
na
'
,
dot_id
:
'
na
'
,
timer
:
{},
timer
:
{},
initalized
:
false
,
init
(
socket
,
domId
,
width
)
{
init
(
socket
,
domId
,
width
)
{
...
@@ -28,6 +29,9 @@ let XyPanel = {
...
@@ -28,6 +29,9 @@ let XyPanel = {
this
.
xyChannel
.
join
()
this
.
xyChannel
.
join
()
.
receive
(
"
ok
"
,
resp
=>
{
.
receive
(
"
ok
"
,
resp
=>
{
if
(
this
.
initialized
)
{
return
true
;
}
this
.
initialized
=
true
;
console
.
log
(
"
join xy:
"
,
resp
.
dot_id
);
console
.
log
(
"
join xy:
"
,
resp
.
dot_id
);
that
.
dot_id
=
resp
.
dot_id
;
that
.
dot_id
=
resp
.
dot_id
;
var
a
=
new
Interface
.
Panel
({
background
:
"
#000
"
,
container
:
element
});
var
a
=
new
Interface
.
Panel
({
background
:
"
#000
"
,
container
:
element
});
...
@@ -52,7 +56,7 @@ let XyPanel = {
...
@@ -52,7 +56,7 @@ let XyPanel = {
// this.setSliderValue(element);
// this.setSliderValue(element);
// } );
// } );
})
})
.
receive
(
"
error
"
,
reason
=>
console
.
log
(
"
join failed
"
,
reason
));
.
receive
(
"
error
"
,
reason
=>
console
.
log
(
reason
));
console
.
log
(
width
);
console
.
log
(
width
);
element
.
style
.
width
=
width
;
element
.
style
.
width
=
width
;
element
.
style
.
height
=
width
;
element
.
style
.
height
=
width
;
...
@@ -72,7 +76,7 @@ let XyPanel = {
...
@@ -72,7 +76,7 @@ let XyPanel = {
};
};
// console.log(payload);
// console.log(payload);
this
.
xyChannel
.
push
(
"
xy
"
,
payload
)
this
.
xyChannel
.
push
(
"
xy
"
,
payload
)
.
receive
(
"
error
"
,
e
=>
console
.
log
(
e
));
.
receive
(
"
error
"
,
e
=>
console
.
log
(
"
foo
"
));
...
...
web/templates/conductor/index.html.eex
View file @
2f67e6cc
...
@@ -2,7 +2,20 @@
...
@@ -2,7 +2,20 @@
<!-- <div id="bpmPanel" class="bpmPanel"></div> -->
<!-- <div id="bpmPanel" class="bpmPanel"></div> -->
<div
id=
"sketch"
></div>
<div
id=
"sketch"
></div>
<div
id=
"mixer"
class=
"interfacePanel"
></div>
<div
id=
"mixer"
class=
"mixerPanel"
></div>
<div
id=
"counter"
>
<table>
<tr>
<th>
Msg rec:
</th>
<td><span
id=
"counter_msg"
></span></td>
</tr>
<tr>
<th>
Msg/sec:
</th>
<td><span
id=
"counter_mps"
></span></td>
</tr>
</table>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-8"
>
<div
class=
"col-md-8"
>
<ul
id=
"UserList"
class=
"list-unstyled"
>
<ul
id=
"UserList"
class=
"list-unstyled"
>
...
...
Write
Preview
Markdown
is supported
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