OpcUaNode
OpcUaNode Yes NodeCollection The wrapper object returned by the indexer represents a remote node. Lazy Load — Only access properties trigger RPC.
- For the entry point, see NodeCollection.
- To avoid multiple lookups in a chained index, use RPC TranslateBrowsePaths Parse the path once.
Public Attributes
| Category | Property | Type | Access | Description |
|---|---|---|---|---|
| Tags (None RPC) | NodeId | string | R | Node ID string |
| Data (Trigger RPC) | Value | DataValue | R | Current value — triggers Read(Value) |
DisplayName | string | R | Display name text — triggers Read(DisplayName) | |
BrowseName | string | R | View name — Triggers Read(BrowseName), returns a format `ns:Name` (e.g., `0:ServerStatus`) | |
Description | string | R | Description text — triggers a Read(Description) operation | |
NodeClass | NodeClass | R | Node category — Triggers Read(NodeClass); if the read fails, `Unspecified` | |
DataTypeNodeId | string | R | Data type NodeId — triggers Read(DataType) | |
IsReadable | bool | R | AccessLevel bit0; false AccessLevel when unreadable | |
IsWritable | bool | R | AccessLevel bit1; false when AccessLevel not readable | |
| Child Nodes (Triggered RPC) | Children | IReadOnlyList<OpcUaReference> | R | List of child nodes — Trigger Browse |
Indexer
| Index | Return | Note |
|---|---|---|
| node[browseName] | OpcUaNode | Search by NameDirect child nodes, triggered once Browse |
Name Matching Rules: BrowseName == browseName or DisplayName == browseName, take the first match; Cannot find the return null (No exceptions are thrown). The matching usesBare Name —— node["ServerStatus"] Hit, node["0:ServerStatus"] Miss (different from the form ns:Name of BrowseName the attribute above).
Public Methods
| Methods | Return | Note |
|---|---|---|
ReadAttribute(AttributeId attr) | DataValue | Read Specified Attribute (Value / DisplayName / ...) |
Write(Variant v) | StatusCode | Write the Value property |
WriteAttribute(AttributeId attr, Variant v) | StatusCode | Write a Specified Attribute |
Resolve(string path) | OpcUaNode | Search along the path starting from this node (segment by segment Browse); Cannot find; returns null |
Call(string parentObjectNodeId, params Variant[] inputs) | IReadOnlyList<Variant> | PutThis node When a method is called; parentObjectNodeId it is the object on which the method resides. NodeId |
Call Equivalent to ua.Call(parentObjectNodeId, 本节点.NodeId, inputs), and the output parameters must also Variant be disposed of one by one.
Examples
// 1. Get Node (None RPC)
var temp = ua.Nodes["ns=2;s=Temperature"];
// 2. Read the basic information (1 RPC each)
Console.WriteLine($"NodeId = {temp.NodeId}");
Console.WriteLine($"DisplayName = {temp.DisplayName}");
Console.WriteLine($"DataTypeNodeId= {temp.DataTypeNodeId}");
Console.WriteLine($"NodeClass = {temp.NodeClass}");
// 3. Read the value
using var dv = temp.Value;
Console.WriteLine($"Value = {dv.Value.AsDouble ?? double.NaN} °C @ {dv.SourceTimestamp}");
// AsDouble Is it a double?: Returns null if the value is not of type Double; passing it directly to a double parameter will result in a compilation error.
// 4. Write
using var v = new Variant();
v.Double = 25.5;
StatusCode st = temp.Write(v);
// 5. Browse Subnodes
foreach (var child in temp.Children)
Console.WriteLine($" {child.BrowseName} -> {child.NodeId}");
// 6. Chained Access (Server.ServerStatus.CurrentTime)
using var time = ua.Nodes.Server["ServerStatus"]["CurrentTime"].Value;
Console.WriteLine($"Server time = {time.Value.AsDateTime}");
Important Notes
- All properties RPC that are triggered are "read-once, return-once," Do not cache. I want to cache a variable I've stored myself
- Chain-based access: One access
a["b"]["c"]per segment Browse RPC, for a total of N accesses DataValueYou must call Dispose; otherwise, a memory leak will occur.IsReadable/IsWritableNot a permission check: They read the node'sAccessLevelbit, not the current user'sUserAccessLevel. If you seeIsWritable == trueand write to it, the server can still returnBadUserAccessDenied— you must handle the status code before writing; you cannot treat these two attributes as proof that "I have permission."
Comparison with Resolve
// Method A: Chain Indexer — 3 times RPC
using var ta = ua.Nodes.Server["ServerStatus"]["CurrentTime"].Value;
// ^Nodes.Server Do not post RPC
// ^1st Browse ^2nd Browse ^3rd Read
// Method B: Path Resolution — 5 times RPC (1 time for each of the 4 segments Browse + 1 Read)
var nb = ua.Resolve("/Objects/Server/ServerStatus/CurrentTime"); // 4 times Browse, one paragraph at a time
if (nb != null) // Cannot find; returns null
{
using var tb = nb.Value; // 1 view
Console.WriteLine($"server time = {tb.Value.AsDateTime}");
}
// Method C: Directly NodeId — 1 time RPC
using var tc = ua.Read("i=2258");
Known path → Method C (done in 1 call); Exploratory development → Method A; Don't use Method B just to "save a few lines." —— Resolve It's priced by section Browse; the deeper it goes, the more expensive it is.