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

정보 요청에 사용할 연결입니다.

이 속성을 설정하지 않으면 기본 연결(있는 경우)이 사용됩니다.

ConnectionConnection::defaultConnection참조하세요 .


count : int

이 요소의 현재 서버 수입니다. 이 서버 검색의 데이터를 사용하기 전에 status 에서 정보 검색이 성공했는지 확인해야 합니다.

statusStatus도 참조 하세요.


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도 참조하세요 .


메서드 문서

주어진 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도 참조하세요 .


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