이 페이지에서

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.