node-opcua-address-space 2.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (598) hide show
  1. package/.mocharc.yml +12 -0
  2. package/LICENSE +20 -0
  3. package/dist/source/address_space_ts.d.ts +122 -0
  4. package/dist/source/address_space_ts.js +18 -0
  5. package/dist/source/address_space_ts.js.map +1 -0
  6. package/dist/source/continuation_points/continuation_point_manager.d.ts +21 -0
  7. package/dist/source/continuation_points/continuation_point_manager.js +100 -0
  8. package/dist/source/continuation_points/continuation_point_manager.js.map +1 -0
  9. package/dist/source/helpers/adjust_browse_direction.d.ts +5 -0
  10. package/dist/source/helpers/adjust_browse_direction.js +12 -0
  11. package/dist/source/helpers/adjust_browse_direction.js.map +1 -0
  12. package/dist/source/helpers/argument_list.d.ts +30 -0
  13. package/dist/source/helpers/argument_list.js +237 -0
  14. package/dist/source/helpers/argument_list.js.map +1 -0
  15. package/dist/source/helpers/call_helpers.d.ts +6 -0
  16. package/dist/source/helpers/call_helpers.js +71 -0
  17. package/dist/source/helpers/call_helpers.js.map +1 -0
  18. package/dist/source/helpers/check_event_clause.d.ts +17 -0
  19. package/dist/source/helpers/check_event_clause.js +53 -0
  20. package/dist/source/helpers/check_event_clause.js.map +1 -0
  21. package/dist/source/helpers/coerce_enum_value.d.ts +6 -0
  22. package/dist/source/helpers/coerce_enum_value.js +34 -0
  23. package/dist/source/helpers/coerce_enum_value.js.map +1 -0
  24. package/dist/source/helpers/dump_tools.d.ts +14 -0
  25. package/dist/source/helpers/dump_tools.js +79 -0
  26. package/dist/source/helpers/dump_tools.js.map +1 -0
  27. package/dist/source/helpers/ensure_secure_access.d.ts +9 -0
  28. package/dist/source/helpers/ensure_secure_access.js +90 -0
  29. package/dist/source/helpers/ensure_secure_access.js.map +1 -0
  30. package/dist/source/helpers/make_optionals_map.d.ts +21 -0
  31. package/dist/source/helpers/make_optionals_map.js +30 -0
  32. package/dist/source/helpers/make_optionals_map.js.map +1 -0
  33. package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -0
  34. package/dist/source/helpers/resolve_opaque_on_address_space.js +37 -0
  35. package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -0
  36. package/dist/source/index.d.ts +39 -0
  37. package/dist/source/index.js +62 -0
  38. package/dist/source/index.js.map +1 -0
  39. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +12 -0
  40. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +3 -0
  41. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js.map +1 -0
  42. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.d.ts +1 -0
  43. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js +3 -0
  44. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js.map +1 -0
  45. package/dist/source/interfaces/data_access/ua_discrete_item.d.ts +4 -0
  46. package/dist/source/interfaces/data_access/ua_discrete_item.js +3 -0
  47. package/dist/source/interfaces/data_access/ua_discrete_item.js.map +1 -0
  48. package/dist/source/interfaces/data_access/ua_multistate_discrete.d.ts +25 -0
  49. package/dist/source/interfaces/data_access/ua_multistate_discrete.js +3 -0
  50. package/dist/source/interfaces/data_access/ua_multistate_discrete.js.map +1 -0
  51. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -0
  52. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +3 -0
  53. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js.map +1 -0
  54. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.d.ts +27 -0
  55. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js +3 -0
  56. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js.map +1 -0
  57. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -0
  58. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +3 -0
  59. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js.map +1 -0
  60. package/dist/source/interfaces/data_access/ua_two_state_discrete.d.ts +17 -0
  61. package/dist/source/interfaces/data_access/ua_two_state_discrete.js +3 -0
  62. package/dist/source/interfaces/data_access/ua_two_state_discrete.js.map +1 -0
  63. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -0
  64. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +3 -0
  65. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js.map +1 -0
  66. package/dist/source/interfaces/data_access/ua_y_array_item.d.ts +4 -0
  67. package/dist/source/interfaces/data_access/ua_y_array_item.js +3 -0
  68. package/dist/source/interfaces/data_access/ua_y_array_item.js.map +1 -0
  69. package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -0
  70. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +3 -0
  71. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js.map +1 -0
  72. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.d.ts +11 -0
  73. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js +3 -0
  74. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js.map +1 -0
  75. package/dist/source/interfaces/state_machine/finite_state_machine.d.ts +69 -0
  76. package/dist/source/interfaces/state_machine/finite_state_machine.js +3 -0
  77. package/dist/source/interfaces/state_machine/finite_state_machine.js.map +1 -0
  78. package/dist/source/interfaces/state_machine/program_finite_state_machine.d.ts +74 -0
  79. package/dist/source/interfaces/state_machine/program_finite_state_machine.js +3 -0
  80. package/dist/source/interfaces/state_machine/program_finite_state_machine.js.map +1 -0
  81. package/dist/source/interfaces/state_machine/state_machine.d.ts +342 -0
  82. package/dist/source/interfaces/state_machine/state_machine.js +3 -0
  83. package/dist/source/interfaces/state_machine/state_machine.js.map +1 -0
  84. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -0
  85. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +3 -0
  86. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js.map +1 -0
  87. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -0
  88. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +3 -0
  89. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js.map +1 -0
  90. package/dist/source/interfaces/state_machine/ua_finite_state_variable.d.ts +18 -0
  91. package/dist/source/interfaces/state_machine/ua_finite_state_variable.js +3 -0
  92. package/dist/source/interfaces/state_machine/ua_finite_state_variable.js.map +1 -0
  93. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -0
  94. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +3 -0
  95. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js.map +1 -0
  96. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +222 -0
  97. package/dist/source/interfaces/state_machine/ua_state_machine_type.js +3 -0
  98. package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -0
  99. package/dist/source/interfaces/state_machine/ua_state_variable.d.ts +29 -0
  100. package/dist/source/interfaces/state_machine/ua_state_variable.js +3 -0
  101. package/dist/source/interfaces/state_machine/ua_state_variable.js.map +1 -0
  102. package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -0
  103. package/dist/source/interfaces/state_machine/ua_transition_ex.js +3 -0
  104. package/dist/source/interfaces/state_machine/ua_transition_ex.js.map +1 -0
  105. package/dist/source/interfaces/state_machine/ua_two_state_variable.d.ts +26 -0
  106. package/dist/source/interfaces/state_machine/ua_two_state_variable.js +3 -0
  107. package/dist/source/interfaces/state_machine/ua_two_state_variable.js.map +1 -0
  108. package/dist/source/interfaces/subscription_diagnostics_variable.d.ts +41 -0
  109. package/dist/source/interfaces/subscription_diagnostics_variable.js +3 -0
  110. package/dist/source/interfaces/subscription_diagnostics_variable.js.map +1 -0
  111. package/dist/source/interfaces/ua_authorisation_service.d.ts +1 -0
  112. package/dist/source/interfaces/ua_authorisation_service.js +3 -0
  113. package/dist/source/interfaces/ua_authorisation_service.js.map +1 -0
  114. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -0
  115. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +3 -0
  116. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js.map +1 -0
  117. package/dist/source/loader/generateAddressSpaceRaw.d.ts +10 -0
  118. package/dist/source/loader/generateAddressSpaceRaw.js +59 -0
  119. package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -0
  120. package/dist/source/loader/load_nodeset2.d.ts +13 -0
  121. package/dist/source/loader/load_nodeset2.js +1392 -0
  122. package/dist/source/loader/load_nodeset2.js.map +1 -0
  123. package/dist/source/loader/namespace_post_step.d.ts +6 -0
  124. package/dist/source/loader/namespace_post_step.js +48 -0
  125. package/dist/source/loader/namespace_post_step.js.map +1 -0
  126. package/dist/source/loader/register_node_promoter.d.ts +3 -0
  127. package/dist/source/loader/register_node_promoter.js +10 -0
  128. package/dist/source/loader/register_node_promoter.js.map +1 -0
  129. package/dist/source/namespace.d.ts +6 -0
  130. package/dist/source/namespace.js +3 -0
  131. package/dist/source/namespace.js.map +1 -0
  132. package/dist/source/namespace_alarm_and_condition.d.ts +24 -0
  133. package/dist/source/namespace_alarm_and_condition.js +3 -0
  134. package/dist/source/namespace_alarm_and_condition.js.map +1 -0
  135. package/dist/source/namespace_data_access.d.ts +42 -0
  136. package/dist/source/namespace_data_access.js +3 -0
  137. package/dist/source/namespace_data_access.js.map +1 -0
  138. package/dist/source/namespace_machine_state.d.ts +7 -0
  139. package/dist/source/namespace_machine_state.js +3 -0
  140. package/dist/source/namespace_machine_state.js.map +1 -0
  141. package/dist/source/pseudo_session.d.ts +55 -0
  142. package/dist/source/pseudo_session.js +205 -0
  143. package/dist/source/pseudo_session.js.map +1 -0
  144. package/dist/source/session_context.d.ts +111 -0
  145. package/dist/source/session_context.js +266 -0
  146. package/dist/source/session_context.js.map +1 -0
  147. package/dist/source/set_namespace_meta_data.d.ts +2 -0
  148. package/dist/source/set_namespace_meta_data.js +60 -0
  149. package/dist/source/set_namespace_meta_data.js.map +1 -0
  150. package/dist/source/ua_namespace_meta_data_type.d.ts +71 -0
  151. package/dist/source/ua_namespace_meta_data_type.js +3 -0
  152. package/dist/source/ua_namespace_meta_data_type.js.map +1 -0
  153. package/dist/source/ua_root_folder.d.ts +9 -0
  154. package/dist/source/ua_root_folder.js +3 -0
  155. package/dist/source/ua_root_folder.js.map +1 -0
  156. package/dist/source/ua_two_state_variable_ex.d.ts +23 -0
  157. package/dist/source/ua_two_state_variable_ex.js +3 -0
  158. package/dist/source/ua_two_state_variable_ex.js.map +1 -0
  159. package/dist/source/xml_writer.d.ts +9 -0
  160. package/dist/source/xml_writer.js +3 -0
  161. package/dist/source/xml_writer.js.map +1 -0
  162. package/dist/src/address_space.d.ts +393 -0
  163. package/dist/src/address_space.js +1375 -0
  164. package/dist/src/address_space.js.map +1 -0
  165. package/dist/src/address_space_change_event_tools.d.ts +6 -0
  166. package/dist/src/address_space_change_event_tools.js +150 -0
  167. package/dist/src/address_space_change_event_tools.js.map +1 -0
  168. package/dist/src/address_space_private.d.ts +44 -0
  169. package/dist/src/address_space_private.js +3 -0
  170. package/dist/src/address_space_private.js.map +1 -0
  171. package/dist/src/alarms_and_conditions/base_event_type.d.ts +26 -0
  172. package/dist/src/alarms_and_conditions/base_event_type.js +41 -0
  173. package/dist/src/alarms_and_conditions/base_event_type.js.map +1 -0
  174. package/dist/src/alarms_and_conditions/check_where_clause.d.ts +4 -0
  175. package/dist/src/alarms_and_conditions/check_where_clause.js +110 -0
  176. package/dist/src/alarms_and_conditions/check_where_clause.js.map +1 -0
  177. package/dist/src/alarms_and_conditions/condition.d.ts +5 -0
  178. package/dist/src/alarms_and_conditions/condition.js +81 -0
  179. package/dist/src/alarms_and_conditions/condition.js.map +1 -0
  180. package/dist/src/alarms_and_conditions/condition_info.d.ts +27 -0
  181. package/dist/src/alarms_and_conditions/condition_info.js +55 -0
  182. package/dist/src/alarms_and_conditions/condition_info.js.map +1 -0
  183. package/dist/src/alarms_and_conditions/condition_snapshot.d.ts +232 -0
  184. package/dist/src/alarms_and_conditions/condition_snapshot.js +667 -0
  185. package/dist/src/alarms_and_conditions/condition_snapshot.js.map +1 -0
  186. package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +21 -0
  187. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +47 -0
  188. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -0
  189. package/dist/src/alarms_and_conditions/extract_event_fields.d.ts +10 -0
  190. package/dist/src/alarms_and_conditions/extract_event_fields.js +90 -0
  191. package/dist/src/alarms_and_conditions/extract_event_fields.js.map +1 -0
  192. package/dist/src/alarms_and_conditions/index.d.ts +18 -0
  193. package/dist/src/alarms_and_conditions/index.js +31 -0
  194. package/dist/src/alarms_and_conditions/index.js.map +1 -0
  195. package/dist/src/alarms_and_conditions/shelving_state_machine.d.ts +22 -0
  196. package/dist/src/alarms_and_conditions/shelving_state_machine.js +241 -0
  197. package/dist/src/alarms_and_conditions/shelving_state_machine.js.map +1 -0
  198. package/dist/src/alarms_and_conditions/trip_alarm.d.ts +16 -0
  199. package/dist/src/alarms_and_conditions/trip_alarm.js +21 -0
  200. package/dist/src/alarms_and_conditions/trip_alarm.js.map +1 -0
  201. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.d.ts +54 -0
  202. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js +255 -0
  203. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js.map +1 -0
  204. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +62 -0
  205. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -0
  206. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -0
  207. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.d.ts +138 -0
  208. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js +460 -0
  209. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js.map +1 -0
  210. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +118 -0
  211. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +417 -0
  212. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -0
  213. package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +29 -0
  214. package/dist/src/alarms_and_conditions/ua_base_event_impl.js +39 -0
  215. package/dist/src/alarms_and_conditions/ua_base_event_impl.js.map +1 -0
  216. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.d.ts +35 -0
  217. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js +32 -0
  218. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js.map +1 -0
  219. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +21 -0
  220. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +26 -0
  221. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -0
  222. package/dist/src/alarms_and_conditions/ua_condition_base.d.ts +191 -0
  223. package/dist/src/alarms_and_conditions/ua_condition_base.js +1029 -0
  224. package/dist/src/alarms_and_conditions/ua_condition_base.js.map +1 -0
  225. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +182 -0
  226. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1021 -0
  227. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -0
  228. package/dist/src/alarms_and_conditions/ua_discrete_alarm.d.ts +11 -0
  229. package/dist/src/alarms_and_conditions/ua_discrete_alarm.js +58 -0
  230. package/dist/src/alarms_and_conditions/ua_discrete_alarm.js.map +1 -0
  231. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +17 -0
  232. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +58 -0
  233. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -0
  234. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.d.ts +24 -0
  235. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js +59 -0
  236. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js.map +1 -0
  237. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +27 -0
  238. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +57 -0
  239. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js.map +1 -0
  240. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.d.ts +14 -0
  241. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js +17 -0
  242. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js.map +1 -0
  243. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +9 -0
  244. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +12 -0
  245. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js.map +1 -0
  246. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.d.ts +22 -0
  247. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js +87 -0
  248. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js.map +1 -0
  249. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +38 -0
  250. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +87 -0
  251. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -0
  252. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.d.ts +6 -0
  253. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js +11 -0
  254. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js.map +1 -0
  255. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +10 -0
  256. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +8 -0
  257. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js.map +1 -0
  258. package/dist/src/alarms_and_conditions/ua_limit_alarm.d.ts +76 -0
  259. package/dist/src/alarms_and_conditions/ua_limit_alarm.js +237 -0
  260. package/dist/src/alarms_and_conditions/ua_limit_alarm.js.map +1 -0
  261. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +98 -0
  262. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +233 -0
  263. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -0
  264. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.d.ts +27 -0
  265. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js +62 -0
  266. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js.map +1 -0
  267. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +28 -0
  268. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +51 -0
  269. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js.map +1 -0
  270. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.d.ts +49 -0
  271. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js +176 -0
  272. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js.map +1 -0
  273. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +25 -0
  274. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +163 -0
  275. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -0
  276. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.d.ts +47 -0
  277. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js +151 -0
  278. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js.map +1 -0
  279. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +39 -0
  280. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +136 -0
  281. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -0
  282. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.d.ts +16 -0
  283. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js +18 -0
  284. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js.map +1 -0
  285. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +16 -0
  286. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +18 -0
  287. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js.map +1 -0
  288. package/dist/src/apply_condition_refresh.d.ts +6 -0
  289. package/dist/src/apply_condition_refresh.js +28 -0
  290. package/dist/src/apply_condition_refresh.js.map +1 -0
  291. package/dist/src/base_node.d.ts +279 -0
  292. package/dist/src/base_node.js +1364 -0
  293. package/dist/src/base_node.js.map +1 -0
  294. package/dist/src/base_node_impl.d.ts +281 -0
  295. package/dist/src/base_node_impl.js +1394 -0
  296. package/dist/src/base_node_impl.js.map +1 -0
  297. package/dist/src/base_node_private.d.ts +61 -0
  298. package/dist/src/base_node_private.js +521 -0
  299. package/dist/src/base_node_private.js.map +1 -0
  300. package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -0
  301. package/dist/src/data_access/add_dataItem_stuff.js +62 -0
  302. package/dist/src/data_access/add_dataItem_stuff.js.map +1 -0
  303. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -0
  304. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +35 -0
  305. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js.map +1 -0
  306. package/dist/src/data_access/ua_analog_item.d.ts +13 -0
  307. package/dist/src/data_access/ua_analog_item.js +37 -0
  308. package/dist/src/data_access/ua_analog_item.js.map +1 -0
  309. package/dist/src/data_access/ua_data_item.d.ts +16 -0
  310. package/dist/src/data_access/ua_data_item.js +66 -0
  311. package/dist/src/data_access/ua_data_item.js.map +1 -0
  312. package/dist/src/data_access/ua_multistate_discrete.d.ts +23 -0
  313. package/dist/src/data_access/ua_multistate_discrete.js +131 -0
  314. package/dist/src/data_access/ua_multistate_discrete.js.map +1 -0
  315. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -0
  316. package/dist/src/data_access/ua_multistate_discrete_impl.js +131 -0
  317. package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -0
  318. package/dist/src/data_access/ua_multistate_value_discrete.d.ts +51 -0
  319. package/dist/src/data_access/ua_multistate_value_discrete.js +249 -0
  320. package/dist/src/data_access/ua_multistate_value_discrete.js.map +1 -0
  321. package/dist/src/data_access/ua_two_state_discrete.d.ts +25 -0
  322. package/dist/src/data_access/ua_two_state_discrete.js +154 -0
  323. package/dist/src/data_access/ua_two_state_discrete.js.map +1 -0
  324. package/dist/src/event_data.d.ts +29 -0
  325. package/dist/src/event_data.js +96 -0
  326. package/dist/src/event_data.js.map +1 -0
  327. package/dist/src/extension_object_array_node.d.ts +61 -0
  328. package/dist/src/extension_object_array_node.js +266 -0
  329. package/dist/src/extension_object_array_node.js.map +1 -0
  330. package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -0
  331. package/dist/src/historical_access/address_space_historical_data_node.js +662 -0
  332. package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -0
  333. package/dist/src/index_current.d.ts +42 -0
  334. package/dist/src/index_current.js +71 -0
  335. package/dist/src/index_current.js.map +1 -0
  336. package/dist/src/namespace.d.ts +475 -0
  337. package/dist/src/namespace.js +1775 -0
  338. package/dist/src/namespace.js.map +1 -0
  339. package/dist/src/namespace_impl.d.ts +463 -0
  340. package/dist/src/namespace_impl.js +1763 -0
  341. package/dist/src/namespace_impl.js.map +1 -0
  342. package/dist/src/namespace_private.d.ts +21 -0
  343. package/dist/src/namespace_private.js +29 -0
  344. package/dist/src/namespace_private.js.map +1 -0
  345. package/dist/src/nodeid_manager.d.ts +36 -0
  346. package/dist/src/nodeid_manager.js +196 -0
  347. package/dist/src/nodeid_manager.js.map +1 -0
  348. package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -0
  349. package/dist/src/nodeset_tools/adjust_namespace_array.js +14 -0
  350. package/dist/src/nodeset_tools/adjust_namespace_array.js.map +1 -0
  351. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +2 -0
  352. package/dist/src/nodeset_tools/construct_namespace_dependency.js +39 -0
  353. package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -0
  354. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +2 -0
  355. package/dist/src/nodeset_tools/nodeset_to_xml.js +1155 -0
  356. package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -0
  357. package/dist/src/nodeset_tools/typedictionary_to_xml.d.ts +2 -0
  358. package/dist/src/nodeset_tools/typedictionary_to_xml.js +147 -0
  359. package/dist/src/nodeset_tools/typedictionary_to_xml.js.map +1 -0
  360. package/dist/src/reference.d.ts +43 -0
  361. package/dist/src/reference.js +138 -0
  362. package/dist/src/reference.js.map +1 -0
  363. package/dist/src/reference_impl.d.ts +43 -0
  364. package/dist/src/reference_impl.js +138 -0
  365. package/dist/src/reference_impl.js.map +1 -0
  366. package/dist/src/role_permissions.d.ts +2 -0
  367. package/dist/src/role_permissions.js +11 -0
  368. package/dist/src/role_permissions.js.map +1 -0
  369. package/dist/src/session_context.d.ts +4 -0
  370. package/dist/src/session_context.js +9 -0
  371. package/dist/src/session_context.js.map +1 -0
  372. package/dist/src/state_machine/finite_state_machine.d.ts +67 -0
  373. package/dist/src/state_machine/finite_state_machine.js +354 -0
  374. package/dist/src/state_machine/finite_state_machine.js.map +1 -0
  375. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +34 -0
  376. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +244 -0
  377. package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -0
  378. package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -0
  379. package/dist/src/state_machine/ua_two_state_variable.js +332 -0
  380. package/dist/src/state_machine/ua_two_state_variable.js.map +1 -0
  381. package/dist/src/tool_isSupertypeOf.d.ts +17 -0
  382. package/dist/src/tool_isSupertypeOf.js +103 -0
  383. package/dist/src/tool_isSupertypeOf.js.map +1 -0
  384. package/dist/src/ua_condition_type.d.ts +8 -0
  385. package/dist/src/ua_condition_type.js +3 -0
  386. package/dist/src/ua_condition_type.js.map +1 -0
  387. package/dist/src/ua_data_type.d.ts +83 -0
  388. package/dist/src/ua_data_type.js +289 -0
  389. package/dist/src/ua_data_type.js.map +1 -0
  390. package/dist/src/ua_data_type_impl.d.ts +83 -0
  391. package/dist/src/ua_data_type_impl.js +291 -0
  392. package/dist/src/ua_data_type_impl.js.map +1 -0
  393. package/dist/src/ua_method.d.ts +42 -0
  394. package/dist/src/ua_method.js +204 -0
  395. package/dist/src/ua_method.js.map +1 -0
  396. package/dist/src/ua_method_impl.d.ts +40 -0
  397. package/dist/src/ua_method_impl.js +203 -0
  398. package/dist/src/ua_method_impl.js.map +1 -0
  399. package/dist/src/ua_object.d.ts +29 -0
  400. package/dist/src/ua_object.js +153 -0
  401. package/dist/src/ua_object.js.map +1 -0
  402. package/dist/src/ua_object_impl.d.ts +29 -0
  403. package/dist/src/ua_object_impl.js +156 -0
  404. package/dist/src/ua_object_impl.js.map +1 -0
  405. package/dist/src/ua_object_type.d.ts +49 -0
  406. package/dist/src/ua_object_type.js +124 -0
  407. package/dist/src/ua_object_type.js.map +1 -0
  408. package/dist/src/ua_object_type_impl.d.ts +48 -0
  409. package/dist/src/ua_object_type_impl.js +124 -0
  410. package/dist/src/ua_object_type_impl.js.map +1 -0
  411. package/dist/src/ua_reference_type.d.ts +42 -0
  412. package/dist/src/ua_reference_type.js +138 -0
  413. package/dist/src/ua_reference_type.js.map +1 -0
  414. package/dist/src/ua_reference_type_impl.d.ts +43 -0
  415. package/dist/src/ua_reference_type_impl.js +138 -0
  416. package/dist/src/ua_reference_type_impl.js.map +1 -0
  417. package/dist/src/ua_variable.d.ts +346 -0
  418. package/dist/src/ua_variable.js +1721 -0
  419. package/dist/src/ua_variable.js.map +1 -0
  420. package/dist/src/ua_variable_impl.d.ts +353 -0
  421. package/dist/src/ua_variable_impl.js +1719 -0
  422. package/dist/src/ua_variable_impl.js.map +1 -0
  423. package/dist/src/ua_variable_type.d.ts +54 -0
  424. package/dist/src/ua_variable_type.js +555 -0
  425. package/dist/src/ua_variable_type.js.map +1 -0
  426. package/dist/src/ua_variable_type_impl.d.ts +63 -0
  427. package/dist/src/ua_variable_type_impl.js +556 -0
  428. package/dist/src/ua_variable_type_impl.js.map +1 -0
  429. package/dist/src/ua_view.d.ts +16 -0
  430. package/dist/src/ua_view.js +42 -0
  431. package/dist/src/ua_view.js.map +1 -0
  432. package/dist/src/ua_view_impl.d.ts +15 -0
  433. package/dist/src/ua_view_impl.js +37 -0
  434. package/dist/src/ua_view_impl.js.map +1 -0
  435. package/distHelpers/add_event_generator_object.d.ts +3 -0
  436. package/distHelpers/add_event_generator_object.js +66 -0
  437. package/distHelpers/add_event_generator_object.js.map +1 -0
  438. package/distHelpers/alarms_and_conditions_demo.d.ts +10 -0
  439. package/distHelpers/alarms_and_conditions_demo.js +115 -0
  440. package/distHelpers/alarms_and_conditions_demo.js.map +1 -0
  441. package/distHelpers/assertHasMatchingReference.d.ts +19 -0
  442. package/distHelpers/assertHasMatchingReference.js +41 -0
  443. package/distHelpers/assertHasMatchingReference.js.map +1 -0
  444. package/distHelpers/boiler_system.d.ts +113 -0
  445. package/distHelpers/boiler_system.js +397 -0
  446. package/distHelpers/boiler_system.js.map +1 -0
  447. package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -0
  448. package/distHelpers/create_minimalist_address_space_nodeset.js +171 -0
  449. package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -0
  450. package/distHelpers/dump_statemachine.d.ts +6 -0
  451. package/distHelpers/dump_statemachine.js +116 -0
  452. package/distHelpers/dump_statemachine.js.map +1 -0
  453. package/distHelpers/get_address_space_fixture.d.ts +1 -0
  454. package/distHelpers/get_address_space_fixture.js +31 -0
  455. package/distHelpers/get_address_space_fixture.js.map +1 -0
  456. package/distHelpers/get_mini_address_space.d.ts +7 -0
  457. package/distHelpers/get_mini_address_space.js +37 -0
  458. package/distHelpers/get_mini_address_space.js.map +1 -0
  459. package/distHelpers/index.d.ts +11 -0
  460. package/distHelpers/index.js +24 -0
  461. package/distHelpers/index.js.map +1 -0
  462. package/distNodeJS/generate_address_space.d.ts +4 -0
  463. package/distNodeJS/generate_address_space.js +31 -0
  464. package/distNodeJS/generate_address_space.js.map +1 -0
  465. package/distNodeJS/index.d.ts +1 -0
  466. package/distNodeJS/index.js +14 -0
  467. package/distNodeJS/index.js.map +1 -0
  468. package/generate.js +1 -0
  469. package/nodeJS.d.ts +1 -0
  470. package/nodeJS.js +1 -0
  471. package/package.json +87 -0
  472. package/source/address_space_ts.ts +217 -0
  473. package/source/continuation_points/continuation_point_manager.ts +121 -0
  474. package/source/helpers/adjust_browse_direction.ts +15 -0
  475. package/source/helpers/argument_list.ts +286 -0
  476. package/source/helpers/call_helpers.ts +112 -0
  477. package/source/helpers/check_event_clause.ts +62 -0
  478. package/source/helpers/coerce_enum_value.ts +33 -0
  479. package/source/helpers/dump_tools.ts +92 -0
  480. package/source/helpers/ensure_secure_access.ts +88 -0
  481. package/source/helpers/make_optionals_map.ts +49 -0
  482. package/source/helpers/resolve_opaque_on_address_space.ts +23 -0
  483. package/source/index.ts +49 -0
  484. package/source/interfaces/alarms_and_conditions/condition_info_i.ts +13 -0
  485. package/source/interfaces/data_access/ua_multistate_discrete_ex.ts +26 -0
  486. package/source/interfaces/data_access/ua_multistate_value_discrete_ex.ts +34 -0
  487. package/source/interfaces/data_access/ua_two_state_discrete_ex.ts +14 -0
  488. package/source/interfaces/data_access/ua_y_array_item_ex.ts +10 -0
  489. package/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.ts +14 -0
  490. package/source/interfaces/state_machine/ua_finite_state_machine_type.ts +50 -0
  491. package/source/interfaces/state_machine/ua_program_state_machine_type.ts +13 -0
  492. package/source/interfaces/state_machine/ua_state_machine_type.ts +261 -0
  493. package/source/interfaces/state_machine/ua_transition_ex.ts +7 -0
  494. package/source/interfaces/ua_subscription_diagnostics_variable_ex.ts +8 -0
  495. package/source/loader/generateAddressSpaceRaw.ts +79 -0
  496. package/source/loader/load_nodeset2.ts +1600 -0
  497. package/source/loader/namespace_post_step.ts +36 -0
  498. package/source/loader/register_node_promoter.ts +8 -0
  499. package/source/namespace.ts +9 -0
  500. package/source/namespace_alarm_and_condition.ts +47 -0
  501. package/source/namespace_data_access.ts +60 -0
  502. package/source/namespace_machine_state.ts +13 -0
  503. package/source/pseudo_session.ts +288 -0
  504. package/source/session_context.ts +345 -0
  505. package/source/set_namespace_meta_data.ts +68 -0
  506. package/source/ua_root_folder.ts +10 -0
  507. package/source/ua_two_state_variable_ex.ts +35 -0
  508. package/source/xml_writer.ts +15 -0
  509. package/source_nodejs/generate_address_space.ts +36 -0
  510. package/source_nodejs/index.ts +1 -0
  511. package/src/address_space.ts +1575 -0
  512. package/src/address_space_change_event_tools.ts +177 -0
  513. package/src/address_space_private.ts +98 -0
  514. package/src/alarms_and_conditions/check_where_clause.ts +148 -0
  515. package/src/alarms_and_conditions/condition.ts +89 -0
  516. package/src/alarms_and_conditions/condition_info.ts +66 -0
  517. package/src/alarms_and_conditions/condition_snapshot.ts +766 -0
  518. package/src/alarms_and_conditions/deviation_alarm_helper.ts +66 -0
  519. package/src/alarms_and_conditions/extract_event_fields.ts +104 -0
  520. package/src/alarms_and_conditions/index.ts +18 -0
  521. package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +339 -0
  522. package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +513 -0
  523. package/src/alarms_and_conditions/ua_base_event_impl.ts +55 -0
  524. package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +50 -0
  525. package/src/alarms_and_conditions/ua_condition_impl.ts +1298 -0
  526. package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +81 -0
  527. package/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.ts +110 -0
  528. package/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.ts +19 -0
  529. package/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.ts +130 -0
  530. package/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.ts +24 -0
  531. package/src/alarms_and_conditions/ua_limit_alarm_impl.ts +305 -0
  532. package/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.ts +108 -0
  533. package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +224 -0
  534. package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +186 -0
  535. package/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.ts +27 -0
  536. package/src/apply_condition_refresh.ts +30 -0
  537. package/src/base_node_impl.ts +1749 -0
  538. package/src/base_node_private.ts +690 -0
  539. package/src/data_access/add_dataItem_stuff.ts +75 -0
  540. package/src/data_access/check_variant_compatibility_ua_analog_item.ts +41 -0
  541. package/src/data_access/ua_multistate_discrete_impl.ts +168 -0
  542. package/src/data_access/ua_multistate_value_discrete.ts +299 -0
  543. package/src/data_access/ua_two_state_discrete.ts +185 -0
  544. package/src/event_data.ts +117 -0
  545. package/src/extension_object_array_node.ts +325 -0
  546. package/src/historical_access/address_space_historical_data_node.ts +828 -0
  547. package/src/index_current.ts +52 -0
  548. package/src/namespace_impl.ts +2181 -0
  549. package/src/namespace_private.ts +60 -0
  550. package/src/nodeid_manager.ts +228 -0
  551. package/src/nodeset_tools/adjust_namespace_array.ts +11 -0
  552. package/src/nodeset_tools/construct_namespace_dependency.ts +40 -0
  553. package/src/nodeset_tools/nodeset_to_xml.ts +1317 -0
  554. package/src/nodeset_tools/typedictionary_to_xml.ts +175 -0
  555. package/src/reference_impl.ts +169 -0
  556. package/src/role_permissions.ts +6 -0
  557. package/src/state_machine/finite_state_machine.ts +428 -0
  558. package/src/state_machine/ua_shelving_state_machine_ex.ts +314 -0
  559. package/src/state_machine/ua_two_state_variable.ts +421 -0
  560. package/src/tool_isSupertypeOf.ts +129 -0
  561. package/src/ua_condition_type.ts +10 -0
  562. package/src/ua_data_type_impl.ts +356 -0
  563. package/src/ua_method_impl.ts +278 -0
  564. package/src/ua_object_impl.ts +203 -0
  565. package/src/ua_object_type_impl.ts +158 -0
  566. package/src/ua_reference_type_impl.ts +174 -0
  567. package/src/ua_variable_impl.ts +2277 -0
  568. package/src/ua_variable_type_impl.ts +741 -0
  569. package/src/ua_view_impl.ts +54 -0
  570. package/testHelpers.d.ts +1 -0
  571. package/testHelpers.js +1 -0
  572. package/test_helpers/add_event_generator_object.ts +71 -0
  573. package/test_helpers/alarms_and_conditions_demo.ts +147 -0
  574. package/test_helpers/assertHasMatchingReference.ts +43 -0
  575. package/test_helpers/boiler_system.ts +618 -0
  576. package/test_helpers/create_minimalist_address_space_nodeset.ts +208 -0
  577. package/test_helpers/dump_statemachine.ts +155 -0
  578. package/test_helpers/get_address_space_fixture.ts +30 -0
  579. package/test_helpers/get_mini_address_space.ts +42 -0
  580. package/test_helpers/index.ts +11 -0
  581. package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +150 -0
  582. package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +57 -0
  583. package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +136 -0
  584. package/test_helpers/test_fixtures/dataType_withEnumeration.xml +82 -0
  585. package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +194 -0
  586. package/test_helpers/test_fixtures/dataType_with_structures.xml +605 -0
  587. package/test_helpers/test_fixtures/dataType_with_union.xml +1 -0
  588. package/test_helpers/test_fixtures/datatype_as_per_1.04.xml +91 -0
  589. package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +106 -0
  590. package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +1303 -0
  591. package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +362 -0
  592. package/test_helpers/test_fixtures/issue_846.xml +3172 -0
  593. package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +33 -0
  594. package/test_helpers/test_fixtures/mini.Node.Set2.xml +4508 -0
  595. package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +194 -0
  596. package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +8 -0
  597. package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +16 -0
  598. package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +45 -0
