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>
  • Constructor Details

  • 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 class AbstractReadTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse,CoilElement,Boolean>
      Parameters:
      element - the ModbusElement
      position - the current position
      response - the converted ModbusResponse values
      Throws:
      OpenemsException - on error
    • calculateNextPosition

      protected int calculateNextPosition(ModbusElement modbusElement, int position)
      Description copied from class: AbstractReadTask
      Calculate the position of the next Element.
      Specified by:
      calculateNextPosition in class AbstractReadTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse,CoilElement,Boolean>
      Parameters:
      modbusElement - current Element
      position - current position
      Returns:
      next position
    • parseResponse

      protected final Boolean[] parseResponse(RESPONSE response)
      Description copied from class: AbstractReadTask
      Parses a ModbusResponse to an array of values.
      Specified by:
      parseResponse in class AbstractReadTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse,CoilElement,Boolean>
      Parameters:
      response - the ModbusResponse
      Returns:
      array of results
    • parseBitResponse

      protected abstract com.ghgande.j2mod.modbus.util.BitVector parseBitResponse(RESPONSE response)
    • toBooleanArray

      protected static Boolean[] toBooleanArray(com.ghgande.j2mod.modbus.util.BitVector v)
      Convert a BitVector to a Boolean array.
      Parameters:
      v - the BitVector
      Returns:
      the Boolean array
    • payloadToString

      protected final String payloadToString(RESPONSE response)
      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 class AbstractTask<REQUEST extends com.ghgande.j2mod.modbus.msg.ModbusRequest,RESPONSE extends com.ghgande.j2mod.modbus.msg.ModbusResponse>
      Parameters:
      response - the response
      Returns:
      a string