RegisterNodes / UnregisterNodes
RegisterNodes The service registers the client's frequently used NodeId with the server, and the server returns a temporary, high-performance NodeId (lifetime = Session). Subsequent Read / Write / operations use this temporary ID directly MonitoredItem. The amount of savings NodeId achieved by using the temporary ID compared to the original depends on the server implementation; please test this with your server.
- One-time script → Not necessary
- Long-term operation with high-frequency access to the same node → Recommendations
- Large number of nodes and continuous monitoring → Recommendations
Signature
Both are member methods of Session.
namespace darra::opcua {
class Session {
public:
std::vector<std::string> RegisterNodes(std::vector<std::string> const& node_ids);
Status UnregisterNodes(std::vector<std::string> const& registered_node_ids);
};
}
Usage
#include <darra/opcua/client.hpp>
#include <vector>
#include <string>
using namespace darra::opcua;
Session s("opc.tcp://localhost:4840");
s.Connect();
// 1. Register when the app starts
std::vector<std::string> orig = {
"ns=2;s=Plant.Line1.Sensor.Temperature",
"ns=2;s=Plant.Line1.Sensor.Pressure",
"ns=2;s=Plant.Line1.Sensor.FlowRate",
};
std::vector<std::string> temp = s.RegisterNodes(orig);
// "temp" is a temporary value returned by the server NodeId; its order corresponds one-to-one with "orig."
// The exact format is determined by the server; do not assume it takes the form "i=99001" — subsequent calls should simply pass temp[i] as a NodeId string.
// 2. Use a temporary one for subsequent frequent visits ID
for (int i = 0; i < 10000; ++i) {
auto dv = s.Read(temp[0]);
}
// 3. Release before the app exits
Status st = s.UnregisterNodes(temp);
When to Use
| Scenario | Necessity |
|---|---|
| One-time script, few nodes | Low (cost savings are negligible) |
| Long-term operation, frequent access to the same node | High |
| A large number of nodes and continuous monitoring | High |
Where do the revenues come from?
NodeId Once the server obtains the temporary ID, it can skip the full resolution NodeId process, so for the same Read/Write operations, there is one less MonitoredItem resolution step. The extent of the benefit depends on how the server implements the lookup NodeId, SDK No promises regarding the gear ratio — Numbers NodeId (i=2258) are already very lightweight to parse, so the performance gains are usually not significant; with long strings NodeId (ns=2;s=Plant.Line1.Sensor.Temperature), the gains are more noticeable. Please base your assessment on actual tests on your server.
Note
- Registered Temporary ID Lifecycle = Session, Expires at the end of the session
- The order in which temporary IDs are returned corresponds
node_idsone-to-one with the order in which they were passed in, butThe specific value is determined by the server., Don't assume its form - Before closing the app, please use "Active
UnregisterNodesRelease" (the temporary ID received during registration). RegisterNodesThe entire operation RPC failsException; if the server does not return a specific slot, the corresponding element is an empty string.