[TASK] Add a ton of event classes, fix up abox with simulation.
This commit is contained in:
parent
038a6a85bc
commit
bdf7191c18
|
@ -30,6 +30,35 @@
|
||||||
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#0"/>
|
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#0"/>
|
||||||
</owl:NamedIndividual>
|
</owl:NamedIndividual>
|
||||||
|
|
||||||
|
<owl:NamedIndividual rdf:about="http://example.org/carSim/objects/Car#4">
|
||||||
|
<rdf:type rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
||||||
|
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#2"/>
|
||||||
|
</owl:NamedIndividual>
|
||||||
|
|
||||||
|
<owl:NamedIndividual rdf:about="http://example.org/carSim/objects/Car#5">
|
||||||
|
<rdf:type rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
||||||
|
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#2"/>
|
||||||
|
</owl:NamedIndividual>
|
||||||
|
|
||||||
|
<owl:NamedIndividual rdf:about="http://example.org/carSim/objects/Car#6">
|
||||||
|
<rdf:type rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
||||||
|
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#0"/>
|
||||||
|
</owl:NamedIndividual>
|
||||||
|
|
||||||
|
<owl:NamedIndividual rdf:about="http://example.org/carSim/objects/Car#7">
|
||||||
|
<rdf:type rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
||||||
|
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#1"/>
|
||||||
|
</owl:NamedIndividual>
|
||||||
|
|
||||||
|
<owl:NamedIndividual rdf:about="http://example.org/carSim/objects/Car#8">
|
||||||
|
<rdf:type rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
||||||
|
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#1"/>
|
||||||
|
</owl:NamedIndividual>
|
||||||
|
|
||||||
|
<owl:NamedIndividual rdf:about="http://example.org/carSim/objects/Car#9">
|
||||||
|
<rdf:type rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
||||||
|
<simontology:isCarModel rdf:resource="http://example.org/carSim/objects/CarModel#0"/>
|
||||||
|
</owl:NamedIndividual>
|
||||||
|
|
||||||
<!-- Car Model data -->
|
<!-- Car Model data -->
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
|
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
|
||||||
|
|
||||||
|
<!-- Classes -->
|
||||||
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#Car">
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#Car">
|
||||||
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#Event"/>
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#Event"/>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
|
|
||||||
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarAirbagEvent">
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarAirbagTriggeredEvent">
|
||||||
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
|
@ -33,6 +34,12 @@
|
||||||
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarCheckEngineEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
|
||||||
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarUserEvent">
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarUserEvent">
|
||||||
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
@ -49,6 +56,76 @@
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
|
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarHandbrakeEngageEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarHandbrakeReleaseEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarLockEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarUnlockEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarStrongAcceleratingEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarStrongBrakingEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarStandingEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarMovingEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarWearEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarEngineWearEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarWearEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarBrakeWearEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarWearEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarHandbrakeWearEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarWearEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#CarTireWearEvent">
|
||||||
|
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
||||||
|
<rdfs:subClassOf rdf:resource="http://example.org/carSim/carSimulationOntology#CarWearEvent"/>
|
||||||
|
</rdf:Description>
|
||||||
|
|
||||||
|
<!-- Attributes -->
|
||||||
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#isOfCarModel">
|
<rdf:Description rdf:about="http://example.org/carSim/carSimulationOntology#isOfCarModel">
|
||||||
<rdfs:domain rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
<rdfs:domain rdf:resource="http://example.org/carSim/carSimulationOntology#Car"/>
|
||||||
<rdfs:range rdf:resource="http://example.org/carSim/carSimulationOntology#CarModel"/>
|
<rdfs:range rdf:resource="http://example.org/carSim/carSimulationOntology#CarModel"/>
|
||||||
|
@ -85,5 +162,4 @@
|
||||||
<rdfs:range rdf:resource="http://example.org/carSim/carSimulationOntology#Event"/>
|
<rdfs:range rdf:resource="http://example.org/carSim/carSimulationOntology#Event"/>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
|
|
||||||
|
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
|
@ -53,6 +53,8 @@ public class Car {
|
||||||
private double tirePressure2;
|
private double tirePressure2;
|
||||||
private double tirePressure3;
|
private double tirePressure3;
|
||||||
private double tirePressure4;
|
private double tirePressure4;
|
||||||
|
|
||||||
|
private boolean checkEngineLightOn;
|
||||||
|
|
||||||
|
|
||||||
// Sitzplätze? Reservierungen für X Personen?
|
// Sitzplätze? Reservierungen für X Personen?
|
||||||
|
@ -61,7 +63,42 @@ public class Car {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.IRI = RentACarSimulation.BASE_OBJECT_IRI + "/Car";
|
this.IRI = RentACarSimulation.BASE_OBJECT_IRI + "/Car";
|
||||||
this.quads = new ArrayList<RdfQuadruple>();
|
this.quads = new ArrayList<RdfQuadruple>();
|
||||||
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);
|
this.initializeCarType(this.CAR_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +117,8 @@ public class Car {
|
||||||
this.currentAction = CarAction.NONE;
|
this.currentAction = CarAction.NONE;
|
||||||
this.isCurrentActionHard = false;
|
this.isCurrentActionHard = false;
|
||||||
this.currentActionTicksLeft = 0;
|
this.currentActionTicksLeft = 0;
|
||||||
|
// Other data
|
||||||
|
this.checkEngineLightOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyClose() {
|
public void keyClose() {
|
||||||
|
@ -111,10 +150,12 @@ public class Car {
|
||||||
|
|
||||||
public void engageHandbrake() {
|
public void engageHandbrake() {
|
||||||
this.handbrakeEngaged = true;
|
this.handbrakeEngaged = true;
|
||||||
|
this.fireHandbrakeEngageEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseHandbrake() {
|
public void releaseHandbrake() {
|
||||||
this.handbrakeEngaged = false;
|
this.handbrakeEngaged = false;
|
||||||
|
this.fireHandbrakeReleaseEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHandbrakeEngaged() {
|
public boolean isHandbrakeEngaged() {
|
||||||
|
@ -142,6 +183,11 @@ public class Car {
|
||||||
* Update internal stuff according to state
|
* Update internal stuff according to state
|
||||||
*/
|
*/
|
||||||
public void tick() {
|
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;
|
int rpmBonus = 0;
|
||||||
Car.logger.debug("Old state: " + this.currentState + ", Action: " + this.currentAction);
|
Car.logger.debug("Old state: " + this.currentState + ", Action: " + this.currentAction);
|
||||||
switch(this.currentAction) {
|
switch(this.currentAction) {
|
||||||
|
@ -158,10 +204,12 @@ public class Car {
|
||||||
case LOCKING:
|
case LOCKING:
|
||||||
this.isLocked = true;
|
this.isLocked = true;
|
||||||
this.currentState = CarState.LOCKED;
|
this.currentState = CarState.LOCKED;
|
||||||
|
this.fireLockEvent();
|
||||||
break;
|
break;
|
||||||
case UNLOCKING:
|
case UNLOCKING:
|
||||||
this.isLocked = false;
|
this.isLocked = false;
|
||||||
this.currentState = CarState.OFF;
|
this.currentState = CarState.OFF;
|
||||||
|
this.fireUnlockEvent();
|
||||||
break;
|
break;
|
||||||
case ACCELERATING:
|
case ACCELERATING:
|
||||||
if(this.currentState == CarState.IDLE) this.currentState = CarState.DRIVE;
|
if(this.currentState == CarState.IDLE) this.currentState = CarState.DRIVE;
|
||||||
|
@ -197,12 +245,17 @@ public class Car {
|
||||||
this.motorOn = false;
|
this.motorOn = false;
|
||||||
this.motorRpm = 0;
|
this.motorRpm = 0;
|
||||||
this.speed = 0;
|
this.speed = 0;
|
||||||
|
this.fireAirbagEvent();
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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
|
// Decrement action tick counter and move to none if action is done
|
||||||
this.currentActionTicksLeft--;
|
this.currentActionTicksLeft--;
|
||||||
if(this.currentActionTicksLeft == 0) {
|
if(this.currentActionTicksLeft == 0) {
|
||||||
|
@ -217,7 +270,7 @@ public class Car {
|
||||||
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
||||||
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
|
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
|
||||||
String eventIri = baseIri + "/event#" + time;
|
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));
|
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));
|
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() {
|
private void generateContinousReportQuads() {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
||||||
|
|
|
@ -57,5 +57,9 @@ public class CarPool {
|
||||||
public List<Car> getCars() {
|
public List<Car> getCars() {
|
||||||
return new ArrayList<Car>(this.cars);
|
return new ArrayList<Car>(this.cars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasFreeCars() {
|
||||||
|
return !this.availableCars.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,25 @@ public class Driver {
|
||||||
this.carPool = carPool;
|
this.carPool = carPool;
|
||||||
this.car = null;
|
this.car = null;
|
||||||
this.quads = new ArrayList<RdfQuadruple>();
|
this.quads = new ArrayList<RdfQuadruple>();
|
||||||
// Pick a random behaviour and stick to it.
|
// Personality according to names in ABox
|
||||||
this.trait = (Trait) RandomHelper.getRandomElementFromArray(Trait.values());
|
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() {
|
public int getID() {
|
||||||
|
@ -64,12 +81,12 @@ public class Driver {
|
||||||
* given a car is available.
|
* given a car is available.
|
||||||
*/
|
*/
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if(car == null) {
|
if(car == null && this.carPool.hasFreeCars()) {
|
||||||
// Nothing to do, maybe randomly take a free car
|
// Nothing to do, maybe randomly take a free car
|
||||||
if(RandomHelper.isLuckyByChance(0.75)) {
|
if(RandomHelper.isLuckyByChance(0.75)) {
|
||||||
this.takeRandomCarFor(RandomHelper.getRandomNumberWithin(20,50));
|
this.takeRandomCarFor(RandomHelper.getRandomNumberWithin(20,50));
|
||||||
}
|
}
|
||||||
} else {
|
} else if(car != null) {
|
||||||
// Do random things with the car
|
// Do random things with the car
|
||||||
if(this.car.needsInput()) {
|
if(this.car.needsInput()) {
|
||||||
this.useCar(this.car);
|
this.useCar(this.car);
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class RentACarSimulation implements Runnable {
|
||||||
|
|
||||||
public RentACarSimulation() {
|
public RentACarSimulation() {
|
||||||
this.registerOwnPrefixes();
|
this.registerOwnPrefixes();
|
||||||
int numberOfCars = 2;
|
int numberOfCars = 2; // Maximum of 10 cars are in the ABox (0-9)
|
||||||
int numberOfCustomers = 1;
|
int numberOfCustomers = 5; // Maximum of 5 drivers are in the ABox (0-4)
|
||||||
// Create a car pool and drivers
|
// Create a car pool and drivers
|
||||||
this.carPool = new CarPool(numberOfCars);
|
this.carPool = new CarPool(numberOfCars);
|
||||||
this.drivers = new ArrayList<Driver>();
|
this.drivers = new ArrayList<Driver>();
|
||||||
|
|
Loading…
Reference in New Issue