Saltar al contenido principal

WellKnownNodes

WellKnownNodes Se trata de una clase estática que contiene constantes de cadena NodeId predefinidas para los nodos estándar OPC Foundation . Utilízala en lugar de escribirlas manualmente para i=2258 mejorar la legibilidad del código.

Accesorios
  • Véase la búsqueda inversa de espacios de nombres Namespaces.
  • Para NodeId consultar los datos, véase Read / Write.

Nodo raíz habitual​

ConstanteNodeIdSignificado
WellKnownNodes.RootFolderi=84Raíz del espacio de direcciones
WellKnownNodes.ObjectsFolderi=85Raíz de datos operativos
WellKnownNodes.TypesFolderi=86Raíz de definición de tipos
WellKnownNodes.ViewsFolderi=87Raíz de la vista
WellKnownNodes.Serveri=2253El propio objeto «Server»

Estado del servidor​

ConstanteNodeIdSignificado
WellKnownNodes.Server_ServerStatusi=2256Estructura del estado del servidor
WellKnownNodes.Server_ServerStatus_Statei=2259Estado (Running / Failed / ...)
WellKnownNodes.Server_ServerStatus_CurrentTimei=2258Hora actual del servidor
WellKnownNodes.Server_ServerStatus_StartTimei=2257Tiempo de inicio del servidor
WellKnownNodes.Server_ServerStatus_BuildInfoi=2260BuildInfo (Producto / Fabricante / Versión)
WellKnownNodes.Server_ServerArrayi=2254ServerArray Matriz de cadenas
WellKnownNodes.Server_NamespaceArrayi=2255NamespaceArray Matriz de cadenas

Norma ReferenceType​

ConstanteNodeId
WellKnownNodes.HasComponenti=47
WellKnownNodes.HasPropertyi=46
WellKnownNodes.Organizesi=35
WellKnownNodes.HasTypeDefinitioni=40
WellKnownNodes.HierarchicalReferencesi=33
WellKnownNodes.Referencesi=31

Espacio de nombres estándar URI​

Dentro de un mismo grupo de clases estáticas se WellKnownNamespaces proporcionan constantes URI de espacio de nombres:

Constantevalor
WellKnownNamespaces.OpcFoundationhttp://opcfoundation.org/UA/
WellKnownNamespaces.DIhttp://opcfoundation.org/UA/DI/

Modo de empleo​

using DarraOpcUa_Client;

using var ua = new DarraOpcUa("opc.tcp://localhost:4840");

// No recomendado: codificación fija
using var dv1 = ua.Read("i=2258");

// Recomendación: utilizar constantes
using var dv2 = ua.Read(WellKnownNodes.Server_ServerStatus_CurrentTime);

ServerStatus Leer completo​

using System;
using DarraOpcUa_Client;

var items = new (string nodeId, AttributeId attr)[]
{
(WellKnownNodes.Server_ServerStatus_State, AttributeId.Value),
(WellKnownNodes.Server_ServerStatus_CurrentTime, AttributeId.Value),
(WellKnownNodes.Server_ServerStatus_StartTime, AttributeId.Value),
(WellKnownNodes.Server_NamespaceArray, AttributeId.Value),
};
var values = ua.ReadMany(items); // IReadOnlyList<DataValue>
try
{
Console.WriteLine($"State = {values[0].Value}");
Console.WriteLine($"CurrentTime = {values[1].Value.AsDateTime}");
Console.WriteLine($"StartTime = {values[2].Value.AsDateTime}");
Console.WriteLine($"Namespaces = {string.Join(",", values[3].Value.AsStringArray ?? Array.Empty<string>())}");
}
finally
{
foreach (var dv in values) dv?.Dispose();
}

Lista completa​

WellKnownNodes Hay un total de 55 const string constantes (Carpeta 8 / Server 16 / ReferenceType 12 / DataType 19), todas ellas cadenas NodeId de caracteres de nodos estándar ns=0. En el mismo grupo de clases estáticas hay además ( WellKnownNamespaces 2 URI constantes).

Siguiente paso​