node-opcua-address-space 2.69.1 → 2.70.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.
Files changed (35) hide show
  1. package/dist/source/helpers/argument_list.d.ts +4 -0
  2. package/dist/source/helpers/argument_list.js +50 -12
  3. package/dist/source/helpers/argument_list.js.map +1 -1
  4. package/dist/source/index.d.ts +3 -2
  5. package/dist/source/index.js +3 -2
  6. package/dist/source/index.js.map +1 -1
  7. package/dist/source/loader/load_nodeset2.js +123 -94
  8. package/dist/source/loader/load_nodeset2.js.map +1 -1
  9. package/dist/source/loader/make_xml_extension_object_parser.d.ts +5 -0
  10. package/dist/source/loader/make_xml_extension_object_parser.js +25 -1
  11. package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
  12. package/dist/src/data_access/add_dataItem_stuff.js +2 -2
  13. package/dist/src/data_access/add_dataItem_stuff.js.map +1 -1
  14. package/dist/src/data_access/ua_multistate_value_discrete.js +1 -0
  15. package/dist/src/data_access/ua_multistate_value_discrete.js.map +1 -1
  16. package/dist/src/namespace_impl.d.ts +1 -15
  17. package/dist/src/namespace_impl.js +1 -28
  18. package/dist/src/namespace_impl.js.map +1 -1
  19. package/dist/src/ua_variable_impl.d.ts +3 -1
  20. package/dist/src/ua_variable_impl.js +77 -16
  21. package/dist/src/ua_variable_impl.js.map +1 -1
  22. package/dist/src/ua_variable_impl_ext_obj.d.ts +2 -2
  23. package/dist/src/ua_variable_impl_ext_obj.js +68 -23
  24. package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
  25. package/package.json +28 -28
  26. package/source/helpers/argument_list.ts +47 -13
  27. package/source/index.ts +6 -3
  28. package/source/loader/load_nodeset2.ts +222 -150
  29. package/source/loader/make_xml_extension_object_parser.ts +80 -33
  30. package/src/data_access/add_dataItem_stuff.ts +2 -2
  31. package/src/data_access/ua_multistate_value_discrete.ts +1 -0
  32. package/src/namespace_impl.ts +1 -29
  33. package/src/ua_variable_impl.ts +93 -18
  34. package/src/ua_variable_impl_ext_obj.ts +79 -30
  35. package/test_helpers/test_fixtures/dataType_with_qualifiedname.xml +71 -0
@@ -18,11 +18,11 @@ import {
18
18
  } from "node-opcua-address-space-base";
19
19
  import { assert, renderError } from "node-opcua-assert";
20
20
  import { isValidGuid, StatusCodes } from "node-opcua-basic-types";
21
- import { ExtraDataTypeManager, populateDataTypeManager } from "node-opcua-client-dynamic-extension-object";
22
21
  import { EUInformation } from "node-opcua-data-access";
