Merge pull request #230 from ayyoob/das-ext

refactored analytic scripts to use custom publisher and recivers
revert-dabc3590
Ruwan 9 years ago
commit b2e95e8f94

@ -23,6 +23,7 @@ import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject;
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler;
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler;
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException;
@ -149,7 +150,7 @@ public class DataPublisherService extends Service {
for (Event event : events) { for (Event event : events) {
event.setOwner(user); event.setOwner(user);
event.setDeviceId(deviceId); event.setDeviceId(deviceId);
jsonArray.put(event.getEvent()); jsonArray.put(new JSONObject().put("event", event.getEvent()));
} }
MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context); MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context);
if (!mqttTransportHandler.isConnected()) { if (!mqttTransportHandler.isConnected()) {

@ -11,7 +11,7 @@ public class Event {
private String owner; private String owner;
private String deviceId; private String deviceId;
private String type; private String type;
private float battery; private int battery;
private double gps[]; //lat,long private double gps[]; //lat,long
private float accelerometer[]; //x,y,z private float accelerometer[]; //x,y,z
private float magnetic[]; //x,y,z private float magnetic[]; //x,y,z
@ -26,11 +26,11 @@ public class Event {
private String wordStatus; private String wordStatus;
private long timestamp; private long timestamp;
private float getBattery() { private int getBattery() {
return battery; return battery;
} }
public void setBattery(float battery) { public void setBattery(int battery) {
this.type = "battery"; this.type = "battery";
this.battery = battery; this.battery = battery;
} }

@ -104,7 +104,6 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler {
}; };
Thread connectorThread = new Thread(connector); Thread connectorThread = new Thread(connector);
connectorThread.setDaemon(true);
connectorThread.start(); connectorThread.start();
} }
@ -207,7 +206,6 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler {
}; };
Thread terminatorThread = new Thread(stopConnection); Thread terminatorThread = new Thread(stopConnection);
terminatorThread.setDaemon(true);
terminatorThread.start(); terminatorThread.start();
} }

