In questa pagina

EndpointDiscovery QML Type

Fornisce informazioni sugli endpoint disponibili su un server. Altro...

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

Questo tipo è deprecato a partire da QtOpcUa 6.9. Si sconsiglia vivamente di utilizzarlo nel nuovo codice.

Proprietà

Segnali

Metodi

  • EndpointDescription at(index)

Descrizione dettagliata

Consente di recuperare e accedere alle informazioni relative agli endpoint disponibili su un server.

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);
        }
    }
}

Documentazione delle proprietà

connection : Connection

La connessione da utilizzare per richiedere informazioni.

Se questa proprietà non è impostata, verrà utilizzata la connessione predefinita, se presente.

Vedi anche Connection e Connection::defaultConnection.

count : int

Numero attuale di endpoint presenti in questo elemento. Prima di utilizzare qualsiasi dato proveniente da un'operazione di individuazione degli endpoint, è necessario verificare su status se le informazioni sono state recuperate correttamente.

Vedi anche status e Status.

serverUrl : string

URL di individuazione del server da cui recuperare gli endpoint. Ogni volta che l'URL viene modificato, viene avviata una richiesta al server specificato.

All’avvio della richiesta, l’elenco degli endpoint disponibili viene azzerato e lo stato viene impostato su Status.GoodCompletesAsynchronously. Una volta terminata la richiesta, status cambia.

Assicurarsi di controllare status prima di accedere all’elenco degli endpoint.

Vedi anche endpointsChanged.

status : Status

Lo stato attuale di questo elemento. Se l'ultimo recupero degli endpoint è andato a buon fine, lo stato è " Status.Good".

if (endpoints.status.isGood) {
    // do something
} else {
    // handle error
}

Vedi anche Status.

Documentazione Signal

endpointsChanged()

Viene emesso quando una richiesta di recupero è stata avviata, completata o non è andata a buon fine. All’interno di una funzione chiamata, è necessario verificare innanzitutto il campo ` status ` dell’oggetto. Se lo stato è ` Status.GoodCompletesAsynchronously`, la richiesta è ancora in corso. Se lo stato è ` Status.Good`, la richiesta è terminata ed è possibile leggere le descrizioni degli endpoint. Se lo stato non è corretto, si è verificato un errore e il campo ` status ` contiene il codice di errore restituito.

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
        }
}

Nota: il gestore corrispondente è onEndpointsChanged.

Vedi anche status, count, at, Status e EndpointDescription.

Documentazione sui metodi

EndpointDescription at(index)

Restituisce la descrizione dell'endpoint all'indirizzo specificato index. Qualora non fossero disponibili endpoint o l'indice non fosse valido, viene restituita una descrizione dell'endpoint non valida. Prima di utilizzare qualsiasi dato proveniente da questa fonte, è necessario verificare su status se il recupero delle informazioni è andato a buon fine.

if (endpoints.status.isGood) {
    if (endpoints.count > 0)
        var endpointUrl = endpoints.at(0).endpointUrl();
        console.log(endpointUrl);
} else {
    // handle error
}

Vedi anche count, status e EndpointDescription.

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