[TASK] Prepare for integration of background knowledge
This commit is contained in:
1 parent
018f54ea1c
commit
6d2c90ef96
6 files changed
+254
-245
No files matched your search
@@ -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: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX car: <http://myexample.org/car#> "
|
||||
+ "SELECT ?s ?p ?o "
|
||||
+ "FROM STREAM <http://myexample.org/car> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <http://myexample.org/driver> [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: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX car: <http://myexample.org/car#> "
|
||||
+ "SELECT ?car ?locked ?on ?speed ?rpm ?handbrake ?tirePressure "
|
||||
+ "FROM STREAM <http://myexample.org/car> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <http://myexample.org/driver> [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 . "
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "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 . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user