Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//xx assert(parentNode instanceof opcua.BaseNode);
const addressSpace = parentNode.addressSpace;
const namespace = addressSpace.getOwnNamespace();
// add a UAAnalogItem
namespace.addAnalogDataItem({
componentOf: parentNode,
nodeId: "s=TemperatureAnalogItem",
browseName: "TemperatureAnalogItem",
definition: "(tempA -25) + tempB",
valuePrecision: 0.5,
engineeringUnitsRange: {low: 100, high: 200},
instrumentRange: {low: -100, high: +200},
engineeringUnits: opcua.standardUnits.degree_celsius,
dataType: "Double",
value: {
get: function () {
return new Variant({dataType: DataType.Double, value: Math.random() + 19.0});
}
}
});
}
}
});
// UAAnalogItem
// add a UAAnalogItem
const node = namespace.addAnalogDataItem({
organizedBy: myDevices,
nodeId: "s=TemperatureAnalogItem",
browseName: "TemperatureAnalogItem",
definition: "(tempA -25) + tempB",
valuePrecision: 0.5,
engineeringUnitsRange: { low: 100, high: 200 },
instrumentRange: { low: -100, high: +200 },
engineeringUnits: opcua.standardUnits.degree_celsius,
dataType: "Double",
value: {
get: function() {
return new Variant({ dataType: DataType.Double, value: Math.random() + 19.0 });
}
}
});
const m3x3 = namespace.addVariable({
organizedBy: addressSpace.rootFolder.objects,
nodeId: "s=Matrix",
browseName: "Matrix",
dataType: "Double",
valueRank: 2,
arrayDimensions: [3, 3],
function construct_address_space(server) {
const addressSpace = server.engine.addressSpace;
const namespace = addressSpace.getOwnNamespace();
const vessel = namespace.addObject({
browseName: "Vessel",
organizedBy: addressSpace.rootFolder.objects
});
const vesselPressure = namespace.addAnalogDataItem({
browseName: "Pressure",
engineeringUnitsRange: {
low: 0,
high: 10.0
},
engineeringUnits: opcua.standardUnits.bar,
componentOf: vessel
});
addressSpace.installHistoricalDataNode(vesselPressure);
// simulate pressure change
let t = 0;
setInterval(function() {
let value = (Math.sin(t/50)*0.70+Math.random()*0.20)*5.0+5.0;
vesselPressure.setValueFromSource({dataType:"Double",value:value});
t=t+1;
}, 200);
};
"use strict";
const chalk = require("chalk");
const _ = require("underscore");
const assert = require("node-opcua-assert").assert;
const opcua = require("node-opcua");
const StatusCodes = opcua.StatusCodes;
const DataType = opcua.DataType;
const standardUnits = opcua.standardUnits;
const doDebug = false;
/**
* @method createHVACSystem
*
* @startuml
*
* class HVACModuleType {
* }
* HVACModuleType -up-> ObjectType
* HVACModuleType o-down-> ExteriorTemperatureSensor << (P,#F0F0FF)TemperatureSensorType >>
* HVACModuleType o-down-> InteriorTemperatureSensor << (P,#F0F0FF)TemperatureSensorType >>
* HVACModuleType o-down-> TargetTemperature << (P,#F0F0FF)TemperatureSensorType >>
* HVACModuleType o-down-> HVACEnabledEventType << (E,#00F0FF)BaseEventType >>
* HVACModuleType o-down-> HVACDisabledEventType << (E,#00F0FF)BaseEventType >>
});
const fakeValue = 1;
const analogItem = namespace.addAnalogDataItem({
componentOf: myDevice,
browseName: "TemperatureSensor",
definition: "(tempA -25) + tempB",
valuePrecision: 0.5,
engineeringUnitsRange: { low: 100 , high: 200},
instrumentRange: { low: -100 , high: +200},
engineeringUnits: opcua.standardUnits.degree_celsius,
dataType: "Double",
value: { get: function(){return new opcua.Variant({dataType: opcua.DataType.Double , value: fakeValue}); } }
});
}