node-opcua-address-space 2.51.0

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