Interface GenDriverAPI4Modbus


  • public interface GenDriverAPI4Modbus
    Defines the interface of a Modbus interface driver.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean connect()
      Connects to the Modbus interface.
      void disconnect()
      Disconnects from the Modbus interface.
      boolean isConnected()
      Tells if the Modbus interface is connected.
      default boolean[] readCoils​(short unitId, int startingAddress, int quantity)
      Reads one or multiple coils.
      boolean[] ReadCoils​(int startingAddress, int quantity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      default boolean[] readDiscreteInputs​(short unitId, int startingAddress, int quantity)
      Reads one or multiple discrete inputs.
      boolean[] ReadDiscreteInputs​(int startingAddress, int quantity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      default int[] readHoldingRegisters​(short unitId, int startingAddress, int quantity)
      Reads one or multiple holding registers.
      int[] ReadHoldingRegisters​(int startingAddress, int quantity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      default int[] readInputRegisters​(short unitId, int startingAddress, int quantity)
      Reads one or multiple input registers.
      int[] ReadInputRegisters​(int startingAddress, int quantity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      void setUnitIdentifier​(short unitId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      default void writeMultipleCoils​(short unitId, int startingAddress, boolean[] values)
      Writes multiple coils.
      void WriteMultipleCoils​(int startingAdress, boolean[] values)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      default void writeMultipleRegisters​(short unitId, int startingAddress, int[] values)
      Writes multiple holding registers.
      void WriteMultipleRegisters​(int startingAdress, int[] values)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      default void writeSingleCoil​(short unitId, int startingAddress, boolean value)
      Writes a single coil.
      void WriteSingleCoil​(int startingAdress, boolean value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
      default void writeSingleRegister​(short unitId, int startingAddress, int value)
      Writes a single holding register.
      void WriteSingleRegister​(int startingAdress, int value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since version 2.2.0
    • Method Detail

      • connect

        boolean connect()
                 throws GenDriverException
        Connects to the Modbus interface.
        Returns:
        true if connected, false otherwise
        Throws:
        GenDriverException - when connection failed
      • isConnected

        boolean isConnected()
        Tells if the Modbus interface is connected.
        Returns:
        true if connected, false otherwise
      • setUnitIdentifier

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        void setUnitIdentifier​(short unitId)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Sets the Modbus unit identifier / slave ID for future commands. This method is deprecated, as the current implementation prefers sending the unit ID with each command.
        Parameters:
        unitId - the new unit ID
      • ReadInputRegisters

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        int[] ReadInputRegisters​(int startingAddress,
                                 int quantity)
                          throws GenDriverException,
                                 GenDriverSocketException,
                                 GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Reads one or multiple input registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use readInputRegisters instead.
        Parameters:
        startingAddress - the first register address to read
        quantity - the number of registers to read
        Returns:
        an array of integers
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred
      • ReadHoldingRegisters

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        int[] ReadHoldingRegisters​(int startingAddress,
                                   int quantity)
                            throws GenDriverException,
                                   GenDriverSocketException,
                                   GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Reads one or multiple holding registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use readHoldingRegisters instead.
        Parameters:
        startingAddress - the first register address to read
        quantity - the number of registers to read
        Returns:
        an array of integers
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred
      • ReadDiscreteInputs

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        boolean[] ReadDiscreteInputs​(int startingAddress,
                                     int quantity)
                              throws GenDriverException,
                                     GenDriverSocketException,
                                     GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Reads one or multiple discrete inputs. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use readDiscreteInputs instead.
        Parameters:
        startingAddress - the first discrete input address to read
        quantity - the number of discrete inputs to read
        Returns:
        an array of boolean
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred
      • ReadCoils

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        boolean[] ReadCoils​(int startingAddress,
                            int quantity)
                     throws GenDriverException,
                            GenDriverSocketException,
                            GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Reads one or multiple coils. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use readCoils instead.
        Parameters:
        startingAddress - the first coil address to read
        quantity - the number of coils to read
        Returns:
        an array of boolean
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred
      • WriteMultipleCoils

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        void WriteMultipleCoils​(int startingAdress,
                                boolean[] values)
                         throws GenDriverException,
                                GenDriverSocketException,
                                GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Writes multiple coils. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use writeMultipleCoils instead.
        Parameters:
        startingAdress - the first coil address to write
        values - the array of coil values to write
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred
      • WriteSingleCoil

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        void WriteSingleCoil​(int startingAdress,
                             boolean value)
                      throws GenDriverException,
                             GenDriverSocketException,
                             GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Writes a single coil. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use writeSingleCoil instead.
        Parameters:
        startingAdress - the coil address to write
        value - the coil value to write
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred
      • WriteMultipleRegisters

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        void WriteMultipleRegisters​(int startingAdress,
                                    int[] values)
                             throws GenDriverException,
                                    GenDriverSocketException,
                                    GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Writes multiple holding registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use writeMultipleRegisters instead.
        Parameters:
        startingAdress - the first register address to write
        values - the array of register values to write
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred
      • WriteSingleRegister

        @Deprecated(since="2.2.0",
                    forRemoval=true)
        void WriteSingleRegister​(int startingAdress,
                                 int value)
                          throws GenDriverException,
                                 GenDriverSocketException,
                                 GenDriverModbusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since version 2.2.0
        Writes a single holding register. This method is deprecated, as the current implementation prefers sending the unit ID with each command. Use writeSingleRegister instead.
        Parameters:
        startingAdress - the register address to write
        value - the register value to write
        Throws:
        GenDriverException - when a general error occurred
        GenDriverSocketException - when a network error occurred
        GenDriverModbusException - when a Modbus protocol error occurred