@ -81,8 +81,8 @@ public abstract class MQTTTransportHandler implements MqttCallback, TransportHan
this.clientWillTopic = DISCONNECTION_WILL_TOPIC_PREFIX + SenseConstants.DEVICE_TYPE; this.clientWillTopic = DISCONNECTION_WILL_TOPIC_PREFIX + SenseConstants.DEVICE_TYPE;
this.mqttBrokerEndPoint = "tcp://" + LocalRegistry.getServerHost(context) + ":" + LocalRegistry.getMqttPort(context); this.mqttBrokerEndPoint = "tcp://" + LocalRegistry.getServerHost(context) + ":" + LocalRegistry.getMqttPort(context);
this.timeoutInterval = DEFAULT_TIMEOUT_INTERVAL; this.timeoutInterval = DEFAULT_TIMEOUT_INTERVAL;
setUsernameAndPassword(LocalRegistry.getAccessToken(context), "");
this.initMQTTClient(); this.initMQTTClient();
setUsernameAndPassword(LocalRegistry.getAccessToken(context), "");
} }
/** /**
@ -308,7 +308,6 @@ public abstract class MQTTTransportHandler implements MqttCallback, TransportHan
connect(); connect();
} }
}; };
reconnectThread.setDaemon(true);
reconnectThread.start(); reconnectThread.start();
} }
@ -333,7 +332,6 @@ public abstract class MQTTTransportHandler implements MqttCallback, TransportHan
} }
} }
}; };
messageProcessorThread.setDaemon(true);
messageProcessorThread.start(); messageProcessorThread.start();
} }

@ -180,6 +180,9 @@ public class ActivitySelectSensor extends AppCompatActivity
LocalRegistry.removeUsername(getApplicationContext()); LocalRegistry.removeUsername(getApplicationContext());
LocalRegistry.removeDeviceId(getApplicationContext()); LocalRegistry.removeDeviceId(getApplicationContext());
LocalRegistry.removeServerURL(getApplicationContext()); LocalRegistry.removeServerURL(getApplicationContext());
LocalRegistry.removeAccessToken(getApplicationContext());
LocalRegistry.removeRefreshToken(getApplicationContext());
LocalRegistry.removeMqttPort(getApplicationContext());
LocalRegistry.setExist(false); LocalRegistry.setExist(false);
//Stop the current running background services. //Stop the current running background services.
stopService(new Intent(this, SenseService.class)); //Stop sensor reading service stopService(new Intent(this, SenseService.class)); //Stop sensor reading service

@ -95,6 +95,7 @@ public class SenseClientAsyncExecutor extends AsyncTask<String, Void, Map<String
String endpoint = parameters[3]; String endpoint = parameters[3];
Map<String, String> responseMap = new HashMap<>(); Map<String, String> responseMap = new HashMap<>();
responseMap.put(STATUS, "200"); responseMap.put(STATUS, "200");
AccessTokenInfo accessTokenInfo = null;
try { try {
//DynamicClientRegistraiton. //DynamicClientRegistraiton.
DynamicClientRegistrationService dynamicClientRegistrationService = Feign.builder() DynamicClientRegistrationService dynamicClientRegistrationService = Feign.builder()
@ -116,7 +117,7 @@ public class SenseClientAsyncExecutor extends AsyncTask<String, Void, Map<String
new BasicAuthRequestInterceptor(oAuthApplicationInfo.getClient_id(), oAuthApplicationInfo.getClient_secret())) new BasicAuthRequestInterceptor(oAuthApplicationInfo.getClient_id(), oAuthApplicationInfo.getClient_secret()))
.contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder()) .contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.target(TokenIssuerService.class, endpoint + SenseConstants.TOKEN_ISSUER_CONTEXT); .target(TokenIssuerService.class, endpoint + SenseConstants.TOKEN_ISSUER_CONTEXT);
AccessTokenInfo accessTokenInfo = tokenIssuerService.getToken("password", username, password); accessTokenInfo = tokenIssuerService.getToken("password", username, password);
//ApiApplicationRegistration //ApiApplicationRegistration
ApiApplicationRegistrationService apiApplicationRegistrationService = Feign.builder().client(disableHostnameVerification) ApiApplicationRegistrationService apiApplicationRegistrationService = Feign.builder().client(disableHostnameVerification)
@ -145,6 +146,10 @@ public class SenseClientAsyncExecutor extends AsyncTask<String, Void, Map<String
return responseMap; return responseMap;
} catch (FeignException e) { } catch (FeignException e) {
responseMap.put(STATUS, "" + e.status()); responseMap.put(STATUS, "" + e.status());
if (e.status() == 409) {
LocalRegistry.addAccessToken(context, accessTokenInfo.getAccess_token());
LocalRegistry.addRefreshToken(context, accessTokenInfo.getRefresh_token());
}
return responseMap; return responseMap;
} }
} }

@ -4,7 +4,8 @@
android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" tools:context="org.wso2.carbon.iot.android.sense.RegisterActivity"> android:paddingTop="@dimen/activity_vertical_margin" tools:context="org.wso2.carbon.iot.android.sense.RegisterActivity"
android:weightSum="1">
<!-- Login progress --> <!-- Login progress -->
@ -14,7 +15,8 @@
<ScrollView android:id="@+id/login_form" android:layout_width="match_parent" <ScrollView android:id="@+id/login_form" android:layout_width="match_parent"
android:layout_height="211dp" android:layout_height="211dp"
android:fillViewport="false"> android:fillViewport="false"
android:layout_weight="0.07">
<LinearLayout android:id="@+id/email_login_form" android:layout_width="match_parent" <LinearLayout android:id="@+id/email_login_form" android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"> android:layout_height="wrap_content" android:orientation="vertical">
@ -37,33 +39,20 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/hostname" android:layout_height="wrap_content" android:hint="@string/hostname"
android:id="@+id/hostname" android:id="@+id/hostname"
android:text="https://localhost:9443" android:text="https://10.10.10.149:9443"
android:inputType="text" android:inputType="text"
android:maxLines="1" android:singleLine="true"/> android:maxLines="1" android:singleLine="true"/>
<Button android:id="@+id/device_register_button" style="?android:textAppearanceSmall"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:text="@string/action_sign_in"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:text="MQTT Port" android:text="MQTT Port"
android:id="@+id/textView4" android:id="@+id/textView4"
android:layout_gravity="center_horizontal"/> />
<EditText <EditText
android:layout_width="350dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/hostname" android:hint="@string/hostname"
android:id="@+id/mqttPort" android:id="@+id/mqttPort"
@ -71,9 +60,15 @@
android:inputType="text" android:inputType="text"
android:maxLines="1" android:maxLines="1"
android:singleLine="true" android:singleLine="true"
android:layout_gravity="right"/> />
</LinearLayout>
</ScrollView>
<Button android:id="@+id/device_register_button" style="?android:textAppearanceSmall"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:text="@string/action_sign_in"
android:textStyle="bold" />
</LinearLayout> </LinearLayout>

@ -23,17 +23,7 @@
<property name="target-dir" value="target/carbonapps"/> <property name="target-dir" value="target/carbonapps"/>
<property name="src-dir" value="src/main/resources/carbonapps"/> <property name="src-dir" value="src/main/resources/carbonapps"/>
<property name="GPS_dir" value="GPS"/> <property name="Android_Sense_dir" value="Android_Sense"/>
<property name="Light_dir" value="Light"/>
<property name="Battery_dir" value="Battery"/>
<property name="Magnetic_dir" value="Magnetic"/>
<property name="Accelerometer_dir" value="Accelerometer"/>
<property name="Gravity_dir" value="Gravity"/>
<property name="Gyroscope_dir" value="Gyroscope"/>
<property name="Proximity_dir" value="Proximity"/>
<property name="Pressure_dir" value="Pressure"/>
<property name="Rotation_dir" value="Rotation"/>
<property name="Wordcounter_dir" value="WordCount"/>
<target name="clean"> <target name="clean">
<delete dir="${target-dir}" /> <delete dir="${target-dir}" />
@ -41,38 +31,8 @@
<target name="zip" depends="clean"> <target name="zip" depends="clean">
<mkdir dir="${target-dir}"/> <mkdir dir="${target-dir}"/>
<zip destfile="${target-dir}/${GPS_dir}.car"> <zip destfile="${target-dir}/${Android_Sense_dir}.car">
<zipfileset dir="${src-dir}/${GPS_dir}"/> <zipfileset dir="${src-dir}/${Android_Sense_dir}"/>
</zip>
<zip destfile="${target-dir}/${Light_dir}.car">
<zipfileset dir="${src-dir}/${Light_dir}"/>
</zip>
<zip destfile="${target-dir}/${Battery_dir}.car">
<zipfileset dir="${src-dir}/${Battery_dir}"/>
</zip>
<zip destfile="${target-dir}/${Magnetic_dir}.car">
<zipfileset dir="${src-dir}/${Magnetic_dir}"/>
</zip>
<zip destfile="${target-dir}/${Accelerometer_dir}.car">
<zipfileset dir="${src-dir}/${Accelerometer_dir}"/>
</zip>
<zip destfile="${target-dir}/${Gravity_dir}.car">
<zipfileset dir="${src-dir}/${Gravity_dir}"/>
</zip>
<zip destfile="${target-dir}/${Gyroscope_dir}.car">
<zipfileset dir="${src-dir}/${Gyroscope_dir}"/>
</zip>
<zip destfile="${target-dir}/${Pressure_dir}.car">
<zipfileset dir="${src-dir}/${Pressure_dir}"/>
</zip>
<zip destfile="${target-dir}/${Rotation_dir}.car">
<zipfileset dir="${src-dir}/${Rotation_dir}"/>
</zip>
<zip destfile="${target-dir}/${Proximity_dir}.car">
<zipfileset dir="${src-dir}/${Proximity_dir}"/>
</zip>
<zip destfile="${target-dir}/${Wordcounter_dir}.car">
<zipfileset dir="${src-dir}/${Wordcounter_dir}"/>
</zip> </zip>
</target> </target>
</project> </project>

@ -0,0 +1,87 @@
/* Enter a unique ExecutionPlan */
@Plan:name('android_sense_execution')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Export('org.wso2.iot.devices.wordcount:1.0.0')
define stream words (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, sessionId string, word string, status string);
@Export('org.wso2.iot.devices.rotation:1.0.0')
define stream rotation (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, x float, y float, z float);
@Export('org.wso2.iot.devices.proximity:1.0.0')
define stream proximity (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, proximity float);
@Export('org.wso2.iot.devices.pressure:1.0.0')
define stream pressure (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, pressure float);
@Export('org.wso2.iot.devices.magnetic:1.0.0')
define stream magnetic (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, x float, y float, z float);
@Export('org.wso2.iot.devices.light:1.0.0')
define stream light (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, light float);
@Export('org.wso2.iot.devices.gyroscope:1.0.0')
define stream gyroscope (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, x float, y float, z float);
@Export('org.wso2.iot.devices.gravity:1.0.0')
define stream gravity (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, x float, y float, z float);
@Export('org.wso2.iot.devices.gps:1.0.0')
define stream gps (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, latitude double, longitude double);
@Export('org.wso2.iot.devices.battery:1.0.0')
define stream battery (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, level int);
@Export('org.wso2.iot.devices.accelerometer:1.0.0')
define stream accelerometer (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, x float, y float, z float);
@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, gps_lat double, gps_long double, accelerometer_x float, accelerometer_y float, accelerometer_z float, 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);
from androidsense[meta_type == 'accelerometer']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, accelerometer_x as x, accelerometer_y as y, accelerometer_z as z
insert into accelerometer;
from androidsense[meta_type == 'battery']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, battery as level
insert into battery;
from androidsense[meta_type == 'gps']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, gps_lat as latitude, gps_long as longitude
insert into gps;
from androidsense[meta_type == 'gravity']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, gravity_x as x, gravity_y as y, gravity_z as z
insert into gravity;
from androidsense[meta_type == 'gyroscope']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, gyroscope_x as x, gyroscope_y as y, gyroscope_z as z
insert into gyroscope;
from androidsense[meta_type == 'light']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, light
insert into light;
from androidsense[meta_type == 'magnetic']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, magnetic_x as x, magnetic_y as y, magnetic_z as z
insert into magnetic;
from androidsense[meta_type == 'pressure']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, pressure
insert into pressure;
from androidsense[meta_type == 'proximity']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, proximity
insert into proximity;
from androidsense[meta_type == 'rotation']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, rotation_x as x, rotation_y as y, rotation_z as z
insert into rotation;
from androidsense[meta_type == 'word']
select meta_owner, 'android_sense' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, word_sessionId as sessionId, word as word, word_status as status
insert into words;