@@ -0,0 +1,1749 @@
1
+ /**
2
+ * @module node-opcua-address-space
3
+ */
4
+ import { EventEmitter } from "events";
5
+ import * as chalk from "chalk";
6
+ import { isEqual } from "lodash";
7
+
8
+ import {
9
+ AddReferenceOpts,
10
+ ModellingRuleType,
11
+ ISessionContext,
12
+ UAMethod,
13
+ UAObject,
14
+ UAObjectType,
15
+ UAReference,
16
+ UAVariable,
17
+ UAVariableType,
18
+ BaseNode,
19
+ UAReferenceType,
20
+ IAddressSpace,
21
+ INamespace,
22
+ BrowseDescriptionOptions2
23
+ } from "node-opcua-address-space-base";
24
+ import { assert } from "node-opcua-assert";
25
+ import {
26
+ AttributeIds,
27
+ attributeNameById,
28
+ BrowseDirection,
29
+ coerceLocalizedText,
30
+ coerceQualifiedName,
31
+ LocalizedText,
32
+ LocalizedTextLike,
33
+ makeNodeClassMask,
34
+ NodeClass,
35
+ QualifiedName,
36
+ QualifiedNameLike,
37
+ QualifiedNameOptions,
38
+ AccessRestrictionsFlag
39
+ } from "node-opcua-data-model";
40
+ import { DataValue } from "node-opcua-data-value";
41
+ import { dumpIf, make_warningLog } from "node-opcua-debug";
42
+ import { coerceNodeId, makeNodeId, NodeId, NodeIdLike, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
43
+ import { NumericRange } from "node-opcua-numeric-range";
44
+ import { ReferenceDescription } from "node-opcua-service-browse";
45
+ import { StatusCode, StatusCodes } from "node-opcua-status-code";
46
+ import {
47
+ PermissionType,
48
+ RelativePathElement,
49
+ RolePermissionType,
50
+ RolePermissionTypeOptions,
51
+ WriteValueOptions
52
+ } from "node-opcua-types";
53
+ import { lowerFirstLetter } from "node-opcua-utils";
54
+ import { DataType, VariantArrayType } from "node-opcua-variant";
55
+
56
+ import { UAStateVariable } from "node-opcua-nodeset-ua";
57
+
58
+ import { XmlWriter } from "../source/xml_writer";
59
+ import { dumpReferenceDescriptions, dumpReferences } from "../source/helpers/dump_tools";
60
+ import { SessionContext, WellKnownRolesNodeId } from "../source/session_context";
61
+ import { AddressSpace } from "../src/address_space";
62
+ import * as cetools from "./address_space_change_event_tools";
63
+ import { AddressSpacePrivate } from "./address_space_private";
64
+ import {
65
+ _constructReferenceDescription,
66
+ _handle_HierarchicalReference,
67
+ BaseNode_add_backward_reference,
68
+ BaseNode_getPrivate,
69
+ BaseNode_initPrivate,
70
+ BaseNode_remove_backward_reference,
71
+ BaseNode_removePrivate,
72
+ BaseNode_toString,
73
+ ToStringBuilder,
74
+ BaseNode_getCache,
75
+ BaseNode_clearCache
76
+ } from "./base_node_private";
77
+ import { MinimalistAddressSpace, ReferenceImpl } from "./reference_impl";
78
+ import { coerceRolePermissions } from "./role_permissions";
79
+
80
+ // tslint:disable:no-var-requires
81
+ // tslint:disable:no-bitwise
82
+ // tslint:disable:no-console
83
+
84
+ const doDebug = false;
85
+ const warningLog = make_warningLog(__filename);
86
+
87
+ function defaultBrowseFilterFunc(context?: ISessionContext): boolean {
88
+ return true;
89
+ }
90
+
91
+ function _get_QualifiedBrowseName(browseName: QualifiedNameLike): QualifiedName {
92
+ return coerceQualifiedName(browseName)!;
93
+ }
94
+
95
+ export interface InternalBaseNodeOptions {
96
+ /**
97
+ * the parent address space
98
+ */
99
+ addressSpace: AddressSpacePrivate;
100
+ browseName: QualifiedName;
101
+ nodeId: NodeId;
102
+ references?: UAReference[];
103
+
104
+ displayName?: LocalizedTextLike | LocalizedTextLike[];
105
+ description?: LocalizedTextLike | null;
106
+
107
+ browseFilter?: (this: BaseNode, context?: ISessionContext) => boolean;
108
+
109
+ /**
110
+ * https://reference.opcfoundation.org/v104/Core/docs/Part3/8.56/
111
+ */
112
+ accessRestrictions?: AccessRestrictionsFlag;
113
+ rolePermissions?: RolePermissionTypeOptions[];
114
+ }
115
+
116
+ function _is_valid_BrowseDirection(browseDirection: any) {
117
+ return (
118
+ browseDirection === BrowseDirection.Forward ||
119
+ browseDirection === BrowseDirection.Inverse ||
120
+ browseDirection === BrowseDirection.Both
121
+ );
122
+ }
123
+
124
+ export function makeAttributeEventName(attributeId: AttributeIds): string {
125
+ const attributeName = attributeNameById[attributeId];
126
+ return attributeName + "_changed";
127
+ }
128
+
129
+ /**
130
+ * Base class for all Node classes
131
+ *
132
+ * BaseNode is the base class for all the OPCUA objects in the address space
133
+ * It provides attributes and a set of references to other nodes.
134
+ * see:
135
+ * {{#crossLink "UAObject"}}{{/crossLink}},
136
+ * {{#crossLink "UAVariable"}}{{/crossLink}},
137
+ * {{#crossLink "Reference"}}{{/crossLink}},
138
+ * {{#crossLink "UAMethod"}}{{/crossLink}},
139
+ * {{#crossLink "UAView"}}{{/crossLink}},
140
+ * {{#crossLink "UAObjectType"}}{{/crossLink}},
141
+ * {{#crossLink "UADataType"}}{{/crossLink}},
142
+ * {{#crossLink "UAVariableType"}}{{/crossLink}},
143
+ *
144
+ *
145
+ */
146
+ export class BaseNodeImpl extends EventEmitter implements BaseNode {
147
+ public static makeAttributeEventName(attributeId: AttributeIds): string {
148
+ return makeAttributeEventName(attributeId);
149
+ }
150
+
151
+ private _accessRestrictions?: AccessRestrictionsFlag;
152
+ private _rolePermissions?: RolePermissionType[];
153
+
154
+ public onFirstBrowseAction?: (this: BaseNode) => Promise<void>;
155
+
156
+ public get addressSpace(): IAddressSpace {
157
+ const _private = BaseNode_getPrivate(this);
158
+ // istanbul ignore next
159
+ if (!_private) {
160
+ throw new Error("Internal error , cannot extract private data from " + this.browseName.toString());
161
+ }
162
+ return _private.__address_space as AddressSpace;
163
+ }
164
+
165
+ protected get addressSpacePrivate(): AddressSpacePrivate {
166
+ const _private = BaseNode_getPrivate(this);
167
+ // istanbul ignore next
168
+ if (!_private) {
169
+ throw new Error("Internal error , cannot extract private data from " + this.browseName.toString());
170
+ }
171
+ return _private.__address_space as AddressSpacePrivate;
172
+ }
173
+
174
+ public get displayName(): LocalizedText[] {
175
+ const _private = BaseNode_getPrivate(this);
176
+ return _private._displayName;
177
+ }
178
+
179
+ public setDisplayName(value: LocalizedText[]): void {
180
+ this._setDisplayName(value);
181
+ /**
182
+ * fires when the displayName is changed.
183
+ * @event DisplayName_changed
184
+ * @param dataValue {DataValue}
185
+ */
186
+ this._notifyAttributeChange(AttributeIds.DisplayName);
187
+ }
188
+
189
+ public get description(): LocalizedText {
190
+ const _private = BaseNode_getPrivate(this);
191
+ return _private._description!;
192
+ }
193
+
194
+ public setDescription(value: LocalizedText): void {
195
+ this._setDescription(value);
196
+ /**
197
+ * fires when the description attribute is changed.
198
+ * @event Description_changed
199
+ * @param dataValue {DataValue}
200
+ */
201
+ this._notifyAttributeChange(AttributeIds.Description);
202
+ }
203
+
204
+ /**
205
+ * returns the nodeId of this node's Type Definition
206
+ */
207
+ public get typeDefinition(): NodeId {
208
+ const _cache = BaseNode_getCache(this);
209
+ if (!_cache.typeDefinition) {
210
+ const has_type_definition_ref = this.findReference("HasTypeDefinition", true);
211
+ _cache.typeDefinition = has_type_definition_ref ? has_type_definition_ref.nodeId : null;
212
+ }
213
+ return _cache.typeDefinition;
214
+ }
215
+
216
+ /**
217
+ * returns the nodeId of this node's Type Definition
218
+ */
219
+ public get typeDefinitionObj(): UAObjectType | UAVariableType {
220
+ const _cache = BaseNode_getCache(this);
221
+ if (undefined === _cache.typeDefinitionObj) {
222
+ const nodeId = this.typeDefinition;
223
+ _cache.typeDefinitionObj = nodeId ? this.addressSpace.findNode(nodeId) : null;
224
+ }
225
+ return _cache.typeDefinitionObj;
226
+ }
227
+
228
+ public get parentNodeId(): NodeId | undefined {
229
+ const parent = this.parent;
230
+ return parent ? parent.nodeId : undefined;
231
+ }
232
+
233
+ /**
234
+ * namespace index
235
+ */
236
+ public get namespaceIndex(): number {
237
+ return this.nodeId.namespace;
238
+ }
239
+
240
+ /**
241
+ * namespace uri
242
+ */
243
+ public get namespaceUri(): string {
244
+ return this.addressSpace.getNamespaceUri(this.namespaceIndex);
245
+ }
246
+
247
+ /**
248
+ * the parent node
249
+ */
250
+ public get parent(): BaseNode | null {
251
+ const _private = BaseNode_getPrivate(this);
252
+ if (_private._parent === undefined) {
253
+ // never been set before
254
+ _private._parent = _setup_parent_item.call(this, _private._referenceIdx);
255
+ }
256
+ return _private._parent || null;
257
+ }
258
+
259
+ /**
260
+ * @property modellingRule
261
+ * @type {String|undefined}
262
+ */
263
+ public get modellingRule(): ModellingRuleType | undefined {
264
+ const r = this.findReferencesAsObject("HasModellingRule");
265
+ if (!r || r.length === 0) {
266
+ return null; /// "? modellingRule missing ?"; // consider "Mandatory"
267
+ }
268
+ const r0 = r[0];
269
+ return r0.browseName.toString() as ModellingRuleType | undefined;
270
+ }
271
+
272
+ public readonly nodeClass: NodeClass = NodeClass.Unspecified;
273
+ public readonly nodeId: NodeId;
274
+ public readonly browseName: QualifiedName;
275
+
276
+ protected _postInstantiateFunc?: any;
277
+
278
+ /**
279
+ * @internal
280
+ * @param options
281
+ */
282
+ constructor(options: InternalBaseNodeOptions) {
283
+ super();
284
+
285
+ assert(this.nodeClass === NodeClass.Unspecified, "must not be specify a nodeClass");
286
+ assert(options.addressSpace); // expecting an address space
287
+ assert(options.browseName instanceof QualifiedName, "Expecting a valid QualifiedName");
288
+ assert(options.nodeId instanceof NodeId, "Expecting a valid NodeId");
289
+ options.references = options.references || [];
290
+
291
+ const _private = BaseNode_initPrivate(this);
292
+ _private.__address_space = options.addressSpace;
293
+
294
+ this.nodeId = resolveNodeId(options.nodeId);
295
+
296
+ // QualifiedName
297
+ /**
298
+ * the node browseName
299
+ * @property browseName
300
+ * @type QualifiedName
301
+ * @static
302
+ */
303
+ this.browseName = _get_QualifiedBrowseName(options.browseName);
304
+
305
+ // re-use browseName as displayName if displayName is missing
306
+ options.displayName = options.displayName || this.browseName.name!.toString();
307
+
308
+ if (options.description === undefined) {
309
+ options.description = null;
310
+ }
311
+ this._setDisplayName(options.displayName);
312
+
313
+ this._setDescription(options.description);
314
+
315
+ // user defined filter function for browsing
316
+ const _browseFilter = options.browseFilter || defaultBrowseFilterFunc;
317
+ assert(typeof _browseFilter === "function");
318
+
319
+ _private._browseFilter = _browseFilter;
320
+
321
+ // normalize reference type
322
+ // this will convert any referenceType expressed with its inverseName into
323
+ // its normal name and fix the isForward flag accordingly.
324
+ // ( e.g "ComponentOf" isForward:true => "HasComponent", isForward:false)
325
+ for (const reference of options.references) {
326
+ this.__addReference(reference);
327
+ }
328
+
329
+ this._accessRestrictions = options.accessRestrictions;
330
+ this._rolePermissions = coerceRolePermissions(options.rolePermissions);
331
+ }
332
+
333
+ public getDisplayName(locale?: string): string {
334
+ const _private = BaseNode_getPrivate(this);
335
+ return _private._displayName[0].text!;
336
+ }
337
+
338
+ public get namespace(): INamespace {
339
+ return this.addressSpacePrivate.getNamespace(this.nodeId.namespace);
340
+ }
341
+
342
+ // ---------------------------------------------------------------------------------------------------
343
+ // Finders
344
+ // ---------------------------------------------------------------------------------------------------
345
+
346
+ public findReferencesEx(referenceType: string | NodeId | UAReferenceType, browseDirection?: BrowseDirection): UAReference[] {
347
+ browseDirection = browseDirection !== undefined ? browseDirection : BrowseDirection.Forward;
348
+ assert(_is_valid_BrowseDirection(browseDirection));
349
+ assert(browseDirection !== BrowseDirection.Both);
350
+
351
+ const referenceTypeNode = this._coerceReferenceType(referenceType);
352
+
353
+ if (!referenceTypeNode) {
354
+ // note: when loading nodeset2.xml files, reference type may not exit yet
355
+ // throw new Error("expecting valid reference name " + strReference);
356
+ return [];
357
+ }
358
+
359
+ const isForward = browseDirection === BrowseDirection.Forward;
360
+ const results: UAReference[] = [];
361
+
362
+ const process = (referenceIdx: { [key: string]: UAReference }) => {
363
+ const references = Object.values(referenceIdx);
364
+ for (const ref of references) {
365
+ if (ref.isForward === isForward && referenceTypeNode && referenceTypeNode.checkHasSubtype(ref.referenceType)) {
366
+ results.push(ref);
367
+ }
368
+ }
369
+ };
370
+ const _private = BaseNode_getPrivate(this);
371
+ process(_private._referenceIdx);
372
+ process(_private._back_referenceIdx);
373
+ return results;
374
+ }
375
+
376
+ public findReferences(referenceType: string | NodeId | UAReferenceType, isForward = true): UAReference[] {
377
+ const _cache = BaseNode_getCache(this);
378
+ const _private = BaseNode_getPrivate(this);
379
+
380
+ const referenceTypeNode = this._coerceReferenceType(referenceType);
381
+ if (!referenceTypeNode) {
382
+ // note: when loading nodeset2.xml files, reference type may not exit yet
383
+ // throw new Error("expecting valid reference name " + strReference);
384
+ return [];
385
+ }
386
+ const hash = "_ref_" + referenceTypeNode.nodeId.toString() + isForward.toString();
387
+ if (_cache[hash]) {
388
+ return _cache[hash];
389
+ }
390
+
391
+ // istanbul ignore next
392
+ if (doDebug && !this.addressSpace.findReferenceType(referenceTypeNode.nodeId)) {
393
+ throw new Error("expecting valid reference name " + referenceType);
394
+ }
395
+
396
+ const result: UAReference[] = [];
397
+ for (const ref of Object.values(_private._referenceIdx)) {
398
+ if (ref.isForward === isForward) {
399
+ if (sameNodeId(ref.referenceType, referenceTypeNode.nodeId)) {
400
+ result.push(ref);
401
+ }
402
+ }
403
+ }
404
+
405
+ for (const ref of Object.values(_private._back_referenceIdx)) {
406
+ if (ref.isForward === isForward) {
407
+ if (sameNodeId(ref.referenceType, referenceTypeNode.nodeId)) {
408
+ result.push(ref);
409
+ }
410
+ }
411
+ }
412
+
413
+ _cache[hash] = result;
414
+ return result;
415
+ }
416
+
417
+ public findReference(strReference: string | NodeId | UAReferenceType, isForward?: boolean): UAReference | null {
418
+ const refs = this.findReferences(strReference, isForward);
419
+ if (refs.length !== 1 && refs.length !== 0) {
420
+ throw new Error("findReference: expecting only one or zero element here");
421
+ }
422
+ return refs[0] || null;
423
+ }
424
+
425
+ public findReferencesExAsObject(
426
+ referenceType: string | NodeId | UAReferenceType,
427
+ browseDirection?: BrowseDirection
428
+ ): BaseNode[] {
429
+ const references = this.findReferencesEx(referenceType, browseDirection);
430
+ return _asObject<BaseNode>(references, this.addressSpace);
431
+ }
432
+
433
+ public findReferencesAsObject(referenceType: string | NodeId | UAReferenceType, isForward?: boolean): BaseNode[] {
434
+ const references = this.findReferences(referenceType, isForward);
435
+ return _asObject<BaseNode>(references, this.addressSpace);
436
+ }
437
+
438
+ /**
439
+ * return an array with the Aggregates of this object.
440
+ */
441
+ public getAggregates(): BaseNode[] {
442
+ const _cache = BaseNode_getCache(this);
443
+ if (!_cache._aggregates) {
444
+ _cache._aggregates = this.findReferencesExAsObject("Aggregates", BrowseDirection.Forward);
445
+ }
446
+ return _cache._aggregates;
447
+ }
448
+
449
+ /**
450
+ * return an array with the components of this object.
451
+ */
452
+ public getComponents(): BaseNode[] {
453
+ const _cache = BaseNode_getCache(this);
454
+ if (!_cache._components) {
455
+ _cache._components = this.findReferencesExAsObject("HasComponent", BrowseDirection.Forward);
456
+ }
457
+ return _cache._components;
458
+ }
459
+
460
+ /**
461
+ * return a array with the properties of this object.
462
+ */
463
+ public getProperties(): BaseNode[] {
464
+ const _cache = BaseNode_getCache(this);
465
+ if (!_cache._properties) {
466
+ _cache._properties = this.findReferencesExAsObject("HasProperty", BrowseDirection.Forward);
467
+ }
468
+ return _cache._properties;
469
+ }
470
+
471
+ /**
472
+ * return a array with the notifiers of this object.
473
+ */
474
+ public getNotifiers(): BaseNode[] {
475
+ const _cache = BaseNode_getCache(this);
476
+ if (!_cache._notifiers) {
477
+ _cache._notifiers = this.findReferencesAsObject("HasNotifier", true);
478
+ }
479
+ return _cache._notifiers;
480
+ }
481
+
482
+ /**
483
+ * return a array with the event source of this object.
484
+ */
485
+ public getEventSources(): BaseNode[] {
486
+ const _cache = BaseNode_getCache(this);
487
+ if (!_cache._eventSources) {
488
+ _cache._eventSources = this.findReferencesAsObject("HasEventSource", true);
489
+ }
490
+ return _cache._eventSources;
491
+ }
492
+
493
+ /**
494
+ * return a array of the objects for which this node is an EventSource
495
+ */
496
+ public getEventSourceOfs(): BaseNode[] {
497
+ const _cache = BaseNode_getCache(this);
498
+ if (!_cache._eventSources) {
499
+ _cache._eventSources = this.findReferencesAsObject("HasEventSource", false);
500
+ }
501
+ return _cache._eventSources;
502
+ }
503
+
504
+ /**
505
+ * retrieve a component by name
506
+ */
507
+ public getComponentByName(browseName: QualifiedNameOptions): UAVariable | UAObject | null;
508
+ public getComponentByName(browseName: string, namespaceIndex?: number): UAVariable | UAObject | null;
509
+ public getComponentByName(browseName: QualifiedNameLike, namespaceIndex?: number): UAVariable | UAObject | null {
510
+ const components = this.getComponents();
511
+ const select = _filter_by_browse_name(components, browseName, namespaceIndex);
512
+ assert(select.length <= 1, "BaseNode#getComponentByName found duplicated reference");
513
+ if (select.length === 1) {
514
+ const component = select[0];
515
+ if (component.nodeClass === NodeClass.Method) {
516
+ warningLog("please use getMethodByName to retrieve a method");
517
+ return null;
518
+ }
519
+ assert(component.nodeClass === NodeClass.Variable || component.nodeClass === NodeClass.Object);
520
+ return component as any as UAVariable | UAObject;
521
+ } else {
522
+ return null;
523
+ }
524
+ }
525
+
526
+ /**
527
+ * retrieve a property by name
528
+ */
529
+ public getPropertyByName(browseName: QualifiedNameOptions): UAVariable | null;
530
+ public getPropertyByName(browseName: string, namespaceIndex?: number): UAVariable | null;
531
+ public getPropertyByName(browseName: QualifiedNameLike, namespaceIndex?: number): UAVariable | null {
532
+ const properties = this.getProperties();
533
+ const select = _filter_by_browse_name(properties, browseName, namespaceIndex);
534
+ assert(select.length <= 1, "BaseNode#getPropertyByName found duplicated reference");
535
+ if (select.length === 1 && select[0].nodeClass !== NodeClass.Variable) {
536
+ throw new Error("Expecting a property to be of nodeClass==NodeClass.Variable");
537
+ }
538
+ return select.length === 1 ? (select[0] as any as UAVariable) : null;
539
+ }
540
+
541
+ /**
542
+ * retrieve a folder element by name
543
+ */
544
+ public getFolderElementByName(browseName: QualifiedNameOptions): BaseNode | null;
545
+ public getFolderElementByName(browseName: string, namespaceIndex?: number): BaseNode | null;
546
+ public getFolderElementByName(browseName: QualifiedNameLike, namespaceIndex?: number): BaseNode | null {
547
+ const elements = this.getFolderElements();
548
+ const select = _filter_by_browse_name(elements, browseName, namespaceIndex);
549
+ return select.length === 1 ? select[0] : null;
550
+ }
551
+
552
+ /**
553
+ * returns the list of nodes that this folder object organizes
554
+ */
555
+ public getFolderElements(): BaseNodeImpl[] {
556
+ return this.findReferencesExAsObject("Organizes", BrowseDirection.Forward) as BaseNodeImpl[];
557
+ }
558
+
559
+ /**
560
+ * returns the list of methods that this object provides
561
+ * @method getMethods
562
+ * @return an array with Method objects.
563
+ *
564
+ *
565
+ * Note: internally, methods are special types of components
566
+ */
567
+ public getMethods(): UAMethod[] {
568
+ const _cache = BaseNode_getCache(this);
569
+ if (!_cache._methods) {
570
+ const components = this.getComponents();
571
+ _cache._methods = components.filter((obj) => obj.nodeClass === NodeClass.Method);
572
+ }
573
+ return _cache._methods;
574
+ }
575
+
576
+ /**
577
+ * returns the method exposed by this object and with the given nodeId
578
+ */
579
+ public getMethodById(nodeId: NodeId): UAMethod | null {
580
+ const methods = this.getMethods();
581
+ const found = methods.find((m: UAMethod) => m.nodeId.toString() === nodeId.toString());
582
+ return found || null;
583
+ }
584
+
585
+ public getMethodByName(methodName: QualifiedNameOptions): UAMethod | null;
586
+ public getMethodByName(methodName: string, namespaceIndex?: number): UAMethod | null;
587
+ public getMethodByName(methodName: QualifiedNameLike, namespaceIndex?: number): UAMethod | null {
588
+ const methods = this.getMethods();
589
+ const select = _filter_by_browse_name(methods, methodName, namespaceIndex);
590
+ assert(select.length <= 1, "BaseNode#getMethodByName found duplicated reference");
591
+ return select.length === 1 ? select[0]! : null;
592
+ }
593
+
594
+ public getWriteMask(): number {
595
+ return 0;
596
+ }
597
+
598
+ public getUserWriteMask(): number {
599
+ return 0;
600
+ }
601
+ public readAttribute(
602
+ context: ISessionContext | null,
603
+ attributeId: AttributeIds,
604
+ indexRange?: NumericRange,
605
+ dataEncoding?: QualifiedNameLike | null
606
+ ): DataValue {
607
+ indexRange;
608
+ dataEncoding;
609
+ assert(!context || context instanceof SessionContext);
610
+ const options: any = {};
611
+ options.statusCode = StatusCodes.Good;
612
+
613
+ switch (attributeId) {
614
+ case AttributeIds.NodeId: // NodeId
615
+ options.value = { dataType: DataType.NodeId, value: this.nodeId };
616
+ break;
617
+
618
+ case AttributeIds.NodeClass: // NodeClass
619
+ assert(isFinite(this.nodeClass));
620
+ options.value = { dataType: DataType.Int32, value: this.nodeClass };
621
+ break;
622
+
623
+ case AttributeIds.BrowseName: // QualifiedName
624
+ assert(this.browseName instanceof QualifiedName);
625
+ options.value = { dataType: DataType.QualifiedName, value: this.browseName };
626
+ break;
627
+
628
+ case AttributeIds.DisplayName: // LocalizedText
629
+ options.value = { dataType: DataType.LocalizedText, value: this.displayName[0] };
630
+ break;
631
+
632
+ case AttributeIds.Description: // LocalizedText
633
+ options.value = { dataType: DataType.LocalizedText, value: this.description };
634
+ break;
635
+
636
+ case AttributeIds.WriteMask:
637
+ options.value = { dataType: DataType.UInt32, value: this.getWriteMask() };
638
+ break;
639
+
640
+ case AttributeIds.UserWriteMask:
641
+ options.value = { dataType: DataType.UInt32, value: this.getUserWriteMask() };
642
+ break;
643
+
644
+ case AttributeIds.AccessRestrictions:
645
+ return this._readAccessRestrictions(context);
646
+
647
+ case AttributeIds.RolePermissions:
648
+ return this._readRolePermissions(context);
649
+
650
+ case AttributeIds.UserRolePermissions:
651
+ return this._readUserRolePermissions(context);
652
+
653
+ default:
654
+ options.value = null;
655
+ options.statusCode = StatusCodes.BadAttributeIdInvalid;
656
+ break;
657
+ }
658
+ // xx options.serverTimestamp = new Date();
659
+ return new DataValue(options);
660
+ }
661
+
662
+ public writeAttribute(
663
+ context: ISessionContext | null,
664
+ writeValue: WriteValueOptions,
665
+ callback: (err: Error | null, statusCode?: StatusCode) => void
666
+ ): void {
667
+ context = context || SessionContext.defaultContext;
668
+
669
+ assert(context instanceof SessionContext);
670
+ assert(typeof callback === "function");
671
+
672
+ if (
673
+ writeValue.attributeId === undefined ||
674
+ writeValue.attributeId <= 0 ||
675
+ writeValue.attributeId > AttributeIds.UserExecutable
676
+ ) {
677
+ return callback(null, StatusCodes.BadAttributeIdInvalid);
678
+ }
679
+ // by default Node is read-only,
680
+ // this method needs to be overridden to change the behavior
681
+ callback(null, StatusCodes.BadNotWritable);
682
+ }
683
+
684
+ public fullName(): string {
685
+ if (this.parentNodeId) {
686
+ const parent = this.addressSpace.findNode(this.parentNodeId) as BaseNode;
687
+
688
+ // istanbul ignore else
689
+ if (parent) {
690
+ return parent.fullName() + "." + this.browseName.toString() + "";
691
+ } else {
692
+ return "NOT YET REGISTERED" + this.parentNodeId.toString() + "." + this.browseName.toString() + "";
693
+ }
694
+ }
695
+ return this.browseName.toString();
696
+ }
697
+
698
+ public ownReferences(): UAReference[] {
699
+ const _private = BaseNode_getPrivate(this);
700
+ return Object.values(_private._referenceIdx);
701
+ }
702
+
703
+ /**
704
+ * @method browseNodeByTargetName
705
+ *
706
+ * @param relativePathElement
707
+ * @param isLast
708
+ * @return {NodeId[]}
709
+ */
710
+ public browseNodeByTargetName(relativePathElement: RelativePathElement, isLast: boolean): NodeId[] {
711
+ relativePathElement.targetName = relativePathElement.targetName || new QualifiedName({});
712
+ // part 4.0 v1.03 $7.26 RelativePath
713
+ // The BrowseName of the target node.
714
+ // The final element may have an empty targetName. In this situation all targets of the references identified by
715
+ // the referenceTypeId are the targets of the RelativePath.
716
+ // The targetName shall be specified for all other elements.
717
+ // The current path cannot be followed any further if no targets with the specified BrowseName exist.
718
+ assert(relativePathElement.targetName instanceof QualifiedName);
719
+ assert(relativePathElement.targetName.namespaceIndex >= 0);
720
+ assert(relativePathElement.targetName.name!.length > 0);
721
+
722
+ // The type of reference to follow from the current node.
723
+ // The current path cannot be followed any further if the referenceTypeId is not available on the Node instance.
724
+ // If not specified then all References are included and the parameter includeSubtypes is ignored.
725
+ assert(Object.prototype.hasOwnProperty.call(relativePathElement, "referenceTypeId"));
726
+
727
+ // Indicates whether the inverse Reference should be followed.
728
+ // The inverse reference is followed if this value is TRUE.
729
+ assert(Object.prototype.hasOwnProperty.call(relativePathElement, "isInverse"));
730
+
731
+ // Indicates whether subtypes of the ReferenceType should be followed.
732
+ // Subtypes are included if this value is TRUE.
733
+ assert(Object.prototype.hasOwnProperty.call(relativePathElement, "includeSubtypes"));
734
+
735
+ const references = this.allReferences();
736
+
737
+ const _check_reference = (reference: UAReference) => {
738
+ if (relativePathElement.referenceTypeId.isEmpty()) {
739
+ return true;
740
+ }
741
+ assert(relativePathElement.referenceTypeId instanceof NodeId);
742
+ if (
743
+ (relativePathElement.isInverse && reference.isForward) ||
744
+ (!relativePathElement.isInverse && !reference.isForward)
745
+ ) {
746
+ return false;
747
+ }
748
+ assert(Object.prototype.hasOwnProperty.call(reference, "isForward"));
749
+ const referenceType = resolveReferenceType(this.addressSpace, reference);
750
+ const referenceTypeId = referenceType.nodeId;
751
+
752
+ if (sameNodeId(relativePathElement.referenceTypeId, referenceTypeId)) {
753
+ return true;
754
+ }
755
+ if (relativePathElement.includeSubtypes) {
756
+ const baseType = this.addressSpace.findReferenceType(relativePathElement.referenceTypeId)!;
757
+ if (baseType && referenceType.isSupertypeOf(baseType)) {
758
+ return true;
759
+ }
760
+ }
761
+ return false;
762
+ };
763
+
764
+ const nodeIdsMap: any = {};
765
+ let nodeIds: NodeId[] = [];
766
+
767
+ for (const reference of references) {
768
+ if (!_check_reference(reference)) {
769
+ continue;
770
+ }
771
+
772
+ const obj = resolveReferenceNode(this.addressSpace, reference);
773
+
774
+ // istanbul ignore next
775
+ if (!obj) {
776
+ throw new Error(" cannot find node with id " + reference.nodeId.toString());
777
+ }
778
+
779
+ if (isEqual(obj.browseName, relativePathElement.targetName)) {
780
+ // compare QualifiedName
781
+
782
+ const key = obj.nodeId.toString();
783
+ if (!Object.prototype.hasOwnProperty.call(nodeIdsMap, key)) {
784
+ nodeIds.push(obj.nodeId);
785
+ nodeIdsMap[key] = obj;
786
+ }
787
+ }
788
+ }
789
+
790
+ if (nodeIds.length === 0 && (this.nodeClass === NodeClass.ObjectType || this.nodeClass === NodeClass.VariableType)) {
791
+ const nodeType = this as any as UAVariableType;
792
+
793
+ if (nodeType.subtypeOf) {
794
+ // browsing also InstanceDeclarations included in base type
795
+ const baseType = this.addressSpace.findNode(nodeType.subtypeOf)! as BaseNode;
796
+ const n = (baseType as BaseNodeImpl).browseNodeByTargetName(relativePathElement, isLast);
797
+ nodeIds = ([] as NodeId[]).concat(nodeIds, n);
798
+ }
799
+ }
800
+ return nodeIds;
801
+ }
802
+
803
+ /**
804
+ * browse the node to extract information requested in browseDescription
805
+ * and returns an array with reference descriptions
806
+ *
807
+ *
808
+ *
809
+ */
810
+ public browseNode(browseDescription: BrowseDescriptionOptions2, context?: ISessionContext): ReferenceDescription[] {
811
+ assert(isFinite(browseDescription.nodeClassMask));
812
+
813
+ const do_debug = false;
814
+
815
+ const _private = BaseNode_getPrivate(this);
816
+
817
+ const addressSpace = this.addressSpace;
818
+
819
+ const referenceTypeId = normalize_referenceTypeId(addressSpace, browseDescription.referenceTypeId);
820
+ assert(referenceTypeId instanceof NodeId);
821
+
822
+ const browseDirection =
823
+ browseDescription.browseDirection !== undefined ? browseDescription.browseDirection : BrowseDirection.Both;
824
+
825
+ // get all possible references
826
+ let references = this.allReferences();
827
+
828
+ /* istanbul ignore next */
829
+ if (do_debug) {
830
+ console.log("all references :", this.nodeId.toString(), this.browseName.toString());
831
+ dumpReferences(addressSpace, (Object as any).values(_private._referenceIdx));
832
+ }
833
+
834
+ // filter out references not matching referenceType
835
+ references = _filter_by_referenceType.call(this, browseDescription, references, referenceTypeId);
836
+
837
+ references = _filter_by_direction(references, browseDirection);
838
+
839
+ references = _filter_by_nodeClass.call(this, references, browseDescription.nodeClassMask);
840
+
841
+ references = _filter_by_userFilter.call(this, references, context);
842
+
843
+ if (context) {
844
+ references = _filter_by_context(this, references, context);
845
+ }
846
+ const referenceDescriptions = _constructReferenceDescription(addressSpace, references, browseDescription.resultMask);
847
+
848
+ /* istanbul ignore next */
849
+ if (do_debug) {
850
+ dumpReferenceDescriptions(this.addressSpace, referenceDescriptions);
851
+ }
852
+
853
+ return referenceDescriptions;
854
+ }
855
+
856
+ public allReferences(): UAReference[] {
857
+ const _private = BaseNode_getPrivate(this);
858
+ return Object.values(_private._referenceIdx).concat(Object.values(_private._back_referenceIdx));
859
+ }
860
+
861
+ /**
862
+ * @method addReference
863
+ * @param reference
864
+ * @param reference.referenceType {String}
865
+ * @param [reference.isForward = true] {Boolean}
866
+ * @param reference.nodeId {Node|NodeId|String}
867
+ *
868
+ * @example
869
+ *
870
+ * view.addReference({ referenceType: "Organizes", nodeId: myDevice });
871
+ *
872
+ * or
873
+ *
874
+ * myDevice1.addReference({ referenceType: "OrganizedBy", nodeId: view });
875
+ */
876
+ public addReference(reference: AddReferenceOpts): void {
877
+ const referenceNode = this.__addReference(reference);
878
+
879
+ const addressSpace = this.addressSpace;
880
+
881
+ if (!resolveReferenceType(addressSpace, referenceNode)) {
882
+ throw new Error("BaseNode#addReference : invalid reference " + reference.toString());
883
+ }
884
+
885
+ this._clear_caches();
886
+
887
+ _propagate_ref.call(this, addressSpace, referenceNode);
888
+ this.install_extra_properties();
889
+ cetools._handle_add_reference_change_event(this, referenceNode.nodeId);
890
+ }
891
+
892
+ public removeReference(referenceOpts: AddReferenceOpts): void {
893
+ const _private = BaseNode_getPrivate(this);
894
+
895
+ assert(Object.prototype.hasOwnProperty.call(referenceOpts, "referenceType"));
896
+ // xx isForward is optional : assert(Object.prototype.hasOwnProperty.call(reference,"isForward"));
897
+ assert(Object.prototype.hasOwnProperty.call(referenceOpts, "nodeId"));
898
+
899
+ const addressSpace = this.addressSpace as AddressSpacePrivate;
900
+
901
+ // istanbul ignore next
902
+ if (!addressSpace) {
903
+ console.log(" Where is addressSpace ?");
904
+ }
905
+ const reference = addressSpace.normalizeReferenceTypes([referenceOpts!])![0];
906
+ const h = (<ReferenceImpl>reference).hash;
907
+
908
+ const relatedNode = addressSpace.findNode(reference.nodeId)!;
909
+
910
+ const invReference = new ReferenceImpl({
911
+ isForward: !reference.isForward,
912
+ nodeId: this.nodeId,
913
+ referenceType: reference.referenceType
914
+ });
915
+
916
+ if (_private._referenceIdx[h]) {
917
+ delete _private._referenceIdx[h];
918
+ BaseNode_remove_backward_reference.call(relatedNode as BaseNode, invReference);
919
+ } else if (_private._back_referenceIdx[h]) {
920
+ (relatedNode as any).removeReference(invReference);
921
+ } else {
922
+ // throw new Error("Cannot find reference " + reference);
923
+ }
924
+
925
+ _handle_HierarchicalReference(this, reference);
926
+
927
+ this.uninstall_extra_properties(reference);
928
+
929
+ this._clear_caches();
930
+ }
931
+
932
+ /**
933
+ *
934
+ */
935
+ public resolveNodeId(nodeId: NodeIdLike): NodeId {
936
+ return this.addressSpace.resolveNodeId(nodeId);
937
+ }
938
+
939
+ public install_extra_properties(): void {
940
+ const addressSpace = this.addressSpace;
941
+
942
+ if (addressSpace.isFrugal) {
943
+ // skipping
944
+ return;
945
+ }
946
+
947
+ install_components_as_object_properties(this);
948
+
949
+ function install_extra_properties_on_parent(ref: UAReference): void {
950
+ const node = ReferenceImpl.resolveReferenceNode(addressSpace, ref) as BaseNode;
951
+ install_components_as_object_properties(node);
952
+ }
953
+
954
+ // make sure parent have extra properties updated
955
+ const parentComponents = this.findReferencesEx("HasComponent", BrowseDirection.Inverse);
956
+ const parentSubfolders = this.findReferencesEx("Organizes", BrowseDirection.Inverse);
957
+ const parentProperties = this.findReferencesEx("HasProperty", BrowseDirection.Inverse);
958
+
959
+ for (const p of parentComponents) {
960
+ install_extra_properties_on_parent(p);
961
+ }
962
+ for (const p of parentSubfolders) {
963
+ install_extra_properties_on_parent(p);
964
+ }
965
+ for (const p of parentProperties) {
966
+ install_extra_properties_on_parent(p);
967
+ }
968
+ }
969
+
970
+ public uninstall_extra_properties(reference: UAReference): void {
971
+ const addressSpace = this.addressSpace;
972
+
973
+ if (addressSpace.isFrugal) {
974
+ // skipping
975
+ return;
976
+ }
977
+ const childNode = resolveReferenceNode(addressSpace, reference);
978
+
979
+ const name = lowerFirstLetter(childNode.browseName.name!.toString());
980
+ if (Object.prototype.hasOwnProperty.call(reservedNames, name)) {
981
+ // istanbul ignore next
982
+ if (doDebug) {
983
+ // tslint:disable-next-line:no-console
984
+ console.log(chalk.bgWhite.red("Ignoring reserved keyword " + name));
985
+ }
986
+ return;
987
+ }
988
+ /* istanbul ignore next */
989
+ if (!Object.prototype.hasOwnProperty.call(this, name)) {
990
+ return;
991
+ }
992
+
993
+ Object.defineProperty(this, name, {
994
+ value: undefined
995
+ });
996
+ }
997
+
998
+ public toString(): string {
999
+ const options = new ToStringBuilder();
1000
+ BaseNode_toString.call(this, options);
1001
+ return options.toString();
1002
+ }
1003
+
1004
+ /**
1005
+ * @property isFalseSubStateOf
1006
+ * @type {BaseNode|null}
1007
+ */
1008
+ public get isFalseSubStateOf(): BaseNode | null {
1009
+ const r = this.findReferencesAsObject("HasFalseSubState", false);
1010
+ if (!r || r.length === 0) {
1011
+ return null;
1012
+ }
1013
+ assert(r.length === 1);
1014
+ return r[0];
1015
+ }
1016
+
1017
+ /**
1018
+ * @property isTrueSubStateOf
1019
+ * @type {BaseNode|null}
1020
+ */
1021
+ public get isTrueSubStateOf(): BaseNode | null {
1022
+ const r = this.findReferencesAsObject("HasTrueSubState", false);
1023
+ if (!r || r.length === 0) {
1024
+ return null;
1025
+ }
1026
+ assert(r.length === 1);
1027
+ return r[0] as BaseNode;
1028
+ }
1029
+
1030
+ /**
1031
+ * @method getFalseSubStates
1032
+ * @return {UAStateVariable[]} return an array with the SubStates of this object.
1033
+ */
1034
+ public getFalseSubStates(): UAStateVariable<LocalizedText>[] {
1035
+ return this.findReferencesAsObject("HasFalseSubState") as UAStateVariable<LocalizedText>[];
1036
+ }
1037
+
1038
+ /**
1039
+ * @method getTrueSubStates
1040
+ * @return {UAStateVariable[]} return an array with the SubStates of this object.
1041
+ */
1042
+ public getTrueSubStates(): UAStateVariable<LocalizedText>[] {
1043
+ return this.findReferencesAsObject("HasTrueSubState") as UAStateVariable<LocalizedText>[];
1044
+ }
1045
+
1046
+ public findHierarchicalReferences(): UAReference[] {
1047
+ return this.findReferencesEx("HierarchicalReferences", BrowseDirection.Forward);
1048
+ }
1049
+
1050
+ public getChildByName(browseName: QualifiedNameOptions): BaseNode | null;
1051
+ public getChildByName(browseName: string, namespaceIndex?: number): BaseNode | null;
1052
+ public getChildByName(browseName: QualifiedNameLike, namespaceIndex?: number): BaseNode | null {
1053
+ // Attention: getChild doesn't care about namespace on browseName
1054
+ // !!!!
1055
+ if (browseName instanceof QualifiedName) {
1056
+ browseName = browseName.name!.toString();
1057
+ }
1058
+ assert(typeof browseName === "string");
1059
+
1060
+ const _cache = BaseNode_getCache(this);
1061
+
1062
+ const addressSpace = this.addressSpace;
1063
+
1064
+ if (!_cache._childByNameMap) {
1065
+ _cache._childByNameMap = {};
1066
+
1067
+ const childReferenceTypes = this.findReferencesEx("HasChild");
1068
+ for (const r of childReferenceTypes) {
1069
+ const child = resolveReferenceNode(addressSpace, r);
1070
+ _cache._childByNameMap[child.browseName.name!.toString()] = child;
1071
+ }
1072
+ }
1073
+ const ret = _cache._childByNameMap[browseName.toString()] || null;
1074
+ return ret;
1075
+ }
1076
+
1077
+ get toStateNode(): BaseNode | null {
1078
+ const nodes = this.findReferencesAsObject("ToState", true);
1079
+ assert(nodes.length <= 1);
1080
+ return nodes.length === 1 ? nodes[0] : null;
1081
+ }
1082
+
1083
+ get fromStateNode(): BaseNode | null {
1084
+ const nodes = this.findReferencesAsObject("FromState", true);
1085
+ assert(nodes.length <= 1);
1086
+ return nodes.length === 1 ? nodes[0] : null;
1087
+ }
1088
+
1089
+ /**
1090
+ * this methods propagates the forward references to the pointed node
1091
+ * by inserting backward references to the counter part node
1092
+ */
1093
+ public propagate_back_references(): void {
1094
+ const _private = BaseNode_getPrivate(this);
1095
+ if ((this.addressSpace as AddressSpacePrivate).suspendBackReference) {
1096
+ // this indicates that the base node is constructed from an xml definition
1097
+ // propagate_back_references will be called later once the file has been completely processed.
1098
+ return;
1099
+ }
1100
+ const addressSpace = this.addressSpace;
1101
+ for (const reference of Object.values(_private._referenceIdx)) {
1102
+ _propagate_ref.call(this, addressSpace, reference);
1103
+ }
1104
+ }
1105
+
1106
+ /**
1107
+ * the dispose method should be called when the node is no longer used, to release
1108
+ * back pointer to the address space and clear caches.
1109
+ *
1110
+ * @method dispose
1111
+ *
1112
+ */
1113
+ public dispose(): void {
1114
+ this.emit("dispose");
1115
+
1116
+ this.removeAllListeners();
1117
+ this._clear_caches();
1118
+
1119
+ const _private = BaseNode_getPrivate(this);
1120
+ Object.values(_private._back_referenceIdx).forEach((ref) => (ref as ReferenceImpl).dispose());
1121
+ Object.values(_private._referenceIdx).forEach((ref) => (ref as ReferenceImpl).dispose());
1122
+
1123
+ BaseNode_removePrivate(this);
1124
+ }
1125
+
1126
+ // istanbul ignore next
1127
+ public dumpXML(xmlWriter: XmlWriter): void {
1128
+ console.error(" This ", (NodeClass as any)[this.nodeClass]);
1129
+ assert(false, "BaseNode#dumpXML NOT IMPLEMENTED !");
1130
+ assert(xmlWriter);
1131
+ }
1132
+
1133
+ /**
1134
+ * Undo the effect of propagate_back_references
1135
+ */
1136
+ public unpropagate_back_references(): void {
1137
+ const _private = BaseNode_getPrivate(this);
1138
+
1139
+ const addressSpace = this.addressSpace;
1140
+
1141
+ for (const reference of Object.values(_private._referenceIdx) as UAReference[]) {
1142
+ // filter out non Hierarchical References
1143
+ const referenceType = resolveReferenceType(addressSpace, reference);
1144
+
1145
+ // istanbul ignore next
1146
+ if (!referenceType) {
1147
+ console.error(chalk.red(" ERROR"), " cannot find reference ", reference.referenceType, reference.toString());
1148
+ }
1149
+
1150
+ const related_node = resolveReferenceNode(addressSpace, reference) as BaseNode;
1151
+ if (related_node) {
1152
+ assert(reference.nodeId.toString() !== this.nodeId.toString());
1153
+ BaseNode_remove_backward_reference.call(
1154
+ related_node,
1155
+ new ReferenceImpl({
1156
+ isForward: !reference.isForward,
1157
+ nodeId: this.nodeId,
1158
+ referenceType: reference.referenceType
1159
+ })
1160
+ );
1161
+ } // else addressSpace may be incomplete
1162
+ }
1163
+ }
1164
+
1165
+ public installPostInstallFunc(f: ()=>void): void {
1166
+ if (!f) {
1167
+ // nothing to do
1168
+ return;
1169
+ }
1170
+
1171
+ function chain(f1: any, f2: any) {
1172
+ return function chaiFunc(this: BaseNode, ... args: any[]) {
1173
+ if (f1) {
1174
+ f1.apply(this, args);
1175
+ }
1176
+ if (f2) {
1177
+ f2.apply(this, args);
1178
+ }
1179
+ };
1180
+ }
1181
+
1182
+ this._postInstantiateFunc = chain.call(this, this._postInstantiateFunc, f);
1183
+ }
1184
+
1185
+ public _on_child_added(): void {
1186
+ this._clear_caches();
1187
+ }
1188
+
1189
+ public _on_child_removed(obj: BaseNode): void {
1190
+ // obj; // unused;
1191
+ this._clear_caches();
1192
+ }
1193
+
1194
+ /**
1195
+ * @private
1196
+ * @param reference
1197
+ */
1198
+ public _add_backward_reference(reference: UAReference): void {
1199
+ BaseNode_add_backward_reference.call(this, reference);
1200
+ }
1201
+
1202
+ protected _coerceReferenceType(referenceType: string | NodeId | UAReferenceType): UAReferenceType | null {
1203
+ let result: UAReferenceType;
1204
+ if (typeof referenceType === "string") {
1205
+ result = this.addressSpace.findReferenceType(referenceType)!;
1206
+ /* istanbul ignore next */
1207
+ if (!result) {
1208
+ throw new Error("Cannot coerce reference with name " + referenceType);
1209
+ }
1210
+ } else if (referenceType instanceof NodeId) {
1211
+ result = this.addressSpace.findNode(referenceType) as UAReferenceType;
1212
+ if (!result) {
1213
+ return null;
1214
+ }
1215
+ } else {
1216
+ result = referenceType;
1217
+ }
1218
+ assert(result, "reference must exists");
1219
+ assert(result.nodeClass === NodeClass.ReferenceType);
1220
+ return result as UAReferenceType;
1221
+ }
1222
+
1223
+ private __addReference(referenceOpts: AddReferenceOpts): UAReference {
1224
+ const _private = BaseNode_getPrivate(this);
1225
+
1226
+ assert(Object.prototype.hasOwnProperty.call(referenceOpts, "referenceType"));
1227
+ // xx isForward is optional : assert(Object.prototype.hasOwnProperty.call(reference,"isForward"));
1228
+ assert(Object.prototype.hasOwnProperty.call(referenceOpts, "nodeId"));
1229
+
1230
+ const addressSpace = this.addressSpace as AddressSpacePrivate;
1231
+ const reference: UAReference = addressSpace.normalizeReferenceTypes([referenceOpts])[0];
1232
+ assert(reference instanceof ReferenceImpl);
1233
+
1234
+ const h = (<ReferenceImpl>reference).hash;
1235
+ assert(!_private._back_referenceIdx[h], "reference exists already in _back_references");
1236
+ assert(!_private._referenceIdx[h], "reference exists already in _references");
1237
+
1238
+ _private._referenceIdx[h] = reference;
1239
+ _handle_HierarchicalReference(this, reference);
1240
+ return reference;
1241
+ }
1242
+
1243
+ private _setDisplayName(displayName: LocalizedTextLike | LocalizedTextLike[]) {
1244
+ const displayNames: LocalizedTextLike[] = Array.isArray(displayName) ? displayName : [displayName];
1245
+ const _displayNames = displayNames.map(coerceLocalizedText) as LocalizedText[];
1246
+ const _private = BaseNode_getPrivate(this);
1247
+ _private._displayName = _displayNames;
1248
+ }
1249
+
1250
+ private _setDescription(description: LocalizedTextLike | null): void {
1251
+ const __description = coerceLocalizedText(description);
1252
+ const _private = BaseNode_getPrivate(this);
1253
+ _private._description = __description!;
1254
+ }
1255
+
1256
+ private _notifyAttributeChange(attributeId: AttributeIds): void {
1257
+ const event_name = BaseNodeImpl.makeAttributeEventName(attributeId);
1258
+ this.emit(event_name, this.readAttribute(SessionContext.defaultContext, attributeId));
1259
+ }
1260
+
1261
+ private _clear_caches() {
1262
+ BaseNode_clearCache(this);
1263
+ }
1264
+ private _readAccessRestrictions(context: ISessionContext | null): DataValue {
1265
+ // https://reference.opcfoundation.org/v104/Core/docs/Part3/8.56/
1266
+ if (this.accessRestrictions === undefined) {
1267
+ return new DataValue({ statusCode: StatusCodes.BadAttributeIdInvalid });
1268
+ }
1269
+
1270
+ return new DataValue({
1271
+ statusCode: StatusCodes.Good,
1272
+ value: {
1273
+ dataType: DataType.UInt16,
1274
+ value: this.accessRestrictions
1275
+ }
1276
+ });
1277
+ }
1278
+ private _readRolePermissions(context: ISessionContext | null): DataValue {
1279
+ // https://reference.opcfoundation.org/v104/Core/docs/Part3/4.8.3/
1280
+
1281
+ // to do check that current user can read permission
1282
+ if (context && !context?.checkPermission(this as any, PermissionType.ReadRolePermissions)) {
1283
+ return new DataValue({
1284
+ statusCode: StatusCodes.BadSecurityModeInsufficient
1285
+ });
1286
+ }
1287
+
1288
+ if (this.rolePermissions === undefined) {
1289
+ // to do : If not specified, the value of DefaultUserRolePermissions Property from
1290
+ // the Namespace Metadata Object associated with the Node is used instead.
1291
+ return new DataValue({
1292
+ statusCode: StatusCodes.BadAttributeIdInvalid
1293
+ });
1294
+ }
1295
+
1296
+ const rolePermissions = this.rolePermissions.map(({ roleId, permissions }) => {
1297
+ return new RolePermissionType({
1298
+ roleId: toRoleNodeId(roleId!),
1299
+ permissions
1300
+ });
1301
+ });
1302
+ return new DataValue({
1303
+ statusCode: StatusCodes.Good,
1304
+ value: {
1305
+ dataType: DataType.ExtensionObject,
1306
+ arrayType: VariantArrayType.Array,
1307
+ value: rolePermissions
1308
+ }
1309
+ });
1310
+ }
1311
+
1312
+ private _readUserRolePermissions(context: ISessionContext | null): DataValue {
1313
+ if (this.rolePermissions === undefined) {
1314
+ // to do : If not specified, the value of DefaultUserRolePermissions Property from
1315
+ // the Namespace Metadata Object associated with the Node is used instead.
1316
+ return new DataValue({
1317
+ statusCode: StatusCodes.BadAttributeIdInvalid
1318
+ });
1319
+ }
1320
+ const context1: ISessionContext = context === null ? SessionContext.defaultContext : context;
1321
+ // for the time being ...
1322
+ // get user Permission
1323
+ const rolePermissions = this.rolePermissions
1324
+ .map(({ roleId, permissions }) => {
1325
+ return new RolePermissionType({
1326
+ roleId: toRoleNodeId(roleId!),
1327
+ permissions
1328
+ });
1329
+ })
1330
+ .filter(({ roleId }) => context1.currentUserHasRole(roleId));
1331
+ return new DataValue({
1332
+ statusCode: StatusCodes.Good,
1333
+ value: {
1334
+ dataType: DataType.ExtensionObject,
1335
+ arrayType: VariantArrayType.Array,
1336
+ value: rolePermissions
1337
+ }
1338
+ });
1339
+ }
1340
+
1341
+ /**
1342
+ *
1343
+ * @param rolePermissions
1344
+ */
1345
+ setRolePermissions(rolePermissions: RolePermissionTypeOptions[]): void {
1346
+ this._rolePermissions = coerceRolePermissions(rolePermissions);
1347
+ }
1348
+ getRolePermissions(inherited: boolean): RolePermissionType[] | null {
1349
+ if (this.rolePermissions === undefined && inherited) {
1350
+ return this.namespace.getDefaultRolePermissions();
1351
+ }
1352
+ return this._rolePermissions || null;
1353
+ }
1354
+ get rolePermissions(): RolePermissionType[] | undefined {
1355
+ return this._rolePermissions || undefined;
1356
+ }
1357
+
1358
+ setAccessRestrictions(accessRestrictions: AccessRestrictionsFlag): void {
1359
+ this._accessRestrictions = accessRestrictions;
1360
+ }
1361
+ get accessRestrictions(): AccessRestrictionsFlag | undefined {
1362
+ return this._accessRestrictions;
1363
+ }
1364
+ getAccessRestrictions(inherited: boolean): AccessRestrictionsFlag {
1365
+ if (this._accessRestrictions === undefined && inherited) {
1366
+ return this.namespace.getDefaultAccessRestrictions();
1367
+ }
1368
+ return this._accessRestrictions || AccessRestrictionsFlag.None;
1369
+ }
1370
+ }
1371
+
1372
+ function toRoleNodeId(s: NodeIdLike): NodeId {
1373
+ if (typeof s === "string") {
1374
+ return resolveNodeId(WellKnownRolesNodeId[s as any]);
1375
+ }
1376
+ return coerceNodeId(s);
1377
+ }
1378
+
1379
+ let displayWarning = true;
1380
+
1381
+ function toString_ReferenceDescription(ref: UAReference, options: { addressSpace: IAddressSpace }): string {
1382
+ const addressSpace = options.addressSpace as AddressSpacePrivate;
1383
+ // xx assert(ref instanceof ReferenceDescription);
1384
+ const refNode = addressSpace.findNode(ref.referenceType);
1385
+ if (!refNode) {
1386
+ return "Unknown Ref : " + ref;
1387
+ }
1388
+ const r = new ReferenceImpl({
1389
+ isForward: ref.isForward,
1390
+ nodeId: ref.nodeId,
1391
+ referenceType: refNode.browseName.toString()
1392
+ });
1393
+ const str = r.toString(options);
1394
+ r.dispose();
1395
+ return str;
1396
+ }
1397
+
1398
+ function _setup_parent_item(this: BaseNode, references: { [key: string]: any }): BaseNode | null {
1399
+ references = Object.values(references);
1400
+
1401
+ const _private = BaseNode_getPrivate(this);
1402
+ assert(!_private._parent, "_setup_parent_item has been already called");
1403
+
1404
+ const addressSpace = this.addressSpace;
1405
+
1406
+ if (references.length > 0) {
1407
+ references = this.findReferencesEx("Aggregates", BrowseDirection.Inverse);
1408
+
1409
+ if (references.length >= 1) {
1410
+ // istanbul ignore next
1411
+ if (references.length > 1) {
1412
+ if (displayWarning) {
1413
+ const options = { addressSpace };
1414
+ // tslint:disable-next-line:no-console
1415
+ console.warn(" More than one Aggregates reference have been found for parent of object");
1416
+ // tslint:disable-next-line:no-console
1417
+ console.warn(" object node id:", this.nodeId.toString(), chalk.cyan(this.browseName.toString()));
1418
+ // tslint:disable-next-line:no-console
1419
+ console.warn(" browseResults:");
1420
+ // tslint:disable-next-line:no-console
1421
+ console.warn(references.map((f: UAReference) => toString_ReferenceDescription(f, options)).join("\n"));
1422
+ // tslint:disable-next-line:no-console
1423
+ console.warn(" first one will be used as parent");
1424
+ // xx assert(browseResults.length === 1);
1425
+ displayWarning = false;
1426
+ }
1427
+ }
1428
+ return ReferenceImpl.resolveReferenceNode(addressSpace, references[0]);
1429
+ }
1430
+ }
1431
+ return null;
1432
+ }
1433
+
1434
+ function _asObject<T extends BaseNode>(references: UAReference[], addressSpace: IAddressSpace): T[] {
1435
+ function toObject(reference: UAReference): T {
1436
+ const obj = resolveReferenceNode(addressSpace, reference);
1437
+ // istanbul ignore next
1438
+ if (false && !obj) {
1439
+ // tslint:disable-next-line:no-console
1440
+ console.log(
1441
+ chalk.red(" Warning : object with nodeId ") +
1442
+ chalk.cyan(reference.nodeId.toString()) +
1443
+ chalk.red(" cannot be found in the address space !")
1444
+ );
1445
+ }
1446
+ return obj as any as T;
1447
+ }
1448
+
1449
+ function remove_null(o: any): boolean {
1450
+ return !!o;
1451
+ }
1452
+
1453
+ return references.map(toObject)!.filter(remove_null)! as T[];
1454
+ }
1455
+
1456
+ function _filter_by_browse_name<T extends BaseNode>(components: T[], browseName: QualifiedNameLike, namespaceIndex?: number): T[] {
1457
+ let select: T[] = [];
1458
+ if ((namespaceIndex === null || namespaceIndex === undefined) && typeof browseName === "string") {
1459
+ select = components.filter((c: T) => c.browseName.name!.toString() === browseName);
1460
+ if (select && select.length > 1) {
1461
+ warningLog("Multiple children exist with name ", browseName, " please specify a namespace index");
1462
+ }
1463
+ } else {
1464
+ const _browseName = coerceQualifiedName(
1465
+ typeof browseName === "string" ? { name: browseName, namespaceIndex } : browseName
1466
+ )!;
1467
+ select = components.filter(
1468
+ (c: T) => c.browseName.name === _browseName.name && c.browseName.namespaceIndex === _browseName.namespaceIndex
1469
+ );
1470
+ }
1471
+ return select;
1472
+ }
1473
+
1474
+ let displayWarningReferencePointingToItSelf = true;
1475
+
1476
+ function _is_massively_used_reference(referenceType: UAReferenceType): boolean {
1477
+ const name = referenceType.browseName.toString();
1478
+ return name === "HasTypeDefinition" || name === "HasModellingRule";
1479
+ }
1480
+
1481
+ function _propagate_ref(this: BaseNode, addressSpace: MinimalistAddressSpace, reference: UAReference): void {
1482
+ // filter out non Hierarchical References
1483
+ const referenceType = ReferenceImpl.resolveReferenceType(addressSpace, reference);
1484
+
1485
+ // istanbul ignore next
1486
+ if (!referenceType) {
1487
+ // tslint:disable-next-line:no-console
1488
+ console.error(chalk.red(" ERROR"), " cannot find reference ", reference.referenceType, reference.toString());
1489
+ }
1490
+
1491
+ // ------------------------------- Filter out back reference when reference type
1492
+ // is HasTypeDefinition, HasModellingRule, etc ...
1493
+ //
1494
+ // var referenceNode = Reference.resolveReferenceNode(addressSpace,reference);
1495
+ // ignore propagation on back reference to UAVariableType or UAObject Type reference
1496
+ // because there are too many !
1497
+ if (!referenceType || _is_massively_used_reference(referenceType)) {
1498
+ return;
1499
+ }
1500
+ // ------------------------------- EXPERIMENT
1501
+
1502
+ // xx if (!referenceType.isSupertypeOf(hierarchicalReferencesId)) { return; }
1503
+ const related_node = resolveReferenceNode(addressSpace, reference) as BaseNodeImpl;
1504
+ if (related_node) {
1505
+ // verify that reference doesn't point to object it this (see mantis 3099)
1506
+ if (sameNodeId(reference.nodeId, this.nodeId)) {
1507
+ // istanbul ignore next
1508
+ if (displayWarningReferencePointingToItSelf) {
1509
+ // this could happen with method
1510
+ console.warn(" Warning: a Reference is pointing to this ", this.nodeId.toString(), this.browseName.toString());
1511
+ displayWarningReferencePointingToItSelf = false;
1512
+ }
1513
+ }
1514
+ // xx ignore this assert(reference.nodeId.toString() !== this.nodeId.toString());
1515
+ // function w(s,l) { return (s+" ").substr(0,l);}
1516
+ // if (reference.isForward) {
1517
+ // console.log(" CHILD => ",w(related_node.browseName + " " + related_node.nodeId.toString(),30),
1518
+ // " PARENT ",w(this.browseName + " " + this.nodeId.toString(),30) , reference.toString());
1519
+ // } else {
1520
+ // console.log(" CHILD => ",w(this.browseName + " " + this.nodeId.toString(),30),
1521
+ // " PARENT ",w(related_node.browseName + " " + related_node.nodeId.toString(),30) , reference.toString());
1522
+ //
1523
+ // }
1524
+ (related_node as BaseNodeImpl)._add_backward_reference(
1525
+ new ReferenceImpl({
1526
+ _referenceType: getReferenceType(reference),
1527
+ isForward: !reference.isForward,
1528
+ node: this,
1529
+ nodeId: this.nodeId,
1530
+ referenceType: reference.referenceType
1531
+ })
1532
+ );
1533
+ } // else addressSpace may be incomplete and under construction (while loading a nodeset.xml file for instance)
1534
+ }
1535
+
1536
+ function nodeid_is_nothing(nodeid: NodeId): boolean {
1537
+ return nodeid.value === 0 && nodeid.namespace === 0;
1538
+ }
1539
+
1540
+ /**
1541
+ * @method normalize_referenceTypeId
1542
+ * @param addressSpace {IAddressSpace}
1543
+ * @param referenceTypeId {String|NodeId|null} : the referenceType either as a string or a nodeId
1544
+ * @return {NodeId}
1545
+ */
1546
+ function normalize_referenceTypeId(addressSpace: IAddressSpace, referenceTypeId?: NodeIdLike | null): NodeId {
1547
+ if (!referenceTypeId) {
1548
+ return makeNodeId(0);
1549
+ }
1550
+ if (typeof referenceTypeId === "string") {
1551
+ const ref = addressSpace.findReferenceType(referenceTypeId);
1552
+ if (ref) {
1553
+ return ref.nodeId;
1554
+ }
1555
+ }
1556
+ let nodeId;
1557
+ try {
1558
+ nodeId = addressSpace.resolveNodeId(referenceTypeId);
1559
+ } catch (err) {
1560
+ console.log("cannot normalize_referenceTypeId", referenceTypeId);
1561
+ throw err;
1562
+ }
1563
+ assert(nodeId);
1564
+ return nodeId;
1565
+ }
1566
+
1567
+ const resolveReferenceNode = ReferenceImpl.resolveReferenceNode;
1568
+ const resolveReferenceType = ReferenceImpl.resolveReferenceType;
1569
+
1570
+ function _filter_by_referenceType(
1571
+ this: BaseNode,
1572
+ browseDescription: BrowseDescriptionOptions2,
1573
+ references: UAReference[],
1574
+ referenceTypeId: NodeId
1575
+ ) {
1576
+ // make sure we have a valid referenceTypeId if not null
1577
+ if (!nodeid_is_nothing(referenceTypeId)) {
1578
+ assert(referenceTypeId instanceof NodeId);
1579
+ const referenceType = this.addressSpace.findNode(referenceTypeId) as UAReferenceType;
1580
+ dumpIf(!referenceType, referenceTypeId);
1581
+ // istanbul ignore next
1582
+ if (!referenceType || referenceType.nodeClass !== NodeClass.ReferenceType) {
1583
+ throw new Error("Cannot find reference type");
1584
+ }
1585
+
1586
+ if (!browseDescription.includeSubtypes && referenceType.isAbstract) {
1587
+ warningLog("filter by reference will skip all reference as referenceType is abstract and includeSubtypes is false");
1588
+ }
1589
+
1590
+ references = references.filter((reference) => {
1591
+ const ref = resolveReferenceType(this.addressSpace, reference)!;
1592
+ // istanbul ignore next
1593
+ if (!ref) {
1594
+ throw new Error("Cannot find reference type " + reference.toString());
1595
+ }
1596
+ // unknown type ... this may happen when the address space is not fully build
1597
+ assert(ref.nodeClass === NodeClass.ReferenceType);
1598
+
1599
+ const isSameType = sameNodeId(ref.nodeId, referenceType.nodeId);
1600
+ if (isSameType) {
1601
+ return true;
1602
+ }
1603
+ if (browseDescription.includeSubtypes) {
1604
+ return ref.isSupertypeOf(referenceType as UAReferenceType);
1605
+ } else {
1606
+ return false;
1607
+ }
1608
+ });
1609
+ }
1610
+ return references;
1611
+ }
1612
+
1613
+ function forwardOnly(reference: UAReference): boolean {
1614
+ return reference.isForward;
1615
+ }
1616
+
1617
+ function reverseOnly(reference: UAReference): boolean {
1618
+ return !reference.isForward;
1619
+ }
1620
+
1621
+ function _filter_by_direction(references: UAReference[], browseDirection: BrowseDirection): UAReference[] {
1622
+ if (browseDirection === BrowseDirection.Both) {
1623
+ return references;
1624
+ }
1625
+ if (browseDirection === BrowseDirection.Forward) {
1626
+ return references.filter(forwardOnly);
1627
+ } else {
1628
+ return references.filter(reverseOnly);
1629
+ }
1630
+ }
1631
+ /*
1632
+ function _filter_by_context(node: BaseNode, references: Reference[], context: SessionContext): Reference[] {
1633
+ if (!context.isBrowseAccessRestricted(node)) {
1634
+ return references;
1635
+ }
1636
+ // browse access is restricted for forward
1637
+ return [];
1638
+ }
1639
+ */
1640
+ function _filter_by_context(node: BaseNode, references: UAReference[], context: ISessionContext): UAReference[] {
1641
+ const addressSpace = node.addressSpace;
1642
+ return references.filter((reference) => !context.isBrowseAccessRestricted(resolveReferenceNode(addressSpace, reference)));
1643
+ }
1644
+
1645
+ function _filter_by_nodeClass(this: BaseNode, references: UAReference[], nodeClassMask: number): UAReference[] {
1646
+ assert(isFinite(nodeClassMask));
1647
+ if (nodeClassMask === 0) {
1648
+ return references;
1649
+ }
1650
+ const addressSpace = this.addressSpace;
1651
+ return references.filter((reference) => {
1652
+ const obj = resolveReferenceNode(addressSpace, reference);
1653
+
1654
+ if (!obj) {
1655
+ return false;
1656
+ }
1657
+
1658
+ const nodeClassName = NodeClass[obj.nodeClass];
1659
+
1660
+ const value = makeNodeClassMask(nodeClassName);
1661
+ return (value & nodeClassMask) === value;
1662
+ });
1663
+ }
1664
+
1665
+ function _filter_by_userFilter(this: BaseNode, references: UAReference[], context?: ISessionContext): UAReference[] {
1666
+ const addressSpace = this.addressSpace;
1667
+ return references.filter((reference: UAReference) => {
1668
+ const obj = resolveReferenceNode(addressSpace, reference) as BaseNode;
1669
+ // istanbul ignore next
1670
+ if (!obj) {
1671
+ return false;
1672
+ }
1673
+
1674
+ const _private = BaseNode_getPrivate(obj);
1675
+ // istanbul ignore next
1676
+ if (!_private._browseFilter) {
1677
+ throw Error("Internal error : cannot find browseFilter");
1678
+ }
1679
+
1680
+ const filter1 = _private._browseFilter.call(obj, context);
1681
+ return filter1;
1682
+ });
1683
+ }
1684
+
1685
+ const reservedNames = {
1686
+ __description: 0,
1687
+ __displayName: 0,
1688
+ browseName: 0,
1689
+ description: 0,
1690
+ displayName: 0,
1691
+ nodeClass: 0,
1692
+ nodeId: 0,
1693
+ typeDefinition: 0
1694
+ };
1695
+
1696
+ /*
1697
+ * install hierarchical references as javascript properties
1698
+ * Components/Properties/Organizes
1699
+ */
1700
+ function install_components_as_object_properties(parentObj: BaseNode) {
1701
+ if (!parentObj) {
1702
+ return;
1703
+ }
1704
+
1705
+ const addressSpace = parentObj.addressSpace;
1706
+ const hierarchicalRefs = (parentObj as BaseNodeImpl).findHierarchicalReferences();
1707
+
1708
+ const children = hierarchicalRefs.map((r: UAReference) => ReferenceImpl.resolveReferenceNode(addressSpace, r));
1709
+
1710
+ for (const child of children) {
1711
+ if (!child) {
1712
+ continue;
1713
+ }
1714
+ // assumption: we ignore namespace here .
1715
+ const name = lowerFirstLetter(child.browseName.name!.toString());
1716
+
1717
+ if (Object.prototype.hasOwnProperty.call(reservedNames, name)) {
1718
+ // ignore reserved names
1719
+ if (doDebug) {
1720
+ console.log(chalk.bgWhite.red("Ignoring reserved keyword " + name));
1721
+ }
1722
+ continue;
1723
+ }
1724
+
1725
+ // ignore reserved names
1726
+ if (doDebug) {
1727
+ console.log("Installing property " + name, " on ", parentObj.browseName.toString());
1728
+ }
1729
+
1730
+ /* istanbul ignore next */
1731
+ if (Object.prototype.hasOwnProperty.call(parentObj, name)) {
1732
+ continue;
1733
+ }
1734
+
1735
+ Object.defineProperty(parentObj, name, {
1736
+ configurable: true, // set to true, so we can undefine later
1737
+ enumerable: true,
1738
+ // xx writable: false,
1739
+ get() {
1740
+ return child;
1741
+ }
1742
+ // value: child
1743
+ });
1744
+ }
1745
+ }
1746
+
1747
+ export function getReferenceType(reference: UAReference): UAReferenceType {
1748
+ return (<ReferenceImpl>reference)._referenceType!;
1749
+ }