Class ScenarioTestRunner
java.lang.Object
neqsim.process.util.scenario.ScenarioTestRunner
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassFluent builder for batch execution of multiple scenarios.private static classInternal configuration class for batch scenario execution. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final KPIDashboardprivate final ProcessScenarioRunnerprivate int -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new scenario test runner. -
Method Summary
Modifier and TypeMethodDescriptionbatch()Creates a batch executor for running multiple scenarios in sequence.voidDisplays the KPI dashboard comparing all executed scenarios.executeScenario(String scenarioName, ProcessSafetyScenario scenario, double duration, double timeStep) Executes a scenario without activating any logic.executeScenario(String scenarioName, ProcessSafetyScenario scenario, String logicToActivate, double duration, double timeStep) Executes a scenario with automatic logic activation, KPI collection, and reset.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.Gets the KPI dashboard for manual inspection or export.Gets the underlying process scenario runner.intGets the current scenario counter (number of scenarios executed).voidPrints the test header with formatting.voidResets the scenario counter.
-
Field Details
-
runner
-
dashboard
-
scenarioCounter
private int scenarioCounter
-
-
Constructor Details
-
ScenarioTestRunner
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 scenarioscenario- the safety scenario to executelogicToActivate- the name of the logic sequence to activate (can be null)duration- the simulation duration in secondstimeStep- 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 scenarioscenario- the safety scenario to executeduration- the simulation duration in secondstimeStep- 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 scenarioscenario- the safety scenario to executelogicToActivate- the name of the logic sequence to activateactivationDelay- the delay in milliseconds before activating logicactivationMessage- the message to print when activating logicduration- the simulation duration in secondstimeStep- the time step in seconds- Returns:
- the scenario execution summary
-
displayDashboard
public void displayDashboard()Displays the KPI dashboard comparing all executed scenarios. -
getDashboard
Gets the KPI dashboard for manual inspection or export.- Returns:
- the KPI dashboard
-
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
-