From ed7f15346a1e3ae5f7177e1148bc96eddfc2b976 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Fri, 7 Jul 2017 18:16:42 +0530 Subject: [PATCH 1/6] updating connected cup order coffee cup url --- .../connectedcup/component/agent/src/main/webapp/index.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/distribution/src/core/samples/connectedcup/component/agent/src/main/webapp/index.jsp b/modules/distribution/src/core/samples/connectedcup/component/agent/src/main/webapp/index.jsp index 1d68c7ae..5c9425b3 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/agent/src/main/webapp/index.jsp +++ b/modules/distribution/src/core/samples/connectedcup/component/agent/src/main/webapp/index.jsp @@ -101,7 +101,7 @@ var deviceId = '<%=request.getSession().getAttribute("deviceId")%>'; var deviceOwner = '<%=request.getSession().getAttribute("deviceOwner")%>'; var token = '<%=request.getSession().getAttribute("token")%>'; - var url = '/connectedcup/controller/ordercoffee?deviceId=' + deviceId + '&deviceOwner=' + deviceOwner; + var url = '/connectedcup/device/ordercoffee?deviceId=' + deviceId ; $.ajax({ type: 'POST', @@ -131,4 +131,4 @@ sendData(); - \ No newline at end of file + From 55601641e36672f3bb20706c9fbbace8d7f970bf Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 12 Jul 2017 14:55:01 +0530 Subject: [PATCH 2/6] fixes for connected cup, device_temperature_summary table missing --- .../carbonapps/coffee_level/artifacts.xml | 5 ++ .../coffee_level_script.xml | 13 +++- .../temperature_level_publisher/artifact.xml | 22 +++++++ .../temperature_level_publisher.xml | 25 ++++++++ .../temperature_level_receiver/artifact.xml | 22 +++++++ .../temperature_level_receiver.xml | 27 ++++++++ .../temperature_level_script/artifact.xml | 22 +++++++ .../temperature_level_script.xml | 35 +++++++++++ .../temperature_level_store/artifact.xml | 22 +++++++ .../org_wso2_iot_devices_temperature.xml | 63 +++++++++++++++++++ .../temperature_level_stream/artifact.xml | 23 +++++++ ...rg.wso2.iot.devices.temperature_1.0.0.json | 17 +++++ .../connected_cup_publisher.xml | 2 +- .../java/org/coffeeking/api/util/APIUtil.java | 8 ++- .../public/js/device-stats.js | 11 +++- 15 files changed, 309 insertions(+), 8 deletions(-) create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/artifact.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/temperature_level_publisher.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/artifact.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/temperature_level_receiver.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/artifact.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/artifact.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/org_wso2_iot_devices_temperature.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/artifact.xml create mode 100644 modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/org.wso2.iot.devices.temperature_1.0.0.json diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml index 8a29b5f2..d8cf034c 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/artifacts.xml @@ -24,5 +24,10 @@ + + + + + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml index 15684e58..636bffe5 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml @@ -20,11 +20,18 @@ coffee_level_script 0 0/5 * * * ? diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/artifact.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/artifact.xml new file mode 100644 index 00000000..9803a168 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/artifact.xml @@ -0,0 +1,22 @@ + + + + + temperature_level_publisher.xml + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/temperature_level_publisher.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/temperature_level_publisher.xml new file mode 100644 index 00000000..16a0bce0 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_publisher/temperature_level_publisher.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/artifact.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/artifact.xml new file mode 100644 index 00000000..5647c8e1 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/artifact.xml @@ -0,0 +1,22 @@ + + + + + temperature_level_receiver.xml + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/temperature_level_receiver.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/temperature_level_receiver.xml new file mode 100644 index 00000000..4e36e4c7 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_receiver/temperature_level_receiver.xml @@ -0,0 +1,27 @@ + + + + + + false + + + + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/artifact.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/artifact.xml new file mode 100644 index 00000000..fdd524ed --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/artifact.xml @@ -0,0 +1,22 @@ + + + + + temperature_level_script.xml + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml new file mode 100644 index 00000000..a978e693 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml @@ -0,0 +1,35 @@ + + + + + temperature_level_script + + 0 0/5 * * * ? + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/artifact.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/artifact.xml new file mode 100644 index 00000000..cdf54780 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/artifact.xml @@ -0,0 +1,22 @@ + + + + + org_wso2_iot_devices_temperature.xml + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/org_wso2_iot_devices_temperature.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/org_wso2_iot_devices_temperature.xml new file mode 100644 index 00000000..bc448459 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_store/org_wso2_iot_devices_temperature.xml @@ -0,0 +1,63 @@ + + + + + + + meta_owner + true + true + false + STRING + + + meta_deviceType + true + true + false + STRING + + + meta_deviceId + true + true + false + STRING + + + meta_time + true + true + false + LONG + + + temperature + false + false + false + FLOAT + + + + org.wso2.iot.devices.temperature:1.0.0 + + + EVENT_STORE + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/artifact.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/artifact.xml new file mode 100644 index 00000000..841c1d4f --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/artifact.xml @@ -0,0 +1,23 @@ + + + + + org.wso2.iot.devices.temperature_1.0.0.json + + diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/org.wso2.iot.devices.temperature_1.0.0.json b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/org.wso2.iot.devices.temperature_1.0.0.json new file mode 100644 index 00000000..c2e3ada2 --- /dev/null +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_stream/org.wso2.iot.devices.temperature_1.0.0.json @@ -0,0 +1,17 @@ +{ + "name": "org.wso2.iot.devices.temperature", + "version": "1.0.0", + "nickName": "TemperatureLevel", + "description": "Temperature Level data received from the Device", + "metaData": [ + {"name":"owner","type":"STRING"}, + {"name":"deviceType","type":"STRING"}, + {"name":"deviceId","type":"STRING"}, + {"name":"time","type":"LONG"} + ], + "payloadData": [ + { + "name": "temperature","type": "FLOAT" + } + ] +} diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml index 4a6ff9ff..597b9661 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/connected_cup/connected_cup_publisher/connected_cup_publisher.xml @@ -20,6 +20,6 @@ - + diff --git a/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java b/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java index 65ee31e6..06d68c00 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java +++ b/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java @@ -89,10 +89,16 @@ public class APIUtil { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI(); int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query); + // limiting the data read from the server + int start = 0; + int dataCount = 1000; if (eventCount == 0) { return null; + } else if (eventCount >= dataCount){ + start = eventCount - dataCount; } - List resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount, + + List resultEntries = analyticsDataAPI.search(tenantId, tableName, query, start, eventCount, sortByFields); List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); diff --git a/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js b/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js index 17381ee5..5825085c 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js +++ b/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js @@ -41,9 +41,9 @@ function drawGraph(wsConnection, placeHolder, yAxis, chat, chartData, graph) { var tNow = new Date().getTime() / 1000; for (var i = 0; i < 30; i++) { chartData.push({ - x: tNow - (30 - i) * 15, - y: parseFloat(0) - }); + x: tNow - (30 - i) * 15, + y: parseFloat(0) + }); } graph = new Rickshaw.Graph({ @@ -112,6 +112,11 @@ function connect(wsConnection, target, chartData, graph, sensorType) { graph.update(); }; } + if (sensorType == "temperature") { + wsConnectionTemperature = wsConnection; + } else { + wsConnectionCoffeeLevel = wsConnection; + } } function disconnect(wsConnection) { From 0bae6b15197a0bd7e14f17c6800cfebc7fbe9a81 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 12 Jul 2017 16:29:43 +0530 Subject: [PATCH 3/6] symultaneous stream authentication failure fix --- .../public/js/device-stats.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js b/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js index 5825085c..de7e6c6b 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js +++ b/modules/distribution/src/core/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js @@ -28,8 +28,11 @@ var palette = new Rickshaw.Color.Palette({scheme: "classic9"}); $(window).load(function () { drawGraph(wsConnectionTemperature, "#div-chartTemperature", "y_axisTemperature", "chartTemperature", chartDataSensorTypeTemperature , graphForSensorTypeTemperature); - drawGraph(wsConnectionCoffeeLevel, "#div-chartCoffeeLevel", "y_axisCoffeeLevel", "chartCoffeeLevel", chartDataSensorTypeCoffeeLevel - , graphForSensorTypeCoffeeLevel); + var millisecondsToWait = 1000; + setTimeout(function() { + drawGraph(wsConnectionCoffeeLevel, "#div-chartCoffeeLevel", "y_axisCoffeeLevel", "chartCoffeeLevel", chartDataSensorTypeCoffeeLevel + , graphForSensorTypeCoffeeLevel); + }, millisecondsToWait); }); window.onbeforeunload = function() { From 2ab4e8fa135499a96a9f733a5a5cf8c7533000fb Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 13 Jul 2017 17:49:58 +0530 Subject: [PATCH 4/6] changing update summary to 3 mins. --- .../coffee_level/coffee_level_script/coffee_level_script.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml index 636bffe5..3e965230 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/coffee_level_script/coffee_level_script.xml @@ -33,5 +33,5 @@ from DeviceCoffeeLevelData group by coffeelevel, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT); - 0 0/5 * * * ? + 0 0/3 * * * ? From 3eb75d040d985d0a3304e6956ad2b3a50df54c0c Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 13 Jul 2017 17:50:40 +0530 Subject: [PATCH 5/6] changing update summary to 3 mins --- .../temperature_level_script/temperature_level_script.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml index a978e693..ae4e4d9a 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml +++ b/modules/distribution/src/core/samples/connectedcup/component/analytics/src/main/resources/carbonapps/coffee_level/temperature_level_script/temperature_level_script.xml @@ -31,5 +31,5 @@ from DeviceTemperatureLevelData group by temperature, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT); - 0 0/5 * * * ? + 0 0/3c * * * ? From dec82f5b0feda2747a7fde1935ee7930aca1df38 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 13 Jul 2017 18:43:10 +0530 Subject: [PATCH 6/6] changing data count to 100 --- .../api/src/main/java/org/coffeeking/api/util/APIUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java b/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java index 06d68c00..efb120c7 100644 --- a/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java +++ b/modules/distribution/src/core/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/APIUtil.java @@ -91,7 +91,7 @@ public class APIUtil { int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query); // limiting the data read from the server int start = 0; - int dataCount = 1000; + int dataCount = 100; if (eventCount == 0) { return null; } else if (eventCount >= dataCount){