mirror of
https://gitlab.silvrtree.co.uk/martind2000/censis-archive.git
synced 2025-02-05 06:50:14 +00:00
”2016-06-08”
This commit is contained in:
parent
e80c00e850
commit
1f362f4fbe
@ -198,22 +198,16 @@ CC2650_ACCEL = function(p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log('accel max:', max);
|
|
||||||
ceiling = max;
|
ceiling = max;
|
||||||
|
|
||||||
/* if (ceiling < this.previousCeil) {
|
|
||||||
ceiling = ceiling + ((this.previousCeil - ceiling) / 2);
|
|
||||||
ceiling = (Math.ceil((Math.round(ceiling) + 1) / 10));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
floor = ceiling * -1;
|
floor = ceiling * -1;
|
||||||
ceilingLimit = ceiling;
|
ceilingLimit = ceiling;
|
||||||
|
|
||||||
var scalePos = (124 / 2) / ceiling;
|
var scalePos = (124 / 2) / ceiling;
|
||||||
var scaleNeg = (124 / 2) / floor;
|
var scaleNeg = (124 / 2) / floor;
|
||||||
// Var xstep = (280 - 46) / 100;
|
var xstep = (680 - 46) / 100;
|
||||||
var xstep = 2.34;
|
|
||||||
|
//Var xstep = 2.34;
|
||||||
|
|
||||||
for (lineMode = 0; lineMode < parts.length; lineMode++) {
|
for (lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||||
|
|
||||||
@ -259,7 +253,7 @@ CC2650_ACCEL = function(p) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.generateBlankGraphBase = function(subID) {
|
this.generateBlankGraphBase = function(subID, settings) {
|
||||||
|
|
||||||
var _subID = subID || '';
|
var _subID = subID || '';
|
||||||
var xmlns = 'http://www.w3.org/2000/svg';
|
var xmlns = 'http://www.w3.org/2000/svg';
|
||||||
@ -268,16 +262,28 @@ CC2650_ACCEL = function(p) {
|
|||||||
var text1ID = this.frameID + _subID + '-txt1';
|
var text1ID = this.frameID + _subID + '-txt1';
|
||||||
var text2ID = this.frameID + _subID + '-txt2';
|
var text2ID = this.frameID + _subID + '-txt2';
|
||||||
|
|
||||||
|
var _width = settings.width || 300;
|
||||||
|
var _height = settings.height || 150;
|
||||||
|
var _fill = settings.fill || 'blue';
|
||||||
|
|
||||||
var svg = document.createElementNS(xmlns, 'svg');
|
var svg = document.createElementNS(xmlns, 'svg');
|
||||||
|
|
||||||
svg.setAttributeNS(xmlns, 'id', svgID);
|
svg.setAttribute('id', svgID);
|
||||||
svg.setAttributeNS(xmlns, 'width', '300');
|
// Svg.setAttribute(xmlns, 'version', '1.1');
|
||||||
svg.setAttributeNS(xmlns, 'height', '150');
|
svg.setAttribute('width', _width.toString());
|
||||||
svg.setAttributeNS(xmlns, 'fill', 'blue');
|
svg.setAttribute('height', _height.toString());
|
||||||
|
svg.setAttribute('fill', _fill);
|
||||||
|
|
||||||
svg = this.graphAddXAxis(svg, {y: 12, colour: '#004c6d', id: text1ID});
|
|
||||||
svg = this.graphAddXAxis(svg, {y: 136, colour: '#004c6d', id: text2ID});
|
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||||
svg = this.graphAddXAxis(svg, {y: 71, colour: '#004c6d', text: '0'});
|
|
||||||
|
svg.setAttributeNS(xmlns, 'viewBox', '0 0 700 150');
|
||||||
|
// Svg.setAttributeNS(xmlns, 'style', 'width:700px;height:150px;');
|
||||||
|
|
||||||
|
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 12, x2: 680, colour: '#004c6d', id: text1ID});
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 136, x2: 680, colour: '#004c6d', id: text2ID});
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 71, x2: 680, colour: '#004c6d', text: '0'});
|
||||||
|
|
||||||
return svg;
|
return svg;
|
||||||
|
|
||||||
@ -290,7 +296,7 @@ CC2650_ACCEL = function(p) {
|
|||||||
var ylineID = this.frameID + _subID + '-y-line';
|
var ylineID = this.frameID + _subID + '-y-line';
|
||||||
var zlineID = this.frameID + _subID + '-z-line';
|
var zlineID = this.frameID + _subID + '-z-line';
|
||||||
|
|
||||||
var svg = this.generateBlankGraphBase(_subID);
|
var svg = this.generateBlankGraphBase(_subID,{width: '700',height: 150});
|
||||||
|
|
||||||
svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)');
|
svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)');
|
||||||
svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)');
|
svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)');
|
||||||
@ -300,6 +306,12 @@ CC2650_ACCEL = function(p) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.startCalibrate = function() {
|
||||||
|
console.log('Start calibrate');
|
||||||
|
|
||||||
|
alert('Mag Calibration: Wave device in a figure eight until done!');
|
||||||
|
};
|
||||||
|
|
||||||
this.insertFrame = function(mode) {
|
this.insertFrame = function(mode) {
|
||||||
|
|
||||||
var frame;
|
var frame;
|
||||||
@ -320,10 +332,22 @@ CC2650_ACCEL = function(p) {
|
|||||||
class: 'mui-panel', id: this.frames[modeID]
|
class: 'mui-panel', id: this.frames[modeID]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (mode === 'mag') {
|
||||||
|
var elm = $('<div />', {class: 'mui-row'});
|
||||||
|
var button = $('<button />',{class: 'mui-btn mui-btn--raised', id: modeID + '-cal', text: 'Calibrate', click: this.startCalibrate.bind(this)});
|
||||||
|
|
||||||
|
elm.append($('<div />', { class: 'mui-col-xs-8 mui--text-title mui-ellipsis-2', text: title}));
|
||||||
|
|
||||||
|
// elm.append($('<div />', {class: 'mui-col-xs-4 mui--text-right'}).append(button));
|
||||||
|
|
||||||
|
frame.append(elm);
|
||||||
|
|
||||||
|
} else {
|
||||||
$('<div />', {class: 'mui-row'}).append($('<div />', {
|
$('<div />', {class: 'mui-row'}).append($('<div />', {
|
||||||
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
|
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
|
||||||
})).appendTo(frame);
|
})).appendTo(frame);
|
||||||
|
|
||||||
|
}
|
||||||
this.$frame.append(frame);
|
this.$frame.append(frame);
|
||||||
this.$id[modeID] = $('#' + this.frames[modeID]);
|
this.$id[modeID] = $('#' + this.frames[modeID]);
|
||||||
|
|
||||||
@ -370,7 +394,7 @@ CC2650_ACCEL = function(p) {
|
|||||||
row = $('<div />', {class: 'mui-row'});
|
row = $('<div />', {class: 'mui-row'});
|
||||||
|
|
||||||
var _graph = this.generateBlankGraph(mode);
|
var _graph = this.generateBlankGraph(mode);
|
||||||
row.append($('<div>', {class: 'mui-col-md-12'}).append(_graph));
|
row.append($('<div>', {class: 'mui-col-sm-12'}).append(_graph));
|
||||||
|
|
||||||
this.$id[modeID].append(row);
|
this.$id[modeID].append(row);
|
||||||
};
|
};
|
||||||
|
@ -169,6 +169,7 @@ CAPABILITY.prototype.graphAddXAxis = function(svg, settings) {
|
|||||||
var _svg = svg;
|
var _svg = svg;
|
||||||
var y = settings.y || 0;
|
var y = settings.y || 0;
|
||||||
var y2 = y + 3;
|
var y2 = y + 3;
|
||||||
|
var x2 = settings.x2 || 280;
|
||||||
var colour = settings.colour || '#ff0000';
|
var colour = settings.colour || '#ff0000';
|
||||||
var id = settings.id;
|
var id = settings.id;
|
||||||
var textContent = settings.text || '-';
|
var textContent = settings.text || '-';
|
||||||
@ -179,7 +180,7 @@ CAPABILITY.prototype.graphAddXAxis = function(svg, settings) {
|
|||||||
|
|
||||||
line.setAttributeNS(null,'x1','46');
|
line.setAttributeNS(null,'x1','46');
|
||||||
line.setAttributeNS(null,'y1', y);
|
line.setAttributeNS(null,'y1', y);
|
||||||
line.setAttributeNS(null,'x2','280');
|
line.setAttributeNS(null,'x2', x2);
|
||||||
line.setAttributeNS(null,'y2', y);
|
line.setAttributeNS(null,'y2', y);
|
||||||
line.setAttributeNS(null,'style',lineStyle);
|
line.setAttributeNS(null,'style',lineStyle);
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -198,22 +198,16 @@ CC2650_ACCEL = function(p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log('accel max:', max);
|
|
||||||
ceiling = max;
|
ceiling = max;
|
||||||
|
|
||||||
/* if (ceiling < this.previousCeil) {
|
|
||||||
ceiling = ceiling + ((this.previousCeil - ceiling) / 2);
|
|
||||||
ceiling = (Math.ceil((Math.round(ceiling) + 1) / 10));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
floor = ceiling * -1;
|
floor = ceiling * -1;
|
||||||
ceilingLimit = ceiling;
|
ceilingLimit = ceiling;
|
||||||
|
|
||||||
var scalePos = (124 / 2) / ceiling;
|
var scalePos = (124 / 2) / ceiling;
|
||||||
var scaleNeg = (124 / 2) / floor;
|
var scaleNeg = (124 / 2) / floor;
|
||||||
// Var xstep = (280 - 46) / 100;
|
var xstep = (680 - 46) / 100;
|
||||||
var xstep = 2.34;
|
|
||||||
|
//Var xstep = 2.34;
|
||||||
|
|
||||||
for (lineMode = 0; lineMode < parts.length; lineMode++) {
|
for (lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||||
|
|
||||||
@ -259,7 +253,7 @@ CC2650_ACCEL = function(p) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.generateBlankGraphBase = function(subID) {
|
this.generateBlankGraphBase = function(subID, settings) {
|
||||||
|
|
||||||
var _subID = subID || '';
|
var _subID = subID || '';
|
||||||
var xmlns = 'http://www.w3.org/2000/svg';
|
var xmlns = 'http://www.w3.org/2000/svg';
|
||||||
@ -268,16 +262,28 @@ CC2650_ACCEL = function(p) {
|
|||||||
var text1ID = this.frameID + _subID + '-txt1';
|
var text1ID = this.frameID + _subID + '-txt1';
|
||||||
var text2ID = this.frameID + _subID + '-txt2';
|
var text2ID = this.frameID + _subID + '-txt2';
|
||||||
|
|
||||||
|
var _width = settings.width || 300;
|
||||||
|
var _height = settings.height || 150;
|
||||||
|
var _fill = settings.fill || 'blue';
|
||||||
|
|
||||||
var svg = document.createElementNS(xmlns, 'svg');
|
var svg = document.createElementNS(xmlns, 'svg');
|
||||||
|
|
||||||
svg.setAttributeNS(xmlns, 'id', svgID);
|
svg.setAttribute('id', svgID);
|
||||||
svg.setAttributeNS(xmlns, 'width', '300');
|
// Svg.setAttribute(xmlns, 'version', '1.1');
|
||||||
svg.setAttributeNS(xmlns, 'height', '150');
|
svg.setAttribute('width', _width.toString());
|
||||||
svg.setAttributeNS(xmlns, 'fill', 'blue');
|
svg.setAttribute('height', _height.toString());
|
||||||
|
svg.setAttribute('fill', _fill);
|
||||||
|
|
||||||
svg = this.graphAddXAxis(svg, {y: 12, colour: '#004c6d', id: text1ID});
|
|
||||||
svg = this.graphAddXAxis(svg, {y: 136, colour: '#004c6d', id: text2ID});
|
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||||
svg = this.graphAddXAxis(svg, {y: 71, colour: '#004c6d', text: '0'});
|
|
||||||
|
svg.setAttributeNS(xmlns, 'viewBox', '0 0 700 150');
|
||||||
|
// Svg.setAttributeNS(xmlns, 'style', 'width:700px;height:150px;');
|
||||||
|
|
||||||
|
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 12, x2: 680, colour: '#004c6d', id: text1ID});
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 136, x2: 680, colour: '#004c6d', id: text2ID});
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 71, x2: 680, colour: '#004c6d', text: '0'});
|
||||||
|
|
||||||
return svg;
|
return svg;
|
||||||
|
|
||||||
@ -290,7 +296,7 @@ CC2650_ACCEL = function(p) {
|
|||||||
var ylineID = this.frameID + _subID + '-y-line';
|
var ylineID = this.frameID + _subID + '-y-line';
|
||||||
var zlineID = this.frameID + _subID + '-z-line';
|
var zlineID = this.frameID + _subID + '-z-line';
|
||||||
|
|
||||||
var svg = this.generateBlankGraphBase(_subID);
|
var svg = this.generateBlankGraphBase(_subID,{width: '700',height: 150});
|
||||||
|
|
||||||
svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)');
|
svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)');
|
||||||
svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)');
|
svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)');
|
||||||
@ -300,6 +306,12 @@ CC2650_ACCEL = function(p) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.startCalibrate = function() {
|
||||||
|
console.log('Start calibrate');
|
||||||
|
|
||||||
|
alert('Mag Calibration: Wave device in a figure eight until done!');
|
||||||
|
};
|
||||||
|
|
||||||
this.insertFrame = function(mode) {
|
this.insertFrame = function(mode) {
|
||||||
|
|
||||||
var frame;
|
var frame;
|
||||||
@ -320,10 +332,22 @@ CC2650_ACCEL = function(p) {
|
|||||||
class: 'mui-panel', id: this.frames[modeID]
|
class: 'mui-panel', id: this.frames[modeID]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (mode === 'mag') {
|
||||||
|
var elm = $('<div />', {class: 'mui-row'});
|
||||||
|
var button = $('<button />',{class: 'mui-btn mui-btn--raised', id: modeID + '-cal', text: 'Calibrate', click: this.startCalibrate.bind(this)});
|
||||||
|
|
||||||
|
elm.append($('<div />', { class: 'mui-col-xs-8 mui--text-title mui-ellipsis-2', text: title}));
|
||||||
|
|
||||||
|
elm.append($('<div />', {class: 'mui-col-xs-4 mui--text-right'}).append(button));
|
||||||
|
|
||||||
|
frame.append(elm);
|
||||||
|
|
||||||
|
} else {
|
||||||
$('<div />', {class: 'mui-row'}).append($('<div />', {
|
$('<div />', {class: 'mui-row'}).append($('<div />', {
|
||||||
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
|
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
|
||||||
})).appendTo(frame);
|
})).appendTo(frame);
|
||||||
|
|
||||||
|
}
|
||||||
this.$frame.append(frame);
|
this.$frame.append(frame);
|
||||||
this.$id[modeID] = $('#' + this.frames[modeID]);
|
this.$id[modeID] = $('#' + this.frames[modeID]);
|
||||||
|
|
||||||
@ -370,7 +394,7 @@ CC2650_ACCEL = function(p) {
|
|||||||
row = $('<div />', {class: 'mui-row'});
|
row = $('<div />', {class: 'mui-row'});
|
||||||
|
|
||||||
var _graph = this.generateBlankGraph(mode);
|
var _graph = this.generateBlankGraph(mode);
|
||||||
row.append($('<div>', {class: 'mui-col-md-12'}).append(_graph));
|
row.append($('<div>', {class: 'mui-col-sm-12'}).append(_graph));
|
||||||
|
|
||||||
this.$id[modeID].append(row);
|
this.$id[modeID].append(row);
|
||||||
};
|
};
|
||||||
|
@ -169,6 +169,7 @@ CAPABILITY.prototype.graphAddXAxis = function(svg, settings) {
|
|||||||
var _svg = svg;
|
var _svg = svg;
|
||||||
var y = settings.y || 0;
|
var y = settings.y || 0;
|
||||||
var y2 = y + 3;
|
var y2 = y + 3;
|
||||||
|
var x2 = settings.x2 || 280;
|
||||||
var colour = settings.colour || '#ff0000';
|
var colour = settings.colour || '#ff0000';
|
||||||
var id = settings.id;
|
var id = settings.id;
|
||||||
var textContent = settings.text || '-';
|
var textContent = settings.text || '-';
|
||||||
@ -179,7 +180,7 @@ CAPABILITY.prototype.graphAddXAxis = function(svg, settings) {
|
|||||||
|
|
||||||
line.setAttributeNS(null,'x1','46');
|
line.setAttributeNS(null,'x1','46');
|
||||||
line.setAttributeNS(null,'y1', y);
|
line.setAttributeNS(null,'y1', y);
|
||||||
line.setAttributeNS(null,'x2','280');
|
line.setAttributeNS(null,'x2', x2);
|
||||||
line.setAttributeNS(null,'y2', y);
|
line.setAttributeNS(null,'y2', y);
|
||||||
line.setAttributeNS(null,'style',lineStyle);
|
line.setAttributeNS(null,'style',lineStyle);
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
/* global ble */
|
/* global ble */
|
||||||
/* jshint browser: true , devel: true*/
|
/* jshint browser: true , devel: true*/
|
||||||
|
|
||||||
var CC2650_ACCEL = function(p) {
|
var CC2650_ACCEL;
|
||||||
|
CC2650_ACCEL = function(p) {
|
||||||
'use strict';
|
'use strict';
|
||||||
this.name = 'Accelerometer';
|
this.name = 'Accelerometer';
|
||||||
this.deviceID = p.deviceID || null;
|
this.deviceID = p.deviceID || null;
|
||||||
@ -27,7 +28,11 @@ var CC2650_ACCEL = function(p) {
|
|||||||
|
|
||||||
this.$id = {};
|
this.$id = {};
|
||||||
this.$result = {};
|
this.$result = {};
|
||||||
this.data = {gyro: {x: [], y: [], z: []}, accel: {x: [], y: [], z: []}, mag: {x: [], y: [], z: []}};
|
this.data = {
|
||||||
|
gyro: {x: [], y: [], z: []},
|
||||||
|
accel: {x: [], y: [], z: []},
|
||||||
|
mag: {x: [], y: [], z: []}
|
||||||
|
};
|
||||||
|
|
||||||
this.setFrame();
|
this.setFrame();
|
||||||
|
|
||||||
@ -44,17 +49,18 @@ var CC2650_ACCEL = function(p) {
|
|||||||
var a = new Int16Array(data);
|
var a = new Int16Array(data);
|
||||||
var calcData = {
|
var calcData = {
|
||||||
gyro: {
|
gyro: {
|
||||||
x: this.sensorMpu9250GyroConvert(a[0]),y: this.sensorMpu9250GyroConvert(a[1]),z: this.sensorMpu9250GyroConvert(a[2])
|
x: this.sensorMpu9250GyroConvert(a[0]),
|
||||||
},
|
y: this.sensorMpu9250GyroConvert(a[1]),
|
||||||
accel: {
|
z: this.sensorMpu9250GyroConvert(a[2])
|
||||||
x: this.sensorMpu9250AccConvert(a[3]),y: this.sensorMpu9250AccConvert(a[4]),z: this.sensorMpu9250AccConvert(a[5])
|
}, accel: {
|
||||||
},
|
x: this.sensorMpu9250AccConvert(a[3]),
|
||||||
mag: {
|
y: this.sensorMpu9250AccConvert(a[4]),
|
||||||
x: a[6],y: a[7],z: a[8]
|
z: this.sensorMpu9250AccConvert(a[5])
|
||||||
|
}, mag: {
|
||||||
|
x: a[6], y: a[7], z: a[8]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return calcData;
|
return calcData;
|
||||||
};
|
};
|
||||||
this.onAccelerometerData = function(data) {
|
this.onAccelerometerData = function(data) {
|
||||||
@ -62,49 +68,48 @@ var CC2650_ACCEL = function(p) {
|
|||||||
var message;
|
var message;
|
||||||
var calcData;
|
var calcData;
|
||||||
|
|
||||||
|
function gString(v) {
|
||||||
|
return [v.toFixed(3),'G'].join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function aString(v) {
|
||||||
|
return [v.toFixed(3),'\'/s'].join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function mString(v) {
|
||||||
|
return [v.toFixed(3),'mT'].join('');
|
||||||
|
}
|
||||||
calcData = this.processData(data);
|
calcData = this.processData(data);
|
||||||
|
|
||||||
message = 'Gyro <br/>' +
|
message = 'Gyro <br/>' + 'X: ' + calcData.gyro.x + '<br/>' + 'Y: ' + calcData.gyro.y + '<br/>' + 'Z: ' + calcData.gyro.z + '<br/>' + 'Accel <br/>' + 'X: ' + calcData.accel.x + '<br/>' + 'Y: ' + calcData.accel.y + '<br/>' + 'Z: ' + calcData.accel.z + '<br/>' + 'Mag <br/>' + 'X: ' + calcData.mag.x + '<br/>' + 'Y: ' + calcData.mag.y + '<br/>' + 'Z: ' + calcData.mag.z + '<br/>';
|
||||||
'X: ' + calcData.gyro.x + '<br/>' +
|
|
||||||
'Y: ' + calcData.gyro.y + '<br/>' +
|
|
||||||
'Z: ' + calcData.gyro.z + '<br/>' +
|
|
||||||
'Accel <br/>' +
|
|
||||||
'X: ' + calcData.accel.x + '<br/>' +
|
|
||||||
'Y: ' + calcData.accel.y + '<br/>' +
|
|
||||||
'Z: ' + calcData.accel.z + '<br/>' +
|
|
||||||
'Mag <br/>' +
|
|
||||||
'X: ' + calcData.mag.x + '<br/>' +
|
|
||||||
'Y: ' + calcData.mag.y + '<br/>' +
|
|
||||||
'Z: ' + calcData.mag.z + '<br/>' ;
|
|
||||||
|
|
||||||
|
|
||||||
this.state = message;
|
this.state = message;
|
||||||
|
|
||||||
this.$result[this.frames.gyroID + '-x'].text(calcData.gyro.x.toFixed(5));
|
this.$result[this.frames.gyroID + '-x'].text(gString(calcData.gyro.x));
|
||||||
this.$result[this.frames.gyroID + '-y'].text(calcData.gyro.y.toFixed(5));
|
this.$result[this.frames.gyroID + '-y'].text(gString(calcData.gyro.y));
|
||||||
this.$result[this.frames.gyroID + '-z'].text(calcData.gyro.z.toFixed(5));
|
this.$result[this.frames.gyroID + '-z'].text(gString(calcData.gyro.z));
|
||||||
|
|
||||||
this.$result[this.frames.accelID + '-x'].text(calcData.accel.x.toFixed(5));
|
this.$result[this.frames.accelID + '-x'].text(aString(calcData.accel.x));
|
||||||
this.$result[this.frames.accelID + '-y'].text(calcData.accel.y.toFixed(5));
|
this.$result[this.frames.accelID + '-y'].text(aString(calcData.accel.y));
|
||||||
this.$result[this.frames.accelID + '-z'].text(calcData.accel.z.toFixed(5));
|
this.$result[this.frames.accelID + '-z'].text(aString(calcData.accel.z));
|
||||||
|
|
||||||
this.$result[this.frames.magID + '-x'].text(calcData.mag.x);
|
this.$result[this.frames.magID + '-x'].text(mString(calcData.mag.x));
|
||||||
this.$result[this.frames.magID + '-y'].text(calcData.mag.y);
|
this.$result[this.frames.magID + '-y'].text(mString(calcData.mag.y));
|
||||||
this.$result[this.frames.magID + '-z'].text(calcData.mag.z);
|
this.$result[this.frames.magID + '-z'].text(mString(calcData.mag.z));
|
||||||
|
|
||||||
|
this.data.gyro.x = this.storeData(calcData.gyro.x, this.data.gyro.x);
|
||||||
|
this.data.gyro.y = this.storeData(calcData.gyro.y, this.data.gyro.y);
|
||||||
|
this.data.gyro.z = this.storeData(calcData.gyro.z, this.data.gyro.z);
|
||||||
|
|
||||||
this.storeData(calcData.gyro.x, this.data.gyro.x);
|
this.data.accel.x = this.storeData(calcData.accel.x, this.data.accel.x);
|
||||||
this.storeData(calcData.gyro.y, this.data.gyro.y);
|
this.data.accel.y = this.storeData(calcData.accel.y, this.data.accel.y);
|
||||||
this.storeData(calcData.gyro.z, this.data.gyro.z);
|
this.data.accel.z = this.storeData(calcData.accel.z, this.data.accel.z);
|
||||||
|
|
||||||
this.storeData(calcData.accel.x, this.data.accel.x);
|
this.data.mag.x = this.storeData(calcData.mag.x, this.data.mag.x);
|
||||||
this.storeData(calcData.accel.y, this.data.accel.y);
|
this.data.mag.y = this.storeData(calcData.mag.y, this.data.mag.y);
|
||||||
this.storeData(calcData.accel.z, this.data.accel.z);
|
this.data.mag.z = this.storeData(calcData.mag.z, this.data.mag.z);
|
||||||
|
|
||||||
this.storeData(calcData.mag.x, this.data.mag.x);
|
|
||||||
this.storeData(calcData.mag.y, this.data.mag.y);
|
|
||||||
this.storeData(calcData.mag.z, this.data.mag.z);
|
|
||||||
|
|
||||||
|
// Console.log(JSON.stringify(this.data));
|
||||||
// Console.log(this.state);
|
// Console.log(this.state);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,32 +120,173 @@ var CC2650_ACCEL = function(p) {
|
|||||||
console.log('Starting CC2650 Accelerometer Service on ', this.deviceID);
|
console.log('Starting CC2650 Accelerometer Service on ', this.deviceID);
|
||||||
console.log(this.serviceDef);
|
console.log(this.serviceDef);
|
||||||
|
|
||||||
ble.startNotification(this.deviceID, this.serviceDef.service, this.serviceDef.data, this.onAccelerometerData.bind(this), this.onError);
|
this.setInternalID();
|
||||||
|
this.insertFrame('gyro');
|
||||||
|
this.insertFrame('accel');
|
||||||
|
this.insertFrame('mag');
|
||||||
|
|
||||||
|
ble.startNotification(this.deviceID,
|
||||||
|
this.serviceDef.service,
|
||||||
|
this.serviceDef.data,
|
||||||
|
this.onAccelerometerData.bind(this),
|
||||||
|
this.onError);
|
||||||
|
|
||||||
// Turn accelerometer on
|
// Turn accelerometer on
|
||||||
var configData = new Uint16Array(1);
|
var configData = new Uint16Array(1);
|
||||||
// Turn on gyro, accel, and mag, 2G range, Disable wake on motion
|
// Turn on gyro, accel, and mag, 2G range, Disable wake on motion
|
||||||
configData[0] = 0x007F;
|
configData[0] = 0x007F;
|
||||||
ble.write(this.deviceID, this.serviceDef.service, this.serviceDef.configuration, configData.buffer,
|
ble.write(this.deviceID,
|
||||||
function() { console.log('Started accelerometer.'); }, this.onError);
|
this.serviceDef.service,
|
||||||
|
this.serviceDef.configuration,
|
||||||
|
configData.buffer,
|
||||||
|
function() { console.log('Started accelerometer.'); },
|
||||||
|
this.onError);
|
||||||
|
|
||||||
var periodData = new Uint8Array(1);
|
var periodData = new Uint8Array(1);
|
||||||
periodData[0] = 0x0A;
|
periodData[0] = 0x0A;
|
||||||
ble.write(deviceId, accelerometer.service, accelerometer.period, periodData.buffer,
|
ble.write(this.deviceID,
|
||||||
function() { console.log('Configured accelerometer period.'); },app.onError);
|
this.serviceDef.service,
|
||||||
|
this.serviceDef.period,
|
||||||
this.setInternalID();
|
periodData.buffer,
|
||||||
this.insertFrame('gyro');
|
function() { console.log('Configured accelerometer period.'); },
|
||||||
this.insertFrame('accel');
|
this.onError);
|
||||||
this.insertFrame('mag');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.advancedGraph = function(mode, data, subID) {
|
||||||
|
|
||||||
|
var lm;
|
||||||
|
var ceiling;
|
||||||
|
var elm;
|
||||||
|
var text2ID;
|
||||||
|
var ceilingLimit;
|
||||||
|
var calcArray;
|
||||||
|
var floor;
|
||||||
|
var _subID;
|
||||||
|
var _data;
|
||||||
|
var text1ID;
|
||||||
|
var lineID;
|
||||||
|
var max;
|
||||||
|
|
||||||
|
|
||||||
|
var parts = ['x', 'y', 'z'];
|
||||||
|
|
||||||
|
_data = data || this.data;
|
||||||
|
|
||||||
|
_subID = subID || '';
|
||||||
|
|
||||||
|
// LineID = [this.frameID , _subID , '-line'].join('');
|
||||||
|
text1ID = [this.frameID, _subID, '-txt1'].join('');
|
||||||
|
text2ID = [this.frameID, _subID, '-txt2'].join('');
|
||||||
|
|
||||||
|
if (_data.x.length > 0) {
|
||||||
|
|
||||||
|
max = 2;
|
||||||
|
|
||||||
|
for (var lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||||
|
lm = parts[lineMode];
|
||||||
|
ceiling = _data[lm].reduce(function(p, v) {
|
||||||
|
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (ceiling > 500) {
|
||||||
|
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 50) * 50) : max;
|
||||||
|
} else {
|
||||||
|
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 10) * 10) : max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ceiling = max;
|
||||||
|
|
||||||
|
floor = ceiling * -1;
|
||||||
|
ceilingLimit = ceiling;
|
||||||
|
|
||||||
|
var scalePos = (124 / 2) / ceiling;
|
||||||
|
var scaleNeg = (124 / 2) / floor;
|
||||||
|
var xstep = (680 - 46) / 100;
|
||||||
|
|
||||||
|
//Var xstep = 2.34;
|
||||||
|
|
||||||
|
for (lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||||
|
|
||||||
|
lm = parts[lineMode];
|
||||||
|
var startX = 46 + (100 - _data[lm].length) * xstep;
|
||||||
|
|
||||||
|
calcArray = [];
|
||||||
|
|
||||||
|
lineID = this.frameID + _subID + '-' + lm + '-line';
|
||||||
|
for (var x = 0; x < _data[lm].length; x++) {
|
||||||
|
|
||||||
|
calcArray.push((startX + (x * xstep)).toFixed(2) + ',' + (71 - ((_data[lm][x]) * scalePos)).toFixed(
|
||||||
|
2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
elm = document.getElementById(lineID);
|
||||||
|
|
||||||
|
elm.setAttribute('points', calcArray.join(' '));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
elm = document.getElementById(text1ID);
|
||||||
|
elm.textContent = ceilingLimit;
|
||||||
|
|
||||||
|
elm = document.getElementById(text2ID);
|
||||||
|
elm.textContent = floor;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.previousCeil = ceiling;
|
||||||
|
};
|
||||||
|
|
||||||
this.animateGraph = function() {
|
this.animateGraph = function() {
|
||||||
// Nothing to animate yet
|
// Nothing to animate yet
|
||||||
|
|
||||||
return -1;
|
// return -1;
|
||||||
|
this.advancedGraph(0, this.data.gyro, 'gyro');
|
||||||
|
this.advancedGraph(0, this.data.accel, 'accel');
|
||||||
|
this.advancedGraph(0, this.data.mag, 'mag');
|
||||||
|
// This.simpleGraph(this.data.temp, 'temp');
|
||||||
|
// this.simpleGraph(this.data.pressure, 'pressure');
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
this.generateBlankGraphBase = function(subID, settings) {
|
||||||
|
|
||||||
|
var _subID = subID || '';
|
||||||
|
var xmlns = 'http://www.w3.org/2000/svg';
|
||||||
|
|
||||||
|
var svgID = this.frameID + _subID + '-svg';
|
||||||
|
var text1ID = this.frameID + _subID + '-txt1';
|
||||||
|
var text2ID = this.frameID + _subID + '-txt2';
|
||||||
|
|
||||||
|
var _width = settings.width || 300;
|
||||||
|
var _height = settings.height || 150;
|
||||||
|
var _fill = settings.fill || 'blue';
|
||||||
|
|
||||||
|
var svg = document.createElementNS(xmlns, 'svg');
|
||||||
|
|
||||||
|
svg.setAttribute('id', svgID);
|
||||||
|
// Svg.setAttribute(xmlns, 'version', '1.1');
|
||||||
|
svg.setAttribute('width', _width.toString());
|
||||||
|
svg.setAttribute('height', _height.toString());
|
||||||
|
svg.setAttribute('fill', _fill);
|
||||||
|
|
||||||
|
|
||||||
|
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||||
|
|
||||||
|
svg.setAttributeNS(xmlns, 'viewBox', '0 0 700 150');
|
||||||
|
// Svg.setAttributeNS(xmlns, 'style', 'width:700px;height:150px;');
|
||||||
|
|
||||||
|
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 12, x2: 680, colour: '#004c6d', id: text1ID});
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 136, x2: 680, colour: '#004c6d', id: text2ID});
|
||||||
|
svg = this.graphAddXAxis(svg, {y: 71, x2: 680, colour: '#004c6d', text: '0'});
|
||||||
|
|
||||||
|
return svg;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.generateBlankGraph = function(subID) {
|
this.generateBlankGraph = function(subID) {
|
||||||
@ -150,11 +296,11 @@ var CC2650_ACCEL = function(p) {
|
|||||||
var ylineID = this.frameID + _subID + '-y-line';
|
var ylineID = this.frameID + _subID + '-y-line';
|
||||||
var zlineID = this.frameID + _subID + '-z-line';
|
var zlineID = this.frameID + _subID + '-z-line';
|
||||||
|
|
||||||
var svg = this.generateBlankGraphBase(_subID);
|
var svg = this.generateBlankGraphBase(_subID,{width: '700',height: 150});
|
||||||
|
|
||||||
svg = this.graphAddLine(svg, xlineID, '#FF0000');
|
svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)');
|
||||||
svg = this.graphAddLine(svg, ylineID, '#00FF00');
|
svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)');
|
||||||
svg = this.graphAddLine(svg, zlineID, '#0000FF');
|
svg = this.graphAddLine(svg, zlineID, 'rgba(0,0,255,0.5)');
|
||||||
|
|
||||||
return svg;
|
return svg;
|
||||||
|
|
||||||
@ -167,10 +313,12 @@ var CC2650_ACCEL = function(p) {
|
|||||||
var modeID = mode + 'ID';
|
var modeID = mode + 'ID';
|
||||||
this.frames[modeID] = this.frameID + '-' + mode;
|
this.frames[modeID] = this.frameID + '-' + mode;
|
||||||
|
|
||||||
var titles = {gyro: 'Gyroscope', accel: 'Accelerometer', mag: 'Magnetometer'};
|
var titles = {
|
||||||
var modes = ['gyro','accel','mag'];
|
gyro: 'Gyroscope', accel: 'Accelerometer', mag: 'Magnetometer'
|
||||||
|
};
|
||||||
|
var modes = ['gyro', 'accel', 'mag'];
|
||||||
|
|
||||||
console.log('FrameID: ' , this.frames[modeID]);
|
console.log('FrameID: ', this.frames[modeID]);
|
||||||
|
|
||||||
title = [titles[mode], ' - ', this.deviceID].join(' ');
|
title = [titles[mode], ' - ', this.deviceID].join(' ');
|
||||||
|
|
||||||
@ -178,7 +326,9 @@ var CC2650_ACCEL = function(p) {
|
|||||||
class: 'mui-panel', id: this.frames[modeID]
|
class: 'mui-panel', id: this.frames[modeID]
|
||||||
});
|
});
|
||||||
|
|
||||||
$('<div />', { class: 'mui-row'}).append($('<div />', { class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title})).appendTo(frame);
|
$('<div />', {class: 'mui-row'}).append($('<div />', {
|
||||||
|
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
|
||||||
|
})).appendTo(frame);
|
||||||
|
|
||||||
this.$frame.append(frame);
|
this.$frame.append(frame);
|
||||||
this.$id[modeID] = $('#' + this.frames[modeID]);
|
this.$id[modeID] = $('#' + this.frames[modeID]);
|
||||||
@ -187,17 +337,35 @@ var CC2650_ACCEL = function(p) {
|
|||||||
|
|
||||||
var row = $('<div />', {class: 'mui-row'});
|
var row = $('<div />', {class: 'mui-row'});
|
||||||
|
|
||||||
$('<div />', { class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'X'}).appendTo(row);
|
$('<div />', {
|
||||||
$('<div />', { class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Y'}).appendTo(row);
|
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'X'
|
||||||
$('<div />', { class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Z'}).appendTo(row);
|
}).appendTo(row);
|
||||||
|
$('<div />', {
|
||||||
|
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Y'
|
||||||
|
}).appendTo(row);
|
||||||
|
$('<div />', {
|
||||||
|
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Z'
|
||||||
|
}).appendTo(row);
|
||||||
|
|
||||||
this.$id[modeID].append(row);
|
this.$id[modeID].append(row);
|
||||||
|
|
||||||
row = $('<div />', {class: 'mui-row'});
|
row = $('<div />', {class: 'mui-row'});
|
||||||
|
|
||||||
$('<div />', { class: 'mui-col-xs-4 mui--text-dark mui--text-center', text: '--', id: this.frames[modeID] + '-x' }).appendTo(row);
|
$('<div />', {
|
||||||
$('<div />', { class: 'mui-col-xs-4 mui--text-dark mui--text-center', text: '--', id: this.frames[modeID] + '-y'}).appendTo(row);
|
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||||
$('<div />', { class: 'mui-col-xs-4 mui--text-dark mui--text-center', text: '--', id: this.frames[modeID] + '-z'}).appendTo(row);
|
text: '--',
|
||||||
|
id: this.frames[modeID] + '-x'
|
||||||
|
}).appendTo(row);
|
||||||
|
$('<div />', {
|
||||||
|
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||||
|
text: '--',
|
||||||
|
id: this.frames[modeID] + '-y'
|
||||||
|
}).appendTo(row);
|
||||||
|
$('<div />', {
|
||||||
|
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||||
|
text: '--',
|
||||||
|
id: this.frames[modeID] + '-z'
|
||||||
|
}).appendTo(row);
|
||||||
|
|
||||||
this.$id[modeID].append(row);
|
this.$id[modeID].append(row);
|
||||||
|
|
||||||
@ -207,7 +375,8 @@ var CC2650_ACCEL = function(p) {
|
|||||||
|
|
||||||
row = $('<div />', {class: 'mui-row'});
|
row = $('<div />', {class: 'mui-row'});
|
||||||
|
|
||||||
row.append($('<div>',{class: 'mui-col-md-12'}).append(this.generateBlankGraph(modes[mode]))) ;
|
var _graph = this.generateBlankGraph(mode);
|
||||||
|
row.append($('<div>', {class: 'mui-col-sm-12'}).append(_graph));
|
||||||
|
|
||||||
this.$id[modeID].append(row);
|
this.$id[modeID].append(row);
|
||||||
};
|
};
|
||||||
|
@ -45,6 +45,9 @@ var CAPABILITY = function(p) {
|
|||||||
|
|
||||||
this.target = null;
|
this.target = null;
|
||||||
this.$frame = null;
|
this.$frame = null;
|
||||||
|
|
||||||
|
this.previousCeil = 0;
|
||||||
|
|
||||||
capabilityManager.register({id: this.capabilityID, module: this});
|
capabilityManager.register({id: this.capabilityID, module: this});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,6 +140,7 @@ CAPABILITY.prototype.startGraph = function(id) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CAPABILITY.prototype.generateBlankGraphBase = function(subID) {
|
CAPABILITY.prototype.generateBlankGraphBase = function(subID) {
|
||||||
|
|
||||||
var _subID = subID || '';
|
var _subID = subID || '';
|
||||||
@ -152,52 +156,52 @@ CAPABILITY.prototype.generateBlankGraphBase = function(subID) {
|
|||||||
svg.setAttributeNS(xmlns,'height','150');
|
svg.setAttributeNS(xmlns,'height','150');
|
||||||
svg.setAttributeNS(xmlns,'fill', 'blue');
|
svg.setAttributeNS(xmlns,'fill', 'blue');
|
||||||
|
|
||||||
var line = document.createElementNS(xmlns,'line');
|
|
||||||
|
|
||||||
line.setAttributeNS(null,'x1','46');
|
svg = this.graphAddXAxis(svg,{y: 12, colour: '#004c6d', id: text1ID});
|
||||||
line.setAttributeNS(null,'y1','12');
|
svg = this.graphAddXAxis(svg,{y: 136, colour: '#004c6d', text: '0'});
|
||||||
line.setAttributeNS(null,'x2','280');
|
|
||||||
line.setAttributeNS(null,'y2', '12');
|
|
||||||
line.setAttributeNS(null,'style','stroke:#004c6d;stroke-width:2;');
|
|
||||||
|
|
||||||
svg.appendChild(line);
|
|
||||||
|
|
||||||
line = document.createElementNS(xmlns,'line');
|
|
||||||
|
|
||||||
line.setAttributeNS(null,'x1','46');
|
|
||||||
line.setAttributeNS(null,'y1','136');
|
|
||||||
line.setAttributeNS(null,'x2','280');
|
|
||||||
line.setAttributeNS(null,'y2', '136');
|
|
||||||
line.setAttributeNS(null,'style','stroke:#004c6d;stroke-width:2;');
|
|
||||||
|
|
||||||
svg.appendChild(line);
|
|
||||||
|
|
||||||
var text = document.createElementNS(xmlns,'text');
|
|
||||||
|
|
||||||
text.setAttributeNS(null,'id',text1ID);
|
|
||||||
text.setAttributeNS(null,'x','36');
|
|
||||||
text.setAttributeNS(null,'y','15');
|
|
||||||
text.setAttributeNS(null,'text-anchor', 'end');
|
|
||||||
text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #004c6d;text-align:right;');
|
|
||||||
text.textContent = '000';
|
|
||||||
|
|
||||||
svg.appendChild(text);
|
|
||||||
|
|
||||||
text = document.createElementNS(xmlns,'text');
|
|
||||||
|
|
||||||
text.setAttributeNS(null,'id','text2');
|
|
||||||
text.setAttributeNS(null,'x','36');
|
|
||||||
text.setAttributeNS(null,'y','140');
|
|
||||||
text.setAttributeNS(null,'text-anchor', 'end');
|
|
||||||
text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #004c6d;text-align:right;');
|
|
||||||
text.textContent = '0';
|
|
||||||
|
|
||||||
svg.appendChild(text);
|
|
||||||
|
|
||||||
return svg;
|
return svg;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CAPABILITY.prototype.graphAddXAxis = function(svg, settings) {
|
||||||
|
var xmlns = 'http://www.w3.org/2000/svg';
|
||||||
|
var _svg = svg;
|
||||||
|
var y = settings.y || 0;
|
||||||
|
var y2 = y + 3;
|
||||||
|
var x2 = settings.x2 || 280;
|
||||||
|
var colour = settings.colour || '#ff0000';
|
||||||
|
var id = settings.id;
|
||||||
|
var textContent = settings.text || '-';
|
||||||
|
var lineStyle = ['stroke:',colour,';stroke-width:2;'].join('');
|
||||||
|
var textStyle = ['font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: ',colour,';text-align:right;'].join('');
|
||||||
|
|
||||||
|
var line = document.createElementNS(xmlns,'line');
|
||||||
|
|
||||||
|
line.setAttributeNS(null,'x1','46');
|
||||||
|
line.setAttributeNS(null,'y1', y);
|
||||||
|
line.setAttributeNS(null,'x2', x2);
|
||||||
|
line.setAttributeNS(null,'y2', y);
|
||||||
|
line.setAttributeNS(null,'style',lineStyle);
|
||||||
|
|
||||||
|
_svg.appendChild(line);
|
||||||
|
|
||||||
|
var text = document.createElementNS(xmlns,'text');
|
||||||
|
|
||||||
|
if (id !== null) {
|
||||||
|
text.setAttributeNS(null,'id',id);
|
||||||
|
}
|
||||||
|
text.setAttributeNS(null,'x','36');
|
||||||
|
text.setAttributeNS(null,'y', y2);
|
||||||
|
text.setAttributeNS(null,'text-anchor', 'end');
|
||||||
|
text.setAttributeNS(null,'style',textStyle);
|
||||||
|
text.textContent = textContent;
|
||||||
|
|
||||||
|
_svg.appendChild(text);
|
||||||
|
|
||||||
|
return _svg;
|
||||||
|
};
|
||||||
|
|
||||||
CAPABILITY.prototype.graphAddLine = function(svg, lineId, colour) {
|
CAPABILITY.prototype.graphAddLine = function(svg, lineId, colour) {
|
||||||
var xmlns = 'http://www.w3.org/2000/svg';
|
var xmlns = 'http://www.w3.org/2000/svg';
|
||||||
var _svg = svg;
|
var _svg = svg;
|
||||||
@ -240,6 +244,8 @@ CAPABILITY.prototype.animateGraph = function() {
|
|||||||
|
|
||||||
CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||||
|
|
||||||
|
var ceilingLimit;
|
||||||
|
var ceiling;
|
||||||
var _subID;
|
var _subID;
|
||||||
var _data;
|
var _data;
|
||||||
var text1ID;
|
var text1ID;
|
||||||
@ -253,10 +259,12 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
|||||||
text1ID = [this.frameID , _subID , '-txt1'].join('');
|
text1ID = [this.frameID , _subID , '-txt1'].join('');
|
||||||
|
|
||||||
if (_data.length > 0) {
|
if (_data.length > 0) {
|
||||||
var ceiling = _data.reduce(function(p, v) {
|
|
||||||
return (p > v ? p : v);
|
ceiling = _data.reduce(function(p, v) {
|
||||||
|
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Var floor = _data.reduce(function(p, v) {
|
/* Var floor = _data.reduce(function(p, v) {
|
||||||
return (p < v ? p : v);
|
return (p < v ? p : v);
|
||||||
});
|
});
|
||||||
@ -264,6 +272,7 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
|||||||
|
|
||||||
var calcArray = [];
|
var calcArray = [];
|
||||||
|
|
||||||
|
/*
|
||||||
var ceilingLimit = Math.floor(ceiling / 10) * 10;
|
var ceilingLimit = Math.floor(ceiling / 10) * 10;
|
||||||
if (ceilingLimit < ceiling) {
|
if (ceilingLimit < ceiling) {
|
||||||
ceilingLimit = Math.floor((ceiling + (ceiling * 0.25)) / 10) * 10;
|
ceilingLimit = Math.floor((ceiling + (ceiling * 0.25)) / 10) * 10;
|
||||||
@ -272,6 +281,13 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
|||||||
if (ceilingLimit < 30) {
|
if (ceilingLimit < 30) {
|
||||||
ceilingLimit = 30;
|
ceilingLimit = 30;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 10) * 10);
|
||||||
|
if (ceilingLimit > 1000) {
|
||||||
|
ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 50) * 50);
|
||||||
|
}
|
||||||
|
|
||||||
var scale = 124 / ceilingLimit;
|
var scale = 124 / ceilingLimit;
|
||||||
// Var xstep = (280 - 46) / 100;
|
// Var xstep = (280 - 46) / 100;
|
||||||
|
Loading…
Reference in New Issue
Block a user