@ -17,7 +17,7 @@
~ under the License. ~ under the License.
--> -->
<artifact name="Eventstream_temperature" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer"> <artifact name="EventExecution_AndroidSense" version="1.0.0" type="event/execution-plan" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.temperature_1.0.0.json</file> <file>EventExecution_AndroidSense.siddhiql</file>
</artifact> </artifact>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<eventPublisher name="EventPublisher_AndroidSense" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="org.wso2.iot.android.sense" version="1.0.0"/>
<mapping customMapping="disable" type="wso2event"/>
<to eventAdapterType="iot-ui"/>
</eventPublisher>

@ -17,6 +17,6 @@
~ under the License. ~ under the License.
--> -->
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer"> <artifact name="EventPublisher_AndroidSense" version="1.0.0" type="event/publisher" serverRole="DataAnalyticsServer">
<file>Temperature_Sensor_Script.xml</file> <file>EventPublisher_AndroidSense.xml</file>
</artifact> </artifact>

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<eventReceiver name="EventReceiver_AndroidSense" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="oauth-mqtt">
<property name="topic">wso2/android_sense/#</property>
<property name="username">admin</property>
<property name="contentValidationParams">device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:2</property>
<property name="contentValidation">default</property>
<property name="dcrUrl">https://localhost:9443/dynamic-client-web/register</property>
<property name="url">tcp://localhost:1883</property>
<property name="cleanSession">false</property>
</from>
<mapping customMapping="disable" type="json"/>
<to streamName="org.wso2.iot.android.sense" version="1.0.0"/>
</eventReceiver>