23
22
  import {
24
23
  AccessLevelFlag,
25
24
  coerceLocalizedText,
25
+ LocalizedTextOptions,
26
26
  makeAccessLevelFlag,
27
27
  NodeClass,
28
28
  QualifiedName,
@@ -32,7 +32,7 @@ import {
32
32
  import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
33
33
  import { ExtensionObject } from "node-opcua-extension-object";
34
34
  import { DataTypeFactory, findSimpleType, getStandardDataTypeFactory } from "node-opcua-factory";
35
- import { NodeId, resolveNodeId } from "node-opcua-nodeid";
35
+ import { NodeId, NodeIdLike, resolveNodeId } from "node-opcua-nodeid";
36
36
  import { Argument } from "node-opcua-service-call";
37
37
  import { CallbackT, ErrorCallback } from "node-opcua-status-code";
38
38
  import { EnumFieldOptions, EnumValueType, Range, StructureFieldOptions } from "node-opcua-types";
@@ -56,12 +56,10 @@ import { promoteObjectsAndVariables } from "./namespace_post_step";
56
56
  import { ensureDatatypeExtracted } from "./ensure_datatype_extracted";
57
57
  import { decodeXmlExtensionObject } from "./decode_xml_extension_object";
58
58
 
59
-
60
59
  const doDebug = checkDebugFlag(__filename);
61
60
  const debugLog = make_debugLog(__filename);
62
61
  const errorLog = make_errorLog(__filename);
63
62
 
64
-
65
63
  function __make_back_references(namespace: INamespace) {
66
64
  const namespaceP = namespace as NamespacePrivate;
67
65
  for (const node of namespaceP.nodeIterator()) {
@@ -156,10 +154,10 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
156
154
  const addressSpace1 = addressSpace as AddressSpacePrivate;
157
155
  addressSpace1.suspendBackReference = true;
158
156
 
159
- let postTasks: Task[] = [];
160
- let postTaskInitializeVariable: Task[] = [];
161
- let postTasks2: Task[] = [];
162
- let postTasks3: Task[] = [];
157
+ const postTasks: Task[] = [];
158
+ const postTasks0_DecodePojoString: Task[] = [];
159
+ const postTasks1_InitializeVariable: Task[] = [];
160
+ const postTasks2_AssignedExtensionObjectToDataValue: Task[] = [];
163
161
 
164
162
  let alias_map: { [key: string]: NodeId } = {};
165
163
 
@@ -554,17 +552,16 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
554
552
  });
555
553
  this.obj.partialDefinition = definitionFields;
556
554
 
557
- const dataTypeNode = _internal_createNode(this.obj) as UADataType;
558
- assert(addressSpace1.findNode(this.obj.nodeId));
559
- const definitionName = dataTypeNode.browseName.name!;
560
-
555
+ let capturedDataTypeNode = _internal_createNode(this.obj) as UADataType;
561
556
  const processBasicDataType = async (addressSpace2: IAddressSpace) => {
562
- const isStructure = dataTypeNode.isStructure();
563
- const isEnumeration = dataTypeNode.isEnumeration();
564
- if (!isEnumeration && !isStructure && dataTypeNode.nodeId.namespace !== 0) {
557
+ const definitionName = capturedDataTypeNode.browseName.name!;
558
+ const isStructure = capturedDataTypeNode.isStructure();
559
+ const isEnumeration = capturedDataTypeNode.isEnumeration();
560
+ if (!isEnumeration && !isStructure && capturedDataTypeNode.nodeId.namespace !== 0) {
565
561
  // add a custom basic type that is not a structure nor a enumeration
566
- pendingSimpleTypeToRegister.push({ name: definitionName, dataTypeNodeId: dataTypeNode.nodeId });
562
+ pendingSimpleTypeToRegister.push({ name: definitionName, dataTypeNodeId: capturedDataTypeNode.nodeId });
567
563
  }
564
+ (capturedDataTypeNode as any) = undefined;
568
565
  };
569
566
  postTasks.push(processBasicDataType);
570
567
  },
@@ -813,7 +810,7 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
813
810
  TypeId: {
814
811
  parser: {
815
812
  Identifier: {
816
- finish(this: any) {
813
+ finish(this: ExtensionObjectTypeIdIdentifierParser) {
817
814
  const typeDefinitionId = this.text.trim();
818
815
  const self = this.parent.parent; // ExtensionObject
819
816
  self.typeDefinitionId = resolveNodeId(typeDefinitionId);
@@ -831,7 +828,7 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
831
828
  EnumValueType: enumValueType_parser.EnumValueType,
832
829
  Range: Range_parser.Range
833
830
  },
834
- startElement(this: any, elementName: string, attrs: any) {
831
+ startElement(this: ExtensionObjectBodyParser, elementName: string, attrs: any) {
835
832
  const self = this.parent; // ExtensionObject
836
833
  self.extensionObject = null;
837
834
  self.extensionObjectPojo = null;
@@ -843,7 +840,7 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
843
840
  this.engine!._promote(this._cloneFragment, this.engine!.currentLevel, elementName, attrs);
844
841
  }
845
842
  },
846
- finish(this: any) {
843
+ finish(this: ExtensionObjectBodyParser) {
847
844
  const self = this.parent; // ExtensionObject
848
845
 
849
846
  // typeDefinitionId is also the "Default XML" encoding nodeId !
@@ -883,42 +880,30 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
883
880
  debugLog("xmlEncodingNodeId is empty for " + self.typeDefinitionId.toString());
884
881
  break;
885
882
  }
886
- const xmlBody = this.bodyXML;
883
+ let captureXmlBody = this.bodyXML;
887
884
  if (doDebug) {
888
- debugLog("xxxx ", chalk.yellow(xmlBody));
885
+ debugLog("xxxx ", chalk.yellow(captureXmlBody));
889
886
  }
890
-
891
- /*
892
- if (xmlEncodingNodeId.namespace === 0) {
893
- const dataTypeFactory = getStandardDataTypeFactory();
894
- const extensionObject: ExtensionObject | null = decodeXmlObject2(
895
- addressSpace,
896
- dataTypeFactory,
897
- xmlEncodingNodeId,
898
- xmlBody
899
- );
900
- self.extensionObject = extensionObject;
901
- return;
902
- }
903
- */
904
887
  // this is a user defined Extension Object
905
888
  debugLog(
906
889
  "load nodeset2: typeDefinitionId in ExtensionObject Default XML = " + xmlEncodingNodeId.toString()
907
890
  );
908
891
 
909
- const postTaskData = self.postTaskData;
892
+ let captured = self.postTaskData;
893
+ self.extensionObjectPojo = null;
910
894
  const task = async (addressSpace2: IAddressSpace) => {
911
895
  const extensionObject: ExtensionObject | null = await decodeXmlExtensionObject(
912
896
  addressSpace2,
913
897
  xmlEncodingNodeId,
914
- xmlBody
898
+ captureXmlBody
915
899
  );
916
- if (postTaskData) {
917
- postTaskData.postponedExtensionObject = extensionObject;
900
+ if (captured) {
901
+ captured.postponedExtensionObject = extensionObject;
918
902
  }
903
+ (captureXmlBody as any) = undefined;
904
+ (captured as any) = undefined;
919
905
  };
920
- postTasks2.push(task);
921
- self.extensionObjectPojo = null;
906
+ postTasks0_DecodePojoString.push(task);
922
907
  assert(!self.extensionObject || self.extensionObject instanceof ExtensionObject);
923
908
 
924
909
  break;
@@ -930,27 +915,28 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
930
915
 
931
916
  const extensionObject_parser = {
932
917
  ExtensionObject: {
933
- init(this: any) {
934
- this.typeDefinitionId = "";
918
+ init(this: ExtensionObjectParser) {
919
+ this.typeDefinitionId = NodeId.nullNodeId;
935
920
  this.extensionObject = null;
936
921
  this.extensionObjectPojo = null;
922
+ this.postTaskData = { postponedExtensionObject: null };
937
923
  },
938
924
  parser: _extensionObject_inner_parser,
939
- finish(this: any) {
925
+ finish(this: ExtensionObjectParser) {
940
926
  /* empty */
941
927
  }
942
928
  }
943
929
  };
944
930
 
945
- function BasicType_parser(dataType: string, parseFunc: (this: any, text: string) => any): ParserLike {
931
+ function BasicType_parser<T>(dataType: string, parseFunc: (this: { value: T | undefined }, text: string) => any): ParserLike {
946
932
  const _parser: ParserLike = {};
947
933
 
948
934
  const r: ReaderStateParserLike = {
949
- init(this: any, name: string, attrs: XmlAttributes) {
950
- this.value = 0;
935
+ init(this: { value: T | undefined }, name: string, attrs: XmlAttributes) {
936
+ this.value = undefined;
951
937
  },
952
938
 
953
- finish(this: any) {
939
+ finish(this: { value: T | undefined; text: string }) {
954
940
  this.value = parseFunc.call(this, this.text);
955
941
  }
956
942
  };
@@ -958,22 +944,22 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
958
944
  return _parser;
959
945
  }
960
946
 
961
- function ListOf(dataType: string, parseFunc: any) {
947
+ function ListOf<T>(dataType: string, parseFunc: any) {
962
948
  return {
963
- init(this: any) {
949
+ init(this: ListOfTParser<T>) {
964
950
  this.listData = [];
965
951
  },
966
952
 
967
- parser: BasicType_parser(dataType, parseFunc),
953
+ parser: BasicType_parser<T>(dataType, parseFunc),
968
954
 
969
- finish(this: any) {
955
+ finish(this: ListOfTParser<T>) {
970
956
  this.parent.parent.obj.value = {
971
957
  arrayType: VariantArrayType.Array,
972
958
  dataType: (DataType as any)[dataType],
973
959
  value: this.listData
974
960
  };
975
961
  },
976
- endElement(this: any, element: string) {
962
+ endElement(this: ListOfTParser<T>, element: string) {
977
963
  this.listData.push(this.parser[dataType].value);
978
964
  }
979
965
  };
@@ -989,6 +975,58 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
989
975
  }
990
976
  };
991
977
  }
978
+
979
+ interface PostExtensionObjectData {
980
+ postponedExtensionObject: ExtensionObject | null;
981
+ // variant: Variant;
982
+ // nodeId: NodeId;
983
+ }
984
+ interface ExtensionObjectParser {
985
+ parent: any;
986
+ typeDefinitionId: NodeId;
987
+ extensionObject: ExtensionObject | null;
988
+ extensionObjectPojo: any | null;
989
+ postTaskData?: PostExtensionObjectData;
990
+ parser: {
991
+ Body: ExtensionObjectBodyParser;
992
+ };
993
+ }
994
+
995
+ interface ExtensionObjectTypeIdParser {
996
+ parent: ExtensionObjectParser;
997
+ }
998
+ interface ExtensionObjectTypeIdIdentifierParser {
999
+ text: string;
1000
+ parent: ExtensionObjectTypeIdParser;
1001
+ }
1002
+
1003
+ interface ExtensionObjectBodyParser {
1004
+ parent: ExtensionObjectParser;
1005
+ _cloneFragment: InternalFragmentClonerReaderState;
1006
+ bodyXML: string;
1007
+ engine: any;
1008
+ NodeSet2ParserEngine: any;
1009
+ parser: any;
1010
+ }
1011
+
1012
+ interface Parser {
1013
+ parent: Parser | any;
1014
+ }
1015
+ interface ListOfTParser<T> extends Parser {
1016
+ listData: T[];
1017
+ parent: Parser;
1018
+ parser: {
1019
+ [key: string]: Parser | any;
1020
+ };
1021
+ }
1022
+
1023
+ interface ListOfExtensionObjectParser extends ListOfTParser<ExtensionObject> {
1024
+ listExtensionObject: (ExtensionObject | null)[];
1025
+ parser: {
1026
+ ExtensionObject: ExtensionObjectParser;
1027
+ };
1028
+ }
1029
+
992
1030
  const state_Variant = {
993
1031
  init: () => {
994
1032
  /* empty */
@@ -1105,113 +1143,128 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
1105
1143
  },
1106
1144
 
1107
1145
  ListOfExtensionObject: {
1108
- init(this: any) {
1109
- this.listData = [];
1146
+ init(this: ListOfExtensionObjectParser) {
1147
+ this.listExtensionObject = [];
1110
1148
  },
1111
1149
  parser: extensionObject_parser,
1112
- finish(this: any) {
1113
- this.parent.parent.obj.value = {
1114
- arrayType: VariantArrayType.Array,
1115
- dataType: DataType.ExtensionObject,
1116
- value: this.listData
1117
- };
1150
+ finish(this: ListOfExtensionObjectParser) {
1151
+ installExtensionObjectListInitializationPostTask(this);
1118
1152
  },
1119
- startElement(this: any, elementName: string) {
1153
+ startElement(this: ListOfExtensionObjectParser, elementName: string) {
1120
1154
  /* empty */
1155
+ const extensionObjectParser = this.parser.ExtensionObject;
1156
+ extensionObjectParser.postTaskData = { postponedExtensionObject: null };
1121
1157
  },
1122
- endElement(this: any, elementName: string) {
1123
- this.listData.push(this.parser.ExtensionObject.extensionObject);
1158
+ endElement(this: ListOfExtensionObjectParser, elementName: string) {
1159
+ const extensionObjectParser = this.parser.ExtensionObject;
1124
1160
 
1125
- if (this.parser.ExtensionObject.extensionObject) {
1126
- // assert(element === "ExtensionObject");
1161
+ this.listExtensionObject.push(extensionObjectParser.extensionObject);
1162
+ if (this.parser.ExtensionObject.extensionObject === null) {
1163
+ // extension object creation will be postponed
1164
+ const index = this.listExtensionObject.length - 1;
1165
+ let capturedData = extensionObjectParser.postTaskData;
1127
1166
 
1128
1167
  // istanbul ignore next
1129
- if (!(this.parser.ExtensionObject.extensionObject instanceof ExtensionObject)) {
1130
- throw new Error("expecting an extension object");
1168
+ if (!capturedData) {
1169
+ throw new Error("Internal Error : postponedExtensionObject not resolved");
1131
1170
  }
1171
+
1172
+ let listExtensionObject = this.listExtensionObject;
1173
+ const task = async (addressSpace2: IAddressSpace) => {
1174
+ // istanbul ignore next
1175
+ if (!capturedData!.postponedExtensionObject) {
1176
+ throw new Error("Internal Error : postponedExtensionObject not resolved");
1177
+ }
1178
+ listExtensionObject[index] = capturedData!.postponedExtensionObject!;
1179
+ capturedData = undefined;
1180
+ (listExtensionObject as any) = undefined;
1181
+ };
1182
+ postTasks2_AssignedExtensionObjectToDataValue.push(task);
1132
1183
  }
1133
1184
  }
1134
1185
  },
1135
1186
 
1136
1187
  ListOfLocalizedText: {
1137
- init(this: any) {
1188
+ init(this: ListOfTParser<LocalizedTextOptions>) {
1138
1189
  this.listData = [];
1139
1190
  },
1140
1191
  parser: localizedText_parser,
1141
- finish(this: any) {
1192
+ finish(this: ListOfTParser<QualifiedNameOptions>) {
1142
1193
  this.parent.parent.obj.value = {
1143
1194
  arrayType: VariantArrayType.Array,
1144
1195
  dataType: DataType.LocalizedText,
1145
1196
  value: this.listData
1146
1197
  };
1147
1198
  },
1148
- endElement(this: any /*element*/) {
1199
+ endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
1149
1200
  this.listData.push(this.parser.LocalizedText.localizedText);
1150
1201
  }
1151
1202
  },
1152
1203
  ListOfQualifiedName: {
1153
- init(this: any) {
1204
+ init(this: ListOfTParser<QualifiedNameOptions>) {
1154
1205
  this.listData = [];
1155
1206
  },
1156
1207
  parser: qualifiedName_parser,
1157
- finish(this: any) {
1208
+ finish(this: ListOfTParser<QualifiedNameOptions>) {
1158
1209
  this.parent.parent.obj.value = {
1159
1210
  arrayType: VariantArrayType.Array,
1160
1211
  dataType: DataType.QualifiedName,
1161
1212
  value: this.listData
1162
1213
  };
1163
1214
  },
1164
- endElement(this: any /*element*/) {
1215
+ endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
1165
1216
  this.listData.push(this.parser.QualifiedName.qualifiedName);
1166
1217
  }
1167
1218
  },
1168
1219
  ListOfNodeId: {
1169
- init(this: any) {
1220
+ init(this: ListOfTParser<NodeIdLike>) {
1170
1221
  this.listData = [];
1171
1222
  },
1172
1223
  parser: nodeId_parser,
1173
- finish(this: any) {
1224
+ finish(this: ListOfTParser<NodeIdLike>) {
1174
1225
  this.parent.parent.obj.value = {
1175
1226
  arrayType: VariantArrayType.Array,
1176
1227
  dataType: DataType.NodeId,
1177
1228
  value: this.listData
1178
1229
  };
1179
1230
  },
1180
- endElement(this: any, elementName: string) {
1231
+ endElement(this: ListOfTParser<NodeIdLike>, elementName: string) {
1181
1232
  this.listData.push(this.parser.NodeId.nodeId);
1182
1233
  }
1183
1234
  },
1184
- ListOfBoolean: ListOf("Boolean", ec.coerceBoolean),
1185
- ListOfByte: ListOf("Byte", parseInt),
1186
1235
 
1187
- ListOfDouble: ListOf("Double", parseFloat),
1236
+ ListOfBoolean: ListOf<boolean>("Boolean", ec.coerceBoolean),
1237
+
1238
+ ListOfByte: ListOf<number>("Byte", parseInt),
1239
+
1240
+ ListOfDouble: ListOf<number>("Double", parseFloat),
1188
1241
 
1189
- ListOfFloat: ListOf("Float", parseFloat),
1242
+ ListOfFloat: ListOf<number>("Float", parseFloat),
1190
1243
 
1191
- ListOfInt32: ListOf("Int32", parseInt),
1244
+ ListOfInt32: ListOf<number>("Int32", parseInt),
1192
1245
 
1193
- ListOfInt16: ListOf("Int16", parseInt),
1246
+ ListOfInt16: ListOf<number>("Int16", parseInt),
1194
1247
 
1195
- ListOfInt8: ListOf("Int8", parseInt),
1248
+ ListOfInt8: ListOf<number>("Int8", parseInt),
1196
1249
 
1197
- ListOfUInt32: ListOf("UInt32", parseInt),
1250
+ ListOfUInt32: ListOf<number>("UInt32", parseInt),
1198
1251
 
1199
- ListOfUInt16: ListOf("UInt16", parseInt),
1252
+ ListOfUInt16: ListOf<number>("UInt16", parseInt),
1200
1253
 
1201
- ListOfUInt8: ListOf("UInt8", parseInt),
1254
+ ListOfUInt8: ListOf<number>("UInt8", parseInt),
1202
1255
 
1203
- ListOfString: ListOf("String", (value: string) => value),
1256
+ ListOfString: ListOf<string>("String", (value: string) => value),
1204
1257
 
1205
- ListOfXmlElement: ListOf("XmlElement", (value: string) => value),
1258
+ ListOfXmlElement: ListOf<string>("XmlElement", (value: string) => value),
1206
1259
 
1207
1260
  ExtensionObject: {
1208
- init(this: any) {
1209
- this.typeDefinitionId = {};
1261
+ init(this: ExtensionObjectParser) {
1262
+ this.typeDefinitionId = NodeId.nullNodeId;
1210
1263
  this.extensionObject = null;
1211
- this.postTaskData = {};
1264
+ this.postTaskData = { postponedExtensionObject: null };
1212
1265
  },
1213
1266
  parser: _extensionObject_inner_parser,
1214
- finish(this: any) {
1267
+ finish(this: ExtensionObjectParser) {
1215
1268
  // istanbul ignore next
1216
1269
  if (this.extensionObject && !(this.extensionObject instanceof ExtensionObject)) {
1217
1270
  throw new Error("expecting an extension object");
@@ -1220,38 +1273,63 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
1220
1273
  dataType: DataType.ExtensionObject,
1221
1274
  value: this.extensionObject
1222
1275
  };
1223
- installExtensionObjectInitializationPostTask(this);
1276
+ if (!this.extensionObject) {
1277
+ installExtensionObjectInitializationPostTask(this);
1278
+ }
1224
1279
  }
1225
1280
  }
1226
1281
  }
1227
1282
  };
1228
- function installExtensionObjectInitializationPostTask(element: {
1229
- postTaskData: any;
1230
- parent: any;
1231
- extensionObject?: ExtensionObject;
1232
- }) {
1233
- if (!element.extensionObject) {
1234
- // let's create the mechanism that postpone the creation of the
1235
- // extension object
1236
- const data = element.postTaskData;
1237
- data.variant = element.parent.parent.obj.value;
1238
- data.nodeId = element.parent.parent.obj.nodeId;
1239
- element.postTaskData = null;
1240
- const task = async (addressSpace2: IAddressSpace) => {
1241
- data.variant.value = data.postponedExtensionObject;
1242
- assert(data.nodeId, "expecting a nodeid");
1243
- const node = addressSpace2.findNode(data.nodeId)!;
1244
- if (node.nodeClass === NodeClass.Variable) {
1245
- const v = node as UAVariable;
1246
- v.setValueFromSource(data.variant);
1247
- }
1248
- if (node.nodeClass === NodeClass.VariableType) {
1249
- const v = node as UAVariableType;
1250
- (v as any) /*fix me*/.value.value = data.variant.value;
1251
- }
1252
- };
1253
- postTasks3.push(task);
1254
- }
1283
+
1284
+ function installExtensionObjectListInitializationPostTask(element: ListOfExtensionObjectParser) {
1285
+ let listExtensionObject = element.listExtensionObject;
1286
+ let nodeId = element.parent.parent.obj.nodeId;
1287
+ assert(nodeId, "expecting a nodeid");
1288
+ const task = async (addressSpace2: IAddressSpace) => {
1289
+ const node = addressSpace2.findNode(nodeId)!;
1290
+ if (!node) {
1291
+ debugLog("Cannot find node with nodeId " + nodeId + ". may be the node was marked as deprecated");
1292
+ } else if (node.nodeClass === NodeClass.Variable) {
1293
+ const v = node as UAVariable;
1294
+ v.setValueFromSource({
1295
+ dataType: DataType.ExtensionObject,
1296
+ value: listExtensionObject
1297
+ });
1298
+ } else if (node.nodeClass === NodeClass.VariableType) {
1299
+ const v = node as UAVariableType;
1300
+ (v as any) /*fix me*/.value.value = listExtensionObject;
1301
+ }
1302
+ listExtensionObject.slice(0);
1303
+ (listExtensionObject as any) = undefined;
1304
+ (nodeId as any) = undefined;
1305
+ };
1306
+ postTasks2_AssignedExtensionObjectToDataValue.push(task);
1307
+ }
1308
+
1309
+ function installExtensionObjectInitializationPostTask(element: ExtensionObjectParser) {
1310
+ // let's create the mechanism that postpone the creation of the
1311
+ // extension object
1312
+ let data = element.postTaskData!;
1313
+ let variant = element.parent.parent.obj.value;
1314
+ let nodeId = element.parent.parent.obj.nodeId;
1315
+ const task = async (addressSpace2: IAddressSpace) => {
1316
+ variant.value = data.postponedExtensionObject;
1317
+ assert(nodeId, "expecting a nodeid");
1318
+ const node = addressSpace2.findNode(nodeId)!;
1319
+ if (node.nodeClass === NodeClass.Variable) {
1320
+ const v = node as UAVariable;
1321
+ v.setValueFromSource(variant);
1322
+ } else if (node.nodeClass === NodeClass.VariableType) {
1323
+ const v = node as UAVariableType;
1324
+ (v as any) /*fix me*/.value.value = variant.value;
1325
+ }
1326
+
1327
+ data.postponedExtensionObject = null;
1328
+ (data as any) = undefined;
1329
+ (variant as any) = undefined;
1330
+ (nodeId as any) = undefined;
1331
+ };
1332
+ postTasks2_AssignedExtensionObjectToDataValue.push(task);
1255
1333
  }
1256
1334
  const state_UAVariable = {
1257
1335
  init(this: any, name: string, attrs: XmlAttributes) {
@@ -1291,38 +1369,39 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
1291
1369
  }
1292
1370
  */
1293
1371
  // eslint-disable-next-line prefer-const
1294
- let variable: UAVariable;
1372
+ let capturedVariable: UAVariable;
1295
1373
  if (this.obj.value) {
1296
- const capturedValue = this.obj.value;
1374
+ let capturedValue = this.obj.value;
1297
1375
  const task = async (addressSpace2: IAddressSpace) => {
1298
1376
  if (false && doDebug) {
1299
- debugLog("1 setting value to ", variable.nodeId.toString(), new Variant(capturedValue).toString());
1377
+ debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new Variant(capturedValue).toString());
1300
1378
  }
1301
- variable.setValueFromSource(capturedValue);
1379
+ capturedVariable.setValueFromSource(capturedValue);
1380
+ capturedValue = undefined;
1381
+ (capturedVariable as any) = undefined;
1302
1382
  };
1303
- postTaskInitializeVariable.push(task);
1383
+ postTasks1_InitializeVariable.push(task);
1304
1384
  } else {
1305
- const captureName = this.obj.browseName.toString();
1306
- const captureNodeId = this.obj.nodeId;
1307
1385
  const task = async (addressSpace2: IAddressSpace) => {
1308
- const dataTypeNode = variable.dataType;
1309
- const valueRank = variable.valueRank;
1386
+ const dataTypeNode = capturedVariable.dataType;
1387
+ const valueRank = capturedVariable.valueRank;
1310
1388
  const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
1311
1389
  if (value) {
1312
1390
  if (false && doDebug) {
1313
- debugLog("2 setting value to ", variable.nodeId.toString(), value);
1391
+ debugLog("2 setting value to ", capturedVariable.nodeId.toString(), value);
1314
1392
  }
1315
1393
  if (value.dataType === DataType.Null) {
1316
- variable.setValueFromSource(value, StatusCodes.BadWaitingForInitialData);
1394
+ capturedVariable.setValueFromSource(value, StatusCodes.BadWaitingForInitialData);
1317
1395
  } else {
1318
- variable.setValueFromSource(value, StatusCodes.Good);
1396
+ capturedVariable.setValueFromSource(value, StatusCodes.Good);
1319
1397
  }
1320
1398
  }
1399
+ (capturedVariable as any) = undefined;
1321
1400
  };
1322
- postTaskInitializeVariable.push(task);
1401
+ postTasks1_InitializeVariable.push(task);
1323
1402
  }
1324
1403
  this.obj.value = undefined;
1325
- variable = _internal_createNode(this.obj) as UAVariable;
1404
+ capturedVariable = _internal_createNode(this.obj) as UAVariable;
1326
1405
  },
1327
1406
  parser: {
1328
1407
  DisplayName: {
@@ -1596,13 +1675,13 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
1596
1675
  await task(addressSpace1);
1597
1676
  }
1598
1677
  }
1678
+ tasks.splice(0);
1599
1679
  }
1600
1680
  async function finalSteps(): Promise<void> {
1601
1681
  /// ----------------------------------------------------------------------------------------
1602
1682
  // perform post task
1603
1683
  doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------"));
1604
1684
  await performPostLoadingTasks(postTasks);
1605
- postTasks = [];
1606
1685
 
1607
1686
  doDebug && debugLog(chalk.bgGreenBright("Performing DataType extraction -------------------------------------------"));
1608
1687
  assert(!addressSpace1.suspendBackReference);
@@ -1620,23 +1699,16 @@ export function makeNodeSetParserEngine(addressSpace: IAddressSpace): NodeSet2Pa
1620
1699
  }
1621
1700
  pendingSimpleTypeToRegister.splice(0);
1622
1701
 
1623
- doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks 2 (parsing XML objects) ---------------------"));
1624
- await performPostLoadingTasks(postTasks2);
1625
- postTasks2 = [];
1702
+ doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Decoding Pojo String (parsing XML objects) -"));
1703
+ await performPostLoadingTasks(postTasks0_DecodePojoString);
1626
1704
 
1627
- doDebug && debugLog(chalk.bgGreenBright("Performing post variable initialization ---------------------"));
1628
- await performPostLoadingTasks(postTaskInitializeVariable);
1629
- postTaskInitializeVariable = [];
1705
+ doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Variables ---------------------"));
1706
+ await performPostLoadingTasks(postTasks1_InitializeVariable);
1630
1707
 
1631
- doDebug &&
1632
- debugLog(
1633
- chalk.bgGreenBright(
1634
- "Performing post loading tasks 3 (assigning Extension Object to Variables) ---------------------"
1635
- )
1636
- );
1637
- await performPostLoadingTasks(postTasks3);
1638
- postTasks3 = [];
1708
+ doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks: (assigning Extension Object to Variables) -"));
1709
+ await performPostLoadingTasks(postTasks2_AssignedExtensionObjectToDataValue);
1639
1710
 
1711
+ doDebug && debugLog(chalk.bgGreenBright("Performing post variable initialization ---------------------"));
1640
1712
  promoteObjectsAndVariables(addressSpace);
1641
1713
  }
1642
1714
  finalSteps()