|
jamod at SF | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.wimpi.modbus.msg.ModbusMessageImpl
Abstract class implementing a ModbusMessage. This class provides specialised implementations with the functionality they have in common.
Constructor Summary | |
ModbusMessageImpl()
|
Method Summary | |
int |
getDataLength()
Returns the length of the data appended after the protocol header. |
int |
getFunctionCode()
Returns the function code of this ModbusMessage as int. |
java.lang.String |
getHexMessage()
Returns the this message as hexadecimal string. |
int |
getOutputLength()
Returns the number of bytes that will be written by writeTo(DataOutput) . |
int |
getProtocolID()
Returns the protocol identifier of this ModbusMessage as int. |
int |
getTransactionID()
Returns the transaction identifier of this ModbusMessage as int. |
int |
getUnitID()
Returns the unit identifier of this ModbusMessage as int. |
boolean |
isHeadless()
Tests if this message instance is headless. |
abstract void |
readData(java.io.DataInput din)
Reads the subclass specific data from the given DataInput instance. |
void |
readFrom(java.io.DataInput din)
Reads this Transportable from the given DataInput. |
void |
setDataLength(int length)
Sets the length of the data appended after the protocol header. |
protected void |
setFunctionCode(int code)
Sets the function code of this ModbusMessage. |
void |
setHeadless()
Sets the flag that marks this ModbusMessage as headless (for serial transport). |
protected void |
setHeadless(boolean b)
Sets the headless flag of this message. |
void |
setProtocolID(int pid)
Sets the protocol identifier of this ModbusMessage. |
void |
setTransactionID(int tid)
Sets the transaction identifier of this ModbusMessage. |
void |
setUnitID(int num)
Sets the unit identifier of this ModbusMessage. |
abstract void |
writeData(java.io.DataOutput dout)
Writes the subclass specific data to the given DataOutput. |
void |
writeTo(java.io.DataOutput dout)
Writes this message to the given DataOutput. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ModbusMessageImpl()
Method Detail |
public boolean isHeadless()
public void setHeadless()
ModbusMessage
setHeadless
in interface ModbusMessage
protected void setHeadless(boolean b)
b
- true if headless, false otherwise.public int getTransactionID()
ModbusMessage
getTransactionID
in interface ModbusMessage
public void setTransactionID(int tid)
The identifier should be a 2-byte (short) non negative
integer value valid in the range of 0-65535.
tid
- the transaction identifier as int.public int getProtocolID()
ModbusMessage
getProtocolID
in interface ModbusMessage
public void setProtocolID(int pid)
The identifier should be a 2-byte (short) non negative
integer value valid in the range of 0-65535.
pid
- the protocol identifier as int.public int getDataLength()
ModbusMessage
getDataLength
in interface ModbusMessage
public void setDataLength(int length)
Note that this library, a bit in contrast to the specification, counts the unit identifier and the function code to the header, because it is part of each and every message. Thus this message will append two (2) to the passed in integer value.
length
- the data length as int.public int getUnitID()
ModbusMessage
getUnitID
in interface ModbusMessage
public void setUnitID(int num)
num
- the unit identifier number to be set.public int getFunctionCode()
ModbusMessage
getFunctionCode
in interface ModbusMessage
Modbus
protected void setFunctionCode(int code)
code
- the code of the function to be set.Modbus
public void writeTo(java.io.DataOutput dout) throws java.io.IOException
writeTo
in interface Transportable
dout
- a DataOutput instance.
java.io.IOException
- if an I/O related error occurs.public abstract void writeData(java.io.DataOutput dout) throws java.io.IOException
dout
- the DataOutput to be written to.
java.io.IOException
- if an I/O related error occurs.public void readFrom(java.io.DataInput din) throws java.io.IOException
Transportable
readFrom
in interface Transportable
din
- the DataInput to read from.
java.io.IOException
- if an I/O error occurs or the data
is invalid.public abstract void readData(java.io.DataInput din) throws java.io.IOException
din
- the DataInput to read from.
java.io.IOException
- if an I/O related error occurs.public int getOutputLength()
Transportable
Transportable.writeTo(DataOutput)
.
getOutputLength
in interface Transportable
public java.lang.String getHexMessage()
getHexMessage
in interface ModbusMessage
|
jamod at SF | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |