WellKnownNodes
WellKnownNodes É uma classe estática que contém constantes de string NodeId predefinidas para nós padrão OPC Foundation. Use-a em vez de escrever i=2258 manualmente para melhorar a legibilidade do código.
acompanhamento
- Consulte a pesquisa reversa do namespace Namespaces.
- Para NodeId ler os dados, consulte Read / Write.
Nó raiz comumente usado
| Constante | NodeId | Significado |
|---|---|---|
| WellKnownNodes.RootFolder | i=84 | Raiz do espaço de endereços |
| WellKnownNodes.ObjectsFolder | i=85 | Raiz dos dados operacionais |
| WellKnownNodes.TypesFolder | i=86 | Raiz da definição de tipo |
| WellKnownNodes.ViewsFolder | i=87 | Raiz da visualização |
| WellKnownNodes.Server | i=2253 | O próprio objeto Server |
Status do servidor
| Constante | NodeId | Significado |
|---|---|---|
| WellKnownNodes.Server_ServerStatus | i=2256 | Estrutura de status do servidor |
| WellKnownNodes.Server_ServerStatus_State | i=2259 | Status (Em execução / Falha / ...) |
| WellKnownNodes.Server_ServerStatus_CurrentTime | i=2258 | Hora atual do servidor |
| WellKnownNodes.Server_ServerStatus_StartTime | i=2257 | Tempo de inicialização do servidor |
| WellKnownNodes.Server_ServerStatus_BuildInfo | i=2260 | BuildInfo (Produto / Fabricante / Versão) |
| WellKnownNodes.Server_ServerArray | i=2254 | ServerArray Matriz de strings |
| WellKnownNodes.Server_NamespaceArray | i=2255 | NamespaceArray Matriz de strings |
Padrão ReferenceType
| Constante | NodeId |
|---|---|
| WellKnownNodes.HasComponent | i=47 |
| WellKnownNodes.HasProperty | i=46 |
| WellKnownNodes.Organizes | i=35 |
| WellKnownNodes.HasTypeDefinition | i=40 |
| WellKnownNodes.HierarchicalReferences | i=33 |
| WellKnownNodes.References | i=31 |
Espaço de nomes padrão URI
Constantes URI de namespace WellKnownNamespaces fornecidas no mesmo grupo de classes estáticas:
| Constante | valor |
|---|---|
| WellKnownNamespaces.OpcFoundation | http://opcfoundation.org/UA/ |
| WellKnownNamespaces.DI | http://opcfoundation.org/UA/DI/ |
Modo de uso
using DarraOpcUa_Client;
using var ua = new DarraOpcUa("opc.tcp://localhost:4840");
// Não recomendado: codificação rígida
using var dv1 = ua.Read("i=2258");
// Recomendação: use constantes
using var dv2 = ua.Read(WellKnownNodes.Server_ServerStatus_CurrentTime);
ServerStatus Leitura completa
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 Ao todo, 55 const string constantes (Pasta 8 / Server 16 / ReferenceType 12 / DataType 19), todas sendo strings NodeId de nós padrão ns=0. Há ainda WellKnownNamespaces (2 constantes URI) no mesmo grupo de classes estáticas.