• No results found

4. Implementing WikiSensing’s Data Management and Collaboration

4.4. Basic Sensor Data Management Components

4.4.3. Creating a Virtual Sensor

Virtual sensors are usually created when there is no physical sensor deployed at a specific location. This is also useful when users require the aggregation of several data streams to be persistent.

Figure 4.6: The WikiSensing map illustrating the deployment of sensors

Stage 1: The search phase

The users can either view the WikiSensing map or query to check the locations of available sensors. Figure 4.6 illustrates an instance of a map used in WikiSensing followed by an example query that would select available sensors in a specific location.

84 SELECT e.sensorId

FROM Environment e, Datastream d WHERE d.sensorType = ‘NO2’

WIKI_LOCATION = <51.521, -0.026453> WIKI_RADIUS = 0.25<km>

This query selects sensors that measure the air pollutant NO2 within a radius of 0.25 km of the location specified with the coordinates 51.521 and - 0.026453.

Stage 2: Registering a virtual sensor

If the user requires sensor measurements from a particular location where a sensor is not physically deployed the user can create a virtual sensor. This is done by specifying its details similar to registering a regular sensor described in scenario 1 with the exception that the domain field is set as ‘virtual’. In addition users can specify the virtual sensor data persistence field (Table 4.1) to be either persistent or dynamic.

The two categories of virtual sensors are the ones which store the aggregated measurements (persistence) and the virtual sensors that generate measurements dynamically. The measurements of persistent virtual sensors can be traced for the origins of the contributing sensor data streams. For example, in case where there are doubts on a virtual sensor, the data can be audited as its measurements are recorded. The audit can check for problems by analysing the history of streams that are included as well as removed from a virtual sensor. In contrast dynamic virtual sensors produce their reading on request, and their output is generated by aggregating the data streams in real time.

Stage 3: Select and record contributing sensors

The user can select a set of contributing sensors (usually sensors that are nearby) for the virtual sensor (Figure 4.7). In this example, sensor S1 (at distance X) and S2 (at distance Y) are selected for the virtual sensor VS. The user also has the

85

flexibility to add more sensors or remove existing contributing sensors from the virtual sensor.

The sensors that contribute to a virtual sensor are recorded in a virtual sensor map table, whose fields are listed in Table 4.4. The optimize column is updated when the user explicitly requests the selected contributing sensors list to be optimized. The system updates this column with virtual sensor identities (virtual sensors that are persistent) that are already created using a subset of the selected sensors. The aim is to reduce the database reads using existing virtual sensor data streams that are already formulated. Figure 4.8 illustrates the WikiSensing interface that enables users to add sensor data streams to a virtual sensor.

Field Mandatory Domain Description

Virtual Sensor Environment

Identity Yes Number

The identity of virtual sensor environment

Contributing Sensor

Environment Identity Yes Number

The identity of contributing sensor environment

Data stream identity Virtual

Sensor Yes Number

The identity of the data stream of virtual sensor

Data stream identity

Contributing Sensor Yes Number

The identity of the data stream of contributing sensor

Optimize No Number List of identities of selected virtual sensors that are used to optimize performance.

Table 4.4: The list of fields to register a virtual sensor network Y

S2

S1

X

Figure 4.7: Selecting sensors to create a virtual sensor VS

86

It is assumed that the contributing sensor streams are of same type (e.g. measuring the same physical phenomena). Moreover it is also assumed that these sensors are continuously functioning and submit data consistently in accordance to its frequency. However it also expected that the user explicitly removes a contributing sensor from a virtual sensor when it no longer provides measurements or seize to function. A further discussion is done on assessing the trustworthiness of these contributing sensors of virtual sensors in section 9.2.2, page 196.

Figure 4.8: WikiSensing Interface for selecting sensor streams to create a virtual sensor

Sample Window size Virtual sensors

Aggregated virtual sensor reading

Contributing sensor data streams

87

Stage 4: Aggregating the data streams of the contributing sensors

The system provides an aggregated sensor measurement (of selected sensors) as the reading for the virtual sensor. The following query is an example that aggregates readings for a virtual sensor.

SELECT AVG (p.measurement)

FROM Environment e, DataStream d, DataPoint p WHERE d.sensorType = ‘NO2’

AND e.sensorId IN (<List of sensors selected by the user>) WIKI_WINDOW = 1<r>

WIKI_UOM = <Milligrams> WIKI_PROPORTION = <DISTANCE> WIKI_SAMPLE_STREAM

Figure 4.8 illustrates an aggregated measurement of the virtual sensor (GUSTO_Virtual_Sensor_1) of type NO2 that consists of the contributing

GUSTO_A1 and GUSTO_A10. The construct WIKI_PROPORTION is an indication to

aggregate the sensor streams based on a weighted calculation. This can be the weighted mean of the distance (formula 4.1) from the specified location or any other specified calculation.

(4.1)

For example, if a weighted calculation is used would denote the weighted arithmetic mean with x and w being the values and weights of the items. The weight is the proportion to the spatial distances from the contributing sensor to the location of the virtual sensor. The aggregation query that is responsible for obtaining virtual sensor readings is stored in the virtual sensor query table (Table 4.5) with the ability to be modified on request.

88

Field Mandatory Domain Description

Virtual Sensor Environment Identity

Yes Number The identity of the virtual sensor

Data stream identity Virtual Sensor

Yes Number The identity of the data stream of virtual sensor

Query Yes String The SQL of the aggregate query

Table 4.5: The list of fields in the virtual sensor query table

When a user completes registration a Wiki page for the virtual sensor is automatically created and the provided information is recorded (Figure 4.9). The Wiki page also gets automatically updated when a user updates the composition of the virtual sensor.

Figure 4.9: Wiki page recording information on a virtual sensor Virtual sensor readings

89