node-opcua-address-space 2.70.3 → 2.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) 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/alarms_and_conditions/ua_condition_base_i.d.ts +23 -0
  30. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js +3 -0
  31. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js.map +1 -0
  32. package/dist/source/interfaces/data_access/ua_discrete_item.d.ts +6 -0
  33. package/dist/source/interfaces/data_access/ua_discrete_item.js +3 -0
  34. package/dist/source/interfaces/data_access/ua_discrete_item.js.map +1 -0
  35. package/dist/source/interfaces/data_access/ua_multistate_discrete.d.ts +25 -0
  36. package/dist/source/interfaces/data_access/ua_multistate_discrete.js +3 -0
  37. package/dist/source/interfaces/data_access/ua_multistate_discrete.js.map +1 -0
  38. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -21
  39. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +2 -2
  40. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.d.ts +27 -0
  41. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js +3 -0
  42. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js.map +1 -0
  43. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -24
  44. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +2 -2
  45. package/dist/source/interfaces/data_access/ua_two_state_discrete.d.ts +17 -0
  46. package/dist/source/interfaces/data_access/ua_two_state_discrete.js +3 -0
  47. package/dist/source/interfaces/data_access/ua_two_state_discrete.js.map +1 -0
  48. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -12
  49. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +2 -2
  50. package/dist/source/interfaces/data_access/ua_y_array_item.d.ts +19 -0
  51. package/dist/source/interfaces/data_access/ua_y_array_item.js +3 -0
  52. package/dist/source/interfaces/data_access/ua_y_array_item.js.map +1 -0
  53. package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -8
  54. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +2 -2
  55. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.d.ts +11 -0
  56. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js +3 -0
  57. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js.map +1 -0
  58. package/dist/source/interfaces/state_machine/finite_state_machine.d.ts +70 -0
  59. package/dist/source/interfaces/state_machine/finite_state_machine.js +3 -0
  60. package/dist/source/interfaces/state_machine/finite_state_machine.js.map +1 -0
  61. package/dist/source/interfaces/state_machine/program_finite_state_machine.d.ts +74 -0
  62. package/dist/source/interfaces/state_machine/program_finite_state_machine.js +3 -0
  63. package/dist/source/interfaces/state_machine/program_finite_state_machine.js.map +1 -0
  64. package/dist/source/interfaces/state_machine/state_machine.d.ts +342 -0
  65. package/dist/source/interfaces/state_machine/state_machine.js +3 -0
  66. package/dist/source/interfaces/state_machine/state_machine.js.map +1 -0
  67. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -12
  68. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +2 -2
  69. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -49
  70. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +2 -2
  71. package/dist/source/interfaces/state_machine/ua_finite_state_variable.d.ts +18 -0
  72. package/dist/source/interfaces/state_machine/ua_finite_state_variable.js +3 -0
  73. package/dist/source/interfaces/state_machine/ua_finite_state_variable.js.map +1 -0
  74. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -11
  75. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +2 -2
  76. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +222 -222
  77. package/dist/source/interfaces/state_machine/ua_state_machine_type.js +2 -2
  78. package/dist/source/interfaces/state_machine/ua_state_variable.d.ts +29 -0
  79. package/dist/source/interfaces/state_machine/ua_state_variable.js +3 -0
  80. package/dist/source/interfaces/state_machine/ua_state_variable.js.map +1 -0
  81. package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -6
  82. package/dist/source/interfaces/state_machine/ua_transition_ex.js +2 -2
  83. package/dist/source/interfaces/state_machine/ua_two_state_variable.d.ts +26 -0
  84. package/dist/source/interfaces/state_machine/ua_two_state_variable.js +3 -0
  85. package/dist/source/interfaces/state_machine/ua_two_state_variable.js.map +1 -0
  86. package/dist/source/interfaces/subscription_diagnostics_variable.d.ts +41 -0
  87. package/dist/source/interfaces/subscription_diagnostics_variable.js +3 -0
  88. package/dist/source/interfaces/subscription_diagnostics_variable.js.map +1 -0
  89. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -8
  90. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +2 -2
  91. package/dist/source/loader/decode_xml_extension_object.d.ts +6 -6
  92. package/dist/source/loader/decode_xml_extension_object.js +71 -71
  93. package/dist/source/loader/ensure_datatype_extracted.d.ts +5 -5
  94. package/dist/source/loader/ensure_datatype_extracted.js +45 -45
  95. package/dist/source/loader/generateAddressSpaceRaw.d.ts +10 -10
  96. package/dist/source/loader/generateAddressSpaceRaw.js +45 -45
  97. package/dist/source/loader/load_nodeset2.d.ts +16 -16
  98. package/dist/source/loader/load_nodeset2.js +1464 -1464
  99. package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -28
  100. package/dist/source/loader/make_xml_extension_object_parser.js +315 -315
  101. package/dist/source/loader/namespace_post_step.d.ts +6 -6
  102. package/dist/source/loader/namespace_post_step.js +47 -47
  103. package/dist/source/loader/register_node_promoter.d.ts +3 -3
  104. package/dist/source/loader/register_node_promoter.js +9 -9
  105. package/dist/source/namespace.d.ts +6 -6
  106. package/dist/source/namespace.js +2 -2
  107. package/dist/source/namespace_alarm_and_condition.d.ts +24 -24
  108. package/dist/source/namespace_alarm_and_condition.js +2 -2
  109. package/dist/source/namespace_data_access.d.ts +42 -42
  110. package/dist/source/namespace_data_access.js +2 -2
  111. package/dist/source/namespace_machine_state.d.ts +7 -7
  112. package/dist/source/namespace_machine_state.js +2 -2
  113. package/dist/source/pseudo_session.d.ts +55 -55
  114. package/dist/source/pseudo_session.js +203 -203
  115. package/dist/source/session_context.d.ts +111 -111
  116. package/dist/source/session_context.js +265 -265
  117. package/dist/source/set_namespace_meta_data.d.ts +2 -2
  118. package/dist/source/set_namespace_meta_data.js +59 -59
  119. package/dist/source/ua_root_folder.d.ts +9 -9
  120. package/dist/source/ua_root_folder.js +2 -2
  121. package/dist/source/ua_two_state_variable_ex.d.ts +23 -23
  122. package/dist/source/ua_two_state_variable_ex.js +2 -2
  123. package/dist/source/xml_writer.d.ts +9 -9
  124. package/dist/source/xml_writer.js +2 -2
  125. package/dist/src/address_space.d.ts +392 -392
  126. package/dist/src/address_space.js +1387 -1387
  127. package/dist/src/address_space_change_event_tools.d.ts +6 -6
  128. package/dist/src/address_space_change_event_tools.js +149 -149
  129. package/dist/src/address_space_private.d.ts +43 -43
  130. package/dist/src/address_space_private.js +2 -2
  131. package/dist/src/alarms_and_conditions/base_event_type.d.ts +26 -0
  132. package/dist/src/alarms_and_conditions/base_event_type.js +41 -0
  133. package/dist/src/alarms_and_conditions/base_event_type.js.map +1 -0
  134. package/dist/src/alarms_and_conditions/check_where_clause.d.ts +4 -4
  135. package/dist/src/alarms_and_conditions/check_where_clause.js +109 -109
  136. package/dist/src/alarms_and_conditions/condition.d.ts +5 -5
  137. package/dist/src/alarms_and_conditions/condition.js +80 -80
  138. package/dist/src/alarms_and_conditions/condition_info.d.ts +27 -27
  139. package/dist/src/alarms_and_conditions/condition_info.js +54 -54
  140. package/dist/src/alarms_and_conditions/condition_snapshot.d.ts +233 -233
  141. package/dist/src/alarms_and_conditions/condition_snapshot.js +666 -666
  142. package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +21 -21
  143. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +46 -46
  144. package/dist/src/alarms_and_conditions/extract_event_fields.d.ts +10 -10
  145. package/dist/src/alarms_and_conditions/extract_event_fields.js +89 -89
  146. package/dist/src/alarms_and_conditions/index.d.ts +18 -18
  147. package/dist/src/alarms_and_conditions/index.js +34 -34
  148. package/dist/src/alarms_and_conditions/shelving_state_machine.d.ts +22 -0
  149. package/dist/src/alarms_and_conditions/shelving_state_machine.js +241 -0
  150. package/dist/src/alarms_and_conditions/shelving_state_machine.js.map +1 -0
  151. package/dist/src/alarms_and_conditions/trip_alarm.d.ts +16 -0
  152. package/dist/src/alarms_and_conditions/trip_alarm.js +21 -0
  153. package/dist/src/alarms_and_conditions/trip_alarm.js.map +1 -0
  154. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.d.ts +54 -0
  155. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js +255 -0
  156. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js.map +1 -0
  157. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +62 -62
  158. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -244
  159. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.d.ts +138 -0
  160. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js +460 -0
  161. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js.map +1 -0
  162. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +118 -118
  163. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +416 -416
  164. package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +29 -29
  165. package/dist/src/alarms_and_conditions/ua_base_event_impl.js +38 -38
  166. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.d.ts +35 -0
  167. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js +32 -0
  168. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js.map +1 -0
  169. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +21 -21
  170. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +25 -25
  171. package/dist/src/alarms_and_conditions/ua_condition_base.d.ts +191 -0
  172. package/dist/src/alarms_and_conditions/ua_condition_base.js +1029 -0
  173. package/dist/src/alarms_and_conditions/ua_condition_base.js.map +1 -0
  174. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +182 -182
  175. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1022 -1022
  176. package/dist/src/alarms_and_conditions/ua_discrete_alarm.d.ts +11 -0
  177. package/dist/src/alarms_and_conditions/ua_discrete_alarm.js +58 -0
  178. package/dist/src/alarms_and_conditions/ua_discrete_alarm.js.map +1 -0
  179. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +17 -17
  180. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +57 -57
  181. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.d.ts +24 -0
  182. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js +59 -0
  183. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js.map +1 -0
  184. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +27 -27
  185. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +56 -56
  186. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.d.ts +14 -0
  187. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js +17 -0
  188. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js.map +1 -0
  189. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +9 -9
  190. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +11 -11
  191. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.d.ts +22 -0
  192. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js +87 -0
  193. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js.map +1 -0
  194. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +38 -38
  195. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +86 -86
  196. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.d.ts +6 -0
  197. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js +11 -0
  198. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js.map +1 -0
  199. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +10 -10
  200. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +7 -7
  201. package/dist/src/alarms_and_conditions/ua_limit_alarm.d.ts +76 -0
  202. package/dist/src/alarms_and_conditions/ua_limit_alarm.js +237 -0
  203. package/dist/src/alarms_and_conditions/ua_limit_alarm.js.map +1 -0
  204. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +97 -97
  205. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +250 -250
  206. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.d.ts +27 -0
  207. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js +62 -0
  208. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js.map +1 -0
  209. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +28 -28
  210. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +50 -50
  211. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.d.ts +49 -0
  212. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js +176 -0
  213. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js.map +1 -0
  214. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +25 -25
  215. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +162 -162
  216. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.d.ts +47 -0
  217. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js +151 -0
  218. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js.map +1 -0
  219. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +39 -39
  220. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +135 -135
  221. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.d.ts +16 -0
  222. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js +18 -0
  223. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js.map +1 -0
  224. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +16 -16
  225. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +17 -17
  226. package/dist/src/apply_condition_refresh.d.ts +6 -6
  227. package/dist/src/apply_condition_refresh.js +27 -27
  228. package/dist/src/base_node.d.ts +270 -0
  229. package/dist/src/base_node.js +1299 -0
  230. package/dist/src/base_node.js.map +1 -0
  231. package/dist/src/base_node_impl.d.ts +281 -281
  232. package/dist/src/base_node_impl.js +1395 -1395
  233. package/dist/src/base_node_private.d.ts +61 -61
  234. package/dist/src/base_node_private.js +705 -705
  235. package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -11
  236. package/dist/src/data_access/add_dataItem_stuff.js +61 -61
  237. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -1
  238. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +34 -34
  239. package/dist/src/data_access/ua_analog_item.d.ts +13 -0
  240. package/dist/src/data_access/ua_analog_item.js +37 -0
  241. package/dist/src/data_access/ua_analog_item.js.map +1 -0
  242. package/dist/src/data_access/ua_data_item.d.ts +16 -0
  243. package/dist/src/data_access/ua_data_item.js +66 -0
  244. package/dist/src/data_access/ua_data_item.js.map +1 -0
  245. package/dist/src/data_access/ua_multistate_discrete.d.ts +24 -0
  246. package/dist/src/data_access/ua_multistate_discrete.js +132 -0
  247. package/dist/src/data_access/ua_multistate_discrete.js.map +1 -0
  248. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -32
  249. package/dist/src/data_access/ua_multistate_discrete_impl.js +130 -130
  250. package/dist/src/data_access/ua_multistate_value_discrete.d.ts +51 -51
  251. package/dist/src/data_access/ua_multistate_value_discrete.js +249 -249
  252. package/dist/src/data_access/ua_two_state_discrete.d.ts +25 -25
  253. package/dist/src/data_access/ua_two_state_discrete.js +153 -153
  254. package/dist/src/event_data.d.ts +29 -29
  255. package/dist/src/event_data.js +95 -95
  256. package/dist/src/extension_object_array_node.d.ts +61 -61
  257. package/dist/src/extension_object_array_node.js +276 -276
  258. package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -26
  259. package/dist/src/historical_access/address_space_historical_data_node.js +630 -630
  260. package/dist/src/index_current.d.ts +45 -45
  261. package/dist/src/index_current.js +77 -77
  262. package/dist/src/namespace.d.ts +472 -0
  263. package/dist/src/namespace.js +1759 -0
  264. package/dist/src/namespace.js.map +1 -0
  265. package/dist/src/namespace_impl.d.ts +457 -457
  266. package/dist/src/namespace_impl.js +1733 -1733
  267. package/dist/src/namespace_private.d.ts +21 -21
  268. package/dist/src/namespace_private.js +32 -32
  269. package/dist/src/nodeid_manager.d.ts +36 -36
  270. package/dist/src/nodeid_manager.js +197 -197
  271. package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -2
  272. package/dist/src/nodeset_tools/adjust_namespace_array.js +13 -13
  273. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +2 -2
  274. package/dist/src/nodeset_tools/construct_namespace_dependency.js +83 -83
  275. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +2 -2
  276. package/dist/src/nodeset_tools/nodeset_to_xml.js +1143 -1143
  277. package/dist/src/nodeset_tools/typedictionary_to_xml.d.ts +2 -2
  278. package/dist/src/nodeset_tools/typedictionary_to_xml.js +154 -154
  279. package/dist/src/reference.d.ts +43 -0
  280. package/dist/src/reference.js +138 -0
  281. package/dist/src/reference.js.map +1 -0
  282. package/dist/src/reference_impl.d.ts +43 -43
  283. package/dist/src/reference_impl.js +139 -139
  284. package/dist/src/role_permissions.d.ts +2 -2
  285. package/dist/src/role_permissions.js +10 -10
  286. package/dist/src/session_context.d.ts +4 -0
  287. package/dist/src/session_context.js +9 -0
  288. package/dist/src/session_context.js.map +1 -0
  289. package/dist/src/state_machine/finite_state_machine.d.ts +67 -67
  290. package/dist/src/state_machine/finite_state_machine.js +353 -353
  291. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +34 -34
  292. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +250 -250
  293. package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -61
  294. package/dist/src/state_machine/ua_two_state_variable.js +331 -331
  295. package/dist/src/tool_isSupertypeOf.d.ts +17 -17
  296. package/dist/src/tool_isSupertypeOf.js +108 -108
  297. package/dist/src/ua_condition_type.d.ts +8 -8
  298. package/dist/src/ua_condition_type.js +2 -2
  299. package/dist/src/ua_data_type.d.ts +81 -0
  300. package/dist/src/ua_data_type.js +259 -0
  301. package/dist/src/ua_data_type.js.map +1 -0
  302. package/dist/src/ua_data_type_impl.d.ts +93 -93
  303. package/dist/src/ua_data_type_impl.js +368 -368
  304. package/dist/src/ua_method.d.ts +33 -0
  305. package/dist/src/ua_method.js +194 -0
  306. package/dist/src/ua_method.js.map +1 -0
  307. package/dist/src/ua_method_impl.d.ts +41 -41
  308. package/dist/src/ua_method_impl.js +208 -208
  309. package/dist/src/ua_object.d.ts +27 -0
  310. package/dist/src/ua_object.js +153 -0
  311. package/dist/src/ua_object.js.map +1 -0
  312. package/dist/src/ua_object_impl.d.ts +33 -33
  313. package/dist/src/ua_object_impl.js +156 -156
  314. package/dist/src/ua_object_type.d.ts +49 -0
  315. package/dist/src/ua_object_type.js +123 -0
  316. package/dist/src/ua_object_type.js.map +1 -0
  317. package/dist/src/ua_object_type_impl.d.ts +48 -48
  318. package/dist/src/ua_object_type_impl.js +124 -124
  319. package/dist/src/ua_reference_type.d.ts +31 -0
  320. package/dist/src/ua_reference_type.js +108 -0
  321. package/dist/src/ua_reference_type.js.map +1 -0
  322. package/dist/src/ua_reference_type_impl.d.ts +43 -43
  323. package/dist/src/ua_reference_type_impl.js +139 -139
  324. package/dist/src/ua_variable.d.ts +346 -0
  325. package/dist/src/ua_variable.js +1651 -0
  326. package/dist/src/ua_variable.js.map +1 -0
  327. package/dist/src/ua_variable_impl.d.ts +351 -351
  328. package/dist/src/ua_variable_impl.js +1604 -1604
  329. package/dist/src/ua_variable_impl_ext_obj.d.ts +17 -17
  330. package/dist/src/ua_variable_impl_ext_obj.js +437 -437
  331. package/dist/src/ua_variable_type.d.ts +57 -0
  332. package/dist/src/ua_variable_type.js +530 -0
  333. package/dist/src/ua_variable_type.js.map +1 -0
  334. package/dist/src/ua_variable_type_impl.d.ts +62 -62
  335. package/dist/src/ua_variable_type_impl.js +570 -564
  336. package/dist/src/ua_variable_type_impl.js.map +1 -1
  337. package/dist/src/ua_view.d.ts +16 -0
  338. package/dist/src/ua_view.js +41 -0
  339. package/dist/src/ua_view.js.map +1 -0
  340. package/dist/src/ua_view_impl.d.ts +15 -15
  341. package/dist/src/ua_view_impl.js +36 -36
  342. package/distHelpers/add_event_generator_object.d.ts +3 -3
  343. package/distHelpers/add_event_generator_object.js +65 -65
  344. package/distHelpers/alarms_and_conditions_demo.d.ts +10 -10
  345. package/distHelpers/alarms_and_conditions_demo.js +114 -114
  346. package/distHelpers/assertHasMatchingReference.d.ts +19 -19
  347. package/distHelpers/assertHasMatchingReference.js +40 -40
  348. package/distHelpers/boiler_system.d.ts +113 -113
  349. package/distHelpers/boiler_system.js +395 -395
  350. package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -5
  351. package/distHelpers/create_minimalist_address_space_nodeset.js +171 -171
  352. package/distHelpers/date_utils.d.ts +3 -3
  353. package/distHelpers/date_utils.js +9 -9
  354. package/distHelpers/dump_statemachine.js +127 -127
  355. package/distHelpers/get_address_space_fixture.d.ts +1 -1
  356. package/distHelpers/get_address_space_fixture.js +30 -30
  357. package/distHelpers/get_mini_address_space.d.ts +7 -7
  358. package/distHelpers/get_mini_address_space.js +36 -36
  359. package/distHelpers/index.d.ts +12 -12
  360. package/distHelpers/index.js +28 -28
  361. package/distHelpers/mock_session.d.ts +14 -14
  362. package/distHelpers/mock_session.js +25 -25
  363. package/distNodeJS/generate_address_space.d.ts +4 -4
  364. package/distNodeJS/generate_address_space.js +41 -41
  365. package/distNodeJS/index.d.ts +1 -1
  366. package/distNodeJS/index.js +17 -17
  367. package/package.json +38 -38
  368. package/src/ua_variable_type_impl.ts +11 -4
  369. package/test_helpers/test_fixtures/eurange_issue.xml +73 -0
@@ -1,1465 +1,1465 @@
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 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;
1465
1465
  //# sourceMappingURL=load_nodeset2.js.map