In my use case, I have to return different values based on the user context / current session in the server.
In pseudo-node-opcua code something like following:
namespace.addVariable({
componentOf: device,
browseName: "MyVariable1",
dataType: "Double",
value: {
get: context => {
const user = context.userIdentity;
const value = user === "admin"
? service.getRootValue()
: service.getUserValueFor(user);
return new Variant({dataType: DataType.Double, value })
}
}
});
Is there a way how to achieve this with node-opcua?
One can override the
readValue
function, which takes the context as a parameter, to return a dynamic value: