node-opcua-address-space 2.97.0 → 2.98.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/dist/source/address_space_ts.d.ts +118 -118
  2. package/dist/source/address_space_ts.js +17 -17
  3. package/dist/source/continuation_points/continuation_point_manager.d.ts +91 -91
  4. package/dist/source/continuation_points/continuation_point_manager.js +200 -200
  5. package/dist/source/helpers/adjust_browse_direction.d.ts +5 -5
  6. package/dist/source/helpers/adjust_browse_direction.js +11 -11
  7. package/dist/source/helpers/argument_list.d.ts +33 -33
  8. package/dist/source/helpers/argument_list.js +254 -254
  9. package/dist/source/helpers/call_helpers.d.ts +6 -6
  10. package/dist/source/helpers/call_helpers.js +71 -71
  11. package/dist/source/helpers/coerce_enum_value.d.ts +6 -6
  12. package/dist/source/helpers/coerce_enum_value.js +33 -33
  13. package/dist/source/helpers/dump_tools.d.ts +14 -14
  14. package/dist/source/helpers/dump_tools.js +78 -78
  15. package/dist/source/helpers/ensure_secure_access.d.ts +9 -9
  16. package/dist/source/helpers/ensure_secure_access.js +76 -76
  17. package/dist/source/helpers/make_optionals_map.d.ts +21 -21
  18. package/dist/source/helpers/make_optionals_map.js +29 -29
  19. package/dist/source/helpers/multiform_func.d.ts +11 -11
  20. package/dist/source/helpers/multiform_func.js +75 -75
  21. package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -3
  22. package/dist/source/helpers/resolve_opaque_on_address_space.js +36 -36
  23. package/dist/source/index.d.ts +61 -61
  24. package/dist/source/index.js +89 -89
  25. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +19 -19
  26. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +2 -2
  27. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +193 -193
  28. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js +2 -2
  29. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.d.ts +12 -12
  30. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js +2 -2
  31. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.d.ts +10 -10
  32. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js +2 -2
  33. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.d.ts +7 -7
  34. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js +2 -2
  35. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.d.ts +7 -7
  36. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js +2 -2
  37. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.d.ts +4 -4
  38. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js +2 -2
  39. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.d.ts +4 -4
  40. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js +2 -2
  41. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.d.ts +9 -9
  42. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js +2 -2
  43. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.d.ts +4 -4
  44. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js +2 -2
  45. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.d.ts +4 -4
  46. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js +2 -2
  47. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.d.ts +20 -20
  48. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js +2 -2
  49. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +23 -23
  50. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js +2 -2
  51. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.d.ts +32 -32
  52. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js +2 -2
  53. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.d.ts +19 -19
  54. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js +2 -2
  55. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +45 -42
  56. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js +2 -2
  57. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.d.ts +7 -7
  58. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js +25 -25
  59. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.d.ts +5 -5
  60. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js +2 -2
  61. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.d.ts +20 -20
  62. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js +2 -2
  63. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.d.ts +26 -26
  64. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js +2 -2
  65. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.d.ts +8 -8
  66. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js +2 -2
  67. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.d.ts +10 -10
  68. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js +2 -2
  69. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -21
  70. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +2 -2
  71. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -24
  72. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +2 -2
  73. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -12
  74. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +2 -2
  75. package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -8
  76. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +2 -2
  77. package/dist/source/interfaces/extension_object_constructor.d.ts +10 -10
  78. package/dist/source/interfaces/extension_object_constructor.js +2 -2
  79. package/dist/source/interfaces/nodeset_loader_options.d.ts +4 -4
  80. package/dist/source/interfaces/nodeset_loader_options.js +2 -2
  81. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -12
  82. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +2 -2
  83. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -49
  84. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +2 -2
  85. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -11
  86. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +2 -2
  87. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +30 -30
  88. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js +2 -2
  89. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +234 -234
  90. package/dist/source/interfaces/state_machine/ua_state_machine_type.js +2 -2
  91. package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -6
  92. package/dist/source/interfaces/state_machine/ua_transition_ex.js +2 -2
  93. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -8
  94. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +2 -2
  95. package/dist/source/loader/decode_xml_extension_object.d.ts +6 -6
  96. package/dist/source/loader/decode_xml_extension_object.js +71 -71
  97. package/dist/source/loader/ensure_datatype_extracted.d.ts +5 -5
  98. package/dist/source/loader/ensure_datatype_extracted.js +70 -70
  99. package/dist/source/loader/generateAddressSpaceRaw.d.ts +11 -11
  100. package/dist/source/loader/generateAddressSpaceRaw.js +45 -45
  101. package/dist/source/loader/load_nodeset2.d.ts +17 -17
  102. package/dist/source/loader/load_nodeset2.js +1483 -1483
  103. package/dist/source/loader/make_semver_compatible.d.ts +6 -6
  104. package/dist/source/loader/make_semver_compatible.js +25 -25
  105. package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -28
  106. package/dist/source/loader/make_xml_extension_object_parser.js +326 -326
  107. package/dist/source/loader/namespace_post_step.d.ts +10 -10
  108. package/dist/source/loader/namespace_post_step.js +61 -61
  109. package/dist/source/loader/register_node_promoter.d.ts +2 -2
  110. package/dist/source/loader/register_node_promoter.js +9 -9
  111. package/dist/source/namespace.d.ts +6 -6
  112. package/dist/source/namespace.js +2 -2
  113. package/dist/source/namespace_alarm_and_condition.d.ts +32 -32
  114. package/dist/source/namespace_alarm_and_condition.js +2 -2
  115. package/dist/source/namespace_data_access.d.ts +42 -42
  116. package/dist/source/namespace_data_access.js +2 -2
  117. package/dist/source/namespace_machine_state.d.ts +8 -8
  118. package/dist/source/namespace_machine_state.js +2 -2
  119. package/dist/source/pseudo_session.d.ts +72 -72
  120. package/dist/source/pseudo_session.js +254 -254
  121. package/dist/source/session_context.d.ts +111 -111
  122. package/dist/source/session_context.js +264 -264
  123. package/dist/source/session_context.js.map +1 -1
  124. package/dist/source/set_namespace_meta_data.d.ts +2 -2
  125. package/dist/source/set_namespace_meta_data.js +59 -59
  126. package/dist/source/ua_root_folder.d.ts +9 -9
  127. package/dist/source/ua_root_folder.js +2 -2
  128. package/dist/source/ua_two_state_variable_ex.d.ts +23 -23
  129. package/dist/source/ua_two_state_variable_ex.js +2 -2
  130. package/dist/source/xml_writer.d.ts +18 -18
  131. package/dist/source/xml_writer.js +2 -2
  132. package/dist/src/address_space.d.ts +387 -387
  133. package/dist/src/address_space.js +1385 -1385
  134. package/dist/src/address_space.js.map +1 -1
  135. package/dist/src/address_space_change_event_tools.d.ts +6 -6
  136. package/dist/src/address_space_change_event_tools.js +152 -152
  137. package/dist/src/address_space_private.d.ts +43 -43
  138. package/dist/src/address_space_private.js +2 -2
  139. package/dist/src/alarms_and_conditions/condition.d.ts +5 -5
  140. package/dist/src/alarms_and_conditions/condition.js +78 -78
  141. package/dist/src/alarms_and_conditions/condition_info_impl.d.ts +26 -26
  142. package/dist/src/alarms_and_conditions/condition_info_impl.js +54 -54
  143. package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +222 -222
  144. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +657 -657
  145. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
  146. package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +9 -9
  147. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +60 -60
  148. package/dist/src/alarms_and_conditions/index.d.ts +16 -16
  149. package/dist/src/alarms_and_conditions/index.js +32 -32
  150. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +44 -44
  151. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -244
  152. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +93 -93
  153. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +418 -418
  154. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  155. package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +26 -26
  156. package/dist/src/alarms_and_conditions/ua_base_event_impl.js +38 -38
  157. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +44 -44
  158. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +183 -183
  159. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +155 -153
  160. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1028 -1028
  161. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  162. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +14 -14
  163. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +34 -34
  164. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +24 -24
  165. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +56 -56
  166. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +11 -11
  167. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +11 -11
  168. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +23 -23
  169. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +86 -86
  170. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +11 -11
  171. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +7 -7
  172. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +79 -79
  173. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +250 -250
  174. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +24 -24
  175. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +50 -50
  176. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +19 -19
  177. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +162 -162
  178. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +46 -46
  179. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +165 -165
  180. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +18 -18
  181. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +17 -17
  182. package/dist/src/apply_condition_refresh.d.ts +6 -6
  183. package/dist/src/apply_condition_refresh.js +27 -27
  184. package/dist/src/base_node_impl.d.ts +284 -284
  185. package/dist/src/base_node_impl.js +1454 -1454
  186. package/dist/src/base_node_private.d.ts +81 -81
  187. package/dist/src/base_node_private.js +832 -803
  188. package/dist/src/base_node_private.js.map +1 -1
  189. package/dist/src/check_value_rank_compatibility.d.ts +15 -15
  190. package/dist/src/check_value_rank_compatibility.js +81 -81
  191. package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -11
  192. package/dist/src/data_access/add_dataItem_stuff.js +61 -61
  193. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -1
  194. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +34 -34
  195. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -32
  196. package/dist/src/data_access/ua_multistate_discrete_impl.js +130 -130
  197. package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +52 -52
  198. package/dist/src/data_access/ua_multistate_value_discrete_impl.js +253 -253
  199. package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +25 -25
  200. package/dist/src/data_access/ua_two_state_discrete_impl.js +155 -155
  201. package/dist/src/event_data.d.ts +34 -34
  202. package/dist/src/event_data.js +64 -64
  203. package/dist/src/extension_object_array_node.d.ts +23 -23
  204. package/dist/src/extension_object_array_node.js +248 -248
  205. package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -26
  206. package/dist/src/historical_access/address_space_historical_data_node.js +652 -652
  207. package/dist/src/idx_iterator.d.ts +8 -8
  208. package/dist/src/idx_iterator.js +50 -50
  209. package/dist/src/index_current.d.ts +46 -46
  210. package/dist/src/index_current.js +77 -77
  211. package/dist/src/namespace_impl.d.ts +456 -456
  212. package/dist/src/namespace_impl.js +1762 -1762
  213. package/dist/src/namespace_impl.js.map +1 -1
  214. package/dist/src/namespace_private.d.ts +23 -23
  215. package/dist/src/namespace_private.js +32 -32
  216. package/dist/src/nodeid_manager.d.ts +37 -37
  217. package/dist/src/nodeid_manager.js +183 -183
  218. package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -2
  219. package/dist/src/nodeset_tools/adjust_namespace_array.js +13 -13
  220. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +18 -18
  221. package/dist/src/nodeset_tools/construct_namespace_dependency.js +140 -140
  222. package/dist/src/nodeset_tools/dump_to_bsd.d.ts +2 -2
  223. package/dist/src/nodeset_tools/dump_to_bsd.js +164 -164
  224. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +10 -10
  225. package/dist/src/nodeset_tools/nodeset_to_xml.js +1287 -1287
  226. package/dist/src/private_namespace.d.ts +5 -5
  227. package/dist/src/private_namespace.js +19 -19
  228. package/dist/src/reference_impl.d.ts +43 -43
  229. package/dist/src/reference_impl.js +139 -139
  230. package/dist/src/role_permissions.d.ts +2 -2
  231. package/dist/src/role_permissions.js +10 -10
  232. package/dist/src/state_machine/finite_state_machine.d.ts +81 -81
  233. package/dist/src/state_machine/finite_state_machine.js +388 -388
  234. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +38 -38
  235. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +250 -250
  236. package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -61
  237. package/dist/src/state_machine/ua_two_state_variable.js +331 -331
  238. package/dist/src/tool_isSubtypeOf.d.ts +18 -18
  239. package/dist/src/tool_isSubtypeOf.js +124 -124
  240. package/dist/src/ua_condition_type.d.ts +8 -8
  241. package/dist/src/ua_condition_type.js +2 -2
  242. package/dist/src/ua_data_type_impl.d.ts +89 -89
  243. package/dist/src/ua_data_type_impl.js +368 -368
  244. package/dist/src/ua_method_impl.d.ts +42 -42
  245. package/dist/src/ua_method_impl.js +217 -217
  246. package/dist/src/ua_object_impl.d.ts +35 -35
  247. package/dist/src/ua_object_impl.js +168 -168
  248. package/dist/src/ua_object_type_impl.d.ts +50 -50
  249. package/dist/src/ua_object_type_impl.js +126 -126
  250. package/dist/src/ua_reference_type_impl.d.ts +45 -45
  251. package/dist/src/ua_reference_type_impl.js +141 -141
  252. package/dist/src/ua_variable_impl.d.ts +380 -380
  253. package/dist/src/ua_variable_impl.js +1738 -1738
  254. package/dist/src/ua_variable_impl_ext_obj.d.ts +23 -23
  255. package/dist/src/ua_variable_impl_ext_obj.js +670 -670
  256. package/dist/src/ua_variable_type_impl.d.ts +74 -74
  257. package/dist/src/ua_variable_type_impl.js +597 -581
  258. package/dist/src/ua_variable_type_impl.js.map +1 -1
  259. package/dist/src/ua_view_impl.d.ts +19 -19
  260. package/dist/src/ua_view_impl.js +43 -43
  261. package/dist/tsconfig_common.tsbuildinfo +1 -0
  262. package/distHelpers/add_event_generator_object.d.ts +3 -3
  263. package/distHelpers/add_event_generator_object.js +64 -64
  264. package/distHelpers/alarms_and_conditions_demo.d.ts +9 -9
  265. package/distHelpers/alarms_and_conditions_demo.js +115 -115
  266. package/distHelpers/assertHasMatchingReference.d.ts +19 -19
  267. package/distHelpers/assertHasMatchingReference.js +40 -40
  268. package/distHelpers/boiler_system.d.ts +113 -113
  269. package/distHelpers/boiler_system.js +395 -395
  270. package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -5
  271. package/distHelpers/create_minimalist_address_space_nodeset.js +171 -171
  272. package/distHelpers/date_utils.d.ts +3 -3
  273. package/distHelpers/date_utils.js +9 -9
  274. package/distHelpers/dump_statemachine.js +127 -127
  275. package/distHelpers/get_address_space_fixture.d.ts +1 -1
  276. package/distHelpers/get_address_space_fixture.js +30 -30
  277. package/distHelpers/get_mini_address_space.d.ts +7 -7
  278. package/distHelpers/get_mini_address_space.js +36 -36
  279. package/distHelpers/index.d.ts +12 -12
  280. package/distHelpers/index.js +28 -28
  281. package/distHelpers/mock_session.d.ts +10 -10
  282. package/distHelpers/mock_session.js +25 -25
  283. package/distNodeJS/generate_address_space.d.ts +6 -6
  284. package/distNodeJS/generate_address_space.js +52 -52
  285. package/distNodeJS/index.d.ts +1 -1
  286. package/distNodeJS/index.js +17 -17
  287. package/package.json +51 -40
  288. package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +4 -3
  289. package/src/alarms_and_conditions/ua_condition_impl.ts +14 -9
  290. package/src/base_node_private.ts +73 -28
  291. package/src/ua_variable_type_impl.ts +35 -17
  292. package/.mocharc.yml +0 -12
  293. package/dist/src/tool_isSupertypeOf.d.ts +0 -18
  294. package/dist/src/tool_isSupertypeOf.js +0 -125
  295. package/dist/src/tool_isSupertypeOf.js.map +0 -1
  296. package/generate.js +0 -1
  297. package/source_nodejs/generate_address_space.ts +0 -60
  298. package/source_nodejs/index.ts +0 -1
  299. package/test_helpers/add_event_generator_object.ts +0 -71
  300. package/test_helpers/alarms_and_conditions_demo.ts +0 -151
  301. package/test_helpers/assertHasMatchingReference.ts +0 -43
  302. package/test_helpers/boiler_system.ts +0 -610
  303. package/test_helpers/create_minimalist_address_space_nodeset.ts +0 -208
  304. package/test_helpers/date_utils.ts +0 -5
  305. package/test_helpers/dump_statemachine.ts +0 -155
  306. package/test_helpers/get_address_space_fixture.ts +0 -30
  307. package/test_helpers/get_mini_address_space.ts +0 -42
  308. package/test_helpers/index.ts +0 -12
  309. package/test_helpers/mock_session.ts +0 -34
  310. package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +0 -150
  311. package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +0 -57
  312. package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +0 -136
  313. package/test_helpers/test_fixtures/dataType_issue.xml +0 -80
  314. package/test_helpers/test_fixtures/dataType_withEnumeration.xml +0 -82
  315. package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +0 -194
  316. package/test_helpers/test_fixtures/dataType_with_qualifiedname.xml +0 -71
  317. package/test_helpers/test_fixtures/dataType_with_recursive_structure.xml +0 -155
  318. package/test_helpers/test_fixtures/dataType_with_structures.xml +0 -605
  319. package/test_helpers/test_fixtures/dataType_with_union.xml +0 -90
  320. package/test_helpers/test_fixtures/datatype_as_per_1.04.xml +0 -118
  321. package/test_helpers/test_fixtures/datatype_with_allow_subtype.xml +0 -104
  322. package/test_helpers/test_fixtures/eurange_issue.xml +0 -74
  323. package/test_helpers/test_fixtures/example_issue1096.xml +0 -267
  324. package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +0 -106
  325. package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +0 -1305
  326. package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +0 -370
  327. package/test_helpers/test_fixtures/issue_1132_variable_with_nodeid_value.xml +0 -68
  328. package/test_helpers/test_fixtures/issue_846.xml +0 -3172
  329. package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +0 -33
  330. package/test_helpers/test_fixtures/mini.Node.Set2.xml +0 -4736
  331. package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +0 -196
  332. package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +0 -8
  333. package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +0 -20
  334. package/test_helpers/test_fixtures/nodeset_no_aliases.xml +0 -30
  335. package/test_helpers/test_fixtures/nodeset_no_aliases_with_aliases.xml +0 -31
  336. package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +0 -45
  337. package/test_helpers/test_fixtures/nodeset_with_guid.xml +0 -1442
  338. package/test_helpers/test_fixtures/nodeset_with_int64_values.xml +0 -31
  339. package/test_helpers/test_fixtures/nodeset_with_special_char.xml +0 -34
  340. package/test_helpers/test_fixtures/nodeset_with_utf8_special_characters.xml +0 -20
  341. package/test_helpers/test_fixtures/variable_with_value.xml +0 -143
  342. package/test_helpers/test_fixtures/variabletype_with_value.xml +0 -324
