node-opcua-address-space 2.136.0 → 2.138.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 (270) hide show
  1. package/dist/source/helpers/adjust_browse_direction.js +1 -2
  2. package/dist/source/helpers/adjust_browse_direction.js.map +1 -1
  3. package/dist/source/helpers/argument_list.js +6 -7
  4. package/dist/source/helpers/argument_list.js.map +1 -1
  5. package/dist/source/helpers/call_helpers.js +1 -2
  6. package/dist/source/helpers/call_helpers.js.map +1 -1
  7. package/dist/source/helpers/coerce_enum_value.js +1 -2
  8. package/dist/source/helpers/coerce_enum_value.js.map +1 -1
  9. package/dist/source/helpers/dump_tools.js +5 -6
  10. package/dist/source/helpers/dump_tools.js.map +1 -1
  11. package/dist/source/helpers/ensure_secure_access.js +1 -2
  12. package/dist/source/helpers/ensure_secure_access.js.map +1 -1
  13. package/dist/source/helpers/make_optionals_map.d.ts +1 -3
  14. package/dist/source/helpers/make_optionals_map.js +7 -4
  15. package/dist/source/helpers/make_optionals_map.js.map +1 -1
  16. package/dist/source/helpers/multiform_func.js +2 -3
  17. package/dist/source/helpers/multiform_func.js.map +1 -1
  18. package/dist/source/helpers/resolve_opaque_on_address_space.js +1 -2
  19. package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -1
  20. package/dist/source/index.d.ts +2 -0
  21. package/dist/source/index.js +2 -0
  22. package/dist/source/index.js.map +1 -1
  23. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +0 -3
  24. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +0 -2
  25. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +0 -2
  26. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js.map +1 -1
  27. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +1 -1
  28. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +1 -2
  29. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +1 -0
  30. package/dist/source/loader/decode_xml_extension_object.d.ts +1 -1
  31. package/dist/source/loader/decode_xml_extension_object.js +4 -5
  32. package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
  33. package/dist/source/loader/ensure_datatype_extracted.js +32 -4
  34. package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
  35. package/dist/source/loader/generateAddressSpaceRaw.js +3 -4
  36. package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
  37. package/dist/source/loader/load_nodeset2.js +145 -737
  38. package/dist/source/loader/load_nodeset2.js.map +1 -1
  39. package/dist/source/loader/make_semver_compatible.js +1 -2
  40. package/dist/source/loader/make_semver_compatible.js.map +1 -1
  41. package/dist/source/loader/make_xml_extension_object_parser.d.ts +1 -6
  42. package/dist/source/loader/make_xml_extension_object_parser.js +52 -73
  43. package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
  44. package/dist/source/loader/namespace_post_step.d.ts +4 -6
  45. package/dist/source/loader/namespace_post_step.js +5 -5
  46. package/dist/source/loader/namespace_post_step.js.map +1 -1
  47. package/dist/source/loader/parsers/extension_object_parser.d.ts +51 -0
  48. package/dist/source/loader/parsers/extension_object_parser.js +269 -0
  49. package/dist/source/loader/parsers/extension_object_parser.js.map +1 -0
  50. package/dist/source/loader/parsers/localized_text_parser.d.ts +25 -0
  51. package/dist/source/loader/parsers/localized_text_parser.js +30 -0
  52. package/dist/source/loader/parsers/localized_text_parser.js.map +1 -0
  53. package/dist/source/loader/parsers/nodeid_parser.d.ts +11 -0
  54. package/dist/source/loader/parsers/nodeid_parser.js +20 -0
  55. package/dist/source/loader/parsers/nodeid_parser.js.map +1 -0
  56. package/dist/source/loader/parsers/qualified_name_parser.d.ts +26 -0
  57. package/dist/source/loader/parsers/qualified_name_parser.js +35 -0
  58. package/dist/source/loader/parsers/qualified_name_parser.js.map +1 -0
  59. package/dist/source/loader/parsers/variant_parser.d.ts +29 -0
  60. package/dist/source/loader/parsers/variant_parser.js +328 -0
  61. package/dist/source/loader/parsers/variant_parser.js.map +1 -0
  62. package/dist/source/loader/register_node_promoter.js +2 -3
  63. package/dist/source/loader/register_node_promoter.js.map +1 -1
  64. package/dist/source/pseudo_session.d.ts +0 -2
  65. package/dist/source/pseudo_session.js +3 -3
  66. package/dist/source/pseudo_session.js.map +1 -1
  67. package/dist/source/session_context.d.ts +1 -1
  68. package/dist/source/session_context.js +3 -3
  69. package/dist/source/session_context.js.map +1 -1
  70. package/dist/source/set_namespace_meta_data.js +1 -2
  71. package/dist/source/set_namespace_meta_data.js.map +1 -1
  72. package/dist/source/ua_addin.d.ts +11 -0
  73. package/dist/source/ua_addin.js +42 -0
  74. package/dist/source/ua_addin.js.map +1 -0
  75. package/dist/source/ua_interface.d.ts +3 -0
  76. package/dist/source/ua_interface.js +45 -0
  77. package/dist/source/ua_interface.js.map +1 -0
  78. package/dist/source/xml_writer.d.ts +3 -5
  79. package/dist/src/_instantiate_helpers.d.ts +1 -1
  80. package/dist/src/_instantiate_helpers.js +7 -8
  81. package/dist/src/_instantiate_helpers.js.map +1 -1
  82. package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +3 -1
  83. package/dist/src/_mandatory_child_or_requested_optional_filter.js +6 -5
  84. package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
  85. package/dist/src/address_space.d.ts +1 -5
  86. package/dist/src/address_space.js +1 -1
  87. package/dist/src/address_space.js.map +1 -1
  88. package/dist/src/address_space_change_event_tools.js +3 -4
  89. package/dist/src/address_space_change_event_tools.js.map +1 -1
  90. package/dist/src/alarms_and_conditions/condition.d.ts +4 -7
  91. package/dist/src/alarms_and_conditions/condition.js +1 -25
  92. package/dist/src/alarms_and_conditions/condition.js.map +1 -1
  93. package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +2 -20
  94. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +211 -234
  95. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
  96. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +4 -5
  97. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -1
  98. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +0 -2
  99. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +1 -2
  100. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
  101. package/dist/src/alarms_and_conditions/ua_base_event_impl.js.map +1 -1
  102. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +0 -2
  103. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +3 -3
  104. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  105. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +0 -2
  106. package/dist/src/alarms_and_conditions/ua_condition_impl.js +10 -12
  107. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  108. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -1
  109. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js.map +1 -1
  110. package/dist/src/apply_condition_refresh.d.ts +1 -3
  111. package/dist/src/apply_condition_refresh.js +4 -5
  112. package/dist/src/apply_condition_refresh.js.map +1 -1
  113. package/dist/src/base_node_impl.d.ts +0 -1
  114. package/dist/src/base_node_impl.js +11 -11
  115. package/dist/src/base_node_impl.js.map +1 -1
  116. package/dist/src/base_node_private.d.ts +4 -7
  117. package/dist/src/base_node_private.js +23 -25
  118. package/dist/src/base_node_private.js.map +1 -1
  119. package/dist/src/check_value_rank_compatibility.js +1 -2
  120. package/dist/src/check_value_rank_compatibility.js.map +1 -1
  121. package/dist/src/data_access/add_dataItem_stuff.js +1 -2
  122. package/dist/src/data_access/add_dataItem_stuff.js.map +1 -1
  123. package/dist/src/data_access/adjust_datavalue_status_code.js +1 -2
  124. package/dist/src/data_access/adjust_datavalue_status_code.js.map +1 -1
  125. package/dist/src/data_access/ua_multistate_discrete_impl.js +3 -3
  126. package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -1
  127. package/dist/src/data_access/ua_multistate_value_discrete_impl.js +5 -5
  128. package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -1
  129. package/dist/src/data_access/ua_two_state_discrete_impl.js +3 -3
  130. package/dist/src/data_access/ua_two_state_discrete_impl.js.map +1 -1
  131. package/dist/src/extension_object_array_node.js +4 -5
  132. package/dist/src/extension_object_array_node.js.map +1 -1
  133. package/dist/src/get_basic_datatype.js +2 -3
  134. package/dist/src/get_basic_datatype.js.map +1 -1
  135. package/dist/src/historical_access/address_space_historical_data_node.js +5 -5
  136. package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
  137. package/dist/src/index_current.d.ts +3 -1
  138. package/dist/src/index_current.js +3 -1
  139. package/dist/src/index_current.js.map +1 -1
  140. package/dist/src/namespace_impl.d.ts +1 -9
  141. package/dist/src/namespace_impl.js +19 -12
  142. package/dist/src/namespace_impl.js.map +1 -1
  143. package/dist/src/namespace_private.js +1 -2
  144. package/dist/src/namespace_private.js.map +1 -1
  145. package/dist/src/nodeid_manager.js +35 -10
  146. package/dist/src/nodeid_manager.js.map +1 -1
  147. package/dist/src/nodeset_tools/adjust_namespace_array.js +1 -2
  148. package/dist/src/nodeset_tools/adjust_namespace_array.js.map +1 -1
  149. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +2 -2
  150. package/dist/src/nodeset_tools/construct_namespace_dependency.js +12 -12
  151. package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
  152. package/dist/src/nodeset_tools/dump_to_bsd.js +5 -6
  153. package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -1
  154. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +1 -1
  155. package/dist/src/nodeset_tools/nodeset_to_xml.js +53 -46
  156. package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
  157. package/dist/src/private_namespace.js +4 -5
  158. package/dist/src/private_namespace.js.map +1 -1
  159. package/dist/src/reference_impl.js +4 -4
  160. package/dist/src/reference_impl.js.map +1 -1
  161. package/dist/src/role_permissions.js +1 -2
  162. package/dist/src/role_permissions.js.map +1 -1
  163. package/dist/src/state_machine/finite_state_machine.js +6 -6
  164. package/dist/src/state_machine/finite_state_machine.js.map +1 -1
  165. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +0 -1
  166. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +2 -2
  167. package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
  168. package/dist/src/state_machine/ua_two_state_variable.js +4 -4
  169. package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
  170. package/dist/src/tool_isSubtypeOf.d.ts +1 -1
  171. package/dist/src/tool_isSubtypeOf.js +18 -16
  172. package/dist/src/tool_isSubtypeOf.js.map +1 -1
  173. package/dist/src/ua_addin.d.ts +11 -0
  174. package/dist/src/ua_addin.js +43 -0
  175. package/dist/src/ua_addin.js.map +1 -0
  176. package/dist/src/ua_data_type_impl.js +7 -6
  177. package/dist/src/ua_data_type_impl.js.map +1 -1
  178. package/dist/src/ua_object_type_impl.d.ts +1 -0
  179. package/dist/src/ua_object_type_impl.js +4 -1
  180. package/dist/src/ua_object_type_impl.js.map +1 -1
  181. package/dist/src/ua_reference_type_impl.js +3 -3
  182. package/dist/src/ua_reference_type_impl.js.map +1 -1
  183. package/dist/src/ua_variable_impl.js +6 -3
  184. package/dist/src/ua_variable_impl.js.map +1 -1
  185. package/dist/src/ua_variable_impl_ext_obj.js +15 -15
  186. package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
  187. package/dist/src/ua_variable_type_impl.d.ts +2 -0
  188. package/dist/src/ua_variable_type_impl.js +8 -4
  189. package/dist/src/ua_variable_type_impl.js.map +1 -1
  190. package/dist/src/validate_data_type_correctness.js +1 -2
  191. package/dist/src/validate_data_type_correctness.js.map +1 -1
  192. package/dist/tsconfig_common.tsbuildinfo +1 -1
  193. package/distHelpers/add_event_generator_object.js +1 -2
  194. package/distHelpers/add_event_generator_object.js.map +1 -1
  195. package/distHelpers/alarms_and_conditions_demo.js +1 -2
  196. package/distHelpers/alarms_and_conditions_demo.js.map +1 -1
  197. package/distHelpers/assertHasMatchingReference.js +1 -2
  198. package/distHelpers/assertHasMatchingReference.js.map +1 -1
  199. package/distHelpers/boiler_system.js +2 -3
  200. package/distHelpers/boiler_system.js.map +1 -1
  201. package/distHelpers/create_minimalist_address_space_nodeset.js +1 -2
  202. package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -1
  203. package/distHelpers/date_utils.js +1 -2
  204. package/distHelpers/date_utils.js.map +1 -1
  205. package/distHelpers/get_address_space_fixture.js +1 -2
  206. package/distHelpers/get_address_space_fixture.js.map +1 -1
  207. package/distHelpers/get_mini_address_space.js +2 -2
  208. package/distHelpers/get_mini_address_space.js.map +1 -1
  209. package/distNodeJS/generate_address_space.js +2 -3
  210. package/distNodeJS/generate_address_space.js.map +1 -1
  211. package/package.json +24 -24
  212. package/source/helpers/make_optionals_map.ts +9 -6
  213. package/source/index.ts +3 -0
  214. package/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.ts +3 -1
  215. package/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.ts +3 -1
  216. package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.ts +3 -1
  217. package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.ts +3 -1
  218. package/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.ts +3 -1
  219. package/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.ts +18 -16
  220. package/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.ts +5 -3
  221. package/source/interfaces/data_access/ua_multistate_discrete_ex.ts +4 -2
  222. package/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.ts +4 -2
  223. package/source/interfaces/state_machine/ua_program_state_machine_type.ts +3 -1
  224. package/source/interfaces/state_machine/ua_shelved_state_machine_ex.ts +1 -1
  225. package/source/interfaces/state_machine/ua_state_machine_type.ts +14 -7
  226. package/source/loader/decode_xml_extension_object.ts +4 -3
  227. package/source/loader/ensure_datatype_extracted.ts +38 -2
  228. package/source/loader/generateAddressSpaceRaw.ts +4 -4
  229. package/source/loader/load_nodeset2.ts +212 -901
  230. package/source/loader/make_xml_extension_object_parser.ts +87 -123
  231. package/source/loader/namespace_post_step.ts +6 -5
  232. package/source/loader/parsers/extension_object_parser.ts +364 -0
  233. package/source/loader/parsers/localized_text_parser.ts +34 -0
  234. package/source/loader/parsers/nodeid_parser.ts +17 -0
  235. package/source/loader/parsers/qualified_name_parser.ts +43 -0
  236. package/source/loader/parsers/variant_parser.ts +427 -0
  237. package/source/loader/register_node_promoter.ts +2 -5
  238. package/source/session_context.ts +1 -1
  239. package/source/ua_addin.ts +53 -0
  240. package/source/ua_interface.ts +49 -0
  241. package/source/xml_writer.ts +4 -5
  242. package/src/_instantiate_helpers.ts +9 -3
  243. package/src/_mandatory_child_or_requested_optional_filter.ts +9 -7
  244. package/src/address_space.ts +1 -1
  245. package/src/alarms_and_conditions/condition.ts +0 -32
  246. package/src/alarms_and_conditions/condition_snapshot_impl.ts +176 -189
  247. package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +1 -3
  248. package/src/alarms_and_conditions/ua_base_event_impl.ts +6 -2
  249. package/src/alarms_and_conditions/ua_condition_impl.ts +11 -13
  250. package/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.ts +3 -1
  251. package/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.ts +3 -1
  252. package/src/apply_condition_refresh.ts +4 -4
  253. package/src/base_node_impl.ts +13 -13
  254. package/src/base_node_private.ts +6 -11
  255. package/src/data_access/ua_multistate_value_discrete_impl.ts +1 -1
  256. package/src/historical_access/address_space_historical_data_node.ts +3 -3
  257. package/src/index_current.ts +4 -1
  258. package/src/namespace_impl.ts +21 -10
  259. package/src/nodeid_manager.ts +46 -17
  260. package/src/nodeset_tools/construct_namespace_dependency.ts +9 -8
  261. package/src/nodeset_tools/dump_to_bsd.ts +7 -7
  262. package/src/nodeset_tools/nodeset_to_xml.ts +70 -44
  263. package/src/private_namespace.ts +2 -1
  264. package/src/tool_isSubtypeOf.ts +20 -16
  265. package/src/ua_data_type_impl.ts +5 -4
  266. package/src/ua_object_type_impl.ts +7 -2
  267. package/src/ua_reference_type_impl.ts +6 -6
  268. package/src/ua_variable_impl.ts +4 -0
  269. package/src/ua_variable_impl_ext_obj.ts +2 -1
  270. package/src/ua_variable_type_impl.ts +11 -1
