what’s new in NodeOPCUA 0.0.50

This version add a significant number of enhancements. You can access the details in the release notes

Enhancements

  • AddresseSpace helper methods have been added to create DI objects of type TwoStateDiscreteType , MultiStateDiscreteType and MultiStateValueDiscreteType

  • AddresseSpace#addTwoStateDiscreteType

var addressSpace = engine.addressSpace;
var rootFolder = addressSpace.findObject("ObjectsFolder");
rootFolder.browseName.toString().should.eql("Objects");

var prop = addressSpace.addTwoStateDiscreteType({
organizedBy: rootFolder,
browseName: "MySwitch",
trueState: "busy",
falseState: "idle",
value: false
});
prop.browseName.toString().should.eql("MySwitch");

prop.getPropertyByName("TrueState").readValue().value.toString()
.should.eql("Variant(Scalar<LocalizedText>, value: locale=null text=busy)");

prop.getPropertyByName("FalseState").readValue().value.toString()
.should.eql("Variant(Scalar<LocalizedText>, value: locale=null text=idle)");

prop.readValue().value.toString().should.eql("Variant(Scalar<Boolean>, value: false)");
  • AddresseSpace#addMultiStateDiscreteType
 var prop = addressSpace.addMultiStateDiscreteType({
componentOf: rootFolder,
browseName: "MyMultiStateVariable",
enumStrings: [ "Red","Orange","Green"],
value: 1 // Orange
});
prop.browseName.toString().should.eql("MyMultiStateVariable");

prop.valueRank.should.eql(-2);

prop.getPropertyByName("EnumStrings").readValue().value.toString()
.should.eql("Variant(Array<LocalizedText>, l= 3, value=[locale=null text=Red,locale=null text=Orange,locale=null text=Green])");

prop.enumStrings.readValue().value.dataType.should.eql(DataType.LocalizedText);

prop.readValue().value.toString().should.eql("Variant(Scalar<UInt32>, value: 1)");
prop.readValue().value.dataType.should.eql(DataType.UInt32);

…..see unit test

  • AddresseSpace#AddMultiStateValueDiscreteType
var addressSpace = engine.addressSpace;
var rootFolder = addressSpace.findObject("ObjectsFolder");
rootFolder.browseName.toString().should.eql("Objects");

var prop = addressSpace.addMultiStateValueDiscreteType({
componentOf: rootFolder,
browseName: "MyMultiStateValueVariable",
enumValues: {
"Red": 0xFF0000,
"Orange": 0xFF9933,
"Green": 0x00FF00,
"Blue": 0x0000FF
},
value: 0xFF0000 // Red
});
prop.browseName.toString().should.eql("MyMultiStateValueVariable");
var v = prop.getPropertyByName("EnumValues").readValue().value;
v.dataType.should.eql(DataType.ExtensionObject);
v.arrayType.should.eql(VariantArrayType.Array);
v.value.length.should.eql(4);
v.value[0].constructor.name.should.eql("EnumValueType");

prop.readValue().value.toString().should.eql("Variant(Scalar<UInt32>, value: 16711680)");
prop.readValue().value.dataType.should.eql(DataType.UInt32);

prop.valueAsText.readValue().value.value.text.should.eql("Red");

see unit test

  • UAVariable#bindExtensionObject add the ability to create a Variable containing an array extension object,
    and exposing elements as components.

  • Variant can now be Matrices and have dimensions

var var1 = new opcua.Variant({
dataType: opcua.DataType.UInt32,
arrayType: opcua.VariantArrayType.Matrix,
dimensions: [ 2,3], // 2 lines , 3 columns
value : [
0x000,0x001,0x002, // first line
0x010,0x011,0x012 // second line
]
});

Breaking changes:

  • server.engine.address_space now becomes server.engine.addressSpace to comply with camelCase naming convention.

  • AddressSpace#addVariable now takes a single argument. The parent object is now specified in the parameters, using the propertyOf, componentOf, or organizedBy attributes.

addressSpace.addVariable(parent,{browseName: "MyVar"});
becomes :
addressSpace.addVariable({ componentOf: parent, browseName: "MyVar"});
  • AddressSpace#addProperty has been deprecated.
addressSpace.addProperty(parent,{browseName: "MyVar"});
becomes :
addressSpace.addVariable({ propertyOf: parent, browseName: "MyVar"});