diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag index 0fafe9cb..bcd3e72c 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag @@ -43,12 +43,28 @@ if (uriMatcher.match("/{context}/api/stats")) { } log.info("deviceId : " + deviceId + " from : " + from + " to : " + to); - if(deviceType=="firealarm"){ - result = getFireAlarmData(user.username, deviceId, from, to); - }else if(deviceType=="sensebot"){ - result = getSensebotData(user.username, deviceId, from, to); - }else if(deviceType=="arduino"){ - result = getArduinoData(user.username, deviceId, from, to); + + switch (deviceType){ + case "firealarm": + result = getFireAlarmData(user.username, deviceId, from, to); + break; + case "sensebot": + result = getSensebotData(user.username, deviceId, from, to); + break; + case "arduino": + result = getArduinoData(user.username, deviceId, from, to); + break; + case "digital_display": + result = getDigitalDisplayData(user.username, deviceId, from, to); + break; + case "android_sense": + result = getAndroidSenseData(user.username, deviceId, from, to); + break; + case "raspberrypi": + result = getDigitalDisplayData(user.username, deviceId, from, to); + break; + default: + result = new Object(); } } @@ -57,6 +73,14 @@ if (result) { print(result); } +function getFireAlarmData(user, deviceId, from, to){ + result = new Object(); + result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",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); + return result; +} + function getSensebotData(user, deviceId, from, to){ result = new Object(); result['sonarData'] = getSensorData("SONAR_SENSOR_SUMMARY","sonar",user, deviceId, from, to); @@ -66,22 +90,33 @@ function getSensebotData(user, deviceId, from, to){ return result; } - -function getFireAlarmData(user, deviceId, from, to){ +function getArduinoData(user, deviceId, from, to){ result = new Object(); + result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to); + return result; +} - //result['sonarData'] = getSensorData("SONAR_SENSOR_SUMMARY","sonar",user, deviceId, from, to); - //result['motionData'] = getSensorData("PIR_MOTION_SENSOR_SUMMARY","motion",user, deviceId, from, to); - //result['lightData'] = getSensorData("LDR_LIGHT_SENSOR_SUMMARY","light",user, deviceId, from, to); +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){ + 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); - 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['motionData'] = getSensorData("PIR_MOTION_SENSOR_SUMMARY","motion",user, deviceId, from, to); return result; } -function getArduinoData(user, deviceId, from, to){ +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; } @@ -96,18 +131,18 @@ function getSensorData(table, column, user, deviceId, from, to) { log.info(error); } - var temperatureData = []; + var sensorData = []; if(fetchedData==null) return []; for (var i = 0; i < fetchedData.size(); i++) { - temperatureData.push({ + sensorData.push({ time: fetchedData.get(i).getTime(), value: fetchedData.get(i).getValue() }); } - return temperatureData; + return sensorData; } %> \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs index 557d1a9c..9575d03e 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs @@ -37,64 +37,20 @@
-
-
-

Temperature

-
-
No data available...
-
-
-
-
-
-

Light

-
-
No data available...
-
-
-
-
-
-

Motion

-
-
No data available...
-
-
-
-
-
-

Sonar

-
-
No data available...
-
-
-
-
-
-

Fan Status

-
-
No data available...
-
-
-
-
-
-

Bulb Status

-
-
No data available...
-
-
-
+
+
+
+
@@ -112,4 +68,6 @@ + + {{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js index c49d5843..c8dbd110 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js @@ -195,6 +195,22 @@ function updateGraphs(stats) { $('#div-bulbData').html(""); } + var cpuData = stats['cpuData']; + if (typeof cpuData != 'undefined'){ + $('#div-CPUData').html("").html("

CPU Load



"); + updateCPUGraph(convertStateStatsToGraphData(cpuData)); + }else{ + $('#div-CPUData').html(""); + } + + var ramData = stats['ramData']; + if (typeof ramData != 'undefined'){ + $('#div-RAMData').html("").html("

RAM Usage



"); + updateRAMGraph(convertStateStatsToGraphData(ramData)); + }else{ + $('#div-RAMData').html(""); + } + scaleGraphs(); } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graphs/cpu_graph.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graphs/cpu_graph.js new file mode 100644 index 00000000..cdaf9b2a --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graphs/cpu_graph.js @@ -0,0 +1,69 @@ +function updateCPUGraph(CPUData) { + renderCPUChart(CPUData); +} + +function renderCPUChart(chartDataRaw){ + var chartWrapperElmId = "#canvas-wrapper7"; + 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 = "chart7"; + var sliderDiv = "slider7"; + var x_axis = "x_axis7"; + var y_axis = "y_axis7"; + $(chartWrapperElmId).html("").html('
'); + + 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: '#2F0B3A', 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) + }); +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graphs/ram_graph.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graphs/ram_graph.js new file mode 100644 index 00000000..5b6953e8 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graphs/ram_graph.js @@ -0,0 +1,69 @@ +function updateRAMGraph(RAMData) { + renderRAMChart(RAMData); +} + +function renderRAMChart(chartDataRaw){ + var chartWrapperElmId = "#canvas-wrapper8"; + 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 = "chart8"; + var sliderDiv = "slider8"; + var x_axis = "x_axis8"; + var y_axis = "y_axis8"; + $(chartWrapperElmId).html("").html('
'); + + 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: '#170B3B', 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) + }); +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/public/img/device_icons/raspberrypi.png b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/public/img/device_icons/raspberrypi.png new file mode 100644 index 00000000..eb0e28cb Binary files /dev/null and b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/public/img/device_icons/raspberrypi.png differ diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/images/raspberrypi.png b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/images/raspberrypi.png new file mode 100644 index 00000000..eb0e28cb Binary files /dev/null and b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/images/raspberrypi.png differ diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/android_sense/android_sense.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/android_sense/android_sense.hbs index 3bcc5bb1..c8d3e782 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/android_sense/android_sense.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/android_sense/android_sense.hbs @@ -1,18 +1,18 @@ {{#zone "main"}} -
+

Android Sense


-

Connect your Android Sense - to the WSO2 device cloud.

+

Connect your Android Sense + to the WSO2 device cloud.

- -
+ +

Ingredients


@@ -21,70 +21,58 @@ - Arduino Uno

- - - - Arduino Ethernet / WiFi Shield -

-
- - - -
- -
+ Android Phone

+

+ +
+ + + +
+
-
-

Prepare


-

Get your device ready

-
- 01 Mount the Ethernet / Wifi shield on the Arduino Uno device. -
+
+

Prepare

+
+

Get your device ready

+ +
+ 01 Go to android device security settings. +
- 02 Mount the Ethernet / Wifi shield on the Arduino Uno device. + 02 Check unknown sources.
-
- 03 Mount the Ethernet / Wifi shield on the Arduino Uno device. -

Connect (Quickstart)


-

Internet of Things Foundation Quickstart connection

+

Internet of Things Foundation Quickstart connection

+
01 Use the following command to download the installer from GitHub:
- 02 Download the Sketch installer from the Arduino website http://arduino.cc/en/Main/Software
-
-
- 03 Install the Sketch program
+ 02 Copy downloaded apk in to device
- 04 Use the Sketch program to open the samples code: http://tinyurl.com/EUHackathonRobot
+ 03 Install apk in the device.
- 05 View the lower part of the Sketch pad window to check that the COM connection is shown as active
+ 04 Open Android Sense application.
+
{{/zone}} {{#zone "topCss"}} - - + + {{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/raspberrypi/raspberrypi.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/raspberrypi/raspberrypi.hbs index 9b324792..5f373ef9 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/raspberrypi/raspberrypi.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/devices/raspberrypi/raspberrypi.hbs @@ -24,8 +24,8 @@ Raspberry Pi

- - + +

diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/downloads/downloads.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/downloads/downloads.hbs new file mode 100644 index 00000000..e69de29b diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/downloads/downloads.json b/modules/distribution/src/repository/jaggeryapps/iotserver/units/downloads/downloads.json new file mode 100644 index 00000000..0e0dcd23 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/downloads/downloads.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/downloads/public/android-app.apk b/modules/distribution/src/repository/jaggeryapps/iotserver/units/downloads/public/android-app.apk new file mode 100644 index 00000000..e69de29b