Conflicts:
	modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/VirtualFireAlarmService.java
	modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceRecord.java
	modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/TemperatureRecord.java
	modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dto/TemperatureRecord.java
	modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/DataHolder.java
application-manager-new
Shabirmean 9 years ago
commit 7664f73b4e

@ -340,11 +340,11 @@
file="target/wso2carbon-core-${carbon.kernel.version}/repository/conf/iot/iot-config.xml"/>
</copy>
<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/arduino/build.xml"
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/arduino/build.xml.disable"/>
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/arduino/build.xml"/>
<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/raspberrypi/build.xml"
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/raspberrypi/build.xml.disable"/>
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/raspberrypi/build.xml"/>
<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml"
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml.disable"/>
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml"/>
<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/sample_pom.xml"
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/pom.xml"
overwrite="true"/>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="EventReceiver_battery" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.iot.devices.battery" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventreceiver_battery" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_battery.xml</file>
</artifact>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstore_battery" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
<file>org_wso2_iot_devices_battery.xml</file>
</artifact>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<EventStoreConfiguration>
<Source>
<StreamId>org.wso2.iot.devices.battery:1.0.0</StreamId>
</Source>
<RecordStoreName>EVENT_STORE</RecordStoreName>
<TableSchema>
<ColumnDefinition>
<Name>meta_owner</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceType</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceId</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_time</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>LONG</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>battery</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
</TableSchema>
</EventStoreConfiguration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstream_battery" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.battery_1.0.0.json</file>
</artifact>