@@ -1,804 +1,833 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseNode_add_backward_reference = exports.BaseNode_remove_backward_reference = exports._constructReferenceDescription = exports._handle_HierarchicalReference = exports._clone = exports._clone_non_hierarchical_references = exports._clone_children_references = exports.VariableOrVariableType_toString = exports.valueRankToString = exports.UAObjectType_toString = exports.UAObject_toString = exports.UAVariable_toString = exports.UAVariableType_toString = exports.BaseNode_References_toString = exports.BaseNode_toString = exports.ToStringBuilder = exports.BaseNode_clearCache = exports.BaseNode_getCache = exports.BaseNode_getPrivate = exports.BaseNode_removePrivate = exports.BaseNode_initPrivate = void 0;
4
- /**
5
- * @module node-opcua-address-space.Private
6
- */
7
- // tslint:disable:no-bitwise
8
- const chalk = require("chalk");
9
- const node_opcua_assert_1 = require("node-opcua-assert");
10
- const node_opcua_data_model_1 = require("node-opcua-data-model");
11
- const node_opcua_debug_1 = require("node-opcua-debug");
12
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
13
- const node_opcua_types_1 = require("node-opcua-types");
14
- const node_opcua_constants_1 = require("node-opcua-constants");
15
- const namespace_private_1 = require("./namespace_private");
16
- const reference_impl_1 = require("./reference_impl");
17
- const base_node_impl_1 = require("./base_node_impl");
18
- const tool_isSubtypeOf_1 = require("./tool_isSubtypeOf");
19
- // eslint-disable-next-line prefer-const
20
- const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
21
- const doTrace = (0, node_opcua_debug_1.checkDebugFlag)("INSTANTIATE");
22
- const traceLog = errorLog;
23
- const g_weakMap = new WeakMap();
24
- const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
25
- function BaseNode_initPrivate(self) {
26
- const _private = {
27
- __address_space: null,
28
- _referenceIdx: {},
29
- _back_referenceIdx: {},
30
- _browseFilter: undefined,
31
- _cache: {},
32
- _description: undefined,
33
- _displayName: [],
34
- _parent: undefined,
35
- _subtype_idx: {},
36
- _subtype_idxVersion: 0
37
- };
38
- g_weakMap.set(self, _private);
39
- return _private;
40
- }
41
- exports.BaseNode_initPrivate = BaseNode_initPrivate;
42
- function BaseNode_removePrivate(self) {
43
- // there is no need to delete object from weak map
44
- // the GC will take care of this in due course
45
- // g_weakMap.delete(self);
46
- const _private = BaseNode_getPrivate(self);
47
- _private._cache = {};
48
- _private.__address_space = null;
49
- _private._back_referenceIdx = {};
50
- _private._referenceIdx = {};
51
- _private._description = undefined;
52
- _private._displayName = [];
53
- }
54
- exports.BaseNode_removePrivate = BaseNode_removePrivate;
55
- function BaseNode_getPrivate(self) {
56
- return g_weakMap.get(self);
57
- }
58
- exports.BaseNode_getPrivate = BaseNode_getPrivate;
59
- function BaseNode_getCache(node) {
60
- return BaseNode_getPrivate(node)._cache;
61
- }
62
- exports.BaseNode_getCache = BaseNode_getCache;
63
- function BaseNode_clearCache(node) {
64
- const _private = BaseNode_getPrivate(node);
65
- if (_private && _private._cache) {
66
- _private._cache = {};
67
- }
68
- (0, tool_isSubtypeOf_1.wipeMemorizedStuff)(node);
69
- }
70
- exports.BaseNode_clearCache = BaseNode_clearCache;
71
- const hasTypeDefinition_ReferenceTypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition");
72
- class ToStringBuilder {
73
- constructor() {
74
- this.level = 0;
75
- this.cycleDetector = {};
76
- this.padding = "";
77
- this.str = [];
78
- //
79
- this.str = [];
80
- }
81
- add(line) {
82
- this.str.push(line);
83
- }
84
- toString() {
85
- return this.str.join("\n");
86
- }
87
- indent(str, padding) {
88
- padding = padding || " ";
89
- return str
90
- .split("\n")
91
- .map((r) => {
92
- return padding + r;
93
- })
94
- .join("\n");
95
- }
96
- }
97
- exports.ToStringBuilder = ToStringBuilder;
98
- function set_as_processed(options, nodeId) {
99
- options.cycleDetector[nodeId.toString()] = nodeId;
100
- }
101
- function is_already_processed(options, nodeId) {
102
- return !!options.cycleDetector[nodeId.toString()];
103
- }
104
- function BaseNode_toString(options) {
105
- options.level = options.level || 1;
106
- set_as_processed(options, this.nodeId);
107
- options.add("");
108
- options.add(options.padding + chalk.yellow(" nodeId : ") + this.nodeId.toString());
109
- options.add(options.padding + chalk.yellow(" nodeClass : ") + node_opcua_data_model_1.NodeClass[this.nodeClass] + " (" + this.nodeClass + ")");
110
- options.add(options.padding + chalk.yellow(" browseName : ") + this.browseName.toString());
111
- options.add(options.padding +
112
- chalk.yellow(" displayName : ") +
113
- this.displayName.map((f) => f.locale + " " + f.text).join(" | "));
114
- options.add(options.padding + chalk.yellow(" description : ") + (this.description ? this.description.toString() : ""));
115
- }
116
- exports.BaseNode_toString = BaseNode_toString;
117
- function BaseNode_References_toString(options) {
118
- const _private = BaseNode_getPrivate(this);
119
- const displayOptions = {
120
- addressSpace: this.addressSpace
121
- };
122
- const addressSpace = this.addressSpace;
123
- options.add(options.padding +
124
- chalk.yellow(" references : ") +
125
- " length =" +
126
- Object.keys(_private._referenceIdx).length);
127
- function dump_reference(follow, reference) {
128
- if (!reference) {
129
- return;
130
- }
131
- const o = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
132
- if (!o) {
133
- warningLog("cannot find referece", reference.toString());
134
- return;
135
- }
136
- const name = o.browseName.toString();
137
- const modellingRule = o.modellingRule || " ";
138
- const extra = modellingRule[0] +
139
- (() => {
140
- switch (o.nodeClass) {
141
- case node_opcua_data_model_1.NodeClass.Object:
142
- return "[O] ";
143
- case node_opcua_data_model_1.NodeClass.Variable:
144
- return "[V] " + o.dataType.toString(displayOptions).padEnd(10);
145
- case node_opcua_data_model_1.NodeClass.Method:
146
- return "[M] ";
147
- case node_opcua_data_model_1.NodeClass.DataType:
148
- return "[DT]";
149
- case node_opcua_data_model_1.NodeClass.ReferenceType:
150
- return "[RT]";
151
- case node_opcua_data_model_1.NodeClass.ObjectType:
152
- return "[OT]";
153
- case node_opcua_data_model_1.NodeClass.VariableType:
154
- return "[VT]";
155
- case node_opcua_data_model_1.NodeClass.View:
156
- return "[V] ";
157
- }
158
- return "";
159
- })();
160
- options.add(options.padding +
161
- chalk.yellow(" +-> ") +
162
- reference.toString(displayOptions) +
163
- " " +
164
- chalk.cyan(name.padEnd(25, " ")) +
165
- " " +
166
- chalk.magentaBright(extra));
167
- // ignore HasTypeDefinition as it has been already handled
168
- if ((0, node_opcua_nodeid_1.sameNodeId)(reference.referenceType, hasTypeDefinition_ReferenceTypeNodeId) && reference.nodeId.namespace === 0) {
169
- return;
170
- }
171
- if (o) {
172
- if (!is_already_processed(options, o.nodeId)) {
173
- set_as_processed(options, o.nodeId);
174
- if (options.level > 1 && follow) {
175
- const rr = o.toString({
176
- cycleDetector: options.cycleDetector,
177
- level: options.level - 1,
178
- padding: options.padding + " "
179
- });
180
- options.add(rr);
181
- }
182
- }
183
- }
184
- }
185
- // direct reference
186
- Object.values(_private._referenceIdx).forEach(dump_reference.bind(null, true));
187
- const br = Object.values(_private._back_referenceIdx).map((x) => x);
188
- options.add(options.padding +
189
- chalk.yellow(" back_references : ") +
190
- chalk.cyan(" length =") +
191
- br.length +
192
- chalk.grey(" ( references held by other nodes involving this node)"));
193
- // backward reference
194
- br.forEach(dump_reference.bind(null, false));
195
- }
196
- exports.BaseNode_References_toString = BaseNode_References_toString;
197
- function _UAType_toString(options) {
198
- if (this.subtypeOfObj) {
199
- options.add(options.padding +
200
- chalk.yellow(" subtypeOf : ") +
201
- this.subtypeOfObj.browseName.toString() +
202
- " (" +
203
- this.subtypeOfObj.nodeId.toString() +
204
- ")");
205
- }
206
- }
207
- function _UAInstance_toString(options) {
208
- if (this.typeDefinitionObj) {
209
- options.add(options.padding +
210
- chalk.yellow(" typeDefinition : ") +
211
- this.typeDefinitionObj.browseName.toString() +
212
- " (" +
213
- this.typeDefinitionObj.nodeId.toString() +
214
- ")");
215
- }
216
- }
217
- function UAVariableType_toString(options) {
218
- BaseNode_toString.call(this, options);
219
- _UAType_toString.call(this, options);
220
- VariableOrVariableType_toString.call(this, options);
221
- BaseNode_References_toString.call(this, options);
222
- }
223
- exports.UAVariableType_toString = UAVariableType_toString;
224
- function UAVariable_toString(options) {
225
- BaseNode_toString.call(this, options);
226
- _UAInstance_toString.call(this, options);
227
- VariableOrVariableType_toString.call(this, options);
228
- AccessLevelFlags_toString.call(this, options);
229
- BaseNode_References_toString.call(this, options);
230
- }
231
- exports.UAVariable_toString = UAVariable_toString;
232
- function UAObject_toString(options) {
233
- BaseNode_toString.call(this, options);
234
- _UAInstance_toString.call(this, options);
235
- BaseNode_References_toString.call(this, options);
236
- }
237
- exports.UAObject_toString = UAObject_toString;
238
- function UAObjectType_toString(options) {
239
- BaseNode_toString.call(this, options);
240
- _UAType_toString.call(this, options);
241
- BaseNode_References_toString.call(this, options);
242
- }
243
- exports.UAObjectType_toString = UAObjectType_toString;
244
- function valueRankToString(valueRank) {
245
- switch (valueRank) {
246
- case 1:
247
- return "OneDimension (1)";
248
- case 0:
249
- return "OneOrMoreDimensions (0)"; // The value is an array with one or more dimensions
250
- case -1:
251
- return "Scalar (-1)";
252
- case -2:
253
- return "Any (-2)"; // The value can be a scalar or an array with any number of dimensions
254
- case -3:
255
- return "ScalarOrOneDimension (2)"; // The value can be a scalar or a one dimensional array.
256
- default:
257
- if (valueRank > 0) {
258
- return "" + valueRank + "-Dimensions";
259
- }
260
- else {
261
- return "Invalid (" + valueRank + ")";
262
- }
263
- }
264
- }
265
- exports.valueRankToString = valueRankToString;
266
- function accessLevelFlagToString(flag) {
267
- const str = [];
268
- if (flag & node_opcua_data_model_1.AccessLevelFlag.CurrentRead) {
269
- str.push("CurrentRead");
270
- }
271
- if (flag & node_opcua_data_model_1.AccessLevelFlag.CurrentWrite) {
272
- str.push("CurrentWrite");
273
- }
274
- if (flag & node_opcua_data_model_1.AccessLevelFlag.HistoryRead) {
275
- str.push("HistoryRead");
276
- }
277
- if (flag & node_opcua_data_model_1.AccessLevelFlag.HistoryWrite) {
278
- str.push("HistoryWrite");
279
- }
280
- if (flag & node_opcua_data_model_1.AccessLevelFlag.SemanticChange) {
281
- str.push("SemanticChange");
282
- }
283
- if (flag & node_opcua_data_model_1.AccessLevelFlag.StatusWrite) {
284
- str.push("StatusWrite");
285
- }
286
- if (flag & node_opcua_data_model_1.AccessLevelFlag.TimestampWrite) {
287
- str.push("TimestampWrite");
288
- }
289
- return str.join(" | ");
290
- }
291
- function AccessLevelFlags_toString(options) {
292
- (0, node_opcua_assert_1.assert)(options);
293
- options.add(options.padding + chalk.yellow(" accessLevel : ") + " " + accessLevelFlagToString(this.accessLevel));
294
- if (this.userAccessLevel !== undefined) {
295
- options.add(options.padding + chalk.yellow(" userAccessLevel : ") + " " + accessLevelFlagToString(this.userAccessLevel));
296
- }
297
- }
298
- function VariableOrVariableType_toString(options) {
299
- (0, node_opcua_assert_1.assert)(options);
300
- if (this.dataType) {
301
- const addressSpace = this.addressSpace;
302
- const d = addressSpace.findNode(this.dataType);
303
- const n = d ? "(" + d.browseName.toString() + ")" : " (???)";
304
- options.add(options.padding + chalk.yellow(" dataType : ") + this.dataType + " " + n);
305
- }
306
- if (this.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
307
- const _dataValue = this.$dataValue;
308
- if (_dataValue) {
309
- options.add(options.padding +
310
- chalk.yellow(" value : ") +
311
- "\n" +
312
- options.indent(_dataValue.toString(), options.padding + " | "));
313
- }
314
- }
315
- if (Object.prototype.hasOwnProperty.call(this, "valueRank")) {
316
- if (this.valueRank !== undefined) {
317
- options.add(options.padding + chalk.yellow(" valueRank : ") + " " + valueRankToString(this.valueRank));
318
- }
319
- else {
320
- options.add(options.padding + chalk.yellow(" valueRank : ") + " undefined");
321
- }
322
- }
323
- if (this.minimumSamplingInterval !== undefined) {
324
- options.add(options.padding +
325
- chalk.yellow(" minimumSamplingInterval : ") +
326
- " " +
327
- this.minimumSamplingInterval.toString() +
328
- " ms");
329
- }
330
- if (this.arrayDimensions) {
331
- options.add(options.padding +
332
- chalk.yellow(" arrayDimension : ") +
333
- " [" +
334
- this.arrayDimensions.join(",").toString() +
335
- " ]");
336
- }
337
- }
338
- exports.VariableOrVariableType_toString = VariableOrVariableType_toString;
339
- const defaultExtraInfo = {
340
- level: 0,
341
- pad() {
342
- return "";
343
- },
344
- registerClonedObject(node, node1) {
345
- /** */
346
- }
347
- };
348
- /**
349
- *
350
- *
351
- * MyDeriveType ------------------- -> MyBaseType --------------> TopologyElementType
352
- * | | |
353
- * +- ParamaterSet +-> ParameterSet +-> ParamaterSet
354
- * | |
355
- * +- Foo1 |
356
- * +- Bar
357
- *
358
- * Instance
359
- *
360
- * @param newParent
361
- * @param node
362
- * @param copyAlsoModellingRules
363
- * @param optionalFilter
364
- * @param extraInfo
365
- * @param browseNameMap
366
- * @returns
367
- */
368
- function _clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
369
- /**
370
- * the type definition node of the node to clone
371
- */
372
- const nodeToCloneTypeDefinition = nodeToClone.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || nodeToClone.nodeClass === node_opcua_data_model_1.NodeClass.VariableType
373
- ? nodeToClone.subtypeOfObj
374
- : null;
375
- if (!nodeToCloneTypeDefinition)
376
- return;
377
- doTrace &&
378
- traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- now cloning children on template ", node.browseName.toString(), node.nodeId.toString(), nodeToCloneTypeDefinition.browseName.toString()));
379
- const namespace = newParent.namespace;
380
- /**
381
- * the child node of the new parent that match the node to clone or enrich
382
- */
383
- const newParentChild = newParent.getChildByName(node.browseName);
384
- if (!newParentChild) {
385
- return;
386
- }
387
- // we have found a matching child on the new parent.
388
- // the mission is to enrich this child node with compoents and property that
389
- // exists also in the template
390
- let typeDefinitionNode = nodeToCloneTypeDefinition;
391
- while (typeDefinitionNode) {
392
- doTrace &&
393
- traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- now cloning children on ", newParentChild.browseName.toString(), newParentChild.nodeId.toString(), " (child of ", node.browseName.toString(), node.nodeId.toString(), ") from ", typeDefinitionNode.browseName.toString()));
394
- const typeDefinitionChild = typeDefinitionNode.getChildByName(node.browseName);
395
- if (typeDefinitionChild) {
396
- const references = typeDefinitionChild.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
397
- for (const ref of references) {
398
- const grandChild = ref.node;
399
- if (grandChild.modellingRule === "MandatoryPlaceholder" || grandChild.modellingRule === "OptionalPlaceholder")
400
- continue;
401
- // if not already node present in new Parent => just ignore
402
- const hasAlready = newParentChild.getChildByName(grandChild.browseName) !== null;
403
- if (!hasAlready) {
404
- if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
405
- doTrace &&
406
- traceLog(extraInfo.pad(), "skipping optional ", node.browseName.toString(), "that doesn't appear in the filter");
407
- continue; // skip this node
408
- }
409
- const options = {
410
- namespace,
411
- references: [
412
- new reference_impl_1.ReferenceImpl({
413
- referenceType: ref.referenceType,
414
- isForward: false,
415
- nodeId: newParentChild.nodeId
416
- })
417
- ],
418
- copyAlsoModellingRules
419
- };
420
- const a = grandChild.clone(options, optionalFilter, extraInfo);
421
- }
422
- }
423
- }
424
- typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
425
- }
426
- }
427
- /**
428
- * clone properties and methods
429
- * @private
430
- */
431
- function _clone_collection_new(nodeToClone, newParent, collectionRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
432
- var _a;
433
- const namespace = newParent.namespace;
434
- extraInfo = extraInfo || defaultExtraInfo;
435
- const addressSpace = newParent.addressSpace;
436
- (0, node_opcua_assert_1.assert)(!optionalFilter || (typeof optionalFilter.shouldKeep === "function" && typeof optionalFilter.filterFor === "function"));
437
- for (const reference of collectionRef) {
438
- const node = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
439
- // ensure node is of the correct type,
440
- // it may happen that the xml nodeset2 file was malformed
441
- // istanbul ignore next
442
- if (typeof node.clone !== "function") {
443
- // tslint:disable-next-line:no-console
444
- warningLog(chalk.red("Warning : cannot clone node ") +
445
- node.browseName.toString() +
446
- " of class " +
447
- node_opcua_data_model_1.NodeClass[node.nodeClass].toString() +
448
- " while cloning " +
449
- newParent.browseName.toString());
450
- continue;
451
- }
452
- if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
453
- doTrace &&
454
- traceLog(extraInfo.pad(), "skipping optional ", node.browseName.toString(), "that doesn't appear in the filter");
455
- continue; // skip this node
456
- }
457
- const key = node.browseName.toString();
458
- if (browseNameMap === null || browseNameMap === void 0 ? void 0 : browseNameMap.has(key)) {
459
- _clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
460
- continue; // skipping node with same browseName
461
- }
462
- browseNameMap === null || browseNameMap === void 0 ? void 0 : browseNameMap.add(key);
463
- // assert(reference.isForward);
464
- // assert(reference.referenceType instanceof NodeId, "" + reference.referenceType.toString());
465
- const options = {
466
- namespace,
467
- references: [new reference_impl_1.ReferenceImpl({ referenceType: reference.referenceType, isForward: false, nodeId: newParent.nodeId })],
468
- copyAlsoModellingRules
469
- };
470
- doTrace &&
471
- traceLog(extraInfo.pad(), "cloning => ", reference.referenceType.toString({ addressSpace }), "=>", node.browseName.toString(), chalk.magentaBright((_a = node.typeDefinitionObj) === null || _a === void 0 ? void 0 : _a.browseName.toString()));
472
- extraInfo.level += 4;
473
- const clone = node.clone(options, optionalFilter, extraInfo);
474
- extraInfo.level -= 4;
475
- doTrace && traceLog(extraInfo.pad(), "cloning => ", node.browseName.toString(), "nodeId", clone.nodeId.toString());
476
- extraInfo.level++;
477
- _clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
478
- extraInfo.level--;
479
- // also clone or instantiate interface members that may be required in the optionals
480
- extraInfo.level++;
481
- _cloneInterface(nodeToClone, newParent, node, optionalFilter, extraInfo, browseNameMap);
482
- extraInfo.level--;
483
- if (extraInfo) {
484
- extraInfo.registerClonedObject(node, clone);
485
- }
486
- }
487
- }
488
- function _extractInterfaces2(typeDefinitionNode, extraInfo) {
489
- if (!typeDefinitionNode ||
490
- (typeDefinitionNode.nodeId.namespace === 0 &&
491
- (typeDefinitionNode.nodeId.value === node_opcua_constants_1.ObjectTypeIds.BaseObjectType ||
492
- typeDefinitionNode.nodeId.value === node_opcua_constants_1.VariableTypeIds.BaseVariableType))) {
493
- return [];
494
- }
495
- const addressSpace = typeDefinitionNode.addressSpace;
496
- const hasInterfaceReference = addressSpace.findReferenceType("HasInterface");
497
- if (!hasInterfaceReference) {
498
- // this version of the standard UA namespace doesn't support Interface yet
499
- return [];
500
- }
501
- // example:
502
- // FolderType
503
- // FunctionalGroupType
504
- // MachineryItemIdentificationType : IMachineryItemVendorNameplateType
505
- // MachineIdentificationType : IMachineTagNameplateType, IMachineVendorNamePlateType
506
- // MachineToolIdentificationType
507
- //
508
- //
509
- // IMachineTagNameplateType -subtypeOf-> ITagNameplateType
510
- // IMachineVendorNamePlateType -subtypeOf-> IMachineryItemVendorNamePlateType
511
- // IMachineryItemVendorNamePlateType -subtypeOf-> IVendorNameplateType
512
- const interfacesRef = typeDefinitionNode.findReferencesEx("HasInterface", node_opcua_data_model_1.BrowseDirection.Forward);
513
- const interfaces = interfacesRef.map((r) => addressSpace.findNode(r.nodeId));
514
- const baseInterfaces = [];
515
- for (const iface of interfaces) {
516
- doTrace &&
517
- traceLog(extraInfo.pad(), typeDefinitionNode.browseName.toString(), " - has interface -> ", iface.browseName.toString());
518
- baseInterfaces.push(iface);
519
- if (iface.subtypeOfObj) {
520
- extraInfo.level++;
521
- baseInterfaces.push(..._extractInterfaces2(iface.subtypeOfObj, extraInfo));
522
- extraInfo.level--;
523
- }
524
- }
525
- interfaces.push(...baseInterfaces);
526
- if (typeDefinitionNode.subtypeOfObj) {
527
- doTrace &&
528
- traceLog(extraInfo.pad(), typeDefinitionNode.browseName.toString(), " - subtypef -> ", typeDefinitionNode.subtypeOfObj.browseName.toString());
529
- extraInfo.level++;
530
- interfaces.push(..._extractInterfaces2(typeDefinitionNode.subtypeOfObj, extraInfo));
531
- extraInfo.level--;
532
- }
533
- const dedupedInterfaces = [...new Set(interfaces)];
534
- doTrace &&
535
- dedupedInterfaces.length &&
536
- traceLog(extraInfo.pad(), chalk.yellow("Interface for ", typeDefinitionNode.browseName.toString()), "=", dedupedInterfaces.map((x) => x.browseName.toString()).join(" "));
537
- return dedupedInterfaces;
538
- }
539
- /*
540
-
541
- // also find all related interfaces
542
- if (false && typeDefinitionNode) {
543
- dotrace && tracelog("typeDefinitionNode = ", typeDefinitionNode.browseName.toString());
544
- const interfaces = _extractInterfaces(typeDefinitionNode);
545
- for (const interfaceNode of interfaces) {
546
- dotrace && tracelog(" adding member of interface ", interfaceNode.browseName.toString());
547
- const fromInterface = interfaceNode.findReferencesEx("Aggregates", BrowseDirection.Forward);
548
- dotrace && tracelog(
549
- " B ",
550
- fromInterface.map((r) => r.toString({ addressSpace }) + " " + r.node!.browseName.toString()).join("\n")
551
- );
552
- add(fromInterface);
553
- }
554
- }
555
- */
556
- function _crap_extractInterfaces(typeDefinitionNode, extraInfo) {
557
- if (typeDefinitionNode.nodeId.namespace === 0 &&
558
- (typeDefinitionNode.nodeId.value === node_opcua_constants_1.ObjectTypeIds.BaseObjectType ||
559
- typeDefinitionNode.nodeId.value === node_opcua_constants_1.VariableTypeIds.BaseVariableType)) {
560
- return [];
561
- }
562
- const addressSpace = typeDefinitionNode.addressSpace;
563
- // example:
564
- // FolderType
565
- // FunctionalGroupType
566
- // MachineryItemIdentificationType : IMachineryItemVendorNameplateType
567
- // MachineIdentificationType : IMachineTagNameplateType, IMachineVendorNamePlateType
568
- // MachineToolIdentificationType
569
- //
570
- //
571
- // IMachineTagNameplateType -subtypeOf-> ITagNameplateType
572
- // IMachineVendorNamePlateType -subtypeOf-> IMachineryItemVendorNamePlateType
573
- // IMachineryItemVendorNamePlateType -subtypeOf-> IVendorNameplateType
574
- const interfacesRef = typeDefinitionNode.findReferencesEx("HasInterface", node_opcua_data_model_1.BrowseDirection.Forward);
575
- const interfaces = interfacesRef.map((r) => r.node);
576
- for (const iface of interfaces) {
577
- doTrace && traceLog(extraInfo.pad(), " interface ", iface.browseName.toString());
578
- }
579
- return interfaces;
580
- }
581
- function _cloneInterface(nodeToClone, newParent, node, optionalFilter, extraInfo, browseNameMap) {
582
- doTrace &&
583
- traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- now cloning interfaces of ", node.browseName.toString(), node.nodeId.toString()));
584
- extraInfo = extraInfo || defaultExtraInfo;
585
- const addressSpace = node.addressSpace;
586
- if (node.nodeClass !== node_opcua_data_model_1.NodeClass.Object && node.nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
587
- return;
588
- }
589
- const typeDefinitionNode = node.typeDefinitionObj;
590
- if (!typeDefinitionNode) {
591
- return;
592
- }
593
- const interfaces = _extractInterfaces2(typeDefinitionNode, extraInfo);
594
- if (interfaces.length === 0) {
595
- doTrace &&
596
- false &&
597
- traceLog(extraInfo.pad(), chalk.yellow("No interface for ", node.browseName.toString(), node.nodeId.toString()));
598
- return;
599
- }
600
- doTrace && traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- interfaces are ", interfaces.length));
601
- const localFilter = optionalFilter.filterFor(node);
602
- for (const iface of interfaces) {
603
- const aggregates = iface.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
604
- doTrace &&
605
- traceLog(extraInfo.pad(), chalk.magentaBright(" interface ", iface.browseName.toString()), "\n" + (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad()), aggregates.map((r) => r.toString({ addressSpace })).join("\n" + (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad())));
606
- _clone_collection_new(nodeToClone, node, aggregates, false, localFilter, extraInfo, browseNameMap);
607
- }
608
- }
609
- function _clone_children_references(node, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
610
- // find all reference that derives from the Aggregates
611
- const aggregatesRef = node.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
612
- _clone_collection_new(node, newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
613
- }
614
- exports._clone_children_references = _clone_children_references;
615
- function _clone_non_hierarchical_references(nodeToClone, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
616
- // clone only some non hierarchical_references that we do want to clone
617
- // such as:
618
- // HasSubStateMachine
619
- // (may be other as well later ... to do )
620
- (0, node_opcua_assert_1.assert)(newParent instanceof base_node_impl_1.BaseNodeImpl);
621
- // find all reference that derives from the HasSubStateMachine
622
- const references = nodeToClone.findReferencesEx("HasSubStateMachine", node_opcua_data_model_1.BrowseDirection.Forward);
623
- _clone_collection_new(nodeToClone, newParent, references, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
624
- }
625
- exports._clone_non_hierarchical_references = _clone_non_hierarchical_references;
626
- /**
627
- * @method _clone
628
- * @private
629
- */
630
- function _clone(Constructor, options, optionalFilter, extraInfo) {
631
- (0, node_opcua_assert_1.assert)(typeof Constructor === "function");
632
- (0, node_opcua_assert_1.assert)(options !== null && typeof options === "object");
633
- (0, node_opcua_assert_1.assert)(!extraInfo || (extraInfo !== null && typeof extraInfo === "object" && typeof extraInfo.registerClonedObject === "function"));
634
- (0, node_opcua_assert_1.assert)(!this.subtypeOf, "We do not do cloning of Type yet");
635
- const namespace = options.namespace;
636
- const constructorOptions = Object.assign(Object.assign({}, options), { addressSpace: namespace.addressSpace, browseName: this.browseName, description: this.description, displayName: this.displayName, nodeClass: this.nodeClass });
637
- constructorOptions.references = options.references || [];
638
- if (this.nodeClass === node_opcua_data_model_1.NodeClass.Variable || this.nodeClass === node_opcua_data_model_1.NodeClass.Object) {
639
- const voThis = this;
640
- if (voThis.typeDefinition) {
641
- constructorOptions.references.push(new reference_impl_1.ReferenceImpl({
642
- isForward: true,
643
- nodeId: voThis.typeDefinition,
644
- referenceType: (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition")
645
- }));
646
- }
647
- }
648
- if (!constructorOptions.modellingRule) {
649
- if (this.modellingRule && options.copyAlsoModellingRules) {
650
- const modellingRuleNode = this.findReferencesAsObject("HasModellingRule", true)[0];
651
- (0, node_opcua_assert_1.assert)(modellingRuleNode);
652
- constructorOptions.references.push(new reference_impl_1.ReferenceImpl({
653
- isForward: true,
654
- nodeId: modellingRuleNode.nodeId,
655
- referenceType: (0, node_opcua_nodeid_1.resolveNodeId)("HasModellingRule")
656
- }));
657
- }
658
- }
659
- else {
660
- (0, namespace_private_1.UANamespace_process_modelling_rule)(constructorOptions.references, constructorOptions.modellingRule);
661
- }
662
- constructorOptions.nodeId = namespace.constructNodeId(constructorOptions);
663
- (0, node_opcua_assert_1.assert)(constructorOptions.nodeId instanceof node_opcua_nodeid_1.NodeId);
664
- const cloneObj = new Constructor(constructorOptions);
665
- this.addressSpace._register(cloneObj);
666
- if (!options.ignoreChildren) {
667
- // clone children and the rest ....
668
- options.copyAlsoModellingRules = options.copyAlsoModellingRules || false;
669
- const newFilter = optionalFilter.filterFor(cloneObj);
670
- const browseNameMap = new Set();
671
- _clone_children_references(this, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
672
- if (this.nodeClass === node_opcua_data_model_1.NodeClass.Object || this.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
673
- let typeDefinitionNode = this.typeDefinitionObj;
674
- while (typeDefinitionNode) {
675
- doTrace &&
676
- traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.blueBright("---------------------- Exploring ", typeDefinitionNode.browseName.toString()));
677
- _clone_children_references(typeDefinitionNode, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
678
- typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
679
- }
680
- }
681
- _clone_non_hierarchical_references(this, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
682
- }
683
- cloneObj.propagate_back_references();
684
- cloneObj.install_extra_properties();
685
- return cloneObj;
686
- }
687
- exports._clone = _clone;
688
- function _handle_HierarchicalReference(node, reference) {
689
- const _cache = BaseNode_getCache(node);
690
- if (!reference.isForward)
691
- return;
692
- if (_cache._childByNameMap) {
693
- const addressSpace = node.addressSpace;
694
- const referenceType = reference_impl_1.ReferenceImpl.resolveReferenceType(addressSpace, reference);
695
- if (referenceType) {
696
- const HierarchicalReferencesType = addressSpace.findReferenceType("HierarchicalReferences");
697
- if (referenceType.isSubtypeOf(HierarchicalReferencesType)) {
698
- (0, node_opcua_assert_1.assert)(reference.isForward);
699
- const targetNode = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
700
- _cache._childByNameMap[targetNode.browseName.name.toString()] = targetNode;
701
- }
702
- }
703
- }
704
- }
705
- exports._handle_HierarchicalReference = _handle_HierarchicalReference;
706
- function _remove_HierarchicalReference(node, reference) {
707
- const _cache = BaseNode_getCache(node);
708
- if (_cache._childByNameMap) {
709
- const addressSpace = node.addressSpace;
710
- const referenceType = reference_impl_1.ReferenceImpl.resolveReferenceType(addressSpace, reference);
711
- if (referenceType) {
712
- const HierarchicalReferencesType = addressSpace.findReferenceType("HierarchicalReferences");
713
- if (referenceType.isSubtypeOf(HierarchicalReferencesType)) {
714
- (0, node_opcua_assert_1.assert)(reference.isForward);
715
- const targetNode = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
716
- // Xx dotrace && tracelog(" adding object to map");
717
- delete _cache._childByNameMap[targetNode.browseName.name.toString()];
718
- }
719
- }
720
- }
721
- }
722
- function _makeReferenceDescription(addressSpace, reference, resultMask) {
723
- const isForward = reference.isForward;
724
- const referenceTypeId = reference_impl_1.ReferenceImpl.resolveReferenceType(addressSpace, reference).nodeId;
725
- (0, node_opcua_assert_1.assert)(referenceTypeId instanceof node_opcua_nodeid_1.NodeId);
726
- const obj = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
727
- let data = {};
728
- if (!obj) {
729
- // cannot find reference node
730
- data = {
731
- isForward,
732
- nodeId: reference.nodeId,
733
- referenceTypeId: resultMask & node_opcua_data_model_1.ResultMask.ReferenceType ? referenceTypeId : null,
734
- typeDefinition: null
735
- };
736
- }
737
- else {
738
- (0, node_opcua_assert_1.assert)(reference.nodeId, " obj.nodeId");
739
- data = {
740
- browseName: resultMask & node_opcua_data_model_1.ResultMask.BrowseName ? (0, node_opcua_data_model_1.coerceQualifiedName)(obj.browseName) : null,
741
- displayName: resultMask & node_opcua_data_model_1.ResultMask.DisplayName ? (0, node_opcua_data_model_1.coerceLocalizedText)(obj.displayName[0]) : null,
742
- isForward: resultMask & node_opcua_data_model_1.ResultMask.IsForward ? isForward : false,
743
- nodeClass: resultMask & node_opcua_data_model_1.ResultMask.NodeClass ? obj.nodeClass : node_opcua_data_model_1.NodeClass.Unspecified,
744
- nodeId: obj.nodeId,
745
- referenceTypeId: resultMask & node_opcua_data_model_1.ResultMask.ReferenceType ? referenceTypeId : null,
746
- typeDefinition: resultMask & node_opcua_data_model_1.ResultMask.TypeDefinition ? obj.typeDefinition : null
747
- };
748
- }
749
- if (data.typeDefinition === null) {
750
- data.typeDefinition = new node_opcua_nodeid_1.NodeId();
751
- }
752
- const referenceDescription = new node_opcua_types_1.ReferenceDescription(data);
753
- return referenceDescription;
754
- }
755
- function _constructReferenceDescription(addressSpace, references, resultMask) {
756
- (0, node_opcua_assert_1.assert)(Array.isArray(references));
757
- return references.map((reference) => _makeReferenceDescription(addressSpace, reference, resultMask));
758
- }
759
- exports._constructReferenceDescription = _constructReferenceDescription;
760
- function BaseNode_remove_backward_reference(reference) {
761
- const _private = BaseNode_getPrivate(this);
762
- _remove_HierarchicalReference(this, reference);
763
- const h = reference.hash;
764
- if (_private._back_referenceIdx && _private._back_referenceIdx[h]) {
765
- // note : h may not exist in _back_referenceIdx since we are not indexing
766
- // _back_referenceIdx to UAObjectType and UAVariableType for performance reasons
767
- _private._back_referenceIdx[h].dispose();
768
- delete _private._back_referenceIdx[h];
769
- }
770
- reference.dispose();
771
- }
772
- exports.BaseNode_remove_backward_reference = BaseNode_remove_backward_reference;
773
- function BaseNode_add_backward_reference(reference) {
774
- const _private = BaseNode_getPrivate(this);
775
- const h = reference.hash;
776
- (0, node_opcua_assert_1.assert)(typeof h === "string");
777
- // istanbul ignore next
778
- if (_private._referenceIdx[h]) {
779
- // the reference exists already in the forward references
780
- // this append for instance when the XML NotSetFile has redundant <UAReference>
781
- // in this case there is nothing to do
782
- return;
783
- }
784
- // istanbul ignore next
785
- if (_private._back_referenceIdx[h]) {
786
- const opts = { addressSpace: this.addressSpace };
787
- warningLog(" Warning !", this.browseName.toString());
788
- warningLog(" ", reference.toString(opts));
789
- warningLog(" already found in ===>");
790
- warningLog(Object.values(_private._back_referenceIdx).map((c) => c.toString(opts)).join("\n"));
791
- // tslint:disable-next-line:no-console
792
- warningLog("===>");
793
- throw new Error("reference exists already in _back_references");
794
- }
795
- if (!(0, base_node_impl_1.getReferenceType)(reference)) {
796
- const stop_here = 1;
797
- }
798
- // assert(reference._referenceType instanceof ReferenceType);
799
- _private._back_referenceIdx[h] = reference;
800
- _handle_HierarchicalReference(this, reference);
801
- this._clear_caches();
802
- }
803
- exports.BaseNode_add_backward_reference = BaseNode_add_backward_reference;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseNode_add_backward_reference = exports.BaseNode_remove_backward_reference = exports._constructReferenceDescription = exports._handle_HierarchicalReference = exports._clone = exports._clone_non_hierarchical_references = exports._clone_hierarchical_references = exports.VariableOrVariableType_toString = exports.valueRankToString = exports.UAObjectType_toString = exports.UAObject_toString = exports.UAVariable_toString = exports.UAVariableType_toString = exports.BaseNode_References_toString = exports.BaseNode_toString = exports.ToStringBuilder = exports.BaseNode_clearCache = exports.BaseNode_getCache = exports.BaseNode_getPrivate = exports.BaseNode_removePrivate = exports.BaseNode_initPrivate = void 0;
4
+ /**
5
+ * @module node-opcua-address-space.Private
6
+ */
7
+ // tslint:disable:no-bitwise
8
+ const chalk = require("chalk");
9
+ const node_opcua_assert_1 = require("node-opcua-assert");
10
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
11
+ const node_opcua_debug_1 = require("node-opcua-debug");
12
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
13
+ const node_opcua_types_1 = require("node-opcua-types");
14
+ const node_opcua_constants_1 = require("node-opcua-constants");
15
+ const namespace_private_1 = require("./namespace_private");
16
+ const reference_impl_1 = require("./reference_impl");
17
+ const base_node_impl_1 = require("./base_node_impl");
18
+ const tool_isSubtypeOf_1 = require("./tool_isSubtypeOf");
19
+ // eslint-disable-next-line prefer-const
20
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
21
+ const doTrace = (0, node_opcua_debug_1.checkDebugFlag)("INSTANTIATE");
22
+ const traceLog = errorLog;
23
+ const g_weakMap = new WeakMap();
24
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
25
+ function BaseNode_initPrivate(self) {
26
+ const _private = {
27
+ __address_space: null,
28
+ _referenceIdx: {},
29
+ _back_referenceIdx: {},
30
+ _browseFilter: undefined,
31
+ _cache: {},
32
+ _description: undefined,
33
+ _displayName: [],
34
+ _parent: undefined,
35
+ _subtype_idx: {},
36
+ _subtype_idxVersion: 0
37
+ };
38
+ g_weakMap.set(self, _private);
39
+ return _private;
40
+ }
41
+ exports.BaseNode_initPrivate = BaseNode_initPrivate;
42
+ function BaseNode_removePrivate(self) {
43
+ // there is no need to delete object from weak map
44
+ // the GC will take care of this in due course
45
+ // g_weakMap.delete(self);
46
+ const _private = BaseNode_getPrivate(self);
47
+ _private._cache = {};
48
+ _private.__address_space = null;
49
+ _private._back_referenceIdx = {};
50
+ _private._referenceIdx = {};
51
+ _private._description = undefined;
52
+ _private._displayName = [];
53
+ }
54
+ exports.BaseNode_removePrivate = BaseNode_removePrivate;
55
+ function BaseNode_getPrivate(self) {
56
+ return g_weakMap.get(self);
57
+ }
58
+ exports.BaseNode_getPrivate = BaseNode_getPrivate;
59
+ function BaseNode_getCache(node) {
60
+ return BaseNode_getPrivate(node)._cache;
61
+ }
62
+ exports.BaseNode_getCache = BaseNode_getCache;
63
+ function BaseNode_clearCache(node) {
64
+ const _private = BaseNode_getPrivate(node);
65
+ if (_private && _private._cache) {
66
+ _private._cache = {};
67
+ }
68
+ (0, tool_isSubtypeOf_1.wipeMemorizedStuff)(node);
69
+ }
70
+ exports.BaseNode_clearCache = BaseNode_clearCache;
71
+ const hasTypeDefinition_ReferenceTypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition");
72
+ class ToStringBuilder {
73
+ constructor() {
74
+ this.level = 0;
75
+ this.cycleDetector = {};
76
+ this.padding = "";
77
+ this.str = [];
78
+ //
79
+ this.str = [];
80
+ }
81
+ add(line) {
82
+ this.str.push(line);
83
+ }
84
+ toString() {
85
+ return this.str.join("\n");
86
+ }
87
+ indent(str, padding) {
88
+ padding = padding || " ";
89
+ return str
90
+ .split("\n")
91
+ .map((r) => {
92
+ return padding + r;
93
+ })
94
+ .join("\n");
95
+ }
96
+ }
97
+ exports.ToStringBuilder = ToStringBuilder;
98
+ function set_as_processed(options, nodeId) {
99
+ options.cycleDetector[nodeId.toString()] = nodeId;
100
+ }
101
+ function is_already_processed(options, nodeId) {
102
+ return !!options.cycleDetector[nodeId.toString()];
103
+ }
104
+ function BaseNode_toString(options) {
105
+ options.level = options.level || 1;
106
+ set_as_processed(options, this.nodeId);
107
+ options.add("");
108
+ options.add(options.padding + chalk.yellow(" nodeId : ") + this.nodeId.toString());
109
+ options.add(options.padding + chalk.yellow(" nodeClass : ") + node_opcua_data_model_1.NodeClass[this.nodeClass] + " (" + this.nodeClass + ")");
110
+ options.add(options.padding + chalk.yellow(" browseName : ") + this.browseName.toString());
111
+ options.add(options.padding +
112
+ chalk.yellow(" displayName : ") +
113
+ this.displayName.map((f) => f.locale + " " + f.text).join(" | "));
114
+ options.add(options.padding + chalk.yellow(" description : ") + (this.description ? this.description.toString() : ""));
115
+ }
116
+ exports.BaseNode_toString = BaseNode_toString;
117
+ function BaseNode_References_toString(options) {
118
+ const _private = BaseNode_getPrivate(this);
119
+ const displayOptions = {
120
+ addressSpace: this.addressSpace
121
+ };
122
+ const addressSpace = this.addressSpace;
123
+ options.add(options.padding +
124
+ chalk.yellow(" references : ") +
125
+ " length =" +
126
+ Object.keys(_private._referenceIdx).length);
127
+ function dump_reference(follow, reference) {
128
+ if (!reference) {
129
+ return;
130
+ }
131
+ const o = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
132
+ if (!o) {
133
+ warningLog("cannot find referece", reference.toString());
134
+ return;
135
+ }
136
+ const name = o.browseName.toString();
137
+ const modellingRule = o.modellingRule || " ";
138
+ const extra = modellingRule[0] +
139
+ (() => {
140
+ switch (o.nodeClass) {
141
+ case node_opcua_data_model_1.NodeClass.Object:
142
+ return "[O] ";
143
+ case node_opcua_data_model_1.NodeClass.Variable:
144
+ return "[V] " + o.dataType.toString(displayOptions).padEnd(10);
145
+ case node_opcua_data_model_1.NodeClass.Method:
146
+ return "[M] ";
147
+ case node_opcua_data_model_1.NodeClass.DataType:
148
+ return "[DT]";
149
+ case node_opcua_data_model_1.NodeClass.ReferenceType:
150
+ return "[RT]";
151
+ case node_opcua_data_model_1.NodeClass.ObjectType:
152
+ return "[OT]";
153
+ case node_opcua_data_model_1.NodeClass.VariableType:
154
+ return "[VT]";
155
+ case node_opcua_data_model_1.NodeClass.View:
156
+ return "[V] ";
157
+ }
158
+ return "";
159
+ })();
160
+ options.add(options.padding +
161
+ chalk.yellow(" +-> ") +
162
+ reference.toString(displayOptions) +
163
+ " " +
164
+ chalk.cyan(name.padEnd(25, " ")) +
165
+ " " +
166
+ chalk.magentaBright(extra));
167
+ // ignore HasTypeDefinition as it has been already handled
168
+ if ((0, node_opcua_nodeid_1.sameNodeId)(reference.referenceType, hasTypeDefinition_ReferenceTypeNodeId) && reference.nodeId.namespace === 0) {
169
+ return;
170
+ }
171
+ if (o) {
172
+ if (!is_already_processed(options, o.nodeId)) {
173
+ set_as_processed(options, o.nodeId);
174
+ if (options.level > 1 && follow) {
175
+ const rr = o.toString({
176
+ cycleDetector: options.cycleDetector,
177
+ level: options.level - 1,
178
+ padding: options.padding + " "
179
+ });
180
+ options.add(rr);
181
+ }
182
+ }
183
+ }
184
+ }
185
+ // direct reference
186
+ Object.values(_private._referenceIdx).forEach(dump_reference.bind(null, true));
187
+ const br = Object.values(_private._back_referenceIdx).map((x) => x);
188
+ options.add(options.padding +
189
+ chalk.yellow(" back_references : ") +
190
+ chalk.cyan(" length =") +
191
+ br.length +
192
+ chalk.grey(" ( references held by other nodes involving this node)"));
193
+ // backward reference
194
+ br.forEach(dump_reference.bind(null, false));
195
+ }
196
+ exports.BaseNode_References_toString = BaseNode_References_toString;
197
+ function _UAType_toString(options) {
198
+ if (this.subtypeOfObj) {
199
+ options.add(options.padding +
200
+ chalk.yellow(" subtypeOf : ") +
201
+ this.subtypeOfObj.browseName.toString() +
202
+ " (" +
203
+ this.subtypeOfObj.nodeId.toString() +
204
+ ")");
205
+ }
206
+ }
207
+ function _UAInstance_toString(options) {
208
+ if (this.typeDefinitionObj) {
209
+ options.add(options.padding +
210
+ chalk.yellow(" typeDefinition : ") +
211
+ this.typeDefinitionObj.browseName.toString() +
212
+ " (" +
213
+ this.typeDefinitionObj.nodeId.toString() +
214
+ ")");
215
+ }
216
+ }
217
+ function UAVariableType_toString(options) {
218
+ BaseNode_toString.call(this, options);
219
+ _UAType_toString.call(this, options);
220
+ VariableOrVariableType_toString.call(this, options);
221
+ BaseNode_References_toString.call(this, options);
222
+ }
223
+ exports.UAVariableType_toString = UAVariableType_toString;
224
+ function UAVariable_toString(options) {
225
+ BaseNode_toString.call(this, options);
226
+ _UAInstance_toString.call(this, options);
227
+ VariableOrVariableType_toString.call(this, options);
228
+ AccessLevelFlags_toString.call(this, options);
229
+ BaseNode_References_toString.call(this, options);
230
+ }
231
+ exports.UAVariable_toString = UAVariable_toString;
232
+ function UAObject_toString(options) {
233
+ BaseNode_toString.call(this, options);
234
+ _UAInstance_toString.call(this, options);
235
+ BaseNode_References_toString.call(this, options);
236
+ }
237
+ exports.UAObject_toString = UAObject_toString;
238
+ function UAObjectType_toString(options) {
239
+ BaseNode_toString.call(this, options);
240
+ _UAType_toString.call(this, options);
241
+ BaseNode_References_toString.call(this, options);
242
+ }
243
+ exports.UAObjectType_toString = UAObjectType_toString;
244
+ function valueRankToString(valueRank) {
245
+ switch (valueRank) {
246
+ case 1:
247
+ return "OneDimension (1)";
248
+ case 0:
249
+ return "OneOrMoreDimensions (0)"; // The value is an array with one or more dimensions
250
+ case -1:
251
+ return "Scalar (-1)";
252
+ case -2:
253
+ return "Any (-2)"; // The value can be a scalar or an array with any number of dimensions
254
+ case -3:
255
+ return "ScalarOrOneDimension (2)"; // The value can be a scalar or a one dimensional array.
256
+ default:
257
+ if (valueRank > 0) {
258
+ return "" + valueRank + "-Dimensions";
259
+ }
260
+ else {
261
+ return "Invalid (" + valueRank + ")";
262
+ }
263
+ }
264
+ }
265
+ exports.valueRankToString = valueRankToString;
266
+ function accessLevelFlagToString(flag) {
267
+ const str = [];
268
+ if (flag & node_opcua_data_model_1.AccessLevelFlag.CurrentRead) {
269
+ str.push("CurrentRead");
270
+ }
271
+ if (flag & node_opcua_data_model_1.AccessLevelFlag.CurrentWrite) {
272
+ str.push("CurrentWrite");
273
+ }
274
+ if (flag & node_opcua_data_model_1.AccessLevelFlag.HistoryRead) {
275
+ str.push("HistoryRead");
276
+ }
277
+ if (flag & node_opcua_data_model_1.AccessLevelFlag.HistoryWrite) {
278
+ str.push("HistoryWrite");
279
+ }
280
+ if (flag & node_opcua_data_model_1.AccessLevelFlag.SemanticChange) {
281
+ str.push("SemanticChange");
282
+ }
283
+ if (flag & node_opcua_data_model_1.AccessLevelFlag.StatusWrite) {
284
+ str.push("StatusWrite");
285
+ }
286
+ if (flag & node_opcua_data_model_1.AccessLevelFlag.TimestampWrite) {
287
+ str.push("TimestampWrite");
288
+ }
289
+ return str.join(" | ");
290
+ }
291
+ function AccessLevelFlags_toString(options) {
292
+ (0, node_opcua_assert_1.assert)(options);
293
+ options.add(options.padding + chalk.yellow(" accessLevel : ") + " " + accessLevelFlagToString(this.accessLevel));
294
+ if (this.userAccessLevel !== undefined) {
295
+ options.add(options.padding + chalk.yellow(" userAccessLevel : ") + " " + accessLevelFlagToString(this.userAccessLevel));
296
+ }
297
+ }
298
+ function VariableOrVariableType_toString(options) {
299
+ (0, node_opcua_assert_1.assert)(options);
300
+ if (this.dataType) {
301
+ const addressSpace = this.addressSpace;
302
+ const d = addressSpace.findNode(this.dataType);
303
+ const n = d ? "(" + d.browseName.toString() + ")" : " (???)";
304
+ options.add(options.padding + chalk.yellow(" dataType : ") + this.dataType + " " + n);
305
+ }
306
+ if (this.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
307
+ const _dataValue = this.$dataValue;
308
+ if (_dataValue) {
309
+ options.add(options.padding +
310
+ chalk.yellow(" value : ") +
311
+ "\n" +
312
+ options.indent(_dataValue.toString(), options.padding + " | "));
313
+ }
314
+ }
315
+ if (Object.prototype.hasOwnProperty.call(this, "valueRank")) {
316
+ if (this.valueRank !== undefined) {
317
+ options.add(options.padding + chalk.yellow(" valueRank : ") + " " + valueRankToString(this.valueRank));
318
+ }
319
+ else {
320
+ options.add(options.padding + chalk.yellow(" valueRank : ") + " undefined");
321
+ }
322
+ }
323
+ if (this.minimumSamplingInterval !== undefined) {
324
+ options.add(options.padding +
325
+ chalk.yellow(" minimumSamplingInterval : ") +
326
+ " " +
327
+ this.minimumSamplingInterval.toString() +
328
+ " ms");
329
+ }
330
+ if (this.arrayDimensions) {
331
+ options.add(options.padding +
332
+ chalk.yellow(" arrayDimension : ") +
333
+ " [" +
334
+ this.arrayDimensions.join(",").toString() +
335
+ " ]");
336
+ }
337
+ }
338
+ exports.VariableOrVariableType_toString = VariableOrVariableType_toString;
339
+ const defaultExtraInfo = {
340
+ level: 0,
341
+ pad() {
342
+ return "";
343
+ },
344
+ registerClonedObject(node, node1) {
345
+ /** */
346
+ }
347
+ };
348
+ /**
349
+ *
350
+ *
351
+ * MyDeriveType ------------------- -> MyBaseType --------------> TopologyElementType
352
+ * | | |
353
+ * +- ParamaterSet +-> ParameterSet +-> ParamaterSet
354
+ * | |
355
+ * +- Foo1 |
356
+ * +- Bar
357
+ *
358
+ * Instance
359
+ *
360
+ * @param newParent
361
+ * @param node
362
+ * @param copyAlsoModellingRules
363
+ * @param optionalFilter
364
+ * @param extraInfo
365
+ * @param browseNameMap
366
+ * @returns
367
+ */
368
+ function _clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
369
+ /**
370
+ * the type definition node of the node to clone
371
+ */
372
+ const nodeToCloneTypeDefinition = nodeToClone.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || nodeToClone.nodeClass === node_opcua_data_model_1.NodeClass.VariableType
373
+ ? nodeToClone.subtypeOfObj
374
+ : null;
375
+ if (!nodeToCloneTypeDefinition)
376
+ return;
377
+ doTrace &&
378
+ traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- now cloning children on template ", node.browseName.toString(), node.nodeId.toString(), nodeToCloneTypeDefinition.browseName.toString()));
379
+ const namespace = newParent.namespace;
380
+ /**
381
+ * the child node of the new parent that match the node to clone or enrich
382
+ */
383
+ const newParentChild = newParent.getChildByName(node.browseName);
384
+ if (!newParentChild) {
385
+ return;
386
+ }
387
+ // we have found a matching child on the new parent.
388
+ // the mission is to enrich this child node with components and properties that
389
+ // exist also in the template
390
+ let typeDefinitionNode = nodeToCloneTypeDefinition;
391
+ while (typeDefinitionNode) {
392
+ doTrace &&
393
+ traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- now cloning children on ", newParentChild.browseName.toString(), newParentChild.nodeId.toString(), " (child of ", node.browseName.toString(), node.nodeId.toString(), ") from ", typeDefinitionNode.browseName.toString()));
394
+ const typeDefinitionChild = typeDefinitionNode.getChildByName(node.browseName);
395
+ if (typeDefinitionChild) {
396
+ const references = typeDefinitionChild.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
397
+ for (const ref of references) {
398
+ const grandChild = ref.node;
399
+ if (grandChild.modellingRule === "MandatoryPlaceholder" || grandChild.modellingRule === "OptionalPlaceholder")
400
+ continue;
401
+ // if not already node present in new Parent => just ignore
402
+ const hasAlready = newParentChild.getChildByName(grandChild.browseName) !== null;
403
+ if (!hasAlready) {
404
+ if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
405
+ doTrace &&
406
+ traceLog(extraInfo.pad(), "skipping optional ", node.browseName.toString(), "that doesn't appear in the filter");
407
+ continue; // skip this node
408
+ }
409
+ const options = {
410
+ namespace,
411
+ references: [
412
+ new reference_impl_1.ReferenceImpl({
413
+ referenceType: ref.referenceType,
414
+ isForward: false,
415
+ nodeId: newParentChild.nodeId
416
+ })
417
+ ],
418
+ copyAlsoModellingRules
419
+ };
420
+ const alreadyCloned = extraInfo.getCloned(grandChild);
421
+ if (alreadyCloned) {
422
+ alreadyCloned.addReference({
423
+ referenceType: ref.referenceType,
424
+ isForward: false,
425
+ nodeId: newParentChild.nodeId
426
+ });
427
+ }
428
+ else {
429
+ const a = grandChild.clone(options, optionalFilter, extraInfo);
430
+ extraInfo.registerClonedObject(a, grandChild);
431
+ }
432
+ }
433
+ }
434
+ }
435
+ typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
436
+ }
437
+ }
438
+ /**
439
+ * clone properties and methods
440
+ * @private
441
+ */
442
+ function _clone_collection_new(nodeToClone, newParent, collectionRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
443
+ var _a;
444
+ const namespace = newParent.namespace;
445
+ extraInfo = extraInfo || defaultExtraInfo;
446
+ const addressSpace = newParent.addressSpace;
447
+ (0, node_opcua_assert_1.assert)(!optionalFilter || (typeof optionalFilter.shouldKeep === "function" && typeof optionalFilter.filterFor === "function"));
448
+ for (const reference of collectionRef) {
449
+ const node = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
450
+ // ensure node is of the correct type,
451
+ // it may happen that the xml nodeset2 file was malformed
452
+ // istanbul ignore next
453
+ if (typeof node.clone !== "function") {
454
+ // tslint:disable-next-line:no-console
455
+ warningLog(chalk.red("Warning : cannot clone node ") +
456
+ node.browseName.toString() +
457
+ " of class " +
458
+ node_opcua_data_model_1.NodeClass[node.nodeClass].toString() +
459
+ " while cloning " +
460
+ newParent.browseName.toString());
461
+ continue;
462
+ }
463
+ if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
464
+ doTrace &&
465
+ traceLog(extraInfo.pad(), "skipping optional ", node.browseName.toString(), "that doesn't appear in the filter");
466
+ continue; // skip this node
467
+ }
468
+ const key = node.browseName.toString();
469
+ if (browseNameMap === null || browseNameMap === void 0 ? void 0 : browseNameMap.has(key)) {
470
+ _clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
471
+ continue; // skipping node with same browseName
472
+ }
473
+ browseNameMap === null || browseNameMap === void 0 ? void 0 : browseNameMap.add(key);
474
+ // assert(reference.isForward);
475
+ // assert(reference.referenceType instanceof NodeId, "" + reference.referenceType.toString());
476
+ const options = {
477
+ namespace,
478
+ references: [new reference_impl_1.ReferenceImpl({ referenceType: reference.referenceType, isForward: false, nodeId: newParent.nodeId })],
479
+ copyAlsoModellingRules
480
+ };
481
+ doTrace &&
482
+ traceLog(extraInfo.pad(), "cloning => ", reference.referenceType.toString({ addressSpace }), "=>", node.browseName.toString(), chalk.magentaBright((_a = node.typeDefinitionObj) === null || _a === void 0 ? void 0 : _a.browseName.toString()));
483
+ extraInfo.level += 4;
484
+ const alreadyCloned = extraInfo.getCloned(node);
485
+ if (alreadyCloned) {
486
+ alreadyCloned.addReference({
487
+ referenceType: reference.referenceType,
488
+ isForward: false,
489
+ nodeId: newParent.nodeId
490
+ });
491
+ }
492
+ else {
493
+ const clone = node.clone(options, optionalFilter, extraInfo);
494
+ extraInfo.level -= 4;
495
+ doTrace && traceLog(extraInfo.pad(), "cloning => ", node.browseName.toString(), "nodeId", clone.nodeId.toString());
496
+ extraInfo.level++;
497
+ _clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
498
+ extraInfo.level--;
499
+ // also clone or instantiate interface members that may be required in the optionals
500
+ extraInfo.level++;
501
+ _cloneInterface(nodeToClone, newParent, node, optionalFilter, extraInfo, browseNameMap);
502
+ extraInfo.level--;
503
+ extraInfo.registerClonedObject(node, clone);
504
+ }
505
+ }
506
+ }
507
+ function _extractInterfaces2(typeDefinitionNode, extraInfo) {
508
+ if (!typeDefinitionNode ||
509
+ (typeDefinitionNode.nodeId.namespace === 0 &&
510
+ (typeDefinitionNode.nodeId.value === node_opcua_constants_1.ObjectTypeIds.BaseObjectType ||
511
+ typeDefinitionNode.nodeId.value === node_opcua_constants_1.VariableTypeIds.BaseVariableType))) {
512
+ return [];
513
+ }
514
+ const addressSpace = typeDefinitionNode.addressSpace;
515
+ const hasInterfaceReference = addressSpace.findReferenceType("HasInterface");
516
+ if (!hasInterfaceReference) {
517
+ // this version of the standard UA namespace doesn't support Interface yet
518
+ return [];
519
+ }
520
+ // example:
521
+ // FolderType
522
+ // FunctionalGroupType
523
+ // MachineryItemIdentificationType : IMachineryItemVendorNameplateType
524
+ // MachineIdentificationType : IMachineTagNameplateType, IMachineVendorNamePlateType
525
+ // MachineToolIdentificationType
526
+ //
527
+ //
528
+ // IMachineTagNameplateType -subtypeOf-> ITagNameplateType
529
+ // IMachineVendorNamePlateType -subtypeOf-> IMachineryItemVendorNamePlateType
530
+ // IMachineryItemVendorNamePlateType -subtypeOf-> IVendorNameplateType
531
+ const interfacesRef = typeDefinitionNode.findReferencesEx("HasInterface", node_opcua_data_model_1.BrowseDirection.Forward);
532
+ const interfaces = interfacesRef.map((r) => addressSpace.findNode(r.nodeId));
533
+ const baseInterfaces = [];
534
+ for (const iface of interfaces) {
535
+ doTrace &&
536
+ traceLog(extraInfo.pad(), typeDefinitionNode.browseName.toString(), " - has interface -> ", iface.browseName.toString());
537
+ baseInterfaces.push(iface);
538
+ if (iface.subtypeOfObj) {
539
+ extraInfo.level++;
540
+ baseInterfaces.push(..._extractInterfaces2(iface.subtypeOfObj, extraInfo));
541
+ extraInfo.level--;
542
+ }
543
+ }
544
+ interfaces.push(...baseInterfaces);
545
+ if (typeDefinitionNode.subtypeOfObj) {
546
+ doTrace &&
547
+ traceLog(extraInfo.pad(), typeDefinitionNode.browseName.toString(), " - subtypef -> ", typeDefinitionNode.subtypeOfObj.browseName.toString());
548
+ extraInfo.level++;
549
+ interfaces.push(..._extractInterfaces2(typeDefinitionNode.subtypeOfObj, extraInfo));
550
+ extraInfo.level--;
551
+ }
552
+ const dedupedInterfaces = [...new Set(interfaces)];
553
+ doTrace &&
554
+ dedupedInterfaces.length &&
555
+ traceLog(extraInfo.pad(), chalk.yellow("Interface for ", typeDefinitionNode.browseName.toString()), "=", dedupedInterfaces.map((x) => x.browseName.toString()).join(" "));
556
+ return dedupedInterfaces;
557
+ }
558
+ /*
559
+
560
+ // also find all related interfaces
561
+ if (false && typeDefinitionNode) {
562
+ dotrace && tracelog("typeDefinitionNode = ", typeDefinitionNode.browseName.toString());
563
+ const interfaces = _extractInterfaces(typeDefinitionNode);
564
+ for (const interfaceNode of interfaces) {
565
+ dotrace && tracelog(" adding member of interface ", interfaceNode.browseName.toString());
566
+ const fromInterface = interfaceNode.findReferencesEx("Aggregates", BrowseDirection.Forward);
567
+ dotrace && tracelog(
568
+ " B ",
569
+ fromInterface.map((r) => r.toString({ addressSpace }) + " " + r.node!.browseName.toString()).join("\n")
570
+ );
571
+ add(fromInterface);
572
+ }
573
+ }
574
+ */
575
+ function _crap_extractInterfaces(typeDefinitionNode, extraInfo) {
576
+ if (typeDefinitionNode.nodeId.namespace === 0 &&
577
+ (typeDefinitionNode.nodeId.value === node_opcua_constants_1.ObjectTypeIds.BaseObjectType ||
578
+ typeDefinitionNode.nodeId.value === node_opcua_constants_1.VariableTypeIds.BaseVariableType)) {
579
+ return [];
580
+ }
581
+ const addressSpace = typeDefinitionNode.addressSpace;
582
+ // example:
583
+ // FolderType
584
+ // (di):FunctionalGroupType
585
+ // MachineryItemIdentificationType : IMachineryItemVendorNameplateType
586
+ // MachineIdentificationType : IMachineTagNameplateType, IMachineVendorNamePlateType
587
+ // MachineToolIdentificationType
588
+ //
589
+ //
590
+ // IMachineTagNameplateType -subtypeOf-> ITagNameplateType
591
+ // IMachineVendorNamePlateType -subtypeOf-> IMachineryItemVendorNamePlateType
592
+ // IMachineryItemVendorNamePlateType -subtypeOf-> IVendorNameplateType
593
+ const interfacesRef = typeDefinitionNode.findReferencesEx("HasInterface", node_opcua_data_model_1.BrowseDirection.Forward);
594
+ const interfaces = interfacesRef.map((r) => r.node);
595
+ for (const iface of interfaces) {
596
+ doTrace && traceLog(extraInfo.pad(), " interface ", iface.browseName.toString());
597
+ }
598
+ return interfaces;
599
+ }
600
+ function _cloneInterface(nodeToClone, newParent, node, optionalFilter, extraInfo, browseNameMap) {
601
+ doTrace &&
602
+ traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- now cloning interfaces of ", node.browseName.toString(), node.nodeId.toString()));
603
+ extraInfo = extraInfo || defaultExtraInfo;
604
+ const addressSpace = node.addressSpace;
605
+ if (node.nodeClass !== node_opcua_data_model_1.NodeClass.Object && node.nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
606
+ return;
607
+ }
608
+ const typeDefinitionNode = node.typeDefinitionObj;
609
+ if (!typeDefinitionNode) {
610
+ return;
611
+ }
612
+ const interfaces = _extractInterfaces2(typeDefinitionNode, extraInfo);
613
+ if (interfaces.length === 0) {
614
+ doTrace &&
615
+ false &&
616
+ traceLog(extraInfo.pad(), chalk.yellow("No interface for ", node.browseName.toString(), node.nodeId.toString()));
617
+ return;
618
+ }
619
+ doTrace && traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.green("-------------------- interfaces are ", interfaces.length));
620
+ const localFilter = optionalFilter.filterFor(node);
621
+ for (const iface of interfaces) {
622
+ const aggregates = iface.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
623
+ doTrace &&
624
+ traceLog(extraInfo.pad(), chalk.magentaBright(" interface ", iface.browseName.toString()), "\n" + (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad()), aggregates.map((r) => r.toString({ addressSpace })).join("\n" + (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad())));
625
+ _clone_collection_new(nodeToClone, node, aggregates, false, localFilter, extraInfo, browseNameMap);
626
+ }
627
+ }
628
+ function __clone_organizes_references(node, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
629
+ // find all references that derives from the Organizes
630
+ const organizedRef = node.findReferencesEx("Organizes", node_opcua_data_model_1.BrowseDirection.Forward);
631
+ _clone_collection_new(node, newParent, organizedRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
632
+ }
633
+ function __clone_children_references(node, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
634
+ // find all references that derives from the Aggregates
635
+ const aggregatesRef = node.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
636
+ _clone_collection_new(node, newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
637
+ }
638
+ function _clone_hierarchical_references(node, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
639
+ __clone_children_references(node, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
640
+ __clone_organizes_references(node, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
641
+ }
642
+ exports._clone_hierarchical_references = _clone_hierarchical_references;
643
+ function _clone_non_hierarchical_references(nodeToClone, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap) {
644
+ // clone only some non hierarchical_references that we do want to clone
645
+ // such as:
646
+ // HasSubStateMachine
647
+ // (may be other as well later ... to do )
648
+ (0, node_opcua_assert_1.assert)(newParent instanceof base_node_impl_1.BaseNodeImpl);
649
+ // find all reference that derives from the HasSubStateMachine
650
+ const references = nodeToClone.findReferencesEx("HasSubStateMachine", node_opcua_data_model_1.BrowseDirection.Forward);
651
+ _clone_collection_new(nodeToClone, newParent, references, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
652
+ }
653
+ exports._clone_non_hierarchical_references = _clone_non_hierarchical_references;
654
+ /**
655
+ * @method _clone
656
+ * @private
657
+ */
658
+ function _clone(Constructor, options, optionalFilter, extraInfo) {
659
+ (0, node_opcua_assert_1.assert)(typeof Constructor === "function");
660
+ (0, node_opcua_assert_1.assert)(options !== null && typeof options === "object");
661
+ (0, node_opcua_assert_1.assert)(!extraInfo || (extraInfo !== null && typeof extraInfo === "object" && typeof extraInfo.registerClonedObject === "function"));
662
+ (0, node_opcua_assert_1.assert)(!this.subtypeOf, "We do not do cloning of Type yet");
663
+ (0, node_opcua_assert_1.assert)(!extraInfo.getCloned(this), "object has already been cloned");
664
+ const namespace = options.namespace;
665
+ const constructorOptions = Object.assign(Object.assign({}, options), { addressSpace: namespace.addressSpace, browseName: this.browseName, description: this.description, displayName: this.displayName, nodeClass: this.nodeClass });
666
+ constructorOptions.references = options.references || [];
667
+ if (this.nodeClass === node_opcua_data_model_1.NodeClass.Variable || this.nodeClass === node_opcua_data_model_1.NodeClass.Object) {
668
+ const voThis = this;
669
+ if (voThis.typeDefinition) {
670
+ constructorOptions.references.push(new reference_impl_1.ReferenceImpl({
671
+ isForward: true,
672
+ nodeId: voThis.typeDefinition,
673
+ referenceType: (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition")
674
+ }));
675
+ }
676
+ }
677
+ if (!constructorOptions.modellingRule) {
678
+ if (this.modellingRule && options.copyAlsoModellingRules) {
679
+ const modellingRuleNode = this.findReferencesAsObject("HasModellingRule", true)[0];
680
+ (0, node_opcua_assert_1.assert)(modellingRuleNode);
681
+ constructorOptions.references.push(new reference_impl_1.ReferenceImpl({
682
+ isForward: true,
683
+ nodeId: modellingRuleNode.nodeId,
684
+ referenceType: (0, node_opcua_nodeid_1.resolveNodeId)("HasModellingRule")
685
+ }));
686
+ }
687
+ }
688
+ else {
689
+ (0, namespace_private_1.UANamespace_process_modelling_rule)(constructorOptions.references, constructorOptions.modellingRule);
690
+ }
691
+ constructorOptions.nodeId = namespace.constructNodeId(constructorOptions);
692
+ (0, node_opcua_assert_1.assert)(constructorOptions.nodeId instanceof node_opcua_nodeid_1.NodeId);
693
+ const cloneObj = new Constructor(constructorOptions);
694
+ this.addressSpace._register(cloneObj);
695
+ if (!options.ignoreChildren) {
696
+ // clone children and the rest ....
697
+ options.copyAlsoModellingRules = options.copyAlsoModellingRules || false;
698
+ const newFilter = optionalFilter.filterFor(cloneObj);
699
+ const browseNameMap = new Set();
700
+ _clone_hierarchical_references(this, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
701
+ if (this.nodeClass === node_opcua_data_model_1.NodeClass.Object || this.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
702
+ let typeDefinitionNode = this.typeDefinitionObj;
703
+ while (typeDefinitionNode) {
704
+ doTrace &&
705
+ traceLog(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.pad(), chalk.blueBright("---------------------- Exploring ", typeDefinitionNode.browseName.toString()));
706
+ _clone_hierarchical_references(typeDefinitionNode, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
707
+ typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
708
+ }
709
+ }
710
+ _clone_non_hierarchical_references(this, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
711
+ }
712
+ cloneObj.propagate_back_references();
713
+ cloneObj.install_extra_properties();
714
+ return cloneObj;
715
+ }
716
+ exports._clone = _clone;
717
+ function _handle_HierarchicalReference(node, reference) {
718
+ const _cache = BaseNode_getCache(node);
719
+ if (!reference.isForward)
720
+ return;
721
+ if (_cache._childByNameMap) {
722
+ const addressSpace = node.addressSpace;
723
+ const referenceType = reference_impl_1.ReferenceImpl.resolveReferenceType(addressSpace, reference);
724
+ if (referenceType) {
725
+ const HierarchicalReferencesType = addressSpace.findReferenceType("HierarchicalReferences");
726
+ if (referenceType.isSubtypeOf(HierarchicalReferencesType)) {
727
+ (0, node_opcua_assert_1.assert)(reference.isForward);
728
+ const targetNode = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
729
+ _cache._childByNameMap[targetNode.browseName.name.toString()] = targetNode;
730
+ }
731
+ }
732
+ }
733
+ }
734
+ exports._handle_HierarchicalReference = _handle_HierarchicalReference;
735
+ function _remove_HierarchicalReference(node, reference) {
736
+ const _cache = BaseNode_getCache(node);
737
+ if (_cache._childByNameMap) {
738
+ const addressSpace = node.addressSpace;
739
+ const referenceType = reference_impl_1.ReferenceImpl.resolveReferenceType(addressSpace, reference);
740
+ if (referenceType) {
741
+ const HierarchicalReferencesType = addressSpace.findReferenceType("HierarchicalReferences");
742
+ if (referenceType.isSubtypeOf(HierarchicalReferencesType)) {
743
+ (0, node_opcua_assert_1.assert)(reference.isForward);
744
+ const targetNode = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
745
+ // Xx dotrace && tracelog(" adding object to map");
746
+ delete _cache._childByNameMap[targetNode.browseName.name.toString()];
747
+ }
748
+ }
749
+ }
750
+ }
751
+ function _makeReferenceDescription(addressSpace, reference, resultMask) {
752
+ const isForward = reference.isForward;
753
+ const referenceTypeId = reference_impl_1.ReferenceImpl.resolveReferenceType(addressSpace, reference).nodeId;
754
+ (0, node_opcua_assert_1.assert)(referenceTypeId instanceof node_opcua_nodeid_1.NodeId);
755
+ const obj = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
756
+ let data = {};
757
+ if (!obj) {
758
+ // cannot find reference node
759
+ data = {
760
+ isForward,
761
+ nodeId: reference.nodeId,
762
+ referenceTypeId: resultMask & node_opcua_data_model_1.ResultMask.ReferenceType ? referenceTypeId : null,
763
+ typeDefinition: null
764
+ };
765
+ }
766
+ else {
767
+ (0, node_opcua_assert_1.assert)(reference.nodeId, " obj.nodeId");
768
+ data = {
769
+ browseName: resultMask & node_opcua_data_model_1.ResultMask.BrowseName ? (0, node_opcua_data_model_1.coerceQualifiedName)(obj.browseName) : null,
770
+ displayName: resultMask & node_opcua_data_model_1.ResultMask.DisplayName ? (0, node_opcua_data_model_1.coerceLocalizedText)(obj.displayName[0]) : null,
771
+ isForward: resultMask & node_opcua_data_model_1.ResultMask.IsForward ? isForward : false,
772
+ nodeClass: resultMask & node_opcua_data_model_1.ResultMask.NodeClass ? obj.nodeClass : node_opcua_data_model_1.NodeClass.Unspecified,
773
+ nodeId: obj.nodeId,
774
+ referenceTypeId: resultMask & node_opcua_data_model_1.ResultMask.ReferenceType ? referenceTypeId : null,
775
+ typeDefinition: resultMask & node_opcua_data_model_1.ResultMask.TypeDefinition ? obj.typeDefinition : null
776
+ };
777
+ }
778
+ if (data.typeDefinition === null) {
779
+ data.typeDefinition = new node_opcua_nodeid_1.NodeId();
780
+ }
781
+ const referenceDescription = new node_opcua_types_1.ReferenceDescription(data);
782
+ return referenceDescription;
783
+ }
784
+ function _constructReferenceDescription(addressSpace, references, resultMask) {
785
+ (0, node_opcua_assert_1.assert)(Array.isArray(references));
786
+ return references.map((reference) => _makeReferenceDescription(addressSpace, reference, resultMask));
787
+ }
788
+ exports._constructReferenceDescription = _constructReferenceDescription;
789
+ function BaseNode_remove_backward_reference(reference) {
790
+ const _private = BaseNode_getPrivate(this);
791
+ _remove_HierarchicalReference(this, reference);
792
+ const h = reference.hash;
793
+ if (_private._back_referenceIdx && _private._back_referenceIdx[h]) {
794
+ // note : h may not exist in _back_referenceIdx since we are not indexing
795
+ // _back_referenceIdx to UAObjectType and UAVariableType for performance reasons
796
+ _private._back_referenceIdx[h].dispose();
797
+ delete _private._back_referenceIdx[h];
798
+ }
799
+ reference.dispose();
800
+ }
801
+ exports.BaseNode_remove_backward_reference = BaseNode_remove_backward_reference;
802
+ function BaseNode_add_backward_reference(reference) {
803
+ const _private = BaseNode_getPrivate(this);
804
+ const h = reference.hash;
805
+ (0, node_opcua_assert_1.assert)(typeof h === "string");
806
+ // istanbul ignore next
807
+ if (_private._referenceIdx[h]) {
808
+ // the reference exists already in the forward references
809
+ // this append for instance when the XML NotSetFile has redundant <UAReference>
810
+ // in this case there is nothing to do
811
+ return;
812
+ }
813
+ // istanbul ignore next
814
+ if (_private._back_referenceIdx[h]) {
815
+ const opts = { addressSpace: this.addressSpace };
816
+ warningLog(" Warning !", this.browseName.toString());
817
+ warningLog(" ", reference.toString(opts));
818
+ warningLog(" already found in ===>");
819
+ warningLog(Object.values(_private._back_referenceIdx).map((c) => c.toString(opts)).join("\n"));
820
+ // tslint:disable-next-line:no-console
821
+ warningLog("===>");
822
+ throw new Error("reference exists already in _back_references");
823
+ }
824
+ if (!(0, base_node_impl_1.getReferenceType)(reference)) {
825
+ const stop_here = 1;
826
+ }
827
+ // assert(reference._referenceType instanceof ReferenceType);
828
+ _private._back_referenceIdx[h] = reference;
829
+ _handle_HierarchicalReference(this, reference);
830
+ this._clear_caches();
831
+ }
832
+ exports.BaseNode_add_backward_reference = BaseNode_add_backward_reference;
804
833
  //# sourceMappingURL=base_node_private.js.map