Class WaitDelayHandler
java.lang.Object
io.openems.edge.bridge.modbus.api.worker.internal.WaitDelayHandler
-
Constructor Summary
ModifierConstructorDescriptionprotected
WaitDelayHandler
(com.google.common.base.Ticker ticker, Runnable onWaitDelayTaskFinished, Consumer<Long> cycleDelayChannel) protected
WaitDelayHandler
(Runnable onWaitDelayTaskFinished, Consumer<Long> cycleDelayChannel) -
Method Summary
Modifier and TypeMethodDescriptionprotected static WaitTask.Delay
generateWaitDelayTask
(Collection<Long> possibleDelays, Runnable onWaitDelayTaskFinished) Generates ainvalid reference
WaitDelayTask
Gets theWaitTask.Delay
.onBeforeProcessImage
(boolean traceLog) Called on BEFORE_PROCESS_IMAGE event.void
Called when waiting finished.void
Announce, that the Cycle measurement time is invalid.void
updateTotalNumberOfTasks
(int totalNumberOfTasks) Updates the size of the internalpossibleDelays
queue to the total number of tasks.
-
Constructor Details
-
WaitDelayHandler
-
WaitDelayHandler
-
-
Method Details
-
updateTotalNumberOfTasks
public void updateTotalNumberOfTasks(int totalNumberOfTasks) Updates the size of the internalpossibleDelays
queue to the total number of tasks.'possibleDelays' needs to 'learn' execution time of all tasks, so it is important to keep its size in sync with the total number of tasks.
- Parameters:
totalNumberOfTasks
- the total number of tasks
-
onBeforeProcessImage
Called on BEFORE_PROCESS_IMAGE event.- Parameters:
traceLog
- activate logging- Returns:
- if traceLog is active, return a detailed log info; empty string otherwise
-
timeIsInvalid
public void timeIsInvalid()Announce, that the Cycle measurement time is invalid.- WaitDelayTask will be set to 'zero-wait'
- Internal marker 'timeIsInvalid' is set. This causes the time measurement for this Cycle to be ignored
This method is called shortly after 'onBeforeProcessImage()'
-
onFinished
public void onFinished()Called when waiting finished. -
getWaitDelayTask
Gets theWaitTask.Delay
.- Returns:
- the task
-
generateWaitDelayTask
protected static WaitTask.Delay generateWaitDelayTask(Collection<Long> possibleDelays, Runnable onWaitDelayTaskFinished) Generates ainvalid reference
WaitDelayTask
BUFFER_MS
.- Parameters:
possibleDelays
- the collected possible delays of the last CyclesonWaitDelayTaskFinished
- callback on wait-delay finished- Returns:
- the
invalid reference
WaitDelayTask
-