From 55601641e36672f3bb20706c9fbbace8d7f970bf Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 12 Jul 2017 14:55:01 +0530 Subject: [PATCH] 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) {