@ -17,6 +17,6 @@
~ under the License. ~ under the License.
--> -->
<artifact name="Eventreceiver_temperature" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer"> <artifact name="EventReceiver_AndroidSense" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_temperature.xml</file> <file>EventReceiver_AndroidSense.xml</file>
</artifact> </artifact>

@ -17,6 +17,7 @@
~ under the License. ~ under the License.
--> -->
<artifact name="Eventreceiver_temperature" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer"> <artifact name="EventStream_AndroidSense" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>EventReceiver_temperature.xml</file> <file>org.wso2.iot.android.sense_1.0.0.json</file>
</artifact> </artifact>

@ -0,0 +1,38 @@
{
"name": "org.wso2.iot.android.sense",
"version": "1.0.0",
"nickName": "android_sense_stream",
"description": "This hold the device type stream of android sense",
"metaData": [
{"name": "owner", "type": "STRING"},
{"name": "deviceId", "type": "STRING"},
{"name": "type", "type": "STRING"},
{"name": "timestamp", "type": "LONG"}
],
"payloadData": [
{"name": "battery", "type": "INT"},
{"name": "gps_lat", "type": "DOUBLE"},
{"name": "gps_long", "type": "DOUBLE"},
{"name": "accelerometer_x", "type": "FLOAT"},
{"name": "accelerometer_y", "type": "FLOAT"},
{"name": "accelerometer_z", "type": "FLOAT"},
{"name": "magnetic_x", "type": "FLOAT"},
{"name": "magnetic_y", "type": "FLOAT"},
{"name": "magnetic_z", "type": "FLOAT"},
{"name": "gyroscope_x", "type": "FLOAT"},
{"name": "gyroscope_y", "type": "FLOAT"},
{"name": "gyroscope_z", "type": "FLOAT"},
{"name": "light", "type": "FLOAT"},
{"name": "pressure", "type": "FLOAT"},
{"name": "proximity", "type": "FLOAT"},
{"name": "gravity_x", "type": "FLOAT"},
{"name": "gravity_y", "type": "FLOAT"},
{"name": "gravity_z", "type": "FLOAT"},
{"name": "rotation_x", "type": "FLOAT"},
{"name": "rotation_y", "type": "FLOAT"},
{"name": "rotation_z", "type": "FLOAT"},
{"name": "word", "type": "STRING"},
{"name": "word_sessionId", "type": "STRING"},
{"name": "word_status", "type": "STRING"}
]
}

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<artifacts>
<artifact name="AndroidSense_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="EventStream_AndroidSense" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="EventReceiver_AndroidSense" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="EventPublisher_AndroidSense" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="EventExecution_AndroidSense" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -57,8 +57,7 @@ public class AndroidSenseControllerServiceImpl implements AndroidSenseController
@POST @POST
public Response sendKeyWords(@PathParam("deviceId") String deviceId, @FormParam("keywords") String keywords) { public Response sendKeyWords(@PathParam("deviceId") String deviceId, @FormParam("keywords") String keywords) {
try { try {
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); androidSenseMQTTConnector.publishDeviceData(deviceId, "add", keywords);
androidSenseMQTTConnector.publishDeviceData(username, deviceId, "add", keywords);
return Response.ok().build(); return Response.ok().build();
} catch (TransportHandlerException e) { } catch (TransportHandlerException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
@ -69,8 +68,7 @@ public class AndroidSenseControllerServiceImpl implements AndroidSenseController
@POST @POST
public Response sendThreshold(@PathParam("deviceId") String deviceId, @FormParam("threshold") String threshold) { public Response sendThreshold(@PathParam("deviceId") String deviceId, @FormParam("threshold") String threshold) {
try { try {
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); androidSenseMQTTConnector.publishDeviceData(deviceId, "threshold", threshold);
androidSenseMQTTConnector.publishDeviceData(username, deviceId, "threshold", threshold);
return Response.ok().build(); return Response.ok().build();
} catch (TransportHandlerException e) { } catch (TransportHandlerException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
@ -79,10 +77,9 @@ public class AndroidSenseControllerServiceImpl implements AndroidSenseController
@Path("device/{deviceId}/words") @Path("device/{deviceId}/words")
@DELETE @DELETE
public Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words) { public Response removeKeyWords(@PathParam("deviceId") String deviceId, @FormParam("words") String words) {
try { try {
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); androidSenseMQTTConnector.publishDeviceData(deviceId, "remove", words);
androidSenseMQTTConnector.publishDeviceData(username, deviceId, "remove", words);
return Response.ok().build(); return Response.ok().build();
} catch (TransportHandlerException e) { } catch (TransportHandlerException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
@ -191,7 +188,7 @@ public class AndroidSenseControllerServiceImpl implements AndroidSenseController
if (waitForServerStartup()) { if (waitForServerStartup()) {
return; return;
} }
//The delay is added till the server starts up. //The delay is added for the server to starts up.
try { try {
Thread.sleep(5000); Thread.sleep(5000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -208,7 +205,6 @@ public class AndroidSenseControllerServiceImpl implements AndroidSenseController
} }
}; };
Thread connectorThread = new Thread(connector); Thread connectorThread = new Thread(connector);
connectorThread.setDaemon(true);
connectorThread.start(); connectorThread.start();
} }

@ -101,7 +101,6 @@ public class AndroidSenseMQTTConnector extends MQTTTransportHandler {
} }
}; };
Thread connectorThread = new Thread(connector); Thread connectorThread = new Thread(connector);
connectorThread.setDaemon(true);
connectorThread.start(); connectorThread.start();
} }
@ -195,7 +194,6 @@ public class AndroidSenseMQTTConnector extends MQTTTransportHandler {
} }
}; };
Thread terminatorThread = new Thread(stopConnection); Thread terminatorThread = new Thread(stopConnection);
terminatorThread.setDaemon(true);
terminatorThread.start(); terminatorThread.start();
} }
} }

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project name="create-sample-sensor-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="target/carbonapps"/>
<property name="src-dir" value="src/main/resources/carbonapps"/>
<property name="Temperature_Sensor_dir" value="Temperature_Sensor"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<mkdir dir="${target-dir}"/>
<zip destfile="${target-dir}/${Temperature_Sensor_dir}.car">
<zipfileset dir="${src-dir}/${Temperature_Sensor_dir}"/>
</zip>
</target>
</project>

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Script>
CREATE TEMPORARY TABLE DeviceTemperatureData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_TEMPERATURE");
CREATE TEMPORARY TABLE DeviceTemperatureSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_TEMPERATURE_SUMMARY", schema "temperature FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceTemperatureSummaryData select temperature, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceTemperatureData group by temperature, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script>
<CronExpression>0 * * * * ?</CronExpression>
</Analytics>

