diff --git a/data/carData.rdf b/data/carData.rdf
new file mode 100644
index 0000000..5103103
--- /dev/null
+++ b/data/carData.rdf
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+ 3500
+ 3.5
+ 800
+ 2.9
+ B
+
+
+
+
+
+
+
+
+ Max
+ +49 12345
+ B
+
+
+
\ No newline at end of file
diff --git a/data/carSimulationOntology.owl b/data/carSimulationOntology.owl
index f9c4534..a1b472c 100644
--- a/data/carSimulationOntology.owl
+++ b/data/carSimulationOntology.owl
@@ -1,15 +1,14 @@
-
-
+
Beispielhafte Ontologie für die Autosimulation
@@ -26,51 +25,51 @@
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
+
+
+
@@ -86,10 +85,134 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -98,136 +221,12 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3500
- 3.5
- 800
- 2.9
- B
-
-
-
-
-
-
-
-
-
- Max
- +49 12345
- B
-
+
diff --git a/src/main/java/lu/jpt/csparqltest/Main.java b/src/main/java/lu/jpt/csparqltest/Main.java
index b7abd1f..26be9c0 100644
--- a/src/main/java/lu/jpt/csparqltest/Main.java
+++ b/src/main/java/lu/jpt/csparqltest/Main.java
@@ -35,7 +35,7 @@ public class Main {
// Add static knowledge into local graph from file
try {
- //engine.putStaticNamedModel("http://streamreasoning.org/roomConnection", CsparqlUtils.serializeRDFFile("examples_files/roomConnection.rdf"));
+ engine.putStaticNamedModel("http://jpt.lu/carSimKnowledge", CsparqlUtils.serializeRDFFile("data/carData.rdf"));
} catch (Exception e) {
logger.error(e.toString());
logger.error(e.getStackTrace().toString());
@@ -66,7 +66,7 @@ public class Main {
simulationThread.start();
// Now build a query to run - interchangeable
- String query = Main.getAllCarAttributesQuery();
+ String query = Main.getSPO();
// Create a result proxy by registering the query at the engine
CsparqlQueryResultProxy resultProxy = null;
@@ -103,10 +103,9 @@ public class Main {
return "REGISTER QUERY BasicCarInfo AS "
+ "PREFIX f: "
+ "PREFIX xsd: "
- + "PREFIX car: "
+ "SELECT ?s ?p ?o "
- + "FROM STREAM [RANGE 5s STEP 1s] "
- + "FROM STREAM [RANGE 15s STEP 1s] "
+ + "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
+ + "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
+ "WHERE { "
+ " ?s ?p ?o . "
+ "}";
@@ -118,8 +117,8 @@ public class Main {
+ "PREFIX xsd: "
+ "PREFIX car: "
+ "SELECT ?car ?locked ?on ?speed ?rpm ?handbrake ?tirePressure "
- + "FROM STREAM [RANGE 5s STEP 1s] "
- + "FROM STREAM [RANGE 15s STEP 1s] "
+ + "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
+ + "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
+ "WHERE { "
+ " ?e car:subject ?car . "
+ " ?e car:locked ?locked . "
diff --git a/src/main/java/lu/jpt/csparqltest/rentacar/Car.java b/src/main/java/lu/jpt/csparqltest/rentacar/Car.java
index e31f5ae..9746ccf 100644
--- a/src/main/java/lu/jpt/csparqltest/rentacar/Car.java
+++ b/src/main/java/lu/jpt/csparqltest/rentacar/Car.java
@@ -200,8 +200,8 @@ public class Car {
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
String eventIri = baseIri + "/event#" + time;
- this.quads.add(new RdfQuadruple(eventIri, "a", baseOnt+"/CarAirbagEvent", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#relatedCar", this.getIri(), time));
+ this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarAirbagEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
}
private void generateContinousReportQuads() {
@@ -209,14 +209,14 @@ public class Car {
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
String eventIri = baseIri + "/event#" + time;
- this.quads.add(new RdfQuadruple(eventIri, "a", baseOnt+"/CarStatusEvent", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#relatedCar", this.getIri(), time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#motorOn", ""+this.motorOn+"^^http://www.w3.org/2001/XMLSchema#boolean", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#motorRPM", ""+this.motorRpm+"^^http://www.w3.org/2001/XMLSchema#integer", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#speed", ""+this.speed+"^^http://www.w3.org/2001/XMLSchema#integer", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#handbrakeEngaged", ""+this.handbrakeEngaged+"^^http://www.w3.org/2001/XMLSchema#boolean", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#tirePressure", ""+this.tirePressure+"^^http://www.w3.org/2001/XMLSchema#double", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#locked", ""+this.isLocked+"^^http://www.w3.org/2001/XMLSchema#boolean", time));
+ this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarStatusEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"motorOn", ""+this.motorOn+"^^http://www.w3.org/2001/XMLSchema#boolean", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"motorRPM", ""+this.motorRpm+"^^http://www.w3.org/2001/XMLSchema#integer", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"speed", ""+this.speed+"^^http://www.w3.org/2001/XMLSchema#integer", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"handbrakeEngaged", ""+this.handbrakeEngaged+"^^http://www.w3.org/2001/XMLSchema#boolean", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"tirePressure", ""+this.tirePressure+"^^http://www.w3.org/2001/XMLSchema#double", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"locked", ""+this.isLocked+"^^http://www.w3.org/2001/XMLSchema#boolean", time));
}
public CarState getState() {
diff --git a/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java b/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java
index 071d61e..0d1ea3f 100644
--- a/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java
+++ b/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java
@@ -151,10 +151,10 @@ public class Driver {
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
String eventIri = baseIri + "/event#" + time;
- this.quads.add(new RdfQuadruple(eventIri, "a", baseOnt+"/CarTakenEvent", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#relatedUser", this.getIri(), time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#relatedCar", this.car.getIri(), System.currentTimeMillis()));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#usagePeriod", ""+useCycles+"^^http://www.w3.org/2001/XMLSchema#integer", System.currentTimeMillis()));
+ this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarTakenEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedUser", this.getIri(), time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.car.getIri(), System.currentTimeMillis()));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"usagePeriod", ""+useCycles+"^^http://www.w3.org/2001/XMLSchema#integer", System.currentTimeMillis()));
}
private void returnCar() {
@@ -162,9 +162,9 @@ public class Driver {
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
String eventIri = baseIri + "/event#" + time;
- this.quads.add(new RdfQuadruple(eventIri, "a", baseOnt+"/CarReturnedEvent", time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#relatedUser", this.getIri(), time));
- this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#relatedCar", this.car.getIri(), time));
+ this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarReturnedEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedUser", this.getIri(), time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.car.getIri(), time));
this.carPool.returnCar(this.car);
this.car = null;
}
diff --git a/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java b/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java
index 2f4a38c..aeccb88 100644
--- a/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java
+++ b/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java
@@ -8,9 +8,9 @@ import eu.larkc.csparql.cep.api.RdfStream;
public class RentACarSimulation implements Runnable {
- public static final String BASE_ONTOLOGY_IRI = "http://simontology.org";
+ public static final String BASE_ONTOLOGY_IRI = "http://jpt.lu/carSimulationOntology#";
public static final String BASE_STREAM_IRI = "http://simstream.org";
- public static final String BASE_OBJECT_IRI = "http://simobject.org";
+ public static final String BASE_OBJECT_IRI = "http://jpt.lu/objects";
public static final String CAR_STREAM_IRI = BASE_STREAM_IRI + "/carStream";
public static final String DRIVER_STREAM_IRI = BASE_STREAM_IRI + "/driverStream";
@@ -99,8 +99,23 @@ public class RentACarSimulation implements Runnable {
this.runSimulation = false;
}
- public static String getSomeQuery() {
-
+ public static String getEvents() {
+ return "REGISTER QUERY getEvents AS "
+ + "PREFIX f: "
+ + "PREFIX xsd: "
+ + "PREFIX car: <"+RentACarSimulation.BASE_ONTOLOGY_IRI+"> "
+ + "SELECT ?car ?locked ?on ?speed ?rpm ?handbrake ?tirePressure "
+ + "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
+ + "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
+ + "WHERE { "
+ + " ?e car:subject ?car . "
+ + " ?e car:locked ?locked . "
+ + " ?e car:motorOn ?on . "
+ + " ?e car:speed ?speed . "
+ + " ?e car:motorRPM ?rpm . "
+ + " ?e car:handbrakeEngaged ?handbrake . "
+ + " ?e car:tirePressure ?pressure . "
+ + "}";
}
-
+
}