@@ -18,31 +18,24 @@ import {
18
18
  UAVariableType
19
19
  } from "node-opcua-address-space-base";
20
20
  import { assert, renderError } from "node-opcua-assert";
21
- import { coerceInt64, coerceUInt64, Int64, isValidGuid, StatusCodes, UInt64 } from "node-opcua-basic-types";
22
- import { EUInformation } from "node-opcua-data-access";
21
+ import { StatusCodes } from "node-opcua-basic-types";
23
22
  import {
24
23
  AccessLevelFlag,
25
24
  coerceLocalizedText,
26
- LocalizedTextOptions,
25
+ LocalizedText,
27
26
  makeAccessLevelFlag,
28
27
  NodeClass,
29
28
  QualifiedName,
30
- QualifiedNameOptions,
31
29
  stringToQualifiedName
32
30
  } from "node-opcua-data-model";
33
31
  import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
34
- import { ExtensionObject } from "node-opcua-extension-object";
35
32
  import { getBuiltInType } from "node-opcua-factory";
36
- import { NodeId, NodeIdLike, resolveNodeId } from "node-opcua-nodeid";
37
- import { Argument } from "node-opcua-service-call";
33
+ import { NodeId, resolveNodeId } from "node-opcua-nodeid";
38
34
  import { ErrorCallback } from "node-opcua-status-code";
