node-opcua-address-space 2.97.0 → 2.98.1

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 (342) hide show
  1. package/dist/source/address_space_ts.d.ts +118 -118
  2. package/dist/source/address_space_ts.js +17 -17
  3. package/dist/source/continuation_points/continuation_point_manager.d.ts +91 -91
  4. package/dist/source/continuation_points/continuation_point_manager.js +200 -200
  5. package/dist/source/helpers/adjust_browse_direction.d.ts +5 -5
  6. package/dist/source/helpers/adjust_browse_direction.js +11 -11
  7. package/dist/source/helpers/argument_list.d.ts +33 -33
  8. package/dist/source/helpers/argument_list.js +254 -254
  9. package/dist/source/helpers/call_helpers.d.ts +6 -6
  10. package/dist/source/helpers/call_helpers.js +71 -71
  11. package/dist/source/helpers/coerce_enum_value.d.ts +6 -6
  12. package/dist/source/helpers/coerce_enum_value.js +33 -33
  13. package/dist/source/helpers/dump_tools.d.ts +14 -14
  14. package/dist/source/helpers/dump_tools.js +78 -78
  15. package/dist/source/helpers/ensure_secure_access.d.ts +9 -9
  16. package/dist/source/helpers/ensure_secure_access.js +76 -76
  17. package/dist/source/helpers/make_optionals_map.d.ts +21 -21
  18. package/dist/source/helpers/make_optionals_map.js +29 -29
  19. package/dist/source/helpers/multiform_func.d.ts +11 -11
  20. package/dist/source/helpers/multiform_func.js +75 -75
  21. package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -3
  22. package/dist/source/helpers/resolve_opaque_on_address_space.js +36 -36
  23. package/dist/source/index.d.ts +61 -61
  24. package/dist/source/index.js +89 -89
  25. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +19 -19
  26. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +2 -2
  27. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +193 -193
  28. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js +2 -2
  29. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.d.ts +12 -12
  30. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js +2 -2
  31. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.d.ts +10 -10
  32. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js +2 -2
  33. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.d.ts +7 -7
  34. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js +2 -2
  35. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.d.ts +7 -7
  36. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js +2 -2
  37. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.d.ts +4 -4
  38. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js +2 -2
  39. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.d.ts +4 -4
  40. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js +2 -2
  41. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.d.ts +9 -9
  42. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js +2 -2
  43. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.d.ts +4 -4
  44. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js +2 -2
  45. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.d.ts +4 -4
  46. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js +2 -2
  47. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.d.ts +20 -20
  48. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js +2 -2
  49. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +23 -23
  50. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js +2 -2
  51. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.d.ts +32 -32
  52. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js +2 -2
  53. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.d.ts +19 -19
  54. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js +2 -2
  55. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +45 -42
  56. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js +2 -2
  57. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.d.ts +7 -7
  58. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js +25 -25
  59. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.d.ts +5 -5
  60. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js +2 -2
  61. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.d.ts +20 -20
  62. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js +2 -2
  63. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.d.ts +26 -26
  64. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js +2 -2
  65. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.d.ts +8 -8
  66. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js +2 -2
  67. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.d.ts +10 -10
  68. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js +2 -2
  69. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -21
  70. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +2 -2
  71. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -24
  72. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +2 -2
  73. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -12
  74. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +2 -2
  75. package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -8
  76. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +2 -2
  77. package/dist/source/interfaces/extension_object_constructor.d.ts +10 -10
  78. package/dist/source/interfaces/extension_object_constructor.js +2 -2
  79. package/dist/source/interfaces/nodeset_loader_options.d.ts +4 -4
  80. package/dist/source/interfaces/nodeset_loader_options.js +2 -2
  81. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -12
  82. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +2 -2
  83. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -49
  84. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +2 -2
  85. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -11
  86. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +2 -2
  87. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +30 -30
  88. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js +2 -2
  89. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +234 -234
  90. package/dist/source/interfaces/state_machine/ua_state_machine_type.js +2 -2
  91. package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -6
  92. package/dist/source/interfaces/state_machine/ua_transition_ex.js +2 -2
  93. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -8
  94. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +2 -2
  95. package/dist/source/loader/decode_xml_extension_object.d.ts +6 -6
  96. package/dist/source/loader/decode_xml_extension_object.js +71 -71
  97. package/dist/source/loader/ensure_datatype_extracted.d.ts +5 -5
  98. package/dist/source/loader/ensure_datatype_extracted.js +70 -70
  99. package/dist/source/loader/generateAddressSpaceRaw.d.ts +11 -11
  100. package/dist/source/loader/generateAddressSpaceRaw.js +45 -45
  101. package/dist/source/loader/load_nodeset2.d.ts +17 -17
  102. package/dist/source/loader/load_nodeset2.js +1483 -1483
  103. package/dist/source/loader/make_semver_compatible.d.ts +6 -6
  104. package/dist/source/loader/make_semver_compatible.js +25 -25
  105. package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -28
  106. package/dist/source/loader/make_xml_extension_object_parser.js +326 -326
  107. package/dist/source/loader/namespace_post_step.d.ts +10 -10
  108. package/dist/source/loader/namespace_post_step.js +61 -61
  109. package/dist/source/loader/register_node_promoter.d.ts +2 -2
  110. package/dist/source/loader/register_node_promoter.js +9 -9
  111. package/dist/source/namespace.d.ts +6 -6
  112. package/dist/source/namespace.js +2 -2
  113. package/dist/source/namespace_alarm_and_condition.d.ts +32 -32
  114. package/dist/source/namespace_alarm_and_condition.js +2 -2
  115. package/dist/source/namespace_data_access.d.ts +42 -42
  116. package/dist/source/namespace_data_access.js +2 -2
  117. package/dist/source/namespace_machine_state.d.ts +8 -8
  118. package/dist/source/namespace_machine_state.js +2 -2
  119. package/dist/source/pseudo_session.d.ts +72 -72
  120. package/dist/source/pseudo_session.js +254 -254
  121. package/dist/source/session_context.d.ts +111 -111
  122. package/dist/source/session_context.js +264 -264
  123. package/dist/source/session_context.js.map +1 -1
  124. package/dist/source/set_namespace_meta_data.d.ts +2 -2
  125. package/dist/source/set_namespace_meta_data.js +59 -59
  126. package/dist/source/ua_root_folder.d.ts +9 -9
  127. package/dist/source/ua_root_folder.js +2 -2
  128. package/dist/source/ua_two_state_variable_ex.d.ts +23 -23
  129. package/dist/source/ua_two_state_variable_ex.js +2 -2
  130. package/dist/source/xml_writer.d.ts +18 -18
  131. package/dist/source/xml_writer.js +2 -2
  132. package/dist/src/address_space.d.ts +387 -387
  133. package/dist/src/address_space.js +1385 -1385
  134. package/dist/src/address_space.js.map +1 -1
  135. package/dist/src/address_space_change_event_tools.d.ts +6 -6
  136. package/dist/src/address_space_change_event_tools.js +152 -152
  137. package/dist/src/address_space_private.d.ts +43 -43
  138. package/dist/src/address_space_private.js +2 -2
  139. package/dist/src/alarms_and_conditions/condition.d.ts +5 -5
  140. package/dist/src/alarms_and_conditions/condition.js +78 -78
  141. package/dist/src/alarms_and_conditions/condition_info_impl.d.ts +26 -26
  142. package/dist/src/alarms_and_conditions/condition_info_impl.js +54 -54
  143. package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +222 -222
  144. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +657 -657
  145. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
  146. package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +9 -9
  147. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +60 -60
  148. package/dist/src/alarms_and_conditions/index.d.ts +16 -16
  149. package/dist/src/alarms_and_conditions/index.js +32 -32
  150. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +44 -44
  151. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -244
  152. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +93 -93
  153. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +418 -418
  154. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  155. package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +26 -26
  156. package/dist/src/alarms_and_conditions/ua_base_event_impl.js +38 -38
  157. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +44 -44
  158. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +183 -183
  159. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +155 -153
  160. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1028 -1028
  161. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  162. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +14 -14
  163. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +34 -34
  164. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +24 -24
  165. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +56 -56
  166. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +11 -11
  167. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +11 -11
  168. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +23 -23
  169. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +86 -86
  170. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +11 -11
  171. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +7 -7
  172. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +79 -79
  173. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +250 -250
  174. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +24 -24
  175. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +50 -50
  176. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +19 -19
  177. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +162 -162
  178. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +46 -46
  179. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +165 -165
  180. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +18 -18
  181. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +17 -17
  182. package/dist/src/apply_condition_refresh.d.ts +6 -6
  183. package/dist/src/apply_condition_refresh.js +27 -27
  184. package/dist/src/base_node_impl.d.ts +284 -284
  185. package/dist/src/base_node_impl.js +1454 -1454
  186. package/dist/src/base_node_private.d.ts +81 -81
  187. package/dist/src/base_node_private.js +832 -803
  188. package/dist/src/base_node_private.js.map +1 -1
  189. package/dist/src/check_value_rank_compatibility.d.ts +15 -15
  190. package/dist/src/check_value_rank_compatibility.js +81 -81
  191. package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -11
  192. package/dist/src/data_access/add_dataItem_stuff.js +61 -61
  193. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -1
  194. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +34 -34
  195. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -32
  196. package/dist/src/data_access/ua_multistate_discrete_impl.js +130 -130
  197. package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +52 -52
  198. package/dist/src/data_access/ua_multistate_value_discrete_impl.js +253 -253
  199. package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +25 -25
  200. package/dist/src/data_access/ua_two_state_discrete_impl.js +155 -155
  201. package/dist/src/event_data.d.ts +34 -34
  202. package/dist/src/event_data.js +64 -64
  203. package/dist/src/extension_object_array_node.d.ts +23 -23
  204. package/dist/src/extension_object_array_node.js +248 -248
  205. package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -26
  206. package/dist/src/historical_access/address_space_historical_data_node.js +652 -652
  207. package/dist/src/idx_iterator.d.ts +8 -8
  208. package/dist/src/idx_iterator.js +50 -50
  209. package/dist/src/index_current.d.ts +46 -46
  210. package/dist/src/index_current.js +77 -77
  211. package/dist/src/namespace_impl.d.ts +456 -456
  212. package/dist/src/namespace_impl.js +1762 -1762
  213. package/dist/src/namespace_impl.js.map +1 -1
  214. package/dist/src/namespace_private.d.ts +23 -23
  215. package/dist/src/namespace_private.js +32 -32
  216. package/dist/src/nodeid_manager.d.ts +37 -37
  217. package/dist/src/nodeid_manager.js +183 -183
  218. package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -2
  219. package/dist/src/nodeset_tools/adjust_namespace_array.js +13 -13
  220. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +18 -18
  221. package/dist/src/nodeset_tools/construct_namespace_dependency.js +140 -140
  222. package/dist/src/nodeset_tools/dump_to_bsd.d.ts +2 -2
  223. package/dist/src/nodeset_tools/dump_to_bsd.js +164 -164
  224. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +10 -10
  225. package/dist/src/nodeset_tools/nodeset_to_xml.js +1287 -1287
  226. package/dist/src/private_namespace.d.ts +5 -5
  227. package/dist/src/private_namespace.js +19 -19
  228. package/dist/src/reference_impl.d.ts +43 -43
  229. package/dist/src/reference_impl.js +139 -139
  230. package/dist/src/role_permissions.d.ts +2 -2
  231. package/dist/src/role_permissions.js +10 -10
  232. package/dist/src/state_machine/finite_state_machine.d.ts +81 -81
  233. package/dist/src/state_machine/finite_state_machine.js +388 -388
  234. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +38 -38
  235. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +250 -250
  236. package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -61
  237. package/dist/src/state_machine/ua_two_state_variable.js +331 -331
  238. package/dist/src/tool_isSubtypeOf.d.ts +18 -18
  239. package/dist/src/tool_isSubtypeOf.js +124 -124
  240. package/dist/src/ua_condition_type.d.ts +8 -8
  241. package/dist/src/ua_condition_type.js +2 -2
  242. package/dist/src/ua_data_type_impl.d.ts +89 -89
  243. package/dist/src/ua_data_type_impl.js +368 -368
  244. package/dist/src/ua_method_impl.d.ts +42 -42
  245. package/dist/src/ua_method_impl.js +217 -217
  246. package/dist/src/ua_object_impl.d.ts +35 -35
  247. package/dist/src/ua_object_impl.js +168 -168
  248. package/dist/src/ua_object_type_impl.d.ts +50 -50
  249. package/dist/src/ua_object_type_impl.js +126 -126
  250. package/dist/src/ua_reference_type_impl.d.ts +45 -45
  251. package/dist/src/ua_reference_type_impl.js +141 -141
  252. package/dist/src/ua_variable_impl.d.ts +380 -380
  253. package/dist/src/ua_variable_impl.js +1738 -1738
  254. package/dist/src/ua_variable_impl_ext_obj.d.ts +23 -23
  255. package/dist/src/ua_variable_impl_ext_obj.js +670 -670
  256. package/dist/src/ua_variable_type_impl.d.ts +74 -74
  257. package/dist/src/ua_variable_type_impl.js +597 -581
  258. package/dist/src/ua_variable_type_impl.js.map +1 -1
  259. package/dist/src/ua_view_impl.d.ts +19 -19
  260. package/dist/src/ua_view_impl.js +43 -43
  261. package/dist/tsconfig_common.tsbuildinfo +1 -0
  262. package/distHelpers/add_event_generator_object.d.ts +3 -3
  263. package/distHelpers/add_event_generator_object.js +64 -64
  264. package/distHelpers/alarms_and_conditions_demo.d.ts +9 -9
  265. package/distHelpers/alarms_and_conditions_demo.js +115 -115
  266. package/distHelpers/assertHasMatchingReference.d.ts +19 -19
  267. package/distHelpers/assertHasMatchingReference.js +40 -40
  268. package/distHelpers/boiler_system.d.ts +113 -113
  269. package/distHelpers/boiler_system.js +395 -395
  270. package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -5
  271. package/distHelpers/create_minimalist_address_space_nodeset.js +171 -171
  272. package/distHelpers/date_utils.d.ts +3 -3
  273. package/distHelpers/date_utils.js +9 -9
  274. package/distHelpers/dump_statemachine.js +127 -127
  275. package/distHelpers/get_address_space_fixture.d.ts +1 -1
  276. package/distHelpers/get_address_space_fixture.js +30 -30
  277. package/distHelpers/get_mini_address_space.d.ts +7 -7
  278. package/distHelpers/get_mini_address_space.js +36 -36
  279. package/distHelpers/index.d.ts +12 -12
  280. package/distHelpers/index.js +28 -28
  281. package/distHelpers/mock_session.d.ts +10 -10
  282. package/distHelpers/mock_session.js +25 -25
  283. package/distNodeJS/generate_address_space.d.ts +6 -6
  284. package/distNodeJS/generate_address_space.js +52 -52
  285. package/distNodeJS/index.d.ts +1 -1
  286. package/distNodeJS/index.js +17 -17
  287. package/package.json +51 -40
  288. package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +4 -3
  289. package/src/alarms_and_conditions/ua_condition_impl.ts +14 -9
  290. package/src/base_node_private.ts +73 -28
  291. package/src/ua_variable_type_impl.ts +35 -17
  292. package/.mocharc.yml +0 -12
  293. package/dist/src/tool_isSupertypeOf.d.ts +0 -18
  294. package/dist/src/tool_isSupertypeOf.js +0 -125
  295. package/dist/src/tool_isSupertypeOf.js.map +0 -1
  296. package/generate.js +0 -1
  297. package/source_nodejs/generate_address_space.ts +0 -60
  298. package/source_nodejs/index.ts +0 -1
  299. package/test_helpers/add_event_generator_object.ts +0 -71
  300. package/test_helpers/alarms_and_conditions_demo.ts +0 -151
  301. package/test_helpers/assertHasMatchingReference.ts +0 -43
  302. package/test_helpers/boiler_system.ts +0 -610
  303. package/test_helpers/create_minimalist_address_space_nodeset.ts +0 -208
  304. package/test_helpers/date_utils.ts +0 -5
  305. package/test_helpers/dump_statemachine.ts +0 -155
  306. package/test_helpers/get_address_space_fixture.ts +0 -30
  307. package/test_helpers/get_mini_address_space.ts +0 -42
  308. package/test_helpers/index.ts +0 -12
  309. package/test_helpers/mock_session.ts +0 -34
  310. package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +0 -150
  311. package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +0 -57
  312. package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +0 -136
  313. package/test_helpers/test_fixtures/dataType_issue.xml +0 -80
  314. package/test_helpers/test_fixtures/dataType_withEnumeration.xml +0 -82
  315. package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +0 -194
  316. package/test_helpers/test_fixtures/dataType_with_qualifiedname.xml +0 -71
  317. package/test_helpers/test_fixtures/dataType_with_recursive_structure.xml +0 -155
  318. package/test_helpers/test_fixtures/dataType_with_structures.xml +0 -605
  319. package/test_helpers/test_fixtures/dataType_with_union.xml +0 -90
  320. package/test_helpers/test_fixtures/datatype_as_per_1.04.xml +0 -118
  321. package/test_helpers/test_fixtures/datatype_with_allow_subtype.xml +0 -104
  322. package/test_helpers/test_fixtures/eurange_issue.xml +0 -74
  323. package/test_helpers/test_fixtures/example_issue1096.xml +0 -267
  324. package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +0 -106
  325. package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +0 -1305
  326. package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +0 -370
  327. package/test_helpers/test_fixtures/issue_1132_variable_with_nodeid_value.xml +0 -68
  328. package/test_helpers/test_fixtures/issue_846.xml +0 -3172
  329. package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +0 -33
  330. package/test_helpers/test_fixtures/mini.Node.Set2.xml +0 -4736
  331. package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +0 -196
  332. package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +0 -8
  333. package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +0 -20
  334. package/test_helpers/test_fixtures/nodeset_no_aliases.xml +0 -30
  335. package/test_helpers/test_fixtures/nodeset_no_aliases_with_aliases.xml +0 -31
  336. package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +0 -45
  337. package/test_helpers/test_fixtures/nodeset_with_guid.xml +0 -1442
  338. package/test_helpers/test_fixtures/nodeset_with_int64_values.xml +0 -31
  339. package/test_helpers/test_fixtures/nodeset_with_special_char.xml +0 -34
  340. package/test_helpers/test_fixtures/nodeset_with_utf8_special_characters.xml +0 -20
  341. package/test_helpers/test_fixtures/variable_with_value.xml +0 -143
  342. package/test_helpers/test_fixtures/variabletype_with_value.xml +0 -324