@ -0,0 +1,20 @@
{
"name": "org.wso2.iot.devices.battery",
"version": "1.0.0",
"nickName": "battery Data",
"description": "battery data received from the Device",
"metaData": [
{"name":"owner","type":"STRING"},
{"name":"deviceType","type":"STRING"},
{"name":"deviceId","type":"STRING"},
{"name":"time","type":"LONG"}
],
"payloadData": [
{
"name": "battery","type": "FLOAT"
}
]
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>Battery_Sensor_Script</Name>
<Script>
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");
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>
<CronExpression>0 * * * * ?</CronExpression>
</Analytics>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
<file>Battery_Sensor_Script.xml</file>
</artifact>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifacts>
<artifact name="Battery_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_battery" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_battery" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_battery" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="EventReceiver_gps" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.iot.devices.gps" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventreceiver_gps" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_gps.xml</file>
</artifact>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstore_gps" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
<file>org_wso2_iot_devices_gps.xml</file>
</artifact>

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<EventStoreConfiguration>
<Source>
<StreamId>org.wso2.iot.devices.gps:1.0.0</StreamId>
</Source>
<RecordStoreName>EVENT_STORE</RecordStoreName>
<TableSchema>
<ColumnDefinition>
<Name>meta_owner</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceType</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceId</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_time</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>LONG</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>latitude</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>longitude</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
</TableSchema>
</EventStoreConfiguration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstream_gps" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.gps_1.0.0.json</file>
</artifact>

@ -0,0 +1,23 @@
{
"name": "org.wso2.iot.devices.gps",
"version": "1.0.0",
"nickName": "GPS Data",
"description": "GPS data received from the Device",
"metaData": [
{"name":"owner","type":"STRING"},
{"name":"deviceType","type":"STRING"},
{"name":"deviceId","type":"STRING"},
{"name":"time","type":"LONG"}
],
"payloadData": [
{
"name": "latitude","type": "FLOAT"
},
{
"name": "longitude","type": "FLOAT"
}
]
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Script>
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");
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>
<CronExpression>0 * * * * ?</CronExpression>
</Analytics>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
<file>GPS_Sensor_Script.xml</file>
</artifact>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifacts>
<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="Eventstore_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"/>
</artifact>
</artifacts>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="EventReceiver_light" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.iot.devices.light" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventreceiver_light" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_light.xml</file>
</artifact>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstore_light" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
<file>org_wso2_iot_devices_light.xml</file>
</artifact>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<EventStoreConfiguration>
<Source>
<StreamId>org.wso2.iot.devices.light:1.0.0</StreamId>
</Source>
<RecordStoreName>EVENT_STORE</RecordStoreName>
<TableSchema>
<ColumnDefinition>
<Name>meta_owner</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceType</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceId</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_time</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>LONG</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>light</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
</TableSchema>
</EventStoreConfiguration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstream_light" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.light_1.0.0.json</file>
</artifact>

@ -0,0 +1,20 @@
{
"name": "org.wso2.iot.devices.light",
"version": "1.0.0",
"nickName": "light Data",
"description": "light data received from the Device",
"metaData": [
{"name":"owner","type":"STRING"},
{"name":"deviceType","type":"STRING"},
{"name":"deviceId","type":"STRING"},
{"name":"time","type":"LONG"}
],
"payloadData": [
{
"name": "light","type": "FLOAT"
}
]
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>Light_Sensor_Script</Name>
<Script>
CREATE TEMPORARY TABLE DeviceLightData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_LIGHT");
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);
</Script>
<CronExpression>0 * * * * ?</CronExpression>
</Analytics>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
<file>Light_Sensor_Script.xml</file>
</artifact>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifacts>
<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="Eventstore_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"/>
</artifact>
</artifacts>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="EventReceiver_magnetic" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.iot.devices.magnetic" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventreceiver_magnetic" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_magnetic.xml</file>
</artifact>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstore_magnetic" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
<file>org_wso2_iot_devices_magnetic.xml</file>
</artifact>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<EventStoreConfiguration>
<Source>
<StreamId>org.wso2.iot.devices.magnetic:1.0.0</StreamId>
</Source>
<RecordStoreName>EVENT_STORE</RecordStoreName>
<TableSchema>
<ColumnDefinition>
<Name>meta_owner</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceType</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceId</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_time</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>LONG</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>magnetic</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
</TableSchema>
</EventStoreConfiguration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstream_magnetic" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.magnetic_1.0.0.json</file>
</artifact>

@ -0,0 +1,20 @@
{
"name": "org.wso2.iot.devices.magnetic",
"version": "1.0.0",
"nickName": "magnetic Data",
"description": "magnetic data received from the Device",
"metaData": [
{"name":"owner","type":"STRING"},
{"name":"deviceType","type":"STRING"},
{"name":"deviceId","type":"STRING"},
{"name":"time","type":"LONG"}
],
"payloadData": [
{
"name": "magnetic","type": "FLOAT"
}
]
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Script>
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");
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);
</Script>
<CronExpression>0 * * * * ?</CronExpression>
</Analytics>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
<file>magnetic_Sensor_Script.xml</file>
</artifact>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifacts>
<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="Eventstore_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"/>
</artifact>
</artifacts>

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Script>
CREATE TEMPORARY TABLE DeviceTemperatureData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_TEMPERATURE");
<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");
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>
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>

@ -5,6 +5,10 @@
<property name="target-dir" value="target"/>
<property name="Temperature_Sensor_dir" value="Temperature_Sensor"/>
<property name="GPS_dir" value="GPS"/>
<property name="Light_dir" value="Light"/>
<property name="Battery_dir" value="Battery"/>
<property name="Magnetic_dir" value="Magnetic"/>
<target name="clean">
<delete dir="${target-dir}"/>
</target>
@ -13,6 +17,20 @@
<zip destfile="${target-dir}/${Temperature_Sensor_dir}.car">
<zipfileset dir="${Temperature_Sensor_dir}"/>
</zip>
<zip destfile="${target-dir}/${GPS_dir}.car">
<zipfileset dir="${GPS_dir}"/>
</zip>
<zip destfile="${target-dir}/${Light_dir}.car">
<zipfileset dir="${Light_dir}"/>
</zip>
<zip destfile="${target-dir}/${Battery_dir}.car">
<zipfileset dir="${Battery_dir}"/>
</zip>
<zip destfile="${target-dir}/${Magnetic_dir}.car">
<zipfileset dir="${Magnetic_dir}"/>
</zip>
</target>
</project>

@ -43,7 +43,7 @@ public class AndroidSenseControllerService {
String temperature = dataMsg.value; //TEMP
String temperature = dataMsg.owner; //TEMP
log.info("Recieved Sensor Data Values: " + temperature);
if (log.isDebugEnabled()) {

@ -61,22 +61,24 @@ public class AndroidSenseManagerService {
deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE);
try {
if (deviceManagement.getDeviceManagementService().isEnrolled(deviceIdentifier)) {
response.setStatus(Response.Status.CONFLICT.getStatusCode());
return true;
}
Device device = new Device();
device.setDeviceIdentifier(deviceId);
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
enrolmentInfo.setDateOfLastUpdate(new Date().getTime());
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
device.setEnrolmentInfo(enrolmentInfo);
String name = "android_sense" + deviceId;
String name = owner + " android " + deviceId;
device.setName(name);
device.setType(AndroidSenseConstants.DEVICE_TYPE);
enrolmentInfo.setOwner(owner);
device.setEnrolmentInfo(enrolmentInfo);
boolean added = deviceManagement.getDeviceManagementService().enrollDevice(device);
if (added) {
response.setStatus(Response.Status.OK.getStatusCode());
} else {

@ -11,8 +11,5 @@ import javax.xml.bind.annotation.XmlRootElement;
public class DeviceJSON {
@XmlElement(required = true) public String owner;
@XmlElement(required = true) public String deviceId;
@XmlElement(required = true) public String reply;
@XmlElement public Long time;
@XmlElement public String key;
@XmlElement public String value;
@XmlElement public SensorJSON[] values;
}

@ -0,0 +1,16 @@
package org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl.util;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@JsonIgnoreProperties(ignoreUnknown = true)
public class SensorJSON {
@XmlElement public Long time;
@XmlElement public String key;
@XmlElement public String value;
}

@ -400,7 +400,7 @@
</exclusion>
</exclusions>
<scope>system</scope>
<systemPath>${basedir}/../../../../repository/components/plugins/org.wso2.carbon.utils_4.4.1.jar</systemPath>
<systemPath>${basedir}/../../../../repository/components/plugins/org.wso2.carbon.utils_4.4.2.jar</systemPath>
</dependency>
<dependency>

@ -27,4 +27,6 @@ public class VirtualFireAlarmConstants {
public static final String BULB_CONTEXT = "/BULB/";
public static final String SONAR_CONTEXT = "/HUMIDITY/";
public static final String TEMPERATURE_CONTEXT = "/TEMPERATURE/";
public static final String SENSOR_TEMPERATURE = "temperature";
}

@ -58,6 +58,16 @@
<dependency>
<groupId>org.wso2.carbon.device.mgt.iot</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.common</artifactId>
<exclusions>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.device.mgt.iot.server.sample</groupId>
@ -92,11 +102,77 @@
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<exclusions>
<exclusion>
<groupId>org.bouncycastle.wso2</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.api</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.queuing</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.base</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</exclusion>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
<exclusion>
<groupId>commons-fileupload.wso2</groupId>
<artifactId>commons-fileupload</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.equinox</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</dependency>
</dependencies>

@ -44,7 +44,9 @@ import org.wso2.carbon.device.mgt.iot.common.exception.DeviceControllerException
import org.wso2.carbon.device.mgt.iot.common.util.ZipArchive;
import org.wso2.carbon.device.mgt.iot.common.util.ZipUtil;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.plugin.constants.VirtualFireAlarmConstants;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto.TemperatureRecord;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto.SensorRecord;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util.DataHolder;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto.DeviceJSON;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util.VirtualFireAlarmMQTTSubscriber;
@ -246,8 +248,7 @@ public class VirtualFireAlarmService {
device.setName(name);
device.setType(VirtualFireAlarmConstants.DEVICE_TYPE);
boolean updated = deviceManagement.getDeviceManagementService().modifyEnrollment(
device);
boolean updated = deviceManagement.getDeviceManagementService().modifyEnrollment(device);
if (updated) {
response.setStatus(Response.Status.OK.getStatusCode());
@ -607,11 +608,11 @@ public class VirtualFireAlarmService {
@GET
@Consumes("application/json")
@Produces("application/json")
public TemperatureRecord requestTemperature(@HeaderParam("owner") String owner,
public SensorRecord requestTemperature(@HeaderParam("owner") String owner,
@HeaderParam("deviceId") String deviceId,
@HeaderParam("protocol") String protocol,
@Context HttpServletResponse response) {
TemperatureRecord temperatureRecord = null;
SensorRecord sensorRecord = null;
DeviceValidator deviceValidator = new DeviceValidator();
try {
@ -636,8 +637,13 @@ public class VirtualFireAlarmService {
response.setStatus(Response.Status.PRECONDITION_FAILED.getStatusCode());
}
String tString = sendCommandViaHTTP(deviceHTTPEndpoint, VirtualFireAlarmConstants.TEMPERATURE_CONTEXT, false);
float temperature = Float.parseFloat(tString);
DataHolder.getThisInstance().setTemperature(deviceId, temperature, Calendar.getInstance().getTimeInMillis());
String temperatureValue = tString;
DataHolder.getInstance().setSensorRecord(deviceId,
VirtualFireAlarmConstants
.SENSOR_TEMPERATURE,
temperatureValue,
Calendar.getInstance()
.getTimeInMillis());
break;
case MQTT_PROTOCOL:
@ -645,19 +651,21 @@ public class VirtualFireAlarmService {
break;
case XMPP_PROTOCOL:
sendCommandViaXMPP(owner, deviceId, VirtualFireAlarmConstants.TEMPERATURE_CONTEXT, "");
sendCommandViaXMPP(owner, deviceId, VirtualFireAlarmConstants
.TEMPERATURE_CONTEXT, "");
break;
default:
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
}
temperatureRecord = DataHolder.getThisInstance().getTemperature(deviceId);
sensorRecord = DataHolder.getInstance().getSensorRecord(deviceId,
VirtualFireAlarmConstants.SENSOR_TEMPERATURE);
} catch (DeviceManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
response.setStatus(Response.Status.OK.getStatusCode());
return temperatureRecord;
return sensorRecord;
}
@Path("controller/push_temperature")
@ -684,13 +692,38 @@ public class VirtualFireAlarmService {
response.setStatus(Response.Status.CONFLICT.getStatusCode());
return;
}
DataHolder.getThisInstance().setTemperature(deviceId, temperature, Calendar.getInstance().getTimeInMillis());
DataHolder.getInstance().setSensorRecord(deviceId,
VirtualFireAlarmConstants.SENSOR_TEMPERATURE,
String.valueOf(temperature),
Calendar.getInstance().getTimeInMillis());
if (!publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value)) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
}
@Path("controller/set_sensor")
@POST
@Consumes("application/json")
@Produces("application/json")
public boolean setSensorReading(@HeaderParam("deviceId") String deviceId,
@HeaderParam("sensorName") String sensorName,
@HeaderParam("sensorValue") String sensorValue,
@Context HttpServletResponse response) {
return DataHolder.getInstance().setSensorRecord(deviceId, sensorName, sensorValue, Calendar.getInstance().getTimeInMillis());
}
@Path("controller/read_sensor")
@GET
@Consumes("application/json")
@Produces("application/json")
public SensorRecord readSensorReading(@HeaderParam("deviceId") String deviceId,
@HeaderParam("sensorName") String sensorName,
@Context HttpServletResponse response) {
return DataHolder.getInstance().getSensorRecord(deviceId, sensorName);
}
private String sendCommandViaHTTP(final String deviceHTTPEndpoint, String urlContext, boolean fireAndForgot) throws DeviceManagementException {
String responseMsg = "";
@ -764,6 +797,8 @@ public class VirtualFireAlarmService {
return responseMsg;
}
private boolean sendCommandViaMQTT(String deviceOwner, String deviceId, String resource, String state) throws DeviceManagementException {
boolean result = false;

@ -18,24 +18,21 @@ package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.HashMap;
import java.util.Map;
@XmlRootElement
public class TemperatureRecord {
private double temperature;
private long time;
public class DeviceRecord {
//all int, float, boolean should be converted into string
//when saving on the map
private Map<String, SensorRecord> sensorDataList = new HashMap<>();
public TemperatureRecord(double temperature, long time) {
this.temperature = temperature;
this.time = time;
public DeviceRecord(String sensorName, String sensorValue, long time) {
sensorDataList.put(sensorName, new SensorRecord(sensorValue, time));
}
@XmlElement
public double getTemperature() {
return temperature;
}
@XmlElement
public long getTime() {
return time;
public Map<String, SensorRecord> getSensorDataList() {
return sensorDataList;
}
}

@ -0,0 +1,24 @@
package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto;
import javax.xml.bind.annotation.XmlElement;
public class SensorRecord {
private String sensorValue;
private long time;
public SensorRecord(String sensorValue, long time) {
this.sensorValue = sensorValue;
this.time = time;
}
@XmlElement
public String getSensorValue() {
return sensorValue;
}
@XmlElement
public long getTime() {
return time;
}
}

@ -16,30 +16,69 @@
package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto.TemperatureRecord;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto.DeviceRecord;
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dto.SensorRecord;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class DataHolder {
private static DataHolder thisInstance = new DataHolder();
private Map<String, TemperatureRecord> temperatureMap = new HashMap<>();
private static DataHolder instance = new DataHolder();
private Map<String, DeviceRecord> deviceMap = new HashMap<>();
private DataHolder() {
}
public static DataHolder getInstance() {
return instance;
}
public static DataHolder getThisInstance() {
return thisInstance;
public boolean setSensorRecord(String deviceId, String sensorName, String sensorValue, long time){
DeviceRecord deviceRecord = new DeviceRecord(sensorName, sensorValue, time);
deviceMap.put(deviceId, deviceRecord);
return true;
}
public TemperatureRecord getTemperature(String deviceId) {
return temperatureMap.get(deviceId);
/**
* Returns last updated sensor records list for a device
* @param deviceId
* @return
*/
public SensorRecord[] getSensorRecords(String deviceId){
Collection<SensorRecord> list = deviceMap.get(deviceId).getSensorDataList().values();
return list.toArray(new SensorRecord[list.size()]);
}
/**
* Returns last updated sensor record for a device's sensor
* @param deviceId
* @param sensorName
* @return
*/
public SensorRecord getSensorRecord(String deviceId, String sensorName){
return deviceMap.get(deviceId).getSensorDataList().get(sensorName);
}
public void setTemperature(String deviceId, double temperature, long time){
temperatureMap.put(deviceId, new TemperatureRecord(temperature, time));
/**
* Returns last updated sensor value for a device's sensor
* @param deviceId
* @param sensorName
* @return
*/
public String getSensorRecordValue(String deviceId, String sensorName){
return deviceMap.get(deviceId).getSensorDataList().get(sensorName).getSensorValue();
}
/**
* Returns last updated sensor value reading time for a device's sensor
* @param deviceId
* @param sensorName
* @return
*/
public long getSensorRecordTime(String deviceId, String sensorName){
return deviceMap.get(deviceId).getSensorDataList().get(sensorName).getTime();
}
}

@ -66,8 +66,8 @@ public class VirtualFireAlarmMQTTSubscriber extends MqttSubscriber {
}
} else if (message.toString().contains("TEMPERATURE")) {
log.info("MQTT: Reply Message [" + message.toString() + "] topic: [" + topic + "]");
float temperature = Float.parseFloat(message.toString().split(":")[1]);
DataHolder.getThisInstance().setTemperature(deviceId, temperature, Calendar.getInstance().getTimeInMillis());
String temperatureValue = message.toString().split(":")[1];
DataHolder.getInstance().setSensorRecord(deviceId, VirtualFireAlarmConstants.SENSOR_TEMPERATURE, temperatureValue, Calendar.getInstance().getTimeInMillis());
} else {
log.info("MQTT: Message [" + message.toString() + "] topic: [" + topic + "]");
}

Loading…
Cancel
Save