Interface GenDriverAPI4Modbus
-
public interface GenDriverAPI4ModbusDefines the interface of a Modbus interface driver.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description booleanconnect()Connects to the Modbus interface.voiddisconnect()Disconnects from the Modbus interface.booleanisConnected()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.0default 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.0default 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.0default 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.0voidsetUnitIdentifier(short unitId)Deprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0default voidwriteMultipleCoils(short unitId, int startingAddress, boolean[] values)Writes multiple coils.voidWriteMultipleCoils(int startingAdress, boolean[] values)Deprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0default voidwriteMultipleRegisters(short unitId, int startingAddress, int[] values)Writes multiple holding registers.voidWriteMultipleRegisters(int startingAdress, int[] values)Deprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0default voidwriteSingleCoil(short unitId, int startingAddress, boolean value)Writes a single coil.voidWriteSingleCoil(int startingAdress, boolean value)Deprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0default voidwriteSingleRegister(short unitId, int startingAddress, int value)Writes a single holding register.voidWriteSingleRegister(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 GenDriverExceptionConnects to the Modbus interface.- Returns:
- true if connected, false otherwise
- Throws:
GenDriverException- when connection failed
-
disconnect
void disconnect() throws GenDriverExceptionDisconnects from the Modbus interface.- Throws:
GenDriverException- when an error occurred
-
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.0Sets 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, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Reads one or multiple input registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadInputRegistersinstead.- Parameters:
startingAddress- the first register address to readquantity- the number of registers to read- Returns:
- an array of integers
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
ReadHoldingRegisters
@Deprecated(since="2.2.0", forRemoval=true) int[] ReadHoldingRegisters(int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Reads one or multiple holding registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadHoldingRegistersinstead.- Parameters:
startingAddress- the first register address to readquantity- the number of registers to read- Returns:
- an array of integers
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
ReadDiscreteInputs
@Deprecated(since="2.2.0", forRemoval=true) boolean[] ReadDiscreteInputs(int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Reads one or multiple discrete inputs. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadDiscreteInputsinstead.- Parameters:
startingAddress- the first discrete input address to readquantity- the number of discrete inputs to read- Returns:
- an array of boolean
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
ReadCoils
@Deprecated(since="2.2.0", forRemoval=true) boolean[] ReadCoils(int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Reads one or multiple coils. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadCoilsinstead.- Parameters:
startingAddress- the first coil address to readquantity- the number of coils to read- Returns:
- an array of boolean
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
WriteMultipleCoils
@Deprecated(since="2.2.0", forRemoval=true) void WriteMultipleCoils(int startingAdress, boolean[] values) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Writes multiple coils. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteMultipleCoilsinstead.- Parameters:
startingAdress- the first coil address to writevalues- the array of coil values to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
WriteSingleCoil
@Deprecated(since="2.2.0", forRemoval=true) void WriteSingleCoil(int startingAdress, boolean value) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Writes a single coil. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteSingleCoilinstead.- Parameters:
startingAdress- the coil address to writevalue- the coil value to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
WriteMultipleRegisters
@Deprecated(since="2.2.0", forRemoval=true) void WriteMultipleRegisters(int startingAdress, int[] values) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Writes multiple holding registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteMultipleRegistersinstead.- Parameters:
startingAdress- the first register address to writevalues- the array of register values to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
WriteSingleRegister
@Deprecated(since="2.2.0", forRemoval=true) void WriteSingleRegister(int startingAdress, int value) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.2.0Writes a single holding register. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteSingleRegisterinstead.- Parameters:
startingAdress- the register address to writevalue- the register value to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
readInputRegisters
default int[] readInputRegisters(short unitId, int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionReads one or multiple input registers.- Parameters:
unitId- the unit identifierstartingAddress- the first register address to readquantity- the number of registers to read- Returns:
- an array of integers
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
readHoldingRegisters
default int[] readHoldingRegisters(short unitId, int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionReads one or multiple holding registers.- Parameters:
unitId- the unit identifierstartingAddress- the first register address to readquantity- the number of registers to read- Returns:
- an array of integers
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
readDiscreteInputs
default boolean[] readDiscreteInputs(short unitId, int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionReads one or multiple discrete inputs.- Parameters:
unitId- the unit identifierstartingAddress- the first discrete input address to readquantity- the number of discrete inputs to read- Returns:
- an array of boolean
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
readCoils
default boolean[] readCoils(short unitId, int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionReads one or multiple coils.- Parameters:
unitId- the unit identifierstartingAddress- the first coil address to readquantity- the number of coils to read- Returns:
- an array of boolean
- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
writeMultipleRegisters
default void writeMultipleRegisters(short unitId, int startingAddress, int[] values) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionWrites multiple holding registers.- Parameters:
unitId- the unit identifierstartingAddress- the first register address to writevalues- the array of register values to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
writeSingleRegister
default void writeSingleRegister(short unitId, int startingAddress, int value) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionWrites a single holding register.- Parameters:
unitId- the unit identifierstartingAddress- the register address to writevalue- the register value to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
writeMultipleCoils
default void writeMultipleCoils(short unitId, int startingAddress, boolean[] values) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionWrites multiple coils.- Parameters:
unitId- the unit identifierstartingAddress- the first coil address to writevalues- the array of coil values to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
writeSingleCoil
default void writeSingleCoil(short unitId, int startingAddress, boolean value) throws GenDriverException, GenDriverSocketException, GenDriverModbusExceptionWrites a single coil.- Parameters:
unitId- the unit identifierstartingAddress- the coil address to writevalue- the coil value to write- Throws:
GenDriverException- when a general error occurredGenDriverSocketException- when a network error occurredGenDriverModbusException- when a Modbus protocol error occurred
-
-