Package crackers.kobots.parts.movement
Class SequenceExecutor
-
- All Implemented Interfaces:
public abstract class SequenceExecutor
Handles running a sequence for a thing. Every sequence is executed on a background thread that runs until completion or until the stop method is called. Only one sequence can be running at a time (see the moveInProgress flag).
Default execution speeds are:
VERY_SLOW = 100ms
SLOW = 50ms
NORMAL = 10ms
FAST = 5ms
VERY_FAST = 2ms
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
SequenceExecutor.SequenceEvent
-
Field Summary
Fields Modifier and Type Field Description private final Boolean
moveInProgress
private final String
executorName
-
Constructor Summary
Constructors Constructor Description SequenceExecutor(String executorName, KobotsMQTT mqttClient)
-
Method Summary
Modifier and Type Method Description final Boolean
getMoveInProgress()
final String
getExecutorName()
Unit
stop()
Sets the stop flag and blocks until the flag is cleared. Unit
handleRequest(SequenceRequest request)
Handles a request. final Unit
does(ActionSequence actionSequence)
Unit
preExecution()
Optional callback for pre-execution. Unit
postExecution()
Optional callback for post-execution. Unit
updateCurrentState()
Optionally updates the state of the executor. -
-
Constructor Detail
-
SequenceExecutor
SequenceExecutor(String executorName, KobotsMQTT mqttClient)
- Parameters:
executorName
- the name of the executormqttClient
- the MQTT client for publishing events
-
-
Method Detail
-
getMoveInProgress
final Boolean getMoveInProgress()
-
getExecutorName
final String getExecutorName()
-
handleRequest
Unit handleRequest(SequenceRequest request)
Handles a request. If the request is a sequence, it is executed on a background thread.
This function is non-blocking.
-
does
final Unit does(ActionSequence actionSequence)
-
preExecution
Unit preExecution()
Optional callback for pre-execution.
-
postExecution
Unit postExecution()
Optional callback for post-execution.
-
updateCurrentState
Unit updateCurrentState()
Optionally updates the state of the executor.
-
-
-
-