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 + 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..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 @@ -20,11 +20,18 @@ coffee_level_script - 0 0/5 * * * ? + 0 0/3 * * * ? 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..ae4e4d9a --- /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/3c * * * ? + 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..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 @@ -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 = 100; 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..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() { @@ -41,9 +44,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 +115,11 @@ function connect(wsConnection, target, chartData, graph, sensorType) { graph.update(); }; } + if (sensorType == "temperature") { + wsConnectionTemperature = wsConnection; + } else { + wsConnectionCoffeeLevel = wsConnection; + } } function disconnect(wsConnection) {