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.default boolean[]
readDiscreteInputs(short unitId, int startingAddress, int quantity)
Reads one or multiple discrete inputs.boolean[]
ReadDiscreteInputs(int startingAddress, int quantity)
Deprecated.default int[]
readHoldingRegisters(short unitId, int startingAddress, int quantity)
Reads one or multiple holding registers.int[]
ReadHoldingRegisters(int startingAddress, int quantity)
Deprecated.default int[]
readInputRegisters(short unitId, int startingAddress, int quantity)
Reads one or multiple input registers.int[]
ReadInputRegisters(int startingAddress, int quantity)
Deprecated.void
setUnitIdentifier(short unitId)
Deprecated.default void
writeMultipleCoils(short unitId, int startingAddress, boolean[] values)
Writes multiple coils.void
WriteMultipleCoils(int startingAdress, boolean[] values)
Deprecated.default void
writeMultipleRegisters(short unitId, int startingAddress, int[] values)
Writes multiple holding registers.void
WriteMultipleRegisters(int startingAdress, int[] values)
Deprecated.default void
writeSingleCoil(short unitId, int startingAddress, boolean value)
Writes a single coil.void
WriteSingleCoil(int startingAdress, boolean value)
Deprecated.default void
writeSingleRegister(short unitId, int startingAddress, int value)
Writes a single holding register.void
WriteSingleRegister(int startingAdress, int value)
Deprecated.
-
-
-
Method Detail
-
connect
boolean connect() throws GenDriverException
Connects to the Modbus interface.- Returns:
- true if connected, false otherwise
- Throws:
GenDriverException
- when connection failed
-
disconnect
void disconnect() throws GenDriverException
Disconnects 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 void setUnitIdentifier(short unitId)
Deprecated.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 int[] ReadInputRegisters(int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Reads one or multiple input registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadInputRegisters
instead.- 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 int[] ReadHoldingRegisters(int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Reads one or multiple holding registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadHoldingRegisters
instead.- 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 boolean[] ReadDiscreteInputs(int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Reads one or multiple discrete inputs. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadDiscreteInputs
instead.- 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 boolean[] ReadCoils(int startingAddress, int quantity) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Reads one or multiple coils. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsereadCoils
instead.- 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 void WriteMultipleCoils(int startingAdress, boolean[] values) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Writes multiple coils. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteMultipleCoils
instead.- 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 void WriteSingleCoil(int startingAdress, boolean value) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Writes a single coil. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteSingleCoil
instead.- 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 void WriteMultipleRegisters(int startingAdress, int[] values) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Writes multiple holding registers. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteMultipleRegisters
instead.- 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 void WriteSingleRegister(int startingAdress, int value) throws GenDriverException, GenDriverSocketException, GenDriverModbusException
Deprecated.Writes a single holding register. This method is deprecated, as the current implementation prefers sending the unit ID with each command. UsewriteSingleRegister
instead.- 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, GenDriverModbusException
Reads 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, GenDriverModbusException
Reads 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, GenDriverModbusException
Reads 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, GenDriverModbusException
Reads 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, GenDriverModbusException
Writes 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, GenDriverModbusException
Writes 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, GenDriverModbusException
Writes 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, GenDriverModbusException
Writes 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
-
-