node-opcua-address-space 2.83.0 → 2.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -813,25 +813,25 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
813
813
  const browseNameMap = new Set<string>();
814
814
  _clone_children_references(this, cloneObj, options.copyAlsoModellingRules, newFilter!, extraInfo, browseNameMap);
815
815
 
816
- //
817
- let typeDefinitionNode: UAVariableType | UAObjectType | null = this.typeDefinitionObj;
818
- while (typeDefinitionNode) {
819
- doTrace &&
820
- traceLog(
821
- extraInfo?.pad(),
822
- chalk.blueBright("---------------------- Exploring ", typeDefinitionNode.browseName.toString())
816
+ if (this.nodeClass === NodeClass.Object || this.nodeClass === NodeClass.Variable) {
817
+ let typeDefinitionNode: UAVariableType | UAObjectType | null = this.typeDefinitionObj;
818
+ while (typeDefinitionNode) {
819
+ doTrace &&
820
+ traceLog(
821
+ extraInfo?.pad(),
822
+ chalk.blueBright("---------------------- Exploring ", typeDefinitionNode.browseName.toString())
823
+ );
824
+ _clone_children_references(
825
+ typeDefinitionNode,
826
+ cloneObj,
827
+ options.copyAlsoModellingRules,
828
+ newFilter,
829
+ extraInfo,
830
+ browseNameMap
823
831
  );
824
- _clone_children_references(
825
- typeDefinitionNode,
826
- cloneObj,
827
- options.copyAlsoModellingRules,
828
- newFilter,
829
- extraInfo,
830
- browseNameMap
831
- );
832
- typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
832
+ typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
833
+ }
833
834
  }
834
-
835
835
  _clone_non_hierarchical_references(this, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
836
836
  }
837
837
  cloneObj.propagate_back_references();
@@ -50,7 +50,11 @@ import { SessionContext } from "../index_current";
50
50
 
51
51
  import { DefinitionMap2, TypeInfo } from "../../source/loader/make_xml_extension_object_parser";
52
52
  import { makeDefinitionMap } from "../../source/loader/decode_xml_extension_object";
53
- import { constructNamespaceDependency, constructNamespacePriorityTable, hasHigherPriorityThan } from "./construct_namespace_dependency";
53
+ import {
54
+ constructNamespaceDependency,
55
+ constructNamespacePriorityTable,
56
+ hasHigherPriorityThan
57
+ } from "./construct_namespace_dependency";
54
58
 
55
59
  // tslint:disable:no-var-requires
56
60
  const XMLWriter = require("xml-writer");
@@ -628,37 +632,37 @@ function _dumpValue(xw: XmlWriter, node: UAVariable | UAVariableType, value: Var
628
632
  if (isExtensionObject) {
629
633
  const encodeXml = _dumpVariantExtensionObjectValue2.bind(null, xw, dataTypeNode);
630
634
 
631
- if (value.arrayType === VariantArrayType.Array) {
632
- startElementEx(xw, uax, `ListOf${baseDataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
633
- value.value.forEach(encodeXml);
634
- restoreDefaultNamespace(xw);
635
- xw.endElement();
636
- } else if (value.arrayType === VariantArrayType.Scalar) {
637
- encodeXml(value.value);
638
- } else {
639
- errorLog(node.toString());
640
- errorLog("_dumpValue : unsupported case , Matrix of ExtensionObjects");
641
- // throw new Error("Unsupported case");
635
+ switch (value.arrayType) {
636
+ case VariantArrayType.Matrix:
637
+ case VariantArrayType.Array:
638
+ startElementEx(xw, uax, `ListOf${baseDataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
639
+ value.value.forEach(encodeXml);
640
+ restoreDefaultNamespace(xw);
641
+ xw.endElement();
642
+ break;
643
+ case VariantArrayType.Scalar:
644
+ encodeXml(value.value);
645
+ break;
646
+ default:
647
+ errorLog(node.toString());
648
+ errorLog("_dumpValue : unsupported arrayType: ", value.arrayType);
642
649
  }
643
650
  } else {
644
651
  const encodeXml = _dumpVariantValue.bind(null, xw, value.dataType, node);
645
- if (value.arrayType === VariantArrayType.Matrix) {
646
- // console.log("Warning _dumpValue : Matrix not supported yet");
647
- startElementEx(xw, uax, `ListOf${dataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
648
- value.value.forEach(encodeXml);
649
- restoreDefaultNamespace(xw);
650
- xw.endElement();
651
- } else if (value.arrayType === VariantArrayType.Array) {
652
- startElementEx(xw, uax, `ListOf${dataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
653
- value.value.forEach(encodeXml);
654
- restoreDefaultNamespace(xw);
655
- xw.endElement();
656
- } else if (value.arrayType === VariantArrayType.Scalar) {
657
- encodeXml(value.value);
658
- } else {
659
- errorLog(node.toString());
660
- errorLog("_dumpValue : unsupported case , Matrix");
661
- // xx throw new Error("Unsupported case");
652
+ switch (value.arrayType) {
653
+ case VariantArrayType.Matrix:
654
+ case VariantArrayType.Array:
655
+ startElementEx(xw, uax, `ListOf${dataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
656
+ value.value.forEach(encodeXml);
657
+ restoreDefaultNamespace(xw);
658
+ xw.endElement();
659
+ break;
660
+ case VariantArrayType.Scalar:
661
+ encodeXml(value.value);
662
+ break;
663
+ default:
664
+ errorLog(node.toString());
665
+ errorLog("_dumpValue : unsupported arrayType: ", value.arrayType);
662
666
  }
663
667
  }
664
668
 
@@ -675,7 +679,6 @@ function _dumpArrayDimensionsAttribute(xw: XmlWriter, node: UAVariableType | UAV
675
679
  }
676
680
 
677
681
  function visitUANode(node: BaseNode, data: DumpData, forward: boolean) {
678
-
679
682
  const addressSpace = node.addressSpace;
680
683
 
681
684
  // visit references
@@ -800,7 +803,7 @@ function dumpCommonAttributes(xw: XmlWriter, node: BaseNode) {
800
803
  }
801
804
  }
802
805
  if (Object.prototype.hasOwnProperty.call(node, "minimumSamplingInterval")) {
803
- const minimumSamplingInterval =(node as UAVariable).minimumSamplingInterval;
806
+ const minimumSamplingInterval = (node as UAVariable).minimumSamplingInterval;
804
807
  if (minimumSamplingInterval > 0) {
805
808
  xw.writeAttribute("MinimumSamplingInterval", minimumSamplingInterval);
806
809
  }
@@ -1030,11 +1033,11 @@ function dumpUAVariableType(xw: XmlWriter, node: UAVariableType) {
1030
1033
  // throw new Error(" cannot find datatype " + node.dataType);
1031
1034
  console.log(
1032
1035
  " cannot find datatype " +
1033
- node.dataType +
1034
- " for node " +
1035
- node.browseName.toString() +
1036
- " id =" +
1037
- node.nodeId.toString()
1036
+ node.dataType +
1037
+ " for node " +
1038
+ node.browseName.toString() +
1039
+ " id =" +
1040
+ node.nodeId.toString()
1038
1041
  );
1039
1042
  } else {
1040
1043
  const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
@@ -1063,6 +1066,7 @@ function dumpUAObject(xw: XmlWriter, node: UAObject) {
1063
1066
  _dumpUAObject(xw, node);
1064
1067
  xw.writeComment("Object - " + b(xw, node.browseName) + " }}}} ");
1065
1068
  }
1069
+
1066
1070
  function _dumpUAObject(xw: XmlWriter, node: UAObject) {
1067
1071
  assert(node.nodeClass === NodeClass.Object);
1068
1072
  xw.visitedNode = xw.visitedNode || {};
@@ -1101,9 +1105,7 @@ function dumpElementInFolder(xw: XmlWriter, node: BaseNodeImpl) {
1101
1105
 
1102
1106
  function dumpAggregates(xw: XmlWriter, node: BaseNode) {
1103
1107
  // Xx xw.writeComment("Aggregates {{ ");
1104
- const aggregates = node
1105
- .getAggregates()
1106
- .sort(sortByBrowseName);
1108
+ const aggregates = node.getAggregates().sort(sortByBrowseName);
1107
1109
  // const aggregates = node.findReferencesExAsObject("Aggregates", BrowseDirection.Forward);
1108
1110
 
1109
1111
  for (const aggregate of aggregates.sort(sortByNodeId)) {
@@ -1242,7 +1244,6 @@ function writeAliases(xw: XmlWriter, aliases: Record<string, NodeIdString>) {
1242
1244
  xw.endElement();
1243
1245
  }
1244
1246
 
1245
-
1246
1247
  export function constructNamespaceTranslationTable(dependency: INamespace[]): ITranslationTable {
1247
1248
  const translationTable: ITranslationTable = {};
1248
1249
  for (let i = 0; i < dependency.length; i++) {
@@ -1329,8 +1330,6 @@ function makeTypeXsd(namespaceUri: string): string {
1329
1330
 
1330
1331
  // eslint-disable-next-line max-statements
1331
1332
  NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
1332
-
1333
-
1334
1333
  const namespaceArrayNode = this.addressSpace.findNode(VariableIds.Server_NamespaceArray);
1335
1334
  const namespaceArray: string[] = namespaceArrayNode
1336
1335
  ? namespaceArrayNode.readAttribute(null, AttributeIds.Value).value.value
@@ -1343,7 +1342,6 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
1343
1342
  const translationTable = constructNamespaceTranslationTable(dependency);
1344
1343
  xw.translationTable = translationTable;
1345
1344
 
1346
-
1347
1345
  xw.startDocument({ encoding: "utf-8", version: "1.0" });
1348
1346
  xw.startElement("UANodeSet");
1349
1347
 
@@ -1388,7 +1388,7 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
1388
1388
  return false;
1389
1389
  }
1390
1390
  return checkExtensionObjectIsCorrectScalar.call(this, extObj);
1391
- } else if (this.valueRank === 1) {
1391
+ } else if (this.valueRank >= 1) {
1392
1392
  /** array */
1393
1393
  if (!(extObj instanceof Array)) {
1394
1394
  // let's coerce this scalar into an 1-element array if it is a valid extension object