node-opcua-address-space 2.98.0 → 2.98.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/dist/source/address_space_ts.d.ts +118 -0
  2. package/dist/source/address_space_ts.js +18 -0
  3. package/dist/source/address_space_ts.js.map +1 -0
  4. package/dist/source/continuation_points/continuation_point_manager.d.ts +91 -0
  5. package/dist/source/continuation_points/continuation_point_manager.js +201 -0
  6. package/dist/source/continuation_points/continuation_point_manager.js.map +1 -0
  7. package/dist/source/helpers/adjust_browse_direction.d.ts +5 -0
  8. package/dist/source/helpers/adjust_browse_direction.js +12 -0
  9. package/dist/source/helpers/adjust_browse_direction.js.map +1 -0
  10. package/dist/source/helpers/argument_list.d.ts +33 -0
  11. package/dist/source/helpers/argument_list.js +255 -0
  12. package/dist/source/helpers/argument_list.js.map +1 -0
  13. package/dist/source/helpers/call_helpers.d.ts +6 -0
  14. package/dist/source/helpers/call_helpers.js +72 -0
  15. package/dist/source/helpers/call_helpers.js.map +1 -0
  16. package/dist/source/helpers/coerce_enum_value.d.ts +6 -0
  17. package/dist/source/helpers/coerce_enum_value.js +34 -0
  18. package/dist/source/helpers/coerce_enum_value.js.map +1 -0
  19. package/dist/source/helpers/dump_tools.d.ts +14 -0
  20. package/dist/source/helpers/dump_tools.js +79 -0
  21. package/dist/source/helpers/dump_tools.js.map +1 -0
  22. package/dist/source/helpers/ensure_secure_access.d.ts +9 -0
  23. package/dist/source/helpers/ensure_secure_access.js +77 -0
  24. package/dist/source/helpers/ensure_secure_access.js.map +1 -0
  25. package/dist/source/helpers/make_optionals_map.d.ts +21 -0
  26. package/dist/source/helpers/make_optionals_map.js +30 -0
  27. package/dist/source/helpers/make_optionals_map.js.map +1 -0
  28. package/dist/source/helpers/multiform_func.d.ts +11 -0
  29. package/dist/source/helpers/multiform_func.js +76 -0
  30. package/dist/source/helpers/multiform_func.js.map +1 -0
  31. package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -0
  32. package/dist/source/helpers/resolve_opaque_on_address_space.js +37 -0
  33. package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -0
  34. package/dist/source/index.d.ts +61 -0
  35. package/dist/source/index.js +90 -0
  36. package/dist/source/index.js.map +1 -0
  37. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +19 -0
  38. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +3 -0
  39. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js.map +1 -0
  40. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +193 -0
  41. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js +3 -0
  42. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js.map +1 -0
  43. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.d.ts +12 -0
  44. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js +3 -0
  45. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js.map +1 -0
  46. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.d.ts +10 -0
  47. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js +3 -0
  48. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js.map +1 -0
  49. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.d.ts +7 -0
  50. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js +3 -0
  51. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js.map +1 -0
  52. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.d.ts +7 -0
  53. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js +3 -0
  54. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js.map +1 -0
  55. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.d.ts +4 -0
  56. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js +3 -0
  57. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js.map +1 -0
  58. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.d.ts +4 -0
  59. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js +3 -0
  60. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js.map +1 -0
  61. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.d.ts +9 -0
  62. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js +3 -0
  63. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js.map +1 -0
  64. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.d.ts +4 -0
  65. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js +3 -0
  66. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js.map +1 -0
  67. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.d.ts +4 -0
  68. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js +3 -0
  69. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js.map +1 -0
  70. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.d.ts +20 -0
  71. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js +3 -0
  72. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js.map +1 -0
  73. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +23 -0
  74. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js +3 -0
  75. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js.map +1 -0
  76. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.d.ts +32 -0
  77. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js +3 -0
  78. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js.map +1 -0
  79. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.d.ts +19 -0
  80. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js +3 -0
  81. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js.map +1 -0
  82. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +45 -0
  83. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js +3 -0
  84. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js.map +1 -0
  85. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.d.ts +7 -0
  86. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js +26 -0
  87. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js.map +1 -0
  88. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.d.ts +5 -0
  89. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js +3 -0
  90. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js.map +1 -0
  91. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.d.ts +20 -0
  92. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js +3 -0
  93. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js.map +1 -0
  94. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.d.ts +26 -0
  95. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js +3 -0
  96. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js.map +1 -0
  97. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.d.ts +8 -0
  98. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js +3 -0
  99. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js.map +1 -0
  100. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.d.ts +10 -0
  101. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js +3 -0
  102. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js.map +1 -0
  103. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -0
  104. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +3 -0
  105. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js.map +1 -0
  106. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -0
  107. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +3 -0
  108. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js.map +1 -0
  109. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -0
  110. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +3 -0
  111. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js.map +1 -0
  112. package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -0
  113. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +3 -0
  114. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js.map +1 -0
  115. package/dist/source/interfaces/extension_object_constructor.d.ts +10 -0
  116. package/dist/source/interfaces/extension_object_constructor.js +3 -0
  117. package/dist/source/interfaces/extension_object_constructor.js.map +1 -0
  118. package/dist/source/interfaces/nodeset_loader_options.d.ts +4 -0
  119. package/dist/source/interfaces/nodeset_loader_options.js +3 -0
  120. package/dist/source/interfaces/nodeset_loader_options.js.map +1 -0
  121. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -0
  122. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +3 -0
  123. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js.map +1 -0
  124. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -0
  125. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +3 -0
  126. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js.map +1 -0
  127. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -0
  128. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +3 -0
  129. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js.map +1 -0
  130. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +30 -0
  131. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js +3 -0
  132. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js.map +1 -0
  133. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +234 -0
  134. package/dist/source/interfaces/state_machine/ua_state_machine_type.js +3 -0
  135. package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -0
  136. package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -0
  137. package/dist/source/interfaces/state_machine/ua_transition_ex.js +3 -0
  138. package/dist/source/interfaces/state_machine/ua_transition_ex.js.map +1 -0
  139. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -0
  140. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +3 -0
  141. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js.map +1 -0
  142. package/dist/source/loader/decode_xml_extension_object.d.ts +6 -0
  143. package/dist/source/loader/decode_xml_extension_object.js +72 -0
  144. package/dist/source/loader/decode_xml_extension_object.js.map +1 -0
  145. package/dist/source/loader/ensure_datatype_extracted.d.ts +5 -0
  146. package/dist/source/loader/ensure_datatype_extracted.js +71 -0
  147. package/dist/source/loader/ensure_datatype_extracted.js.map +1 -0
  148. package/dist/source/loader/generateAddressSpaceRaw.d.ts +11 -0
  149. package/dist/source/loader/generateAddressSpaceRaw.js +46 -0
  150. package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -0
  151. package/dist/source/loader/load_nodeset2.d.ts +17 -0
  152. package/dist/source/loader/load_nodeset2.js +1484 -0
  153. package/dist/source/loader/load_nodeset2.js.map +1 -0
  154. package/dist/source/loader/make_semver_compatible.d.ts +6 -0
  155. package/dist/source/loader/make_semver_compatible.js +26 -0
  156. package/dist/source/loader/make_semver_compatible.js.map +1 -0
  157. package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -0
  158. package/dist/source/loader/make_xml_extension_object_parser.js +327 -0
  159. package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -0
  160. package/dist/source/loader/namespace_post_step.d.ts +10 -0
  161. package/dist/source/loader/namespace_post_step.js +62 -0
  162. package/dist/source/loader/namespace_post_step.js.map +1 -0
  163. package/dist/source/loader/register_node_promoter.d.ts +2 -0
  164. package/dist/source/loader/register_node_promoter.js +10 -0
  165. package/dist/source/loader/register_node_promoter.js.map +1 -0
  166. package/dist/source/namespace.d.ts +6 -0
  167. package/dist/source/namespace.js +3 -0
  168. package/dist/source/namespace.js.map +1 -0
  169. package/dist/source/namespace_alarm_and_condition.d.ts +32 -0
  170. package/dist/source/namespace_alarm_and_condition.js +3 -0
  171. package/dist/source/namespace_alarm_and_condition.js.map +1 -0
  172. package/dist/source/namespace_data_access.d.ts +42 -0
  173. package/dist/source/namespace_data_access.js +3 -0
  174. package/dist/source/namespace_data_access.js.map +1 -0
  175. package/dist/source/namespace_machine_state.d.ts +8 -0
  176. package/dist/source/namespace_machine_state.js +3 -0
  177. package/dist/source/namespace_machine_state.js.map +1 -0
  178. package/dist/source/pseudo_session.d.ts +72 -0
  179. package/dist/source/pseudo_session.js +255 -0
  180. package/dist/source/pseudo_session.js.map +1 -0
  181. package/dist/source/session_context.d.ts +111 -0
  182. package/dist/source/session_context.js +265 -0
  183. package/dist/source/session_context.js.map +1 -0
  184. package/dist/source/set_namespace_meta_data.d.ts +2 -0
  185. package/dist/source/set_namespace_meta_data.js +60 -0
  186. package/dist/source/set_namespace_meta_data.js.map +1 -0
  187. package/dist/source/ua_root_folder.d.ts +9 -0
  188. package/dist/source/ua_root_folder.js +3 -0
  189. package/dist/source/ua_root_folder.js.map +1 -0
  190. package/dist/source/ua_two_state_variable_ex.d.ts +23 -0
  191. package/dist/source/ua_two_state_variable_ex.js +3 -0
  192. package/dist/source/ua_two_state_variable_ex.js.map +1 -0
  193. package/dist/source/xml_writer.d.ts +18 -0
  194. package/dist/source/xml_writer.js +3 -0
  195. package/dist/source/xml_writer.js.map +1 -0
  196. package/dist/src/address_space.d.ts +387 -0
  197. package/dist/src/address_space.js +1386 -0
  198. package/dist/src/address_space.js.map +1 -0
  199. package/dist/src/address_space_change_event_tools.d.ts +6 -0
  200. package/dist/src/address_space_change_event_tools.js +153 -0
  201. package/dist/src/address_space_change_event_tools.js.map +1 -0
  202. package/dist/src/address_space_private.d.ts +43 -0
  203. package/dist/src/address_space_private.js +3 -0
  204. package/dist/src/address_space_private.js.map +1 -0
  205. package/dist/src/alarms_and_conditions/condition.d.ts +5 -0
  206. package/dist/src/alarms_and_conditions/condition.js +79 -0
  207. package/dist/src/alarms_and_conditions/condition.js.map +1 -0
  208. package/dist/src/alarms_and_conditions/condition_info_impl.d.ts +26 -0
  209. package/dist/src/alarms_and_conditions/condition_info_impl.js +55 -0
  210. package/dist/src/alarms_and_conditions/condition_info_impl.js.map +1 -0
  211. package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +222 -0
  212. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +658 -0
  213. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -0
  214. package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +9 -0
  215. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +61 -0
  216. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -0
  217. package/dist/src/alarms_and_conditions/index.d.ts +16 -0
  218. package/dist/src/alarms_and_conditions/index.js +33 -0
  219. package/dist/src/alarms_and_conditions/index.js.map +1 -0
  220. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +44 -0
  221. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +245 -0
  222. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -0
  223. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +93 -0
  224. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +419 -0
  225. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -0
  226. package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +26 -0
  227. package/dist/src/alarms_and_conditions/ua_base_event_impl.js +39 -0
  228. package/dist/src/alarms_and_conditions/ua_base_event_impl.js.map +1 -0
  229. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +44 -0
  230. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +184 -0
  231. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -0
  232. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +155 -0
  233. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1029 -0
  234. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -0
  235. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +14 -0
  236. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +35 -0
  237. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -0
  238. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +24 -0
  239. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +57 -0
  240. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js.map +1 -0
  241. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +11 -0
  242. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +12 -0
  243. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js.map +1 -0
  244. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +23 -0
  245. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +87 -0
  246. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -0
  247. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +11 -0
  248. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +8 -0
  249. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js.map +1 -0
  250. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +79 -0
  251. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +251 -0
  252. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -0
  253. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +24 -0
  254. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +51 -0
  255. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js.map +1 -0
  256. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +19 -0
  257. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +163 -0
  258. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -0
  259. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +46 -0
  260. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +166 -0
  261. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -0
  262. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +18 -0
  263. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +18 -0
  264. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js.map +1 -0
  265. package/dist/src/apply_condition_refresh.d.ts +6 -0
  266. package/dist/src/apply_condition_refresh.js +28 -0
  267. package/dist/src/apply_condition_refresh.js.map +1 -0
  268. package/dist/src/base_node_impl.d.ts +284 -0
  269. package/dist/src/base_node_impl.js +1455 -0
  270. package/dist/src/base_node_impl.js.map +1 -0
  271. package/dist/src/base_node_private.d.ts +81 -0
  272. package/dist/src/base_node_private.js +833 -0
  273. package/dist/src/base_node_private.js.map +1 -0
  274. package/dist/src/check_value_rank_compatibility.d.ts +15 -0
  275. package/dist/src/check_value_rank_compatibility.js +82 -0
  276. package/dist/src/check_value_rank_compatibility.js.map +1 -0
  277. package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -0
  278. package/dist/src/data_access/add_dataItem_stuff.js +62 -0
  279. package/dist/src/data_access/add_dataItem_stuff.js.map +1 -0
  280. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -0
  281. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +35 -0
  282. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js.map +1 -0
  283. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -0
  284. package/dist/src/data_access/ua_multistate_discrete_impl.js +131 -0
  285. package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -0
  286. package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +52 -0
  287. package/dist/src/data_access/ua_multistate_value_discrete_impl.js +254 -0
  288. package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -0
  289. package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +25 -0
  290. package/dist/src/data_access/ua_two_state_discrete_impl.js +156 -0
  291. package/dist/src/data_access/ua_two_state_discrete_impl.js.map +1 -0
  292. package/dist/src/event_data.d.ts +34 -0
  293. package/dist/src/event_data.js +65 -0
  294. package/dist/src/event_data.js.map +1 -0
  295. package/dist/src/extension_object_array_node.d.ts +23 -0
  296. package/dist/src/extension_object_array_node.js +249 -0
  297. package/dist/src/extension_object_array_node.js.map +1 -0
  298. package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -0
  299. package/dist/src/historical_access/address_space_historical_data_node.js +653 -0
  300. package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -0
  301. package/dist/src/idx_iterator.d.ts +8 -0
  302. package/dist/src/idx_iterator.js +51 -0
  303. package/dist/src/idx_iterator.js.map +1 -0
  304. package/dist/src/index_current.d.ts +46 -0
  305. package/dist/src/index_current.js +78 -0
  306. package/dist/src/index_current.js.map +1 -0
  307. package/dist/src/namespace_impl.d.ts +456 -0
  308. package/dist/src/namespace_impl.js +1763 -0
  309. package/dist/src/namespace_impl.js.map +1 -0
  310. package/dist/src/namespace_private.d.ts +23 -0
  311. package/dist/src/namespace_private.js +33 -0
  312. package/dist/src/namespace_private.js.map +1 -0
  313. package/dist/src/nodeid_manager.d.ts +37 -0
  314. package/dist/src/nodeid_manager.js +184 -0
  315. package/dist/src/nodeid_manager.js.map +1 -0
  316. package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -0
  317. package/dist/src/nodeset_tools/adjust_namespace_array.js +14 -0
  318. package/dist/src/nodeset_tools/adjust_namespace_array.js.map +1 -0
  319. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +18 -0
  320. package/dist/src/nodeset_tools/construct_namespace_dependency.js +141 -0
  321. package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -0
  322. package/dist/src/nodeset_tools/dump_to_bsd.d.ts +2 -0
  323. package/dist/src/nodeset_tools/dump_to_bsd.js +165 -0
  324. package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -0
  325. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +10 -0
  326. package/dist/src/nodeset_tools/nodeset_to_xml.js +1288 -0
  327. package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -0
  328. package/dist/src/private_namespace.d.ts +5 -0
  329. package/dist/src/private_namespace.js +20 -0
  330. package/dist/src/private_namespace.js.map +1 -0
  331. package/dist/src/reference_impl.d.ts +43 -0
  332. package/dist/src/reference_impl.js +140 -0
  333. package/dist/src/reference_impl.js.map +1 -0
  334. package/dist/src/role_permissions.d.ts +2 -0
  335. package/dist/src/role_permissions.js +11 -0
  336. package/dist/src/role_permissions.js.map +1 -0
  337. package/dist/src/state_machine/finite_state_machine.d.ts +81 -0
  338. package/dist/src/state_machine/finite_state_machine.js +389 -0
  339. package/dist/src/state_machine/finite_state_machine.js.map +1 -0
  340. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +38 -0
  341. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +251 -0
  342. package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -0
  343. package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -0
  344. package/dist/src/state_machine/ua_two_state_variable.js +332 -0
  345. package/dist/src/state_machine/ua_two_state_variable.js.map +1 -0
  346. package/dist/src/tool_isSubtypeOf.d.ts +18 -0
  347. package/dist/src/tool_isSubtypeOf.js +125 -0
  348. package/dist/src/tool_isSubtypeOf.js.map +1 -0
  349. package/dist/src/ua_condition_type.d.ts +8 -0
  350. package/dist/src/ua_condition_type.js +3 -0
  351. package/dist/src/ua_condition_type.js.map +1 -0
  352. package/dist/src/ua_data_type_impl.d.ts +89 -0
  353. package/dist/src/ua_data_type_impl.js +369 -0
  354. package/dist/src/ua_data_type_impl.js.map +1 -0
  355. package/dist/src/ua_method_impl.d.ts +42 -0
  356. package/dist/src/ua_method_impl.js +218 -0
  357. package/dist/src/ua_method_impl.js.map +1 -0
  358. package/dist/src/ua_object_impl.d.ts +35 -0
  359. package/dist/src/ua_object_impl.js +169 -0
  360. package/dist/src/ua_object_impl.js.map +1 -0
  361. package/dist/src/ua_object_type_impl.d.ts +50 -0
  362. package/dist/src/ua_object_type_impl.js +127 -0
  363. package/dist/src/ua_object_type_impl.js.map +1 -0
  364. package/dist/src/ua_reference_type_impl.d.ts +45 -0
  365. package/dist/src/ua_reference_type_impl.js +142 -0
  366. package/dist/src/ua_reference_type_impl.js.map +1 -0
  367. package/dist/src/ua_variable_impl.d.ts +380 -0
  368. package/dist/src/ua_variable_impl.js +1739 -0
  369. package/dist/src/ua_variable_impl.js.map +1 -0
  370. package/dist/src/ua_variable_impl_ext_obj.d.ts +23 -0
  371. package/dist/src/ua_variable_impl_ext_obj.js +671 -0
  372. package/dist/src/ua_variable_impl_ext_obj.js.map +1 -0
  373. package/dist/src/ua_variable_type_impl.d.ts +74 -0
  374. package/dist/src/ua_variable_type_impl.js +598 -0
  375. package/dist/src/ua_variable_type_impl.js.map +1 -0
  376. package/dist/src/ua_view_impl.d.ts +19 -0
  377. package/dist/src/ua_view_impl.js +44 -0
  378. package/dist/src/ua_view_impl.js.map +1 -0
  379. package/dist/tsconfig_common.tsbuildinfo +1 -0
  380. package/distHelpers/add_event_generator_object.d.ts +3 -0
  381. package/{test_helpers/add_event_generator_object.ts → distHelpers/add_event_generator_object.js} +16 -22
  382. package/distHelpers/add_event_generator_object.js.map +1 -0
  383. package/distHelpers/alarms_and_conditions_demo.d.ts +9 -0
  384. package/{test_helpers/alarms_and_conditions_demo.ts → distHelpers/alarms_and_conditions_demo.js} +21 -56
  385. package/distHelpers/alarms_and_conditions_demo.js.map +1 -0
  386. package/distHelpers/assertHasMatchingReference.d.ts +19 -0
  387. package/{test_helpers/assertHasMatchingReference.ts → distHelpers/assertHasMatchingReference.js} +12 -14
  388. package/distHelpers/assertHasMatchingReference.js.map +1 -0
  389. package/distHelpers/boiler_system.d.ts +113 -0
  390. package/{test_helpers/boiler_system.ts → distHelpers/boiler_system.js} +81 -295
  391. package/distHelpers/boiler_system.js.map +1 -0
  392. package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -0
  393. package/{test_helpers/create_minimalist_address_space_nodeset.ts → distHelpers/create_minimalist_address_space_nodeset.js} +51 -87
  394. package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -0
  395. package/distHelpers/date_utils.d.ts +3 -0
  396. package/distHelpers/date_utils.js +10 -0
  397. package/distHelpers/date_utils.js.map +1 -0
  398. package/distHelpers/dump_statemachine.d.ts +0 -0
  399. package/distHelpers/dump_statemachine.js +128 -0
  400. package/distHelpers/dump_statemachine.js.map +1 -0
  401. package/distHelpers/get_address_space_fixture.d.ts +1 -0
  402. package/{test_helpers/get_address_space_fixture.ts → distHelpers/get_address_space_fixture.js} +8 -7
  403. package/distHelpers/get_address_space_fixture.js.map +1 -0
  404. package/distHelpers/get_mini_address_space.d.ts +7 -0
  405. package/distHelpers/get_mini_address_space.js +37 -0
  406. package/distHelpers/get_mini_address_space.js.map +1 -0
  407. package/distHelpers/index.js +29 -0
  408. package/distHelpers/index.js.map +1 -0
  409. package/distHelpers/mock_session.d.ts +10 -0
  410. package/distHelpers/mock_session.js +26 -0
  411. package/distHelpers/mock_session.js.map +1 -0
  412. package/distNodeJS/generate_address_space.d.ts +6 -0
  413. package/distNodeJS/generate_address_space.js +53 -0
  414. package/distNodeJS/generate_address_space.js.map +1 -0
  415. package/distNodeJS/index.js +18 -0
  416. package/distNodeJS/index.js.map +1 -0
  417. package/package.json +49 -38
  418. package/source/helpers/dump_tools.ts +92 -0
  419. package/src/nodeset_tools/dump_to_bsd.ts +198 -0
  420. package/.mocharc.yml +0 -12
  421. package/generate.js +0 -1
  422. package/source_nodejs/generate_address_space.ts +0 -60
  423. package/test_helpers/date_utils.ts +0 -5
  424. package/test_helpers/get_mini_address_space.ts +0 -42
  425. package/test_helpers/mock_session.ts +0 -34
  426. package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +0 -150
  427. package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +0 -57
  428. package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +0 -136
  429. package/test_helpers/test_fixtures/dataType_issue.xml +0 -80
  430. package/test_helpers/test_fixtures/dataType_withEnumeration.xml +0 -82
  431. package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +0 -194
  432. package/test_helpers/test_fixtures/dataType_with_qualifiedname.xml +0 -71
  433. package/test_helpers/test_fixtures/dataType_with_recursive_structure.xml +0 -155
  434. package/test_helpers/test_fixtures/dataType_with_structures.xml +0 -605
  435. package/test_helpers/test_fixtures/dataType_with_union.xml +0 -90
  436. package/test_helpers/test_fixtures/datatype_as_per_1.04.xml +0 -118
  437. package/test_helpers/test_fixtures/datatype_with_allow_subtype.xml +0 -104
  438. package/test_helpers/test_fixtures/eurange_issue.xml +0 -74
  439. package/test_helpers/test_fixtures/example_issue1096.xml +0 -267
  440. package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +0 -106
  441. package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +0 -1305
  442. package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +0 -370
  443. package/test_helpers/test_fixtures/issue_1132_variable_with_nodeid_value.xml +0 -68
  444. package/test_helpers/test_fixtures/issue_846.xml +0 -3172
  445. package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +0 -33
  446. package/test_helpers/test_fixtures/mini.Node.Set2.xml +0 -4736
  447. package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +0 -196
  448. package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +0 -8
  449. package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +0 -20
  450. package/test_helpers/test_fixtures/nodeset_no_aliases.xml +0 -30
  451. package/test_helpers/test_fixtures/nodeset_no_aliases_with_aliases.xml +0 -31
  452. package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +0 -45
  453. package/test_helpers/test_fixtures/nodeset_with_guid.xml +0 -1442
  454. package/test_helpers/test_fixtures/nodeset_with_int64_values.xml +0 -31
  455. package/test_helpers/test_fixtures/nodeset_with_special_char.xml +0 -34
  456. package/test_helpers/test_fixtures/nodeset_with_utf8_special_characters.xml +0 -20
  457. package/test_helpers/test_fixtures/variable_with_value.xml +0 -143
  458. package/test_helpers/test_fixtures/variabletype_with_value.xml +0 -324
  459. /package/{test_helpers/index.ts → distHelpers/index.d.ts} +0 -0
  460. /package/{source_nodejs/index.ts → distNodeJS/index.d.ts} +0 -0
