Class Engine

java.lang.Object
java.lang.Thread
simu.framework.Engine
All Implemented Interfaces:
Runnable, IEngine
Direct Known Subclasses:
OwnEngine

public abstract class Engine extends Thread implements IEngine
The Engine class is an abstract class that represents the core of the simulation engine. It extends the Thread class and implements the IEngine interface. The engine manages the simulation time, event list, and the execution of events.
  • Field Details

  • Constructor Details

    • Engine

      public Engine(IControllerForM controller)
      Constructs an Engine with the specified controller.
      Parameters:
      controller - the controller used to manage the simulation
  • Method Details

    • setSimulationTime

      public void setSimulationTime(double time)
      Sets the simulation time of the engine.
      Specified by:
      setSimulationTime in interface IEngine
      Parameters:
      time - the new simulation time
    • setDelay

      public void setDelay(long delay)
      Sets the delay between simulation steps.
      Specified by:
      setDelay in interface IEngine
      Parameters:
      delay - the delay in milliseconds
    • getDelay

      public long getDelay()
      Returns the delay between simulation steps.
      Specified by:
      getDelay in interface IEngine
      Returns:
      the delay in milliseconds
    • run

      public void run()
      Runs the simulation engine. The engine initializes the simulation, runs the B-phase events, and attempts the C-phase events. The engine continues to run until the simulation time is reached. The engine then displays the simulation results. The engine also includes a delay between simulation steps. The engine is implemented as a thread to allow for concurrent execution.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • attemptCEvents

      protected abstract void attemptCEvents()
      Attempts the C-phase events. The engine attempts to run the C-phase events. The engine is implemented in the subclasses of the engine.
    • init

      protected abstract void init()
      Initializes the simulation. The engine is implemented in the subclasses of the engine.
    • runEvent

      protected abstract void runEvent(Event t)
      Runs the specified event. The engine is implemented in the subclasses of the engine.
      Parameters:
      t - the event to run
    • results

      protected abstract void results()
      Displays the simulation results. The engine is implemented in the subclasses of the engine.