QKnxNetIpServerDescriptionAgent Class

The QKnxNetIpServerDescriptionAgent class establishes a point-to-point connection with a KNXnet/IP server and requests its description. 更多...

头: #include <QKnxNetIpServerDescriptionAgent>
qmake: QT += knx
继承: QObject

公共类型

enum class Error { None, Network, NotIPv4, Timeout, Unknown }
enum class State { NotRunning, Starting, Running, Stopping }

公共函数

QKnxNetIpServerDescriptionAgent (const QHostAddress & localAddress , quint16 port , QObject * parent = nullptr)
QKnxNetIpServerDescriptionAgent (const QHostAddress & localAddress , QObject * parent = nullptr)
QKnxNetIpServerDescriptionAgent (QObject * parent = nullptr)
virtual ~QKnxNetIpServerDescriptionAgent ()
QKnxNetIpServerDescriptionAgent::Error error () const
QString errorString () const
QHostAddress localAddress () const
quint16 localPort () const
quint8 multicastTtl () const
bool natAware () const
QKnxNetIpServerInfo serverDescription () const
void setLocalAddress (const QHostAddress & address )
void setLocalPort (quint16 port )
void setMulticastTtl (quint8 ttl )
void setNatAware (bool useNat )
void setTimeout (int msec )
QKnxNetIpServerDescriptionAgent::State state () const
int timeout () const

公共槽

void start (const QHostAddress & address , quint16 port )
void start (const QKnxNetIpServerInfo & server )
void start (const QKnxNetIpHpai & server )
void stop ()

信号

void descriptionReceived (QKnxNetIpServerInfo server )
void errorOccurred (QKnxNetIpServerDescriptionAgent::Error error , QString errorString )
void finished ()
void started ()
void stateChanged (QKnxNetIpServerDescriptionAgent::State state )

详细描述

First, the QKnxNetIpServerDiscoveryAgent class is used to search the network for available KNXnet/IP devices. After successful discovery of such a device, the server needs to be chosen to fetch the description. This can be been done as illustrated by the following code snippet:

QKnxNetIpServerDescriptionAgent descriptionAgent;
QHostAddress clientLocalAddress = ...
descriptionAgent.setLocalAddress(clientLocalAddress);
auto server = discoveryAgent.discoveredServers()[0]; // for example
descriptionAgent.start(server);
					

When the description is received from the server, the descriptionReceived () signal is emitted. The description received through this point-to-point connection may be more complete than the one sent during discovery.

另请参阅 Qt KNXnet/IP Connection Classes .

成员类型文档编制

enum class QKnxNetIpServerDescriptionAgent:: Error

This enum value holds the type of an error that occurred.

常量 描述
QKnxNetIpServerDescriptionAgent::Error::None 0 No errors occurred.
QKnxNetIpServerDescriptionAgent::Error::Network 1 发生网络错误。
QKnxNetIpServerDescriptionAgent::Error::NotIPv4 2 The network protocol used is not IPv4.
QKnxNetIpServerDescriptionAgent::Error::Timeout 3 A timeout occurred while waiting for the description response.
QKnxNetIpServerDescriptionAgent::Error::Unknown 0x80 出现未知错误。

enum class QKnxNetIpServerDescriptionAgent:: State

This enum value holds the state of the description agent.

常量 描述
QKnxNetIpServerDescriptionAgent::State::NotRunning 0 The description agent is not running.
QKnxNetIpServerDescriptionAgent::State::Starting 1 The description agent is starting up.
QKnxNetIpServerDescriptionAgent::State::Running 2 The description agent is running.
QKnxNetIpServerDescriptionAgent::State::Stopping 3 The description agent is stopping.

成员函数文档编制

QKnxNetIpServerDescriptionAgent:: QKnxNetIpServerDescriptionAgent (const QHostAddress & localAddress , quint16 port , QObject * parent = nullptr)

Creates a KNXnet/IP server description agent with the host address localAddress , the port number port , and the parent parent .

注意: If the port number is already bound by a different process, description requests will fail.

QKnxNetIpServerDescriptionAgent:: QKnxNetIpServerDescriptionAgent (const QHostAddress & localAddress , QObject * parent = nullptr)

Creates a KNXnet/IP server description agent with the host address localAddress and the parent parent .

QKnxNetIpServerDescriptionAgent:: QKnxNetIpServerDescriptionAgent ( QObject * parent = nullptr)

