This repository has been archived by the owner on Feb 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
FakeWeatherSensor.java
101 lines (75 loc) · 2.85 KB
/
FakeWeatherSensor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/***************************** BEGIN LICENSE BLOCK ***************************
The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer is Botts Innovative Research Inc. Portions created by the Initial
Developer are Copyright (C) 2014 the Initial Developer. All Rights Reserved.
******************************* END LICENSE BLOCK ***************************/
package org.sensorhub.impl.sensor.fakeweather;
import org.sensorhub.api.common.SensorHubException;
import org.sensorhub.impl.sensor.AbstractSensorModule;
import org.sensorhub.impl.sensor.fakeweather.FakeWeatherOutput;
import org.vast.sensorML.SMLHelper;
/**
* <p>
* Driver implementation outputting simulated weather data by randomly
* increasing or decreasing temperature, pressure, wind speed, and
* wind direction. Serves as a simple sensor to deploy as well as
* a simple example of a sensor driver.
* </p>
*
* @author Mike Botts <mike.botts@botts-inc.com>
* @since Dec 24, 2014
*/
public class FakeWeatherSensor extends AbstractSensorModule<FakeWeatherConfig>
{
FakeWeatherOutput dataInterface;
@Override
public void init() throws SensorHubException
{
super.init();
// generate identifiers
generateUniqueID("urn:osh:sensor:simweather:", config.serialNumber);
generateXmlID("WEATHER_STATION_", config.serialNumber);
// init main data interface
dataInterface = new FakeWeatherOutput(this);
addOutput(dataInterface, false);
dataInterface.init();
}
@Override
protected void updateSensorDescription()
{
synchronized (sensorDescLock)
{
super.updateSensorDescription();
if (!sensorDescription.isSetDescription())
sensorDescription.setDescription("Simulated weather station generating realistic pseudo-random measurements");
SMLHelper helper = new SMLHelper(sensorDescription);
helper.addSerialNumber(config.serialNumber);
}
}
@Override
public void start() throws SensorHubException
{
if (dataInterface != null)
dataInterface.start();
}
@Override
public void stop() throws SensorHubException
{
if (dataInterface != null)
dataInterface.stop();
}
@Override
public void cleanup() throws SensorHubException
{
}
@Override
public boolean isConnected()
{
return true;
}
}