Class ScenarioTestRunner

java.lang.Object
neqsim.process.util.scenario.ScenarioTestRunner

public class ScenarioTestRunner extends Object
Utility class for running and managing multiple test scenarios with automatic KPI collection.

This class simplifies the execution of multiple scenarios by:

  • Automating scenario execution with proper reset between scenarios
  • Collecting KPI data automatically into a dashboard
  • Providing consistent formatting and reporting
  • Handling scenario numbering and headers

Example usage:

ProcessScenarioRunner runner = new ProcessScenarioRunner(processSystem);
runner.initializeSteadyState();

ScenarioTestRunner testRunner = new ScenarioTestRunner(runner);

// Execute scenarios
testRunner.executeScenario("Normal Startup", normalScenario, "System Startup", 30.0, 1.0);
testRunner.executeScenario("Manual ESD", esdScenario, "ESD Level 1", 25.0, 0.5);

// Display results
testRunner.displayDashboard();

Batch execution example using builder:

testRunner.printHeader();
testRunner.batch().add("Normal Startup", normalScenario, "System Startup", 30.0, 1.0)
    .add("Manual ESD", esdScenario, "ESD Level 1", 25.0, 0.5).addDelayed("High Pressure",
        highPressureScenario, "ESD Level 1", 8000, "HIGH PRESSURE DETECTED", 30.0, 1.0)
    .execute();
testRunner.displayDashboard();
Version:
1.0
Author:
ESOL
  • Field Details

  • Constructor Details

    • ScenarioTestRunner

      public ScenarioTestRunner(ProcessScenarioRunner runner)
      Creates a new scenario test runner.
      Parameters:
      runner - the process scenario runner to use for executing scenarios
  • Method Details

    • printHeader

      public void printHeader()
      Prints the test header with formatting.
    • executeScenario

      public ScenarioExecutionSummary executeScenario(String scenarioName, ProcessSafetyScenario scenario, String logicToActivate, double duration, double timeStep)
      Executes a scenario with automatic logic activation, KPI collection, and reset.
      Parameters:
      scenarioName - the display name for the scenario
      scenario - the safety scenario to execute
      logicToActivate - the name of the logic sequence to activate (can be null)
      duration - the simulation duration in seconds
      timeStep - the time step in seconds
      Returns:
      the scenario execution summary
    • executeScenario

      public ScenarioExecutionSummary executeScenario(String scenarioName, ProcessSafetyScenario scenario, double duration, double timeStep)
      Executes a scenario without activating any logic.
      Parameters:
      scenarioName - the display name for the scenario
      scenario - the safety scenario to execute
      duration - the simulation duration in seconds
      timeStep - the time step in seconds
      Returns:
      the scenario execution summary
    • executeScenarioWithDelayedActivation

      public ScenarioExecutionSummary executeScenarioWithDelayedActivation(String scenarioName, ProcessSafetyScenario scenario, String logicToActivate, long activationDelay, String activationMessage, double duration, double timeStep)
      Executes a scenario with delayed logic activation using a background thread.

      This is useful for simulating manual interventions or automatic triggers that occur after some time during the scenario.

      Parameters:
      scenarioName - the display name for the scenario
      scenario - the safety scenario to execute
      logicToActivate - the name of the logic sequence to activate
      activationDelay - the delay in milliseconds before activating logic
      activationMessage - the message to print when activating logic
      duration - the simulation duration in seconds
      timeStep - the time step in seconds
      Returns:
      the scenario execution summary
    • displayDashboard

      public void displayDashboard()
      Displays the KPI dashboard comparing all executed scenarios.
    • getDashboard

      public KPIDashboard getDashboard()
      Gets the KPI dashboard for manual inspection or export.
      Returns:
      the KPI dashboard
    • getRunner

      public ProcessScenarioRunner getRunner()
      Gets the underlying process scenario runner.
      Returns:
      the process scenario runner
    • getScenarioCount

      public int getScenarioCount()
      Gets the current scenario counter (number of scenarios executed).
      Returns:
      the scenario counter
    • resetCounter

      public void resetCounter()
      Resets the scenario counter.
    • batch

      Creates a batch executor for running multiple scenarios in sequence.

      This provides a fluent API for defining and executing multiple scenarios:

      testRunner.batch().add("Scenario 1", scenario1, "Logic 1", 30.0, 1.0)
          .add("Scenario 2", scenario2, null, 25.0, 0.5)
          .addDelayed("Scenario 3", scenario3, "ESD Logic", 5000, "ESD TRIGGERED", 30.0, 1.0)
          .execute();
      
      Returns:
      a new batch executor