@ -34,7 +34,6 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<module>org.wso2.carbon.device.mgt.iot.arduino.analytics</module>
<module>org.wso2.carbon.device.mgt.iot.arduino.api</module> <module>org.wso2.carbon.device.mgt.iot.arduino.api</module>
<module>org.wso2.carbon.device.mgt.iot.arduino.plugin</module> <module>org.wso2.carbon.device.mgt.iot.arduino.plugin</module>
<module>org.wso2.carbon.device.mgt.iot.arduino.ui</module> <module>org.wso2.carbon.device.mgt.iot.arduino.ui</module>

@ -233,7 +233,7 @@ public class DigitalDisplayControllerServiceImpl implements DigitalDisplayContro
private boolean waitForServerStartup() { private boolean waitForServerStartup() {
while (!IoTServerStartupListener.isServerReady()) { while (!IoTServerStartupListener.isServerReady()) {
try { try {
Thread.sleep(1000); Thread.sleep(5000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
return true; return true;
} }
@ -253,6 +253,12 @@ public class DigitalDisplayControllerServiceImpl implements DigitalDisplayContro
if (waitForServerStartup()) { if (waitForServerStartup()) {
return; return;
} }
//The delay is added for the server to starts up.
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
DigitalDisplayControllerServiceImpl.digitalDisplayMQTTConnector = digitalDisplayMQTTConnector; DigitalDisplayControllerServiceImpl.digitalDisplayMQTTConnector = digitalDisplayMQTTConnector;
if (MqttConfig.getInstance().isEnabled()) { if (MqttConfig.getInstance().isEnabled()) {
digitalDisplayMQTTConnector.connect(); digitalDisplayMQTTConnector.connect();
@ -263,7 +269,6 @@ public class DigitalDisplayControllerServiceImpl implements DigitalDisplayContro
} }
}; };
Thread connectorThread = new Thread(connector); Thread connectorThread = new Thread(connector);
connectorThread.setDaemon(true);
connectorThread.start(); connectorThread.start();
} }

@ -96,7 +96,6 @@ public class DigitalDisplayMQTTConnector extends MQTTTransportHandler {
}; };
Thread connectorThread = new Thread(connector); Thread connectorThread = new Thread(connector);
connectorThread.setDaemon(true);
connectorThread.start(); connectorThread.start();
} }
@ -182,7 +181,6 @@ public class DigitalDisplayMQTTConnector extends MQTTTransportHandler {
}; };
Thread terminatorThread = new Thread(stopConnection); Thread terminatorThread = new Thread(stopConnection);
terminatorThread.setDaemon(true);
terminatorThread.start(); terminatorThread.start();
} }

