Enum ModbusFunctionCode

java.lang.Object
java.lang.Enum<ModbusFunctionCode>
net.solarnetwork.io.modbus.ModbusFunctionCode
All Implemented Interfaces:
Serializable, Comparable<ModbusFunctionCode>, java.lang.constant.Constable, ModbusFunction

public enum ModbusFunctionCode extends Enum<ModbusFunctionCode> implements ModbusFunction
Modbus function codes.
  • Enum Constant Details

    • ReadCoils

      public static final ModbusFunctionCode ReadCoils
      Read coil.
    • WriteCoil

      public static final ModbusFunctionCode WriteCoil
      Write a coil.
    • WriteCoils

      public static final ModbusFunctionCode WriteCoils
      Write multiple coils.
    • ReadDiscreteInputs

      public static final ModbusFunctionCode ReadDiscreteInputs
      Read discreet input.
    • ReadInputRegisters

      public static final ModbusFunctionCode ReadInputRegisters
      Read input registers.
    • ReadHoldingRegisters

      public static final ModbusFunctionCode ReadHoldingRegisters
      Read holding registers.
    • WriteHoldingRegister

      public static final ModbusFunctionCode WriteHoldingRegister
      Write a holding register.
    • WriteHoldingRegisters

      public static final ModbusFunctionCode WriteHoldingRegisters
      Write multiple holding registers.
    • ReadWriteHoldingRegisters

      public static final ModbusFunctionCode ReadWriteHoldingRegisters
      Write then read multiple holding registers.
    • MaskWriteHoldingRegister

      public static final ModbusFunctionCode MaskWriteHoldingRegister
      Mask write a holding register.
    • ReadFifoQueue

      public static final ModbusFunctionCode ReadFifoQueue
      Read FIFO queue.
    • ReadFileRecord

      public static final ModbusFunctionCode ReadFileRecord
      Read file record.
    • WriteFileRecord

      public static final ModbusFunctionCode WriteFileRecord
      Write file record.
    • ReadExceptionStatus

      public static final ModbusFunctionCode ReadExceptionStatus
      Read exception status.
    • Diagnostics

      public static final ModbusFunctionCode Diagnostics
      Diagnostics info.
    • GetCommEventCounter

      public static final ModbusFunctionCode GetCommEventCounter
      Get the communication event counter.
    • GetCommEventLog

      public static final ModbusFunctionCode GetCommEventLog
      The the communication event log.
    • ReportServerId

      public static final ModbusFunctionCode ReportServerId
      Get the report server ID.
    • EncapsulatedInterfaceTransport

      public static final ModbusFunctionCode EncapsulatedInterfaceTransport
      Encapsulated interface transport (read device identification).
  • Field Details

  • Method Details

    • values

      public static ModbusFunctionCode[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ModbusFunctionCode valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getCode

      public byte getCode()
      Description copied from interface: ModbusFunction
      Get the function code.
      Specified by:
      getCode in interface ModbusFunction
      Returns:
      the code
    • functionCode

      public ModbusFunctionCode functionCode()
      Description copied from interface: ModbusFunction
      Get this function as a ModbusFunctionCode.
      Specified by:
      functionCode in interface ModbusFunction
      Returns:
      the function code enumeration value, or null if cannot be represented as one
    • toDisplayString

      public String toDisplayString()
      Description copied from interface: ModbusFunction
      Get a friendly display string for this function.
      Specified by:
      toDisplayString in interface ModbusFunction
      Returns:
      a display string
    • isReadFunction

      public boolean isReadFunction()
      Description copied from interface: ModbusFunction
      Return true if this function represents a read operation.
      Specified by:
      isReadFunction in interface ModbusFunction
      Returns:
      true if this function represents a read operation, false if a write operation
    • oppositeFunction

      public ModbusFunctionCode oppositeFunction()
      Description copied from interface: ModbusFunction
      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
       
       
      Specified by:
      oppositeFunction in interface ModbusFunction
      Returns:
      the function, or null if not applicable
    • blockType

      public ModbusBlockType blockType()
      Description copied from interface: ModbusFunction
      Get the register block type related to this function.
      Specified by:
      blockType in interface ModbusFunction
      Returns:
      the block type
    • valueOf

      public static ModbusFunction valueOf(byte code)
      Get a function instance for a code value.

      Error values will be handled to return the non-error function code equivalent value.

      Parameters:
      code - the code
      Returns:
      the function instance; may be an enumeration value of a user-defined custom function instance
    • forCode

      public static ModbusFunctionCode forCode(byte code)
      Get an enum instance for a code value.

      Error values will be handled to return the non-error function code equivalent value.

      Parameters:
      code - the code
      Returns:
      the enum
      Throws:
      IllegalArgumentException - if code is not a valid value