From 09805d451cd2d7858152e37b336dda1a92f39716 Mon Sep 17 00:00:00 2001 From: Megala Date: Sat, 3 Dec 2016 02:58:37 +0530 Subject: [PATCH] Adding initial fixes for geo dashboard --- .../Geo-ExecutionPlan-Within_alert.siddhiql | 4 ++-- .../geo-dashboard/js/geo_remote.js | 3 ++- .../geo-dashboard/js/websocket.js | 5 +++-- .../Android-Sense-ExecutionPlan.siddhiql | 15 +++++++-------- .../org.wso2.iot.android.sense_1.0.0.json | 5 +---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql index 85e57604ec..b58fd59e33 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql @@ -12,9 +12,9 @@ define stream dataIn (id string, latitude double, longitude double, timeStamp lo @Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0') define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string); -from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == $deviceId]#geodashboard:subscribe() +from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == "$deviceId"]#geodashboard:subscribe() select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information insert into dataOut; -from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == $deviceId] +from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"] select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information insert into dataOut; diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js index b96b4194e2..b3b3ced6f4 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js @@ -281,7 +281,8 @@ function setWithinAlert(leafletId) { 'parseData': JSON.stringify({ 'geoFenceGeoJSON': selectedAreaGeoJson, 'executionPlanName': createExecutionPlanName(queryName, "WithIn", deviceId), - 'areaName': areaName + 'areaName': areaName, + 'deviceId' : deviceId }), 'executionPlan': 'Within', 'customName': areaName, // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js index 4e6d77126c..4b413e1a1e 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js @@ -677,13 +677,14 @@ function intializeWebsocketUrls() { .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION - + "?token=ee9971c8-bf09-3c83-b097-ce87a0c88806&deviceId=" + deviceId + "&deviceType=" + deviceType; + + "?deviceId=" + deviceId + "&deviceType=" + deviceType; alertWebSocketURL = 'wss://' + data.ip + ':' + data.httpsPort + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION - + "?token=ee9971c8-bf09-3c83-b097-ce87a0c88806&deviceId=" + deviceId + "&deviceType=" + deviceType; + + "?deviceId=" + deviceId + "&deviceType=" + deviceType; + document.cookie = "websocket-token=f98d6142-e988-3c7f-a8c9-7e6d74da7113; path=/"; initializeWebSocket(); initializeOnAlertWebSocket(); }); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql index 743ec44f31..76ed3cde93 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql @@ -3,10 +3,7 @@ @Plan:description('ExecutionPlan') @Import('org.wso2.iot.android.sense:1.0.0') -define stream AndroidSense (meta_owner string, meta_deviceId string, meta_type string, meta_timestamp long, battery int, battery_state string, battery_status string, battery_temperature int, gps_lat double, gps_long double, accelerometer_x float, accelerometer_y float, accelerometer_z float, speed_limit float, turn_way string, magnetic_x float, magnetic_y float, magnetic_z float, gyroscope_x float, gyroscope_y float, gyroscope_z float, light float, pressure float, proximity float, gravity_x float, gravity_y float, gravity_z float, rotation_x float, rotation_y float, rotation_z float, word string, word_sessionId string, word_status string, beacon_major int, beacon_minor int, beacon_proximity string, beacon_uuid int, call_number string, call_type string, call_start_time long, call_end_time long, screen_state string, audio_playing bool, headset_on bool, music_volume int, activity_type int, confidence int, sms_number string, application_name string, action string, data_type string, data_sent long, data_received long); - -@Export('org.wso2.iot.android.data:1.0.0') -define stream DataStream (meta_owner string, meta_deviceId string, meta_timestamp long, type string, received long, sent long); +define stream AndroidSense (meta_owner string, meta_deviceId string, meta_type string, meta_timestamp long, battery int, battery_state string, battery_status string, battery_temperature int, gps_lat double, gps_long double, accelerometer_x float, accelerometer_y float, accelerometer_z float, speed_limit float, turn_way string, magnetic_x float, magnetic_y float, magnetic_z float, gyroscope_x float, gyroscope_y float, gyroscope_z float, light float, pressure float, proximity float, gravity_x float, gravity_y float, gravity_z float, rotation_x float, rotation_y float, rotation_z float, word string, word_sessionId string, word_status string, beacon_major int, beacon_minor int, beacon_proximity string, beacon_uuid int, call_number string, call_type string, call_start_time long, call_end_time long, screen_state string, audio_playing bool, headset_on bool, music_volume int, activity_type int, confidence int, sms_number string, application_name string, action string); @Export('org.wso2.iot.android.activity:1.0.0') define stream ActivityStream (meta_owner string, meta_deviceId string, meta_timestamp long, action string); @@ -29,6 +26,8 @@ define stream BatteryStream (meta_owner string, meta_deviceId string, meta_times @Export('org.wso2.iot.android.sms:1.0.0') define stream SmsStream (meta_owner string, meta_deviceId string, meta_timestamp long, number string, type string, body string); +@Export('org.wso2.geo.LocationStream:1.0.0') +define stream geoLocationStream (id string, timeStamp long, latitude double, longitude double, type string, speed float, heading float); from AndroidSense[meta_type == 'sms'] select meta_owner, meta_deviceId, meta_timestamp, sms_number as number, action as type, "" as body @@ -42,7 +41,7 @@ from AndroidSense[meta_type == 'audio'] select meta_owner, meta_deviceId, meta_timestamp, audio_playing, headset_on, music_volume insert into AudioStream; -from AndroidSense[meta_type == 'location'] +from AndroidSense[meta_type == 'gps'] select meta_owner, meta_deviceId, meta_timestamp, gps_lat as latitude, gps_long as longitude insert into LocationStream; @@ -58,6 +57,6 @@ from AndroidSense[meta_type == 'activity'] select meta_owner, meta_deviceId, meta_timestamp, action insert into ActivityStream; -from AndroidSense[meta_type == 'data'] -select meta_owner, meta_deviceId, meta_timestamp, data_type as type, data_received as received, data_sent as sent -insert into DataStream; \ No newline at end of file +from AndroidSense[meta_type == 'gps'] +select meta_deviceId as id, meta_timestamp as timeStamp, gps_lat as latitude, gps_long as longitude, "android_sense" as type, speed_limit as speed, 0.0f as heading +insert into geoLocationStream; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_streams/org.wso2.iot.android.sense_1.0.0.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_streams/org.wso2.iot.android.sense_1.0.0.json index 878b4b63d7..4668b4bfea 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_streams/org.wso2.iot.android.sense_1.0.0.json +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_streams/org.wso2.iot.android.sense_1.0.0.json @@ -55,9 +55,6 @@ {"name": "confidence", "type": "INT"}, {"name": "sms_number", "type": "STRING"}, {"name": "application_name", "type": "STRING"}, - {"name": "action", "type": "STRING"}, - {"name": "data_type", "type": "STRING"}, - {"name": "data_sent", "type": "LONG"}, - {"name": "data_received", "type": "LONG"} + {"name": "action", "type": "STRING"} ] }