[TASK] Add some commenting.
This commit is contained in:
parent
36a14510f3
commit
557de999de
|
@ -7,6 +7,13 @@ import org.slf4j.LoggerFactory;
|
|||
import lu.jpt.csparqltest.gui.SimulationControlWindow;
|
||||
import lu.jpt.csparqltest.rentacar.RentACarSimulation;
|
||||
|
||||
/**
|
||||
* This is the main entry point of the whole project. A logger is being set up
|
||||
* and the SimulationContext gets initialized to allow a control window to be
|
||||
* hooked up to it.
|
||||
* The SimulationContext class takes it from there. The window merely provides a
|
||||
* control interface for the user.
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static Logger logger = LoggerFactory.getLogger(Main.class);
|
||||
|
|
|
@ -14,6 +14,18 @@ import eu.larkc.csparql.core.engine.CsparqlQueryResultProxy;
|
|||
import lu.jpt.csparqltest.gui.TextObserverWindow;
|
||||
import lu.jpt.csparqltest.rentacar.RentACarSimulation;
|
||||
|
||||
/**
|
||||
* This class encapsulates the use of the C-SPARQL Engine. Here, the RentACarSimulation,
|
||||
* which provides the needed event streams is being initialized, and its event streams
|
||||
* are being registered with the engine.
|
||||
*
|
||||
* Also, the neccessary C-SPARQL queries are fetched from the RentACarSimulation and
|
||||
* also getting registered with the engine. This way, everything you may need to know
|
||||
* about how to use the engine itself lies within here.
|
||||
*
|
||||
* Take a look at the methods setup()
|
||||
* and teardown(), since they contain the most important parts.
|
||||
*/
|
||||
public class SimulationContext {
|
||||
|
||||
public static Logger logger = LoggerFactory.getLogger(SimulationContext.class);
|
||||
|
|
|
@ -11,6 +11,10 @@ import javax.swing.JPanel;
|
|||
|
||||
import lu.jpt.csparqltest.SimulationContext;
|
||||
|
||||
/**
|
||||
* Basically a window with control buttons that trigger actions
|
||||
* in the SimulationContext. Think of it as a basic remote control.
|
||||
*/
|
||||
public class SimulationControlWindow extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -7,6 +7,10 @@ import eu.larkc.csparql.cep.api.RdfQuadruple;
|
|||
import lu.jpt.csparqltest.util.RandomHelper;
|
||||
import lu.jpt.csparqltest.util.WindowLoggingRdfStream;
|
||||
|
||||
/**
|
||||
* This event stream generator was used for debugging and experimenting
|
||||
* with C-SPARQL queries. It is not actively used for the RentACarSimulation.
|
||||
*/
|
||||
public class TestStreamGenerator extends WindowLoggingRdfStream implements Runnable {
|
||||
protected final Logger logger = LoggerFactory.getLogger(TestStreamGenerator.class);
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@ import org.slf4j.LoggerFactory;
|
|||
import eu.larkc.csparql.cep.api.RdfQuadruple;
|
||||
import lu.jpt.csparqltest.util.RandomHelper;
|
||||
|
||||
/**
|
||||
* This class is all about simulating aspects of different cars.
|
||||
* Nothing too special and unfortunately, it got a little out of hand.
|
||||
* View at your own risk.
|
||||
*/
|
||||
public class Car {
|
||||
|
||||
public static Logger logger = LoggerFactory.getLogger(Car.class);
|
||||
|
|
|
@ -4,6 +4,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* The simulation contains a pool of cars from which the drivers
|
||||
* can pick a vehicle to (ab)use.
|
||||
*/
|
||||
public class CarPool {
|
||||
|
||||
private List<Car> cars;
|
||||
|
|
|
@ -9,6 +9,12 @@ import org.slf4j.LoggerFactory;
|
|||
import eu.larkc.csparql.cep.api.RdfQuadruple;
|
||||
import lu.jpt.csparqltest.util.RandomHelper;
|
||||
|
||||
/**
|
||||
* Since simulating cars is boring without simulating persons that drive these cars,
|
||||
* this class is all about simulating a driver. A driver is basically an entity that
|
||||
* makes use of the car, resulting in triggering actions on the car.
|
||||
* This part is not that beautiful, either. View at own risk!
|
||||
*/
|
||||
public class Driver {
|
||||
|
||||
public static Logger logger = LoggerFactory.getLogger(Driver.class);
|
||||
|
|
|
@ -10,6 +10,14 @@ import eu.larkc.csparql.cep.api.RdfQuadruple;
|
|||
import eu.larkc.csparql.cep.api.RdfStream;
|
||||
import lu.jpt.csparqltest.util.WindowLoggingRdfStream;
|
||||
|
||||
/**
|
||||
* This is the main simulation part of the project.
|
||||
* It is being run within a separate thread, continously feeding its
|
||||
* data into the rdf event streams which are registered with the engine.
|
||||
*
|
||||
* The simulation itself is not that sophisticated and based on a lot of
|
||||
* random numbers.
|
||||
*/
|
||||
public class RentACarSimulation implements Runnable {
|
||||
|
||||
public static Logger logger = LoggerFactory.getLogger(RentACarSimulation.class);
|
||||
|
|
|
@ -2,6 +2,11 @@ package lu.jpt.csparqltest.util;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Since the simulation needs a lot of random numbers and keeps asking
|
||||
* about whether something by a given chance happens, this class provides
|
||||
* helper methods for this.
|
||||
*/
|
||||
public class RandomHelper {
|
||||
|
||||
private static Random myRandom = new Random();
|
||||
|
|
|
@ -3,6 +3,10 @@ package lu.jpt.csparqltest.util;
|
|||
import eu.larkc.csparql.cep.api.RdfQuadruple;
|
||||
import lu.jpt.csparqltest.gui.TextObserverWindow;
|
||||
|
||||
/**
|
||||
* Using this class, RdfStreams can automatically be made visible
|
||||
* within the TextObserverWindow.
|
||||
*/
|
||||
public class WindowLoggingRdfStream extends LoggableRdfStream {
|
||||
|
||||
private TextObserverWindow observerWindow;
|
||||
|
|
Loading…
Reference in New Issue