ServerDiscovery QML Type
Proporciona información sobre los servidores disponibles. Más...
| Import Statement: | import QtOpcUa |
| Since: | QtOpcUa 5.13 |
| Status: | Deprecated since 6.9 |
Este tipo está obsoleto desde QtOpcUa 6.9. Desaconsejamos su uso en código nuevo.
Propiedades
- connection : Connection
- count : int
- discoveryUrl : string
- status : Status
Métodos
- ApplicationDescription at(index)
Descripción detallada
Permite obtener y acceder a información sobre servidores conocidos por un servidor o servidor de descubrimiento.
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); } } }
Documentación de propiedades
connection : Connection
La conexión que se utilizará para solicitar información.
Si no se establece esta propiedad, se utilizará la conexión por defecto, si existe.
Véase también Connection y Connection::defaultConnection.
count : int
Número actual de servidores en este elemento. Antes de utilizar cualquier dato de este descubrimiento de servidores, debe comprobar status si la recuperación de la información se ha realizado correctamente.
Véase también status y Status.
discoveryUrl : string
URL del servidor del que recuperar la lista de servidores. Cada vez que se cambia la URL, se inicia una petición al servidor dado.
Al iniciar la petición, la lista de servidores disponibles se borra y el estado se establece en Status.GoodCompletesAsynchronously. Una vez finalizada la petición, cambia status. Asegúrese de comprobar status antes de acceder a la lista de servidores.
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
}
}Véase también ApplicationDescription, status, at, count, y Status.
status : Status
El estado actual de este elemento. En caso de que la última recuperación de servidores se haya realizado correctamente, el estado debe ser Status.Good.
if (status.isGood) { // Choose endpoint to connect to } else { // handle error }
Véase también Status.
Documentación del método
ApplicationDescription at(index)
Devuelve la descripción de la aplicación en la dirección index. En caso de que no haya servidores disponibles o el índice no sea válido, se devolverá una descripción no válida de la aplicación. Antes de utilizar cualquier dato devuelto, debe comprobar status si la recuperación de la información se ha realizado correctamente.
if (servers.status.isGood) { if (servers.count > 0) var serverUrl = at(0).serverUrl(); console.log(serverUrl); // Choose endpoint to connect to } else { // handle error }
Véase también count, status, y 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.