-
Notifications
You must be signed in to change notification settings - Fork 191
Sensor Data Develop
LSM-LIGHT server requires Java JDK 1.7. In order to setup LSM-LIGHT modules, there are several required components need to be installed on your local system.
Virtuoso Universal Server is a middleware and database engine hybrid that combines the functionality of a traditional RDBMS, ORDBMS, virtual database, RDF, XML, free-text, web application server and file server functionality in a single system. For OpenIoT, we use the open source edition (VOS stable/version 7) of Virtuoso Universal Server (it is also known as OpenLink Virtuoso). If you want to install a virtuoso server instance in your local server, please follow the instructions available at: https://github.com/openlink/virtuoso-opensource/tree/stable/7
Instructions on installing a virtuoso server on a ubunutu instance is available from InstallingVirtuosoOpensource7Ubuntu
Following: (https://github.com/OpenIotOrg/openiot/wiki/InstallingVirtuosoOpensource7Ubuntu)
For the server side of LSM-LIGHT, we use Java Servlets, which are implemented on a JBOSS AS 7 server.
For installing JBoss, you can follow these two tutorials, (Start from step 2, as it is expected that u have installed java 7 beforehand). https://www.digitalocean.com/community/articles/how-to-install-jboss-on-ubuntu-12-10-64bit.
http://dont-panic.eu/blogs/2012/mar/install-jboss-7-ubuntu-1110-server.
Source code can be cloned using GIT from OpenIoT’s repository on GitHub at the following address: https://github.com/OpenIotOrg/openiot.git The LSM-LIGHT module can be found under modules/lsm-light.
- Import the module (lsm-light.server) from GitHub
- Open a command line and navigate to the root directory of the scheduler Project. for example: (/Git3/modules/lsm-light/lsm-light.server)
- LSM-LIGHT relies on Maven or its deployment. If you have not yet done so, you must Configure Maven before testing deployment.
Deploy using maven (in Command Prompt or from Eclipse or other IDE) to build the lsm-light.server.war file of LSM-LIGHT.server source code. Example in command prompt:
**mvn clean package jboss-as:deploy**
For example: XXX@ubuntu:~/Git3/modules/lsm-light/lsm-light.server$ mvn clean package jboss-as:deploy
-
Currently, the user can use OpenIoT server to push their data. However, if the users want to use their local Virtuoso instance, please follow the installation step above to set up Virtuoso server. When the installation is done, please modify the ‘openiot.properties’ file located in ‘utils.commons’ module properly (example location: utils/utils.commons/src/main/resources/properties). Snapshot attached with the changes: https://docs.google.com/file/d/0B6fEpfpblobQQXNJTGticnlOcmc/edit
-
Copy the ‘openiot.properties’ file from (utils.commons/properties/) to your JBoss installation directory (for example: /home/jboss-as-7.1.1.Final/standalone/configuration/).
-
Copy the previously created lsm-light.server.war file to [JBOSS installation directory]/standalone/deployments/ directory. For example: /home/jboss-as-7.1.1.Final/standalone/deployments/
-
Start the JBOSS server
-
Now Check: http://localhost:8080/lsm-light.server/ This step might take few seconds.
Your LSM-light-server is ready to be accessed via LSM-light.client!
Alternatively: After importing package to Eclipse IDE, right click on the project, click install. Then right click again, Run as> Run on Server (JBoss).
The LSM-light modules (client and server) use the global properties file. Directions on how to use and configure can be found here. In case all the OpenIoT modules are installed locally, please find the example content of Openiot properties file below:
#Scheduler Properties
#The following three graph names depend on the graphs you imported in your DB
scheduler.core.lsm.openiotMetaGraph=http://lsm.deri.ie/OpenIoT/demo/sensormeta#
scheduler.core.lsm.openiotDataGraph=http://lsm.deri.ie/OpenIoT/demo/sensordata#
scheduler.core.lsm.openiotFunctionalGraph=http://lsm.deri.ie/OpenIoT/demo/functionaldata#
#At this moment, you do not need to change the credentials below
scheduler.core.lsm.access.username=openiot_guest
scheduler.core.lsm.access.password=openiot
#Next two parameters are configured for OpenIoT using local database
scheduler.core.lsm.sparql.endpoint=http://localhost:8890/sparql
scheduler.core.lsm.remote.server=http://localhost:8080/lsm-light.server/
#Service Delivery & Utility Manager (SD&UM) Properties
#The following graph name depends on the graph you imported in your DB
sdum.core.lsm.openiotFunctionalGraph=http://lsm.deri.ie/OpenIoT/demo/functionaldata#
#Next two parameters are configured for OpenIoT using local database
sdum.core.lsm.sparql.endpoint=http://localhost:8890/sparql
sdum.core.lsm.remote.server=http://localhost:8080/lsm-light.server/
#Request Definition
#Request Presentation
#LSM-LIGHT Properties
lsm-light.server.connection.driver_class=virtuoso.jdbc4.Driver
lsm-light.server.connection.url=jdbc:virtuoso://localhost:1111/log_enable=2
#The following credentials depend on your installation of local DB (virtuoso)
lsm-light.server.connection.username=dba
lsm-light.server.connection.password=dba
lsm-light.server.minConnection=10
lsm-light.server.maxConnection=15
lsm-light.server.acquireRetryAttempts=5
#for local virtuoso instance
#The following graph names depend on the graphs you imported in your DB
lsm-light.server.localMetaGraph = http://lsm.deri.ie/OpenIoT/demo/sensormeta#
lsm-light.server.localDataGraph = http://lsm.deri.ie/OpenIoT/demo/sensordata#
These examples below illustrate some functionalities of LSM api (lsm-light.client module). By following this, the users will know how to communicate with LSM server (lsm-light.server module) and publish their sensor data into it.
Example 1 - How to add a new sensor into the LSM triple store
import java.util.Date;
import org.openiot.lsm.beans.Place;
import org.openiot.lsm.beans.Sensor;
import org.openiot.lsm.beans.User;
import org.openiot.lsm.http.LSMTripleStore;
import org.openiot.lsm.utils.ObsConstant;
public class TestLSM {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
/*
* add new sensor to lsm store. For example: Air quality sensor from Lausanne
* Sensor name: lausanne_1057
*/
// 1. Create an instance of Sensor class and set the sensor metadata
Sensor sensor = new Sensor();
sensor.setName("lausanne_1057");
sensor.setAuthor("sofiane");
sensor.setSensorType("weather");
sensor.setSourceType("lausanne");
sensor.setInfor("Air Quality Sensors from Lausanne");
sensor.setMetaGraph(“http://lsm.deri.ie/OpenIoT/demo/sensormeta#”);
sensor.setDataGraph(“http://lsm.deri.ie/OpenIoT/demo/sensordata#”); sensor.setSource("http://opensensedata.epfl.ch:22002/gsn?REQUEST=113&name=lausanne_1057");
sensor.setTimes(new Date());
//set observed properties of sensor
sensor.addProperty(ObsConstant.TEMPERATURE);
sensor.addProperty(ObsConstant.HUMIDITY);
// set sensor location information (latitude, longitude, city, country, continent...)
Place place = new Place();
place.setLat(46.529838);
place.setLng(6.596818);
sensor.setPlace(place);
// create LSMTripleStore instance
String openiot_server = "http://lsm.deri.ie/lsm-light.server/"; //OpenIoT server host
LSMTripleStore lsmStore = new LSMTripleStore(openiot_server);
//call sensorAdd method
lsmStore.sensorAdd(sensor);
}catch (Exception ex) {
ex.printStackTrace();
System.out.println("cannot send the data to server");
}
}
}
Example 2 - How to update sensor data within the LSM triple store
/*
* An Observation is a Situation in which a Sensing method has been used to estimate or
* calculate a value of a Property of a FeatureOfInterest.
*/
//create an Observation object
Observation obs = new Observation();
obs.setDataGraph(“http://lsm.deri.ie/OpenIoT/demo/sensordata#”);
obs.setMetaGraph(“http://lsm.deri.ie/OpenIoT/demo/sensormeta#);
// set SensorURL of observation
//for example: "http://lsm.deri.ie/resource/8a82919d3264f4ac013264f4e14501c0" is the sensorURL of lausanne_1057 sensor
obs.setSensor("http://lsm.deri.ie/resource/8a82919d3264f4ac013264f4e14501c0");
//set time when the observation was observed. In this example, the time is current local time.
obs.setTimes(new Date());
/*
* Relation linking an Observation to the Property that was observed
*/
ObservedProperty obvTem = new ObservedProperty();
obvTem.setObservationId(obs.getId());
obvTem.setPropertyType(ObsConstant.TEMPERATURE);
obvTem.setValue(9.58485958485958);
obvTem.setUnit("C");
obs.addReading(obvTem);
ObservedProperty obvCO = new ObservedProperty();
obvCO.setObservationId(obs.getId());
obvCO.setPropertyType(ObsConstant.HUMIDITY);
obvCO.setValue(0.0366300366300366);
obvCO.setUnit("C");
obs.addReading(obvCO);
obs.setDataGraph("http://lsm.deri.ie/OpenIoT/new/sensordata#");
obs.setMetaGraph("http://lsm.deri.ie/OpenIoT/new/sensormeta#");
lsmStore.sensorDataUpdate(obs);
If the sensor metadata or sensor data are already in N-Triple format, you can use these methods sensorAdd(String triples) and sensorDataUpdate(String triples) to insert directly data into LSM triple store.
Example 3 - Retrieve sensor object by sensorURL id or by sensor source
/*
* the sensorURL id and sensor source are unique
*/
Sensor sensor1 = lsmStore.getSensorById(http://lsm.deri.ie/resource/8a82919d3264f4ac013264f4e14501c0,”http://lsm.deri.ie/OpenIoT/demo/sensormeta#”);
Sensor sensor2 = lsmStore.getSensorBySource(http://opensensedata.epfl.ch:22002/gsn?REQUEST=113&name=lausanne_1057, ,”http://lsm.deri.ie/OpenIoT/demo/sensormeta#”);
Example 4 - Delete sensor data
/**
* remove sensor
* @param sensorURL
*/
lsmStore.sensorDelete("http://lsm.deri.ie/resource/8a82919d3264f4ac013264f4e14501c0",”http://lsm.deri.ie/OpenIoT/demo/sensormeta#”);
/**
* delete all reading data of specific sensor
* @param sensorURL
*/
lsmStore.deleteAllReadings("http://lsm.deri.ie/resource/8a82919d3264f4ac013264f4e14501c0");
/**
* delete sensor data at a certain period of time
* @param sensorURL
* @param dateOperator
* @param fromTime
* @param toTime
* fromDate, toDate are java Date objects
*/
Date fromDate = new Date();
lsmStore.deleteAllReadings("http://lsm.deri.ie/resource/8a82919d3264f4ac013264f4e14501c0", "<=", fromDate, null);
lsmStore.deleteAllReadings("http://lsm.deri.ie/resource/8a82919d3264f4ac013264f4e14501c0", null, fromDate, toDate);
- Documentation
- Home
- Architecture
- Scheduler
- Service Delivery & Utility Manager
- Data Platform (LSM)
- X-GSN
- Mobile Sensors Management
- Optimizations
- Security
- User Interfaces
- OpenIoT Commons & Properties
- Standalone Platform Testing tools
- X-GSN Sensor Simulators
- Deliverables
- Glossary and Terminology
- Demos