public interface ModbusProtocolDeviceService
Function codes implemented are :
Modifier and Type | Field and Description |
---|---|
static String |
SERVICE_NAME
name of this service
|
Modifier and Type | Method and Description |
---|---|
void |
configureConnection(Properties connectionConfig)
Configure access to the physical device.
|
void |
connect()
attempt to connect to the field device using the provided configuration.
|
void |
disconnect()
attempt to disconnect from the field device.
|
ModbusCommEvent |
getCommEventCounter(int unitAddr)
Modbus function 11 (0x0B)
Get a status word and an event count from the device. Return values in a ModbusCommEvent. |
ModbusCommEvent |
getCommEventLog(int unitAddr)
Modbus function 12 (0x0C)
Get a status word, an event count, a message count and a list of event bytes from the device. Return values in a ModbusCommEvent. |
int |
getConnectStatus()
for expedience, can test the status of the connection prior to attempting
a command.
|
String |
getProtocolName()
returns the protocol name for the specific protocol implemented.
|
boolean[] |
readCoils(int unitAddr,
int dataAddress,
int count)
Modbus function 01
Read 1 to 2000 contiguous status of coils from the attached field device. |
boolean[] |
readDiscreteInputs(int unitAddr,
int dataAddress,
int count)
Modbus function 02
Read 1 to 2000 contiguous status of discrete inputs from the attached field device. |
boolean[] |
readExceptionStatus(int unitAddr)
Modbus function 07
read the content of 8 Exception Status outputs in the field device. |
int[] |
readHoldingRegisters(int unitAddr,
int dataAddress,
int count)
Modbus function 03
Read contents of 1 to 125 contiguous block of holding registers from the attached field device. |
int[] |
readInputRegisters(int unitAddr,
int dataAddress,
int count)
Modbus function 04
Read contents of 1 to 125 contiguous block of input registers from the attached field device. |
String |
toString()
returns the unit name given in the configureProtocol call.
|
void |
writeMultipleCoils(int unitAddr,
int dataAddress,
boolean[] data)
Modbus function 15 (0x0F)
write multiple coils in a sequence of coils to either ON or OFF in the attached field device. |
void |
writeMultipleRegister(int unitAddr,
int dataAddress,
int[] data)
Modbus function 16 (0x10)
write a block of contiguous registers (1 to 123) in the attached field device. |
void |
writeSingleCoil(int unitAddr,
int dataAddress,
boolean data)
Modbus function 05
write a single output to either ON or OFF in the attached field device. |
void |
writeSingleRegister(int unitAddr,
int dataAddress,
int data)
Modbus function 06
write a single holding register in the attached field device. |
static final String SERVICE_NAME
String toString()
toString
in class Object
Object.toString()
String getProtocolName()
void configureConnection(Properties connectionConfig) throws ModbusProtocolException
connectionConfig
- (key/value pairing directly from configuration file)ModbusProtocolException(INVALID_CONFIGURATION)
- unspecified problem with the configurationModbusProtocolException
int getConnectStatus()
All protocols must implement this method.
KuraConnectionStatus
.void connect() throws ModbusProtocolException
Refer to getConnectStatus
to determine if the
connection is completed.
All protocols must implement this method.
ModbusProtocolException(INVALID_CONFIGURATION)
- this operates on the basic assumption that access to a device
should exist, if the device is unreachable, it is interpreted
as a failure of the configuration.ModbusProtocolException
void disconnect() throws ModbusProtocolException
All protocols must implement this method.
ModbusProtocolException
getConnectStatus()
boolean[] readCoils(int unitAddr, int dataAddress, int count) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- starting addresscount
- quantity of coilsModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
boolean[] readDiscreteInputs(int unitAddr, int dataAddress, int count) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- starting addresscount
- quantity of inputsModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
void writeSingleCoil(int unitAddr, int dataAddress, boolean data) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- Output address.data
- Output value (boolean) to write.ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
void writeMultipleCoils(int unitAddr, int dataAddress, boolean[] data) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- Starting Output address.data
- Outputs value (array of boolean) to write.ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
int[] readHoldingRegisters(int unitAddr, int dataAddress, int count) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- starting addresscount
- quantity of registers (maximum 0x7D)ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
int[] readInputRegisters(int unitAddr, int dataAddress, int count) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- starting addresscount
- quantity of registers (maximum 0x7D)ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
void writeSingleRegister(int unitAddr, int dataAddress, int data) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- Output address.data
- Output value (2 bytes) to write.ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
boolean[] readExceptionStatus(int unitAddr) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
ModbusCommEvent getCommEventCounter(int unitAddr) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
ModbusCommEvent getCommEventLog(int unitAddr) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
void writeMultipleRegister(int unitAddr, int dataAddress, int[] data) throws ModbusProtocolException
unitAddr
- modbus slave address (must be unique in the range 1 - 247)dataAddress
- Output address.data
- Registers value (array of int converted in 2 bytes values) to write.ModbusProtocolException(NOT_CONNECTED)
- current connection is in a status other than CONNECTEDModbusProtocolException(TRANSACTION_FAILURE)
- should include a protocol specific message to help clarify
the cause of the exceptionModbusProtocolException
Copyright © 2014. All Rights Reserved.