diff --git a/data/carSimulationABox.rdf b/data/carSimulationABox.rdf
index 3ce4bdd..9534bbc 100644
--- a/data/carSimulationABox.rdf
+++ b/data/carSimulationABox.rdf
@@ -30,6 +30,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/carSimulationTBox.rdf b/data/carSimulationTBox.rdf
index efd4a66..4bbfba7 100644
--- a/data/carSimulationTBox.rdf
+++ b/data/carSimulationTBox.rdf
@@ -2,6 +2,7 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
+
@@ -23,7 +24,7 @@
-
+
@@ -33,6 +34,12 @@
+
+
+
+
+
+
@@ -49,6 +56,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -85,5 +162,4 @@
-
\ No newline at end of file
diff --git a/src/main/java/lu/jpt/csparqlproject/rentacar/Car.java b/src/main/java/lu/jpt/csparqlproject/rentacar/Car.java
index 796a9e5..30fb730 100644
--- a/src/main/java/lu/jpt/csparqlproject/rentacar/Car.java
+++ b/src/main/java/lu/jpt/csparqlproject/rentacar/Car.java
@@ -53,6 +53,8 @@ public class Car {
private double tirePressure2;
private double tirePressure3;
private double tirePressure4;
+
+ private boolean checkEngineLightOn;
// Sitzplätze? Reservierungen für X Personen?
@@ -61,7 +63,42 @@ public class Car {
this.id = id;
this.IRI = RentACarSimulation.BASE_OBJECT_IRI + "/Car";
this.quads = new ArrayList();
- this.CAR_TYPE = RandomHelper.nextInt(2);
+ // Technical details according to data in ABox
+ switch(id) {
+ case 0:
+ this.CAR_TYPE = 0;
+ break;
+ case 1:
+ this.CAR_TYPE = 2;
+ break;
+ case 2:
+ this.CAR_TYPE = 1;
+ break;
+ case 3:
+ this.CAR_TYPE = 0;
+ break;
+ case 4:
+ this.CAR_TYPE = 2;
+ break;
+ case 5:
+ this.CAR_TYPE = 2;
+ break;
+ case 6:
+ this.CAR_TYPE = 0;
+ break;
+ case 7:
+ this.CAR_TYPE = 1;
+ break;
+ case 8:
+ this.CAR_TYPE = 1;
+ break;
+ case 9:
+ this.CAR_TYPE = 0;
+ break;
+ default:
+ this.CAR_TYPE = RandomHelper.nextInt(2);
+ break;
+ }
this.initializeCarType(this.CAR_TYPE);
}
@@ -80,6 +117,8 @@ public class Car {
this.currentAction = CarAction.NONE;
this.isCurrentActionHard = false;
this.currentActionTicksLeft = 0;
+ // Other data
+ this.checkEngineLightOn = false;
}
public void keyClose() {
@@ -111,10 +150,12 @@ public class Car {
public void engageHandbrake() {
this.handbrakeEngaged = true;
+ this.fireHandbrakeEngageEvent();
}
public void releaseHandbrake() {
this.handbrakeEngaged = false;
+ this.fireHandbrakeReleaseEvent();
}
public boolean isHandbrakeEngaged() {
@@ -142,6 +183,11 @@ public class Car {
* Update internal stuff according to state
*/
public void tick() {
+ // See whether the check engine light comes on
+ if(RandomHelper.isLuckyByChance(0.002)) {
+ this.checkEngineLightOn = true;
+ }
+ // Do the simulation stuff
int rpmBonus = 0;
Car.logger.debug("Old state: " + this.currentState + ", Action: " + this.currentAction);
switch(this.currentAction) {
@@ -158,10 +204,12 @@ public class Car {
case LOCKING:
this.isLocked = true;
this.currentState = CarState.LOCKED;
+ this.fireLockEvent();
break;
case UNLOCKING:
this.isLocked = false;
this.currentState = CarState.OFF;
+ this.fireUnlockEvent();
break;
case ACCELERATING:
if(this.currentState == CarState.IDLE) this.currentState = CarState.DRIVE;
@@ -197,12 +245,17 @@ public class Car {
this.motorOn = false;
this.motorRpm = 0;
this.speed = 0;
+ this.fireAirbagEvent();
break;
case NONE:
break;
default:
break;
}
+ // See if the check Engine light is on and fire an event accordingly
+ if(this.checkEngineLightOn) {
+ this.fireCheckEngineEvent();
+ }
// Decrement action tick counter and move to none if action is done
this.currentActionTicksLeft--;
if(this.currentActionTicksLeft == 0) {
@@ -217,7 +270,7 @@ 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, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarAirbagEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarAirbagTriggeredEvent", time));
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
}
@@ -230,6 +283,42 @@ public class Car {
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
}
+ private void fireLockEvent() {
+ long time = System.currentTimeMillis();
+ String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
+ String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
+ String eventIri = baseIri + "/event#" + time;
+ this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarLockEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
+ }
+
+ private void fireUnlockEvent() {
+ long time = System.currentTimeMillis();
+ String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
+ String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
+ String eventIri = baseIri + "/event#" + time;
+ this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarUnlockEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
+ }
+
+ private void fireHandbrakeEngageEvent() {
+ long time = System.currentTimeMillis();
+ String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
+ String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
+ String eventIri = baseIri + "/event#" + time;
+ this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarHandbrakeEngageEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
+ }
+
+ private void fireHandbrakeReleaseEvent() {
+ long time = System.currentTimeMillis();
+ String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
+ String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
+ String eventIri = baseIri + "/event#" + time;
+ this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarHandbrakeReleaseEvent", time));
+ this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
+ }
+
private void generateContinousReportQuads() {
long time = System.currentTimeMillis();
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
diff --git a/src/main/java/lu/jpt/csparqlproject/rentacar/CarPool.java b/src/main/java/lu/jpt/csparqlproject/rentacar/CarPool.java
index db504c2..b1783d4 100644
--- a/src/main/java/lu/jpt/csparqlproject/rentacar/CarPool.java
+++ b/src/main/java/lu/jpt/csparqlproject/rentacar/CarPool.java
@@ -57,5 +57,9 @@ public class CarPool {
public List getCars() {
return new ArrayList(this.cars);
}
+
+ public boolean hasFreeCars() {
+ return !this.availableCars.isEmpty();
+ }
}
diff --git a/src/main/java/lu/jpt/csparqlproject/rentacar/Driver.java b/src/main/java/lu/jpt/csparqlproject/rentacar/Driver.java
index 85cd1ba..ded7bc6 100644
--- a/src/main/java/lu/jpt/csparqlproject/rentacar/Driver.java
+++ b/src/main/java/lu/jpt/csparqlproject/rentacar/Driver.java
@@ -47,8 +47,25 @@ public class Driver {
this.carPool = carPool;
this.car = null;
this.quads = new ArrayList();
- // Pick a random behaviour and stick to it.
- this.trait = (Trait) RandomHelper.getRandomElementFromArray(Trait.values());
+ // Personality according to names in ABox
+ switch(id) {
+ case 0:
+ case 1:
+ this.trait = Trait.REGULAR;
+ break;
+ case 2:
+ this.trait = Trait.INSANE;
+ break;
+ case 3:
+ this.trait = Trait.CAREFUL;
+ break;
+ case 4:
+ this.trait = Trait.FAST;
+ break;
+ default:
+ this.trait = (Trait) RandomHelper.getRandomElementFromArray(Trait.values());
+ break;
+ }
}
public int getID() {
@@ -64,12 +81,12 @@ public class Driver {
* given a car is available.
*/
public void tick() {
- if(car == null) {
+ if(car == null && this.carPool.hasFreeCars()) {
// Nothing to do, maybe randomly take a free car
if(RandomHelper.isLuckyByChance(0.75)) {
this.takeRandomCarFor(RandomHelper.getRandomNumberWithin(20,50));
}
- } else {
+ } else if(car != null) {
// Do random things with the car
if(this.car.needsInput()) {
this.useCar(this.car);
diff --git a/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java b/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java
index 7136a61..d88ce58 100644
--- a/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java
+++ b/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java
@@ -45,8 +45,8 @@ public class RentACarSimulation implements Runnable {
public RentACarSimulation() {
this.registerOwnPrefixes();
- int numberOfCars = 2;
- int numberOfCustomers = 1;
+ int numberOfCars = 2; // Maximum of 10 cars are in the ABox (0-9)
+ int numberOfCustomers = 5; // Maximum of 5 drivers are in the ABox (0-4)
// Create a car pool and drivers
this.carPool = new CarPool(numberOfCars);
this.drivers = new ArrayList();