Creates a KNXnet/IP server description agent with the parent parent .

[signal] void QKnxNetIpServerDescriptionAgent:: descriptionReceived ( QKnxNetIpServerInfo server )

This signal is emitted when the description of server is received.

[signal] void QKnxNetIpServerDescriptionAgent:: errorOccurred ( QKnxNetIpServerDescriptionAgent::Error error , QString errorString )

This signal is emitted when the error error with the message errorString 出现。

[signal] void QKnxNetIpServerDescriptionAgent:: finished ()

This signal is emitted when the description agent has finished.

[slot] void QKnxNetIpServerDescriptionAgent:: start (const QHostAddress & address , quint16 port )

Starts the server description agent at the host address address and port number port .

[slot] void QKnxNetIpServerDescriptionAgent:: start (const QKnxNetIpServerInfo & server )

Starts the server description agent server .

[slot] void QKnxNetIpServerDescriptionAgent:: start (const QKnxNetIpHpai & server )

Starts the server description agent server .

[signal] void QKnxNetIpServerDescriptionAgent:: started ()

This signal is emitted when the description agent starts.

[signal] void QKnxNetIpServerDescriptionAgent:: stateChanged ( QKnxNetIpServerDescriptionAgent::State state )

This signal is emitted when the state of the description agent changes to state .

[slot] void QKnxNetIpServerDescriptionAgent:: stop ()

Stops a server description agent.

[虚拟] QKnxNetIpServerDescriptionAgent:: ~QKnxNetIpServerDescriptionAgent ()

Deletes a KNXnet/IP server description agent.

QKnxNetIpServerDescriptionAgent::Error QKnxNetIpServerDescriptionAgent:: error () const

Returns the type of an error that occurred when receiving the server description.

QString QKnxNetIpServerDescriptionAgent:: errorString () const

Returns a human-readable string that describes an error.

QHostAddress QKnxNetIpServerDescriptionAgent:: localAddress () const

Returns the host address of a description agent.

另请参阅 setLocalAddress ().

quint16 QKnxNetIpServerDescriptionAgent:: localPort () const

Returns the port number used by a description agent.

另请参阅 setLocalPort ().

quint8 QKnxNetIpServerDescriptionAgent:: multicastTtl () const

Returns the time to live (TTL) used for multicast search response messages. TTL is the maximum number of IP routers that may route the message. Each IP router that the message passes decrements the TTL by one. When the TTL has reached zero, the message is discarded.

另请参阅 setMulticastTtl ().

bool QKnxNetIpServerDescriptionAgent:: natAware () const

返回 true if the server description agent uses network address translation (NAT).

另请参阅 setNatAware ().

QKnxNetIpServerInfo QKnxNetIpServerDescriptionAgent:: serverDescription () const

Returns a description of a server.

void QKnxNetIpServerDescriptionAgent:: setLocalAddress (const QHostAddress & address )

Sets the host address of a description agent to address .

注意: If the address changes during a description request, the new address will not be used until the next run.

另请参阅 localAddress ().

void QKnxNetIpServerDescriptionAgent:: setLocalPort ( quint16 port )

Sets the port number used by a description agent to port .

注意: If the port changes during a description request, the new port will not be used until the next run.

另请参阅 localPort ().

void QKnxNetIpServerDescriptionAgent:: setMulticastTtl ( quint8 ttl )

Sets the TTL used for multicasting to ttl 。值 1 means that the message does not leave the local network.

另请参阅 multicastTtl ().

void QKnxNetIpServerDescriptionAgent:: setNatAware ( bool useNat )

Sets whether the server description agent is using NAT to useNat .

注意: If the setting changes during a description request, it will not be used until the next run.

另请参阅 natAware ().

void QKnxNetIpServerDescriptionAgent:: setTimeout ( int msec )

Sets the timeout for the description agent to msec 。若 msec is -1 , the agent will not timeout and has to be terminated by calling the stop 函数。

另请参阅 timeout .

QKnxNetIpServerDescriptionAgent::State QKnxNetIpServerDescriptionAgent:: state () const

Returns the state of a KNXnet/IP server description agent.

int QKnxNetIpServerDescriptionAgent:: timeout () const

Returns the timeout value used by the description agent to wait for incoming search response messages. The default value is 3000 milliseconds.

另请参阅 setTimeout .