EndpointDiscovery QML Type
サーバー上で利用可能なエンドポイントに関する情報を提供します。詳細...
Import Statement: | import QtOpcUa |
Since: | QtOpcUa 5.13 |
プロパティ
- connection : Connection
- count : int
- serverUrl : string
- status : Status
信号
方法
- EndpointDescription 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 |
serverUrl : string |
エンドポイントを取得するサーバーのディスカバリーURL。URL が変更されるたびに、指定されたサーバーへのリクエストが開始されます。
リクエストを開始すると、利用可能なエンドポイントのリストはクリアされ、ステータスはStatus.GoodCompletesAsynchronously に設定されます。リクエストが終了すると、status が変更されます。
エンドポイントのリストにアクセスする前に、必ずstatus を確認してください。
endpointsChangedも参照してください 。
status : Status |
この要素の現在のステータス。最後にエンドポイントの検索に成功した場合、ステータスはStatus.Good になります。
if (endpoints.status.isGood) { // do something } else { // handle error }
Status も参照して ください。
シグナル ドキュメント
endpointsChanged() |
検索要求が開始、終了、失敗したときに発行されます。呼び出された関数では、まずオブジェクトのstatus をチェックする必要があります。ステータスがStatus.GoodCompletesAsynchronously の場合、リクエストはまだ実行中です。ステータスがStatus.Good の場合、リクエストは終了し、エンドポイントの記述を読み取ることができます。ステータスが良くない場合、エラーが発生し、status にエラーコードが返されます。
onEndpointsChanged: { if (endpoints.status.isGood) { if (endpoints.status.status == QtOpcua.Status.GoodCompletesAsynchronusly) return; // wait until finished if (endpoints.count > 0) { var endpointUrl = endpoints.at(0).endpointUrl(); console.log(endpointUrl); } } else { // handle error } }
注意: 対応するハンドラはonEndpointsChanged
です。
status 、count 、at 、Status 、EndpointDescriptionも参照 。
メソッド・ドキュメント
EndpointDescription at(index) |
与えられたindex におけるエンドポイントの説明を返します。利用可能なエンドポイントがない場合やインデックスが無効な場合は、無効なエンドポイントの説明が返されます。このデータを使用する前に、情報の取得が成功したかどうかをstatus で確認する必要があります。
if (endpoints.status.isGood) { if (endpoints.count > 0) var endpointUrl = endpoints.at(0).endpointUrl(); console.log(endpointUrl); } else { // handle error }
count 、status 、EndpointDescriptionも参照して ください。
© 2025 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.