@@ -0,0 +1,1763 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNonEmptyQualifiedName = exports._handle_hierarchy_parent = exports.NamespaceImpl = void 0;
4
+ /**
5
+ * @module node-opcua-address-space
6
+ */
7
+ // tslint:disable:no-console
8
+ const chalk = require("chalk");
9
+ const node_opcua_assert_1 = require("node-opcua-assert");
10
+ const node_opcua_basic_types_1 = require("node-opcua-basic-types");
11
+ const node_opcua_data_access_1 = require("node-opcua-data-access");
12
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
13
+ const node_opcua_data_model_2 = require("node-opcua-data-model");
14
+ const node_opcua_data_model_3 = require("node-opcua-data-model");
15
+ const node_opcua_data_model_4 = require("node-opcua-data-model");
16
+ const node_opcua_debug_1 = require("node-opcua-debug");
17
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
18
+ const node_opcua_nodeid_2 = require("node-opcua-nodeid");
19
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
20
+ const node_opcua_types_1 = require("node-opcua-types");
21
+ const utils = require("node-opcua-utils");
22
+ const node_opcua_variant_1 = require("node-opcua-variant");
23
+ const address_space_change_event_tools_1 = require("./address_space_change_event_tools");
24
+ const ua_condition_impl_1 = require("./alarms_and_conditions/ua_condition_impl");
25
+ const ua_discrete_alarm_impl_1 = require("./alarms_and_conditions/ua_discrete_alarm_impl");
26
+ const ua_exclusive_deviation_alarm_impl_1 = require("./alarms_and_conditions/ua_exclusive_deviation_alarm_impl");
27
+ const ua_exclusive_limit_alarm_impl_1 = require("./alarms_and_conditions/ua_exclusive_limit_alarm_impl");
28
+ const ua_limit_alarm_impl_1 = require("./alarms_and_conditions/ua_limit_alarm_impl");
29
+ const ua_non_exclusive_deviation_alarm_impl_1 = require("./alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl");
30
+ const ua_non_exclusive_limit_alarm_impl_1 = require("./alarms_and_conditions/ua_non_exclusive_limit_alarm_impl");
31
+ const alarms_and_conditions_1 = require("./alarms_and_conditions");
32
+ const ua_off_normal_alarm_impl_1 = require("./alarms_and_conditions/ua_off_normal_alarm_impl");
33
+ const add_dataItem_stuff_1 = require("./data_access/add_dataItem_stuff");
34
+ const ua_multistate_discrete_impl_1 = require("./data_access/ua_multistate_discrete_impl");
35
+ // state machine
36
+ const ua_two_state_variable_1 = require("./state_machine/ua_two_state_variable");
37
+ //
38
+ const namespace_private_1 = require("./namespace_private");
39
+ const base_node_impl_1 = require("./base_node_impl");
40
+ const ua_variable_impl_1 = require("./ua_variable_impl");
41
+ const nodeid_manager_1 = require("./nodeid_manager");
42
+ const ua_two_state_discrete_impl_1 = require("./data_access/ua_two_state_discrete_impl");
43
+ const role_permissions_1 = require("./role_permissions");
44
+ const ua_object_impl_1 = require("./ua_object_impl");
45
+ const ua_data_type_impl_1 = require("./ua_data_type_impl");
46
+ const ua_object_type_impl_1 = require("./ua_object_type_impl");
47
+ const ua_method_impl_1 = require("./ua_method_impl");
48
+ const ua_variable_type_impl_1 = require("./ua_variable_type_impl");
49
+ const ua_reference_type_impl_1 = require("./ua_reference_type_impl");
50
+ const ua_view_impl_1 = require("./ua_view_impl");
51
+ const ua_multistate_value_discrete_impl_1 = require("./data_access/ua_multistate_value_discrete_impl");
52
+ function _makeHashKey(nodeId) {
53
+ switch (nodeId.identifierType) {
54
+ case node_opcua_nodeid_1.NodeIdType.STRING:
55
+ case node_opcua_nodeid_1.NodeIdType.GUID:
56
+ return nodeId.value;
57
+ case node_opcua_nodeid_1.NodeIdType.NUMERIC:
58
+ return nodeId.value;
59
+ default:
60
+ // istanbul ignore next
61
+ if (nodeId.identifierType !== node_opcua_nodeid_1.NodeIdType.BYTESTRING) {
62
+ throw new Error("invalid nodeIdType");
63
+ }
64
+ return nodeId.value ? nodeId.value.toString() : "OPAQUE:0";
65
+ }
66
+ }
67
+ const doDebug = false;
68
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)("AddressSpace");
69
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)("AddressSpace");
70
+ const regExp1 = /^(s|i|b|g)=/;
71
+ const regExpNamespaceDotBrowseName = /^[0-9]+:(.*)/;
72
+ function detachNode(node) {
73
+ const addressSpace = node.addressSpace;
74
+ const nonHierarchicalReferences = node.findReferencesEx("NonHierarchicalReferences", node_opcua_data_model_3.BrowseDirection.Inverse);
75
+ for (const ref of nonHierarchicalReferences) {
76
+ (0, node_opcua_assert_1.assert)(!ref.isForward);
77
+ ref.node.removeReference({
78
+ isForward: !ref.isForward,
79
+ nodeId: node.nodeId,
80
+ referenceType: ref.referenceType
81
+ });
82
+ }
83
+ const nonHierarchicalReferencesF = node.findReferencesEx("NonHierarchicalReferences", node_opcua_data_model_3.BrowseDirection.Forward);
84
+ for (const ref of nonHierarchicalReferencesF) {
85
+ if (!ref.node) {
86
+ // could be a special case of a frequently use target node such as ModellingRule_Mandatory that do not back trace
87
+ // their reference
88
+ continue;
89
+ }
90
+ (0, node_opcua_assert_1.assert)(ref.isForward);
91
+ ref.node.removeReference({
92
+ isForward: !ref.isForward,
93
+ nodeId: node.nodeId,
94
+ referenceType: ref.referenceType
95
+ });
96
+ }
97
+ // remove reversed Hierarchical references
98
+ const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", node_opcua_data_model_3.BrowseDirection.Inverse);
99
+ for (const ref of hierarchicalReferences) {
100
+ (0, node_opcua_assert_1.assert)(!ref.isForward);
101
+ const parent = addressSpace.findNode(ref.nodeId);
102
+ parent.removeReference({
103
+ isForward: !ref.isForward,
104
+ nodeId: node.nodeId,
105
+ referenceType: ref.referenceType
106
+ });
107
+ }
108
+ node.unpropagate_back_references();
109
+ }
110
+ /**
111
+ *
112
+ * @constructor
113
+ * @params options {Object}
114
+ * @params options.namespaceUri {string}
115
+ * @params options.addressSpace {IAddressSpace}
116
+ * @params options.index {number}
117
+ * @params options.version="" {string}
118
+ * @params options.publicationDate="" {Date}
119
+ *
120
+ */
121
+ class NamespaceImpl {
122
+ constructor(options) {
123
+ this.emulateVersion103 = false;
124
+ this.version = "0.0.0";
125
+ this.publicationDate = new Date(Date.UTC(1900, 0, 1));
126
+ this.registerSymbolicNames = false;
127
+ // istanbul ignore next
128
+ if (!(typeof options.namespaceUri === "string")) {
129
+ throw new Error("NamespaceImpl constructor: namespaceUri must exists and be a string : got " + options.namespaceUri);
130
+ }
131
+ // istanbul ignore next
132
+ if (typeof options.index !== "number") {
133
+ throw new Error("NamespaceImpl constructor: index must be a number");
134
+ }
135
+ // istanbul ignore next
136
+ if (!options.addressSpace) {
137
+ throw new Error("NamespaceImpl constructor: Must specify a valid address space");
138
+ }
139
+ this.namespaceUri = options.namespaceUri;
140
+ this.addressSpace = options.addressSpace;
141
+ this.index = options.index;
142
+ this._nodeid_index = new Map();
143
+ this._aliases = new Map();
144
+ this._objectTypeMap = new Map();
145
+ this._variableTypeMap = new Map();
146
+ this._referenceTypeMap = new Map();
147
+ this._referenceTypeMapInv = new Map();
148
+ this._dataTypeMap = new Map();
149
+ this._nodeIdManager = new nodeid_manager_1.NodeIdManager(this.index, this.addressSpace);
150
+ }
151
+ getDefaultNamespace() {
152
+ return this.index === 0 ? this : this.addressSpace.getDefaultNamespace();
153
+ }
154
+ dispose() {
155
+ for (const node of this.nodeIterator()) {
156
+ node.dispose();
157
+ }
158
+ this._nodeid_index = new Map();
159
+ this._aliases = new Map();
160
+ this.addressSpace = {};
161
+ this._objectTypeMap = new Map();
162
+ this._variableTypeMap = new Map();
163
+ this._referenceTypeMap = new Map();
164
+ this._referenceTypeMapInv = new Map();
165
+ this._dataTypeMap = new Map();
166
+ }
167
+ nodeIterator() {
168
+ return this._nodeid_index.values();
169
+ }
170
+ _objectTypeIterator() {
171
+ return this._objectTypeMap.values();
172
+ }
173
+ _objectTypeCount() {
174
+ return this._objectTypeMap.size;
175
+ }
176
+ _variableTypeIterator() {
177
+ return this._variableTypeMap.values();
178
+ }
179
+ _variableTypeCount() {
180
+ return this._variableTypeMap.size;
181
+ }
182
+ _dataTypeIterator() {
183
+ return this._dataTypeMap.values();
184
+ }
185
+ _dataTypeCount() {
186
+ return this._dataTypeMap.size;
187
+ }
188
+ _referenceTypeIterator() {
189
+ return this._referenceTypeMap.values();
190
+ }
191
+ _referenceTypeCount() {
192
+ return this._referenceTypeMap.size;
193
+ }
194
+ _aliasCount() {
195
+ return this._aliases.size;
196
+ }
197
+ findNode2(nodeId) {
198
+ // this one is faster assuming you have a nodeId
199
+ (0, node_opcua_assert_1.assert)(nodeId.namespace === this.index);
200
+ return this._nodeid_index.get(_makeHashKey(nodeId)) || null;
201
+ }
202
+ findNode(nodeId) {
203
+ if (typeof nodeId === "string") {
204
+ if (nodeId.match(regExp1)) {
205
+ nodeId = "ns=" + this.index + ";" + nodeId;
206
+ }
207
+ }
208
+ nodeId = (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
209
+ return this.findNode2(nodeId);
210
+ }
211
+ /**
212
+ *
213
+ * @param objectTypeName {String}
214
+ * @return {UAObjectType|null}
215
+ */
216
+ findObjectType(objectTypeName) {
217
+ return this._objectTypeMap.get(objectTypeName) || null;
218
+ }
219
+ /**
220
+ *
221
+ * @param variableTypeName {String}
222
+ * @returns {UAVariableType|null}
223
+ */
224
+ findVariableType(variableTypeName) {
225
+ return this._variableTypeMap.get(variableTypeName) || null;
226
+ }
227
+ /**
228
+ *
229
+ * @param dataTypeName {String}
230
+ * @returns {UADataType|null}
231
+ */
232
+ findDataType(dataTypeName) {
233
+ return this._dataTypeMap.get(dataTypeName) || null;
234
+ }
235
+ /**
236
+ *
237
+ * @param referenceTypeName {String}
238
+ * @returns {ReferenceType|null}
239
+ */
240
+ findReferenceType(referenceTypeName) {
241
+ return this._referenceTypeMap.get(referenceTypeName) || null;
242
+ }
243
+ /**
244
+ * find a ReferenceType by its inverse name.
245
+ * @method findReferenceTypeFromInverseName
246
+ * @param inverseName {String} the inverse name of the ReferenceType to find
247
+ * @return {ReferenceType}
248
+ */
249
+ findReferenceTypeFromInverseName(inverseName) {
250
+ (0, node_opcua_assert_1.assert)(typeof inverseName === "string");
251
+ const node = this._referenceTypeMapInv.get(inverseName);
252
+ (0, node_opcua_assert_1.assert)(!node || (node.nodeClass === node_opcua_data_model_4.NodeClass.ReferenceType && node.inverseName.text === inverseName));
253
+ return node ? node : null;
254
+ }
255
+ /**
256
+ *
257
+ * @method addAlias
258
+ * @param alias_name {String} the alias name
259
+ * @param nodeId {NodeId} NodeId must belong to this namespace
260
+ */
261
+ addAlias(alias_name, nodeId) {
262
+ (0, node_opcua_assert_1.assert)(typeof alias_name === "string");
263
+ (0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_2.NodeId);
264
+ (0, node_opcua_assert_1.assert)(nodeId.namespace === this.index);
265
+ this._aliases.set(alias_name, nodeId);
266
+ }
267
+ resolveAlias(name) {
268
+ return this._aliases.get(name) || null;
269
+ }
270
+ /**
271
+ * add a new Object type to the address space
272
+ * @method addObjectType
273
+ * @param options
274
+ * @param options.browseName {String} the object type name
275
+ * @param [options.displayName] {String|LocalizedText} the display name
276
+ * @param [options.subtypeOf="BaseObjectType"] {String|NodeId|BaseNode} the base class
277
+ * @param [options.nodeId] {String|NodeId} an optional nodeId for this objectType,
278
+ * if not provided a new nodeId will be created
279
+ * @param [options.isAbstract = false] {Boolean}
280
+ * @param [options.eventNotifier = 0] {Integer}
281
+ * @param [options.postInstantiateFunc = null] {Function}
282
+ *
283
+ */
284
+ addObjectType(options) {
285
+ (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "dataType"), "an objectType should not have a dataType");
286
+ (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "valueRank"), "an objectType should not have a valueRank");
287
+ (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "arrayDimensions"), "an objectType should not have a arrayDimensions");
288
+ return this._addObjectOrVariableType(options, "BaseObjectType", node_opcua_data_model_4.NodeClass.ObjectType);
289
+ }
290
+ /**
291
+ * add a new Variable type to the address space
292
+ * @method addVariableType
293
+ * @param options
294
+ * @param options.browseName {String} the object type name
295
+ * @param [options.displayName] {String|LocalizedText} the display name
296
+ * @param [options.subtypeOf="BaseVariableType"] {String|NodeId|BaseNode} the base class
297
+ * @param [options.nodeId] {String|NodeId} an optional nodeId for this objectType,
298
+ * if not provided a new nodeId will be created
299
+ * @param [options.isAbstract = false] {Boolean}
300
+ * @param options.dataType {String|NodeId} the variable DataType
301
+ * @param [options.valueRank = -1]
302
+ * @param [options.arrayDimensions = null] { Array<Int>>
303
+ *
304
+ */
305
+ addVariableType(options) {
306
+ (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "arrayDimension"), "Do you mean ArrayDimensions ?");
307
+ // dataType
308
+ options.dataType = options.dataType || "Int32";
309
+ options.dataType = this.addressSpace._coerce_DataType(options.dataType);
310
+ // valueRank/ arrayDimensions
311
+ (0, node_opcua_variant_1.verifyRankAndDimensions)(options);
312
+ // arrayDimensions
313
+ const variableType = this._addObjectOrVariableType(options, "BaseVariableType", node_opcua_data_model_4.NodeClass.VariableType);
314
+ variableType.dataType = options.dataType;
315
+ variableType.valueRank = options.valueRank || 0;
316
+ variableType.arrayDimensions = options.arrayDimensions;
317
+ return variableType;
318
+ }
319
+ /**
320
+ * add a variable as a component of the parent node
321
+ */
322
+ addVariable(options) {
323
+ (0, node_opcua_assert_1.assert)(arguments.length === 1, "Invalid arguments IAddressSpace#addVariable now takes only one argument.");
324
+ if (Object.prototype.hasOwnProperty.call(options, "propertyOf") && options.propertyOf) {
325
+ (0, node_opcua_assert_1.assert)(!options.typeDefinition || options.typeDefinition === "PropertyType");
326
+ options.typeDefinition = options.typeDefinition || "PropertyType";
327
+ }
328
+ else {
329
+ (0, node_opcua_assert_1.assert)(!options.typeDefinition || options.typeDefinition !== "PropertyType");
330
+ }
331
+ return this._addVariable(options);
332
+ }
333
+ addView(options) {
334
+ (0, node_opcua_assert_1.assert)(arguments.length === 1, "Namespace#addView expecting a single argument");
335
+ (0, node_opcua_assert_1.assert)(options);
336
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "browseName"));
337
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "organizedBy"));
338
+ const browseName = options.browseName;
339
+ (0, node_opcua_assert_1.assert)(typeof browseName === "string");
340
+ const addressSpace = this.addressSpace;
341
+ const baseDataVariableTypeId = addressSpace.findVariableType("BaseDataVariableType").nodeId;
342
+ // ------------------------------------------ TypeDefinition
343
+ const typeDefinition = options.typeDefinition || baseDataVariableTypeId;
344
+ options.references = options.references || [];
345
+ options.references.push({
346
+ isForward: true,
347
+ nodeId: typeDefinition,
348
+ referenceType: "HasTypeDefinition"
349
+ });
350
+ const createOptions = options;
351
+ (0, node_opcua_assert_1.assert)(!createOptions.nodeClass);
352
+ createOptions.nodeClass = node_opcua_data_model_4.NodeClass.View;
353
+ const view = this.createNode(createOptions);
354
+ (0, node_opcua_assert_1.assert)(view.nodeId instanceof node_opcua_nodeid_2.NodeId);
355
+ (0, node_opcua_assert_1.assert)(view.nodeClass === node_opcua_data_model_4.NodeClass.View);
356
+ return view;
357
+ }
358
+ addObject(options1) {
359
+ const options = options1;
360
+ (0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_4.NodeClass.Object);
361
+ options.nodeClass = node_opcua_data_model_4.NodeClass.Object;
362
+ const typeDefinition = options.typeDefinition || "BaseObjectType";
363
+ options.references = options.references || [];
364
+ options.references.push({ referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition });
365
+ options.eventNotifier = +options.eventNotifier;
366
+ const obj = this.createNode(options);
367
+ (0, node_opcua_assert_1.assert)(obj instanceof ua_object_impl_1.UAObjectImpl);
368
+ (0, node_opcua_assert_1.assert)(obj.nodeClass === node_opcua_data_model_4.NodeClass.Object);
369
+ return obj;
370
+ }
371
+ /**
372
+ *
373
+ * @method addFolder
374
+ * @param parentFolder
375
+ * @param options {String|Object}
376
+ * @param options.browseName {String} the name of the folder
377
+ * @param [options.nodeId] {NodeId}. An optional nodeId for this object
378
+ *
379
+ * @return {BaseNode}
380
+ */
381
+ addFolder(parentFolder, options) {
382
+ if (typeof options === "string") {
383
+ options = { browseName: options };
384
+ }
385
+ const addressSpace = this.addressSpace;
386
+ (0, node_opcua_assert_1.assert)(!options.typeDefinition, "addFolder does not expect typeDefinition to be defined ");
387
+ const typeDefinition = addressSpace._coerceTypeDefinition("FolderType");
388
+ parentFolder = addressSpace._coerceFolder(parentFolder);
389
+ options.nodeClass = node_opcua_data_model_4.NodeClass.Object;
390
+ options.references = [
391
+ { referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition },
392
+ { referenceType: "Organizes", isForward: false, nodeId: parentFolder.nodeId }
393
+ ];
394
+ const node = this.createNode(options);
395
+ return node;
396
+ }
397
+ /**
398
+ * @method addReferenceType
399
+ * @param options
400
+ * @param options.isAbstract
401
+ * @param options.browseName
402
+ * @param options.inverseName
403
+ */
404
+ addReferenceType(options) {
405
+ const addressSpace = this.addressSpace;
406
+ const options1 = options;
407
+ options1.nodeClass = node_opcua_data_model_4.NodeClass.ReferenceType;
408
+ options1.references = options.references || [];
409
+ options1.nodeId = options.nodeId;
410
+ if (options.subtypeOf) {
411
+ const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References", node_opcua_data_model_4.NodeClass.ReferenceType);
412
+ (0, node_opcua_assert_1.assert)(subtypeOfNodeId);
413
+ options1.references.push({
414
+ isForward: false,
415
+ nodeId: subtypeOfNodeId,
416
+ referenceType: "HasSubtype"
417
+ });
418
+ }
419
+ const node = this.internalCreateNode(options1);
420
+ node.propagate_back_references();
421
+ return node;
422
+ }
423
+ /**
424
+ */
425
+ addMultiStateDiscrete(options) {
426
+ return (0, ua_multistate_discrete_impl_1._addMultiStateDiscrete)(this, options);
427
+ }
428
+ /**
429
+ * @method createDataType
430
+ */
431
+ createDataType(options) {
432
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "isAbstract"), "must provide isAbstract");
433
+ (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "nodeClass"));
434
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "browseName"), "must provide a browseName");
435
+ const options1 = options;
436
+ options1.nodeClass = node_opcua_data_model_4.NodeClass.DataType;
437
+ options1.references = options.references || [];
438
+ if (options1.references.length === 0) {
439
+ if (!options1.subtypeOf) {
440
+ throw new Error("must provide a subtypeOf");
441
+ }
442
+ }
443
+ if (options1.subtypeOf) {
444
+ if (!(options1.subtypeOf instanceof ua_data_type_impl_1.UADataTypeImpl)) {
445
+ options1.subtypeOf = this.addressSpace.findDataType(options1.subtypeOf);
446
+ }
447
+ if (!options1.subtypeOf) {
448
+ throw new Error("cannot find subtypeOf ");
449
+ }
450
+ options1.references.push({
451
+ isForward: false,
452
+ nodeId: options1.subtypeOf.nodeId,
453
+ referenceType: "HasSubtype"
454
+ });
455
+ }
456
+ const node = this.internalCreateNode(options);
457
+ node.propagate_back_references();
458
+ return node;
459
+ }
460
+ /**
461
+ * @method createNode
462
+ * @param options
463
+ * @param options.nodeClass
464
+ * @param [options.nodeVersion {String} = "0" ] install nodeVersion
465
+ * @param [options.modellingRule {String} = null]
466
+ * @internal
467
+ */
468
+ createNode(options) {
469
+ let node = null;
470
+ const addressSpace = this.addressSpace;
471
+ addressSpace.modelChangeTransaction(() => {
472
+ (0, node_opcua_assert_1.assert)(isNonEmptyQualifiedName(options.browseName));
473
+ // xx assert(Object.prototype.hasOwnProperty.call(options,"browseName") && options.browseName.length > 0);
474
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "nodeClass"));
475
+ options.references = addressSpace.normalizeReferenceTypes(options.references);
476
+ const references = _copy_references(options.references);
477
+ _handle_hierarchy_parent(addressSpace, references, options);
478
+ _handle_event_hierarchy_parent(addressSpace, references, options);
479
+ (0, namespace_private_1.UANamespace_process_modelling_rule)(references, options.modellingRule);
480
+ options.references = references;
481
+ node = this.internalCreateNode(options);
482
+ (0, node_opcua_assert_1.assert)(node.nodeId instanceof node_opcua_nodeid_2.NodeId);
483
+ node.propagate_back_references();
484
+ node.install_extra_properties();
485
+ _create_node_version_if_needed(node, options);
486
+ (0, address_space_change_event_tools_1._handle_model_change_event)(node);
487
+ });
488
+ return node;
489
+ }
490
+ /**
491
+ * remove the specified Node from the address space
492
+ *
493
+ * @method deleteNode
494
+ * @param nodeOrNodeId
495
+ *
496
+ *
497
+ */
498
+ deleteNode(nodeOrNodeId) {
499
+ let node = null;
500
+ let nodeId = new node_opcua_nodeid_2.NodeId();
501
+ if (nodeOrNodeId instanceof node_opcua_nodeid_2.NodeId) {
502
+ nodeId = nodeOrNodeId;
503
+ node = this.findNode(nodeId);
504
+ // istanbul ignore next
505
+ if (!node) {
506
+ throw new Error(" deleteNode : cannot find node with nodeId" + nodeId.toString());
507
+ }
508
+ }
509
+ else if (nodeOrNodeId instanceof base_node_impl_1.BaseNodeImpl) {
510
+ node = nodeOrNodeId;
511
+ nodeId = node.nodeId;
512
+ }
513
+ // istanbul ignore next
514
+ if (nodeId.namespace !== this.index) {
515
+ throw new Error("this node doesn't belong to this namespace");
516
+ }
517
+ const addressSpace = this.addressSpace;
518
+ addressSpace.modelChangeTransaction(() => {
519
+ /* istanbul ignore next */
520
+ if (!node) {
521
+ throw new Error("this node doesn't belong to this namespace");
522
+ }
523
+ // notify parent that node is being removed
524
+ const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", node_opcua_data_model_3.BrowseDirection.Inverse);
525
+ for (const ref of hierarchicalReferences) {
526
+ (0, node_opcua_assert_1.assert)(!ref.isForward);
527
+ const parent = addressSpace.findNode(ref.nodeId);
528
+ (0, node_opcua_assert_1.assert)(parent);
529
+ parent._on_child_removed(node);
530
+ }
531
+ function deleteNodePointedByReference(ref) {
532
+ const o = addressSpace.findNode(ref.nodeId);
533
+ addressSpace.deleteNode(o.nodeId);
534
+ }
535
+ // recursively delete all nodes below in the hierarchy of nodes
536
+ // TODO : a better idea would be to extract any references of type "HasChild"
537
+ const components = node.findReferencesEx("HasComponent", node_opcua_data_model_3.BrowseDirection.Forward);
538
+ const properties = node.findReferencesEx("HasProperty", node_opcua_data_model_3.BrowseDirection.Forward);
539
+ // TODO: shall we delete nodes pointed by "Organizes" links here ?
540
+ const subFolders = node.findReferencesEx("Organizes", node_opcua_data_model_3.BrowseDirection.Forward);
541
+ for (const r of components) {
542
+ deleteNodePointedByReference(r);
543
+ }
544
+ for (const r of properties) {
545
+ deleteNodePointedByReference(r);
546
+ }
547
+ for (const r of subFolders) {
548
+ deleteNodePointedByReference(r);
549
+ }
550
+ (0, address_space_change_event_tools_1._handle_delete_node_model_change_event)(node);
551
+ detachNode(node);
552
+ // delete nodes from global index
553
+ const namespace = addressSpace.getNamespace(node.nodeId.namespace);
554
+ namespace._deleteNode(node);
555
+ });
556
+ }
557
+ /**
558
+ * @internals
559
+ */
560
+ getStandardsNodeIds() {
561
+ const standardNodeIds = {
562
+ objectTypeIds: {},
563
+ referenceTypeIds: {}
564
+ };
565
+ for (const referenceType of this._referenceTypeMap.values()) {
566
+ standardNodeIds.referenceTypeIds[referenceType.browseName.name] = referenceType.nodeId.toString();
567
+ }
568
+ for (const objectType of this._objectTypeMap.values()) {
569
+ standardNodeIds.objectTypeIds[objectType.browseName.name] = objectType.nodeId.toString();
570
+ }
571
+ return standardNodeIds;
572
+ }
573
+ // - Events --------------------------------------------------------------------------------------
574
+ /**
575
+ * add a new event type to the address space
576
+ * @method addEventType
577
+ * @param options
578
+ * @param options.browseName {String} the eventType name
579
+ * @param [options.subtypeOf ="BaseEventType"]
580
+ * @param [options.isAbstract = true]
581
+ * @return {UAObjectType} : the object type
582
+ *
583
+ * @example
584
+ *
585
+ * var evtType = namespace.addEventType({
586
+ * browseName: "MyAuditEventType",
587
+ * subtypeOf: "AuditEventType"
588
+ * });
589
+ * var myConditionType = namespace.addEventType({
590
+ * browseName: "MyConditionType",
591
+ * subtypeOf: "ConditionType",
592
+ * isAbstract: false
593
+ * });
594
+ *
595
+ */
596
+ addEventType(options) {
597
+ options.subtypeOf = options.subtypeOf || "BaseEventType";
598
+ // are eventType always abstract ?? No => Condition can be instantiated!
599
+ // but, by default is abstract is true
600
+ options.isAbstract = Object.prototype.hasOwnProperty.call(options, "isAbstract") ? !!options.isAbstract : true;
601
+ return this.addObjectType(options);
602
+ }
603
+ // ---------------------------------------------------------------------------------------------------
604
+ /**
605
+ * @method addDataItem
606
+ * @param options
607
+ * @param options.browseName {String}
608
+ * @param options.definition {String}
609
+ * @param [options.valuePrecision {Double |null} =null]
610
+ * @param options.dataType {NodeId} // todo :check
611
+ * @param options.value
612
+ * @param options.componentOf
613
+ * @return {UAVariable}
614
+ */
615
+ addDataItem(options) {
616
+ const addressSpace = this.addressSpace;
617
+ const dataType = options.dataType || "Number";
618
+ const dataItemType = addressSpace.findVariableType("DataItemType");
619
+ if (!dataItemType) {
620
+ throw new Error("Cannot find DataItemType");
621
+ }
622
+ const variable = this.addVariable(Object.assign(Object.assign({}, options), { dataType, typeDefinition: dataItemType.nodeId }));
623
+ (0, add_dataItem_stuff_1.add_dataItem_stuff)(variable, options);
624
+ variable.install_extra_properties();
625
+ return variable;
626
+ }
627
+ /**
628
+ *
629
+ * @method addAnalogDataItem
630
+ *
631
+ * AnalogDataItem DataItems that represent continuously-variable physical quantities ( e.g., length, temperature),
632
+ * in contrast to the digital representation of data in discrete items
633
+ * NOTE Typical examples are the values provided by temperature sensors or pressure sensors. OPC UA defines a
634
+ * specific UAVariableType to identify an AnalogItem. Properties describe the possible ranges of AnalogItems.
635
+ *
636
+ *
637
+ * @example:
638
+ *
639
+ *
640
+ * namespace.add_analog_dataItem({
641
+ * componentOf: parentObject,
642
+ * browseName: "TemperatureSensor",
643
+ *
644
+ * definition: "(tempA -25) + tempB",
645
+ * valuePrecision: 0.5,
646
+ * //-
647
+ * instrumentRange: { low: 100 , high: 200}, // optional
648
+ * engineeringUnitsRange: { low: 100 , high: 200}, // mandatory
649
+ * engineeringUnits: standardUnits.degree_celsius,, // optional
650
+ *
651
+ * // access level
652
+ * accessLevel: 1
653
+ * minimumSamplingInterval: 10,
654
+ *
655
+ * });
656
+ *
657
+
658
+ * @return {UAVariable}
659
+ */
660
+ addAnalogDataItem(options) {
661
+ const addressSpace = this.addressSpace;
662
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
663
+ const dataType = options.dataType || "Number";
664
+ const analogItemType = addressSpace.findVariableType("AnalogItemType");
665
+ if (!analogItemType) {
666
+ throw new Error("expecting AnalogItemType to be defined , check nodeset xml file");
667
+ }
668
+ const clone_options = Object.assign(Object.assign({}, options), { dataType, typeDefinition: analogItemType.nodeId });
669
+ const variable = this.addVariable(clone_options);
670
+ (0, add_dataItem_stuff_1.add_dataItem_stuff)(variable, options);
671
+ // mandatory (EURange in the specs)
672
+ // OPC Unified Architecture, Part 8 6 Release 1.02
673
+ // EURange defines the value range likely to be obtained in normal operation. It is intended for such
674
+ // use as automatically scaling a bar graph display
675
+ // Sensor or instrument failure or deactivation can result in a return ed item value which is actually
676
+ // outside of this range. Client software must be prepared to deal with this possibility. Similarly a client
677
+ // may attempt to write a value that is outside of this range back to the server. The exact behavior
678
+ // (accept, reject, clamp, etc.) in this case is server - dependent. However , in general servers shall be
679
+ // prepared to handle this.
680
+ // Example: EURange ::= {-200.0,1400.0}
681
+ const euRange = this.addVariable({
682
+ browseName: { name: "EURange", namespaceIndex: 0 },
683
+ dataType: "Range",
684
+ minimumSamplingInterval: 0,
685
+ modellingRule: options.modellingRule,
686
+ propertyOf: variable,
687
+ typeDefinition: "PropertyType",
688
+ value: new node_opcua_variant_1.Variant({
689
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
690
+ value: new node_opcua_types_1.Range(options.engineeringUnitsRange)
691
+ })
692
+ });
693
+ (0, node_opcua_assert_1.assert)(euRange.readValue().value.value instanceof node_opcua_types_1.Range);
694
+ const handler = variable.handle_semantic_changed.bind(variable);
695
+ euRange.on("value_changed", handler);
696
+ if (Object.prototype.hasOwnProperty.call(options, "instrumentRange")) {
697
+ const instrumentRange = this.addVariable({
698
+ accessLevel: "CurrentRead | CurrentWrite",
699
+ browseName: { name: "InstrumentRange", namespaceIndex: 0 },
700
+ dataType: "Range",
701
+ minimumSamplingInterval: 0,
702
+ modellingRule: options.modellingRule ? "Mandatory" : undefined,
703
+ propertyOf: variable,
704
+ typeDefinition: "PropertyType",
705
+ value: new node_opcua_variant_1.Variant({
706
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
707
+ value: new node_opcua_types_1.Range(options.instrumentRange)
708
+ })
709
+ });
710
+ instrumentRange.on("value_changed", handler);
711
+ }
712
+ if (Object.prototype.hasOwnProperty.call(options, "engineeringUnits")) {
713
+ const engineeringUnits = new node_opcua_types_1.EUInformation(options.engineeringUnits);
714
+ (0, node_opcua_assert_1.assert)(engineeringUnits instanceof node_opcua_types_1.EUInformation, "expecting engineering units");
715
+ // EngineeringUnits specifies the units for the DataItem‟s value (e.g., degree, hertz, seconds). The
716
+ // EUInformation type is specified in 5.6.3.
717
+ const eu = this.addVariable({
718
+ accessLevel: "CurrentRead",
719
+ browseName: { name: "EngineeringUnits", namespaceIndex: 0 },
720
+ dataType: "EUInformation",
721
+ minimumSamplingInterval: 0,
722
+ modellingRule: options.modellingRule ? "Mandatory" : undefined,
723
+ propertyOf: variable,
724
+ typeDefinition: "PropertyType",
725
+ value: new node_opcua_variant_1.Variant({
726
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
727
+ value: engineeringUnits
728
+ })
729
+ });
730
+ eu.on("value_changed", handler);
731
+ }
732
+ variable.install_extra_properties();
733
+ return variable;
734
+ }
735
+ /**
736
+ *
737
+ * @method addMultiStateValueDiscrete
738
+ * @param options {Object}
739
+ * @param options.browseName {String}
740
+ * @param [options.nodeId {NodeId}]
741
+ * @param [options.value {UInt32} = 0 }
742
+ * @param options.enumValues { EnumValueType[]| {Key,Value} }
743
+ * @return {Object|UAVariable}
744
+ *
745
+ * @example
746
+ *
747
+ *
748
+ * namespace.addMultiStateValueDiscrete({
749
+ * componentOf:parentObj,
750
+ * browseName: "myVar",
751
+ * enumValues: {
752
+ * "Red": 0xFF0000,
753
+ * "Green": 0x00FF00,
754
+ * "Blue": 0x0000FF
755
+ * }
756
+ * });
757
+ * addMultiStateValueDiscrete(parentObj,{
758
+ * browseName: "myVar",
759
+ * enumValues: [
760
+ * {
761
+ * value: 0xFF0000,
762
+ * displayName: "Red",
763
+ * description: " The color Red"
764
+ * },
765
+ * {
766
+ * value: 0x00FF000,
767
+ * displayName: "Green",
768
+ * description: " The color Green"
769
+ * },
770
+ * {
771
+ * value: 0x0000FF,
772
+ * displayName: "Blue",
773
+ * description: " The color Blue"
774
+ * }
775
+ *
776
+ * ]
777
+ * });
778
+ */
779
+ addMultiStateValueDiscrete(options) {
780
+ return (0, ua_multistate_value_discrete_impl_1._addMultiStateValueDiscrete)(this, options);
781
+ }
782
+ // -
783
+ /**
784
+ *
785
+ * @method addYArrayItem
786
+ * @param options
787
+ * @param options.componentOf {NodeId}
788
+ * @param options.browseName {String}
789
+ * @param options.title {String}
790
+ * @param [options.instrumentRange]
791
+ * @param [options.instrumentRange.low] {Double}
792
+ * @param [options.instrumentRange.high] {Double}
793
+ * @param options.engineeringUnitsRange.low {Double}
794
+ * @param options.engineeringUnitsRange.high {Double}
795
+ * @param options.engineeringUnits {String}
796
+ * @param [options.nodeId = {NodeId}]
797
+ * @param options.accessLevel
798
+ * @param options.userAccessLevel
799
+ * @param options.title {String}
800
+ * @param options.axisScaleType {AxisScaleEnumeration}
801
+ *
802
+ * @param options.xAxisDefinition {AxisInformation}
803
+ * @param options.xAxisDefinition.engineeringUnits EURange
804
+ * @param options.xAxisDefinition.range
805
+ * @param options.xAxisDefinition.range.low
806
+ * @param options.xAxisDefinition.range.high
807
+ * @param options.xAxisDefinition.title {LocalizedText}
808
+ * @param options.xAxisDefinition.axisScaleType {AxisScaleEnumeration}
809
+ * @param options.xAxisDefinition.axisSteps = <null> {Array<Double>}
810
+ * @param options.value
811
+ */
812
+ addYArrayItem(options) {
813
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
814
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "axisScaleType"), "expecting axisScaleType");
815
+ (0, node_opcua_assert_1.assert)(options.xAxisDefinition !== null && typeof options.xAxisDefinition === "object", "expecting a xAxisDefinition");
816
+ const addressSpace = this.addressSpace;
817
+ const YArrayItemType = addressSpace.findVariableType("YArrayItemType");
818
+ if (!YArrayItemType) {
819
+ throw new Error("expecting YArrayItemType to be defined , check nodeset xml file");
820
+ }
821
+ function toNodeId(options) {
822
+ if (!options) {
823
+ return (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_variant_1.DataType.Float);
824
+ }
825
+ if (Object.prototype.hasOwnProperty.call(options, "nodeId") || options instanceof base_node_impl_1.BaseNodeImpl) {
826
+ return options.nodeId;
827
+ }
828
+ return (0, node_opcua_nodeid_1.resolveNodeId)(options);
829
+ }
830
+ const dataType = toNodeId(options.dataType);
831
+ const optionals = [];
832
+ if (Object.prototype.hasOwnProperty.call(options, "instrumentRange")) {
833
+ optionals.push("InstrumentRange");
834
+ }
835
+ const variable = YArrayItemType.instantiate({
836
+ browseName: options.browseName,
837
+ componentOf: options.componentOf,
838
+ dataType,
839
+ optionals
840
+ });
841
+ function coerceAxisScale(value) {
842
+ const ret = node_opcua_data_access_1.AxisScaleEnumeration[value];
843
+ (0, node_opcua_assert_1.assert)(!utils.isNullOrUndefined(ret));
844
+ return ret;
845
+ }
846
+ variable.setValueFromSource(options.value, node_opcua_status_code_1.StatusCodes.Good);
847
+ variable.euRange.setValueFromSource(new node_opcua_variant_1.Variant({
848
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
849
+ value: new node_opcua_types_1.Range(options.engineeringUnitsRange)
850
+ }));
851
+ if (Object.prototype.hasOwnProperty.call(options, "instrumentRange") && variable.instrumentRange) {
852
+ variable.instrumentRange.setValueFromSource(new node_opcua_variant_1.Variant({
853
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
854
+ value: new node_opcua_types_1.Range(options.instrumentRange)
855
+ }));
856
+ }
857
+ variable.title.setValueFromSource(new node_opcua_variant_1.Variant({
858
+ dataType: node_opcua_variant_1.DataType.LocalizedText,
859
+ value: (0, node_opcua_data_model_1.coerceLocalizedText)(options.title || "")
860
+ }));
861
+ // Linear/Log/Ln
862
+ variable.axisScaleType.setValueFromSource(new node_opcua_variant_1.Variant({
863
+ dataType: node_opcua_variant_1.DataType.Int32,
864
+ value: coerceAxisScale(options.axisScaleType)
865
+ }));
866
+ variable.xAxisDefinition.setValueFromSource(new node_opcua_variant_1.Variant({
867
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
868
+ value: new node_opcua_types_1.AxisInformation(options.xAxisDefinition)
869
+ }));
870
+ return variable;
871
+ }
872
+ // - Methods ----------------------------------------------------------------------------------------------------
873
+ /**
874
+ * @method addMethod
875
+ * @param parentObject {Object}
876
+ * @param options {Object}
877
+ * @param [options.nodeId=null] {NodeId} the object nodeid.
878
+ * @param [options.browseName=""] {String} the object browse name.
879
+ * @param [options.description=""] {String} the object description.
880
+ * @param options.inputArguments {Array<Argument>}
881
+ * @param options.outputArguments {Array<Argument>}
882
+ * @return {Object}
883
+ */
884
+ addMethod(parentObject, options) {
885
+ const addressSpace = this.addressSpace;
886
+ (0, node_opcua_assert_1.assert)(parentObject !== null && typeof parentObject === "object" && parentObject instanceof base_node_impl_1.BaseNodeImpl, "expecting a valid parent object");
887
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "browseName"));
888
+ options.componentOf = parentObject;
889
+ const method = this._addMethod(options);
890
+ const propertyTypeId = addressSpace._coerce_VariableTypeIds("PropertyType");
891
+ const nodeId_ArgumentDataType = "Argument"; // makeNodeId(DataTypeIds.Argument);
892
+ if (options.inputArguments) {
893
+ const _inputArgs = new node_opcua_variant_1.Variant({
894
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
895
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
896
+ value: options.inputArguments.map((opt) => new node_opcua_types_1.Argument(opt))
897
+ });
898
+ const inputArguments = this.addVariable({
899
+ accessLevel: "CurrentRead",
900
+ arrayDimensions: [_inputArgs.value.length],
901
+ browseName: { name: "InputArguments", namespaceIndex: 0 },
902
+ dataType: nodeId_ArgumentDataType,
903
+ description: "the definition of the input argument of method " +
904
+ parentObject.browseName.toString() +
905
+ "." +
906
+ method.browseName.toString(),
907
+ minimumSamplingInterval: -1,
908
+ modellingRule: "Mandatory",
909
+ propertyOf: method,
910
+ typeDefinition: "PropertyType",
911
+ value: _inputArgs,
912
+ valueRank: 1
913
+ });
914
+ inputArguments.setValueFromSource(_inputArgs);
915
+ (0, node_opcua_assert_1.assert)(inputArguments.typeDefinition.toString() === propertyTypeId.toString());
916
+ (0, node_opcua_assert_1.assert)(Array.isArray(inputArguments.arrayDimensions));
917
+ }
918
+ if (options.outputArguments) {
919
+ const _outputArgs = new node_opcua_variant_1.Variant({
920
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
921
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
922
+ value: options.outputArguments.map((opts) => new node_opcua_types_1.Argument(opts))
923
+ });
924
+ const outputArguments = this.addVariable({
925
+ accessLevel: "CurrentRead",
926
+ arrayDimensions: [_outputArgs.value.length],
927
+ browseName: { name: "OutputArguments", namespaceIndex: 0 },
928
+ dataType: nodeId_ArgumentDataType,
929
+ description: "the definition of the output arguments of method " +
930
+ parentObject.browseName.toString() +
931
+ "." +
932
+ method.browseName.toString(),
933
+ minimumSamplingInterval: -1,
934
+ modellingRule: "Mandatory",
935
+ propertyOf: method,
936
+ typeDefinition: "PropertyType",
937
+ value: _outputArgs,
938
+ valueRank: 1
939
+ });
940
+ outputArguments.setValueFromSource(_outputArgs);
941
+ (0, node_opcua_assert_1.assert)(outputArguments.typeDefinition.toString() === propertyTypeId.toString());
942
+ (0, node_opcua_assert_1.assert)(Array.isArray(outputArguments.arrayDimensions));
943
+ }
944
+ // verifying post-conditions
945
+ parentObject.install_extra_properties();
946
+ return method;
947
+ }
948
+ // - Enumeration ------------------------------------------------------------------------------------------------
949
+ /**
950
+ *
951
+ * @method addEnumerationType
952
+ * @param options
953
+ * @param options.browseName {String}
954
+ * @param options.enumeration {Array}
955
+ * @param options.enumeration[].displayName {String|LocalizedText}
956
+ * @param options.enumeration[].value {Number}
957
+ * @param options.enumeration[].description {String|LocalizedText|null}
958
+ */
959
+ addEnumerationType(options) {
960
+ // Release 1.03 OPC Unified Architecture, Part 3 - page 34
961
+ // Enumeration DataTypes are DataTypes that represent discrete sets of named values.
962
+ // Enumerations are always encoded as Int32 on the wire as defined in Part 6. Enumeration
963
+ // DataTypes inherit directly or indirectly from the DataType Enumeration defined in 8.14.
964
+ // Enumerations have no encodings exposed in the IAddressSpace. To expose the human readable
965
+ // representation of an enumerated value the DataType Node may have the EnumString
966
+ // Property that contains an array of LocalizedText. The Integer representation of the enumeration
967
+ // value points to a position within that array. EnumValues Property can be used instead of the
968
+ // EnumStrings to support integer representation of enumerations that are not zero-based or have
969
+ // gaps. It contains an array of a Structured DataType containing the integer representation as
970
+ // well as the human-readable representation. An example of an enumeration DataType containing
971
+ // a sparse list of Integers is NodeClass which is defined in 8.30.
972
+ // OPC Unified Architecture, Part 3 Release 1.03 page 35
973
+ // Table 11 – DataType NodeClass
974
+ // EnumStrings O LocalizedText[] The EnumStrings Property only applies for Enumeration DataTypes.
975
+ // It shall not be applied for other DataTypes. If the EnumValues
976
+ // Property is provided, the EnumStrings Property shall not be provided.
977
+ // Each entry of the array of LocalizedText in this Property represents
978
+ // the human-readable representation of an enumerated value. The
979
+ // Integer representation of the enumeration value points to a position
980
+ // of the array.
981
+ // EnumValues O EnumValueType[] The EnumValues Property only applies for Enumeration DataTypes.
982
+ // It shall not be applied for other DataTypes. If the EnumStrings
983
+ // Property is provided, the EnumValues Property shall not be provided.
984
+ // Using the EnumValues Property it is possible to represent.
985
+ // Enumerations with integers that are not zero-based or have gaps
986
+ // (e.g. 1, 2, 4, 8, 16).
987
+ // Each entry of the array of EnumValueType in this Property
988
+ // represents one enumeration value with its integer notation, human readable
989
+ // representation and help information.
990
+ // The Property EnumStrings contains human-readable representations of enumeration values and is
991
+ // only applied to Enumeration DataTypes. Instead of the EnumStrings Property an Enumeration
992
+ // DataType can also use the EnumValues Property to represent Enumerations with integer values that are not
993
+ // zero-based or containing gaps. There are no additional Properties defined for DataTypes in this standard.
994
+ // Additional parts of this series of standards may define additional Properties for DataTypes.
995
+ // 8.40 EnumValueType
996
+ // This Structured DataType is used to represent a human-readable representation of an
997
+ // Enumeration. Its elements are described inTable 27. When this type is used in an array representing
998
+ // human-readable representations of an enumeration, each Value shall be unique in that array.
999
+ // Table 27 – EnumValueType Definition
1000
+ // Name Type Description
1001
+ // EnumValueType structure
1002
+ // Value Int64 The Integer representation of an Enumeration.
1003
+ // DisplayName LocalizedText A human-readable representation of the Value of the Enumeration.
1004
+ // Description LocalizedText A localized description of the enumeration value. This field can
1005
+ // contain an empty string if no description is available.
1006
+ // Note that the EnumValueType has been defined with a Int64 Value to meet a variety of usages.
1007
+ // When it is used to define the string representation of an Enumeration DataType, the value range
1008
+ // is limited to Int32, because the Enumeration DataType is a subtype of Int32. Part 8 specifies
1009
+ // other usages where the actual value might be between 8 and 64 Bit.
1010
+ (0, node_opcua_assert_1.assert)(typeof options.browseName === "string");
1011
+ (0, node_opcua_assert_1.assert)(Array.isArray(options.enumeration));
1012
+ const addressSpace = this.addressSpace;
1013
+ let definition;
1014
+ const enumerationType = addressSpace.findDataType("Enumeration");
1015
+ (0, node_opcua_assert_1.assert)(enumerationType.nodeId instanceof node_opcua_nodeid_2.NodeId);
1016
+ (0, node_opcua_assert_1.assert)(enumerationType instanceof ua_data_type_impl_1.UADataTypeImpl);
1017
+ const references = [{ referenceType: "HasSubtype", isForward: false, nodeId: enumerationType.nodeId }];
1018
+ const opts = {
1019
+ browseName: options.browseName,
1020
+ definition,
1021
+ description: (0, node_opcua_data_model_1.coerceLocalizedText)(options.description) || null,
1022
+ displayName: options.displayName || null,
1023
+ isAbstract: false,
1024
+ nodeClass: node_opcua_data_model_4.NodeClass.DataType,
1025
+ references
1026
+ };
1027
+ const enumType = this.internalCreateNode(opts); // as UAEnumeration;
1028
+ enumType.propagate_back_references();
1029
+ if (typeof options.enumeration[0] === "string") {
1030
+ const enumeration = options.enumeration;
1031
+ // enumeration is a array of string
1032
+ definition = enumeration.map((str, index) => (0, node_opcua_data_model_1.coerceLocalizedText)(str));
1033
+ const value = new node_opcua_variant_1.Variant({
1034
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
1035
+ dataType: node_opcua_variant_1.DataType.LocalizedText,
1036
+ value: definition
1037
+ });
1038
+ const enumStrings = this.addVariable({
1039
+ browseName: { name: "EnumStrings", namespaceIndex: 0 },
1040
+ dataType: "LocalizedText",
1041
+ description: "",
1042
+ modellingRule: "Mandatory",
1043
+ propertyOf: enumType,
1044
+ value,
1045
+ valueRank: 1
1046
+ });
1047
+ (0, node_opcua_assert_1.assert)(enumStrings.browseName.toString() === "EnumStrings");
1048
+ // set $definition
1049
+ // EnumDefinition
1050
+ // This Structured DataType is used to provide the metadata for a custom Enumeration or
1051
+ // OptionSet DataType. It is derived from the DataType DataTypeDefinition.
1052
+ // Enum Field:
1053
+ // This Structured DataType is used to provide the metadata for a field of a custom Enumeration
1054
+ // or OptionSet DataType. It is derived from the DataType EnumValueType. If used for an
1055
+ // OptionSet, the corresponding Value in the base type contains the number of the bit associated
1056
+ // with the field. The EnumField is formally defined in Table 37.
1057
+ enumType.$fullDefinition = new node_opcua_types_1.EnumDefinition({
1058
+ fields: enumeration.map((x, index) => new node_opcua_types_1.EnumField({
1059
+ name: x,
1060
+ description: (0, node_opcua_data_model_1.coerceLocalizedText)(x),
1061
+ value: (0, node_opcua_basic_types_1.coerceInt64)(index)
1062
+ }))
1063
+ });
1064
+ }
1065
+ else {
1066
+ const enumeration = options.enumeration;
1067
+ // construct the definition object
1068
+ definition = enumeration.map((enumItem) => {
1069
+ return new node_opcua_types_1.EnumValueType({
1070
+ description: (0, node_opcua_data_model_1.coerceLocalizedText)(enumItem.description),
1071
+ displayName: (0, node_opcua_data_model_1.coerceLocalizedText)(enumItem.displayName),
1072
+ value: [0, enumItem.value]
1073
+ });
1074
+ });
1075
+ const value = new node_opcua_variant_1.Variant({
1076
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
1077
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
1078
+ value: definition
1079
+ });
1080
+ const enumValues = this.addVariable({
1081
+ browseName: { name: "EnumValues", namespaceIndex: 0 },
1082
+ dataType: "EnumValueType",
1083
+ description: undefined,
1084
+ modellingRule: "Mandatory",
1085
+ propertyOf: enumType,
1086
+ value,
1087
+ valueRank: 1
1088
+ });
1089
+ (0, node_opcua_assert_1.assert)(enumValues.browseName.toString() === "EnumValues");
1090
+ enumType.$fullDefinition = new node_opcua_types_1.EnumDefinition({
1091
+ fields: enumeration.map((x, index) => new node_opcua_types_1.EnumField({
1092
+ name: x.displayName.toString(),
1093
+ description: x.description || "",
1094
+ value: (0, node_opcua_basic_types_1.coerceInt64)(x.value)
1095
+ }))
1096
+ });
1097
+ }
1098
+ // now create the string value property
1099
+ // <UAVariable NodeId="i=7612" BrowseName="EnumStrings"
1100
+ // ParentNodeId="i=852" DataType="LocalizedText" ValueRank="1">
1101
+ // <DisplayName>EnumStrings</DisplayName>
1102
+ // <References>
1103
+ // <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
1104
+ // <Reference ReferenceType="HasModellingRule">i=78</Reference>
1105
+ // <Reference ReferenceType="HasProperty" IsForward="false">i=852</Reference>
1106
+ // </References>
1107
+ // <Value>
1108
+ // <ListOfLocalizedText xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
1109
+ // <LocalizedText><Locale></Locale><Text>Running</Text></LocalizedText>
1110
+ // <LocalizedText><Locale></Locale><Text>Failed</Text>
1111
+ // </ListOfLocalizedText>
1112
+ // </Value>
1113
+ // </UAVariable>
1114
+ return enumType;
1115
+ }
1116
+ // -------------------------------------------------------------------------
1117
+ // State and Transition
1118
+ // -------------------------------------------------------------------------
1119
+ toNodeset2XML() {
1120
+ return "<toNodeset2XML>has not be installed</toNodeset2XML>!";
1121
+ }
1122
+ setRequiredModels(requiredModels) {
1123
+ this._requiredModels = requiredModels;
1124
+ }
1125
+ getRequiredModels() {
1126
+ return this._requiredModels;
1127
+ }
1128
+ // -------------------------------------------------------------------------
1129
+ // State and Transition
1130
+ // -------------------------------------------------------------------------
1131
+ /**
1132
+ * @class IAddressSpace
1133
+ * @method addState
1134
+ * @param component
1135
+ * @param stateName {string}
1136
+ * @param stateNumber {number}
1137
+ * @param isInitialState {boolean}
1138
+ * @return {UAObject} {StateType|InitialStateType}
1139
+ */
1140
+ addState(component, stateName, stateNumber, isInitialState) {
1141
+ const addressSpace = this.addressSpace;
1142
+ isInitialState = !!isInitialState;
1143
+ const _component = component;
1144
+ (0, node_opcua_assert_1.assert)(_component.nodeClass === node_opcua_data_model_4.NodeClass.Object || _component.nodeClass === node_opcua_data_model_4.NodeClass.ObjectType);
1145
+ const initialStateType = addressSpace.findObjectType("InitialStateType");
1146
+ const stateType = addressSpace.findObjectType("StateType");
1147
+ let state;
1148
+ if (isInitialState) {
1149
+ state = initialStateType.instantiate({
1150
+ browseName: stateName,
1151
+ componentOf: _component
1152
+ });
1153
+ }
1154
+ else {
1155
+ state = stateType.instantiate({
1156
+ browseName: stateName,
1157
+ componentOf: _component
1158
+ });
1159
+ }
1160
+ // ensure state number is unique
1161
+ state.stateNumber.setValueFromSource({
1162
+ dataType: node_opcua_variant_1.DataType.UInt32,
1163
+ value: stateNumber
1164
+ });
1165
+ return state;
1166
+ }
1167
+ /**
1168
+ */
1169
+ addTransition(component, fromState, toState, transitionNumber, browseName) {
1170
+ const addressSpace = this.addressSpace;
1171
+ const _component = component;
1172
+ (0, node_opcua_assert_1.assert)(_component.nodeClass === node_opcua_data_model_4.NodeClass.Object || _component.nodeClass === node_opcua_data_model_4.NodeClass.ObjectType);
1173
+ (0, node_opcua_assert_1.assert)(typeof fromState === "string");
1174
+ (0, node_opcua_assert_1.assert)(typeof toState === "string");
1175
+ (0, node_opcua_assert_1.assert)(isFinite(transitionNumber));
1176
+ const fromStateNode = _component.getComponentByName(fromState);
1177
+ // istanbul ignore next
1178
+ if (!fromStateNode) {
1179
+ throw new Error("Cannot find state with name " + fromState);
1180
+ }
1181
+ (0, node_opcua_assert_1.assert)(fromStateNode.browseName.name.toString() === fromState);
1182
+ const toStateNode = _component.getComponentByName(toState);
1183
+ // istanbul ignore next
1184
+ if (!toStateNode) {
1185
+ throw new Error("Cannot find state with name " + toState);
1186
+ }
1187
+ (0, node_opcua_assert_1.assert)(toStateNode.browseName.name.toString() === toState);
1188
+ const transitionType = addressSpace.findObjectType("TransitionType");
1189
+ if (!transitionType) {
1190
+ throw new Error("Cannot find TransitionType");
1191
+ }
1192
+ browseName = browseName || fromState + "To" + toState; // "Transition";
1193
+ const transition = transitionType.instantiate({
1194
+ browseName,
1195
+ componentOf: _component
1196
+ });
1197
+ transition.addReference({
1198
+ isForward: true,
1199
+ nodeId: toStateNode.nodeId,
1200
+ referenceType: "ToState"
1201
+ });
1202
+ transition.addReference({
1203
+ isForward: true,
1204
+ nodeId: fromStateNode.nodeId,
1205
+ referenceType: "FromState"
1206
+ });
1207
+ transition.transitionNumber.setValueFromSource({
1208
+ dataType: node_opcua_variant_1.DataType.UInt32,
1209
+ value: transitionNumber
1210
+ });
1211
+ return transition;
1212
+ }
1213
+ /**
1214
+ * @method addTwoStateVariable
1215
+ *
1216
+ * @return {UATwoStateVariable}
1217
+ */
1218
+ addTwoStateVariable(options) {
1219
+ return (0, ua_two_state_variable_1._addTwoStateVariable)(this, options);
1220
+ }
1221
+ /**
1222
+ * @method addTwoStateDiscrete
1223
+ *
1224
+ * Add a TwoStateDiscrete Variable
1225
+ * @return {UATwoStateDiscrete}
1226
+ */
1227
+ addTwoStateDiscrete(options) {
1228
+ return (0, ua_two_state_discrete_impl_1._addTwoStateDiscrete)(this, options);
1229
+ }
1230
+ // --- Alarms & Conditions -------------------------------------------------
1231
+ instantiateCondition(conditionTypeId, options, data) {
1232
+ return ua_condition_impl_1.UAConditionImpl.instantiate(this, conditionTypeId, options, data);
1233
+ }
1234
+ instantiateAcknowledgeableCondition(conditionTypeId, options, data) {
1235
+ return alarms_and_conditions_1.UAAcknowledgeableConditionImpl.instantiate(this, conditionTypeId, options, data);
1236
+ }
1237
+ instantiateAlarmCondition(alarmConditionTypeId, options, data) {
1238
+ return alarms_and_conditions_1.UAAlarmConditionImpl.instantiate(this, alarmConditionTypeId, options, data);
1239
+ }
1240
+ instantiateLimitAlarm(limitAlarmTypeId, options, data) {
1241
+ return ua_limit_alarm_impl_1.UALimitAlarmImpl.instantiate(this, limitAlarmTypeId, options, data);
1242
+ }
1243
+ instantiateExclusiveLimitAlarm(exclusiveLimitAlarmTypeId, options, data) {
1244
+ return ua_exclusive_limit_alarm_impl_1.UAExclusiveLimitAlarmImpl.instantiate(this, exclusiveLimitAlarmTypeId, options, data);
1245
+ }
1246
+ instantiateExclusiveDeviationAlarm(options, data) {
1247
+ return ua_exclusive_deviation_alarm_impl_1.UAExclusiveDeviationAlarmImpl.instantiate(this, "ExclusiveDeviationAlarmType", options, data);
1248
+ }
1249
+ instantiateNonExclusiveLimitAlarm(nonExclusiveLimitAlarmTypeId, options, data) {
1250
+ return ua_non_exclusive_limit_alarm_impl_1.UANonExclusiveLimitAlarmImpl.instantiate(this, nonExclusiveLimitAlarmTypeId, options, data);
1251
+ }
1252
+ instantiateNonExclusiveDeviationAlarm(options, data) {
1253
+ return ua_non_exclusive_deviation_alarm_impl_1.UANonExclusiveDeviationAlarmImpl.instantiate(this, "NonExclusiveDeviationAlarmType", options, data);
1254
+ }
1255
+ instantiateDiscreteAlarm(discreteAlarmType, options, data) {
1256
+ return ua_discrete_alarm_impl_1.UADiscreteAlarmImpl.instantiate(this, discreteAlarmType, options, data);
1257
+ }
1258
+ instantiateOffNormalAlarm(options, data) {
1259
+ return ua_off_normal_alarm_impl_1.UAOffNormalAlarmImpl.instantiate(this, "OffNormalAlarmType", options, data);
1260
+ }
1261
+ // default roles and permissions
1262
+ setDefaultRolePermissions(rolePermissions) {
1263
+ this.defaultRolePermissions = rolePermissions ? (0, role_permissions_1.coerceRolePermissions)(rolePermissions) : undefined;
1264
+ }
1265
+ getDefaultRolePermissions() {
1266
+ return this.defaultRolePermissions || null;
1267
+ }
1268
+ setDefaultAccessRestrictions(accessRestrictions) {
1269
+ this.defaultAccessRestrictions = accessRestrictions;
1270
+ }
1271
+ getDefaultAccessRestrictions() {
1272
+ return this.defaultAccessRestrictions || node_opcua_data_model_1.AccessRestrictionsFlag.None;
1273
+ }
1274
+ // --- internal stuff
1275
+ constructNodeId(options) {
1276
+ return this._nodeIdManager.constructNodeId(Object.assign({ registerSymbolicNames: this.registerSymbolicNames }, options));
1277
+ }
1278
+ _register(node) {
1279
+ var _a;
1280
+ (0, node_opcua_assert_1.assert)(node instanceof base_node_impl_1.BaseNodeImpl, "Expecting a instance of BaseNode in _register");
1281
+ (0, node_opcua_assert_1.assert)(node.nodeId instanceof node_opcua_nodeid_2.NodeId, "Expecting a NodeId");
1282
+ // istanbul ignore next
1283
+ if (node.nodeId.namespace !== this.index) {
1284
+ throw new Error("node must belongs to this namespace");
1285
+ }
1286
+ (0, node_opcua_assert_1.assert)(node.nodeId.namespace === this.index, "node must belongs to this namespace");
1287
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(node, "browseName"), "Node must have a browseName");
1288
+ const hashKey = _makeHashKey(node.nodeId);
1289
+ // istanbul ignore next
1290
+ if (this._nodeid_index.has(hashKey)) {
1291
+ const exstingNode = this.findNode(node.nodeId);
1292
+ throw new Error("node " +
1293
+ node.browseName.toString() +
1294
+ " nodeId = " +
1295
+ node.nodeId.displayText() +
1296
+ " already registered " +
1297
+ node.nodeId.toString() +
1298
+ "\n" +
1299
+ " in namespace " +
1300
+ this.namespaceUri +
1301
+ " index = " +
1302
+ this.index +
1303
+ "\n" +
1304
+ "existing node = " +
1305
+ exstingNode.toString() +
1306
+ "this parent : " + ((_a = node.parentNodeId) === null || _a === void 0 ? void 0 : _a.toString()));
1307
+ }
1308
+ this._nodeid_index.set(hashKey, node);
1309
+ switch (node.nodeClass) {
1310
+ case node_opcua_data_model_4.NodeClass.ObjectType:
1311
+ this._registerObjectType(node);
1312
+ break;
1313
+ case node_opcua_data_model_4.NodeClass.VariableType:
1314
+ this._registerVariableType(node);
1315
+ break;
1316
+ case node_opcua_data_model_4.NodeClass.ReferenceType:
1317
+ this._registerReferenceType(node);
1318
+ break;
1319
+ case node_opcua_data_model_4.NodeClass.DataType:
1320
+ this._registerDataType(node);
1321
+ break;
1322
+ case node_opcua_data_model_4.NodeClass.Object:
1323
+ case node_opcua_data_model_4.NodeClass.Variable:
1324
+ case node_opcua_data_model_4.NodeClass.Method:
1325
+ case node_opcua_data_model_4.NodeClass.View:
1326
+ break;
1327
+ default:
1328
+ // tslint:disable-next-line:no-console
1329
+ console.log("Invalid class Name", node.nodeClass);
1330
+ throw new Error("Invalid class name specified");
1331
+ }
1332
+ }
1333
+ /**
1334
+ * @method internalCreateNode
1335
+ * @internal
1336
+ */
1337
+ internalCreateNode(options) {
1338
+ (0, node_opcua_assert_1.assert)(options.nodeClass !== undefined, " options.nodeClass must be specified");
1339
+ (0, node_opcua_assert_1.assert)(options.browseName, "options.browseName must be specified");
1340
+ // xx assert(options.browseName instanceof QualifiedName
1341
+ // ? (options.browseName.namespaceIndex === this.index): true,
1342
+ // "Expecting browseName to have the same namespaceIndex as the namespace");
1343
+ options.description = (0, node_opcua_data_model_1.coerceLocalizedText)(options.description);
1344
+ // browseName adjustment
1345
+ if (typeof options.browseName === "string") {
1346
+ const match = options.browseName.match(regExpNamespaceDotBrowseName);
1347
+ if (match) {
1348
+ const correctedName = match[1];
1349
+ // the application is using an old scheme
1350
+ console.log(chalk.green("Warning : since node-opcua 0.4.2 " + "namespace index should not be prepended to the browse name anymore"));
1351
+ console.log(" ", options.browseName, " will be replaced with ", correctedName);
1352
+ console.log(" Please update your code");
1353
+ const indexVerif = parseInt(match[0], 10);
1354
+ if (indexVerif !== this.index) {
1355
+ errorLog(chalk.red.bold("Error: namespace index used at the front of the browseName " +
1356
+ indexVerif +
1357
+ " do not match the index of the current namespace (" +
1358
+ this.index +
1359
+ ")"));
1360
+ errorLog(" Please fix your code so that the created node is inserted in the correct namespace," +
1361
+ " please refer to the NodeOPCUA documentation");
1362
+ }
1363
+ }
1364
+ options.browseName = new node_opcua_data_model_2.QualifiedName({ name: options.browseName, namespaceIndex: this.index });
1365
+ }
1366
+ else if (!(options.browseName instanceof node_opcua_data_model_2.QualifiedName)) {
1367
+ options.browseName = new node_opcua_data_model_2.QualifiedName(options.browseName);
1368
+ }
1369
+ (0, node_opcua_assert_1.assert)(options.browseName instanceof node_opcua_data_model_2.QualifiedName, "Expecting options.browseName to be instanceof QualifiedName ");
1370
+ // ------------- set display name
1371
+ if (!options.displayName) {
1372
+ (0, node_opcua_assert_1.assert)(typeof options.browseName.name === "string");
1373
+ options.displayName = options.browseName.name;
1374
+ }
1375
+ // --- nodeId adjustment
1376
+ options.nodeId = this.constructNodeId(options);
1377
+ (0, node_opcua_debug_1.dumpIf)(!options.nodeId, options); // missing node Id
1378
+ (0, node_opcua_assert_1.assert)(options.nodeId instanceof node_opcua_nodeid_2.NodeId);
1379
+ // assert(options.browseName.namespaceIndex === this.index,"Expecting browseName to have
1380
+ // the same namespaceIndex as the namespace");
1381
+ const Constructor = _constructors_map[node_opcua_data_model_4.NodeClass[options.nodeClass]];
1382
+ if (!Constructor) {
1383
+ throw new Error(" missing constructor for NodeClass " + node_opcua_data_model_4.NodeClass[options.nodeClass]);
1384
+ }
1385
+ options.addressSpace = this.addressSpace;
1386
+ const node = new Constructor(options);
1387
+ this._register(node);
1388
+ // object shall now be registered
1389
+ // istanbul ignore next
1390
+ if (doDebug) {
1391
+ (0, node_opcua_assert_1.assert)(this.findNode(node.nodeId) !== null && typeof this.findNode(node.nodeId) === "object");
1392
+ }
1393
+ return node;
1394
+ }
1395
+ _deleteNode(node) {
1396
+ (0, node_opcua_assert_1.assert)(node instanceof base_node_impl_1.BaseNodeImpl);
1397
+ const hashKey = _makeHashKey(node.nodeId);
1398
+ // istanbul ignore next
1399
+ if (!this._nodeid_index.has(hashKey)) {
1400
+ throw new Error("deleteNode : nodeId " + node.nodeId.displayText() + " is not registered " + node.nodeId.toString());
1401
+ }
1402
+ switch (node.nodeClass) {
1403
+ case node_opcua_data_model_4.NodeClass.ObjectType:
1404
+ this._unregisterObjectType(node);
1405
+ break;
1406
+ case node_opcua_data_model_4.NodeClass.VariableType:
1407
+ this._unregisterVariableType(node);
1408
+ break;
1409
+ case node_opcua_data_model_4.NodeClass.Object:
1410
+ case node_opcua_data_model_4.NodeClass.Variable:
1411
+ case node_opcua_data_model_4.NodeClass.Method:
1412
+ case node_opcua_data_model_4.NodeClass.View:
1413
+ break;
1414
+ default:
1415
+ // tslint:disable:no-console
1416
+ console.log("Invalid class Name", node.nodeClass);
1417
+ throw new Error("Invalid class name specified");
1418
+ }
1419
+ const deleted = this._nodeid_index.delete(hashKey);
1420
+ (0, node_opcua_assert_1.assert)(deleted);
1421
+ node.dispose();
1422
+ }
1423
+ // --- Private stuff
1424
+ _addObjectOrVariableType(options1, topMostBaseType, nodeClass) {
1425
+ const addressSpace = this.addressSpace;
1426
+ (0, node_opcua_assert_1.assert)(typeof topMostBaseType === "string");
1427
+ (0, node_opcua_assert_1.assert)(nodeClass === node_opcua_data_model_4.NodeClass.ObjectType || nodeClass === node_opcua_data_model_4.NodeClass.VariableType);
1428
+ const options = options1;
1429
+ (0, node_opcua_assert_1.assert)(!options.nodeClass);
1430
+ (0, node_opcua_assert_1.assert)(options.browseName);
1431
+ (0, node_opcua_assert_1.assert)(typeof options.browseName === "string");
1432
+ if (Object.prototype.hasOwnProperty.call(options, "references")) {
1433
+ throw new Error("options.references should not be provided, use options.subtypeOf instead");
1434
+ }
1435
+ const references = [];
1436
+ function process_subtypeOf_options(options2, references1) {
1437
+ // check common misspelling mistake
1438
+ (0, node_opcua_assert_1.assert)(!options2.subTypeOf, "misspell error : it should be 'subtypeOf' instead");
1439
+ if (Object.prototype.hasOwnProperty.call(options2, "hasTypeDefinition")) {
1440
+ throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
1441
+ }
1442
+ (0, node_opcua_assert_1.assert)(!options2.typeDefinition, " do you mean subtypeOf ?");
1443
+ const subtypeOfNodeId = addressSpace._coerceType(options2.subtypeOf, topMostBaseType, nodeClass);
1444
+ (0, node_opcua_assert_1.assert)(subtypeOfNodeId);
1445
+ references1.push({
1446
+ isForward: false,
1447
+ nodeId: subtypeOfNodeId,
1448
+ referenceType: "HasSubtype"
1449
+ });
1450
+ }
1451
+ process_subtypeOf_options.call(this, options, references);
1452
+ const objectType = this.internalCreateNode({
1453
+ browseName: options.browseName,
1454
+ displayName: options.displayName,
1455
+ description: options.description,
1456
+ eventNotifier: +options.eventNotifier,
1457
+ isAbstract: !!options.isAbstract,
1458
+ nodeClass,
1459
+ nodeId: options.nodeId,
1460
+ references
1461
+ });
1462
+ objectType.propagate_back_references();
1463
+ objectType.install_extra_properties();
1464
+ objectType.installPostInstallFunc(options.postInstantiateFunc);
1465
+ return objectType;
1466
+ }
1467
+ // private _adjust_options(options: any) {
1468
+ // const ns = this.addressSpace.getNamespaceIndex(this.namespaceUri);
1469
+ // if (!options.nodeId) {
1470
+ // const id = this._getNextAvailableId();
1471
+ // options.nodeId = new NodeId(NodeId.NodeIdType.NUMERIC, id, ns);
1472
+ // }
1473
+ // options.nodeId = NodeId.coerce(options.nodeId);
1474
+ // if (typeof options.browseName === "string") {
1475
+ // options.browseName = new QualifiedName({
1476
+ // name: options.browseName,
1477
+ // namespaceIndex: ns
1478
+ // });
1479
+ // }
1480
+ // return options;
1481
+ // }
1482
+ _registerObjectType(node) {
1483
+ (0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
1484
+ const key = node.browseName.name;
1485
+ if (this._objectTypeMap.has(key)) {
1486
+ throw new Error(" UAObjectType already declared " + node.browseName.toString() + " " + node.nodeId.toString());
1487
+ }
1488
+ this._objectTypeMap.set(key, node);
1489
+ }
1490
+ _registerVariableType(node) {
1491
+ (0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
1492
+ const key = node.browseName.name;
1493
+ (0, node_opcua_assert_1.assert)(!this._variableTypeMap.has(key), " UAVariableType already declared");
1494
+ this._variableTypeMap.set(key, node);
1495
+ }
1496
+ _registerReferenceType(node) {
1497
+ (0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
1498
+ (0, node_opcua_assert_1.assert)(node.browseName instanceof node_opcua_data_model_2.QualifiedName);
1499
+ const key = node.browseName.name;
1500
+ this._referenceTypeMap.set(key, node);
1501
+ this._referenceTypeMapInv.set(node.inverseName.text, node);
1502
+ }
1503
+ _registerDataType(node) {
1504
+ (0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
1505
+ const key = node.browseName.name;
1506
+ (0, node_opcua_assert_1.assert)(node.browseName instanceof node_opcua_data_model_2.QualifiedName);
1507
+ (0, node_opcua_assert_1.assert)(!this._dataTypeMap.has(key), " DataType already declared");
1508
+ this._dataTypeMap.set(key, node);
1509
+ }
1510
+ _unregisterObjectType(node) {
1511
+ const key = node.browseName.name;
1512
+ this._objectTypeMap.delete(key);
1513
+ }
1514
+ _unregisterVariableType(node) {
1515
+ const key = node.browseName.name;
1516
+ this._variableTypeMap.delete(key);
1517
+ }
1518
+ /**
1519
+ * @private
1520
+ */
1521
+ _addVariable(options) {
1522
+ const addressSpace = this.addressSpace;
1523
+ const baseDataVariableType = addressSpace.findVariableType("BaseDataVariableType");
1524
+ if (!baseDataVariableType) {
1525
+ throw new Error("cannot find BaseDataVariableType");
1526
+ }
1527
+ const baseDataVariableTypeId = baseDataVariableType.nodeId;
1528
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "browseName"), "options.browseName must be provided");
1529
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "dataType"), "options.dataType must be provided");
1530
+ options.historizing = !!options.historizing;
1531
+ // istanbul ignore next
1532
+ if (Object.prototype.hasOwnProperty.call(options, "hasTypeDefinition")) {
1533
+ throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
1534
+ }
1535
+ // ------------------------------------------ TypeDefinition
1536
+ let typeDefinition = options.typeDefinition || baseDataVariableTypeId;
1537
+ if (typeDefinition instanceof base_node_impl_1.BaseNodeImpl) {
1538
+ // istanbul ignore next
1539
+ if (typeDefinition.nodeClass !== node_opcua_data_model_4.NodeClass.VariableType) {
1540
+ const message = `invalid typeDefinition expecting a VariableType got ${node_opcua_data_model_4.NodeClass[typeDefinition.nodeClass]}`;
1541
+ errorLog(message);
1542
+ throw new Error(message);
1543
+ }
1544
+ }
1545
+ typeDefinition = addressSpace._coerce_VariableTypeIds(typeDefinition);
1546
+ (0, node_opcua_assert_1.assert)(typeDefinition instanceof node_opcua_nodeid_2.NodeId);
1547
+ // ------------------------------------------ DataType
1548
+ options.dataType = addressSpace._coerce_DataType(options.dataType);
1549
+ options.valueRank = utils.isNullOrUndefined(options.valueRank)
1550
+ ? options.arrayDimensions
1551
+ ? options.arrayDimensions.length
1552
+ : -1
1553
+ : options.valueRank;
1554
+ (0, node_opcua_assert_1.assert)(typeof options.valueRank === "number" && isFinite(options.valueRank));
1555
+ options.arrayDimensions = options.arrayDimensions || null;
1556
+ (0, node_opcua_assert_1.assert)(Array.isArray(options.arrayDimensions) || options.arrayDimensions === null);
1557
+ // -----------------------------------------------------
1558
+ const hasGetter = (options) => {
1559
+ var _a, _b;
1560
+ return typeof ((_a = options.value) === null || _a === void 0 ? void 0 : _a.get) === "function" || typeof ((_b = options.value) === null || _b === void 0 ? void 0 : _b.timestamped_get) === "function";
1561
+ };
1562
+ // istanbul ignore next
1563
+ if (options.minimumSamplingInterval === undefined && hasGetter(options)) {
1564
+ // a getter has been specified and no options.minimumSamplingInterval has been specified
1565
+ warningLog("[NODE-OPCUA-W30", "namespace#addVariable a getter has been specified and minimumSamplingInterval is missing.\nMinimumSamplingInterval has been adjusted to 1000 ms");
1566
+ options.minimumSamplingInterval = 1000;
1567
+ }
1568
+ options.minimumSamplingInterval = options.minimumSamplingInterval !== undefined ? +options.minimumSamplingInterval : 0;
1569
+ // istanbul ignore next
1570
+ if (options.minimumSamplingInterval === 0 && hasGetter(options)) {
1571
+ warningLog("[NODE-OPCUA-W31", "namespace#addVariable a getter has been specified and minimumSamplingInterval is 0.\nThis may conduct to an unpredicable behavior.\nPlease specify a non zero minimum sampling interval");
1572
+ }
1573
+ let references = options.references || [];
1574
+ references = [].concat(references, [
1575
+ {
1576
+ isForward: true,
1577
+ nodeId: typeDefinition,
1578
+ referenceType: "HasTypeDefinition"
1579
+ }
1580
+ ]);
1581
+ (0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_4.NodeClass.Variable);
1582
+ options.nodeClass = node_opcua_data_model_4.NodeClass.Variable;
1583
+ options.references = references;
1584
+ const variable = this.createNode(options);
1585
+ return variable;
1586
+ }
1587
+ /**
1588
+ * @private
1589
+ */
1590
+ _addMethod(options) {
1591
+ const addressSpace = this.addressSpace;
1592
+ (0, node_opcua_assert_1.assert)(isNonEmptyQualifiedName(options.browseName));
1593
+ const references = [];
1594
+ (0, node_opcua_assert_1.assert)(isNonEmptyQualifiedName(options.browseName));
1595
+ _handle_hierarchy_parent(addressSpace, references, options);
1596
+ (0, namespace_private_1.UANamespace_process_modelling_rule)(references, options.modellingRule);
1597
+ const method = this.internalCreateNode({
1598
+ browseName: options.browseName,
1599
+ description: options.description || "",
1600
+ displayName: options.displayName,
1601
+ eventNotifier: +options.eventNotifier,
1602
+ isAbstract: false,
1603
+ nodeClass: node_opcua_data_model_4.NodeClass.Method,
1604
+ nodeId: options.nodeId,
1605
+ references,
1606
+ rolePermissions: options.rolePermissions
1607
+ });
1608
+ (0, node_opcua_assert_1.assert)(method.nodeId !== null);
1609
+ method.propagate_back_references();
1610
+ (0, node_opcua_assert_1.assert)(!method.typeDefinition);
1611
+ return method;
1612
+ }
1613
+ }
1614
+ NamespaceImpl._handle_hierarchy_parent = _handle_hierarchy_parent;
1615
+ NamespaceImpl.isNonEmptyQualifiedName = isNonEmptyQualifiedName;
1616
+ exports.NamespaceImpl = NamespaceImpl;
1617
+ const _constructors_map = {
1618
+ DataType: ua_data_type_impl_1.UADataTypeImpl,
1619
+ Method: ua_method_impl_1.UAMethodImpl,
1620
+ Object: ua_object_impl_1.UAObjectImpl,
1621
+ ObjectType: ua_object_type_impl_1.UAObjectTypeImpl,
1622
+ ReferenceType: ua_reference_type_impl_1.UAReferenceTypeImpl,
1623
+ Variable: ua_variable_impl_1.UAVariableImpl,
1624
+ VariableType: ua_variable_type_impl_1.UAVariableTypeImpl,
1625
+ View: ua_view_impl_1.UAViewImpl
1626
+ };
1627
+ /**
1628
+ * @method _coerce_parent
1629
+ * convert a 'string' , NodeId or Object into a valid and existing object
1630
+ * @param addressSpace {IAddressSpace}
1631
+ * @param value
1632
+ * @param coerceFunc
1633
+ * @private
1634
+ */
1635
+ function _coerce_parent(addressSpace, value, coerceFunc) {
1636
+ (0, node_opcua_assert_1.assert)(typeof coerceFunc === "function");
1637
+ if (value) {
1638
+ if (typeof value === "string") {
1639
+ value = coerceFunc.call(addressSpace, value);
1640
+ }
1641
+ if (value instanceof node_opcua_nodeid_2.NodeId) {
1642
+ value = addressSpace.findNode(value);
1643
+ }
1644
+ }
1645
+ (0, node_opcua_assert_1.assert)(!value || value instanceof base_node_impl_1.BaseNodeImpl);
1646
+ return value;
1647
+ }
1648
+ function _handle_event_hierarchy_parent(addressSpace, references, options) {
1649
+ options.eventSourceOf = _coerce_parent(addressSpace, options.eventSourceOf, addressSpace._coerceNode);
1650
+ options.notifierOf = _coerce_parent(addressSpace, options.notifierOf, addressSpace._coerceNode);
1651
+ if (options.eventSourceOf) {
1652
+ (0, node_opcua_assert_1.assert)(!options.notifierOf, "notifierOf shall not be provided with eventSourceOf ");
1653
+ references.push({
1654
+ isForward: false,
1655
+ nodeId: options.eventSourceOf.nodeId,
1656
+ referenceType: "HasEventSource"
1657
+ });
1658
+ options.eventNotifier = options.eventNotifier || 1;
1659
+ }
1660
+ else if (options.notifierOf) {
1661
+ (0, node_opcua_assert_1.assert)(!options.eventSourceOf, "eventSourceOf shall not be provided with notifierOf ");
1662
+ references.push({
1663
+ isForward: false,
1664
+ nodeId: options.notifierOf.nodeId,
1665
+ referenceType: "HasNotifier"
1666
+ });
1667
+ }
1668
+ }
1669
+ function _handle_hierarchy_parent(addressSpace, references, options) {
1670
+ options.componentOf = _coerce_parent(addressSpace, options.componentOf, addressSpace._coerceNode);
1671
+ options.propertyOf = _coerce_parent(addressSpace, options.propertyOf, addressSpace._coerceNode);
1672
+ options.organizedBy = _coerce_parent(addressSpace, options.organizedBy, addressSpace._coerceFolder);
1673
+ options.encodingOf = _coerce_parent(addressSpace, options.encodingOf, addressSpace._coerceNode);
1674
+ if (options.componentOf) {
1675
+ (0, node_opcua_assert_1.assert)(!options.propertyOf);
1676
+ (0, node_opcua_assert_1.assert)(!options.organizedBy);
1677
+ (0, node_opcua_assert_1.assert)(addressSpace.rootFolder.objects, "addressSpace must have a rootFolder.objects folder");
1678
+ (0, node_opcua_assert_1.assert)(options.componentOf.nodeId !== addressSpace.rootFolder.objects.nodeId, "Only Organizes References are used to relate Objects to the 'Objects' standard Object.");
1679
+ references.push({
1680
+ isForward: false,
1681
+ nodeId: options.componentOf.nodeId,
1682
+ referenceType: "HasComponent"
1683
+ });
1684
+ }
1685
+ if (options.propertyOf) {
1686
+ (0, node_opcua_assert_1.assert)(!options.componentOf);
1687
+ (0, node_opcua_assert_1.assert)(!options.organizedBy);
1688
+ (0, node_opcua_assert_1.assert)(options.propertyOf.nodeId !== addressSpace.rootFolder.objects.nodeId, "Only Organizes References are used to relate Objects to the 'Objects' standard Object.");
1689
+ references.push({
1690
+ isForward: false,
1691
+ nodeId: options.propertyOf.nodeId,
1692
+ referenceType: "HasProperty"
1693
+ });
1694
+ }
1695
+ if (options.organizedBy) {
1696
+ (0, node_opcua_assert_1.assert)(!options.propertyOf);
1697
+ (0, node_opcua_assert_1.assert)(!options.componentOf);
1698
+ references.push({
1699
+ isForward: false,
1700
+ nodeId: options.organizedBy.nodeId,
1701
+ referenceType: "Organizes"
1702
+ });
1703
+ }
1704
+ if (options.encodingOf) {
1705
+ // parent must be a DataType
1706
+ (0, node_opcua_assert_1.assert)(options.encodingOf.nodeClass === node_opcua_data_model_4.NodeClass.DataType, "encodingOf must be toward a DataType");
1707
+ references.push({
1708
+ isForward: false,
1709
+ nodeId: options.encodingOf.nodeId,
1710
+ referenceType: "HasEncoding"
1711
+ });
1712
+ }
1713
+ }
1714
+ exports._handle_hierarchy_parent = _handle_hierarchy_parent;
1715
+ function _copy_reference(reference) {
1716
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(reference, "referenceType"));
1717
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(reference, "isForward"));
1718
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(reference, "nodeId"));
1719
+ (0, node_opcua_assert_1.assert)(reference.nodeId instanceof node_opcua_nodeid_2.NodeId);
1720
+ return {
1721
+ isForward: reference.isForward,
1722
+ nodeId: reference.nodeId,
1723
+ referenceType: reference.referenceType
1724
+ };
1725
+ }
1726
+ function _copy_references(references) {
1727
+ references = references || [];
1728
+ return references.map(_copy_reference);
1729
+ }
1730
+ function isNonEmptyQualifiedName(browseName) {
1731
+ if (!browseName) {
1732
+ return false;
1733
+ }
1734
+ if (typeof browseName === "string") {
1735
+ return browseName.length >= 0;
1736
+ }
1737
+ if (!(browseName instanceof node_opcua_data_model_2.QualifiedName)) {
1738
+ browseName = new node_opcua_data_model_2.QualifiedName(browseName);
1739
+ }
1740
+ (0, node_opcua_assert_1.assert)(browseName instanceof node_opcua_data_model_2.QualifiedName);
1741
+ return browseName.name.length > 0;
1742
+ }
1743
+ exports.isNonEmptyQualifiedName = isNonEmptyQualifiedName;
1744
+ function _create_node_version_if_needed(node, options) {
1745
+ (0, node_opcua_assert_1.assert)(options);
1746
+ if (options.nodeVersion) {
1747
+ (0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_4.NodeClass.Variable || node.nodeClass === node_opcua_data_model_4.NodeClass.Object);
1748
+ // istanbul ignore next
1749
+ if (node.getChildByName("NodeVersion")) {
1750
+ return; // already exists
1751
+ }
1752
+ const namespace = node.addressSpace.getOwnNamespace();
1753
+ const nodeVersion = namespace.addVariable({
1754
+ browseName: "NodeVersion",
1755
+ dataType: "String",
1756
+ propertyOf: node
1757
+ });
1758
+ const initialValue = typeof options.nodeVersion === "string" ? options.nodeVersion : "0";
1759
+ // xx console.log(" init value =",initialValue);
1760
+ nodeVersion.setValueFromSource({ dataType: "String", value: initialValue });
1761
+ }
1762
+ }
1763
+ //# sourceMappingURL=namespace_impl.js.map