we installed counters for compressed-air-usage here in our factory, after getting their values into nodered,
now i want to make their values available for third party software by opc-ua.
I set up a OPC-UA server using contrib opc-ua. Now i am having trouble to add items/variables to the server.
Are there additonal things in my flow needed to have the variables appear in the tree?
Maybe somebody can provide a sample flow, where variables are added to the OPC-server.
Server connection works fine.
After some playing around I was able to create a folder on the OPCUA-Server and store variables/values there. So first progress Now I am curious about the servers behaviour in case of powerloss/ nodered crash.
I adressed the variables by their indentifiers after creating them on serverside.
Are these identifiers persistent after being created once or am I going to run into trouble?
Because I tried restarting the server and saw that it initially came back "empty", and all folders and variables had to be set again?
Use inject node that will always inject once as flow starts.
Another option is to save XML and then load it always as server starts.
Study examples and OPCUA-TEST-NODES.json there is tab with server.
Code checks only msg.payload & msg.filename are defined. Optional msg.topic is used to save different namespaces.
case "saveAddressSpace":
if (msg.payload && msg.filename) {
// Save current server namespace objects to file
var namespace = addressSpace.getOwnNamespace();
// Use msg.topic to select namespace
if (msg.topic) {
verbose_log("Saving namespace index: " + msg.topic);
namespace = addressSpace.getNamespace(parseInt(msg.topic));
}
if (namespace) {
const xmlstr = namespace.toNodeset2XML();
fs.writeFileSync(msg.filename, xmlstr.toString(), {encoding: "utf8"});
}
else {
verbose_warn("No namespace to save to XML file, check namespace index: " + msg.topic);
}
}
else {
verbose_warn("Check msg object, it must contain msg.filename for the address space in XML format!");
}
break;