39
- import { EnumFieldOptions, EnumValueType, Range, StructureFieldOptions } from "node-opcua-types";
40
- import { DataType, Variant, VariantArrayType, VariantOptions } from "node-opcua-variant";
35
+ import { EnumFieldOptions, StructureFieldOptions } from "node-opcua-types";
36
+ import { DataType, Variant, VariantArrayType, VariantOptions, VariantOptionsT } from "node-opcua-variant";
41
37
  import {
42
38
  _definitionParser,
43
- FragmentClonerParser,
44
- InternalFragmentClonerReaderState,
45
- ParserLike,
46
39
  ReaderState,
47
40
  ReaderStateParserLike,
48
41
  Xml2Json,
@@ -56,8 +49,9 @@ import { NamespacePrivate } from "../../src/namespace_private";
56
49
  import { NodeSetLoaderOptions } from "../interfaces/nodeset_loader_options";
57
50
  import { promoteObjectsAndVariables } from "./namespace_post_step";
58
51
  import { ensureDatatypeExtracted } from "./ensure_datatype_extracted";
59
- import { decodeXmlExtensionObject } from "./decode_xml_extension_object";
60
52
  import { makeSemverCompatible } from "./make_semver_compatible";
53
+ import { makeVariantReader } from "./parsers/variant_parser";
54
+ import { ExtensionObject } from "node-opcua-extension-object";
61
55
 
62
56
  const doDebug = checkDebugFlag(__filename);
63
57
  const debugLog = make_debugLog(__filename);
@@ -91,7 +85,12 @@ function convertAccessLevel(accessLevel?: string | null): AccessLevelFlag {
91
85
 
92
86
  type Task = (addressSpace: IAddressSpace) => Promise<void>;
93
87
 
94
- function makeDefaultVariant(addressSpace: IAddressSpace, dataTypeNode: NodeId, valueRank: number, arrayDimensions?: number[] |null): VariantOptions | undefined {
88
+ function makeDefaultVariant(
89
+ addressSpace: IAddressSpace,
90
+ dataTypeNode: NodeId,
91
+ valueRank: number,
92
+ arrayDimensions?: number[] | null
93
+ ): VariantOptions | undefined {
95
94
  let variant: VariantOptions = { dataType: DataType.Null };
96
95
 
97
96
  const nodeDataType = addressSpace.findNode(dataTypeNode) as UADataType;
@@ -160,7 +159,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
160
159
  const postTasks1_InitializeVariable: Task[] = [];
161
160
  const postTasks2_AssignedExtensionObjectToDataValue: Task[] = [];
162
161
 
163
- let alias_map: { [key: string]: NodeId } = {};
162
+ let aliasMap: Map<string, NodeId> = new Map();
164
163
 
165
164
  /**
166
165
  * @param aliasName
@@ -169,33 +168,32 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
169
168
  assert(typeof nodeIdInXmlContext === "string");
170
169
  const nodeId = _translateNodeId(nodeIdInXmlContext);
171
170
  assert(nodeId instanceof NodeId);
172
- alias_map[aliasName] = nodeId;
171
+ aliasMap.set(aliasName, nodeId);
173
172
  addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
174
173
  }
175
174
 
176
- let namespace_uri_translation: { [key: number]: number } = {};
175
+ let namespaceUriTranslationMap: Map<number, number> = new Map();
177
176
  let namespaceCounter = 0;
178
- let found_namespace_in_uri: { [key: string]: NamespacePrivate } = {};
177
+ let foundNamespaceMap: Map<string, NamespacePrivate> = new Map();
179
178
  let models: Model[] = [];
180
179
  let performedCalled = false;
181
180
 
182
181
  function _reset_namespace_translation() {
183
182
  debugLog("_reset_namespace_translation");
184
- namespace_uri_translation = {};
185
- found_namespace_in_uri = {};
183
+ namespaceUriTranslationMap.clear();
184
+ foundNamespaceMap.clear();
186
185
  namespaceCounter = 0;
187
- alias_map = {};
186
+ aliasMap.clear();
188
187
  models = [];
189
188
  performedCalled = false;
190
189
  }
191
190
 
192
191
  function _translateNamespaceIndex(innerIndex: number) {
193
- const namespaceIndex = namespace_uri_translation[innerIndex];
192
+ const namespaceIndex = namespaceUriTranslationMap.get(innerIndex);
194
193
 
195
194
  // istanbul ignore next
196
195
  if (namespaceIndex === undefined) {
197
- errorLog("Warning: namespace_uri_translation = ", namespace_uri_translation);
198
- errorLog("Error; namespace_uri_translation", namespace_uri_translation);
196
+ errorLog("Error; namespace_uri_translation", namespaceUriTranslationMap.entries());
199
197
  throw new Error("_translateNamespaceIndex() ! Cannot find namespace definition for index " + innerIndex);
200
198
  }
201
199
  return namespaceIndex;
@@ -222,7 +220,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
222
220
  }
223
221
 
224
222
  function _register_namespace_uri_in_translation_table(namespaceUri: string): void {
225
- if (found_namespace_in_uri[namespaceUri]) {
223
+ if (foundNamespaceMap.has(namespaceUri)) {
226
224
  return;
227
225
  }
228
226
  const namespace = addressSpace1.getNamespace(namespaceUri);
@@ -231,15 +229,15 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
231
229
  if (!namespace) {
232
230
  throw new Error(
233
231
  "cannot find namespace for " +
234
- namespaceUri +
235
- "\nplease make sure to initialize your address space with the corresponding nodeset files"
232
+ namespaceUri +
233
+ "\nplease make sure to initialize your address space with the corresponding nodeset files"
236
234
  );
237
235
  }
238
- found_namespace_in_uri[namespaceUri] = namespace;
236
+ foundNamespaceMap.set(namespaceUri, namespace);
239
237
 
240
238
  const index_in_xml = namespaceCounter;
241
239
  namespaceCounter++;
242
- namespace_uri_translation[index_in_xml] = namespace.index;
240
+ namespaceUriTranslationMap.set(index_in_xml, namespace.index);
243
241
 
244
242
  doDebug &&
245
243
  debugLog(
@@ -320,8 +318,10 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
320
318
  const reg = /ns=([0-9]+);(.*)/;
321
319
 
322
320
  function _translateNodeId(nodeId: string): NodeId {
323
- if (alias_map[nodeId]) {
324
- return alias_map[nodeId];
321
+ if (aliasMap.has(nodeId)) {
322
+ // note alias are already translated to the right namespaces
323
+ const aliasedNodeId = aliasMap.get(nodeId)!;
324
+ return aliasedNodeId;
325
325
  }
326
326
  const m = nodeId.match(reg);
327
327
  if (m) {
@@ -385,18 +385,19 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
385
385
  }
386
386
  }
387
387
  };
388
-
388
+ // #region UAObject
389
389
  const state_UAObject = {
390
390
  init(this: any, name: string, attrs: XmlAttributes) {
391
391
  _perform();
392
392
 
393
- this.obj = {};
394
- this.obj.nodeClass = NodeClass.Object;
395
- this.obj.isAbstract = coerceBoolean(attrs.IsAbstract);
396
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
397
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
398
- this.obj.eventNotifier = coerceByte(attrs.EventNotifier) || 0;
399
- this.obj.symbolicName = attrs.SymbolicName || null;
393
+ this.obj = {
394
+ nodeClass: NodeClass.Object,
395
+ isAbstract: coerceBoolean(attrs.IsAbstract),
396
+ nodeId: convertToNodeId(attrs.NodeId) || null,
397
+ browseName: convertQualifiedName(attrs.BrowseName),
398
+ eventNotifier: coerceByte(attrs.EventNotifier) || 0,
399
+ symbolicName: attrs.SymbolicName || null
400
+ };
400
401
 
401
402
  this.isDraft = attrs.ReleaseStatus === "Draft";
402
403
  this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
@@ -423,17 +424,19 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
423
424
  References: references_parser
424
425
  }
425
426
  };
426
-
427
+ // #endregion
428
+ // #region UAObjectType
427
429
  const state_UAObjectType = {
428
430
  init(this: any, name: string, attrs: XmlAttributes) {
429
431
  _perform();
430
432
 
431
- this.obj = {};
432
- this.obj.nodeClass = NodeClass.ObjectType;
433
- this.obj.isAbstract = coerceBoolean(attrs.IsAbstract);
434
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
435
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
436
- this.obj.eventNotifier = coerceByte(attrs.EventNotifier) || 0;
433
+ this.obj = {
434
+ nodeClass: NodeClass.ObjectType,
435
+ isAbstract: coerceBoolean(attrs.IsAbstract),
436
+ nodeId: convertToNodeId(attrs.NodeId) || null,
437
+ browseName: convertQualifiedName(attrs.BrowseName),
438
+ eventNotifier: coerceByte(attrs.EventNotifier) || 0
439
+ };
437
440
  },
438
441
  finish(this: any) {
439
442
  _internal_createNode(this.obj);
@@ -454,16 +457,18 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
454
457
  References: references_parser
455
458
  }
456
459
  };
457
-
460
+ // #endregion
461
+ // #region UAReferenceType
458
462
  const state_UAReferenceType = {
459
463
  init(this: any, name: string, attrs: XmlAttributes) {
460
464
  _perform();
461
465
 
462
- this.obj = {};
463
- this.obj.nodeClass = NodeClass.ReferenceType;
464
- this.obj.isAbstract = coerceBoolean(attrs.IsAbstract);
465
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
466
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
466
+ this.obj = {
467
+ nodeClass: NodeClass.ReferenceType,
468
+ isAbstract: coerceBoolean(attrs.IsAbstract),
469
+ nodeId: convertToNodeId(attrs.NodeId) || null,
470
+ browseName: convertQualifiedName(attrs.BrowseName)
471
+ };
467
472
  },
468
473
  finish(this: any) {
469
474
  _internal_addReferenceType(this.obj);
@@ -489,21 +494,22 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
489
494
  References: references_parser
490
495
  }
491
496
  };
492
-
497
+ // #endregion
498
+ // #region UADataType
493
499
  const pendingSimpleTypeToRegister: any[] = [];
494
-
495
500
  const state_UADataType = {
496
501
  init(this: any, name: string, attrs: XmlAttributes) {
497
502
  _perform();
498
503
 
499
- this.obj = {};
500
- this.obj.nodeClass = NodeClass.DataType;
501
- this.obj.isAbstract = coerceBoolean(attrs.IsAbstract) || false;
502
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
503
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
504
- this.obj.displayName = "";
505
- this.obj.description = "";
506
- this.obj.symbolicName = attrs.SymbolicName;
504
+ this.obj = {
505
+ nodeClass: NodeClass.DataType,
506
+ isAbstract: coerceBoolean(attrs.IsAbstract) || false,
507
+ nodeId: convertToNodeId(attrs.NodeId) || null,
508
+ browseName: convertQualifiedName(attrs.BrowseName),
509
+ displayName: "",
510
+ description: "",
511
+ symbolicName: attrs.SymbolicName
512
+ };
507
513
 
508
514
  this.isDraft = attrs.ReleaseStatus === "Draft";
509
515
  this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
@@ -562,815 +568,91 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
562
568
  Definition: _definitionParser
563
569
  }
564
570
  };
565
-
566
- const localizedText_parser = {
567
- LocalizedText: {
568
- init(this: any) {
569
- this.localizedText = {};
570
- },
571
- parser: {
572
- Locale: {
573
- finish(this: any) {
574
- this.parent.localizedText.locale = this.text.trim();
575
- }
576
- },
577
- Text: {
578
- finish(this: any) {
579
- this.parent.localizedText.text = this.text.trim();
580
- }
581
- }
582
- }
583
- }
584
- };
585
- interface QualifiedNameParserChild {
586
- parent: {
587
- qualifiedName: QualifiedNameOptions;
588
- };
589
- text: string;
590
- }
591
- const qualifiedName_parser = {
592
- QualifiedName: {
593
- init(this: any) {
594
- this.qualifiedName = {
595
- namespaceIndex: 0,
596
- name: null
597
- } as QualifiedNameOptions;
598
- },
599
- parser: {
600
- Name: {
601
- finish(this: QualifiedNameParserChild) {
602
- this.parent.qualifiedName.name = this.text.trim();
603
- }
604
- },
605
- NamespaceIndex: {
606
- finish(this: QualifiedNameParserChild) {
607
- const ns = parseInt(this.text, 10);
608
- const t = _translateNodeId(resolveNodeId(`ns=${ns};i=1`).toString());
609
- this.parent.qualifiedName.namespaceIndex = t.namespace;
610
- }
611
- }
612
- }
613
- }
614
- };
615
- const nodeId_parser = {
616
- NodeId: {
617
- init(this: any) {
618
- this.nodeId = "";
619
- },
620
- parser: {
621
- Identifier: {
622
- finish(this: any) {
623
- this.parent.nodeId = _translateNodeId(resolveNodeId(this.text.trim()).toString());
624
- }
625
- }
626
- }
627
- }
628
- };
629
- const enumValueType_parser = {
630
- EnumValueType: {
631
- init(this: any) {
632
- this.enumValueType = new EnumValueType({
633
- description: undefined,
634
- displayName: undefined,
635
- value: coerceInt64(-1)
636
- });
637
- },
638
- parser: {
639
- Value: {
640
- // note: Value may be missing, in this case value shall be set to -1(64)
641
- finish(this: any) {
642
- // Low part
643
- this.parent.enumValueType.value = coerceInt64(parseInt(this.text, 10));
644
- }
645
- },
646
-
647
- DisplayName: {
648
- ...localizedText_parser.LocalizedText,
649
- finish(this: any) {
650
- this.parent.enumValueType.displayName = { ...this.localizedText };
651
- }
652
- },
653
-
654
- Description: {
655
- ...localizedText_parser.LocalizedText,
656
- finish(this: any) {
657
- this.parent.enumValueType.description = { ...this.localizedText };
658
- }
659
- }
660
- },
661
- finish(this: any) {
662
- this.enumValueType = new EnumValueType(this.enumValueType);
663
- }
664
- }
665
- };
666
-
667
- const argument_parser = {
668
- Argument: {
669
- init(this: any) {
670
- this.argument = new Argument({});
671
- },
672
- parser: {
673
- Name: {
674
- finish(this: any) {
675
- this.parent.argument.name = this.text.trim();
676
- }
677
- },
678
-
679
- DataType: {
680
- parser: {
681
- Identifier: {
682
- finish(this: any) {
683
- this.parent.parent.argument.dataType = _translateNodeId(resolveNodeId(this.text.trim()).toString());
684
- }
685
- }
686
- }
687
- },
688
- ValueRank: {
689
- finish(this: any) {
690
- this.parent.argument.valueRank = parseInt(this.text.trim(), 10);
691
- }
692
- },
693
-
694
- ArrayDimensions: {
695
- finish(this: any) {
696
- // xx this.parent.argument.arrayDimensions =[];
697
- }
698
- },
699
- Description: {
700
- init(this: any) {
701
- this._text = "";
702
- this.locale = null;
703
- this.text = null;
704
- },
705
- parser: {
706
- Locale: {
707
- init(this: any) {
708
- this.text = "";
709
- },
710
- finish(this: any) {
711
- this.parent.locale = this.text.trim();
712
- }
713
- },
714
- Text: {
715
- finish(this: any) {
716
- this.text = this.text || "";
717
- this.parent._text = this.text.trim();
718
- }
719
- }
720
- },
721
- finish(this: any) {
722
- this.parent.argument.description = coerceLocalizedText(this._text);
723
- }
724
- }
725
- },
726
- finish(this: any) {
727
- // xx this.argument = new Argument(this.argument);
728
- }
729
- }
730
- };
731
-
732
- const Range_parser = {
733
- Range: {
734
- init(this: any) {
735
- this.range = new Range({});
736
- },
737
- parser: {
738
- Low: {
739
- finish(this: any) {
740
- this.parent.range.low = parseFloat(this.text);
741
- }
742
- },
743
-
744
- High: {
745
- finish(this: any) {
746
- this.parent.range.high = parseFloat(this.text);
747
- }
748
- }
749
- }
750
- }
751
- };
752
-
753
- const EUInformation_parser = {
754
- EUInformation: {
755
- init(this: any) {
756
- this.euInformation = new EUInformation({});
757
- },
758
- parser: {
759
- NamespaceUri: {
760
- finish(this: any) {
761
- this.parent.euInformation.namespaceUri = this.text;
762
- }
763
- },
764
- UnitId: {
765
- finish(this: any) {
766
- this.parent.euInformation.unitId = parseInt(this.text, 10);
767
- }
768
- },
769
-
770
- DisplayName: {
771
- ...localizedText_parser.LocalizedText,
772
- finish(this: any) {
773
- this.parent.euInformation.displayName = { ...this.localizedText };
774
- }
775
- },
776
-
777
- Description: {
778
- ...localizedText_parser.LocalizedText,
779
- finish(this: any) {
780
- this.parent.euInformation.description = { ...this.localizedText };
781
- }
782
- }
783
- },
784
- finish(this: any) {
785
- this.euInformation = new EUInformation(this.euInformation);
786
- }
787
- }
788
- };
789
-
790
- const _extensionObject_inner_parser = {
791
- TypeId: {
792
- parser: {
793
- Identifier: {
794
- finish(this: ExtensionObjectTypeIdIdentifierParser) {
795
- const typeDefinitionId = this.text.trim();
796
- const self = this.parent.parent; // ExtensionObject
797
- self.typeDefinitionId = resolveNodeId(typeDefinitionId);
798
- }
799
- }
800
- }
801
- },
802
-
803
- Body2: new FragmentClonerParser(),
804
-
805
- Body: {
806
- parser: {
807
- Argument: argument_parser.Argument,
808
- EUInformation: EUInformation_parser.EUInformation,
809
- EnumValueType: enumValueType_parser.EnumValueType,
810
- Range: Range_parser.Range
811
- },
812
- startElement(this: ExtensionObjectBodyParser, elementName: string, attrs: any) {
813
- const self = this.parent; // ExtensionObject
814
- self.extensionObject = null;
815
- self.extensionObjectPojo = null;
816
-
817
- if (!Object.prototype.hasOwnProperty.call(this.parser, elementName)) {
818
- // treat it as a opaque XML bloc for the time being
819
- // until we find the definition of this object, so we know how to interpret the fields
820
- this._cloneFragment = new InternalFragmentClonerReaderState();
821
- this.engine!._promote(this._cloneFragment, this.engine!.currentLevel, elementName, attrs);
822
- }
823
- },
824
- finish(this: ExtensionObjectBodyParser) {
825
- const self = this.parent; // ExtensionObject
826
-
827
- // typeDefinitionId is also the "Default XML" encoding nodeId !
828
- switch (self.typeDefinitionId.toString()) {
829
- case "i=7616": // EnumValueType
830
- case "ns=0;i=7616": // EnumValueType
831
- self.extensionObject = self.parser.Body.parser.EnumValueType.enumValueType;
832
- assert(self.extensionObject !== null && typeof self.extensionObject === "object");
833
- assert(self.extensionObject instanceof ExtensionObject);
834
- break;
835
- case "i=297": // Arguments
836
- case "ns=0;i=297": // Arguments
837
- self.extensionObject = self.parser.Body.parser.Argument.argument;
838
- assert(self.extensionObject !== null && typeof self.extensionObject === "object");
839
- assert(self.extensionObject instanceof ExtensionObject);
840
- break;
841
- case "i=888":
842
- case "ns=0;i=888": // EUInformation
843
- self.extensionObject = self.parser.Body.parser.EUInformation.euInformation;
844
- assert(self.extensionObject !== null && typeof self.extensionObject === "object");
845
- assert(self.extensionObject instanceof ExtensionObject);
846
- break;
847
- case "i=885": // Range
848
- case "ns=0;i=885":
849
- self.extensionObject = self.parser.Body.parser.Range.range;
850
- assert(self.extensionObject !== null && typeof self.extensionObject === "object");
851
- assert(self.extensionObject instanceof ExtensionObject);
852
- break;
853
- default: {
854
- // istanbul ignore next
855
- if (!this._cloneFragment) {
856
- // the XML file is probably not exposing standard UA extension object correctly.
857
- // this has been seen in some generated xml files using the dataType nodeId instead of the default encoding
858
- // nodeid
859
- errorLog(
860
- "[NODE-OPCUA-E12] standard OPCUA Extension object from (namespace=0) has a invalid TypeId",
861
- self.typeDefinitionId.toString()
862
- );
863
- break;
864
- }
865
- this.bodyXML = this._cloneFragment!.value;
866
- this._cloneFragment!.value = null;
867
-
868
- // the "Default Xml" encoding nodeId
869
- const xmlEncodingNodeId = _translateNodeId(self.typeDefinitionId.toString());
870
-
871
- if (xmlEncodingNodeId.isEmpty()) {
872
- debugLog("xmlEncodingNodeId is empty for " + self.typeDefinitionId.toString());
873
- break;
874
- }
875
- let captureXmlBody = this.bodyXML;
876
- // istanbul ignore next
877
- if (doDebug) {
878
- debugLog("xxxx ", chalk.yellow(captureXmlBody));
879
- }
880
- // this is a user defined Extension Object
881
- // istanbul ignore next
882
- debugLog(
883
- "load nodeset2: typeDefinitionId in ExtensionObject Default XML = " + xmlEncodingNodeId.toString()
884
- );
885
-
886
- let captured = self.postTaskData;
887
- self.extensionObjectPojo = null;
888
- const task = async (addressSpace2: IAddressSpace) => {
889
- const extensionObject: ExtensionObject | null = await decodeXmlExtensionObject(
890
- addressSpace2,
891
- xmlEncodingNodeId,
892
- captureXmlBody
893
- );
894
- if (captured) {
895
- captured.postponedExtensionObject = extensionObject;
896
- }
897
- (captureXmlBody as any) = undefined;
898
- (captured as any) = undefined;
899
- };
900
- postTasks0_DecodePojoString.push(task);
901
- assert(!self.extensionObject || self.extensionObject instanceof ExtensionObject);
902
-
903
- break;
904
- }
905
- }
906
- }
907
- }
908
- };
909
-
910
- const extensionObject_parser = {
911
- ExtensionObject: {
912
- init(this: ExtensionObjectParser) {
913
- this.typeDefinitionId = NodeId.nullNodeId;
914
- this.extensionObject = null;
915
- this.extensionObjectPojo = null;
916
- this.postTaskData = { postponedExtensionObject: null };
917
- },
918
- parser: _extensionObject_inner_parser,
919
- finish(this: ExtensionObjectParser) {
920
- /* empty */
921
- }
571
+ // #endregion
572
+ const canIngore = (
573
+ { isDraft, isDeprecated }: { isDraft: boolean; isDeprecated: boolean },
574
+ node: { browseName: QualifiedName; nodeClass: NodeClass }
575
+ ) => {
576
+ if (isDraft && !options.loadDraftNodes) {
577
+ debugLog("Ignoring Draft =", NodeClass[node.nodeClass], node.browseName.toString());
578
+ return true;
922
579
  }
923
- };
924
-
925
- function BasicType_parser<T>(dataType: string, parseFunc: (this: { value: T | undefined }, text: string) => any): ParserLike {
926
- const _parser: ParserLike = {};
927
-
928
- const r: ReaderStateParserLike = {
929
- init(this: { value: T | undefined }, name: string, attrs: XmlAttributes) {
930
- this.value = undefined;
931
- },
932
-
933
- finish(this: { value: T | undefined; text: string }) {
934
- this.value = parseFunc.call(this, this.text);
935
- }
936
- };
937
- _parser[dataType] = r;
938
- return _parser;
939
- }
940
-
941
- function ListOf<T>(dataType: string, parseFunc: any) {
942
- return {
943
- init(this: ListOfTParser<T>) {
944
- this.listData = [];
945
- },
946
-
947
- parser: BasicType_parser<T>(dataType, parseFunc),
948
-
949
- finish(this: ListOfTParser<T>) {
950
- this.parent.parent.obj.value = {
951
- arrayType: VariantArrayType.Array,
952
- dataType: (DataType as any)[dataType],
953
- value: this.listData
954
- };
955
- },
956
- endElement(this: ListOfTParser<T>, element: string) {
957
- this.listData.push(this.parser[dataType].value);
958
- }
959
- };
960
- }
961
-
962
- function parser2(type: string, p: (a: any) => any): any {
963
- return {
964
- finish(this: any) {
965
- this.parent.parent.obj.value = {
966
- arrayType: VariantArrayType.Scalar,
967
- dataType: (DataType as any)[type],
968
- value: p(this.text)
969
- };
970
- }
971
- };
972
- }
973
-
974
- interface PostExtensionObjectData {
975
- postponedExtensionObject: ExtensionObject | null;
976
- // variant: Variant;
977
- // nodeId: NodeId;
978
- }
979
- interface ExtensionObjectParser {
980
- parent: any;
981
- typeDefinitionId: NodeId;
982
- extensionObject: ExtensionObject | null;
983
- extensionObjectPojo: any | null;
984
- postTaskData?: PostExtensionObjectData;
985
- parser: {
986
- Body: ExtensionObjectBodyParser;
987
- };
988
- }
989
-
990
- interface ExtensionObjectTypeIdParser {
991
- parent: ExtensionObjectParser;
992
- }
993
- interface ExtensionObjectTypeIdIdentifierParser {
994
- text: string;
995
- parent: ExtensionObjectTypeIdParser;
996
- }
997
-
998
- interface ExtensionObjectBodyParser {
999
- parent: ExtensionObjectParser;
1000
- _cloneFragment: InternalFragmentClonerReaderState;
1001
- bodyXML: string;
1002
- engine: any;
1003
- NodeSet2ParserEngine: any;
1004
- parser: any;
1005
- }
1006
-
1007
- interface Parser {
1008
- parent: Parser | any;
1009
- }
1010
- interface ListOfTParser<T> extends Parser {
1011
- listData: T[];
1012
- parent: Parser;
1013
- parser: {
1014
- [key: string]: Parser | any;
1015
- };
1016
- }
1017
-
1018
- interface ListOfExtensionObjectParser extends ListOfTParser<ExtensionObject> {
1019
- listExtensionObject: (ExtensionObject | null)[];
1020
- parser: {
1021
- ExtensionObject: ExtensionObjectParser;
1022
- };
1023
- }
1024
-
1025
- const parseUInt64 = (str: string): UInt64 => coerceUInt64(str);
1026
- const parseInt64 = (str: string): Int64 => coerceInt64(str);
1027
-
1028
- const state_Variant = {
1029
- init: () => {
1030
- /* empty */
1031
- },
1032
- parser: {
1033
- QualifiedName: {
1034
- ...qualifiedName_parser.QualifiedName,
1035
- finish(this: any) {
1036
- this.parent.parent.obj.value = {
1037
- dataType: DataType.QualifiedName,
1038
- value: this.qualifiedName
1039
- };
1040
- }
1041
- },
1042
- LocalizedText: {
1043
- ...localizedText_parser.LocalizedText,
1044
- finish(this: any) {
1045
- this.parent.parent.obj.value = {
1046
- dataType: DataType.LocalizedText,
1047
- value: this.localizedText
1048
- };
1049
- }
1050
- },
1051
- XmlElement: {
1052
- finish(this: any) {
1053
- this.parent.parent.obj.value = {
1054
- dataType: DataType.XmlElement,
1055
- value: this.text
1056
- };
1057
- }
1058
- },
1059
- String: {
1060
- finish(this: any) {
1061
- this.parent.parent.obj.value = {
1062
- dataType: DataType.String,
1063
- value: this.text
1064
- };
1065
- }
1066
- },
1067
-
1068
- Guid: {
1069
- parser: {
1070
- String: {
1071
- finish(this: any) {
1072
- const guid = this.text;
1073
- if (!isValidGuid(guid)) {
1074
- /* ?*/
1075
- }
1076
- this.parent.parent.parent.obj.value = {
1077
- dataType: DataType.Guid,
1078
- arrayType: VariantArrayType.Scalar,
1079
- value: this.text
1080
- };
1081
- }
1082
- }
1083
- }
1084
- },
1085
-
1086
- NodeId: {
1087
- parser: {
1088
- Identifier: {
1089
- finish(this: any) {
1090
- const nodeId = this.text;
1091
- this.parent.parent.parent.obj.value = {
1092
- dataType: DataType.NodeId,
1093
- arrayType: VariantArrayType.Scalar,
1094
- value: _translateNodeId(resolveNodeId(nodeId).toString())
1095
- };
1096
- }
1097
- }
1098
- }
1099
- },
1100
-
1101
- Boolean: parser2("Boolean", coerceBoolean),
1102
- Byte: parser2("Byte", parseInt),
1103
- Int16: parser2("Int16", parseInt),
1104
- Int32: parser2("Int32", parseInt),
1105
- Int8: parser2("Int8", parseInt),
1106
- SByte: parser2("SByte", parseInt),
1107
- UInt16: parser2("UInt16", parseInt),
1108
- UInt32: parser2("UInt32", parseInt),
1109
- UInt8: parser2("UInt8", parseInt),
1110
-
1111
- UInt64: parser2("UInt64", parseUInt64),
1112
- Int64: parser2("Int64", parseInt64),
1113
-
1114
- ByteString: {
1115
- init(this: any) {
1116
- this.value = null;
1117
- },
1118
- finish(this: any) {
1119
- const base64text = this.text;
1120
- const byteString = Buffer.from(base64text, "base64");
1121
- this.parent.parent.obj.value = {
1122
- arrayType: VariantArrayType.Scalar,
1123
- dataType: DataType.ByteString,
1124
- value: byteString
1125
- };
1126
- }
1127
- },
1128
- Float: {
1129
- finish(this: any) {
1130
- this.parent.parent.obj.value = {
1131
- dataType: DataType.Float,
1132
- value: parseFloat(this.text)
1133
- };
1134
- }
1135
- },
1136
-
1137
- Double: {
1138
- finish(this: any) {
1139
- this.parent.parent.obj.value = {
1140
- dataType: DataType.Double,
1141
- value: parseFloat(this.text)
1142
- };
1143
- }
1144
- },
1145
-
1146
- ListOfExtensionObject: {
1147
- init(this: ListOfExtensionObjectParser) {
1148
- this.listExtensionObject = [];
1149
- },
1150
- parser: extensionObject_parser,
1151
- finish(this: ListOfExtensionObjectParser) {
1152
- installExtensionObjectListInitializationPostTask(this);
1153
- },
1154
- startElement(this: ListOfExtensionObjectParser, elementName: string) {
1155
- /* empty */
1156
- const extensionObjectParser = this.parser.ExtensionObject;
1157
- extensionObjectParser.postTaskData = { postponedExtensionObject: null };
1158
- },
1159
- endElement(this: ListOfExtensionObjectParser, elementName: string) {
1160
- const extensionObjectParser = this.parser.ExtensionObject;
1161
-
1162
- this.listExtensionObject.push(extensionObjectParser.extensionObject);
1163
- if (this.parser.ExtensionObject.extensionObject === null) {
1164
- // extension object creation will be postponed
1165
- const index = this.listExtensionObject.length - 1;
1166
- let capturedData = extensionObjectParser.postTaskData;
1167
-
1168
- // istanbul ignore next
1169
- if (!capturedData) {
1170
- throw new Error("Internal Error : postponedExtensionObject not resolved");
1171
- }
1172
-
1173
- let listExtensionObject = this.listExtensionObject;
1174
- const task = async (addressSpace2: IAddressSpace) => {
1175
- // istanbul ignore next
1176
- if (!capturedData!.postponedExtensionObject) {
1177
- throw new Error("Internal Error : postponedExtensionObject not resolved");
1178
- }
1179
- listExtensionObject[index] = capturedData!.postponedExtensionObject!;
1180
- capturedData = undefined;
1181
- (listExtensionObject as any) = undefined;
1182
- };
1183
- postTasks2_AssignedExtensionObjectToDataValue.push(task);
1184
- }
1185
- }
1186
- },
1187
-
1188
- ListOfLocalizedText: {
1189
- init(this: ListOfTParser<LocalizedTextOptions>) {
1190
- this.listData = [];
1191
- },
1192
- parser: localizedText_parser,
1193
- finish(this: ListOfTParser<QualifiedNameOptions>) {
1194
- this.parent.parent.obj.value = {
1195
- arrayType: VariantArrayType.Array,
1196
- dataType: DataType.LocalizedText,
1197
- value: this.listData
1198
- };
1199
- },
1200
- endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
1201
- this.listData.push(this.parser.LocalizedText.localizedText);
1202
- }
1203
- },
1204
- ListOfQualifiedName: {
1205
- init(this: ListOfTParser<QualifiedNameOptions>) {
1206
- this.listData = [];
1207
- },
1208
- parser: qualifiedName_parser,
1209
- finish(this: ListOfTParser<QualifiedNameOptions>) {
1210
- this.parent.parent.obj.value = {
1211
- arrayType: VariantArrayType.Array,
1212
- dataType: DataType.QualifiedName,
1213
- value: this.listData
1214
- };
1215
- },
1216
- endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
1217
- this.listData.push(this.parser.QualifiedName.qualifiedName);
1218
- }
1219
- },
1220
- ListOfNodeId: {
1221
- init(this: ListOfTParser<NodeIdLike>) {
1222
- this.listData = [];
1223
- },
1224
- parser: nodeId_parser,
1225
- finish(this: ListOfTParser<NodeIdLike>) {
1226
- this.parent.parent.obj.value = {
1227
- arrayType: VariantArrayType.Array,
1228
- dataType: DataType.NodeId,
1229
- value: this.listData
1230
- };
1231
- },
1232
- endElement(this: ListOfTParser<NodeIdLike>, elementName: string) {
1233
- this.listData.push(this.parser.NodeId.nodeId);
1234
- }
1235
- },
1236
-
1237
- ListOfBoolean: ListOf<boolean>("Boolean", coerceBoolean),
1238
-
1239
- ListOfByte: ListOf<number>("Byte", parseInt),
1240
-
1241
- ListOfDouble: ListOf<number>("Double", parseFloat),
1242
-
1243
- ListOfFloat: ListOf<number>("Float", parseFloat),
1244
-
1245
- ListOfInt32: ListOf<number>("Int32", parseInt),
1246
-
1247
- ListOfInt16: ListOf<number>("Int16", parseInt),
1248
-
1249
- ListOfInt8: ListOf<number>("Int8", parseInt),
1250
-
1251
- ListOfUInt32: ListOf<number>("UInt32", parseInt),
1252
-
1253
- ListOfUInt16: ListOf<number>("UInt16", parseInt),
1254
-
1255
- ListOfUInt8: ListOf<number>("UInt8", parseInt),
1256
-
1257
- ListOfString: ListOf<string>("String", (value: string) => value),
1258
-
1259
- ListOfXmlElement: ListOf<string>("XmlElement", (value: string) => value),
1260
-
1261
- ExtensionObject: {
1262
- init(this: ExtensionObjectParser) {
1263
- this.typeDefinitionId = NodeId.nullNodeId;
1264
- this.extensionObject = null;
1265
- this.postTaskData = { postponedExtensionObject: null };
1266
- },
1267
- parser: _extensionObject_inner_parser,
1268
- finish(this: ExtensionObjectParser) {
1269
- // istanbul ignore next
1270
- if (this.extensionObject && !(this.extensionObject instanceof ExtensionObject)) {
1271
- throw new Error("expecting an extension object");
1272
- }
1273
- this.parent.parent.obj.value = {
1274
- dataType: DataType.ExtensionObject,
1275
- value: this.extensionObject
1276
- };
1277
- if (!this.extensionObject) {
1278
- installExtensionObjectInitializationPostTask(this);
1279
- }
1280
- }
1281
- }
580
+ if (isDeprecated && !options.loadDeprecatedNodes) {
581
+ debugLog("Ignoring Deprecate =", NodeClass[node.nodeClass], node.browseName.toString());
582
+ return true;
1282
583
  }
584
+ return false;
1283
585
  };
1284
586
 
1285
- function installExtensionObjectListInitializationPostTask(element: ListOfExtensionObjectParser) {
1286
- let listExtensionObject = element.listExtensionObject;
1287
- let nodeId = element.parent.parent.obj.nodeId;
1288
- assert(nodeId, "expecting a nodeid");
1289
- const task = async (addressSpace2: IAddressSpace) => {
1290
- const node = addressSpace2.findNode(nodeId)!;
1291
- if (!node) {
1292
- debugLog("Cannot find node with nodeId " + nodeId + ". may be the node was marked as deprecated");
1293
- } else if (node.nodeClass === NodeClass.Variable) {
1294
- const v = node as UAVariable;
1295
- assert(v.getBasicDataType() === DataType.ExtensionObject, "expecting an extension object");
1296
- v.bindExtensionObject(listExtensionObject as ExtensionObject[], { createMissingProp: false });
1297
- } else if (node.nodeClass === NodeClass.VariableType) {
1298
- // no need to bind a variable type
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;
587
+ function fixExtensionObjectAndArray(obj: { nodeId: NodeId }, deferred: () => ExtensionObject | ExtensionObject[] | null) {
588
+ // let's create the mechanism that postpone the assignment of the extension object
589
+ let capturedNode = obj;
1315
590
  const task = async (addressSpace2: IAddressSpace) => {
1316
- variant.value = data.postponedExtensionObject;
591
+ const extensionObjOrArray = deferred();
592
+ let nodeId = capturedNode.nodeId;
1317
593
  assert(nodeId, "expecting a nodeid");
1318
594
  const node = addressSpace2.findNode(nodeId)!;
595
+
1319
596
  if (node.nodeClass === NodeClass.Variable) {
1320
597
  const v = node as UAVariable;
1321
598
  assert(v.getBasicDataType() === DataType.ExtensionObject, "expecting an extension object");
1322
- v.bindExtensionObject(variant.value, { createMissingProp: false });
599
+ if (extensionObjOrArray != null) {
600
+ v.bindExtensionObject(extensionObjOrArray, { createMissingProp: false });
601
+ }
1323
602
  } else if (node.nodeClass === NodeClass.VariableType) {
1324
603
  const v = node as UAVariableType;
1325
- (v as any) /*fix me*/.value.value = variant.value;
604
+ (v as any) /*fix me*/.value.value = extensionObjOrArray;
1326
605
  }
1327
-
1328
- data.postponedExtensionObject = null;
1329
- (data as any) = undefined;
1330
- (variant as any) = undefined;
1331
- (nodeId as any) = undefined;
1332
606
  };
1333
607
  postTasks2_AssignedExtensionObjectToDataValue.push(task);
1334
608
  }
609
+ // #region UAVariable
610
+ interface IUAVariableProps {
611
+ nodeId: NodeId | null;
612
+ value?: VariantOptions;
613
+ nodeClass: NodeClass;
614
+ browseName: QualifiedName;
615
+ displayName?: LocalizedText;
616
+ description?: LocalizedText;
617
+ parentNodeId: NodeId | null;
618
+ dataType: NodeId | null;
619
+ valueRank: number;
620
+ arrayDimensions: number[] | null;
621
+ minimumSamplingInterval: number;
622
+ historizing: boolean;
623
+ accessLevel: number;
624
+ userAccessLevel: number;
625
+ }
626
+ type ReaderUAVariableL1 = ReaderStateParserLike & { obj: IUAVariableProps; isDraft: boolean; isDeprecated: boolean };
627
+ type ReaderUAVariableL2 = ReaderStateParserLike & { parent: ReaderUAVariableL1; text: string };
1335
628
 
1336
- const canIngore = ({ isDraft, isDeprecated }: { isDraft: boolean; isDeprecated: boolean }, node: BaseNode) => {
1337
- if (isDraft && !options.loadDraftNodes) {
1338
- debugLog("Ignoring Draft =", NodeClass[node.nodeClass], node.browseName.toString());
1339
- return true;
1340
- }
1341
- if (isDeprecated && !options.loadDeprecatedNodes) {
1342
- debugLog("Ignoring Deprecate =", NodeClass[node.nodeClass], node.browseName.toString());
1343
- return true;
1344
- }
1345
- return false;
1346
- };
1347
629
  const state_UAVariable = {
1348
- init(this: any, name: string, attrs: XmlAttributes) {
630
+ init(this: ReaderUAVariableL1, name: string, attrs: XmlAttributes) {
1349
631
  _perform();
1350
632
 
1351
- this.obj = {};
1352
-
1353
- this.obj.nodeClass = NodeClass.Variable;
1354
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1355
- this.obj.parentNodeId = convertToNodeId(attrs.ParentNodeId);
1356
- this.obj.dataType = convertToNodeId(attrs.DataType);
1357
-
1358
- this.obj.valueRank = attrs.ValueRank === undefined ? -1 : coerceInt32(attrs.ValueRank);
1359
- this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
1360
-
1361
- this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
1362
- this.obj.minimumSamplingInterval = parseInt(this.obj.minimumSamplingInterval, 10);
1363
-
1364
- this.obj.historizing = false;
1365
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1366
-
1367
- this.obj.accessLevel = convertAccessLevel(attrs.AccessLevel);
1368
- this.obj.userAccessLevel = this.obj.accessLevel; // convertAccessLevel(attrs.UserAccessLevel || attrs.AccessLevel);
1369
-
1370
- this.isDraft = attrs.ReleaseStatus === "Draft";
1371
- this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
633
+ const valueRank = attrs.ValueRank === undefined ? -1 : coerceInt32(attrs.ValueRank);
634
+ const accessLevel = convertAccessLevel(attrs.AccessLevel);
635
+ const nodeId = convertToNodeId(attrs.NodeId);
636
+ this.obj = {
637
+ value: undefined, // { dataType: DataType.Null },
638
+ nodeClass: NodeClass.Variable,
639
+ browseName: convertQualifiedName(attrs.BrowseName),
640
+ parentNodeId: convertToNodeId(attrs.ParentNodeId),
641
+ dataType: convertToNodeId(attrs.DataType),
642
+ //description: null,
643
+ // displayName: coerceLocalizedText(attrs.BrowseName)!,
644
+ valueRank,
645
+ arrayDimensions: valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions),
646
+ minimumSamplingInterval: attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0,
647
+ historizing: false,
648
+ nodeId,
649
+ accessLevel: accessLevel,
650
+ userAccessLevel: accessLevel // convertAccessLevel(attrs.UserAccessLevel || attrs.AccessLevel);
651
+ };
652
+ this.isDraft = attrs.ReleaseStatus === "Draft" || false;
653
+ this.isDeprecated = attrs.ReleaseStatus === "Deprecated" || false;
1372
654
  },
1373
- finish(this: any) {
655
+ finish(this: ReaderUAVariableL1) {
1374
656
  if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1375
657
  return;
1376
658
  }
@@ -1385,8 +667,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1385
667
  */
1386
668
  // eslint-disable-next-line prefer-const
1387
669
  let capturedVariable: UAVariable;
1388
- if (this.obj.value) {
1389
- let capturedValue = this.obj.value;
670
+ if (this.obj.value && this.obj.value.dataType !== DataType.Null) {
671
+ let capturedValue: any | undefined = this.obj.value;
1390
672
  const task = async (addressSpace2: IAddressSpace) => {
1391
673
  if (false && doDebug) {
1392
674
  debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new Variant(capturedValue).toString());
@@ -1398,7 +680,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1398
680
  if (capturedValue.dataType !== DataType.ExtensionObject) {
1399
681
  postTasks0_InitializeVariable.push(task);
1400
682
  } else {
1401
- // do them later
683
+ // do them later when every thing is created
1402
684
  postTasks1_InitializeVariable.push(task);
1403
685
  }
1404
686
  } else {
@@ -1406,7 +688,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1406
688
  const dataTypeNode = capturedVariable.dataType;
1407
689
  const valueRank = capturedVariable.valueRank;
1408
690
  const arrayDimensions = capturedVariable.arrayDimensions;
1409
-
691
+
1410
692
  const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank, arrayDimensions);
1411
693
  if (value) {
1412
694
  if (false && doDebug) {
@@ -1422,93 +704,121 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1422
704
  };
1423
705
  postTasks0_InitializeVariable.push(task);
1424
706
  }
1425
- this.obj.value = undefined;
707
+ this.obj.value = Object.create(null);
1426
708
  capturedVariable = _internal_createNode(this.obj) as UAVariable;
1427
709
  },
1428
710
  parser: {
1429
711
  DisplayName: {
1430
- finish(this: any) {
1431
- this.parent.obj.displayName = this.text;
712
+ finish(this: ReaderUAVariableL2) {
713
+ this.parent.obj.displayName = coerceLocalizedText(this.text)!;
1432
714
  }
1433
715
  },
1434
716
 
1435
717
  Description: {
1436
- finish(this: any) {
1437
- this.parent.obj.description = this.text;
718
+ finish(this: ReaderUAVariableL2) {
719
+ this.parent.obj.description = coerceLocalizedText(this.text)!;
1438
720
  }
1439
721
  },
1440
722
  References: references_parser,
1441
723
 
1442
- Value: state_Variant
724
+ Value: makeVariantReader<ReaderUAVariableL2>(
725
+ (self: ReaderUAVariableL2, data: VariantOptions) => {
726
+ self.parent.obj.value = data;
727
+ },
728
+ (self: ReaderUAVariableL2, data: VariantOptions, deferredTask) => {
729
+ self.parent.obj.value = data;
730
+ const capturedVariable = { nodeId: self.parent.obj.nodeId! };
731
+ fixExtensionObjectAndArray(capturedVariable, deferredTask);
732
+ },
733
+ (task) => {
734
+ postTasks0_DecodePojoString.push(task);
735
+ },
736
+ _translateNodeId
737
+ )
1443
738
  }
1444
739
  };
1445
-
740
+ // #endregion
741
+ // #region UAVariableType
742
+ interface IUAVariableTypeProps extends Omit<IUAVariableProps, "accessLevel" | "userAccessLevel"> {
743
+ isAbstract: boolean;
744
+ }
745
+ type ReaderUAVariableTypeL1 = ReaderStateParserLike & { obj: IUAVariableTypeProps; isDraft: boolean; isDeprecated: boolean };
746
+ type ReaderUAVariableTypeL2 = ReaderStateParserLike & { parent: ReaderUAVariableTypeL1; text: string };
1446
747
  const state_UAVariableType = {
1447
- init(this: any, name: string, attrs: XmlAttributes) {
748
+ init(this: ReaderUAVariableTypeL1, name: string, attrs: XmlAttributes) {
1448
749
  _perform();
1449
-
1450
- this.obj = {};
1451
- this.obj.isAbstract = coerceBoolean(attrs.IsAbstract);
1452
-
1453
- this.obj.nodeClass = NodeClass.VariableType;
1454
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1455
- this.obj.parentNodeId = attrs.ParentNodeId || null;
1456
- this.obj.dataType = convertToNodeId(attrs.DataType) || null;
1457
-
1458
- this.obj.valueRank = coerceInt32(attrs.ValueRank) || -1;
1459
- this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
1460
-
1461
- this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
1462
-
1463
- this.obj.historizing = false;
1464
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1465
-
750
+ const valueRank = coerceInt32(attrs.ValueRank) || -1;
751
+ this.obj = {
752
+ value: undefined, // { dataType: DataType.Null },
753
+ isAbstract: coerceBoolean(attrs.IsAbstract),
754
+ nodeClass: NodeClass.VariableType,
755
+ browseName: convertQualifiedName(attrs.BrowseName),
756
+ parentNodeId: convertToNodeId(attrs.ParentNodeId) || null,
757
+ dataType: convertToNodeId(attrs.DataType) || null,
758
+ valueRank,
759
+ arrayDimensions: valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions),
760
+ minimumSamplingInterval: attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0,
761
+ historizing: false,
762
+ nodeId: convertToNodeId(attrs.NodeId) || null
763
+ };
1466
764
  this.isDraft = attrs.ReleaseStatus === "Draft";
1467
765
  this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1468
766
  },
1469
- finish(this: any) {
767
+ finish(this: ReaderUAVariableTypeL1) {
1470
768
  if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1471
769
  return;
1472
770
  }
1473
771
  try {
1474
772
  _internal_createNode(this.obj);
1475
773
  } /* istanbul ignore next */ catch (err) {
1476
- this.obj.addressSpace = null;
1477
- // tslint:disable:no-console
1478
- console.warn(" Cannot create object", JSON.stringify(this.obj, null, " "));
774
+ errorLog(" Cannot create object", JSON.stringify(this.obj, null, " "));
1479
775
  throw err;
1480
776
  }
1481
777
  },
1482
778
  parser: {
1483
779
  DisplayName: {
1484
- finish(this: any) {
1485
- this.parent.obj.displayName = this.text;
780
+ finish(this: ReaderUAVariableTypeL2) {
781
+ this.parent.obj.displayName = coerceLocalizedText(this.text || "")!;
1486
782
  }
1487
783
  },
1488
784
 
1489
785
  Description: {
1490
- finish(this: any) {
1491
- this.parent.obj.description = this.text;
786
+ finish(this: ReaderUAVariableTypeL2) {
787
+ this.parent.obj.description = coerceLocalizedText(this.text || "")!;
1492
788
  }
1493
789
  },
1494
790
  References: references_parser,
1495
- Value: state_Variant
791
+ Value: makeVariantReader<ReaderUAVariableTypeL2>(
792
+ (self: ReaderUAVariableTypeL2, data: VariantOptions) => {
793
+ self.parent.obj.value = data;
794
+ },
795
+ (self: ReaderUAVariableTypeL2, data: VariantOptions, deferredTask) => {
796
+ self.parent.obj.value = data;
797
+ const capturedVariable = { nodeId: self.parent.obj.nodeId! };
798
+ fixExtensionObjectAndArray(capturedVariable, deferredTask);
799
+ },
800
+ (task) => {
801
+ postTasks0_DecodePojoString.push(task);
802
+ },
803
+ _translateNodeId
804
+ )
1496
805
  }
1497
806
  };
1498
-
807
+ // #endregion
808
+ // #region UAMethod
1499
809
  const state_UAMethod = {
1500
810
  init(this: any, name: string, attrs: XmlAttributes) {
1501
811
  _perform();
1502
812
 
1503
- this.obj = {};
1504
- this.obj.nodeClass = NodeClass.Method;
1505
- // MethodDeclarationId
1506
- // ParentNodeId
1507
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1508
- this.obj.parentNodeId = attrs.ParentNodeId || null;
1509
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1510
- this.obj.methodDeclarationId = attrs.MethodDeclarationId ? _translateNodeId(attrs.MethodDeclarationId) : null;
1511
-
813
+ this.obj = {
814
+ nodeClass: NodeClass.Method,
815
+ // MethodDeclarationId
816
+ // ParentNodeId
817
+ browseName: convertQualifiedName(attrs.BrowseName),
818
+ parentNodeId: attrs.ParentNodeId || null,
819
+ nodeId: convertToNodeId(attrs.NodeId) || null,
820
+ methodDeclarationId: attrs.MethodDeclarationId ? _translateNodeId(attrs.MethodDeclarationId) : null,
821
+ };
1512
822
  this.isDraft = attrs.ReleaseStatus === "Draft";
1513
823
  this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1514
824
  },
@@ -1527,7 +837,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1527
837
  References: references_parser
1528
838
  }
1529
839
  };
1530
-
840
+ // #endregion
841
+ // #region Model
1531
842
  interface Model {
1532
843
  modelUri: string;
1533
844
  version: string;
@@ -1577,7 +888,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1577
888
  models.push(model);
1578
889
  }
1579
890
  });
1580
-
891
+ // #endregion
1581
892
  function _updateTranslationTable() {
1582
893
  _register_namespace_uri_in_translation_table("http://opcfoundation.org/UA/");
1583
894
  for (const namespaceUri of _namespaceUris) {
@@ -1682,7 +993,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1682
993
  doDebug &&
1683
994
  debugLog(
1684
995
  chalk.bgGreenBright("Performing post loading tasks -------------------------------------------") +
1685
- chalk.green("DONE")
996
+ chalk.green("DONE")
1686
997
  );
1687
998
 
1688
999
  async function performPostLoadingTasks(tasks: Task[]): Promise<void> {