Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Sample added for Siddhi event triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
keizer619 committed Feb 1, 2016
1 parent d7c7da3 commit 3305b7c
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/samples/artifacts/0119/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This sample uses
EventPublisher: logger

Producers: event simulator
Consumers: console
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventPublisher name="cronTriggeredSensorStreamLogger"
statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="cronTriggeredSensorStream" version="1.0.0"/>
<mapping customMapping="disable" type="text"/>
<to eventAdapterType="logger">
<property name="uniqueId">cron</property>
</to>
</eventPublisher>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventPublisher name="periodicalTriggeredSensorStreamLogger"
statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="periodicalTriggeredSensorStream" version="1.0.0"/>
<mapping customMapping="disable" type="text"/>
<to eventAdapterType="logger">
<property name="uniqueId">periodical</property>
</to>
</eventPublisher>
4 changes: 4 additions & 0 deletions modules/samples/artifacts/0119/eventsimulatorfiles/events.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
199008131245,false,100,temperature,23.45656,7.12324,100.34,23.4545
199008131245,true,101,temperature,23.45656,7.12324,100.34,23.4545
199008131245,false,103,temperature,23.45656,7.12324,100.34,23.4545
199008131245,true,104,temperature,23.45656,7.12324,100.34,23.4545
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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.
-->

<streamConfiguration type="csv">
<file>events.csv</file>
<streamID>org.wso2.event.sensor.stream:1.0.0</streamID>
<separateChar>,</separateChar>
<delayBetweenEventsInMilies>1000</delayBetweenEventsInMilies>
</streamConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "cronTriggeredSensorStream",
"version": "1.0.0",
"nickName": "",
"description": "",
"metaData": [
{
"name": "timestamp",
"type": "LONG"
},
{
"name": "isPowerSaverEnabled",
"type": "BOOL"
},
{
"name": "sensorId",
"type": "INT"
},
{
"name": "sensorName",
"type": "STRING"
}
],
"correlationData": [
{
"name": "longitude",
"type": "DOUBLE"
},
{
"name": "latitude",
"type": "DOUBLE"
}
],
"payloadData": [
{
"name": "triggered_time",
"type": "LONG"
},
{
"name": "humidity",
"type": "FLOAT"
},
{
"name": "sensorValue",
"type": "DOUBLE"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "org.wso2.event.sensor.stream",
"version": "1.0.0",
"nickName": "",
"description": "",
"metaData": [
{
"name": "timestamp",
"type": "LONG"
},
{
"name": "isPowerSaverEnabled",
"type": "BOOL"
},
{
"name": "sensorId",
"type": "INT"
},
{
"name": "sensorName",
"type": "STRING"
}
],
"correlationData": [
{
"name": "longitude",
"type": "DOUBLE"
},
{
"name": "latitude",
"type": "DOUBLE"
}
],
"payloadData": [
{
"name": "humidity",
"type": "FLOAT"
},
{
"name": "sensorValue",
"type": "DOUBLE"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "periodicalTriggeredSensorStream",
"version": "1.0.0",
"nickName": "",
"description": "",
"metaData": [
{
"name": "timestamp",
"type": "LONG"
},
{
"name": "isPowerSaverEnabled",
"type": "BOOL"
},
{
"name": "sensorId",
"type": "INT"
},
{
"name": "sensorName",
"type": "STRING"
}
],
"correlationData": [
{
"name": "longitude",
"type": "DOUBLE"
},
{
"name": "latitude",
"type": "DOUBLE"
}
],
"payloadData": [
{
"name": "triggered_time",
"type": "LONG"
},
{
"name": "humidity",
"type": "FLOAT"
},
{
"name": "sensorValue",
"type": "DOUBLE"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Enter a unique ExecutionPlan */
@Plan:name('ExecutionPlan')

/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')

/* define streams/tables and write queries here ... */


@Import('org.wso2.event.sensor.stream:1.0.0')
define stream sensorStream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, humidity float, sensorValue double);


@Export('cronTriggeredSensorStream:1.0.0')
define stream cronTriggeredSensorStream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, triggered_time long, humidity float, sensorValue double);

@Export('periodicalTriggeredSensorStream:1.0.0')
define stream periodicalTriggeredSensorStream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, triggered_time long, humidity float, sensorValue double);

define trigger periodicalTriggerStream at every 5 sec ;

define trigger cronTriggerStream at '*/10 * * * * ?' ;

from periodicalTriggerStream join sensorStream#window.time(10 sec)
select meta_timestamp, meta_isPowerSaverEnabled, meta_sensorId, meta_sensorName, correlation_longitude, correlation_latitude, triggered_time, humidity, sensorValue
insert into periodicalTriggeredSensorStream;

from cronTriggerStream join sensorStream#window.time(10 sec)
select meta_timestamp, meta_isPowerSaverEnabled, meta_sensorId, meta_sensorName, correlation_longitude, correlation_latitude, triggered_time, humidity, sensorValue
insert into cronTriggeredSensorStream;

0 comments on commit 3305b7c

Please sign in to comment.