Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.on("post_initialize", function () {
const addressSpace = server.engine.addressSpace;
const rootFolder = addressSpace.findNode("RootFolder");
const namespace = addressSpace.getOwnNamespace();
const myDevices = namespace.addFolder(rootFolder.objects, {browseName: "MyDevices"});
const variable0 = namespace.addVariable({
organizedBy: myDevices,
browseName: "Counter",
nodeId: "ns=1;s=MyCounter",
dataType: "Int32",
value: new opcua.Variant({dataType: opcua.DataType.Int32, value: 1000.0})
});
server._on_TransferSubscriptionsRequest =(message /* :Message*/, channel/*: ServerSecureChannelLayer*/) => {
const response = new opcua.TransferSubscriptionsResponse({
responseHeader: { serviceResult: opcua.StatusCodes.BadNotImplemented }
});
return channel.send_response("MSG", response, message);
}
});
server.on("post_initialize", function () {
const addressSpace = server.engine.addressSpace;
const rootFolder = addressSpace.findNode("RootFolder");
const namespace = addressSpace.getOwnNamespace();
const myDevices = namespace.addFolder(rootFolder.objects, {browseName: "MyDevices"});
const variable0 = namespace.addVariable({
organizedBy: myDevices,
browseName: "Counter",
nodeId: "ns=1;s=MyCounter",
dataType: "Int32",
value: new opcua.Variant({dataType: opcua.DataType.Int32, value: 1000.0})
});
// Add a mechanism to dismiss session early
const obj = namespace.addObject({
nodeId: "ns=1;s=MyObject",
browseName: "MyObject" ,
organizedBy: myDevices,
});
const simulateNetworkOutage = namespace.addMethod(obj, {
browseName: "SimulateNetworkOutage",
executable: true,
inputArguments: [
{
name: "outageDuration",
description: {text: "specifies the number of miliseconds the Outage should be"},
server.on("post_initialize", function () {
const addressSpace = server.engine.addressSpace;
const rootFolder = addressSpace.findNode("RootFolder");
const namespace = addressSpace.getOwnNamespace();
const myDevices = namespace.addFolder(rootFolder.objects, {browseName: "MyDevices"});
const variable0 = namespace.addVariable({
organizedBy: myDevices,
browseName: "Counter",
nodeId: "ns=1;s=MyCounter",
dataType: "Int32",
value: new opcua.Variant({dataType: opcua.DataType.Int32, value: 1000.0})
});
});
function extract_value(dataType,city_name,property) {
const city = city_data_map[city_name];
if (!city) {
return opcua.StatusCodes.BadDataUnavailable
}
const value = city[property];
return new opcua.Variant({dataType, value: value });
}
function (cb) {
session.writeSingleNode("ns=1;s=Variable1", new opcua.Variant({
dataType: opcua.DataType.Double,
value: 100
}), function (err) {
cb(err);
});
},