このページでは

ServerDiscovery QML Type

利用可能なサーバーに関する情報を提供します。詳細...

Import Statement: import QtOpcUa
Since: QtOpcUa 5.13
Status: Deprecated since 6.9

このタイプは QtOpcUa 6.9 以降、非推奨となっています。新しいコードでの使用は強く推奨しません。

プロパティ

信号

方法

  • 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 を確認し、情報の取得が正常に行われたかどうかを確認してください。

status および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」も参照してください 。

Signal ドキュメント

serversChanged()

取得リクエストが開始、完了、または失敗した際に発生します。呼び出された関数内では、まずオブジェクトのstatus を確認する必要があります。ステータスがStatus.GoodCompletesAsynchronously の場合、リクエストは実行中です。ステータスがStatus.Good の場合、リクエストは完了しており、アプリケーションの説明を読み取ることができます。ステータスが正常でない場合はエラーが発生しており、status には返されたエラーコードが含まれています。

onServersChanged: {
        if (status.isGood) {
            if (status.status == QtOpcUa.Status.GoodCompletesAsynchronusly)
                return; // wait until finished
            if (count > 0) {
                var serverUrl = at(0).endpointUrl();
                console.log(serverUrl);
            }
        } else {
            // handle error
        }
}

注: 対応するハンドラは onServersChanged です。

関連項目: status 、count 、at 、Status 、およびApplicationDescription 。

メソッドのドキュメント

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.