[TASK] Generic commit.
This commit is contained in:
parent
8939a75ff2
commit
2f2fd53006
@ -169,6 +169,7 @@ public class SimulationContext {
|
||||
queriesToRegister.add(simulation.getCarTakenEventsQuery());
|
||||
queriesToRegister.add(simulation.getCarReturnedEventsQuery());
|
||||
queriesToRegister.add(simulation.getWearEvents());
|
||||
queriesToRegister.add(simulation.getLockedMovingCars());
|
||||
// Now register each query appropriately!
|
||||
for(QueryContainer queryContainer : queriesToRegister) {
|
||||
CsparqlQueryResultProxy resultProxy = null;
|
||||
|
@ -237,7 +237,7 @@ public class Car {
|
||||
this.speed += RandomHelper.getRandomNumberWithin(5, 20);
|
||||
if(this.isCurrentActionHard) {
|
||||
this.speed += 40;
|
||||
this.motorRpm += RandomHelper.getRandomNumberWithin(100, 350 + rpmBonus);
|
||||
this.motorRpm += RandomHelper.getRandomNumberWithin(1000, 2000 + rpmBonus);
|
||||
}
|
||||
break;
|
||||
case BRAKING:
|
||||
@ -246,7 +246,7 @@ public class Car {
|
||||
this.speed -= RandomHelper.getRandomNumberWithin(5, 20);
|
||||
if(this.isCurrentActionHard) {
|
||||
this.speed -= 40;
|
||||
this.motorRpm -= RandomHelper.getRandomNumberWithin(100, 350 + rpmBonus);
|
||||
this.motorRpm -= RandomHelper.getRandomNumberWithin(1000, 2000 + rpmBonus);
|
||||
}
|
||||
if(this.speed < 0) this.speed = 0;
|
||||
if(this.motorRpm < 0) this.motorRpm = Car.MIN_RPM[this.CAR_TYPE];
|
||||
|
@ -338,7 +338,7 @@ public class RentACarSimulation implements Runnable {
|
||||
+ " [] rdf:type car:CarBrakeWearEvent "
|
||||
+ " ; car:relatedCar ?car . "
|
||||
+ "} "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getStronglyBrakingCars> [RANGE 2s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getStronglyBrakingCars> [RANGE 3s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e rdf:type car:CarStrongBrakingEvent . "
|
||||
+ " ?e car:relatedCar ?car . "
|
||||
@ -497,30 +497,71 @@ public class RentACarSimulation implements Runnable {
|
||||
|
||||
/**
|
||||
* 5) Query to report all WearEvents using enabled inference.
|
||||
* Also returns the responsible driver if available
|
||||
*/
|
||||
public QueryContainer getWearEvents() {
|
||||
String query = "REGISTER QUERY getWearEvents AS "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX car: <"+RentACarSimulation.BASE_ONTOLOGY_IRI+"> "
|
||||
+ "SELECT ?e ?car ?types "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getEngineWear> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getBrakeWear> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getHandbrakeWear> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getTireWear> [RANGE 5s STEP 1s] "
|
||||
+ "SELECT ?e ?type ?car ?driverName ?driverPhone "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getEngineWear> [RANGE 1s TUMBLING] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getBrakeWear> [RANGE 1s TUMBLING] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getHandbrakeWear> [RANGE 1s TUMBLING] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.BASE_STREAM_IRI+"/getTireWear> [RANGE 1s TUMBLING] "
|
||||
+ "FROM <"+RentACarSimulation.DOMAIN_KNOWLEDGE_GRAPH_IRI+"> "
|
||||
+ "WHERE { "
|
||||
+ " ?e rdf:type car:CarWearEvent . "
|
||||
+ " ?e rdf:type ?types . "
|
||||
+ " ?e car:relatedCar ?car "
|
||||
+ " ?e rdf:type ?type . "
|
||||
+ " ?e car:relatedCar ?car . "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?car car:isDrivenBy ?driver . "
|
||||
+ " ?driver car:hasName ?driverName . "
|
||||
+ " ?driver car:hasPhoneNumber ?driverPhone . "
|
||||
+ " } "
|
||||
+ "}";
|
||||
QueryContainer queryContainer = new QueryContainer("getWearEvents", query, true);
|
||||
QueryContainer queryContainer = new QueryContainer("getWearEvents", query, false);
|
||||
queryContainer.useObserverWindow();
|
||||
RentACarSimulation.setUpReasoningOnQueryContainer(queryContainer);
|
||||
return queryContainer;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 6) Query to report locked cars that move due to forgotten handbrake
|
||||
*/
|
||||
public QueryContainer getLockedMovingCars() {
|
||||
String query = "REGISTER QUERY getLockedMovingCars AS "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "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 "
|
||||
+ "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 15s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?standingEvent rdf:type car:CarStatusEvent . "
|
||||
+ " ?standingEvent car:speed ?zeroSpeed . "
|
||||
+ " ?standingEvent car:handbrakeEngaged ?handbrake . "
|
||||
+ " ?standingEvent car:locked ?locked . "
|
||||
+ " ?rollingEvent rdf:type car:CarStatusEvent . "
|
||||
+ " ?rollingEvent car:speed ?speed . "
|
||||
+ " ?rollingEvent car:handbrakeEngaged ?handbrake . "
|
||||
+ " ?rollingEvent car:locked ?locked . "
|
||||
+ " FILTER(?zeroSpeed = 0) "
|
||||
+ " FILTER(?locked) "
|
||||
+ " FILTER(!?handbrake)"
|
||||
+ " FILTER(f:timestamp(?standingEvent,rdf:type,car:CarStatusEvent) < f:timestamp(?rollingEvent,rdf:type,car:CarStatusEvent)) "
|
||||
+ "}";
|
||||
QueryContainer queryContainer = new QueryContainer("getLockedMovingCars", query, true);
|
||||
queryContainer.useObserverWindow();
|
||||
RentACarSimulation.setUpReasoningOnQueryContainer(queryContainer);
|
||||
return queryContainer;
|
||||
}
|
||||
|
||||
///////////////////////////////////// UNUSED QUERIES BELOW THIS LINE /////////////////////////////////////
|
||||
///////////////////////////////////// UNUSED QUERIES BELOW THIS LINE /////////////////////////////////////
|
||||
///////////////////////////////////// UNUSED QUERIES BELOW THIS LINE /////////////////////////////////////
|
||||
|
||||
public QueryContainer getEventsQuery() {
|
||||
String query = "REGISTER QUERY getCarStatusEvents AS "
|
||||
|
Loading…
Reference in New Issue
Block a user