|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.wimpi.modbus.facade.ModbusSerialMaster
public class ModbusSerialMaster
Modbus/Serial Master facade.
Constructor Summary | |
---|---|
ModbusSerialMaster(SerialParameters param)
Constructs a new master facade instance for communication with a given slave. |
Method Summary | |
---|---|
void |
connect()
Connects this ModbusSerialMaster with the slave. |
void |
disconnect()
Disconnects this ModbusSerialMaster from the slave. |
int |
getUnitIdentifier()
Returns the unit identifier of this ModbusSerialMaster. |
BitVector |
readCoils(int unitid,
int ref,
int count)
Reads a given number of coil states from the slave. |
BitVector |
readInputDiscretes(int unitid,
int ref,
int count)
Reads a given number of input discrete states from the slave. |
InputRegister[] |
readInputRegisters(int unitid,
int ref,
int count)
Reads a given number of input registers from the slave. |
Register[] |
readMultipleRegisters(int unitid,
int ref,
int count)
Reads a given number of registers from the slave. |
void |
setUnitIdentifier(int unitid)
Sets the unit identifier of this ModbusSerialMaster. |
boolean |
writeCoil(int unitid,
int ref,
boolean state)
Writes a coil state to the slave. |
void |
writeMultipleCoils(int unitid,
int ref,
BitVector coils)
Writes a given number of coil states to the slave. |
void |
writeMultipleRegisters(int unitid,
int ref,
Register[] registers)
Writes a number of registers to the slave. |
void |
writeSingleRegister(int unitid,
int ref,
Register register)
Writes a single register to the slave. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ModbusSerialMaster(SerialParameters param)
param
- SerialParameters specifies the serial port parameters to use
to communicate with the slave device network.Method Detail |
---|
public void setUnitIdentifier(int unitid)
unitid
- the unit identifier.public int getUnitIdentifier()
public void connect() throws Exception
Exception
- if the connection cannot be established.public void disconnect()
public BitVector readCoils(int unitid, int ref, int count) throws ModbusException
unitid
- (IN) the slave unit id.ref
- the offset of the coil to start reading from.count
- the number of coil states to be read.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.public boolean writeCoil(int unitid, int ref, boolean state) throws ModbusException
unitid
- the slave unit id.ref
- the offset of the coil to be written.state
- the coil state to be written.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.public void writeMultipleCoils(int unitid, int ref, BitVector coils) throws ModbusException
BitVector.size()
.
unitid
- the slave unit id.ref
- the offset of the coil to start writing to.coils
- a BitVector which holds the coil states to be written.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.public BitVector readInputDiscretes(int unitid, int ref, int count) throws ModbusException
unitid
- the slave unit id.ref
- the offset of the input discrete to start reading from.count
- the number of input discrete states to be read.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.public InputRegister[] readInputRegisters(int unitid, int ref, int count) throws ModbusException
unitid
- the slave unit id.ref
- the offset of the input register to start reading from.count
- the number of input registers to be read.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.public Register[] readMultipleRegisters(int unitid, int ref, int count) throws ModbusException
unitid
- the slave unit id.ref
- the offset of the register to start reading from.count
- the number of registers to be read.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.public void writeSingleRegister(int unitid, int ref, Register register) throws ModbusException
unitid
- the slave unit id.ref
- the offset of the register to be written.register
- a Register holding the value of the register
to be written.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.public void writeMultipleRegisters(int unitid, int ref, Register[] registers) throws ModbusException
unitid
- the slave unit id.ref
- the offset of the register to start writing to.registers
- a Register[] holding the values of
the registers to be written.
ModbusException
- if an I/O error, a slave exception or
a transaction error occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |