|
|
@ -19,88 +19,84 @@
|
|
|
|
var ws;
|
|
|
|
var ws;
|
|
|
|
var typeId = 3;
|
|
|
|
var typeId = 3;
|
|
|
|
var batteryId = 5;
|
|
|
|
var batteryId = 5;
|
|
|
|
var gps_latId = 6;
|
|
|
|
|
|
|
|
var gps_longId = 7;
|
|
|
|
var accelerometer_xId = 11;
|
|
|
|
var accelerometer_xId = 8;
|
|
|
|
var accelerometer_yId = 12;
|
|
|
|
var accelerometer_yId = 9;
|
|
|
|
var accelerometer_zId = 13;
|
|
|
|
var accelerometer_zId = 10;
|
|
|
|
|
|
|
|
var magnetic_xId = 11;
|
|
|
|
var magnetic_xId = 16;
|
|
|
|
var magnetic_yId = 12;
|
|
|
|
var magnetic_yId = 17;
|
|
|
|
var magnetic_zId = 13;
|
|
|
|
var magnetic_zId = 18;
|
|
|
|
var gyroscope_xId = 14;
|
|
|
|
|
|
|
|
var gyroscope_yId = 15;
|
|
|
|
var gyroscope_xId = 19;
|
|
|
|
var gyroscope_zId = 16;
|
|
|
|
var gyroscope_yId = 20;
|
|
|
|
var lightId = 17;
|
|
|
|
var gyroscope_zId = 21;
|
|
|
|
var pressureId = 18;
|
|
|
|
|
|
|
|
var proximityId = 19;
|
|
|
|
var lightId = 22;
|
|
|
|
var gravity_xId = 20;
|
|
|
|
|
|
|
|
var gravity_yId = 21;
|
|
|
|
var pressureId = 23;
|
|
|
|
var gravity_zId = 22;
|
|
|
|
|
|
|
|
var rotation_xId = 23;
|
|
|
|
var proximityId = 24;
|
|
|
|
var rotation_yId = 24;
|
|
|
|
|
|
|
|
var rotation_zId = 25;
|
|
|
|
var gravity_xId = 25;
|
|
|
|
var wordId = 26;
|
|
|
|
var gravity_yId = 26;
|
|
|
|
var word_sessionIdId = 27;
|
|
|
|
var gravity_zId = 27;
|
|
|
|
var word_statusId = 28;
|
|
|
|
|
|
|
|
|
|
|
|
var rotation_xId = 28;
|
|
|
|
var battery;
|
|
|
|
var rotation_yId = 29;
|
|
|
|
|
|
|
|
var rotation_zId = 30;
|
|
|
|
|
|
|
|
|
|
|
|
var batteryData = [];
|
|
|
|
var batteryData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var light;
|
|
|
|
|
|
|
|
var lightData = [];
|
|
|
|
var lightData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var pressure;
|
|
|
|
|
|
|
|
var pressureData = [];
|
|
|
|
var pressureData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var proximity;
|
|
|
|
|
|
|
|
var proximityData = [];
|
|
|
|
var proximityData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var accelerometer;
|
|
|
|
|
|
|
|
var accelerometer_xData = [];
|
|
|
|
var accelerometer_xData = [];
|
|
|
|
var accelerometer_yData = [];
|
|
|
|
var accelerometer_yData = [];
|
|
|
|
var accelerometer_zData = [];
|
|
|
|
var accelerometer_zData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var magnetic;
|
|
|
|
|
|
|
|
var magnetic_xData = [];
|
|
|
|
var magnetic_xData = [];
|
|
|
|
var magnetic_yData = [];
|
|
|
|
var magnetic_yData = [];
|
|
|
|
var magnetic_zData = [];
|
|
|
|
var magnetic_zData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var gyroscope;
|
|
|
|
|
|
|
|
var gyroscope_xData = [];
|
|
|
|
var gyroscope_xData = [];
|
|
|
|
var gyroscope_yData = [];
|
|
|
|
var gyroscope_yData = [];
|
|
|
|
var gyroscope_zData = [];
|
|
|
|
var gyroscope_zData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var gravity;
|
|
|
|
|
|
|
|
var gravity_xData = [];
|
|
|
|
var gravity_xData = [];
|
|
|
|
var gravity_yData = [];
|
|
|
|
var gravity_yData = [];
|
|
|
|
var gravity_zData = [];
|
|
|
|
var gravity_zData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var rotation;
|
|
|
|
|
|
|
|
var rotation_xData = [];
|
|
|
|
var rotation_xData = [];
|
|
|
|
var rotation_yData = [];
|
|
|
|
var rotation_yData = [];
|
|
|
|
var rotation_zData = [];
|
|
|
|
var rotation_zData = [];
|
|
|
|
|
|
|
|
|
|
|
|
var palette = new Rickshaw.Color.Palette({scheme: "classic9"});
|
|
|
|
var graphMap = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var palette = new Rickshaw.Color.Palette({scheme: "munin"});
|
|
|
|
|
|
|
|
|
|
|
|
$(window).load(function () {
|
|
|
|
$(window).load(function () {
|
|
|
|
|
|
|
|
|
|
|
|
battery = lineGraph("battery", batteryData);
|
|
|
|
graphMap["battery"]=lineGraph("battery", batteryData);
|
|
|
|
light = lineGraph("light", lightData);
|
|
|
|
graphMap["light"]=lineGraph("light", lightData);
|
|
|
|
pressure = lineGraph("pressure", pressureData);
|
|
|
|
graphMap["pressure"]=lineGraph("pressure", pressureData);
|
|
|
|
proximity = lineGraph("proximity", proximityData);
|
|
|
|
graphMap["proximity"]=lineGraph("proximity", proximityData);
|
|
|
|
accelerometer = threeDlineGraph("accelerometer", accelerometer_xData, accelerometer_yData, accelerometer_zData);
|
|
|
|
graphMap["accelerometer"]=threeDlineGraph("accelerometer", accelerometer_xData, accelerometer_yData, accelerometer_zData);
|
|
|
|
magnetic = threeDlineGraph("magnetic", magnetic_xData, magnetic_yData, magnetic_zData);
|
|
|
|
graphMap["magnetic"]=threeDlineGraph("magnetic", magnetic_xData, magnetic_yData, magnetic_zData);
|
|
|
|
gyroscope = threeDlineGraph("gyroscope", gyroscope_xData, gyroscope_yData, gyroscope_zData);
|
|
|
|
graphMap["gyroscope"]=threeDlineGraph("gyroscope", gyroscope_xData, gyroscope_yData, gyroscope_zData);
|
|
|
|
gravity = threeDlineGraph("gravity", gravity_xData, gravity_yData, gravity_zData);
|
|
|
|
graphMap["gravity"]=threeDlineGraph("gravity", gravity_xData, gravity_yData, gravity_zData);
|
|
|
|
rotation = threeDlineGraph("rotation", rotation_xData, rotation_yData, rotation_zData);
|
|
|
|
graphMap["rotation"]=threeDlineGraph("rotation", rotation_xData, rotation_yData, rotation_zData);
|
|
|
|
|
|
|
|
|
|
|
|
var websocketUrl = $("#div-chart").data("websocketurl");
|
|
|
|
var websocketUrl = $("#stat-section").data("websocketurl");
|
|
|
|
connect(websocketUrl)
|
|
|
|
connect(websocketUrl)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(window).unload(function () {
|
|
|
|
window.onbeforeunload = function() {
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function threeDlineGraph(type, xChartData, yChartData, zChartData) {
|
|
|
|
function threeDlineGraph(type, xChartData, yChartData, zChartData) {
|
|
|
|
var tNow = new Date().getTime() / 1000;
|
|
|
|
var tNow = new Date().getTime() / 1000;
|
|
|
@ -119,11 +115,14 @@ function threeDlineGraph(type, xChartData, yChartData, zChartData) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $elem = $("#chart-" + type);
|
|
|
|
|
|
|
|
|
|
|
|
var graph = new Rickshaw.Graph({
|
|
|
|
var graph = new Rickshaw.Graph({
|
|
|
|
element: document.getElementById("chart-" + type),
|
|
|
|
element: $elem[0],
|
|
|
|
width: $("#div-chart").width() - 50,
|
|
|
|
width: $elem.width() - 100,
|
|
|
|
height: 300,
|
|
|
|
height: 300,
|
|
|
|
renderer: "line",
|
|
|
|
renderer: "line",
|
|
|
|
|
|
|
|
interpolation: "linear",
|
|
|
|
padding: {top: 0.2, left: 0.0, right: 0.0, bottom: 0.2},
|
|
|
|
padding: {top: 0.2, left: 0.0, right: 0.0, bottom: 0.2},
|
|
|
|
xScale: d3.time.scale(),
|
|
|
|
xScale: d3.time.scale(),
|
|
|
|
series: [
|
|
|
|
series: [
|
|
|
@ -133,14 +132,20 @@ function threeDlineGraph(type, xChartData, yChartData, zChartData) {
|
|
|
|
]
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
graph.render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var xAxis = new Rickshaw.Graph.Axis.Time({
|
|
|
|
var xAxis = new Rickshaw.Graph.Axis.Time({
|
|
|
|
graph: graph
|
|
|
|
graph: graph
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
xAxis.render();
|
|
|
|
xAxis.render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new Rickshaw.Graph.Axis.Y({
|
|
|
|
|
|
|
|
graph: graph,
|
|
|
|
|
|
|
|
orientation: 'left',
|
|
|
|
|
|
|
|
height: 300,
|
|
|
|
|
|
|
|
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
|
|
|
|
|
|
|
|
element: document.getElementById("y-axis-"+type)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
new Rickshaw.Graph.Legend({
|
|
|
|
new Rickshaw.Graph.Legend({
|
|
|
|
graph: graph,
|
|
|
|
graph: graph,
|
|
|
|
element: document.getElementById('legend-' + type)
|
|
|
|
element: document.getElementById('legend-' + type)
|
|
|
@ -150,6 +155,8 @@ function threeDlineGraph(type, xChartData, yChartData, zChartData) {
|
|
|
|
graph: graph
|
|
|
|
graph: graph
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
graph.render();
|
|
|
|
|
|
|
|
|
|
|
|
return graph;
|
|
|
|
return graph;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -162,11 +169,14 @@ function lineGraph(type, chartData) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $elem = $("#chart-" + type);
|
|
|
|
|
|
|
|
|
|
|
|
var graph = new Rickshaw.Graph({
|
|
|
|
var graph = new Rickshaw.Graph({
|
|
|
|
element: document.getElementById("chart-" + type),
|
|
|
|
element: $elem[0],
|
|
|
|
width: $("#div-chart").width() - 50,
|
|
|
|
width: $elem.width() - 100,
|
|
|
|
height: 300,
|
|
|
|
height: 300,
|
|
|
|
renderer: "line",
|
|
|
|
renderer: "line",
|
|
|
|
|
|
|
|
interpolation: "linear",
|
|
|
|
padding: {top: 0.2, left: 0.0, right: 0.0, bottom: 0.2},
|
|
|
|
padding: {top: 0.2, left: 0.0, right: 0.0, bottom: 0.2},
|
|
|
|
xScale: d3.time.scale(),
|
|
|
|
xScale: d3.time.scale(),
|
|
|
|
series: [{
|
|
|
|
series: [{
|
|
|
@ -176,8 +186,6 @@ function lineGraph(type, chartData) {
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
graph.render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var xAxis = new Rickshaw.Graph.Axis.Time({
|
|
|
|
var xAxis = new Rickshaw.Graph.Axis.Time({
|
|
|
|
graph: graph
|
|
|
|
graph: graph
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -189,7 +197,7 @@ function lineGraph(type, chartData) {
|
|
|
|
orientation: 'left',
|
|
|
|
orientation: 'left',
|
|
|
|
height: 300,
|
|
|
|
height: 300,
|
|
|
|
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
|
|
|
|
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
|
|
|
|
element: document.getElementById('y_axis')
|
|
|
|
element: document.getElementById('y-axis-'+type)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
new Rickshaw.Graph.Legend({
|
|
|
|
new Rickshaw.Graph.Legend({
|
|
|
@ -206,6 +214,8 @@ function lineGraph(type, chartData) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
graph.render();
|
|
|
|
|
|
|
|
|
|
|
|
return graph;
|
|
|
|
return graph;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -221,58 +231,59 @@ function connect(target) {
|
|
|
|
if (ws) {
|
|
|
|
if (ws) {
|
|
|
|
ws.onmessage = function (event) {
|
|
|
|
ws.onmessage = function (event) {
|
|
|
|
var dataPoint = JSON.parse(event.data);
|
|
|
|
var dataPoint = JSON.parse(event.data);
|
|
|
|
|
|
|
|
|
|
|
|
if (dataPoint) {
|
|
|
|
if (dataPoint) {
|
|
|
|
var time = parseInt(dataPoint[4]) / 1000;
|
|
|
|
var time = parseInt(dataPoint[4]) / 1000;
|
|
|
|
switch (dataPoint[typeId]) {
|
|
|
|
switch (dataPoint[typeId]) {
|
|
|
|
case "battery":
|
|
|
|
case "battery":
|
|
|
|
graphUpdate(batteryData, time, dataPoint[batteryId], battery);
|
|
|
|
graphUpdate(batteryData, time, dataPoint[batteryId], graphMap["battery"]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "light":
|
|
|
|
case "light":
|
|
|
|
graphUpdate(lightData, time, dataPoint[lightId], light);
|
|
|
|
graphUpdate(lightData, time, dataPoint[lightId], graphMap["light"]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "pressure":
|
|
|
|
case "pressure":
|
|
|
|
graphUpdate(pressureData, time, dataPoint[pressureId], pressure);
|
|
|
|
graphUpdate(pressureData, time, dataPoint[pressureId], graphMap["pressure"]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "proximity":
|
|
|
|
case "proximity":
|
|
|
|
graphUpdate(proximityData, time, dataPoint[proximityId], proximity);
|
|
|
|
graphUpdate(proximityData, time, dataPoint[proximityId], graphMap["proximity"]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "accelerometer":
|
|
|
|
case "accelerometer":
|
|
|
|
dataUpdate(accelerometer_xData, time, dataPoint[accelerometer_xId]);
|
|
|
|
dataUpdate(accelerometer_xData, time, dataPoint[accelerometer_xId]);
|
|
|
|
dataUpdate(accelerometer_yData, time, dataPoint[accelerometer_yId]);
|
|
|
|
dataUpdate(accelerometer_yData, time, dataPoint[accelerometer_yId]);
|
|
|
|
dataUpdate(accelerometer_zData, time, dataPoint[accelerometer_zId]);
|
|
|
|
dataUpdate(accelerometer_zData, time, dataPoint[accelerometer_zId]);
|
|
|
|
accelerometer.update();
|
|
|
|
graphMap["accelerometer"].update();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "magnetic":
|
|
|
|
case "magnetic":
|
|
|
|
dataUpdate(magnetic_xData, time, dataPoint[magnetic_xId]);
|
|
|
|
dataUpdate(magnetic_xData, time, dataPoint[magnetic_xId]);
|
|
|
|
dataUpdate(magnetic_yData, time, dataPoint[magnetic_yId]);
|
|
|
|
dataUpdate(magnetic_yData, time, dataPoint[magnetic_yId]);
|
|
|
|
dataUpdate(magnetic_zData, time, dataPoint[magnetic_zId]);
|
|
|
|
dataUpdate(magnetic_zData, time, dataPoint[magnetic_zId]);
|
|
|
|
magnetic.update();
|
|
|
|
graphMap["magnetic"].update();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "gyroscope":
|
|
|
|
case "gyroscope":
|
|
|
|
dataUpdate(gyroscope_xData, time, dataPoint[gyroscope_xId]);
|
|
|
|
dataUpdate(gyroscope_xData, time, dataPoint[gyroscope_xId]);
|
|
|
|
dataUpdate(gyroscope_yData, time, dataPoint[gyroscope_yId]);
|
|
|
|
dataUpdate(gyroscope_yData, time, dataPoint[gyroscope_yId]);
|
|
|
|
dataUpdate(gyroscope_zData, time, dataPoint[gyroscope_zId]);
|
|
|
|
dataUpdate(gyroscope_zData, time, dataPoint[gyroscope_zId]);
|
|
|
|
gyroscope.update();
|
|
|
|
graphMap["gyroscope"].update();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "rotation":
|
|
|
|
case "rotation":
|
|
|
|
dataUpdate(magnetic_xData, time, dataPoint[rotation_xId]);
|
|
|
|
dataUpdate(magnetic_xData, time, dataPoint[rotation_xId]);
|
|
|
|
dataUpdate(magnetic_yData, time, dataPoint[rotation_yId]);
|
|
|
|
dataUpdate(magnetic_yData, time, dataPoint[rotation_yId]);
|
|
|
|
dataUpdate(magnetic_zData, time, dataPoint[rotation_zId]);
|
|
|
|
dataUpdate(magnetic_zData, time, dataPoint[rotation_zId]);
|
|
|
|
rotation.update();
|
|
|
|
graphMap["rotation"].update();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "gravity":
|
|
|
|
case "gravity":
|
|
|
|
dataUpdate(gravity_xData, time, dataPoint[gravity_xId]);
|
|
|
|
dataUpdate(gravity_xData, time, dataPoint[gravity_xId]);
|
|
|
|
dataUpdate(gravity_yData, time, dataPoint[gravity_yId]);
|
|
|
|
dataUpdate(gravity_yData, time, dataPoint[gravity_yId]);
|
|
|
|
dataUpdate(gravity_zData, time, dataPoint[gravity_zId]);
|
|
|
|
dataUpdate(gravity_zData, time, dataPoint[gravity_zId]);
|
|
|
|
gravity.update();
|
|
|
|
graphMap["gravity"].update();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -297,7 +308,6 @@ function dataUpdate(chartData, xValue, yValue) {
|
|
|
|
chartData.shift();
|
|
|
|
chartData.shift();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function disconnect() {
|
|
|
|
function disconnect() {
|
|
|
|
if (ws != null) {
|
|
|
|
if (ws != null) {
|
|
|
|
ws.close();
|
|
|
|
ws.close();
|
|
|
@ -305,6 +315,41 @@ function disconnect() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function initMap() {
|
|
|
|
function maximizeGraph(graph, width,height){
|
|
|
|
|
|
|
|
graph.configure({
|
|
|
|
|
|
|
|
width: width*2,
|
|
|
|
|
|
|
|
height: height*2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
graph.render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function minimizeGraph(graph){
|
|
|
|
|
|
|
|
graph.configure({
|
|
|
|
|
|
|
|
width: 366,
|
|
|
|
|
|
|
|
height: 300
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
graph.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//maximize minimize functionality
|
|
|
|
|
|
|
|
$(".fw-expand").click(function(e) {
|
|
|
|
|
|
|
|
var innerGraph= graphMap[e.target.nextElementSibling.innerHTML];
|
|
|
|
|
|
|
|
var width = $(".chartWrapper").width();
|
|
|
|
|
|
|
|
var height = $(".chartWrapper").height();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($(this).hasClass("default-view")){
|
|
|
|
|
|
|
|
$(this).removeClass("default-view");
|
|
|
|
|
|
|
|
maximizeGraph(innerGraph,width,height);
|
|
|
|
|
|
|
|
$(this).parent().parent().addClass("max");
|
|
|
|
|
|
|
|
$(this).closest(".graph").siblings().addClass("max_hide");
|
|
|
|
|
|
|
|
$(this).closest(".graph").parent().siblings().addClass("max_hide");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(this).addClass("default-view");
|
|
|
|
|
|
|
|
minimizeGraph(innerGraph);
|
|
|
|
|
|
|
|
$(this).parent().parent().removeClass("max");
|
|
|
|
|
|
|
|
$(this).closest(".graph").siblings().removeClass("max_hide");
|
|
|
|
|
|
|
|
$(this).closest(".graph").parent().siblings().removeClass("max_hide");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|