public abstract class AbstractCycleWorker extends AbstractWorker
The business logic of the Worker is inside the forever()
method. It
is executed after triggered the AbstractWorker.triggerNextRun()
method.
This implementation is helpful to execute logic synchronized with the OpenEMS Edge Cycle. Be sure to call 'triggerNextCycle()' once per Cycle (using an OSGi EventHandler).
ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN, DO_NOT_WAIT
Constructor and Description |
---|
AbstractCycleWorker() |
Modifier and Type | Method and Description |
---|---|
void |
activate(java.lang.String name)
Initializes the worker and starts the worker thread
|
void |
deactivate()
Stops the worker thread
|
protected abstract void |
forever()
This method is called in a loop forever until the Thread gets interrupted.
|
protected int |
getCycleTime()
Gets the cycleTime of this worker in [ms].
|
triggerNextRun
public void activate(java.lang.String name)
AbstractWorker
activate
in class AbstractWorker
public void deactivate()
AbstractWorker
deactivate
in class AbstractWorker
protected final int getCycleTime()
AbstractWorker
getCycleTime
in class AbstractWorker
protected abstract void forever() throws java.lang.Throwable
AbstractWorker
forever
in class AbstractWorker
java.lang.Throwable