ServerDiscovery QML Type
利用可能なサーバーに関する情報を提供する。詳細...
| Import Statement: | import QtOpcUa |
| Since: | QtOpcUa 5.13 |
| Status: | Deprecated since 6.9 |
この型はQtOpcUa 6.9から非推奨となりました。新しいコードでは使用しないことを強くお勧めします。
プロパティ
- connection : Connection
- count : int
- discoveryUrl : string
- status : Status
方法
- ApplicationDescription at(index)
詳細説明
サーバーまたはディスカバリーサーバーが知っているサーバーに関する情報を取得し、アクセスできるようにする。
QtOpcUa.Connection { id: connection backend: availableBackends[0] defaultConnection: true } QtOpcUa.ServerDiscovery { discoveryUrl: "opc.tcp://127.0.0.1:43344" onServersChanged: { if (status.isGood) { if (status.status == QtOpcUa.Status.GoodCompletesAsynchronusly) return; // wait until finished if (count > 0) { // choose right server endpointDiscovery.serverUrl = at(0).discoveryUrls[0]; console.log("Using server URL:", endpointDiscovery.serverUrl); } else { // no servers retrieved } } else { // Fetching servers failed console.log("Error fetching server:", servers.status.status); } } } QtOpcUa.EndpointDiscovery { id: endpointDiscovery onEndpointsChanged: { if (status.isGood) { if (status.status == QtOpcUa.Status.GoodCompletesAsynchronusly) return; // wait until finished if (count > 0) { // choose right endpoint console.log("Using endpoint", at(0).endpointUrl, at(0).securityPolicy); connection.connectToEndpoint(at(0)); } else { // no endpoints retrieved } } else { // Fetching endpoints failed console.log("Error fetching endpoints:", status.status); } } }
プロパティの説明
connection : Connection
情報のリクエストに使用する接続。
このプロパティが設定されていない場合、デフォルトの接続が使用されます。
Connection およびConnection::defaultConnectionも参照してください 。
count : int
このエレメント内の現在のサーバー数。このサーバー発見からのデータを使用する前に、情報の取得が成功したかどうかをstatus 確認する必要があります。
discoveryUrl : string
サーバ一覧を取得するサーバのURL。URLが変更されるたびに、指定されたサーバーへのリクエストが開始される。
リクエストを開始すると、利用可能なサーバーのリストはクリアされ、 ステータスはStatus.GoodCompletesAsynchronously に設定される。リクエストが終了すると、status が変更される。サーバーのリストにアクセスする前に、必ずstatus を確認してください。
onServersChanged: {
if (status.isGood) {
if (status.status == QtOpcUa.Status.GoodCompletesAsynchronusly)
return; // wait until finished
if (count > 0) {
var serverUrl = at(0).serverUrl();
console.log(serverUrl);
}
} else {
// handle error
}
}ApplicationDescription 、status 、at 、count 、Statusも参照のこと 。
status : Status
この要素の現在のステータス。最後にサーバーの取得に成功した場合、ステータスはStatus.Good となります。
if (status.isGood) { // Choose endpoint to connect to } else { // handle error }
Statusも参照して ください。
メソッドのドキュメント
ApplicationDescription at(index)
指定されたindex にあるアプリケーションの説明を返します。利用可能なサーバーがない場合、またはインデックスが無効な場合は、無効なアプリケーション記述が返されます。返されたデータを使用する前に、情報の取得が成功したかどうかをstatus で確認する必要があります。
if (servers.status.isGood) { if (servers.count > 0) var serverUrl = at(0).serverUrl(); console.log(serverUrl); // Choose endpoint to connect to } else { // handle error }
count 、status 、およびApplicationDescriptionも参照して ください。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.