From 695adc1f6bfb0a0eeef4dd6c035475ea2826871f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 21 Jun 2025 20:10:38 +0300 Subject: Complete GUI decoupling implementation for headless testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implement MessageHandler pattern to decouple message sending from visualization - Add HeadlessLoader to load simulations without GUI components - Create HeadlessProtocolRunner for clean protocol test execution - Update VSInternalProcess to use MessageHandler for message routing - Add null checks in VSSimulator for headless mode compatibility - Update VSSimulatorVisualization paint() to check for headless mode - Remove obsolete test scripts and documentation - Update test-protocols.sh to remove GUI error suppression options - Consolidate testing documentation in docs/testing-guide.md All protocol tests now run cleanly in headless mode without GUI errors, enabling proper CI/CD integration and automated testing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../java/simulator/engine/SimulationEngine.java | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/main/java/simulator/engine/SimulationEngine.java (limited to 'src/main/java/simulator/engine/SimulationEngine.java') diff --git a/src/main/java/simulator/engine/SimulationEngine.java b/src/main/java/simulator/engine/SimulationEngine.java new file mode 100644 index 0000000..d557aef --- /dev/null +++ b/src/main/java/simulator/engine/SimulationEngine.java @@ -0,0 +1,119 @@ +package simulator.engine; + +import core.VSInternalProcess; +import core.VSTaskManager; +import core.VSMessage; +import java.util.List; + +/** + * Core simulation engine interface that defines all simulation operations + * without any GUI dependencies. + */ +public interface SimulationEngine { + + /** + * Send a message between processes. + * @param message The message to send + */ + void sendMessage(VSMessage message); + + /** + * Add a process to the simulation. + * @param process The process to add + */ + void addProcess(VSInternalProcess process); + + /** + * Remove a process from the simulation. + * @param process The process to remove + */ + void removeProcess(VSInternalProcess process); + + /** + * Get all processes in the simulation. + * @return List of processes + */ + List getProcesses(); + + /** + * Get a specific process by index. + * @param index The process index + * @return The process or null if not found + */ + VSInternalProcess getProcess(int index); + + /** + * Get the number of processes. + * @return Process count + */ + int getNumProcesses(); + + /** + * Get the task manager. + * @return The task manager + */ + VSTaskManager getTaskManager(); + + /** + * Get the current simulation time. + * @return Current time in milliseconds + */ + long getTime(); + + /** + * Set the simulation time. + * @param time Time in milliseconds + */ + void setTime(long time); + + /** + * Reset the simulation to initial state. + */ + void reset(); + + /** + * Start or resume the simulation. + */ + void play(); + + /** + * Pause the simulation. + */ + void pause(); + + /** + * Check if simulation is paused. + * @return true if paused + */ + boolean isPaused(); + + /** + * Check if simulation has been reset. + * @return true if reset + */ + boolean isResetted(); + + /** + * Check if simulation has finished. + * @return true if finished + */ + boolean hasFinished(); + + /** + * Set finished state. + * @param finished The finished state + */ + void setFinished(boolean finished); + + /** + * Add a visualization observer. + * @param visualizer The visualizer to add + */ + void addVisualizer(SimulationVisualizer visualizer); + + /** + * Remove a visualization observer. + * @param visualizer The visualizer to remove + */ + void removeVisualizer(SimulationVisualizer visualizer); +} \ No newline at end of file -- cgit v1.2.3