ServerDiscovery QML Type

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

Import Statement: import QtOpcUa
Since: QtOpcUa 5.13

プロパティ

方法

  • 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も参照


メソッド Documentation

指定された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
}

countstatus 、およびApplicationDescriptionも参照して ください。


© 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.