@@ -1,1484 +1,1484 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.NodeSetLoader = void 0;
13
- /* eslint-disable max-statements */
14
- /**
15
- * @module node-opcua-address-space
16
- */
17
- const util_1 = require("util");
18
- const chalk = require("chalk");
19
- const ec = require("node-opcua-basic-types");
20
- const node_opcua_assert_1 = require("node-opcua-assert");
21
- const node_opcua_basic_types_1 = require("node-opcua-basic-types");
22
- const node_opcua_data_access_1 = require("node-opcua-data-access");
23
- const node_opcua_data_model_1 = require("node-opcua-data-model");
24
- const node_opcua_debug_1 = require("node-opcua-debug");
25
- const node_opcua_extension_object_1 = require("node-opcua-extension-object");
26
- const node_opcua_factory_1 = require("node-opcua-factory");
27
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
28
- const node_opcua_service_call_1 = require("node-opcua-service-call");
29
- const node_opcua_types_1 = require("node-opcua-types");
30
- const node_opcua_variant_1 = require("node-opcua-variant");
31
- const node_opcua_xml2json_1 = require("node-opcua-xml2json");
32
- const semver = require("semver");
33
- const namespace_post_step_1 = require("./namespace_post_step");
34
- const ensure_datatype_extracted_1 = require("./ensure_datatype_extracted");
35
- const decode_xml_extension_object_1 = require("./decode_xml_extension_object");
36
- const make_semver_compatible_1 = require("./make_semver_compatible");
37
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
38
- const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
39
- const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
40
- function __make_back_references(namespace) {
41
- const namespaceP = namespace;
42
- for (const node of namespaceP.nodeIterator()) {
43
- node.propagate_back_references();
44
- }
45
- for (const node of namespaceP.nodeIterator()) {
46
- node.install_extra_properties();
47
- }
48
- }
49
- function make_back_references(addressSpace) {
50
- const addressSpacePrivate = addressSpace;
51
- addressSpacePrivate.suspendBackReference = false;
52
- addressSpace.getNamespaceArray().map(__make_back_references);
53
- }
54
- function stringToUInt32Array(str) {
55
- const array = str ? str.split(",").map((value) => parseInt(value, 10)) : null;
56
- return array;
57
- }
58
- function convertAccessLevel(accessLevel) {
59
- const accessLevelN = parseInt(accessLevel || "1", 10); // CurrentRead if not specified
60
- return (0, node_opcua_data_model_1.makeAccessLevelFlag)(accessLevelN);
61
- }
62
- function makeDefaultVariant(addressSpace, dataTypeNode, valueRank) {
63
- let variant = { dataType: node_opcua_variant_1.DataType.Null };
64
- const nodeDataType = addressSpace.findNode(dataTypeNode);
65
- if (nodeDataType && nodeDataType.basicDataType) {
66
- const basicDataType = nodeDataType.basicDataType;
67
- if (basicDataType === node_opcua_variant_1.DataType.Variant) {
68
- /// we don't now what is the variant
69
- return undefined;
70
- }
71
- if (basicDataType === node_opcua_variant_1.DataType.ExtensionObject) {
72
- return { dataType: node_opcua_variant_1.DataType.ExtensionObject, value: null };
73
- }
74
- const builtInType = (0, node_opcua_factory_1.getBuiltInType)(node_opcua_variant_1.DataType[basicDataType]);
75
- if (builtInType === undefined || builtInType === null) {
76
- errorLog("Cannot find builtInType for ", basicDataType);
77
- return { dataType: node_opcua_variant_1.DataType.Null };
78
- }
79
- const dv = builtInType.defaultValue;
80
- const value = typeof dv === "function" ? dv() : dv;
81
- let arrayType;
82
- /*
83
- * * n > 1 : the Value is an array with the specified number of dimensions.
84
- * * OneDimension (1): The value is an array with one dimension.
85
- * * OneOrMoreDimensions (0): The value is an array with one or more dimensions.
86
- * * Scalar (-1): The value is not an array.
87
- * * Any (-2): The value can be a scalar or an array with any number of dimensions.
88
- * * ScalarOrOneDimension (-3): The value can be a scalar or a one dimensional array.
89
- */
90
- switch (valueRank) {
91
- case -3: // ScalarOrOneDimension (-3):
92
- case -2: // any
93
- case -1:
94
- arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
95
- variant = { dataType: basicDataType, value, arrayType };
96
- break;
97
- case 0: // one or more dimension
98
- case 1: // one dimension
99
- arrayType = node_opcua_variant_1.VariantArrayType.Array;
100
- variant = { dataType: basicDataType, value: [], arrayType };
101
- break;
102
- default:
103
- arrayType = node_opcua_variant_1.VariantArrayType.Matrix;
104
- variant = { dataType: basicDataType, value: [], arrayType, dimensions: [] };
105
- break;
106
- }
107
- }
108
- return variant;
109
- }
110
- function makeNodeSetParserEngine(addressSpace, options) {
111
- const addressSpace1 = addressSpace;
112
- addressSpace1.suspendBackReference = true;
113
- options.loadDeprecatedNodes = options.loadDeprecatedNodes === undefined ? true : options.loadDeprecatedNodes;
114
- options.loadDraftNodes = options.loadDraftNodes || false;
115
- const postTasks = [];
116
- const postTasks0_InitializeVariable = [];
117
- const postTasks0_DecodePojoString = [];
118
- const postTasks1_InitializeVariable = [];
119
- const postTasks2_AssignedExtensionObjectToDataValue = [];
120
- let alias_map = {};
121
- /**
122
- * @param aliasName
123
- */
124
- function addAlias(aliasName, nodeIdInXmlContext) {
125
- (0, node_opcua_assert_1.assert)(typeof nodeIdInXmlContext === "string");
126
- const nodeId = _translateNodeId(nodeIdInXmlContext);
127
- (0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
128
- alias_map[aliasName] = nodeId;
129
- addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
130
- }
131
- let namespace_uri_translation = {};
132
- let namespaceCounter = 0;
133
- let found_namespace_in_uri = {};
134
- let models = [];
135
- let performedCalled = false;
136
- function _reset_namespace_translation() {
137
- debugLog("_reset_namespace_translation");
138
- namespace_uri_translation = {};
139
- found_namespace_in_uri = {};
140
- namespaceCounter = 0;
141
- alias_map = {};
142
- models = [];
143
- performedCalled = false;
144
- }
145
- function _translateNamespaceIndex(innerIndex) {
146
- const namespaceIndex = namespace_uri_translation[innerIndex];
147
- // istanbul ignore next
148
- if (namespaceIndex === undefined) {
149
- debugLog("Warning: namespace_uri_translation = ", namespace_uri_translation);
150
- errorLog("namespace_uri_translation", namespace_uri_translation);
151
- throw new Error("_translateNamespaceIndex() ! Cannot find namespace definition for index " + innerIndex);
152
- }
153
- return namespaceIndex;
154
- }
155
- function _internal_addReferenceType(params) {
156
- // istanbul ignore next
157
- if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
158
- throw new Error("invalid param");
159
- } // already translated
160
- const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
161
- namespace.addReferenceType(params);
162
- }
163
- function _internal_createNode(params) {
164
- // istanbul ignore next
165
- if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
166
- throw new Error("invalid param expecting a valid nodeId");
167
- } // already translated
168
- const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
169
- return namespace.internalCreateNode(params);
170
- }
171
- function _register_namespace_uri_in_translation_table(namespaceUri) {
172
- if (found_namespace_in_uri[namespaceUri]) {
173
- return;
174
- }
175
- const namespace = addressSpace1.getNamespace(namespaceUri);
176
- // istanbul ignore next
177
- if (!namespace) {
178
- throw new Error("cannot find namespace for " +
179
- namespaceUri +
180
- "\nplease make sure to initialize your address space with the corresponding nodeset files");
181
- }
182
- found_namespace_in_uri[namespaceUri] = namespace;
183
- const index_in_xml = namespaceCounter;
184
- namespaceCounter++;
185
- namespace_uri_translation[index_in_xml] = namespace.index;
186
- doDebug &&
187
- debugLog(" _register_namespace_uri = ", namespaceUri, "index in Xml=", index_in_xml, " index in addressSpace", namespace.index);
188
- }
189
- function _add_namespace(model) {
190
- if (model.requiredModels.length > 0) {
191
- // check that required models exist already in the address space
192
- for (const requiredModel of model.requiredModels) {
193
- const existingNamespace = addressSpace1.getNamespace(requiredModel.modelUri);
194
- // istanbul ignore next
195
- if (!existingNamespace) {
196
- errorLog("Please ensure that the required namespace ", requiredModel.modelUri, "is loaded firs when loading ", model.modelUri);
197
- throw new Error("LoadNodeSet : Cannot find namespace for " + requiredModel.modelUri);
198
- }
199
- /**
200
- * from https://reference.opcfoundation.org/Core/docs/Part6/F.2/
201
- * The version of the model defined in the UANodeSet.
202
- * This is a human readable string and not intended for programmatic comparisons.
203
- *
204
- */
205
- const isLowerVersion = (existingVersion, requiredVersion) => {
206
- const existingSemver = (0, make_semver_compatible_1.makeSemverCompatible)(existingVersion);
207
- const requiredSemver = (0, make_semver_compatible_1.makeSemverCompatible)(requiredVersion);
208
- return semver.lt(existingSemver, requiredSemver);
209
- };
210
- if (isLowerVersion(existingNamespace.version, requiredModel.version)) {
211
- errorLog("Expecting ", requiredModel.modelUri, " with version to be at least", requiredModel.version, " but namespace version is ", existingNamespace.version);
212
- }
213
- if (existingNamespace.publicationDate.getTime() < requiredModel.publicationDate.getTime()) {
214
- errorLog("Expecting ", requiredModel.modelUri, " with publicationDatea at least ", requiredModel.publicationDate.toUTCString(), " but namespace publicationDate is ", existingNamespace.publicationDate.toUTCString());
215
- }
216
- }
217
- }
218
- let namespace;
219
- // Model must not be already registered
220
- const existingNamespace = addressSpace1.getNamespace(model.modelUri);
221
- if (existingNamespace) {
222
- // special treatment for namespace 0
223
- // istanbul ignore else
224
- if (model.modelUri === "http://opcfoundation.org/UA/") {
225
- namespace = existingNamespace;
226
- }
227
- else {
228
- throw new Error(" namespace already registered " + model.modelUri);
229
- }
230
- }
231
- else {
232
- namespace = addressSpace1.registerNamespace(model.modelUri);
233
- namespace.setRequiredModels(model.requiredModels);
234
- }
235
- namespace.version = model.version;
236
- namespace.publicationDate = model.publicationDate || namespace.publicationDate;
237
- return namespace;
238
- }
239
- const reg = /ns=([0-9]+);(.*)/;
240
- function _translateNodeId(nodeId) {
241
- if (alias_map[nodeId]) {
242
- return alias_map[nodeId];
243
- }
244
- const m = nodeId.match(reg);
245
- if (m) {
246
- const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
247
- nodeId = "ns=" + namespaceIndex + ";" + m[2];
248
- }
249
- return (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
250
- }
251
- function _translateReferenceType(refType) {
252
- return _translateNodeId(refType);
253
- }
254
- /**
255
- * convert a nodeId
256
- *
257
- * @method convertToNodeId
258
- * @param nodeId {String|null}
259
- * @return {NodeId}
260
- *
261
- * @example
262
- * convertToNodeId("String") => resolve alias
263
- * convertToNodeId("i=58") => resolve to nodeId in namespace 0
264
- * convertToNodeId("ns=1;i=100") => convert namespace from xml namespace
265
- * table to corresponding namespace in addressSpace
266
- */
267
- function convertToNodeId(nodeIdLike) {
268
- // treat alias
269
- if (!nodeIdLike) {
270
- return null;
271
- }
272
- const nodeId = _translateNodeId(nodeIdLike);
273
- return addressSpace1.resolveNodeId(nodeId);
274
- }
275
- function convertQualifiedName(qualifiedName) {
276
- const qn = (0, node_opcua_data_model_1.stringToQualifiedName)(qualifiedName);
277
- // Xx if (qn.namespaceIndex > 0) {
278
- qn.namespaceIndex = _translateNamespaceIndex(qn.namespaceIndex);
279
- // Xx }
280
- return qn;
281
- }
282
- const state_Alias = {
283
- finish() {
284
- addAlias(this.attrs.Alias, this.text);
285
- }
286
- };
287
- const references_parser = {
288
- init() {
289
- this.parent.obj.references = [];
290
- this.array = this.parent.obj.references;
291
- },
292
- parser: {
293
- Reference: {
294
- finish() {
295
- this.parent.array.push({
296
- isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward === "false" ? false : true,
297
- nodeId: convertToNodeId(this.text),
298
- referenceType: _translateReferenceType(this.attrs.ReferenceType)
299
- });
300
- }
301
- }
302
- }
303
- };
304
- const state_UAObject = {
305
- init(name, attrs) {
306
- _perform();
307
- this.obj = {};
308
- this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Object;
309
- this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
310
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
311
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
312
- this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
313
- this.obj.symbolicName = attrs.SymbolicName || null;
314
- this.isDraft = attrs.ReleaseStatus === "Draft";
315
- this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
316
- },
317
- finish() {
318
- if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
319
- return;
320
- }
321
- _internal_createNode(this.obj);
322
- },
323
- parser: {
324
- DisplayName: {
325
- finish() {
326
- this.parent.obj.displayName = this.text;
327
- }
328
- },
329
- Description: {
330
- finish() {
331
- this.parent.obj.description = this.text;
332
- }
333
- },
334
- References: references_parser
335
- }
336
- };
337
- const state_UAObjectType = {
338
- init(name, attrs) {
339
- _perform();
340
- this.obj = {};
341
- this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ObjectType;
342
- this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
343
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
344
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
345
- this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
346
- },
347
- finish() {
348
- _internal_createNode(this.obj);
349
- },
350
- parser: {
351
- DisplayName: {
352
- finish() {
353
- this.parent.obj.displayName = this.text;
354
- }
355
- },
356
- Description: {
357
- finish() {
358
- this.parent.obj.description = this.text;
359
- }
360
- },
361
- References: references_parser
362
- }
363
- };
364
- const state_UAReferenceType = {
365
- init(name, attrs) {
366
- _perform();
367
- this.obj = {};
368
- this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ReferenceType;
369
- this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
370
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
371
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
372
- },
373
- finish() {
374
- _internal_addReferenceType(this.obj);
375
- },
376
- parser: {
377
- DisplayName: {
378
- finish() {
379
- this.parent.obj.displayName = this.text;
380
- }
381
- },
382
- Description: {
383
- finish() {
384
- this.parent.obj.description = this.text;
385
- }
386
- },
387
- InverseName: {
388
- finish() {
389
- this.parent.obj.inverseName = this.text;
390
- }
391
- },
392
- References: references_parser
393
- }
394
- };
395
- const pendingSimpleTypeToRegister = [];
396
- const state_UADataType = {
397
- init(name, attrs) {
398
- _perform();
399
- this.obj = {};
400
- this.obj.nodeClass = node_opcua_data_model_1.NodeClass.DataType;
401
- this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract) || false;
402
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
403
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
404
- this.obj.displayName = "";
405
- this.obj.description = "";
406
- this.obj.symbolicName = attrs.SymbolicName;
407
- this.isDraft = attrs.ReleaseStatus === "Draft";
408
- this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
409
- this.definitionFields = [];
410
- },
411
- finish() {
412
- if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
413
- return;
414
- }
415
- const definitionFields = this.definitionFields;
416
- // replace DataType with nodeId, and description to LocalizedText
417
- definitionFields.map((x) => {
418
- if (x.description) {
419
- x.description = { text: x.description };
420
- }
421
- if (x.displayName) {
422
- x.displayName = { text: x.displayName };
423
- }
424
- if (x.dataType) {
425
- x.dataType = convertToNodeId(x.dataType);
426
- }
427
- return x;
428
- });
429
- this.obj.partialDefinition = definitionFields;
430
- let capturedDataTypeNode = _internal_createNode(this.obj);
431
- const processBasicDataType = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
432
- const definitionName = capturedDataTypeNode.browseName.name;
433
- const isStructure = capturedDataTypeNode.isStructure();
434
- const isEnumeration = capturedDataTypeNode.isEnumeration();
435
- if (!isEnumeration && !isStructure && capturedDataTypeNode.nodeId.namespace !== 0) {
436
- // add a custom basic type that is not a structure nor a enumeration
437
- pendingSimpleTypeToRegister.push({ name: definitionName, dataTypeNodeId: capturedDataTypeNode.nodeId });
438
- }
439
- capturedDataTypeNode = undefined;
440
- });
441
- postTasks.push(processBasicDataType);
442
- },
443
- parser: {
444
- DisplayName: {
445
- finish() {
446
- this.parent.obj.displayName = this.text;
447
- }
448
- },
449
- Description: {
450
- finish() {
451
- this.parent.obj.description = this.text;
452
- }
453
- },
454
- References: references_parser,
455
- Definition: node_opcua_xml2json_1._definitionParser
456
- }
457
- };
458
- const localizedText_parser = {
459
- LocalizedText: {
460
- init() {
461
- this.localizedText = {};
462
- },
463
- parser: {
464
- Locale: {
465
- finish() {
466
- this.parent.localizedText.locale = this.text.trim();
467
- }
468
- },
469
- Text: {
470
- finish() {
471
- this.parent.localizedText.text = this.text.trim();
472
- }
473
- }
474
- }
475
- }
476
- };
477
- const qualifiedName_parser = {
478
- QualifiedName: {
479
- init() {
480
- this.qualifiedName = {
481
- namespaceIndex: 0,
482
- name: null
483
- };
484
- },
485
- parser: {
486
- Name: {
487
- finish() {
488
- this.parent.qualifiedName.name = this.text.trim();
489
- }
490
- },
491
- NamespaceIndex: {
492
- finish() {
493
- const ns = parseInt(this.text, 10);
494
- const t = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(`ns=${ns};i=1`).toString());
495
- this.parent.qualifiedName.namespaceIndex = t.namespace;
496
- }
497
- }
498
- }
499
- }
500
- };
501
- const nodeId_parser = {
502
- NodeId: {
503
- init() {
504
- this.nodeId = "";
505
- },
506
- parser: {
507
- Identifier: {
508
- finish() {
509
- this.parent.nodeId = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
510
- }
511
- }
512
- }
513
- }
514
- };
515
- const enumValueType_parser = {
516
- EnumValueType: {
517
- init() {
518
- this.enumValueType = new node_opcua_types_1.EnumValueType({
519
- description: undefined,
520
- displayName: undefined,
521
- value: [0, 0] // Int64
522
- });
523
- },
524
- parser: {
525
- Value: {
526
- finish() {
527
- // Low part
528
- this.parent.enumValueType.value[1] = parseInt(this.text, 10);
529
- }
530
- },
531
- DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
532
- this.parent.enumValueType.displayName = Object.assign({}, this.localizedText);
533
- } }),
534
- Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
535
- this.parent.enumValueType.description = Object.assign({}, this.localizedText);
536
- } })
537
- },
538
- finish() {
539
- this.enumValueType = new node_opcua_types_1.EnumValueType(this.enumValueType);
540
- }
541
- }
542
- };
543
- const argument_parser = {
544
- Argument: {
545
- init() {
546
- this.argument = new node_opcua_service_call_1.Argument({});
547
- },
548
- parser: {
549
- Name: {
550
- finish() {
551
- this.parent.argument.name = this.text.trim();
552
- }
553
- },
554
- DataType: {
555
- parser: {
556
- Identifier: {
557
- finish() {
558
- this.parent.parent.argument.dataType = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
559
- }
560
- }
561
- }
562
- },
563
- ValueRank: {
564
- finish() {
565
- this.parent.argument.valueRank = parseInt(this.text.trim(), 10);
566
- }
567
- },
568
- ArrayDimensions: {
569
- finish() {
570
- // xx this.parent.argument.arrayDimensions =[];
571
- }
572
- },
573
- Description: {
574
- init() {
575
- this._text = "";
576
- this.locale = null;
577
- this.text = null;
578
- },
579
- parser: {
580
- Locale: {
581
- init() {
582
- this.text = "";
583
- },
584
- finish() {
585
- this.parent.locale = this.text.trim();
586
- }
587
- },
588
- Text: {
589
- finish() {
590
- this.text = this.text || "";
591
- this.parent._text = this.text.trim();
592
- }
593
- }
594
- },
595
- finish() {
596
- this.parent.argument.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this._text);
597
- }
598
- }
599
- },
600
- finish() {
601
- // xx this.argument = new Argument(this.argument);
602
- }
603
- }
604
- };
605
- const Range_parser = {
606
- Range: {
607
- init() {
608
- this.range = new node_opcua_types_1.Range({});
609
- },
610
- parser: {
611
- Low: {
612
- finish() {
613
- this.parent.range.low = parseFloat(this.text);
614
- }
615
- },
616
- High: {
617
- finish() {
618
- this.parent.range.high = parseFloat(this.text);
619
- }
620
- }
621
- }
622
- }
623
- };
624
- const EUInformation_parser = {
625
- EUInformation: {
626
- init() {
627
- this.euInformation = new node_opcua_data_access_1.EUInformation({});
628
- },
629
- parser: {
630
- NamespaceUri: {
631
- finish() {
632
- this.parent.euInformation.namespaceUri = this.text;
633
- }
634
- },
635
- UnitId: {
636
- finish() {
637
- this.parent.euInformation.unitId = parseInt(this.text, 10);
638
- }
639
- },
640
- DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
641
- this.parent.euInformation.displayName = Object.assign({}, this.localizedText);
642
- } }),
643
- Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
644
- this.parent.euInformation.description = Object.assign({}, this.localizedText);
645
- } })
646
- },
647
- finish() {
648
- this.euInformation = new node_opcua_data_access_1.EUInformation(this.euInformation);
649
- }
650
- }
651
- };
652
- const _extensionObject_inner_parser = {
653
- TypeId: {
654
- parser: {
655
- Identifier: {
656
- finish() {
657
- const typeDefinitionId = this.text.trim();
658
- const self = this.parent.parent; // ExtensionObject
659
- self.typeDefinitionId = (0, node_opcua_nodeid_1.resolveNodeId)(typeDefinitionId);
660
- }
661
- }
662
- }
663
- },
664
- Body2: new node_opcua_xml2json_1.FragmentClonerParser(),
665
- Body: {
666
- parser: {
667
- Argument: argument_parser.Argument,
668
- EUInformation: EUInformation_parser.EUInformation,
669
- EnumValueType: enumValueType_parser.EnumValueType,
670
- Range: Range_parser.Range
671
- },
672
- startElement(elementName, attrs) {
673
- const self = this.parent; // ExtensionObject
674
- self.extensionObject = null;
675
- self.extensionObjectPojo = null;
676
- if (!Object.prototype.hasOwnProperty.call(this.parser, elementName)) {
677
- // treat it as a opaque XML bloc for the time being
678
- // until we find the definition of this object, so we know how to interpret the fields
679
- this._cloneFragment = new node_opcua_xml2json_1.InternalFragmentClonerReaderState();
680
- this.engine._promote(this._cloneFragment, this.engine.currentLevel, elementName, attrs);
681
- }
682
- },
683
- finish() {
684
- const self = this.parent; // ExtensionObject
685
- // typeDefinitionId is also the "Default XML" encoding nodeId !
686
- switch (self.typeDefinitionId.toString()) {
687
- case "i=7616": // EnumValueType
688
- case "ns=0;i=7616": // EnumValueType
689
- self.extensionObject = self.parser.Body.parser.EnumValueType.enumValueType;
690
- (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
691
- (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
692
- break;
693
- case "i=297": // Arguments
694
- case "ns=0;i=297": // Arguments
695
- self.extensionObject = self.parser.Body.parser.Argument.argument;
696
- (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
697
- (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
698
- break;
699
- case "i=888":
700
- case "ns=0;i=888": // EUInformation
701
- self.extensionObject = self.parser.Body.parser.EUInformation.euInformation;
702
- (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
703
- (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
704
- break;
705
- case "i=885": // Range
706
- case "ns=0;i=885":
707
- self.extensionObject = self.parser.Body.parser.Range.range;
708
- (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
709
- (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
710
- break;
711
- default: {
712
- // istanbul ignore next
713
- if (!this._cloneFragment) {
714
- // the XML file is probably not exposing standard UA extension object correctly.
715
- // this has been seen in some generated xml files using the dataType nodeId instead of the default encoding
716
- // nodeid
717
- errorLog("[NODE-OPCUA-E12] standard OPCUA Extension object from (namespace=0) has a invalid TypeId", self.typeDefinitionId.toString());
718
- break;
719
- }
720
- this.bodyXML = this._cloneFragment.value;
721
- this._cloneFragment.value = null;
722
- // the "Default Xml" encoding nodeId
723
- const xmlEncodingNodeId = _translateNodeId(self.typeDefinitionId.toString());
724
- if (xmlEncodingNodeId.isEmpty()) {
725
- debugLog("xmlEncodingNodeId is empty for " + self.typeDefinitionId.toString());
726
- break;
727
- }
728
- let captureXmlBody = this.bodyXML;
729
- if (doDebug) {
730
- debugLog("xxxx ", chalk.yellow(captureXmlBody));
731
- }
732
- // this is a user defined Extension Object
733
- debugLog("load nodeset2: typeDefinitionId in ExtensionObject Default XML = " + xmlEncodingNodeId.toString());
734
- let captured = self.postTaskData;
735
- self.extensionObjectPojo = null;
736
- const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
737
- const extensionObject = yield (0, decode_xml_extension_object_1.decodeXmlExtensionObject)(addressSpace2, xmlEncodingNodeId, captureXmlBody);
738
- if (captured) {
739
- captured.postponedExtensionObject = extensionObject;
740
- }
741
- captureXmlBody = undefined;
742
- captured = undefined;
743
- });
744
- postTasks0_DecodePojoString.push(task);
745
- (0, node_opcua_assert_1.assert)(!self.extensionObject || self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
746
- break;
747
- }
748
- }
749
- }
750
- }
751
- };
752
- const extensionObject_parser = {
753
- ExtensionObject: {
754
- init() {
755
- this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
756
- this.extensionObject = null;
757
- this.extensionObjectPojo = null;
758
- this.postTaskData = { postponedExtensionObject: null };
759
- },
760
- parser: _extensionObject_inner_parser,
761
- finish() {
762
- /* empty */
763
- }
764
- }
765
- };
766
- function BasicType_parser(dataType, parseFunc) {
767
- const _parser = {};
768
- const r = {
769
- init(name, attrs) {
770
- this.value = undefined;
771
- },
772
- finish() {
773
- this.value = parseFunc.call(this, this.text);
774
- }
775
- };
776
- _parser[dataType] = r;
777
- return _parser;
778
- }
779
- function ListOf(dataType, parseFunc) {
780
- return {
781
- init() {
782
- this.listData = [];
783
- },
784
- parser: BasicType_parser(dataType, parseFunc),
785
- finish() {
786
- this.parent.parent.obj.value = {
787
- arrayType: node_opcua_variant_1.VariantArrayType.Array,
788
- dataType: node_opcua_variant_1.DataType[dataType],
789
- value: this.listData
790
- };
791
- },
792
- endElement(element) {
793
- this.listData.push(this.parser[dataType].value);
794
- }
795
- };
796
- }
797
- function parser2(type, p) {
798
- return {
799
- finish() {
800
- this.parent.parent.obj.value = {
801
- arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
802
- dataType: node_opcua_variant_1.DataType[type],
803
- value: p(this.text)
804
- };
805
- }
806
- };
807
- }
808
- const parseUInt64 = (str) => (0, node_opcua_basic_types_1.coerceUInt64)(str);
809
- const parseInt64 = (str) => (0, node_opcua_basic_types_1.coerceInt64)(str);
810
- const state_Variant = {
811
- init: () => {
812
- /* empty */
813
- },
814
- parser: {
815
- QualifiedName: Object.assign(Object.assign({}, qualifiedName_parser.QualifiedName), { finish() {
816
- this.parent.parent.obj.value = {
817
- dataType: node_opcua_variant_1.DataType.QualifiedName,
818
- value: this.qualifiedName
819
- };
820
- } }),
821
- LocalizedText: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
822
- this.parent.parent.obj.value = {
823
- dataType: node_opcua_variant_1.DataType.LocalizedText,
824
- value: this.localizedText
825
- };
826
- } }),
827
- XmlElement: {
828
- finish() {
829
- this.parent.parent.obj.value = {
830
- dataType: node_opcua_variant_1.DataType.XmlElement,
831
- value: this.text
832
- };
833
- }
834
- },
835
- String: {
836
- finish() {
837
- this.parent.parent.obj.value = {
838
- dataType: node_opcua_variant_1.DataType.String,
839
- value: this.text
840
- };
841
- }
842
- },
843
- Guid: {
844
- parser: {
845
- String: {
846
- finish() {
847
- const guid = this.text;
848
- if (!(0, node_opcua_basic_types_1.isValidGuid)(guid)) {
849
- /* ?*/
850
- }
851
- this.parent.parent.parent.obj.value = {
852
- dataType: node_opcua_variant_1.DataType.Guid,
853
- arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
854
- value: this.text
855
- };
856
- }
857
- }
858
- }
859
- },
860
- NodeId: {
861
- parser: {
862
- Identifier: {
863
- finish() {
864
- const nodeId = this.text;
865
- this.parent.parent.parent.obj.value = {
866
- dataType: node_opcua_variant_1.DataType.NodeId,
867
- arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
868
- value: _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(nodeId).toString())
869
- };
870
- }
871
- }
872
- }
873
- },
874
- Boolean: parser2("Boolean", ec.coerceBoolean),
875
- Byte: parser2("Byte", parseInt),
876
- Int16: parser2("Int16", parseInt),
877
- Int32: parser2("Int32", parseInt),
878
- Int8: parser2("Int8", parseInt),
879
- SByte: parser2("SByte", parseInt),
880
- UInt16: parser2("UInt16", parseInt),
881
- UInt32: parser2("UInt32", parseInt),
882
- UInt8: parser2("UInt8", parseInt),
883
- UInt64: parser2("UInt64", parseUInt64),
884
- Int64: parser2("Int64", parseInt64),
885
- ByteString: {
886
- init() {
887
- this.value = null;
888
- },
889
- finish() {
890
- const base64text = this.text;
891
- const byteString = Buffer.from(base64text, "base64");
892
- this.parent.parent.obj.value = {
893
- arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
894
- dataType: node_opcua_variant_1.DataType.ByteString,
895
- value: byteString
896
- };
897
- }
898
- },
899
- Float: {
900
- finish() {
901
- this.parent.parent.obj.value = {
902
- dataType: node_opcua_variant_1.DataType.Float,
903
- value: parseFloat(this.text)
904
- };
905
- }
906
- },
907
- Double: {
908
- finish() {
909
- this.parent.parent.obj.value = {
910
- dataType: node_opcua_variant_1.DataType.Double,
911
- value: parseFloat(this.text)
912
- };
913
- }
914
- },
915
- ListOfExtensionObject: {
916
- init() {
917
- this.listExtensionObject = [];
918
- },
919
- parser: extensionObject_parser,
920
- finish() {
921
- installExtensionObjectListInitializationPostTask(this);
922
- },
923
- startElement(elementName) {
924
- /* empty */
925
- const extensionObjectParser = this.parser.ExtensionObject;
926
- extensionObjectParser.postTaskData = { postponedExtensionObject: null };
927
- },
928
- endElement(elementName) {
929
- const extensionObjectParser = this.parser.ExtensionObject;
930
- this.listExtensionObject.push(extensionObjectParser.extensionObject);
931
- if (this.parser.ExtensionObject.extensionObject === null) {
932
- // extension object creation will be postponed
933
- const index = this.listExtensionObject.length - 1;
934
- let capturedData = extensionObjectParser.postTaskData;
935
- // istanbul ignore next
936
- if (!capturedData) {
937
- throw new Error("Internal Error : postponedExtensionObject not resolved");
938
- }
939
- let listExtensionObject = this.listExtensionObject;
940
- const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
941
- // istanbul ignore next
942
- if (!capturedData.postponedExtensionObject) {
943
- throw new Error("Internal Error : postponedExtensionObject not resolved");
944
- }
945
- listExtensionObject[index] = capturedData.postponedExtensionObject;
946
- capturedData = undefined;
947
- listExtensionObject = undefined;
948
- });
949
- postTasks2_AssignedExtensionObjectToDataValue.push(task);
950
- }
951
- }
952
- },
953
- ListOfLocalizedText: {
954
- init() {
955
- this.listData = [];
956
- },
957
- parser: localizedText_parser,
958
- finish() {
959
- this.parent.parent.obj.value = {
960
- arrayType: node_opcua_variant_1.VariantArrayType.Array,
961
- dataType: node_opcua_variant_1.DataType.LocalizedText,
962
- value: this.listData
963
- };
964
- },
965
- endElement() {
966
- this.listData.push(this.parser.LocalizedText.localizedText);
967
- }
968
- },
969
- ListOfQualifiedName: {
970
- init() {
971
- this.listData = [];
972
- },
973
- parser: qualifiedName_parser,
974
- finish() {
975
- this.parent.parent.obj.value = {
976
- arrayType: node_opcua_variant_1.VariantArrayType.Array,
977
- dataType: node_opcua_variant_1.DataType.QualifiedName,
978
- value: this.listData
979
- };
980
- },
981
- endElement() {
982
- this.listData.push(this.parser.QualifiedName.qualifiedName);
983
- }
984
- },
985
- ListOfNodeId: {
986
- init() {
987
- this.listData = [];
988
- },
989
- parser: nodeId_parser,
990
- finish() {
991
- this.parent.parent.obj.value = {
992
- arrayType: node_opcua_variant_1.VariantArrayType.Array,
993
- dataType: node_opcua_variant_1.DataType.NodeId,
994
- value: this.listData
995
- };
996
- },
997
- endElement(elementName) {
998
- this.listData.push(this.parser.NodeId.nodeId);
999
- }
1000
- },
1001
- ListOfBoolean: ListOf("Boolean", ec.coerceBoolean),
1002
- ListOfByte: ListOf("Byte", parseInt),
1003
- ListOfDouble: ListOf("Double", parseFloat),
1004
- ListOfFloat: ListOf("Float", parseFloat),
1005
- ListOfInt32: ListOf("Int32", parseInt),
1006
- ListOfInt16: ListOf("Int16", parseInt),
1007
- ListOfInt8: ListOf("Int8", parseInt),
1008
- ListOfUInt32: ListOf("UInt32", parseInt),
1009
- ListOfUInt16: ListOf("UInt16", parseInt),
1010
- ListOfUInt8: ListOf("UInt8", parseInt),
1011
- ListOfString: ListOf("String", (value) => value),
1012
- ListOfXmlElement: ListOf("XmlElement", (value) => value),
1013
- ExtensionObject: {
1014
- init() {
1015
- this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
1016
- this.extensionObject = null;
1017
- this.postTaskData = { postponedExtensionObject: null };
1018
- },
1019
- parser: _extensionObject_inner_parser,
1020
- finish() {
1021
- // istanbul ignore next
1022
- if (this.extensionObject && !(this.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject)) {
1023
- throw new Error("expecting an extension object");
1024
- }
1025
- this.parent.parent.obj.value = {
1026
- dataType: node_opcua_variant_1.DataType.ExtensionObject,
1027
- value: this.extensionObject
1028
- };
1029
- if (!this.extensionObject) {
1030
- installExtensionObjectInitializationPostTask(this);
1031
- }
1032
- }
1033
- }
1034
- }
1035
- };
1036
- function installExtensionObjectListInitializationPostTask(element) {
1037
- let listExtensionObject = element.listExtensionObject;
1038
- let nodeId = element.parent.parent.obj.nodeId;
1039
- (0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
1040
- const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1041
- const node = addressSpace2.findNode(nodeId);
1042
- if (!node) {
1043
- debugLog("Cannot find node with nodeId " + nodeId + ". may be the node was marked as deprecated");
1044
- }
1045
- else if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
1046
- const v = node;
1047
- (0, node_opcua_assert_1.assert)(v.getBasicDataType() === node_opcua_variant_1.DataType.ExtensionObject, "expecting an extension object");
1048
- v.bindExtensionObject(listExtensionObject, { createMissingProp: false });
1049
- }
1050
- else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
1051
- // no need to bind a variable type
1052
- const v = node;
1053
- v /*fix me*/.value.value = listExtensionObject;
1054
- }
1055
- listExtensionObject.slice(0);
1056
- listExtensionObject = undefined;
1057
- nodeId = undefined;
1058
- });
1059
- postTasks2_AssignedExtensionObjectToDataValue.push(task);
1060
- }
1061
- function installExtensionObjectInitializationPostTask(element) {
1062
- // let's create the mechanism that postpone the creation of the
1063
- // extension object
1064
- let data = element.postTaskData;
1065
- let variant = element.parent.parent.obj.value;
1066
- let nodeId = element.parent.parent.obj.nodeId;
1067
- const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1068
- variant.value = data.postponedExtensionObject;
1069
- (0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
1070
- const node = addressSpace2.findNode(nodeId);
1071
- if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
1072
- const v = node;
1073
- (0, node_opcua_assert_1.assert)(v.getBasicDataType() === node_opcua_variant_1.DataType.ExtensionObject, "expecting an extension object");
1074
- v.bindExtensionObject(variant.value, { createMissingProp: false });
1075
- }
1076
- else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
1077
- const v = node;
1078
- v /*fix me*/.value.value = variant.value;
1079
- }
1080
- data.postponedExtensionObject = null;
1081
- data = undefined;
1082
- variant = undefined;
1083
- nodeId = undefined;
1084
- });
1085
- postTasks2_AssignedExtensionObjectToDataValue.push(task);
1086
- }
1087
- const canIngore = ({ isDraft, isDeprecated }, node) => {
1088
- if (isDraft && !options.loadDraftNodes) {
1089
- debugLog("Ignoring Draft =", node_opcua_data_model_1.NodeClass[node.nodeClass], node.browseName.toString());
1090
- return true;
1091
- }
1092
- if (isDeprecated && !options.loadDeprecatedNodes) {
1093
- debugLog("Ignoring Deprecate =", node_opcua_data_model_1.NodeClass[node.nodeClass], node.browseName.toString());
1094
- return true;
1095
- }
1096
- return false;
1097
- };
1098
- const state_UAVariable = {
1099
- init(name, attrs) {
1100
- _perform();
1101
- this.obj = {};
1102
- this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
1103
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1104
- this.obj.parentNodeId = convertToNodeId(attrs.ParentNodeId);
1105
- this.obj.dataType = convertToNodeId(attrs.DataType);
1106
- this.obj.valueRank = attrs.ValueRank === undefined ? -1 : ec.coerceInt32(attrs.ValueRank);
1107
- this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
1108
- this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
1109
- this.obj.minimumSamplingInterval = parseInt(this.obj.minimumSamplingInterval, 10);
1110
- this.obj.historizing = false;
1111
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1112
- this.obj.accessLevel = convertAccessLevel(attrs.AccessLevel);
1113
- this.obj.userAccessLevel = this.obj.accessLevel; // convertAccessLevel(attrs.UserAccessLevel || attrs.AccessLevel);
1114
- this.isDraft = attrs.ReleaseStatus === "Draft";
1115
- this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1116
- },
1117
- finish() {
1118
- if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1119
- return;
1120
- }
1121
- /*
1122
- // set default value based on obj data Type
1123
- if (this.obj.value === undefined) {
1124
- const dataTypeNode = this.obj.dataType;
1125
- const valueRank = this.obj.valueRank;
1126
- this.obj.value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
1127
- }
1128
- */
1129
- // eslint-disable-next-line prefer-const
1130
- let capturedVariable;
1131
- if (this.obj.value) {
1132
- let capturedValue = this.obj.value;
1133
- const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1134
- if (false && doDebug) {
1135
- debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new node_opcua_variant_1.Variant(capturedValue).toString());
1136
- }
1137
- capturedVariable.setValueFromSource(capturedValue);
1138
- capturedValue = undefined;
1139
- capturedVariable = undefined;
1140
- });
1141
- if (capturedValue.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
1142
- postTasks0_InitializeVariable.push(task);
1143
- }
1144
- else {
1145
- // do them later
1146
- postTasks1_InitializeVariable.push(task);
1147
- }
1148
- }
1149
- else {
1150
- const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1151
- const dataTypeNode = capturedVariable.dataType;
1152
- const valueRank = capturedVariable.valueRank;
1153
- const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
1154
- if (value) {
1155
- if (false && doDebug) {
1156
- debugLog("2 setting value to ", capturedVariable.nodeId.toString(), value);
1157
- }
1158
- if (value.dataType === node_opcua_variant_1.DataType.Null) {
1159
- capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.BadWaitingForInitialData);
1160
- }
1161
- else {
1162
- capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.Good);
1163
- }
1164
- }
1165
- capturedVariable = undefined;
1166
- });
1167
- postTasks0_InitializeVariable.push(task);
1168
- }
1169
- this.obj.value = undefined;
1170
- capturedVariable = _internal_createNode(this.obj);
1171
- },
1172
- parser: {
1173
- DisplayName: {
1174
- finish() {
1175
- this.parent.obj.displayName = this.text;
1176
- }
1177
- },
1178
- Description: {
1179
- finish() {
1180
- this.parent.obj.description = this.text;
1181
- }
1182
- },
1183
- References: references_parser,
1184
- Value: state_Variant
1185
- }
1186
- };
1187
- const state_UAVariableType = {
1188
- init(name, attrs) {
1189
- _perform();
1190
- this.obj = {};
1191
- this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
1192
- this.obj.nodeClass = node_opcua_data_model_1.NodeClass.VariableType;
1193
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1194
- this.obj.parentNodeId = attrs.ParentNodeId || null;
1195
- this.obj.dataType = convertToNodeId(attrs.DataType) || null;
1196
- this.obj.valueRank = ec.coerceInt32(attrs.ValueRank) || -1;
1197
- this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
1198
- this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
1199
- this.obj.historizing = false;
1200
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1201
- this.isDraft = attrs.ReleaseStatus === "Draft";
1202
- this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1203
- },
1204
- finish() {
1205
- if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1206
- return;
1207
- }
1208
- try {
1209
- _internal_createNode(this.obj);
1210
- } /* istanbul ignore next */
1211
- catch (err) {
1212
- this.obj.addressSpace = null;
1213
- // tslint:disable:no-console
1214
- console.warn(" Cannot create object", JSON.stringify(this.obj, null, " "));
1215
- throw err;
1216
- }
1217
- },
1218
- parser: {
1219
- DisplayName: {
1220
- finish() {
1221
- this.parent.obj.displayName = this.text;
1222
- }
1223
- },
1224
- Description: {
1225
- finish() {
1226
- this.parent.obj.description = this.text;
1227
- }
1228
- },
1229
- References: references_parser,
1230
- Value: state_Variant
1231
- }
1232
- };
1233
- const state_UAMethod = {
1234
- init(name, attrs) {
1235
- _perform();
1236
- this.obj = {};
1237
- this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Method;
1238
- // MethodDeclarationId
1239
- // ParentNodeId
1240
- this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1241
- this.obj.parentNodeId = attrs.ParentNodeId || null;
1242
- this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1243
- this.obj.methodDeclarationId = attrs.MethodDeclarationId ? _translateNodeId(attrs.MethodDeclarationId) : null;
1244
- this.isDraft = attrs.ReleaseStatus === "Draft";
1245
- this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1246
- },
1247
- finish() {
1248
- if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1249
- return;
1250
- }
1251
- _internal_createNode(this.obj);
1252
- },
1253
- parser: {
1254
- DisplayName: {
1255
- finish() {
1256
- this.parent.obj.displayName = this.text;
1257
- }
1258
- },
1259
- References: references_parser
1260
- }
1261
- };
1262
- const state_ModelTableEntry = new node_opcua_xml2json_1.ReaderState({
1263
- // ModelTableEntry
1264
- init() {
1265
- this._requiredModels = [];
1266
- },
1267
- parser: {
1268
- RequiredModel: {
1269
- init(name, attrs) {
1270
- const modelUri = attrs.ModelUri;
1271
- const version = attrs.Version;
1272
- const publicationDate = new Date(Date.parse(attrs.PublicationDate));
1273
- this.parent._requiredModels.push({ modelUri, version, publicationDate });
1274
- },
1275
- finish() {
1276
- /** */
1277
- }
1278
- }
1279
- },
1280
- finish() {
1281
- const modelUri = this.attrs.ModelUri; // //"http://opcfoundation.org/UA/"
1282
- const version = this.attrs.Version; // 1.04
1283
- const publicationDate = this.attrs.PublicationDate ? new Date(Date.parse(this.attrs.PublicationDate)) : undefined; // "2018-05-15T00:00:00Z" "
1284
- // optional,
1285
- const symbolicName = this.attrs.SymbolicName;
1286
- const accessRestrictions = this.attrs.AccessRestrictions;
1287
- const model = {
1288
- accessRestrictions,
1289
- modelUri,
1290
- publicationDate,
1291
- requiredModels: this._requiredModels,
1292
- symbolicName,
1293
- version
1294
- };
1295
- const namespace = _add_namespace(model);
1296
- models.push(model);
1297
- }
1298
- });
1299
- function _updateTranslationTable() {
1300
- _register_namespace_uri_in_translation_table("http://opcfoundation.org/UA/");
1301
- for (const namespaceUri of _namespaceUris) {
1302
- _register_namespace_uri_in_translation_table(namespaceUri);
1303
- }
1304
- }
1305
- function _perform() {
1306
- if (performedCalled)
1307
- return;
1308
- performedCalled = true;
1309
- /**special case for old nodeset file version 1.02 where no models exists */
1310
- if (models.length === 0) {
1311
- for (const namespaceuri of _namespaceUris) {
1312
- const existingNamespace = addressSpace1.getNamespace(namespaceuri);
1313
- if (existingNamespace) {
1314
- continue;
1315
- }
1316
- _add_namespace({
1317
- modelUri: namespaceuri,
1318
- version: "1.0.0",
1319
- requiredModels: []
1320
- });
1321
- }
1322
- }
1323
- _updateTranslationTable();
1324
- }
1325
- // state_ModelTableEntry.parser["RequiredModel"] = state_ModelTableEntry;
1326
- let _namespaceUris = [];
1327
- const state_0 = {
1328
- parser: {
1329
- Aliases: {
1330
- init() {
1331
- _perform();
1332
- },
1333
- parser: { Alias: state_Alias }
1334
- },
1335
- NamespaceUris: {
1336
- init() {
1337
- //
1338
- _namespaceUris = [];
1339
- },
1340
- parser: {
1341
- Uri: {
1342
- finish() {
1343
- _namespaceUris.push(this.text);
1344
- }
1345
- }
1346
- },
1347
- finish() {
1348
- // verify that requested namespaces are already loaded or abort with a message
1349
- }
1350
- },
1351
- Models: {
1352
- // ModelTable
1353
- init(name, attrs) {
1354
- /* */
1355
- },
1356
- parser: {
1357
- Model: state_ModelTableEntry
1358
- },
1359
- finish() {
1360
- /** */
1361
- }
1362
- },
1363
- UADataType: state_UADataType,
1364
- UAMethod: state_UAMethod,
1365
- UAObject: state_UAObject,
1366
- UAObjectType: state_UAObjectType,
1367
- UAReferenceType: state_UAReferenceType,
1368
- UAVariable: state_UAVariable,
1369
- UAVariableType: state_UAVariableType
1370
- }
1371
- };
1372
- const parser = new node_opcua_xml2json_1.Xml2Json(state_0);
1373
- function terminate(callback) {
1374
- var _a, _b, _c;
1375
- make_back_references(addressSpace1);
1376
- // setting up Server_NamespaceArray
1377
- if ((_c = (_b = (_a = addressSpace1.rootFolder) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.server) === null || _c === void 0 ? void 0 : _c.namespaceArray) {
1378
- addressSpace1.rootFolder.objects.server.namespaceArray.setValueFromSource({
1379
- arrayType: node_opcua_variant_1.VariantArrayType.Array,
1380
- dataType: node_opcua_variant_1.DataType.String,
1381
- value: addressSpace1.getNamespaceArray().map((ns) => ns.namespaceUri)
1382
- });
1383
- // istanbul ignore next
1384
- if (doDebug) {
1385
- debugLog("addressSpace NS = ", addressSpace1.rootFolder.objects.server.namespaceArray.readValue().value.value.join(" "));
1386
- }
1387
- }
1388
- doDebug &&
1389
- debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------") +
1390
- chalk.green("DONE"));
1391
- function performPostLoadingTasks(tasks) {
1392
- return __awaiter(this, void 0, void 0, function* () {
1393
- for (const task of tasks) {
1394
- try {
1395
- yield task(addressSpace1);
1396
- }
1397
- catch (err) {
1398
- // istanbul ignore next
1399
- // tslint:disable:no-console
1400
- if (err instanceof Error) {
1401
- console.log(" performPostLoadingTasks Err => ", err.message, "\n", err);
1402
- }
1403
- yield task(addressSpace1);
1404
- }
1405
- }
1406
- tasks.splice(0);
1407
- });
1408
- }
1409
- function finalSteps() {
1410
- return __awaiter(this, void 0, void 0, function* () {
1411
- /// ----------------------------------------------------------------------------------------
1412
- // perform post task
1413
- doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------"));
1414
- yield performPostLoadingTasks(postTasks);
1415
- doDebug &&
1416
- debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Simple Variables ---------------------"));
1417
- yield performPostLoadingTasks(postTasks0_InitializeVariable);
1418
- doDebug && debugLog(chalk.bgGreenBright("Performing DataType extraction -------------------------------------------"));
1419
- (0, node_opcua_assert_1.assert)(!addressSpace1.suspendBackReference);
1420
- yield (0, ensure_datatype_extracted_1.ensureDatatypeExtracted)(addressSpace);
1421
- const dataTypeManager = addressSpace.getDataTypeManager();
1422
- /// ----------------------------------------------------------------------------------------
1423
- doDebug && debugLog(chalk.bgGreenBright("DataType extraction done ") + chalk.green("DONE"));
1424
- for (const { name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
1425
- if (dataTypeNodeId.namespace === 0) {
1426
- continue;
1427
- }
1428
- const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(dataTypeNodeId.namespace);
1429
- }
1430
- pendingSimpleTypeToRegister.splice(0);
1431
- doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Decoding Pojo String (parsing XML objects) -"));
1432
- yield performPostLoadingTasks(postTasks0_DecodePojoString);
1433
- doDebug &&
1434
- debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Complex Variables ---------------------"));
1435
- yield performPostLoadingTasks(postTasks1_InitializeVariable);
1436
- doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks: (assigning Extension Object to Variables) -"));
1437
- yield performPostLoadingTasks(postTasks2_AssignedExtensionObjectToDataValue);
1438
- doDebug && debugLog(chalk.bgGreenBright("Performing post variable initialization ---------------------"));
1439
- (0, namespace_post_step_1.promoteObjectsAndVariables)(addressSpace);
1440
- });
1441
- }
1442
- finalSteps()
1443
- .then(() => callback())
1444
- .catch((err1) => {
1445
- console.log("Error ", (0, node_opcua_assert_1.renderError)(err1));
1446
- callback(err1);
1447
- });
1448
- }
1449
- function addNodeSet(xmlData, callback1) {
1450
- _reset_namespace_translation();
1451
- parser.parseString(xmlData, callback1);
1452
- }
1453
- return {
1454
- addNodeSet,
1455
- terminate
1456
- };
1457
- }
1458
- class NodeSetLoader {
1459
- constructor(addressSpace, options) {
1460
- this.options = options;
1461
- this._s = makeNodeSetParserEngine(addressSpace, options || {});
1462
- }
1463
- addNodeSet(xmlData, callback) {
1464
- if (!callback) {
1465
- throw new Error("Expecting callback function");
1466
- }
1467
- return this._s.addNodeSet(xmlData, callback);
1468
- }
1469
- addNodeSetAsync(xmlData) {
1470
- return __awaiter(this, void 0, void 0, function* () {
1471
- return (0, util_1.promisify)(this.addNodeSet).call(this, xmlData);
1472
- });
1473
- }
1474
- terminate(callback) {
1475
- this._s.terminate(callback);
1476
- }
1477
- terminateAsync() {
1478
- return __awaiter(this, void 0, void 0, function* () {
1479
- return (0, util_1.promisify)(this.terminate).call(this);
1480
- });
1481
- }
1482
- }
1483
- exports.NodeSetLoader = NodeSetLoader;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NodeSetLoader = void 0;
13
+ /* eslint-disable max-statements */
14
+ /**
15
+ * @module node-opcua-address-space
16
+ */
17
+ const util_1 = require("util");
18
+ const chalk = require("chalk");
19
+ const ec = require("node-opcua-basic-types");
20
+ const node_opcua_assert_1 = require("node-opcua-assert");
21
+ const node_opcua_basic_types_1 = require("node-opcua-basic-types");
22
+ const node_opcua_data_access_1 = require("node-opcua-data-access");
23
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
24
+ const node_opcua_debug_1 = require("node-opcua-debug");
25
+ const node_opcua_extension_object_1 = require("node-opcua-extension-object");
26
+ const node_opcua_factory_1 = require("node-opcua-factory");
27
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
28
+ const node_opcua_service_call_1 = require("node-opcua-service-call");
29
+ const node_opcua_types_1 = require("node-opcua-types");
30
+ const node_opcua_variant_1 = require("node-opcua-variant");
31
+ const node_opcua_xml2json_1 = require("node-opcua-xml2json");
32
+ const semver = require("semver");
33
+ const namespace_post_step_1 = require("./namespace_post_step");
34
+ const ensure_datatype_extracted_1 = require("./ensure_datatype_extracted");
35
+ const decode_xml_extension_object_1 = require("./decode_xml_extension_object");
36
+ const make_semver_compatible_1 = require("./make_semver_compatible");
37
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
38
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
39
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
40
+ function __make_back_references(namespace) {
41
+ const namespaceP = namespace;
42
+ for (const node of namespaceP.nodeIterator()) {
43
+ node.propagate_back_references();
44
+ }
45
+ for (const node of namespaceP.nodeIterator()) {
46
+ node.install_extra_properties();
47
+ }
48
+ }
49
+ function make_back_references(addressSpace) {
50
+ const addressSpacePrivate = addressSpace;
51
+ addressSpacePrivate.suspendBackReference = false;
52
+ addressSpace.getNamespaceArray().map(__make_back_references);
53
+ }
54
+ function stringToUInt32Array(str) {
55
+ const array = str ? str.split(",").map((value) => parseInt(value, 10)) : null;
56
+ return array;
57
+ }
58
+ function convertAccessLevel(accessLevel) {
59
+ const accessLevelN = parseInt(accessLevel || "1", 10); // CurrentRead if not specified
60
+ return (0, node_opcua_data_model_1.makeAccessLevelFlag)(accessLevelN);
61
+ }
62
+ function makeDefaultVariant(addressSpace, dataTypeNode, valueRank) {
63
+ let variant = { dataType: node_opcua_variant_1.DataType.Null };
64
+ const nodeDataType = addressSpace.findNode(dataTypeNode);
65
+ if (nodeDataType && nodeDataType.basicDataType) {
66
+ const basicDataType = nodeDataType.basicDataType;
67
+ if (basicDataType === node_opcua_variant_1.DataType.Variant) {
68
+ /// we don't now what is the variant
69
+ return undefined;
70
+ }
71
+ if (basicDataType === node_opcua_variant_1.DataType.ExtensionObject) {
72
+ return { dataType: node_opcua_variant_1.DataType.ExtensionObject, value: null };
73
+ }
74
+ const builtInType = (0, node_opcua_factory_1.getBuiltInType)(node_opcua_variant_1.DataType[basicDataType]);
75
+ if (builtInType === undefined || builtInType === null) {
76
+ errorLog("Cannot find builtInType for ", basicDataType);
77
+ return { dataType: node_opcua_variant_1.DataType.Null };
78
+ }
79
+ const dv = builtInType.defaultValue;
80
+ const value = typeof dv === "function" ? dv() : dv;
81
+ let arrayType;
82
+ /*
83
+ * * n > 1 : the Value is an array with the specified number of dimensions.
84
+ * * OneDimension (1): The value is an array with one dimension.
85
+ * * OneOrMoreDimensions (0): The value is an array with one or more dimensions.
86
+ * * Scalar (-1): The value is not an array.
87
+ * * Any (-2): The value can be a scalar or an array with any number of dimensions.
88
+ * * ScalarOrOneDimension (-3): The value can be a scalar or a one dimensional array.
89
+ */
90
+ switch (valueRank) {
91
+ case -3: // ScalarOrOneDimension (-3):
92
+ case -2: // any
93
+ case -1:
94
+ arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
95
+ variant = { dataType: basicDataType, value, arrayType };
96
+ break;
97
+ case 0: // one or more dimension
98
+ case 1: // one dimension
99
+ arrayType = node_opcua_variant_1.VariantArrayType.Array;
100
+ variant = { dataType: basicDataType, value: [], arrayType };
101
+ break;
102
+ default:
103
+ arrayType = node_opcua_variant_1.VariantArrayType.Matrix;
104
+ variant = { dataType: basicDataType, value: [], arrayType, dimensions: [] };
105
+ break;
106
+ }
107
+ }
108
+ return variant;
109
+ }
110
+ function makeNodeSetParserEngine(addressSpace, options) {
111
+ const addressSpace1 = addressSpace;
112
+ addressSpace1.suspendBackReference = true;
113
+ options.loadDeprecatedNodes = options.loadDeprecatedNodes === undefined ? true : options.loadDeprecatedNodes;
114
+ options.loadDraftNodes = options.loadDraftNodes || false;
115
+ const postTasks = [];
116
+ const postTasks0_InitializeVariable = [];
117
+ const postTasks0_DecodePojoString = [];
118
+ const postTasks1_InitializeVariable = [];
119
+ const postTasks2_AssignedExtensionObjectToDataValue = [];
120
+ let alias_map = {};
121
+ /**
122
+ * @param aliasName
123
+ */
124
+ function addAlias(aliasName, nodeIdInXmlContext) {
125
+ (0, node_opcua_assert_1.assert)(typeof nodeIdInXmlContext === "string");
126
+ const nodeId = _translateNodeId(nodeIdInXmlContext);
127
+ (0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
128
+ alias_map[aliasName] = nodeId;
129
+ addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
130
+ }
131
+ let namespace_uri_translation = {};
132
+ let namespaceCounter = 0;
133
+ let found_namespace_in_uri = {};
134
+ let models = [];
135
+ let performedCalled = false;
136
+ function _reset_namespace_translation() {
137
+ debugLog("_reset_namespace_translation");
138
+ namespace_uri_translation = {};
139
+ found_namespace_in_uri = {};
140
+ namespaceCounter = 0;
141
+ alias_map = {};
142
+ models = [];
143
+ performedCalled = false;
144
+ }
145
+ function _translateNamespaceIndex(innerIndex) {
146
+ const namespaceIndex = namespace_uri_translation[innerIndex];
147
+ // istanbul ignore next
148
+ if (namespaceIndex === undefined) {
149
+ debugLog("Warning: namespace_uri_translation = ", namespace_uri_translation);
150
+ errorLog("namespace_uri_translation", namespace_uri_translation);
151
+ throw new Error("_translateNamespaceIndex() ! Cannot find namespace definition for index " + innerIndex);
152
+ }
153
+ return namespaceIndex;
154
+ }
155
+ function _internal_addReferenceType(params) {
156
+ // istanbul ignore next
157
+ if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
158
+ throw new Error("invalid param");
159
+ } // already translated
160
+ const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
161
+ namespace.addReferenceType(params);
162
+ }
163
+ function _internal_createNode(params) {
164
+ // istanbul ignore next
165
+ if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
166
+ throw new Error("invalid param expecting a valid nodeId");
167
+ } // already translated
168
+ const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
169
+ return namespace.internalCreateNode(params);
170
+ }
171
+ function _register_namespace_uri_in_translation_table(namespaceUri) {
172
+ if (found_namespace_in_uri[namespaceUri]) {
173
+ return;
174
+ }
175
+ const namespace = addressSpace1.getNamespace(namespaceUri);
176
+ // istanbul ignore next
177
+ if (!namespace) {
178
+ throw new Error("cannot find namespace for " +
179
+ namespaceUri +
180
+ "\nplease make sure to initialize your address space with the corresponding nodeset files");
181
+ }
182
+ found_namespace_in_uri[namespaceUri] = namespace;
183
+ const index_in_xml = namespaceCounter;
184
+ namespaceCounter++;
185
+ namespace_uri_translation[index_in_xml] = namespace.index;
186
+ doDebug &&
187
+ debugLog(" _register_namespace_uri = ", namespaceUri, "index in Xml=", index_in_xml, " index in addressSpace", namespace.index);
188
+ }
189
+ function _add_namespace(model) {
190
+ if (model.requiredModels.length > 0) {
191
+ // check that required models exist already in the address space
192
+ for (const requiredModel of model.requiredModels) {
193
+ const existingNamespace = addressSpace1.getNamespace(requiredModel.modelUri);
194
+ // istanbul ignore next
195
+ if (!existingNamespace) {
196
+ errorLog("Please ensure that the required namespace ", requiredModel.modelUri, "is loaded firs when loading ", model.modelUri);
197
+ throw new Error("LoadNodeSet : Cannot find namespace for " + requiredModel.modelUri);
198
+ }
199
+ /**
200
+ * from https://reference.opcfoundation.org/Core/docs/Part6/F.2/
201
+ * The version of the model defined in the UANodeSet.
202
+ * This is a human readable string and not intended for programmatic comparisons.
203
+ *
204
+ */
205
+ const isLowerVersion = (existingVersion, requiredVersion) => {
206
+ const existingSemver = (0, make_semver_compatible_1.makeSemverCompatible)(existingVersion);
207
+ const requiredSemver = (0, make_semver_compatible_1.makeSemverCompatible)(requiredVersion);
208
+ return semver.lt(existingSemver, requiredSemver);
209
+ };
210
+ if (isLowerVersion(existingNamespace.version, requiredModel.version)) {
211
+ errorLog("Expecting ", requiredModel.modelUri, " with version to be at least", requiredModel.version, " but namespace version is ", existingNamespace.version);
212
+ }
213
+ if (existingNamespace.publicationDate.getTime() < requiredModel.publicationDate.getTime()) {
214
+ errorLog("Expecting ", requiredModel.modelUri, " with publicationDatea at least ", requiredModel.publicationDate.toUTCString(), " but namespace publicationDate is ", existingNamespace.publicationDate.toUTCString());
215
+ }
216
+ }
217
+ }
218
+ let namespace;
219
+ // Model must not be already registered
220
+ const existingNamespace = addressSpace1.getNamespace(model.modelUri);
221
+ if (existingNamespace) {
222
+ // special treatment for namespace 0
223
+ // istanbul ignore else
224
+ if (model.modelUri === "http://opcfoundation.org/UA/") {
225
+ namespace = existingNamespace;
226
+ }
227
+ else {
228
+ throw new Error(" namespace already registered " + model.modelUri);
229
+ }
230
+ }
231
+ else {
232
+ namespace = addressSpace1.registerNamespace(model.modelUri);
233
+ namespace.setRequiredModels(model.requiredModels);
234
+ }
235
+ namespace.version = model.version;
236
+ namespace.publicationDate = model.publicationDate || namespace.publicationDate;
237
+ return namespace;
238
+ }
239
+ const reg = /ns=([0-9]+);(.*)/;
240
+ function _translateNodeId(nodeId) {
241
+ if (alias_map[nodeId]) {
242
+ return alias_map[nodeId];
243
+ }
244
+ const m = nodeId.match(reg);
245
+ if (m) {
246
+ const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
247
+ nodeId = "ns=" + namespaceIndex + ";" + m[2];
248
+ }
249
+ return (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
250
+ }
251
+ function _translateReferenceType(refType) {
252
+ return _translateNodeId(refType);
253
+ }
254
+ /**
255
+ * convert a nodeId
256
+ *
257
+ * @method convertToNodeId
258
+ * @param nodeId {String|null}
259
+ * @return {NodeId}
260
+ *
261
+ * @example
262
+ * convertToNodeId("String") => resolve alias
263
+ * convertToNodeId("i=58") => resolve to nodeId in namespace 0
264
+ * convertToNodeId("ns=1;i=100") => convert namespace from xml namespace
265
+ * table to corresponding namespace in addressSpace
266
+ */
267
+ function convertToNodeId(nodeIdLike) {
268
+ // treat alias
269
+ if (!nodeIdLike) {
270
+ return null;
271
+ }
272
+ const nodeId = _translateNodeId(nodeIdLike);
273
+ return addressSpace1.resolveNodeId(nodeId);
274
+ }
275
+ function convertQualifiedName(qualifiedName) {
276
+ const qn = (0, node_opcua_data_model_1.stringToQualifiedName)(qualifiedName);
277
+ // Xx if (qn.namespaceIndex > 0) {
278
+ qn.namespaceIndex = _translateNamespaceIndex(qn.namespaceIndex);
279
+ // Xx }
280
+ return qn;
281
+ }
282
+ const state_Alias = {
283
+ finish() {
284
+ addAlias(this.attrs.Alias, this.text);
285
+ }
286
+ };
287
+ const references_parser = {
288
+ init() {
289
+ this.parent.obj.references = [];
290
+ this.array = this.parent.obj.references;
291
+ },
292
+ parser: {
293
+ Reference: {
294
+ finish() {
295
+ this.parent.array.push({
296
+ isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward === "false" ? false : true,
297
+ nodeId: convertToNodeId(this.text),
298
+ referenceType: _translateReferenceType(this.attrs.ReferenceType)
299
+ });
300
+ }
301
+ }
302
+ }
303
+ };
304
+ const state_UAObject = {
305
+ init(name, attrs) {
306
+ _perform();
307
+ this.obj = {};
308
+ this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Object;
309
+ this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
310
+ this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
311
+ this.obj.browseName = convertQualifiedName(attrs.BrowseName);
312
+ this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
313
+ this.obj.symbolicName = attrs.SymbolicName || null;
314
+ this.isDraft = attrs.ReleaseStatus === "Draft";
315
+ this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
316
+ },
317
+ finish() {
318
+ if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
319
+ return;
320
+ }
321
+ _internal_createNode(this.obj);
322
+ },
323
+ parser: {
324
+ DisplayName: {
325
+ finish() {
326
+ this.parent.obj.displayName = this.text;
327
+ }
328
+ },
329
+ Description: {
330
+ finish() {
331
+ this.parent.obj.description = this.text;
332
+ }
333
+ },
334
+ References: references_parser
335
+ }
336
+ };
337
+ const state_UAObjectType = {
338
+ init(name, attrs) {
339
+ _perform();
340
+ this.obj = {};
341
+ this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ObjectType;
342
+ this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
343
+ this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
344
+ this.obj.browseName = convertQualifiedName(attrs.BrowseName);
345
+ this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
346
+ },
347
+ finish() {
348
+ _internal_createNode(this.obj);
349
+ },
350
+ parser: {
351
+ DisplayName: {
352
+ finish() {
353
+ this.parent.obj.displayName = this.text;
354
+ }
355
+ },
356
+ Description: {
357
+ finish() {
358
+ this.parent.obj.description = this.text;
359
+ }
360
+ },
361
+ References: references_parser
362
+ }
363
+ };
364
+ const state_UAReferenceType = {
365
+ init(name, attrs) {
366
+ _perform();
367
+ this.obj = {};
368
+ this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ReferenceType;
369
+ this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
370
+ this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
371
+ this.obj.browseName = convertQualifiedName(attrs.BrowseName);
372
+ },
373
+ finish() {
374
+ _internal_addReferenceType(this.obj);
375
+ },
376
+ parser: {
377
+ DisplayName: {
378
+ finish() {
379
+ this.parent.obj.displayName = this.text;
380
+ }
381
+ },
382
+ Description: {
383
+ finish() {
384
+ this.parent.obj.description = this.text;
385
+ }
386
+ },
387
+ InverseName: {
388
+ finish() {
389
+ this.parent.obj.inverseName = this.text;
390
+ }
391
+ },
392
+ References: references_parser
393
+ }
394
+ };
395
+ const pendingSimpleTypeToRegister = [];
396
+ const state_UADataType = {
397
+ init(name, attrs) {
398
+ _perform();
399
+ this.obj = {};
400
+ this.obj.nodeClass = node_opcua_data_model_1.NodeClass.DataType;
401
+ this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract) || false;
402
+ this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
403
+ this.obj.browseName = convertQualifiedName(attrs.BrowseName);
404
+ this.obj.displayName = "";
405
+ this.obj.description = "";
406
+ this.obj.symbolicName = attrs.SymbolicName;
407
+ this.isDraft = attrs.ReleaseStatus === "Draft";
408
+ this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
409
+ this.definitionFields = [];
410
+ },
411
+ finish() {
412
+ if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
413
+ return;
414
+ }
415
+ const definitionFields = this.definitionFields;
416
+ // replace DataType with nodeId, and description to LocalizedText
417
+ definitionFields.map((x) => {
418
+ if (x.description) {
419
+ x.description = { text: x.description };
420
+ }
421
+ if (x.displayName) {
422
+ x.displayName = { text: x.displayName };
423
+ }
424
+ if (x.dataType) {
425
+ x.dataType = convertToNodeId(x.dataType);
426
+ }
427
+ return x;
428
+ });
429
+ this.obj.partialDefinition = definitionFields;
430
+ let capturedDataTypeNode = _internal_createNode(this.obj);
431
+ const processBasicDataType = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
432
+ const definitionName = capturedDataTypeNode.browseName.name;
433
+ const isStructure = capturedDataTypeNode.isStructure();
434
+ const isEnumeration = capturedDataTypeNode.isEnumeration();
435
+ if (!isEnumeration && !isStructure && capturedDataTypeNode.nodeId.namespace !== 0) {
436
+ // add a custom basic type that is not a structure nor a enumeration
437
+ pendingSimpleTypeToRegister.push({ name: definitionName, dataTypeNodeId: capturedDataTypeNode.nodeId });
438
+ }
439
+ capturedDataTypeNode = undefined;
440
+ });
441
+ postTasks.push(processBasicDataType);
442
+ },
443
+ parser: {
444
+ DisplayName: {
445
+ finish() {
446
+ this.parent.obj.displayName = this.text;
447
+ }
448
+ },
449
+ Description: {
450
+ finish() {
451
+ this.parent.obj.description = this.text;
452
+ }
453
+ },
454
+ References: references_parser,
455
+ Definition: node_opcua_xml2json_1._definitionParser
456
+ }
457
+ };
458
+ const localizedText_parser = {
459
+ LocalizedText: {
460
+ init() {
461
+ this.localizedText = {};
462
+ },
463
+ parser: {
464
+ Locale: {
465
+ finish() {
466
+ this.parent.localizedText.locale = this.text.trim();
467
+ }
468
+ },
469
+ Text: {
470
+ finish() {
471
+ this.parent.localizedText.text = this.text.trim();
472
+ }
473
+ }
474
+ }
475
+ }
476
+ };
477
+ const qualifiedName_parser = {
478
+ QualifiedName: {
479
+ init() {
480
+ this.qualifiedName = {
481
+ namespaceIndex: 0,
482
+ name: null
483
+ };
484
+ },
485
+ parser: {
486
+ Name: {
487
+ finish() {
488
+ this.parent.qualifiedName.name = this.text.trim();
489
+ }
490
+ },
491
+ NamespaceIndex: {
492
+ finish() {
493
+ const ns = parseInt(this.text, 10);
494
+ const t = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(`ns=${ns};i=1`).toString());
495
+ this.parent.qualifiedName.namespaceIndex = t.namespace;
496
+ }
497
+ }
498
+ }
499
+ }
500
+ };
501
+ const nodeId_parser = {
502
+ NodeId: {
503
+ init() {
504
+ this.nodeId = "";
505
+ },
506
+ parser: {
507
+ Identifier: {
508
+ finish() {
509
+ this.parent.nodeId = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
510
+ }
511
+ }
512
+ }
513
+ }
514
+ };
515
+ const enumValueType_parser = {
516
+ EnumValueType: {
517
+ init() {
518
+ this.enumValueType = new node_opcua_types_1.EnumValueType({
519
+ description: undefined,
520
+ displayName: undefined,
521
+ value: [0, 0] // Int64
522
+ });
523
+ },
524
+ parser: {
525
+ Value: {
526
+ finish() {
527
+ // Low part
528
+ this.parent.enumValueType.value[1] = parseInt(this.text, 10);
529
+ }
530
+ },
531
+ DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
532
+ this.parent.enumValueType.displayName = Object.assign({}, this.localizedText);
533
+ } }),
534
+ Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
535
+ this.parent.enumValueType.description = Object.assign({}, this.localizedText);
536
+ } })
537
+ },
538
+ finish() {
539
+ this.enumValueType = new node_opcua_types_1.EnumValueType(this.enumValueType);
540
+ }
541
+ }
542
+ };
543
+ const argument_parser = {
544
+ Argument: {
545
+ init() {
546
+ this.argument = new node_opcua_service_call_1.Argument({});
547
+ },
548
+ parser: {
549
+ Name: {
550
+ finish() {
551
+ this.parent.argument.name = this.text.trim();
552
+ }
553
+ },
554
+ DataType: {
555
+ parser: {
556
+ Identifier: {
557
+ finish() {
558
+ this.parent.parent.argument.dataType = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
559
+ }
560
+ }
561
+ }
562
+ },
563
+ ValueRank: {
564
+ finish() {
565
+ this.parent.argument.valueRank = parseInt(this.text.trim(), 10);
566
+ }
567
+ },
568
+ ArrayDimensions: {
569
+ finish() {
570
+ // xx this.parent.argument.arrayDimensions =[];
571
+ }
572
+ },
573
+ Description: {
574
+ init() {
575
+ this._text = "";
576
+ this.locale = null;
577
+ this.text = null;
578
+ },
579
+ parser: {
580
+ Locale: {
581
+ init() {
582
+ this.text = "";
583
+ },
584
+ finish() {
585
+ this.parent.locale = this.text.trim();
586
+ }
587
+ },
588
+ Text: {
589
+ finish() {
590
+ this.text = this.text || "";
591
+ this.parent._text = this.text.trim();
592
+ }
593
+ }
594
+ },
595
+ finish() {
596
+ this.parent.argument.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this._text);
597
+ }
598
+ }
599
+ },
600
+ finish() {
601
+ // xx this.argument = new Argument(this.argument);
602
+ }
603
+ }
604
+ };
605
+ const Range_parser = {
606
+ Range: {
607
+ init() {
608
+ this.range = new node_opcua_types_1.Range({});
609
+ },
610
+ parser: {
611
+ Low: {
612
+ finish() {
613
+ this.parent.range.low = parseFloat(this.text);
614
+ }
615
+ },
616
+ High: {
617
+ finish() {
618
+ this.parent.range.high = parseFloat(this.text);
619
+ }
620
+ }
621
+ }
622
+ }
623
+ };
624
+ const EUInformation_parser = {
625
+ EUInformation: {
626
+ init() {
627
+ this.euInformation = new node_opcua_data_access_1.EUInformation({});
628
+ },
629
+ parser: {
630
+ NamespaceUri: {
631
+ finish() {
632
+ this.parent.euInformation.namespaceUri = this.text;
633
+ }
634
+ },
635
+ UnitId: {
636
+ finish() {
637
+ this.parent.euInformation.unitId = parseInt(this.text, 10);
638
+ }
639
+ },
640
+ DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
641
+ this.parent.euInformation.displayName = Object.assign({}, this.localizedText);
642
+ } }),
643
+ Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
644
+ this.parent.euInformation.description = Object.assign({}, this.localizedText);
645
+ } })
646
+ },
647
+ finish() {
648
+ this.euInformation = new node_opcua_data_access_1.EUInformation(this.euInformation);
649
+ }
650
+ }
651
+ };
652
+ const _extensionObject_inner_parser = {
653
+ TypeId: {
654
+ parser: {
655
+ Identifier: {
656
+ finish() {
657
+ const typeDefinitionId = this.text.trim();
658
+ const self = this.parent.parent; // ExtensionObject
659
+ self.typeDefinitionId = (0, node_opcua_nodeid_1.resolveNodeId)(typeDefinitionId);
660
+ }
661
+ }
662
+ }
663
+ },
664
+ Body2: new node_opcua_xml2json_1.FragmentClonerParser(),
665
+ Body: {
666
+ parser: {
667
+ Argument: argument_parser.Argument,
668
+ EUInformation: EUInformation_parser.EUInformation,
669
+ EnumValueType: enumValueType_parser.EnumValueType,
670
+ Range: Range_parser.Range
671
+ },
672
+ startElement(elementName, attrs) {
673
+ const self = this.parent; // ExtensionObject
674
+ self.extensionObject = null;
675
+ self.extensionObjectPojo = null;
676
+ if (!Object.prototype.hasOwnProperty.call(this.parser, elementName)) {
677
+ // treat it as a opaque XML bloc for the time being
678
+ // until we find the definition of this object, so we know how to interpret the fields
679
+ this._cloneFragment = new node_opcua_xml2json_1.InternalFragmentClonerReaderState();
680
+ this.engine._promote(this._cloneFragment, this.engine.currentLevel, elementName, attrs);
681
+ }
682
+ },
683
+ finish() {
684
+ const self = this.parent; // ExtensionObject
685
+ // typeDefinitionId is also the "Default XML" encoding nodeId !
686
+ switch (self.typeDefinitionId.toString()) {
687
+ case "i=7616": // EnumValueType
688
+ case "ns=0;i=7616": // EnumValueType
689
+ self.extensionObject = self.parser.Body.parser.EnumValueType.enumValueType;
690
+ (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
691
+ (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
692
+ break;
693
+ case "i=297": // Arguments
694
+ case "ns=0;i=297": // Arguments
695
+ self.extensionObject = self.parser.Body.parser.Argument.argument;
696
+ (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
697
+ (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
698
+ break;
699
+ case "i=888":
700
+ case "ns=0;i=888": // EUInformation
701
+ self.extensionObject = self.parser.Body.parser.EUInformation.euInformation;
702
+ (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
703
+ (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
704
+ break;
705
+ case "i=885": // Range
706
+ case "ns=0;i=885":
707
+ self.extensionObject = self.parser.Body.parser.Range.range;
708
+ (0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
709
+ (0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
710
+ break;
711
+ default: {
712
+ // istanbul ignore next
713
+ if (!this._cloneFragment) {
714
+ // the XML file is probably not exposing standard UA extension object correctly.
715
+ // this has been seen in some generated xml files using the dataType nodeId instead of the default encoding
716
+ // nodeid
717
+ errorLog("[NODE-OPCUA-E12] standard OPCUA Extension object from (namespace=0) has a invalid TypeId", self.typeDefinitionId.toString());
718
+ break;
719
+ }
720
+ this.bodyXML = this._cloneFragment.value;
721
+ this._cloneFragment.value = null;
722
+ // the "Default Xml" encoding nodeId
723
+ const xmlEncodingNodeId = _translateNodeId(self.typeDefinitionId.toString());
724
+ if (xmlEncodingNodeId.isEmpty()) {
725
+ debugLog("xmlEncodingNodeId is empty for " + self.typeDefinitionId.toString());
726
+ break;
727
+ }
728
+ let captureXmlBody = this.bodyXML;
729
+ if (doDebug) {
730
+ debugLog("xxxx ", chalk.yellow(captureXmlBody));
731
+ }
732
+ // this is a user defined Extension Object
733
+ debugLog("load nodeset2: typeDefinitionId in ExtensionObject Default XML = " + xmlEncodingNodeId.toString());
734
+ let captured = self.postTaskData;
735
+ self.extensionObjectPojo = null;
736
+ const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
737
+ const extensionObject = yield (0, decode_xml_extension_object_1.decodeXmlExtensionObject)(addressSpace2, xmlEncodingNodeId, captureXmlBody);
738
+ if (captured) {
739
+ captured.postponedExtensionObject = extensionObject;
740
+ }
741
+ captureXmlBody = undefined;
742
+ captured = undefined;
743
+ });
744
+ postTasks0_DecodePojoString.push(task);
745
+ (0, node_opcua_assert_1.assert)(!self.extensionObject || self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
746
+ break;
747
+ }
748
+ }
749
+ }
750
+ }
751
+ };
752
+ const extensionObject_parser = {
753
+ ExtensionObject: {
754
+ init() {
755
+ this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
756
+ this.extensionObject = null;
757
+ this.extensionObjectPojo = null;
758
+ this.postTaskData = { postponedExtensionObject: null };
759
+ },
760
+ parser: _extensionObject_inner_parser,
761
+ finish() {
762
+ /* empty */
763
+ }
764
+ }
765
+ };
766
+ function BasicType_parser(dataType, parseFunc) {
767
+ const _parser = {};
768
+ const r = {
769
+ init(name, attrs) {
770
+ this.value = undefined;
771
+ },
772
+ finish() {
773
+ this.value = parseFunc.call(this, this.text);
774
+ }
775
+ };
776
+ _parser[dataType] = r;
777
+ return _parser;
778
+ }
779
+ function ListOf(dataType, parseFunc) {
780
+ return {
781
+ init() {
782
+ this.listData = [];
783
+ },
784
+ parser: BasicType_parser(dataType, parseFunc),
785
+ finish() {
786
+ this.parent.parent.obj.value = {
787
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
788
+ dataType: node_opcua_variant_1.DataType[dataType],
789
+ value: this.listData
790
+ };
791
+ },
792
+ endElement(element) {
793
+ this.listData.push(this.parser[dataType].value);
794
+ }
795
+ };
796
+ }
797
+ function parser2(type, p) {
798
+ return {
799
+ finish() {
800
+ this.parent.parent.obj.value = {
801
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
802
+ dataType: node_opcua_variant_1.DataType[type],
803
+ value: p(this.text)
804
+ };
805
+ }
806
+ };
807
+ }
808
+ const parseUInt64 = (str) => (0, node_opcua_basic_types_1.coerceUInt64)(str);
809
+ const parseInt64 = (str) => (0, node_opcua_basic_types_1.coerceInt64)(str);
810
+ const state_Variant = {
811
+ init: () => {
812
+ /* empty */
813
+ },
814
+ parser: {
815
+ QualifiedName: Object.assign(Object.assign({}, qualifiedName_parser.QualifiedName), { finish() {
816
+ this.parent.parent.obj.value = {
817
+ dataType: node_opcua_variant_1.DataType.QualifiedName,
818
+ value: this.qualifiedName
819
+ };
820
+ } }),
821
+ LocalizedText: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
822
+ this.parent.parent.obj.value = {
823
+ dataType: node_opcua_variant_1.DataType.LocalizedText,
824
+ value: this.localizedText
825
+ };
826
+ } }),
827
+ XmlElement: {
828
+ finish() {
829
+ this.parent.parent.obj.value = {
830
+ dataType: node_opcua_variant_1.DataType.XmlElement,
831
+ value: this.text
832
+ };
833
+ }
834
+ },
835
+ String: {
836
+ finish() {
837
+ this.parent.parent.obj.value = {
838
+ dataType: node_opcua_variant_1.DataType.String,
839
+ value: this.text
840
+ };
841
+ }
842
+ },
843
+ Guid: {
844
+ parser: {
845
+ String: {
846
+ finish() {
847
+ const guid = this.text;
848
+ if (!(0, node_opcua_basic_types_1.isValidGuid)(guid)) {
849
+ /* ?*/
850
+ }
851
+ this.parent.parent.parent.obj.value = {
852
+ dataType: node_opcua_variant_1.DataType.Guid,
853
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
854
+ value: this.text
855
+ };
856
+ }
857
+ }
858
+ }
859
+ },
860
+ NodeId: {
861
+ parser: {
862
+ Identifier: {
863
+ finish() {
864
+ const nodeId = this.text;
865
+ this.parent.parent.parent.obj.value = {
866
+ dataType: node_opcua_variant_1.DataType.NodeId,
867
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
868
+ value: _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(nodeId).toString())
869
+ };
870
+ }
871
+ }
872
+ }
873
+ },
874
+ Boolean: parser2("Boolean", ec.coerceBoolean),
875
+ Byte: parser2("Byte", parseInt),
876
+ Int16: parser2("Int16", parseInt),
877
+ Int32: parser2("Int32", parseInt),
878
+ Int8: parser2("Int8", parseInt),
879
+ SByte: parser2("SByte", parseInt),
880
+ UInt16: parser2("UInt16", parseInt),
881
+ UInt32: parser2("UInt32", parseInt),
882
+ UInt8: parser2("UInt8", parseInt),
883
+ UInt64: parser2("UInt64", parseUInt64),
884
+ Int64: parser2("Int64", parseInt64),
885
+ ByteString: {
886
+ init() {
887
+ this.value = null;
888
+ },
889
+ finish() {
890
+ const base64text = this.text;
891
+ const byteString = Buffer.from(base64text, "base64");
892
+ this.parent.parent.obj.value = {
893
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
894
+ dataType: node_opcua_variant_1.DataType.ByteString,
895
+ value: byteString
896
+ };
897
+ }
898
+ },
899
+ Float: {
900
+ finish() {
901
+ this.parent.parent.obj.value = {
902
+ dataType: node_opcua_variant_1.DataType.Float,
903
+ value: parseFloat(this.text)
904
+ };
905
+ }
906
+ },
907
+ Double: {
908
+ finish() {
909
+ this.parent.parent.obj.value = {
910
+ dataType: node_opcua_variant_1.DataType.Double,
911
+ value: parseFloat(this.text)
912
+ };
913
+ }
914
+ },
915
+ ListOfExtensionObject: {
916
+ init() {
917
+ this.listExtensionObject = [];
918
+ },
919
+ parser: extensionObject_parser,
920
+ finish() {
921
+ installExtensionObjectListInitializationPostTask(this);
922
+ },
923
+ startElement(elementName) {
924
+ /* empty */
925
+ const extensionObjectParser = this.parser.ExtensionObject;
926
+ extensionObjectParser.postTaskData = { postponedExtensionObject: null };
927
+ },
928
+ endElement(elementName) {
929
+ const extensionObjectParser = this.parser.ExtensionObject;
930
+ this.listExtensionObject.push(extensionObjectParser.extensionObject);
931
+ if (this.parser.ExtensionObject.extensionObject === null) {
932
+ // extension object creation will be postponed
933
+ const index = this.listExtensionObject.length - 1;
934
+ let capturedData = extensionObjectParser.postTaskData;
935
+ // istanbul ignore next
936
+ if (!capturedData) {
937
+ throw new Error("Internal Error : postponedExtensionObject not resolved");
938
+ }
939
+ let listExtensionObject = this.listExtensionObject;
940
+ const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
941
+ // istanbul ignore next
942
+ if (!capturedData.postponedExtensionObject) {
943
+ throw new Error("Internal Error : postponedExtensionObject not resolved");
944
+ }
945
+ listExtensionObject[index] = capturedData.postponedExtensionObject;
946
+ capturedData = undefined;
947
+ listExtensionObject = undefined;
948
+ });
949
+ postTasks2_AssignedExtensionObjectToDataValue.push(task);
950
+ }
951
+ }
952
+ },
953
+ ListOfLocalizedText: {
954
+ init() {
955
+ this.listData = [];
956
+ },
957
+ parser: localizedText_parser,
958
+ finish() {
959
+ this.parent.parent.obj.value = {
960
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
961
+ dataType: node_opcua_variant_1.DataType.LocalizedText,
962
+ value: this.listData
963
+ };
964
+ },
965
+ endElement() {
966
+ this.listData.push(this.parser.LocalizedText.localizedText);
967
+ }
968
+ },
969
+ ListOfQualifiedName: {
970
+ init() {
971
+ this.listData = [];
972
+ },
973
+ parser: qualifiedName_parser,
974
+ finish() {
975
+ this.parent.parent.obj.value = {
976
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
977
+ dataType: node_opcua_variant_1.DataType.QualifiedName,
978
+ value: this.listData
979
+ };
980
+ },
981
+ endElement() {
982
+ this.listData.push(this.parser.QualifiedName.qualifiedName);
983
+ }
984
+ },
985
+ ListOfNodeId: {
986
+ init() {
987
+ this.listData = [];
988
+ },
989
+ parser: nodeId_parser,
990
+ finish() {
991
+ this.parent.parent.obj.value = {
992
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
993
+ dataType: node_opcua_variant_1.DataType.NodeId,
994
+ value: this.listData
995
+ };
996
+ },
997
+ endElement(elementName) {
998
+ this.listData.push(this.parser.NodeId.nodeId);
999
+ }
1000
+ },
1001
+ ListOfBoolean: ListOf("Boolean", ec.coerceBoolean),
1002
+ ListOfByte: ListOf("Byte", parseInt),
1003
+ ListOfDouble: ListOf("Double", parseFloat),
1004
+ ListOfFloat: ListOf("Float", parseFloat),
1005
+ ListOfInt32: ListOf("Int32", parseInt),
1006
+ ListOfInt16: ListOf("Int16", parseInt),
1007
+ ListOfInt8: ListOf("Int8", parseInt),
1008
+ ListOfUInt32: ListOf("UInt32", parseInt),
1009
+ ListOfUInt16: ListOf("UInt16", parseInt),
1010
+ ListOfUInt8: ListOf("UInt8", parseInt),
1011
+ ListOfString: ListOf("String", (value) => value),
1012
+ ListOfXmlElement: ListOf("XmlElement", (value) => value),
1013
+ ExtensionObject: {
1014
+ init() {
1015
+ this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
1016
+ this.extensionObject = null;
1017
+ this.postTaskData = { postponedExtensionObject: null };
1018
+ },
1019
+ parser: _extensionObject_inner_parser,
1020
+ finish() {
1021
+ // istanbul ignore next
1022
+ if (this.extensionObject && !(this.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject)) {
1023
+ throw new Error("expecting an extension object");
1024
+ }
1025
+ this.parent.parent.obj.value = {
1026
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
1027
+ value: this.extensionObject
1028
+ };
1029
+ if (!this.extensionObject) {
1030
+ installExtensionObjectInitializationPostTask(this);
1031
+ }
1032
+ }
1033
+ }
1034
+ }
1035
+ };
1036
+ function installExtensionObjectListInitializationPostTask(element) {
1037
+ let listExtensionObject = element.listExtensionObject;
1038
+ let nodeId = element.parent.parent.obj.nodeId;
1039
+ (0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
1040
+ const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1041
+ const node = addressSpace2.findNode(nodeId);
1042
+ if (!node) {
1043
+ debugLog("Cannot find node with nodeId " + nodeId + ". may be the node was marked as deprecated");
1044
+ }
1045
+ else if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
1046
+ const v = node;
1047
+ (0, node_opcua_assert_1.assert)(v.getBasicDataType() === node_opcua_variant_1.DataType.ExtensionObject, "expecting an extension object");
1048
+ v.bindExtensionObject(listExtensionObject, { createMissingProp: false });
1049
+ }
1050
+ else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
1051
+ // no need to bind a variable type
1052
+ const v = node;
1053
+ v /*fix me*/.value.value = listExtensionObject;
1054
+ }
1055
+ listExtensionObject.slice(0);
1056
+ listExtensionObject = undefined;
1057
+ nodeId = undefined;
1058
+ });
1059
+ postTasks2_AssignedExtensionObjectToDataValue.push(task);
1060
+ }
1061
+ function installExtensionObjectInitializationPostTask(element) {
1062
+ // let's create the mechanism that postpone the creation of the
1063
+ // extension object
1064
+ let data = element.postTaskData;
1065
+ let variant = element.parent.parent.obj.value;
1066
+ let nodeId = element.parent.parent.obj.nodeId;
1067
+ const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1068
+ variant.value = data.postponedExtensionObject;
1069
+ (0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
1070
+ const node = addressSpace2.findNode(nodeId);
1071
+ if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
1072
+ const v = node;
1073
+ (0, node_opcua_assert_1.assert)(v.getBasicDataType() === node_opcua_variant_1.DataType.ExtensionObject, "expecting an extension object");
1074
+ v.bindExtensionObject(variant.value, { createMissingProp: false });
1075
+ }
1076
+ else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
1077
+ const v = node;
1078
+ v /*fix me*/.value.value = variant.value;
1079
+ }
1080
+ data.postponedExtensionObject = null;
1081
+ data = undefined;
1082
+ variant = undefined;
1083
+ nodeId = undefined;
1084
+ });
1085
+ postTasks2_AssignedExtensionObjectToDataValue.push(task);
1086
+ }
1087
+ const canIngore = ({ isDraft, isDeprecated }, node) => {
1088
+ if (isDraft && !options.loadDraftNodes) {
1089
+ debugLog("Ignoring Draft =", node_opcua_data_model_1.NodeClass[node.nodeClass], node.browseName.toString());
1090
+ return true;
1091
+ }
1092
+ if (isDeprecated && !options.loadDeprecatedNodes) {
1093
+ debugLog("Ignoring Deprecate =", node_opcua_data_model_1.NodeClass[node.nodeClass], node.browseName.toString());
1094
+ return true;
1095
+ }
1096
+ return false;
1097
+ };
1098
+ const state_UAVariable = {
1099
+ init(name, attrs) {
1100
+ _perform();
1101
+ this.obj = {};
1102
+ this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
1103
+ this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1104
+ this.obj.parentNodeId = convertToNodeId(attrs.ParentNodeId);
1105
+ this.obj.dataType = convertToNodeId(attrs.DataType);
1106
+ this.obj.valueRank = attrs.ValueRank === undefined ? -1 : ec.coerceInt32(attrs.ValueRank);
1107
+ this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
1108
+ this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
1109
+ this.obj.minimumSamplingInterval = parseInt(this.obj.minimumSamplingInterval, 10);
1110
+ this.obj.historizing = false;
1111
+ this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1112
+ this.obj.accessLevel = convertAccessLevel(attrs.AccessLevel);
1113
+ this.obj.userAccessLevel = this.obj.accessLevel; // convertAccessLevel(attrs.UserAccessLevel || attrs.AccessLevel);
1114
+ this.isDraft = attrs.ReleaseStatus === "Draft";
1115
+ this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1116
+ },
1117
+ finish() {
1118
+ if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1119
+ return;
1120
+ }
1121
+ /*
1122
+ // set default value based on obj data Type
1123
+ if (this.obj.value === undefined) {
1124
+ const dataTypeNode = this.obj.dataType;
1125
+ const valueRank = this.obj.valueRank;
1126
+ this.obj.value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
1127
+ }
1128
+ */
1129
+ // eslint-disable-next-line prefer-const
1130
+ let capturedVariable;
1131
+ if (this.obj.value) {
1132
+ let capturedValue = this.obj.value;
1133
+ const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1134
+ if (false && doDebug) {
1135
+ debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new node_opcua_variant_1.Variant(capturedValue).toString());
1136
+ }
1137
+ capturedVariable.setValueFromSource(capturedValue);
1138
+ capturedValue = undefined;
1139
+ capturedVariable = undefined;
1140
+ });
1141
+ if (capturedValue.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
1142
+ postTasks0_InitializeVariable.push(task);
1143
+ }
1144
+ else {
1145
+ // do them later
1146
+ postTasks1_InitializeVariable.push(task);
1147
+ }
1148
+ }
1149
+ else {
1150
+ const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
1151
+ const dataTypeNode = capturedVariable.dataType;
1152
+ const valueRank = capturedVariable.valueRank;
1153
+ const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
1154
+ if (value) {
1155
+ if (false && doDebug) {
1156
+ debugLog("2 setting value to ", capturedVariable.nodeId.toString(), value);
1157
+ }
1158
+ if (value.dataType === node_opcua_variant_1.DataType.Null) {
1159
+ capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.BadWaitingForInitialData);
1160
+ }
1161
+ else {
1162
+ capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.Good);
1163
+ }
1164
+ }
1165
+ capturedVariable = undefined;
1166
+ });
1167
+ postTasks0_InitializeVariable.push(task);
1168
+ }
1169
+ this.obj.value = undefined;
1170
+ capturedVariable = _internal_createNode(this.obj);
1171
+ },
1172
+ parser: {
1173
+ DisplayName: {
1174
+ finish() {
1175
+ this.parent.obj.displayName = this.text;
1176
+ }
1177
+ },
1178
+ Description: {
1179
+ finish() {
1180
+ this.parent.obj.description = this.text;
1181
+ }
1182
+ },
1183
+ References: references_parser,
1184
+ Value: state_Variant
1185
+ }
1186
+ };
1187
+ const state_UAVariableType = {
1188
+ init(name, attrs) {
1189
+ _perform();
1190
+ this.obj = {};
1191
+ this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
1192
+ this.obj.nodeClass = node_opcua_data_model_1.NodeClass.VariableType;
1193
+ this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1194
+ this.obj.parentNodeId = attrs.ParentNodeId || null;
1195
+ this.obj.dataType = convertToNodeId(attrs.DataType) || null;
1196
+ this.obj.valueRank = ec.coerceInt32(attrs.ValueRank) || -1;
1197
+ this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
1198
+ this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
1199
+ this.obj.historizing = false;
1200
+ this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1201
+ this.isDraft = attrs.ReleaseStatus === "Draft";
1202
+ this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1203
+ },
1204
+ finish() {
1205
+ if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1206
+ return;
1207
+ }
1208
+ try {
1209
+ _internal_createNode(this.obj);
1210
+ } /* istanbul ignore next */
1211
+ catch (err) {
1212
+ this.obj.addressSpace = null;
1213
+ // tslint:disable:no-console
1214
+ console.warn(" Cannot create object", JSON.stringify(this.obj, null, " "));
1215
+ throw err;
1216
+ }
1217
+ },
1218
+ parser: {
1219
+ DisplayName: {
1220
+ finish() {
1221
+ this.parent.obj.displayName = this.text;
1222
+ }
1223
+ },
1224
+ Description: {
1225
+ finish() {
1226
+ this.parent.obj.description = this.text;
1227
+ }
1228
+ },
1229
+ References: references_parser,
1230
+ Value: state_Variant
1231
+ }
1232
+ };
1233
+ const state_UAMethod = {
1234
+ init(name, attrs) {
1235
+ _perform();
1236
+ this.obj = {};
1237
+ this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Method;
1238
+ // MethodDeclarationId
1239
+ // ParentNodeId
1240
+ this.obj.browseName = convertQualifiedName(attrs.BrowseName);
1241
+ this.obj.parentNodeId = attrs.ParentNodeId || null;
1242
+ this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
1243
+ this.obj.methodDeclarationId = attrs.MethodDeclarationId ? _translateNodeId(attrs.MethodDeclarationId) : null;
1244
+ this.isDraft = attrs.ReleaseStatus === "Draft";
1245
+ this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
1246
+ },
1247
+ finish() {
1248
+ if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
1249
+ return;
1250
+ }
1251
+ _internal_createNode(this.obj);
1252
+ },
1253
+ parser: {
1254
+ DisplayName: {
1255
+ finish() {
1256
+ this.parent.obj.displayName = this.text;
1257
+ }
1258
+ },
1259
+ References: references_parser
1260
+ }
1261
+ };
1262
+ const state_ModelTableEntry = new node_opcua_xml2json_1.ReaderState({
1263
+ // ModelTableEntry
1264
+ init() {
1265
+ this._requiredModels = [];
1266
+ },
1267
+ parser: {
1268
+ RequiredModel: {
1269
+ init(name, attrs) {
1270
+ const modelUri = attrs.ModelUri;
1271
+ const version = attrs.Version;
1272
+ const publicationDate = new Date(Date.parse(attrs.PublicationDate));
1273
+ this.parent._requiredModels.push({ modelUri, version, publicationDate });
1274
+ },
1275
+ finish() {
1276
+ /** */
1277
+ }
1278
+ }
1279
+ },
1280
+ finish() {
1281
+ const modelUri = this.attrs.ModelUri; // //"http://opcfoundation.org/UA/"
1282
+ const version = this.attrs.Version; // 1.04
1283
+ const publicationDate = this.attrs.PublicationDate ? new Date(Date.parse(this.attrs.PublicationDate)) : undefined; // "2018-05-15T00:00:00Z" "
1284
+ // optional,
1285
+ const symbolicName = this.attrs.SymbolicName;
1286
+ const accessRestrictions = this.attrs.AccessRestrictions;
1287
+ const model = {
1288
+ accessRestrictions,
1289
+ modelUri,
1290
+ publicationDate,
1291
+ requiredModels: this._requiredModels,
1292
+ symbolicName,
1293
+ version
1294
+ };
1295
+ const namespace = _add_namespace(model);
1296
+ models.push(model);
1297
+ }
1298
+ });
1299
+ function _updateTranslationTable() {
1300
+ _register_namespace_uri_in_translation_table("http://opcfoundation.org/UA/");
1301
+ for (const namespaceUri of _namespaceUris) {
1302
+ _register_namespace_uri_in_translation_table(namespaceUri);
1303
+ }
1304
+ }
1305
+ function _perform() {
1306
+ if (performedCalled)
1307
+ return;
1308
+ performedCalled = true;
1309
+ /**special case for old nodeset file version 1.02 where no models exists */
1310
+ if (models.length === 0) {
1311
+ for (const namespaceuri of _namespaceUris) {
1312
+ const existingNamespace = addressSpace1.getNamespace(namespaceuri);
1313
+ if (existingNamespace) {
1314
+ continue;
1315
+ }
1316
+ _add_namespace({
1317
+ modelUri: namespaceuri,
1318
+ version: "1.0.0",
1319
+ requiredModels: []
1320
+ });
1321
+ }
1322
+ }
1323
+ _updateTranslationTable();
1324
+ }
1325
+ // state_ModelTableEntry.parser["RequiredModel"] = state_ModelTableEntry;
1326
+ let _namespaceUris = [];
1327
+ const state_0 = {
1328
+ parser: {
1329
+ Aliases: {
1330
+ init() {
1331
+ _perform();
1332
+ },
1333
+ parser: { Alias: state_Alias }
1334
+ },
1335
+ NamespaceUris: {
1336
+ init() {
1337
+ //
1338
+ _namespaceUris = [];
1339
+ },
1340
+ parser: {
1341
+ Uri: {
1342
+ finish() {
1343
+ _namespaceUris.push(this.text);
1344
+ }
1345
+ }
1346
+ },
1347
+ finish() {
1348
+ // verify that requested namespaces are already loaded or abort with a message
1349
+ }
1350
+ },
1351
+ Models: {
1352
+ // ModelTable
1353
+ init(name, attrs) {
1354
+ /* */
1355
+ },
1356
+ parser: {
1357
+ Model: state_ModelTableEntry
1358
+ },
1359
+ finish() {
1360
+ /** */
1361
+ }
1362
+ },
1363
+ UADataType: state_UADataType,
1364
+ UAMethod: state_UAMethod,
1365
+ UAObject: state_UAObject,
1366
+ UAObjectType: state_UAObjectType,
1367
+ UAReferenceType: state_UAReferenceType,
1368
+ UAVariable: state_UAVariable,
1369
+ UAVariableType: state_UAVariableType
1370
+ }
1371
+ };
1372
+ const parser = new node_opcua_xml2json_1.Xml2Json(state_0);
1373
+ function terminate(callback) {
1374
+ var _a, _b, _c;
1375
+ make_back_references(addressSpace1);
1376
+ // setting up Server_NamespaceArray
1377
+ if ((_c = (_b = (_a = addressSpace1.rootFolder) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.server) === null || _c === void 0 ? void 0 : _c.namespaceArray) {
1378
+ addressSpace1.rootFolder.objects.server.namespaceArray.setValueFromSource({
1379
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
1380
+ dataType: node_opcua_variant_1.DataType.String,
1381
+ value: addressSpace1.getNamespaceArray().map((ns) => ns.namespaceUri)
1382
+ });
1383
+ // istanbul ignore next
1384
+ if (doDebug) {
1385
+ debugLog("addressSpace NS = ", addressSpace1.rootFolder.objects.server.namespaceArray.readValue().value.value.join(" "));
1386
+ }
1387
+ }
1388
+ doDebug &&
1389
+ debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------") +
1390
+ chalk.green("DONE"));
1391
+ function performPostLoadingTasks(tasks) {
1392
+ return __awaiter(this, void 0, void 0, function* () {
1393
+ for (const task of tasks) {
1394
+ try {
1395
+ yield task(addressSpace1);
1396
+ }
1397
+ catch (err) {
1398
+ // istanbul ignore next
1399
+ // tslint:disable:no-console
1400
+ if (err instanceof Error) {
1401
+ console.log(" performPostLoadingTasks Err => ", err.message, "\n", err);
1402
+ }
1403
+ yield task(addressSpace1);
1404
+ }
1405
+ }
1406
+ tasks.splice(0);
1407
+ });
1408
+ }
1409
+ function finalSteps() {
1410
+ return __awaiter(this, void 0, void 0, function* () {
1411
+ /// ----------------------------------------------------------------------------------------
1412
+ // perform post task
1413
+ doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------"));
1414
+ yield performPostLoadingTasks(postTasks);
1415
+ doDebug &&
1416
+ debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Simple Variables ---------------------"));
1417
+ yield performPostLoadingTasks(postTasks0_InitializeVariable);
1418
+ doDebug && debugLog(chalk.bgGreenBright("Performing DataType extraction -------------------------------------------"));
1419
+ (0, node_opcua_assert_1.assert)(!addressSpace1.suspendBackReference);
1420
+ yield (0, ensure_datatype_extracted_1.ensureDatatypeExtracted)(addressSpace);
1421
+ const dataTypeManager = addressSpace.getDataTypeManager();
1422
+ /// ----------------------------------------------------------------------------------------
1423
+ doDebug && debugLog(chalk.bgGreenBright("DataType extraction done ") + chalk.green("DONE"));
1424
+ for (const { name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
1425
+ if (dataTypeNodeId.namespace === 0) {
1426
+ continue;
1427
+ }
1428
+ const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(dataTypeNodeId.namespace);
1429
+ }
1430
+ pendingSimpleTypeToRegister.splice(0);
1431
+ doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Decoding Pojo String (parsing XML objects) -"));
1432
+ yield performPostLoadingTasks(postTasks0_DecodePojoString);
1433
+ doDebug &&
1434
+ debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Complex Variables ---------------------"));
1435
+ yield performPostLoadingTasks(postTasks1_InitializeVariable);
1436
+ doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks: (assigning Extension Object to Variables) -"));
1437
+ yield performPostLoadingTasks(postTasks2_AssignedExtensionObjectToDataValue);
1438
+ doDebug && debugLog(chalk.bgGreenBright("Performing post variable initialization ---------------------"));
1439
+ (0, namespace_post_step_1.promoteObjectsAndVariables)(addressSpace);
1440
+ });
1441
+ }
1442
+ finalSteps()
1443
+ .then(() => callback())
1444
+ .catch((err1) => {
1445
+ console.log("Error ", (0, node_opcua_assert_1.renderError)(err1));
1446
+ callback(err1);
1447
+ });
1448
+ }
1449
+ function addNodeSet(xmlData, callback1) {
1450
+ _reset_namespace_translation();
1451
+ parser.parseString(xmlData, callback1);
1452
+ }
1453
+ return {
1454
+ addNodeSet,
1455
+ terminate
1456
+ };
1457
+ }
1458
+ class NodeSetLoader {
1459
+ constructor(addressSpace, options) {
1460
+ this.options = options;
1461
+ this._s = makeNodeSetParserEngine(addressSpace, options || {});
1462
+ }
1463
+ addNodeSet(xmlData, callback) {
1464
+ if (!callback) {
1465
+ throw new Error("Expecting callback function");
1466
+ }
1467
+ return this._s.addNodeSet(xmlData, callback);
1468
+ }
1469
+ addNodeSetAsync(xmlData) {
1470
+ return __awaiter(this, void 0, void 0, function* () {
1471
+ return (0, util_1.promisify)(this.addNodeSet).call(this, xmlData);
1472
+ });
1473
+ }
1474
+ terminate(callback) {
1475
+ this._s.terminate(callback);
1476
+ }
1477
+ terminateAsync() {
1478
+ return __awaiter(this, void 0, void 0, function* () {
1479
+ return (0, util_1.promisify)(this.terminate).call(this);
1480
+ });
1481
+ }
1482
+ }
1483
+ exports.NodeSetLoader = NodeSetLoader;
1484
1484
  //# sourceMappingURL=load_nodeset2.js.map