@ -55,7 +55,6 @@ public class DroneRealTimeService {
} }
}; };
Thread connectorThread = new Thread(connector); Thread connectorThread = new Thread(connector);
connectorThread.setDaemon(true);
connectorThread.start(); connectorThread.start();
} }

@ -134,7 +134,6 @@ public class DroneAnalyzerXMPPConnector extends XMPPTransportHandler {
} }
}; };
Thread terminatorThread = new Thread(stopConnection); Thread terminatorThread = new Thread(stopConnection);
terminatorThread.setDaemon(true);
terminatorThread.start(); terminatorThread.start();
} }

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project name="create-sample-sensor-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="target/carbonapps"/>
<property name="src-dir" value="src/main/resources/carbonapps"/>
<property name="GPS_dir" value="GPS"/>
<property name="Light_dir" value="Light"/>
<property name="Battery_dir" value="Battery"/>
<property name="Magnetic_dir" value="Magnetic"/>
<property name="Accelerometer_dir" value="Accelerometer"/>
<property name="Gravity_dir" value="Gravity"/>
<property name="Gyroscope_dir" value="Gyroscope"/>
<property name="Proximity_dir" value="Proximity"/>
<property name="Pressure_dir" value="Pressure"/>
<property name="Rotation_dir" value="Rotation"/>
<property name="Wordcounter_dir" value="WordCount"/>
<property name="Temperature_dir" value="Temperature"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<mkdir dir="${target-dir}"/>
<zip destfile="${target-dir}/${GPS_dir}.car">
<zipfileset dir="${src-dir}/${GPS_dir}"/>
</zip>
<zip destfile="${target-dir}/${Light_dir}.car">
<zipfileset dir="${src-dir}/${Light_dir}"/>
</zip>
<zip destfile="${target-dir}/${Battery_dir}.car">
<zipfileset dir="${src-dir}/${Battery_dir}"/>
</zip>
<zip destfile="${target-dir}/${Magnetic_dir}.car">
<zipfileset dir="${src-dir}/${Magnetic_dir}"/>
</zip>
<zip destfile="${target-dir}/${Accelerometer_dir}.car">
<zipfileset dir="${src-dir}/${Accelerometer_dir}"/>
</zip>
<zip destfile="${target-dir}/${Gravity_dir}.car">
<zipfileset dir="${src-dir}/${Gravity_dir}"/>
</zip>
<zip destfile="${target-dir}/${Gyroscope_dir}.car">
<zipfileset dir="${src-dir}/${Gyroscope_dir}"/>
</zip>
<zip destfile="${target-dir}/${Pressure_dir}.car">
<zipfileset dir="${src-dir}/${Pressure_dir}"/>
</zip>
<zip destfile="${target-dir}/${Rotation_dir}.car">
<zipfileset dir="${src-dir}/${Rotation_dir}"/>
</zip>
<zip destfile="${target-dir}/${Proximity_dir}.car">
<zipfileset dir="${src-dir}/${Proximity_dir}"/>
</zip>
<zip destfile="${target-dir}/${Wordcounter_dir}.car">
<zipfileset dir="${src-dir}/${Wordcounter_dir}"/>
</zip>
<zip destfile="${target-dir}/${Temperature_dir}.car">
<zipfileset dir="${src-dir}/${Temperature_dir}"/>
</zip>
</target>
</project>

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
@ -22,15 +21,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <parent>
<artifactId>arduino-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>iot-analytics</artifactId>
<version>2.1.0-SNAPSHOT</version> <version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.arduino.analytics</artifactId> <artifactId>org.wso2.carbon.device.mgt.iot.analytics</artifactId>
<name>WSO2 Carbon - IoT Server Arduino Analytics capp</name> <name>WSO2 Carbon - IoT Server Analytics C-APP</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<build> <build>

@ -52,7 +52,21 @@
<Type>LONG</Type> <Type>LONG</Type>
</ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> <ColumnDefinition>
<Name>accelerometer</Name> <Name>x</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>y</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>z</Name>
<EnableIndexing>false</EnableIndexing> <EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey> <IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam> <EnableScoreParam>false</EnableScoreParam>

@ -17,7 +17,7 @@
~ under the License. ~ under the License.
--> -->
<artifact name="Eventstream_temperature" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer"> <artifact name="Eventstream_accelerometer" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.temperature_1.0.0.json</file> <file>org.wso2.iot.devices.accelerometer_1.0.0.json</file>
</artifact> </artifact>

