Class ModbusWorker
java.lang.Object
io.openems.common.worker.AbstractWorker
io.openems.common.worker.AbstractImmediateWorker
io.openems.edge.bridge.modbus.api.worker.ModbusWorker
The ModbusWorker schedules the execution of all Modbus-Tasks, like reading
and writing modbus registers.
It tries to execute all Write-Tasks as early as possible (directly after the
TOPIC_CYCLE_EXECUTE_WRITE event) and all Read-Tasks as late as possible to
have values available exactly when they are needed (i.e. at the
TOPIC_CYCLE_BEFORE_PROCESS_IMAGE event). For this it uses a
CycleTasksManager
that internally uses a TasksSupplierImpl
that supplies the tasks for one Cycle (CycleTasks
).
-
Field Summary
Fields inherited from class io.openems.common.worker.AbstractWorker
ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN, DO_NOT_WAIT, thread
-
Constructor Summary
ConstructorDescriptionModbusWorker
(Function<Task, Task.ExecuteState> execute, Consumer<ModbusElement[]> invalidate, Consumer<Boolean> cycleTimeIsTooShortChannel, Consumer<Long> cycleDelayChannel, AtomicReference<LogVerbosity> logVerbosity) Constructor forModbusWorker
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProtocol
(String sourceId, ModbusProtocol protocol) Adds the protocol.protected void
forever()
This method is called in a loop forever until the Thread gets interrupted.void
Called on BEFORE_PROCESS_IMAGE event.void
Called on EXECUTE_WRITE event.void
removeProtocol
(String sourceId) Removes the protocol.void
retryModbusCommunication
(String sourceId) Retry Modbus communication to given Component-ID.Methods inherited from class io.openems.common.worker.AbstractImmediateWorker
activate, deactivate, getCycleTime
Methods inherited from class io.openems.common.worker.AbstractWorker
activate, modified, modified, setPriority, triggerNextRun
-
Constructor Details
-
ModbusWorker
public ModbusWorker(Function<Task, Task.ExecuteState> execute, Consumer<ModbusElement[]> invalidate, Consumer<Boolean> cycleTimeIsTooShortChannel, Consumer<Long> cycleDelayChannel, AtomicReference<LogVerbosity> logVerbosity) Constructor forModbusWorker
.- Parameters:
execute
- executes aTask
; returns number of actually executed subtasksinvalidate
- invalidates the givenModbusElement
s after read errorscycleTimeIsTooShortChannel
- sets theBridgeModbus.ChannelId.CYCLE_TIME_IS_TOO_SHORT
channelcycleDelayChannel
- sets theBridgeModbus.ChannelId.CYCLE_DELAY
channellogVerbosity
- the configuredLogVerbosity
-
-
Method Details
-
forever
Description copied from class:AbstractWorker
This method is called in a loop forever until the Thread gets interrupted.- Specified by:
forever
in classAbstractImmediateWorker
- Throws:
InterruptedException
-
addProtocol
Adds the protocol.- Parameters:
sourceId
- Component-ID of the sourceprotocol
- the ModbusProtocol
-
removeProtocol
Removes the protocol.- Parameters:
sourceId
- Component-ID of the source
-
retryModbusCommunication
Retry Modbus communication to given Component-ID.- Parameters:
sourceId
- Component-ID of the source
-
onExecuteWrite
public void onExecuteWrite()Called on EXECUTE_WRITE event. -
onBeforeProcessImage
public void onBeforeProcessImage()Called on BEFORE_PROCESS_IMAGE event.
-