Interface ModbusFunction

All Known Implementing Classes:
ModbusFunctionCode, UserModbusFunction

public interface ModbusFunction
API for a Modbus function.

This API exists to support user-defined Modbus functions that are not defined in the specification.

  • Method Details

    • getCode

      byte getCode()
      Get the function code.
      Returns:
      the code
    • functionCode

      default ModbusFunctionCode functionCode()
      Get this function as a ModbusFunctionCode.
      Returns:
      the function code enumeration value, or null if cannot be represented as one
    • toDisplayString

      String toDisplayString()
      Get a friendly display string for this function.
      Returns:
      a display string
    • isReadFunction

      boolean isReadFunction()
      Return true if this function represents a read operation.
      Returns:
      true if this function represents a read operation, false if a write operation
    • oppositeFunction

      ModbusFunction oppositeFunction()
      Get an "opposite" function from this function.

      This method is used to get a read function for a given write function, and a write function for a given read function. Note that not all functions have exact opposites, such that:

       
       ModbusFunction a = myFunction();
       ModbusFunction b = a.oppositeFunction();
       ModbusFunction c = b.oppositeFunction();
       // at this stage c is not necessarily equal to a
       
       
      Returns:
      the function, or null if not applicable
    • blockType

      ModbusBlockType blockType()
      Get the register block type related to this function.
      Returns:
      the block type
    • hashCode

      int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      boolean equals(Object obj)
      Overrides:
      equals in class Object