@ -22,10 +22,9 @@
<Script> <Script>
CREATE TEMPORARY TABLE DeviceAccelerometerData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_ACCELEROMETER"); CREATE TEMPORARY TABLE DeviceAccelerometerData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_ACCELEROMETER");
CREATE TEMPORARY TABLE DeviceAccelerometerSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_ACCELEROMETER_SUMMARY", schema "accelerometer FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DeviceAccelerometerSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_ACCELEROMETER_SUMMARY", schema "x FLOAT, y FLOAT, z FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceAccelerometerSummaryData select x, y, z, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceAccelerometerData group by x, y, z, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
insert overwrite table DeviceAccelerometerSummaryData select accelerometer, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceAccelerometerData group by accelerometer, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>
<CronExpression>0 * * * * ?</CronExpression> <CronExpression>0 * * * * ?</CronExpression>
</Analytics> </Analytics>

@ -19,11 +19,9 @@
<artifacts> <artifacts>
<artifact name="Accelerometer_CAPP" version="1.0.0" type="carbon/application"> <artifact name="Accelerometer_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_accelerometer" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstream_accelerometer" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_accelerometer" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstore_accelerometer" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_accelerometer" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventreceiver_accelerometer" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact> </artifact>
</artifacts> </artifacts>

@ -52,11 +52,11 @@
<Type>LONG</Type> <Type>LONG</Type>
</ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> <ColumnDefinition>
<Name>battery</Name> <Name>level</Name>
<EnableIndexing>false</EnableIndexing> <EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey> <IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam> <EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type> <Type>INT</Type>
</ColumnDefinition> </ColumnDefinition>
</TableSchema> </TableSchema>
</EventStoreConfiguration> </EventStoreConfiguration>

@ -22,10 +22,9 @@
<Script> <Script>
CREATE TEMPORARY TABLE DeviceBatteryData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_BATTERY"); CREATE TEMPORARY TABLE DeviceBatteryData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_BATTERY");
CREATE TEMPORARY TABLE DeviceBatterySummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_BATTERY_SUMMARY", schema "battery FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DeviceBatterySummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_BATTERY_SUMMARY", schema "level INT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceBatterySummaryData select level, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceBatteryData group by level, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
insert overwrite table DeviceBatterySummaryData select battery, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceBatteryData group by battery, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>
<CronExpression>0 * * * * ?</CronExpression> <CronExpression>0 * * * * ?</CronExpression>
</Analytics> </Analytics>

@ -56,14 +56,14 @@
<EnableIndexing>false</EnableIndexing> <EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey> <IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam> <EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type> <Type>DOUBLE</Type>
</ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> <ColumnDefinition>
<Name>longitude</Name> <Name>longitude</Name>
<EnableIndexing>false</EnableIndexing> <EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey> <IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam> <EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type> <Type>DOUBLE</Type>
</ColumnDefinition> </ColumnDefinition>
</TableSchema> </TableSchema>
</EventStoreConfiguration> </EventStoreConfiguration>

@ -10,12 +10,8 @@
{"name":"time","type":"LONG"} {"name":"time","type":"LONG"}
], ],
"payloadData": [ "payloadData": [
{ {"name": "latitude","type": "DOUBLE"},
"name": "latitude","type": "FLOAT" {"name": "longitude","type": "DOUBLE"}
},
{
"name": "longitude","type": "FLOAT"
}
] ]
} }

@ -22,8 +22,7 @@
<Script> <Script>
CREATE TEMPORARY TABLE DeviceGPSData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_GPS"); CREATE TEMPORARY TABLE DeviceGPSData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_GPS");
CREATE TEMPORARY TABLE DeviceGPSSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_GPS_SUMMARY", schema "latitude FLOAT,longitude FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DeviceGPSSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_GPS_SUMMARY", schema "latitude DOUBLE,longitude DOUBLE, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceGPSSummaryData select latitude, longitude, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceGPSData group by latitude, longitude, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT); insert overwrite table DeviceGPSSummaryData select latitude, longitude, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceGPSData group by latitude, longitude, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>

@ -19,11 +19,9 @@
<artifacts> <artifacts>
<artifact name="GPS_CAPP" version="1.0.0" type="carbon/application"> <artifact name="GPS_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_gps" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstream_gps" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_gps" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstore_gps" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_gps" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventreceiver_gps" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact> </artifact>
</artifacts> </artifacts>

@ -52,7 +52,21 @@
<Type>LONG</Type> <Type>LONG</Type>
</ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> <ColumnDefinition>
<Name>gravity</Name> <Name>x</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>y</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>z</Name>
<EnableIndexing>false</EnableIndexing> <EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey> <IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam> <EnableScoreParam>false</EnableScoreParam>

@ -22,10 +22,9 @@
<Script> <Script>
CREATE TEMPORARY TABLE DeviceGRAVITYData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_GRAVITY"); CREATE TEMPORARY TABLE DeviceGRAVITYData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_GRAVITY");
CREATE TEMPORARY TABLE DeviceGRAVITYSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_GRAVITY_SUMMARY", schema "gravity FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DeviceGRAVITYSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_GRAVITY_SUMMARY", schema "x FLOAT, y FLOAT,z FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceGRAVITYSummaryData select x, y, z, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceGRAVITYData group by x, y, z, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
insert overwrite table DeviceGRAVITYSummaryData select gravity, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceGRAVITYData group by gravity, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>
<CronExpression>0 * * * * ?</CronExpression> <CronExpression>0 * * * * ?</CronExpression>
</Analytics> </Analytics>

