Class ContinuousAutomation
- All Implemented Interfaces:
AutomationScript
ContinuousAutomation provides an event-loop based automation pattern that continuously monitors the GUI for active states and executes appropriate transitions. This implementation is ideal for reactive automation scenarios where the system must respond to unpredictable GUI events or maintain ongoing interaction with an application.
Execution model:
- Periodic Scanning: Searches for active states at configurable intervals
- Transition Execution: Runs transitions for any active states found
- Rest State Support: Naturally pauses at states without transitions
- Concurrent Safety: Single-threaded executor prevents race conditions
Key features:
- Automatic state discovery through periodic searches
- Graceful handling of states with and without transitions
- Clean shutdown with proper thread termination
- Error recovery with automatic stop on exceptions
- Configurable search intervals for performance tuning
Common use cases:
- Monitoring applications for specific conditions
- Handling asynchronous popups or notifications
- Maintaining application state during long-running processes
- Creating responsive bots that react to GUI events
- Implementing watchdog functionality
State handling strategy:
- Active states with transitions trigger state handler execution
- Active states without transitions serve as rest points
- Multiple active states are processed sequentially
- State handler failures are logged but don't stop execution
Performance considerations:
- Search interval affects responsiveness vs. CPU usage
- State finder efficiency impacts overall performance
- Consider search optimization for large state spaces
- Single-threaded design prevents parallel state handling
In the model-based approach, ContinuousAutomation embodies the reactive automation paradigm where the system continuously adapts to the current GUI state. This pattern is particularly powerful for applications with dynamic behavior, unexpected events, or when human interaction may occur alongside automation.
- Since:
- 1.0
- See Also:
-
Field Summary
Fields inherited from class io.github.jspinak.brobot.automationScripts.BaseAutomation
running, stateHandler
-
Constructor Summary
ConstructorsConstructorDescriptionContinuousAutomation
(StateFinder stateFinder, StateTransitionsRepository stateTransitionsRepository, AllStatesInProjectService allStates, StateHandler stateHandler) -
Method Summary
Methods inherited from class io.github.jspinak.brobot.automationScripts.BaseAutomation
isRunning
-
Constructor Details
-
ContinuousAutomation
public ContinuousAutomation(StateFinder stateFinder, StateTransitionsRepository stateTransitionsRepository, AllStatesInProjectService allStates, StateHandler stateHandler)
-
-
Method Details
-
start
public void start() -
stop
public void stop()- Specified by:
stop
in interfaceAutomationScript
- Overrides:
stop
in classBaseAutomation
-