Class Engine
java.lang.Object
java.lang.Thread
simu.framework.Engine
- Direct Known Subclasses:
OwnEngine
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionEngine(IControllerForM controller) Constructs an Engine with the specified controller. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidAttempts the C-phase events.longgetDelay()Returns the delay between simulation steps.protected abstract voidinit()Initializes the simulation.protected abstract voidresults()Displays the simulation results.voidrun()Runs the simulation engine.protected abstract voidRuns the specified event.voidsetDelay(long delay) Sets the delay between simulation steps.voidsetSimulationTime(double time) Sets the simulation time of the engine.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Field Details
-
eventList
-
controller
-
-
Constructor Details
-
Engine
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:
setSimulationTimein interfaceIEngine- Parameters:
time- the new simulation time
-
setDelay
-
getDelay
-
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. -
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
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.
-