@ -19,11 +19,9 @@
<artifacts> <artifacts>
<artifact name="GRAVITY_CAPP" version="1.0.0" type="carbon/application"> <artifact name="GRAVITY_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_gravity" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstream_gravity" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_gravity" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstore_gravity" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_gravity" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventreceiver_gravity" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact> </artifact>
</artifacts> </artifacts>

@ -52,7 +52,21 @@
<Type>LONG</Type> <Type>LONG</Type>
</ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> <ColumnDefinition>
<Name>gyroscope</Name> <Name>x</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>y</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>z</Name>
<EnableIndexing>false</EnableIndexing> <EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey> <IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam> <EnableScoreParam>false</EnableScoreParam>

@ -22,10 +22,9 @@
<Script> <Script>
CREATE TEMPORARY TABLE DeviceGYROSCOPEData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_GYROSCOPE"); CREATE TEMPORARY TABLE DeviceGYROSCOPEData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_GYROSCOPE");
CREATE TEMPORARY TABLE DeviceGYROSCOPESummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_GYROSCOPE_SUMMARY", schema "gyroscope FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DeviceGYROSCOPESummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_GYROSCOPE_SUMMARY", schema "x FLOAT, y FLOAT, z FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceGYROSCOPESummaryData select x, y, z, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceGYROSCOPEData group by x, y, z, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
insert overwrite table DeviceGYROSCOPESummaryData select gyroscope, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceGYROSCOPEData group by gyroscope, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>
<CronExpression>0 * * * * ?</CronExpression> <CronExpression>0 * * * * ?</CronExpression>
</Analytics> </Analytics>

@ -24,7 +24,6 @@ CREATE TEMPORARY TABLE DeviceLightData USING CarbonAnalytics OPTIONS(tableName "
CREATE TEMPORARY TABLE DeviceLightSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_LIGHT_SUMMARY", schema "light FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DeviceLightSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_LIGHT_SUMMARY", schema "light FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceLightSummaryData select light, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceLightData group by light, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT); insert overwrite table DeviceLightSummaryData select light, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceLightData group by light, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>
<CronExpression>0 * * * * ?</CronExpression> <CronExpression>0 * * * * ?</CronExpression>

@ -19,11 +19,9 @@
<artifacts> <artifacts>
<artifact name="Light_Sensors_CAPP" version="1.0.0" type="carbon/application"> <artifact name="Light_Sensors_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_light" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstream_light" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_light" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstore_light" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_light" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventreceiver_light" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact> </artifact>
</artifacts> </artifacts>

@ -52,7 +52,21 @@
<Type>LONG</Type> <Type>LONG</Type>
</ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> <ColumnDefinition>
<Name>magnetic</Name> <Name>x</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>y</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>z</Name>
<EnableIndexing>false</EnableIndexing> <EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey> <IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam> <EnableScoreParam>false</EnableScoreParam>

@ -22,9 +22,9 @@
<Script> <Script>
CREATE TEMPORARY TABLE DeviceMagneticData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_MAGNETIC"); CREATE TEMPORARY TABLE DeviceMagneticData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_MAGNETIC");
CREATE TEMPORARY TABLE DeviceMagneticSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_MAGNETIC_SUMMARY", schema "magnetic FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DeviceMagneticSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_MAGNETIC_SUMMARY", schema "x FLOAT, y FLOAT, z FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceMagneticSummaryData select magnetic, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceMagneticData group by magnetic, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT); insert overwrite table DeviceMagneticSummaryData select x, y , z, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceMagneticData group by x, y, z, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>
<CronExpression>0 * * * * ?</CronExpression> <CronExpression>0 * * * * ?</CronExpression>
</Analytics> </Analytics>

@ -19,11 +19,9 @@
<artifacts> <artifacts>
<artifact name="Magnetic_CAPP" version="1.0.0" type="carbon/application"> <artifact name="Magnetic_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_magnetic" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstream_magnetic" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_magnetic" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventstore_magnetic" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_magnetic" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Eventreceiver_magnetic" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> <dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact> </artifact>
</artifacts> </artifacts>

@ -24,7 +24,6 @@ CREATE TEMPORARY TABLE DevicePRESSUREData USING CarbonAnalytics OPTIONS(tableNam
CREATE TEMPORARY TABLE DevicePRESSURESummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_PRESSURE_SUMMARY", schema "pressure FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time"); CREATE TEMPORARY TABLE DevicePRESSURESummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_PRESSURE_SUMMARY", schema "pressure FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DevicePRESSURESummaryData select pressure, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DevicePRESSUREData group by pressure, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT); insert overwrite table DevicePRESSURESummaryData select pressure, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DevicePRESSUREData group by pressure, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script> </Script>
<CronExpression>0 * * * * ?</CronExpression> <CronExpression>0 * * * * ?</CronExpression>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save