merge-requests/1/head
Rasika Perera 9 years ago
commit 3740712d96

@ -75,6 +75,7 @@ if (result) {
function getFireAlarmData(user, deviceId, from, to) { function getFireAlarmData(user, deviceId, from, to) {
result = new Object(); result = new Object();
result['cpuTemperatureData'] = getSensorData("DEVICE_CPU_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to); result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
result['fanData'] = getSensorData("DEVICE_FAN_USAGE_SUMMARY", "status", user, deviceId, from, to); result['fanData'] = getSensorData("DEVICE_FAN_USAGE_SUMMARY", "status", user, deviceId, from, to);
result['bulbData'] = getSensorData("DEVICE_BULB_USAGE_SUMMARY", "status", user, deviceId, from, to); result['bulbData'] = getSensorData("DEVICE_BULB_USAGE_SUMMARY", "status", user, deviceId, from, to);
@ -96,14 +97,6 @@ function getArduinoData(user, deviceId, from, to){
return result; return result;
} }
function getDigitalDisplayData(user, deviceId, from, to){
result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY","motion",user, deviceId, from, to);
result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY","light",user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to);
return result;
}
function getAndroidSenseData(user, deviceId, from, to) { function getAndroidSenseData(user, deviceId, from, to) {
result = new Object(); result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY", "motion", user, deviceId, from, to); result['ramData'] = getSensorData("RAM_USAGE_SUMMARY", "motion", user, deviceId, from, to);
@ -117,7 +110,7 @@ function getDigitalDisplayData(user, deviceId, from, to){
result = new Object(); result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY", "motion", user, deviceId, from, to); result['ramData'] = getSensorData("RAM_USAGE_SUMMARY", "motion", user, deviceId, from, to);
result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY", "light", user, deviceId, from, to); result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY", "light", user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to); result['cpuTemperatureData'] = getSensorData("DEVICE_CPU_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
return result; return result;
} }

@ -48,6 +48,8 @@
</div> </div>
<div id="div-bulbData"> <div id="div-bulbData">
</div> </div>
<div id="div-cpuTemperatureData">
</div>
<div id="div-CPUData"> <div id="div-CPUData">
</div> </div>
<div id="div-RAMData"> <div id="div-RAMData">
@ -70,4 +72,5 @@
<script src="{{self.publicURL}}/js/graphs/sonar_graph.js"></script> <script src="{{self.publicURL}}/js/graphs/sonar_graph.js"></script>
<script src="{{self.publicURL}}/js/graphs/cpu_graph.js"></script> <script src="{{self.publicURL}}/js/graphs/cpu_graph.js"></script>
<script src="{{self.publicURL}}/js/graphs/ram_graph.js"></script> <script src="{{self.publicURL}}/js/graphs/ram_graph.js"></script>
<script src="{{self.publicURL}}/js/graphs/cpu_temperature_graph.js"></script>
{{/zone}} {{/zone}}

@ -1,6 +1,10 @@
var fromDate; var fromDate;
var toDate; var toDate;
var currentDay = new Date();
var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
var endDate = new Date(currentDay.getTime());
// create a custom bar renderer that has no gaps // create a custom bar renderer that has no gaps
Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Bar, { Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Bar, {
name: 'bar_no_gap', name: 'bar_no_gap',
@ -11,10 +15,11 @@ Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer
} }
}); });
function initDate(){
var currentDay = new Date(); currentDay = new Date();
var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100)); startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
var endDate = new Date(currentDay.getTime()); endDate = new Date(currentDay.getTime());
}
var configObject = { var configObject = {
startOfWeek: 'monday', startOfWeek: 'monday',
@ -38,6 +43,7 @@ var configObject = {
var DateRange = convertDate(startDate) + " " + configObject.separator + " " + convertDate(endDate); var DateRange = convertDate(startDate) + " " + configObject.separator + " " + convertDate(endDate);
$(document).ready(function () { $(document).ready(function () {
initDate();
$('#date-range').dateRangePicker(configObject) $('#date-range').dateRangePicker(configObject)
.bind('datepicker-apply', function (event, dateRange) { .bind('datepicker-apply', function (event, dateRange) {
$(this).addClass('active'); $(this).addClass('active');
@ -61,21 +67,25 @@ $(document).ready(function () {
//day picker //day picker
$('#today-btn').on('click', function () { $('#today-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 86400000, currentDay.getTime()); getDateTime(currentDay.getTime() - 86400000, currentDay.getTime());
}); });
//hour picker //hour picker
$('#hour-btn').on('click', function () { $('#hour-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 3600000, currentDay.getTime()); getDateTime(currentDay.getTime() - 3600000, currentDay.getTime());
}) });
//week picker //week picker
$('#week-btn').on('click', function () { $('#week-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 604800000, currentDay.getTime()); getDateTime(currentDay.getTime() - 604800000, currentDay.getTime());
}) });
//month picker //month picker
$('#month-btn').on('click', function () { $('#month-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - (604800000 * 4), currentDay.getTime()); getDateTime(currentDay.getTime() - (604800000 * 4), currentDay.getTime());
}); });
@ -211,6 +221,14 @@ function updateGraphs(stats) {
$('#div-RAMData').html(""); $('#div-RAMData').html("");
} }
var cpuTemperatureData = stats['cpuTemperatureData'];
if (typeof cpuTemperatureData != 'undefined') {
$('#div-cpuTemperatureData').html("").html("<div class='row margin-double'><div><h2 class='grey'>CPU Temperature</h2><hr><div id='canvas-wrapper9'></div></div><hr></div>");
updateCPUTemperatureGraph(convertStatsToGraphData(cpuTemperatureData));
} else {
$('#div-cpuTemperatureData').html("");
}
scaleGraphs(); scaleGraphs();
} }
@ -219,8 +237,18 @@ function scaleGraphs() {
if (sliders.length == 0) { if (sliders.length == 0) {
return; return;
} }
var graphWidth = 0;
for (var i = 1; i < 10; i++){
if ($('#canvas-wrapper' + i).length){
graphWidth = $('#canvas-wrapper' + i).width() - 50;
break;
}
}
if (graphWidth <= 0){
return;
}
var graphWidth = $('#canvas-wrapper1').width() - 50;
//Scale graphs //Scale graphs
var sliderX = graphWidth * 60 * 60 / (toDate - fromDate); var sliderX = graphWidth * 60 * 60 / (toDate - fromDate);
if (sliderX < graphWidth) { if (sliderX < graphWidth) {

@ -0,0 +1,70 @@
function updateCPUTemperatureGraph(temperatureData) {
console.log("cpuTemperatureData");
renderCPUTemperatureChart(temperatureData);
}
function renderCPUTemperatureChart(chartDataRaw) {
var chartWrapperElmId = "#canvas-wrapper9";
var graphWidth = $(chartWrapperElmId).width() - 50;
if (chartDataRaw.length == 0) {
$(chartWrapperElmId).html("No data available...");
return;
}
var chartData = [];
for (var i = 0; i < chartDataRaw.length; i++) {
chartData.push({x: parseInt(chartDataRaw[i].x), y: parseInt(chartDataRaw[i].y)});
}
//var i = parseInt(fromDate);
//while (i < parseInt(toDate)){
// var rnd = Math.random() * (30 - 20) + 20;
// chartData.push({x:i * 1000, y:rnd});
// i += 60 * 5;
//}
var chartDiv = "chart9";
var sliderDiv = "slider9";
var x_axis = "x_axis9";
var y_axis = "y_axis9";
$(chartWrapperElmId).html("").html('<div id="' + y_axis + '" class="custom_y_axis"></div><div id="' + chartDiv + '" class="custom_rickshaw_graph"></div><div id="' + x_axis + '" class="custom_x_axis"></div><div id="' + sliderDiv + '" class="custom_slider"></div>');
var graph = new Rickshaw.Graph({
element: document.getElementById(chartDiv),
width: graphWidth,
height: 400,
strokeWidth: 1,
renderer: 'line',
xScale: d3.time.scale(),
padding: {top: 0.2, left: 0.02, right: 0.02, bottom: 0},
series: [
{color: '#FF4000', data: chartData}
]
});
graph.render();
var xAxis = new Rickshaw.Graph.Axis.X({
graph: graph,
orientation: 'bottom',
element: document.getElementById(x_axis),
tickFormat: graph.x.tickFormat()
});
xAxis.render();
var yAxis = new Rickshaw.Graph.Axis.Y({
graph: graph,
orientation: 'left',
element: document.getElementById(y_axis),
width: 40,
height: 410
});
yAxis.render();
var slider = new Rickshaw.Graph.RangeSlider.Preview({
graph: graph,
element: document.getElementById(sliderDiv)
});
}
Loading…
Cancel
Save