Class AbstractReadDigitalInputsTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse>
java.lang.Object
io.openems.edge.bridge.modbus.api.task.AbstractTask<REQUEST,RESPONSE>
io.openems.edge.bridge.modbus.api.task.AbstractReadTask<REQUEST,RESPONSE,CoilElement,Boolean>
io.openems.edge.bridge.modbus.api.task.AbstractReadDigitalInputsTask<REQUEST,RESPONSE>
- All Implemented Interfaces:
ReadTask
,Task
,ManagedTask
- Direct Known Subclasses:
FC1ReadCoilsTask
,FC2ReadInputsTask
public abstract class AbstractReadDigitalInputsTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse>
extends AbstractReadTask<REQUEST,RESPONSE,CoilElement,Boolean>
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.openems.edge.bridge.modbus.api.task.Task
Task.ExecuteState
-
Field Summary
Fields inherited from class io.openems.edge.bridge.modbus.api.task.AbstractTask
elements, length, name, onExecute, responseClazz, startAddress
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractReadDigitalInputsTask
(String name, Consumer<Task.ExecuteState> onExecute, Class<RESPONSE> responseClazz, int startAddress, Priority priority, CoilElement... elements) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
calculateNextPosition
(ModbusElement modbusElement, int position) Calculate the position of the next Element.protected void
handleResponse
(CoilElement element, int position, Boolean[] response) Handle a Response, e.g.protected abstract com.ghgande.j2mod.modbus.util.BitVector
parseBitResponse
(RESPONSE response) protected final Boolean[]
parseResponse
(RESPONSE response) Parses aModbusResponse
to an array of values.protected final String
payloadToString
(RESPONSE response) Converts the actual payload of the RESPONSE to a human readable format suitable for logs; without header data (like Unit-ID, function code, checksum, etc).protected static Boolean[]
toBooleanArray
(com.ghgande.j2mod.modbus.util.BitVector v) Convert aBitVector
to aBoolean
array.Methods inherited from class io.openems.edge.bridge.modbus.api.task.AbstractReadTask
createModbusRequest, execute, getPriority, payloadToString
Methods inherited from class io.openems.edge.bridge.modbus.api.task.AbstractTask
deactivate, debug, executeRequest, getElements, getLength, getLogVerbosity, getParent, getStartAddress, logError, logInfo, logRequest, setParent, toLogMessage, toLogMessage, toLogMessage, toLogMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.openems.edge.bridge.modbus.api.task.Task
deactivate, getElements, getLength, getParent, getStartAddress, setParent
-
Constructor Details
-
AbstractReadDigitalInputsTask
public AbstractReadDigitalInputsTask(String name, Consumer<Task.ExecuteState> onExecute, Class<RESPONSE> responseClazz, int startAddress, Priority priority, CoilElement... elements)
-
-
Method Details
-
handleResponse
protected void handleResponse(CoilElement element, int position, Boolean[] response) throws OpenemsException Description copied from class:AbstractReadTask
Handle a Response, e.g. set the internal value.- Specified by:
handleResponse
in classAbstractReadTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,
RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse, CoilElement, Boolean> - Parameters:
element
- theModbusElement
position
- the current positionresponse
- the convertedModbusResponse
values- Throws:
OpenemsException
- on error
-
calculateNextPosition
Description copied from class:AbstractReadTask
Calculate the position of the next Element.- Specified by:
calculateNextPosition
in classAbstractReadTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,
RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse, CoilElement, Boolean> - Parameters:
modbusElement
- current Elementposition
- current position- Returns:
- next position
-
parseResponse
Description copied from class:AbstractReadTask
Parses aModbusResponse
to an array of values.- Specified by:
parseResponse
in classAbstractReadTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,
RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse, CoilElement, Boolean> - Parameters:
response
- theModbusResponse
- Returns:
- array of results
-
parseBitResponse
-
toBooleanArray
Convert aBitVector
to aBoolean
array.- Parameters:
v
- theBitVector
- Returns:
- the
Boolean
array
-
payloadToString
Description copied from class:AbstractTask
Converts the actual payload of the RESPONSE to a human readable format suitable for logs; without header data (like Unit-ID, function code, checksum, etc).- Specified by:
payloadToString
in classAbstractTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,
RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse> - Parameters:
response
- the response- Returns:
- a string
-