node-opcua-address-space 2.71.0 → 2.72.2

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