The QModbusReply class contains the data for a request sent with a QModbusClient derived class. 更多...
头: | #include <QModbusReply> |
qmake: | QT += serialbus |
Since: | Qt 5.8 |
继承: | QObject |
enum | ReplyType { Raw, Common } |
QModbusReply (ReplyType type , int serverAddress , QObject * parent = nullptr) | |
QModbusDevice::Error | error () const |
QString | errorString () const |
bool | isFinished () const |
QModbusResponse | rawResult () const |
QModbusDataUnit | result () const |
int | serverAddress () const |
ReplyType | type () const |
void | errorOccurred (QModbusDevice::Error error ) |
void | finished () |
The QModbusReply class contains the data for a request sent with a QModbusClient derived class.
This enum describes the possible reply type.
常量 | 值 | 描述 |
---|---|---|
QModbusReply::Raw
|
0
|
The reply originates from a raw Modbus request. See QModbusClient::sendRawRequest |
QModbusReply::Common
|
1
|
The reply originates from a common read, write or read/write request. See QModbusClient::sendReadRequest , QModbusClient::sendWriteRequest and QModbusClient::sendReadWriteRequest |
构造 QModbusReply object with a given type and the specified parent .
The reply will be send to the Modbus client represented by serverAddress .
Returns the error state of this reply.
[signal]
void
QModbusReply::
errorOccurred
(
QModbusDevice::Error
error
)
This signal is emitted when an error has been detected in the processing of this reply. The finished () signal will probably follow.
The error will be described by the error code error 。若 errorString is not empty it will contain a textual description of the error. In case of a QModbusDevice::ProtocolError the rawResult () function can be used to obtain the original Modbus exception response to get the exception code.
Note: Do not delete this reply object in the slot connected to this signal. Use deleteLater () 代替。
Returns the textual representation of the error state of this reply.
If no error has occurred this will return an empty string. It is possible that an error occurred which has no associated textual representation, in which case this will also return an empty string.
另请参阅 error () 和 errorOccurred ().
[signal]
void
QModbusReply::
finished
()
This signal is emitted when the reply has finished processing. The reply may still have returned with an error.
After this signal is emitted, there will be no more updates to the reply's data.
注意: 不要在槽中删除连接到此信号的对象。使用 deleteLater ().
还可以使用 isFinished () 去校验,若 QNetworkReply 已完成,甚至在收到 finish() 信号之前。
另请参阅 isFinished () 和 error ().
返回
true
当回复已完成或被中止。
Returns the raw response of a Modbus request.
If the request has not finished then the returned QModbusResponse instance is invalid.
Returns the preprocessed result of a Modbus request.
For read requests as well as combined read/write requests send via QModbusClient::sendReadWriteRequest () it contains the values read from the server instance.
If the request has not finished, has failed with an error or was a write request then the returned QModbusDataUnit instance is invalid.
注意: 若 type () of the reply is QModbusReply::Raw , the return value will always be invalid.
Returns the server address that this reply object targets.
Returns the type of the reply.
注意: If the type of the reply is QModbusReply::Raw , the return value of result () will always be invalid.