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,1298 @@
1
+ /* eslint-disable complexity */
2
+ /**
3
+ * @module node-opcua-address-space.AlarmsAndConditions
4
+ */
5
+ import * as chalk from "chalk";
6
+
7
+ import { assert } from "node-opcua-assert";
8
+ import { ByteString, UAString, UInt16 } from "node-opcua-basic-types";
9
+ import { randomGuid } from "node-opcua-basic-types";
10
+ import {
11
+ AttributeIds,
12
+ BrowseDirection,
13
+ coerceLocalizedText,
14
+ LocalizedText,
15
+ LocalizedTextLike,
16
+ makeAccessLevelFlag,
17
+ NodeClass,
18
+ QualifiedName
19
+ } from "node-opcua-data-model";
20
+ import { DataValue } from "node-opcua-data-value";
21
+ import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
22
+ import { minDate } from "node-opcua-factory";
23
+ import { coerceNodeId, makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
24
+ import { StatusCode, StatusCodes } from "node-opcua-status-code";
25
+ import { TimeZoneDataType } from "node-opcua-types";
26
+ import { DataType, Variant, VariantLike } from "node-opcua-variant";
27
+ import {
28
+ UAVariable,
29
+ INamespace,
30
+ ISessionContext,
31
+ UAEventType,
32
+ BaseNode,
33
+ UAObject
34
+ } from "node-opcua-address-space-base";
35
+ import { UACondition_Base, UAConditionVariable, UACondition } from "node-opcua-nodeset-ua";
36
+
37
+ import { ConditionInfoOptions } from "../../source/interfaces/alarms_and_conditions/condition_info_i";
38
+ import { AddressSpacePrivate } from "../address_space_private";
39
+ import { _install_TwoStateVariable_machinery } from "../state_machine/ua_two_state_variable";
40
+ import { UAObjectImpl } from "../ua_object_impl";
41
+ import { UAVariableImpl } from "../ua_variable_impl";
42
+ import { UAConditionType } from "../ua_condition_type";
43
+ import { UATwoStateVariableEx } from "../../source/ua_two_state_variable_ex";
44
+ import { UABaseEventHelper, UABaseEventImpl } from "./ua_base_event_impl";
45
+ import { ConditionSnapshot } from "./condition_snapshot";
46
+
47
+ const debugLog = make_debugLog(__filename);
48
+ const errorLog = make_errorLog(__filename);
49
+ const doDebug = checkDebugFlag(__filename);
50
+
51
+ export type AddCommentEventHandler = (eventId: Buffer | null, comment: LocalizedText, branch: ConditionSnapshot) => void;
52
+ export interface UAConditionHelper {
53
+ on(eventName: string, eventHandler: (...args: any[]) => void): this;
54
+ // -- Events
55
+ on(eventName: "addComment", eventHandler: AddCommentEventHandler): this;
56
+ on(eventName: "branch_deleted", eventHandler: (branchId: string) => void): this;
57
+ }
58
+ export interface UAConditionHelper extends UABaseEventHelper {
59
+ getBranchCount(): number;
60
+ getBranches(): ConditionSnapshot[];
61
+ getBranchIds(): NodeId[];
62
+ createBranch(): ConditionSnapshot;
63
+ deleteBranch(branch: ConditionSnapshot): void;
64
+ getEnabledState(): boolean ;
65
+ getEnabledStateAsString(): string ;
66
+ setEnabledState(requestedEnabledState: boolean): StatusCode;
67
+ setReceiveTime(time: Date): void;
68
+ setLocalTime(time: TimeZoneDataType):void;
69
+ setTime(time: Date):void;
70
+ conditionOfNode(): UAObject | UAVariable | null;
71
+ raiseConditionEvent(branch: ConditionSnapshot, renewEventId: boolean): void;
72
+ raiseNewCondition(conditionInfo: ConditionInfoOptions): void;
73
+ raiseNewBranchState(branch: ConditionSnapshot): void;
74
+ currentBranch(): ConditionSnapshot;
75
+ }
76
+
77
+ export interface UAConditionEx extends UAObject, UACondition_Base, UAConditionHelper {
78
+ enabledState: UATwoStateVariableEx;
79
+ on(eventName: string, eventHandler: any): this;
80
+ //
81
+ // conditionClassId: UAProperty<NodeId, /*c*/DataType.NodeId>;
82
+ // conditionClassName: UAProperty<LocalizedText, /*c*/DataType.LocalizedText>;
83
+ // conditionSubClassId?: UAProperty<NodeId, /*c*/DataType.NodeId>;
84
+ // conditionSubClassName?: UAProperty<LocalizedText, /*c*/DataType.LocalizedText>;
85
+ // conditionName: UAProperty<UAString, /*c*/DataType.String>;
86
+ // branchId: UAProperty<NodeId, /*c*/DataType.NodeId>;
87
+ // retain: UAProperty<boolean, /*c*/DataType.Boolean>;
88
+ // quality: UAConditionVariable<StatusCode, /*c*/DataType.StatusCode>;
89
+ // lastSeverity: UAConditionVariable<UInt16, /*c*/DataType.UInt16>;
90
+ // comment: UAConditionVariable<LocalizedText, /*c*/DataType.LocalizedText>;
91
+ // clientUserId: UAProperty<UAString, /*c*/DataType.String>;
92
+ // disable: UAMethod;
93
+ // enable: UAMethod;
94
+ // addComment: UAMethod;
95
+ // conditionRefresh: UAMethod;
96
+ // conditionRefresh2: UAMethod;
97
+
98
+ }
99
+ export declare interface UAConditionImpl extends UAConditionEx, UABaseEventImpl {
100
+ on(eventName: string, eventHandler: any): this;
101
+ }
102
+ /**
103
+ *
104
+ * └─ ConditionType
105
+ * ├─ DialogConditionType
106
+ * └─ AcknowledgeableConditionType
107
+ * └─ AlarmConditionType
108
+ * ├─ LimitAlarmType
109
+ * │ ├─ ExclusiveLimitAlarmType
110
+ * │ │ ├─ ExclusiveLevelAlarmType
111
+ * │ │ ├─ ExclusiveDeviationAlarmType
112
+ * │ │ └─ ExclusiveRateOfChangeAlarmType
113
+ * │ └─ NonExclusiveLimitAlarmType
114
+ * │ ├─ NonExclusiveLevelAlarmType
115
+ * │ ├─ NonExclusiveDeviationAlarmType
116
+ * │ └─ NonExclusiveRateOfChangeAlarmType
117
+ * └─ DiscreteAlarmType
118
+ * ├─ OffNormalAlarmType
119
+ * │ ├─ SystemOffNormalAlarmType
120
+ * │ │ └─ CertificateExpirationAlarmType
121
+ * │ └─ TripAlarmType
122
+ *
123
+ */
124
+ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
125
+ public static defaultSeverity = 250;
126
+ public static typeDefinition = resolveNodeId("ConditionType");
127
+
128
+ public static instantiate(
129
+ namespace: INamespace,
130
+ conditionTypeId: NodeId | string | UAEventType,
131
+ options: any,
132
+ data: any
133
+ ): UAConditionImpl {
134
+ return UACondition_instantiate(namespace, conditionTypeId, options, data) as UAConditionImpl;
135
+ }
136
+
137
+ public static install_condition_refresh_handle(addressSpace: AddressSpacePrivate): void {
138
+ //
139
+ // install ConditionRefresh
140
+ //
141
+ // NOTE:
142
+ // OPCUA doesn't implement the condition refresh method ! yet
143
+ // .5.7 ConditionRefresh Method
144
+ // ConditionRefresh allows a Client to request a Refresh of all Condition instances that currently
145
+ // are in an interesting state (they have the Retain flag set). This includes previous states of a
146
+ // Condition instance for which the Server maintains Branches. A Client would typically invoke
147
+ // this Method when it initially connects to a Server and following any situations, such as
148
+ // communication disruptions, in which it would require resynchronization with the Server. This
149
+ // Method is only available on the ConditionType or its subtypes. To invoke this Method, the call
150
+ // shall pass the well known MethodId of the Method on the ConditionType and the ObjectId
151
+ // shall be the well known ObjectId of the ConditionType Object.
152
+
153
+ const conditionType = addressSpace.findEventType("ConditionType") as UAConditionType;
154
+ assert(conditionType !== null);
155
+
156
+ conditionType.disable.bindMethod(_disable_method);
157
+ conditionType.enable.bindMethod(_enable_method);
158
+
159
+ conditionType.conditionRefresh.bindMethod(_condition_refresh_method);
160
+
161
+ conditionType.conditionRefresh2.bindMethod(_condition_refresh2_method);
162
+
163
+ // those methods can be call on the ConditionType or on the ConditionInstance itself...
164
+ conditionType.addComment.bindMethod(_add_comment_method);
165
+ }
166
+
167
+ /**
168
+ *
169
+ * Helper method to handle condition methods that takes a branchId and a comment
170
+ *
171
+ */
172
+ public static with_condition_method(
173
+ inputArguments: VariantLike[],
174
+ context: ISessionContext,
175
+ callback: (err: Error | null, result?: { statusCode: StatusCode }) => void,
176
+ inner_func: (
177
+ eventId: ByteString,
178
+ comment: LocalizedText,
179
+ branch: ConditionSnapshot,
180
+ conditionNode: UAConditionImpl
181
+ ) => StatusCode
182
+ ): void {
183
+ const conditionNode = context.object;
184
+
185
+ // xx console.log(inputArguments.map(function(a){return a.toString()}));
186
+ if (!(conditionNode instanceof UAConditionImpl)) {
187
+ callback(null, {
188
+ statusCode: StatusCodes.BadNodeIdInvalid
189
+ });
190
+ return;
191
+ }
192
+
193
+ if (!conditionNode.getEnabledState()) {
194
+ callback(null, {
195
+ statusCode: StatusCodes.BadConditionDisabled
196
+ });
197
+ return;
198
+ }
199
+
200
+ // inputArguments has 2 arguments
201
+ // EventId => ByteString The Identifier of the event to comment
202
+ // Comment => LocalizedText The Comment to add to the condition
203
+ assert(inputArguments.length === 2);
204
+ assert(inputArguments[0].dataType === DataType.ByteString);
205
+ assert(inputArguments[1].dataType === DataType.LocalizedText);
206
+
207
+ const eventId = inputArguments[0].value;
208
+ assert(!eventId || eventId instanceof Buffer);
209
+
210
+ const comment = inputArguments[1].value;
211
+ assert(comment instanceof LocalizedText);
212
+
213
+ const branch = conditionNode._findBranchForEventId(eventId);
214
+ if (!branch) {
215
+ callback(null, {
216
+ statusCode: StatusCodes.BadEventIdUnknown
217
+ });
218
+ return;
219
+ }
220
+ assert(branch instanceof ConditionSnapshot);
221
+
222
+ const statusCode = inner_func(eventId, comment, branch, conditionNode);
223
+
224
+ // record also who did the call
225
+ branch.setClientUserId(context.userIdentity || "<unknown client user id>");
226
+
227
+ callback(null, {
228
+ statusCode
229
+ });
230
+ }
231
+ private _branch0: ConditionSnapshot = null as any;
232
+ private _previousRetainFlag = false;
233
+ private _branches: { [key: string]: ConditionSnapshot } = {};
234
+
235
+ /**
236
+ * @method initialize
237
+ * @private
238
+ */
239
+ public initialize(): void {
240
+ this._branches = {};
241
+ }
242
+
243
+ /**
244
+ * @method post_initialize
245
+ * @private
246
+ */
247
+ public post_initialize(): void {
248
+ assert(!this._branch0);
249
+ this._branch0 = new ConditionSnapshot(this, NodeId.nullNodeId);
250
+
251
+ // the condition OPCUA object alway reflects the default branch states
252
+ // so we set a mechanism that automatically keeps self in sync
253
+ // with the default branch.
254
+
255
+ // the implication of this convention is that interacting with the condition variable
256
+ // shall be made by using branch0, any value change made
257
+ // using the standard setValueFromSource mechanism will not be work properly.
258
+ this._branch0.on("value_changed", (node: UAVariable, variant: Variant) => {
259
+ assert(node.nodeClass === NodeClass.Variable);
260
+ node.setValueFromSource(variant);
261
+ });
262
+ }
263
+
264
+ public getBranchCount(): number {
265
+ return Object.keys(this._branches).length;
266
+ }
267
+
268
+ public getBranches(): ConditionSnapshot[] {
269
+ return Object.keys(this._branches).map((x: any) => {
270
+ return this._branches[x];
271
+ });
272
+ }
273
+
274
+ public getBranchIds(): NodeId[] {
275
+ return this.getBranches().map((b: any) => b.getBranchId());
276
+ }
277
+
278
+ /**
279
+ * @method createBranch
280
+ * @return {ConditionSnapshot}
281
+ */
282
+ public createBranch(): ConditionSnapshot {
283
+ const branchId = _create_new_branch_id();
284
+ const snapshot = new ConditionSnapshot(this, branchId);
285
+ this._branches[branchId.toString()] = snapshot;
286
+ return snapshot;
287
+ }
288
+
289
+ /**
290
+ * @method deleteBranch
291
+ * @param branch {ConditionSnapshot}
292
+ */
293
+ public deleteBranch(branch: ConditionSnapshot): void {
294
+ const key = branch.getBranchId().toString();
295
+ assert(branch.getBranchId() !== NodeId.nullNodeId, "cannot delete branch zero");
296
+ assert(Object.prototype.hasOwnProperty.call(this._branches,key));
297
+ delete this._branches[key];
298
+ this.emit("branch_deleted", key);
299
+ }
300
+
301
+ /**
302
+ * @method getEnabledState
303
+ * @return {Boolean}
304
+ */
305
+ public getEnabledState(): boolean {
306
+ return this.enabledState.getValue();
307
+ }
308
+
309
+ /**
310
+ * @method getEnabledStateAsString
311
+ * @return {String}
312
+ */
313
+ public getEnabledStateAsString(): string {
314
+ return this.enabledState.getValueAsString();
315
+ }
316
+
317
+ /**
318
+ * returns {StatusCode} StatusCodes.Good if successful or BadConditionAlreadyEnabled/BadConditionAlreadyDisabled
319
+ * @private
320
+ */
321
+ public _setEnabledState(requestedEnabledState: boolean): StatusCode {
322
+ assert(typeof requestedEnabledState === "boolean");
323
+
324
+ const enabledState = this.getEnabledState();
325
+ if (enabledState && requestedEnabledState) {
326
+ return StatusCodes.BadConditionAlreadyEnabled;
327
+ }
328
+ if (!enabledState && !requestedEnabledState) {
329
+ return StatusCodes.BadConditionAlreadyDisabled;
330
+ }
331
+
332
+ this._branch0.setEnabledState(requestedEnabledState);
333
+ // conditionNode.enabledState.setValue(requestedEnabledState);
334
+
335
+ // xx assert(conditionNode.enabledState.id.readValue().value.value === requestedEnabledState,"sanity check 1");
336
+ // xx assert(conditionNode.currentBranch().getEnabledState() === requestedEnabledState,"sanity check 2");
337
+
338
+ if (!requestedEnabledState) {
339
+ // as per Spec 1.0.3 part 9:
340
+ // * When the Condition instance enters the Disabled state, the Retain Property of this
341
+ // Condition shall be set to FALSE by the Server to indicate to the Client that the
342
+ // Condition instance is currently not of interest to Clients.
343
+ // TODO : shall we really set retain to false or artificially expose the retain false as false
344
+ // whist enabled state is false ?
345
+ this._previousRetainFlag = this.currentBranch().getRetain();
346
+ this.currentBranch().setRetain(false);
347
+
348
+ // todo: install the mechanism by which all condition values will be return
349
+ // as Null | BadConditionDisabled;
350
+ const statusCode = StatusCodes.BadConditionDisabled;
351
+
352
+ // a notification must be send
353
+ this.raiseConditionEvent(this.currentBranch(), true);
354
+ } else {
355
+ // * When the Condition instance enters the enabled state, the Condition shall be
356
+ // evaluated and all of its Properties updated to reflect the current values. If this
357
+ // evaluation causes the Retain Property to transition to TRUE for any ConditionBranch,
358
+ // then an Event Notification shall be generated for that ConditionBranch.
359
+
360
+ this.evaluateConditionsAfterEnabled();
361
+
362
+ // todo evaluate branches
363
+ // conditionNode.evaluateBranches();
364
+
365
+ // restore retain flag
366
+ if (Object.prototype.hasOwnProperty.call(this,"_previousRetainFlag")) {
367
+ this.currentBranch().setRetain(this._previousRetainFlag);
368
+ }
369
+
370
+ // todo send notification for branches with retain = true
371
+ let nb_condition_resent = 0;
372
+ if (this.currentBranch().getRetain()) {
373
+ nb_condition_resent += this._resend_conditionEvents();
374
+ }
375
+
376
+ if (nb_condition_resent === 0) {
377
+ // a notification must be send
378
+ this.raiseConditionEvent(this.currentBranch(), true);
379
+ }
380
+ }
381
+ return StatusCodes.Good;
382
+ }
383
+
384
+ /**
385
+ *
386
+ * @method setEnabledState
387
+ * @param requestedEnabledState {Boolean}
388
+ * @private
389
+ */
390
+ public setEnabledState(requestedEnabledState: boolean): StatusCode {
391
+ return this._setEnabledState(requestedEnabledState);
392
+ }
393
+
394
+ /**
395
+ * @method setReceiveTime
396
+ * @param time {Date}
397
+ */
398
+ public setReceiveTime(time: Date): void {
399
+ return this._branch0.setReceiveTime(time);
400
+ }
401
+
402
+ /**
403
+ * @method setLocalTime (optional)
404
+ * @param time
405
+ */
406
+ public setLocalTime(time: TimeZoneDataType): void {
407
+ return this._branch0.setLocalTime(time);
408
+ }
409
+
410
+ /**
411
+ * @method setTime
412
+ * @param time {Date}
413
+ */
414
+ public setTime(time: Date): void {
415
+ return this._branch0.setTime(time);
416
+ }
417
+
418
+ public _assert_valid(): void {
419
+ assert(this.receiveTime.readValue().value.dataType === DataType.DateTime);
420
+ assert(this.receiveTime.readValue().value.value instanceof Date);
421
+
422
+ assert(this.message.readValue().value.dataType === DataType.LocalizedText);
423
+ assert(this.severity.readValue().value.dataType === DataType.UInt16);
424
+
425
+ assert(this.time.readValue().value.dataType === DataType.DateTime);
426
+ assert(this.time.readValue().value.value instanceof Date);
427
+
428
+ assert(this.quality.readValue().value.dataType === DataType.StatusCode);
429
+
430
+ assert(this.enabledState.readValue().value.dataType === DataType.LocalizedText);
431
+ assert(this.branchId.readValue().value.dataType === DataType.NodeId);
432
+
433
+ // note localTime has been made optional in 1.04
434
+ assert(!this.localTime || this.localTime.readValue().value.dataType === DataType.ExtensionObject);
435
+ }
436
+
437
+
438
+
439
+ /**
440
+ * @method conditionOfNode
441
+ * @return {UAObject}
442
+ */
443
+ public conditionOfNode(): UAObject | UAVariable | null {
444
+ const refs = this.findReferencesExAsObject("HasCondition", BrowseDirection.Inverse);
445
+ if (refs.length === 0) {
446
+ return null;
447
+ }
448
+ assert(refs.length !== 0, "UACondition must be the condition of some node");
449
+ assert(refs.length === 1, "expecting only one ConditionOf");
450
+ const node = refs[0];
451
+ assert(
452
+ node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable,
453
+ "node for which we are the condition shall be an UAObject or UAVariable"
454
+ );
455
+ return node as UAObject | UAVariable;
456
+ }
457
+
458
+ /**
459
+ * @method raiseConditionEvent
460
+ * Raise a Instance Event
461
+ * (see also UAObject#raiseEvent to raise a transient event)
462
+ * @param branch the condition branch to raise
463
+ * @param renewEventId true if event Id of the condition branch should be renewed
464
+ */
465
+ public raiseConditionEvent(branch: ConditionSnapshot, renewEventId: boolean): void {
466
+ assert(arguments.length === 2, "expecting 2 arguments");
467
+ if (renewEventId) {
468
+ branch.renewEventId();
469
+ }
470
+
471
+ // xx console.log("MMMMMMMM%%%%%%%%%%%%%%%%%%%%% branch " +
472
+ // branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
473
+
474
+ assert(branch instanceof ConditionSnapshot);
475
+
476
+ this._assert_valid();
477
+
478
+ // In fact the event is raised by the object of which we are the condition
479
+ const conditionOfNode = this.conditionOfNode();
480
+
481
+ if (conditionOfNode) {
482
+ const eventData = branch._constructEventData();
483
+
484
+ this.emit("event", eventData);
485
+
486
+ if (conditionOfNode instanceof UAObjectImpl) {
487
+ // xx assert(conditionOfNode.eventNotifier === 0x01);
488
+ conditionOfNode._bubble_up_event(eventData);
489
+ } else {
490
+ assert(conditionOfNode.nodeClass === NodeClass.Variable);
491
+ // in this case
492
+ const eventOfs = conditionOfNode.getEventSourceOfs();
493
+ assert(eventOfs.length === 1);
494
+ const node = eventOfs[0] as UAObject;
495
+ if (node instanceof UAObjectImpl) {
496
+ node._bubble_up_event(eventData);
497
+ }
498
+ }
499
+ }
500
+ // xx console.log("MMMMMMMM%%%%%%%%%%%%%%%%%%%%% branch " +
501
+ // branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
502
+ }
503
+
504
+ /**
505
+ *
506
+ * @method raiseNewCondition
507
+ * @param conditionInfo {ConditionInfo}
508
+ *
509
+ */
510
+ public raiseNewCondition(conditionInfo: ConditionInfoOptions): void {
511
+ if (!this.getEnabledState()) {
512
+ throw new Error("UACondition#raiseNewCondition Condition is not enabled");
513
+ }
514
+
515
+ conditionInfo = conditionInfo || {};
516
+
517
+ conditionInfo.severity = Object.prototype.hasOwnProperty.call(conditionInfo,"severity")
518
+ ? conditionInfo.severity
519
+ : UAConditionImpl.defaultSeverity;
520
+
521
+ // only valid for ConditionObjects
522
+ // todo check that object is of type ConditionType
523
+
524
+ const addressSpace = this.addressSpace;
525
+
526
+ const selfConditionType = this.typeDefinitionObj;
527
+ const conditionType = addressSpace.findObjectType("ConditionType")!;
528
+ assert(selfConditionType.isSupertypeOf(conditionType));
529
+
530
+ const branch = this.currentBranch();
531
+
532
+ const now = new Date();
533
+ // install the eventTimestamp
534
+ // set the received Time
535
+ branch.setTime(now);
536
+ branch.setReceiveTime(now);
537
+
538
+ // note : in 1.04 LocalTime property is optional
539
+ if (Object.prototype.hasOwnProperty.call(this,"localTime")) {
540
+ branch.setLocalTime(
541
+ new TimeZoneDataType({
542
+ daylightSavingInOffset: false,
543
+ offset: 0
544
+ })
545
+ );
546
+ }
547
+
548
+ if (Object.prototype.hasOwnProperty.call(conditionInfo,"message") && conditionInfo.message) {
549
+ branch.setMessage(conditionInfo.message);
550
+ }
551
+ // todo receive time : when the server received the event from the underlying system.
552
+ // self.receiveTime.setValueFromSource();
553
+
554
+ if (Object.prototype.hasOwnProperty.call(conditionInfo,"severity") && conditionInfo.severity !== null) {
555
+ assert(isFinite(conditionInfo.severity!));
556
+ branch.setSeverity(conditionInfo.severity!);
557
+ }
558
+ if (Object.prototype.hasOwnProperty.call(conditionInfo,"quality") && conditionInfo.quality !== null) {
559
+ assert(conditionInfo.quality instanceof StatusCode);
560
+ branch.setQuality(conditionInfo.quality!);
561
+ }
562
+ if (Object.prototype.hasOwnProperty.call(conditionInfo,"retain") && conditionInfo.retain !== null) {
563
+ assert(typeof conditionInfo.retain === "boolean");
564
+ branch.setRetain(!!conditionInfo.retain!);
565
+ }
566
+
567
+ this.raiseConditionEvent(branch, true);
568
+ }
569
+
570
+ public raiseNewBranchState(branch: ConditionSnapshot): void {
571
+ this.raiseConditionEvent(branch, true);
572
+
573
+ if (branch.getBranchId() !== NodeId.nullNodeId && !branch.getRetain()) {
574
+ // xx console.log(" Deleting not longer needed branch ", branch.getBranchId().toString());
575
+ // branch can be deleted
576
+ this.deleteBranch(branch);
577
+ }
578
+ }
579
+
580
+ /**
581
+ * @method currentBranch
582
+ * @return {ConditionSnapshot}
583
+ */
584
+ public currentBranch(): ConditionSnapshot {
585
+ return this._branch0;
586
+ }
587
+
588
+ public _resend_conditionEvents(): 0|1 {
589
+ // for the time being , only current branch
590
+ const currentBranch = this.currentBranch();
591
+ if (currentBranch.getRetain()) {
592
+ debugLog(" resending condition event for " + this.browseName.toString());
593
+ this.raiseConditionEvent(currentBranch, false);
594
+ return 1;
595
+ }
596
+ return 0;
597
+ }
598
+
599
+ // ------------------------------------------------------------------------------------
600
+ // Acknowledgeable
601
+ // ------------------------------------------------------------------------------------
602
+ /**
603
+ * @method _raiseAuditConditionCommentEvent
604
+ * @param sourceName {string}
605
+ * @param conditionEventId {Buffer}
606
+ * @param comment {LocalizedText}
607
+ * @private
608
+ */
609
+ public _raiseAuditConditionCommentEvent(sourceName: string, conditionEventId: Buffer, comment: LocalizedTextLike): void {
610
+ assert(conditionEventId === null || conditionEventId instanceof Buffer);
611
+ assert(comment instanceof LocalizedText);
612
+ const server = this.addressSpace.rootFolder.objects.server;
613
+
614
+ const now = new Date();
615
+
616
+ // xx if (true || server.isAuditing) {
617
+ // ----------------------------------------------------------------------------------------------------
618
+ server.raiseEvent("AuditConditionCommentEventType", {
619
+ // AuditEventType
620
+ /* part 5 - 6.4.3 AuditEventType */
621
+ actionTimeStamp: {
622
+ dataType: "DateTime",
623
+ value: now
624
+ },
625
+ status: {
626
+ dataType: "Boolean",
627
+ value: true
628
+ },
629
+
630
+ serverId: {
631
+ dataType: "String",
632
+ value: ""
633
+ },
634
+
635
+ // ClientAuditEntryId contains the human-readable AuditEntryId defined in Part 3.
636
+ clientAuditEntryId: {
637
+ dataType: "String",
638
+ value: ""
639
+ },
640
+
641
+ // The ClientUserId identifies the user of the client requesting an action. The ClientUserId can be
642
+ // obtained from the UserIdentityToken passed in the ActivateSession call.
643
+ clientUserId: {
644
+ dataType: "String",
645
+ value: ""
646
+ },
647
+ sourceName: {
648
+ dataType: "String",
649
+ value: sourceName
650
+ },
651
+
652
+ // AuditUpdateMethodEventType
653
+ methodId: {
654
+ dataType: "Null"
655
+ },
656
+
657
+ inputArguments: {
658
+ dataType: "Null"
659
+ },
660
+
661
+ // AuditConditionCommentEventType
662
+ conditionEventId: {
663
+ dataType: "ByteString",
664
+ value: conditionEventId
665
+ },
666
+
667
+ comment: {
668
+ dataType: "LocalizedText",
669
+ value: comment
670
+ }
671
+ });
672
+ // xx }
673
+ }
674
+
675
+ protected _findBranchForEventId(eventId: Buffer): ConditionSnapshot | null {
676
+ if (sameBuffer(this.eventId!.readValue().value.value, eventId)) {
677
+ return this.currentBranch();
678
+ }
679
+ const e = Object.values(this._branches).filter((branch: ConditionSnapshot) =>
680
+ sameBuffer(branch.getEventId(), eventId)
681
+ );
682
+ if (e.length === 1) {
683
+ return e[0];
684
+ }
685
+ assert(e.length === 0, "cannot have 2 branches with same eventId");
686
+ return null; // not found
687
+ }
688
+
689
+ protected evaluateConditionsAfterEnabled(): void {
690
+ assert(this.getEnabledState() === true);
691
+ throw new Error("Unimplemented , please override");
692
+ }
693
+ }
694
+
695
+ /**
696
+ * instantiate a Condition.
697
+ * this will create the unique EventId and will set eventType
698
+ * @method instantiate
699
+ * @param namespace {INamespace}
700
+ * @param conditionTypeId {String|NodeId} the EventType to instantiate
701
+ * @param options {object}
702
+ * @param options.browseName {String|QualifiedName}
703
+ * @param options.componentOf {NodeId|UAObject}
704
+ * @param options.conditionOf {NodeId|UAObject} Mandatory
705
+ * @param options.organizedBy {NodeId|UAObject} ( only provide componentOf or organizedBy but not both)
706
+ * @param [options.conditionClass =BaseConditionClassType] {NodeId|UAObject}
707
+ * The condition Class nodeId or object used to set the ConditionClassId and
708
+ * ConditionClassName properties of the condition.
709
+ *
710
+ * @param options.conditionSource {NodeId|UAObject} the condition source node.
711
+ * this node must be marked a EventSource.
712
+ * the conditionSource is used to populate the sourceNode and
713
+ * sourceName variables defined by BaseEventType
714
+ * @param options.conditionName {String} the condition Name
715
+ * @param [options.optionals] [Array<String>] an Array of optionals fields
716
+ *
717
+ * @param data a object containing the value to set
718
+ * @param data.eventId {String|NodeId} the EventType Identifier to instantiate (type cannot be abstract)
719
+ * @return a instantiated UAConditionEx
720
+ */
721
+ function UACondition_instantiate(
722
+ namespace: INamespace,
723
+ conditionTypeId: UAEventType | NodeId | string,
724
+ options: any,
725
+ data: any
726
+ ): UAConditionEx {
727
+ /* eslint max-statements: ["error", 100] */
728
+ const addressSpace = namespace.addressSpace as AddressSpacePrivate;
729
+
730
+ const conditionType = addressSpace.findEventType(conditionTypeId);
731
+
732
+ /* istanbul ignore next */
733
+ if (!conditionType) {
734
+ throw new Error(" cannot find Condition Type for " + conditionTypeId);
735
+ }
736
+
737
+ // reminder : abstract event type cannot be instantiated directly !
738
+ assert(!conditionType.isAbstract, "Cannot instantiate abstract conditionType");
739
+
740
+ const baseConditionEventType = addressSpace.findEventType("ConditionType");
741
+ /* istanbul ignore next */
742
+ if (!baseConditionEventType) {
743
+ throw new Error("cannot find ConditionType");
744
+ }
745
+
746
+ assert(conditionType.isSupertypeOf(baseConditionEventType));
747
+
748
+ // assert((typeof options.browseName === "string"));
749
+ options.browseName = options.browseName || "??? instantiateCondition - missing browseName";
750
+
751
+ options.optionals = options.optionals || [];
752
+
753
+ // now optionals in 1.04
754
+ options.optionals.push("EventType");
755
+ options.optionals.push("BranchId");
756
+
757
+ //
758
+ options.optionals.push("Comment");
759
+ options.optionals.push("Comment.SourceTimestamp");
760
+ options.optionals.push("EnabledState.TrueState");
761
+ options.optionals.push("EnabledState.TrueState");
762
+ options.optionals.push("EnabledState.FalseState");
763
+
764
+ options.optionals.push("EnabledState.TransitionTime");
765
+ options.optionals.push("EnabledState.EffectiveTransitionTime");
766
+ options.optionals.push("EnabledState.EffectiveDisplayName");
767
+
768
+ const conditionNode = conditionType.instantiate(options) as any as UAConditionImpl;
769
+ Object.setPrototypeOf(conditionNode, UAConditionImpl.prototype);
770
+ conditionNode.initialize();
771
+
772
+ assert(Object.prototype.hasOwnProperty.call(options,"conditionSource"), "must specify a condition source either as null or as a UAObject");
773
+ if (!options.conditionOf) {
774
+ options.conditionOf = options.conditionSource;
775
+ }
776
+ if (options.conditionOf) {
777
+ assert(Object.prototype.hasOwnProperty.call(options,"conditionOf")); // must provide a conditionOf
778
+ options.conditionOf = addressSpace._coerceNode(options.conditionOf);
779
+
780
+ // HasCondition References can be used in the Type definition of an Object or a Variable.
781
+ assert(options.conditionOf.nodeClass === NodeClass.Object || options.conditionOf.nodeClass === NodeClass.Variable);
782
+
783
+ conditionNode.addReference({
784
+ isForward: false,
785
+ nodeId: options.conditionOf,
786
+ referenceType: "HasCondition"
787
+ });
788
+ assert(conditionNode.conditionOfNode()!.nodeId === options.conditionOf.nodeId);
789
+ }
790
+
791
+ // the constant property of this condition
792
+ conditionNode.eventType.setValueFromSource({
793
+ dataType: DataType.NodeId,
794
+ value: conditionType.nodeId
795
+ });
796
+
797
+ data = data || {};
798
+ // install initial branch ID (null NodeId);
799
+ conditionNode.branchId.setValueFromSource({
800
+ dataType: DataType.NodeId,
801
+ value: NodeId.nullNodeId
802
+ });
803
+
804
+ // install 'Comment' condition variable
805
+ _install_condition_variable_type(conditionNode.comment);
806
+
807
+ // install 'Quality' condition variable
808
+ _install_condition_variable_type(conditionNode.quality);
809
+ // xx conditionNode.quality.setValueFromSource({dataType: DataType.StatusCode,value: StatusCodes.Good });
810
+
811
+ // install 'LastSeverity' condition variable
812
+ _install_condition_variable_type(conditionNode.lastSeverity);
813
+ // xx conditionNode.severity.setValueFromSource({dataType: DataType.UInt16,value: 0 });
814
+ // xx conditionNode.lastSeverity.setValueFromSource({dataType: DataType.UInt16,value: 0 });
815
+
816
+ // install 'EnabledState' TwoStateVariable
817
+ /**
818
+ * @property enabledState
819
+ * @type {UATwoStateVariable}
820
+ */
821
+ // -------------- fixing missing EnabledState.EffectiveDisplayName
822
+ if (!conditionNode.enabledState.effectiveDisplayName) {
823
+ namespace.addVariable({
824
+ browseName: new QualifiedName({ namespaceIndex: 0, name: "EffectiveDisplayName" }),
825
+ dataType: "LocalizedText",
826
+ propertyOf: conditionNode.enabledState
827
+ });
828
+ }
829
+ _install_TwoStateVariable_machinery(conditionNode.enabledState, {
830
+ falseState: "Disabled",
831
+ trueState: "Enabled"
832
+ });
833
+
834
+ // installing sourceName and sourceNode
835
+ conditionNode.enabledState.setValue(true);
836
+
837
+ // set properties to in initial values
838
+ Object.keys(data).forEach((key: string) => {
839
+ const varNode = _getCompositeKey(conditionNode, key);
840
+ assert(varNode.nodeClass === NodeClass.Variable);
841
+
842
+ const variant = new Variant(data[key]);
843
+
844
+ // check that Variant DataType is compatible with the UAVariable dataType
845
+ // xx var nodeDataType = addressSpace.findNode(varNode.dataType).browseName;
846
+
847
+ /* istanbul ignore next */
848
+ if (!varNode._validate_DataType(variant.dataType)) {
849
+ throw new Error(" Invalid variant dataType " + variant + " " + varNode.browseName.toString());
850
+ }
851
+
852
+ const value = new Variant(data[key]);
853
+
854
+ varNode.setValueFromSource(value);
855
+ });
856
+
857
+ // bind condition methods -
858
+ /**
859
+ * @property enable
860
+ * @type {UAMethod}
861
+ */
862
+ conditionNode.enable.bindMethod(_enable_method);
863
+
864
+ /**
865
+ * @property disable
866
+ * @type {UAMethod}
867
+ */
868
+ conditionNode.disable.bindMethod(_disable_method);
869
+
870
+ // bind condition methods - AddComment
871
+ /**
872
+ * @property addComment
873
+ * @type {UAMethod}
874
+ */
875
+ conditionNode.addComment.bindMethod(_add_comment_method);
876
+
877
+ assert(conditionNode instanceof UAConditionImpl);
878
+
879
+ // ConditionSource => cf SourceNode
880
+ // As per spec OPCUA 1.03 part 9 page 54:
881
+ // The ConditionType inherits all Properties of the BaseEventType. Their semantic is defined in
882
+ // Part 5. SourceNode identifies the ConditionSource.
883
+ // The SourceNode is the Node which the condition is associated with, it may be the same as the
884
+ // InputNode for an alarm, but it may be a separate node. For example a motor, which is a
885
+ // variable with a value that is an RPM, may be the ConditionSource for Conditions that are
886
+ // related to the motor as well as a temperature sensor associated with the motor. In the former
887
+ // the InputNode for the High RPM alarm is the value of the Motor RPM, while in the later the
888
+ // InputNode of the High Alarm would be the value of the temperature sensor that is associated
889
+ // with the motor.
890
+
891
+ if (options.conditionSource) {
892
+ options.conditionSource = addressSpace._coerceNode(options.conditionSource);
893
+ if (options.conditionSource.nodeClass !== NodeClass.Object && options.conditionSource.nodeClass !== NodeClass.Variable) {
894
+ // tslint:disable:no-console
895
+ console.log(options.conditionSource);
896
+ throw new Error("Expecting condition source to be NodeClass.Object or Variable");
897
+ }
898
+
899
+ const conditionSourceNode = addressSpace.findNode(options.conditionSource.nodeId) as BaseNode;
900
+ if (conditionSourceNode) {
901
+ conditionNode.sourceNode.setValueFromSource({
902
+ dataType: DataType.NodeId,
903
+ value: conditionSourceNode.nodeId
904
+ });
905
+
906
+ // conditionSourceNode node must be registered as a EventSource of an other node.
907
+ // As per spec OPCUA 1.03 part 9 page 54:
908
+ // HasNotifier and HasEventSource References are used to expose the hierarchical organization
909
+ // of Event notifying Objects and ConditionSources. An Event notifying Object represents
910
+ // typically an area of Operator responsibility. The definition of such an area configuration is
911
+ // outside the scope of this standard. If areas are available they shall be linked together and
912
+ // with the included ConditionSources using the HasNotifier and the HasEventSource Reference
913
+ // Types. The Server Object shall be the root of this hierarchy.
914
+ if (!sameNodeId(conditionSourceNode.nodeId, coerceNodeId("ns=0;i=2253"))) {
915
+ // server object
916
+ /* istanbul ignore next */
917
+ if (conditionSourceNode.getEventSourceOfs().length === 0) {
918
+ errorLog("conditionSourceNode = ", conditionSourceNode.browseName.toString());
919
+ errorLog("conditionSourceNode = ", conditionSourceNode.nodeId.toString());
920
+ throw new Error(
921
+ "conditionSourceNode must be an event source " +
922
+ conditionSourceNode.browseName.toString() +
923
+ conditionSourceNode.nodeId.toString()
924
+ );
925
+ }
926
+ }
927
+
928
+ // set source Node (defined in UABaseEventType)
929
+ conditionNode.sourceNode.setValueFromSource(conditionSourceNode.readAttribute(null, AttributeIds.NodeId).value);
930
+
931
+ // set source Name (defined in UABaseEventType)
932
+ conditionNode.sourceName.setValueFromSource(conditionSourceNode.readAttribute(null, AttributeIds.DisplayName).value);
933
+ }
934
+ }
935
+
936
+ conditionNode.eventType.setValueFromSource({
937
+ dataType: DataType.NodeId,
938
+ value: conditionType.nodeId
939
+ });
940
+ // as per spec:
941
+
942
+ /**
943
+ *
944
+ * dataType: DataType.NodeId
945
+ *
946
+ * As per spec OPCUA 1.03 part 9:
947
+ * ConditionClassId specifies in which domain this Condition is used. It is the NodeId of the
948
+ * corresponding ConditionClassType. See 5.9 for the definition of ConditionClass and a set of
949
+ * ConditionClasses defined in this standard. When using this Property for filtering, Clients have
950
+ * to specify all individual ConditionClassType NodeIds. The OfType operator cannot be applied.
951
+ * BaseConditionClassType is used as class whenever a Condition cannot be assigned to a
952
+ * more concrete class.
953
+ *
954
+ * BaseConditionClassType
955
+ * |
956
+ * +---------------------------+----------------------------+
957
+ * | | |
958
+ * ProcessConditionClassType MaintenanceConditionClassType SystemConditionClassType
959
+ *
960
+ * @property conditionName
961
+ * @type {UAVariable}
962
+ */
963
+ const baseConditionClassType = addressSpace.findObjectType("ProcessConditionClassType");
964
+ // assert(baseConditionClassType,"Expecting BaseConditionClassType to be in addressSpace");
965
+ let conditionClassId = baseConditionClassType ? baseConditionClassType.nodeId : NodeId.nullNodeId;
966
+ let conditionClassName = baseConditionClassType ? baseConditionClassType.displayName[0] : "";
967
+ if (options.conditionClass) {
968
+ if (typeof options.conditionClass === "string") {
969
+ options.conditionClass = addressSpace.findObjectType(options.conditionClass);
970
+ }
971
+ const conditionClassNode = addressSpace._coerceNode(options.conditionClass);
972
+ if (!conditionClassNode) {
973
+ throw new Error("cannot find condition class " + options.conditionClass.toString());
974
+ }
975
+ conditionClassId = conditionClassNode.nodeId;
976
+ conditionClassName = conditionClassNode.displayName[0];
977
+ }
978
+
979
+ conditionNode.conditionClassId.setValueFromSource({
980
+ dataType: DataType.NodeId,
981
+ value: conditionClassId
982
+ });
983
+
984
+ // as per spec:
985
+ // ConditionClassName provides the display name of the ConditionClassType.
986
+ conditionNode.conditionClassName.setValueFromSource({
987
+ dataType: DataType.LocalizedText,
988
+ value: coerceLocalizedText(conditionClassName)
989
+ });
990
+
991
+ // as per spec:
992
+ /**
993
+ *
994
+ * dataType: DataType.String
995
+ *
996
+ * As per spec OPCUA 1.03 part 9:
997
+ * ConditionName identifies the Condition instance that the Event originated from. It can be used
998
+ * together with the SourceName in a user display to distinguish between different Condition
999
+ * instances. If a ConditionSource has only one instance of a ConditionType, and the Server has
1000
+ * no instance name, the Server shall supply the ConditionType browse name.
1001
+ * @property conditionName
1002
+ * @type {UAVariable}
1003
+ */
1004
+ const conditionName = options.conditionName || "Unset Condition Name";
1005
+ assert(typeof conditionName === "string");
1006
+ conditionNode.conditionName.setValueFromSource({
1007
+ dataType: DataType.String,
1008
+ value: conditionName
1009
+ });
1010
+
1011
+ // set SourceNode and SourceName based on HasCondition node
1012
+ const sourceNodes = conditionNode.findReferencesAsObject("HasCondition", false);
1013
+ if (sourceNodes.length) {
1014
+ assert(sourceNodes.length === 1);
1015
+ conditionNode.setSourceNode(sourceNodes[0].nodeId);
1016
+ conditionNode.setSourceName(sourceNodes[0].browseName.toString());
1017
+ }
1018
+
1019
+ conditionNode.post_initialize();
1020
+
1021
+ const branch0 = conditionNode.currentBranch();
1022
+ branch0.setRetain(false);
1023
+ branch0.setComment("");
1024
+ branch0.setQuality(StatusCodes.Good);
1025
+ branch0.setSeverity(0);
1026
+ branch0.setLocalTime(
1027
+ new TimeZoneDataType({
1028
+ daylightSavingInOffset: false,
1029
+ offset: 0
1030
+ })
1031
+ );
1032
+ branch0.setMessage("");
1033
+
1034
+ branch0.setReceiveTime(minDate);
1035
+ branch0.setTime(minDate);
1036
+
1037
+ return conditionNode;
1038
+ }
1039
+
1040
+ function _disable_method(inputArguments: VariantLike[], context: ISessionContext, callback: any) {
1041
+ assert(inputArguments.length === 0);
1042
+
1043
+ const conditionNode = context.object;
1044
+ assert(conditionNode);
1045
+
1046
+ // istanbul ignore next
1047
+ if (!(conditionNode instanceof UAConditionImpl)) {
1048
+ console.log("conditionNode is not a UACondition ", conditionNode?.toString());
1049
+ return callback(null, {
1050
+ statusCode: StatusCodes.BadNodeIdInvalid
1051
+ });
1052
+ }
1053
+ const statusCode = conditionNode._setEnabledState(false);
1054
+ return callback(null, {
1055
+ statusCode
1056
+ });
1057
+ }
1058
+
1059
+ function _enable_method(inputArguments: VariantLike[], context: ISessionContext, callback: any) {
1060
+ assert(inputArguments.length === 0);
1061
+ const conditionNode = context.object;
1062
+ assert(conditionNode);
1063
+
1064
+ if (!(conditionNode instanceof UAConditionImpl)) {
1065
+ return callback(null, {
1066
+ statusCode: StatusCodes.BadNodeIdInvalid
1067
+ });
1068
+ }
1069
+ const statusCode = conditionNode._setEnabledState(true);
1070
+ return callback(null, {
1071
+ statusCode
1072
+ });
1073
+ }
1074
+
1075
+ function _condition_refresh_method(inputArguments: VariantLike[], context: ISessionContext, callback: any) {
1076
+ // arguments : IntegerId SubscriptionId
1077
+ assert(inputArguments.length === 1);
1078
+ const addressSpace = context.object!.addressSpace as AddressSpacePrivate;
1079
+ if (doDebug) {
1080
+ debugLog(chalk.red(" ConditionType.ConditionRefresh ! subscriptionId ="), inputArguments[0].toString());
1081
+ }
1082
+ const subscriptionId = inputArguments[0].value;
1083
+
1084
+ let statusCode = _check_subscription_id_is_valid(subscriptionId, context);
1085
+ if (statusCode !== StatusCodes.Good) {
1086
+ return statusCode;
1087
+ }
1088
+
1089
+ statusCode = _perform_condition_refresh(addressSpace, inputArguments, context);
1090
+ return callback(null, {
1091
+ statusCode
1092
+ });
1093
+ }
1094
+
1095
+ function _perform_condition_refresh(addressSpace: AddressSpacePrivate, inputArguments: VariantLike[], context: ISessionContext) {
1096
+ // --- possible StatusCodes:
1097
+ //
1098
+ // Bad_SubscriptionIdInvalid See Part 4 for the description of this result code
1099
+ // Bad_RefreshInProgress See Table 74 for the description of this result code
1100
+ // Bad_UserAccessDenied The Method was not called in the context of the Session
1101
+ // that owns the Subscription
1102
+ //
1103
+
1104
+ // istanbul ignore next
1105
+ if (addressSpace._condition_refresh_in_progress) {
1106
+ // a refresh operation is already in progress....
1107
+ return StatusCodes.BadRefreshInProgress;
1108
+ }
1109
+
1110
+ addressSpace._condition_refresh_in_progress = true;
1111
+
1112
+ const server = context.object!.addressSpace.rootFolder.objects.server;
1113
+ const refreshStartEventType = addressSpace.findEventType("RefreshStartEventType")!;
1114
+ const refreshEndEventType = addressSpace.findEventType("RefreshEndEventType")!;
1115
+
1116
+ server.raiseEvent(refreshStartEventType, {});
1117
+ // todo : resend retained conditions
1118
+
1119
+ const _server = server as unknown as { _conditionRefresh: () => void };
1120
+ // starting from server object ..
1121
+ // evaluated all --> hasNotifier/hasEventSource -> node
1122
+ _server._conditionRefresh();
1123
+
1124
+ server.raiseEvent(refreshEndEventType, {});
1125
+
1126
+ addressSpace._condition_refresh_in_progress = false;
1127
+
1128
+ return StatusCodes.Good;
1129
+ }
1130
+
1131
+ function _condition_refresh2_method(inputArguments: VariantLike[], context: ISessionContext, callback: any) {
1132
+ // arguments : IntegerId SubscriptionId
1133
+ // arguments : IntegerId MonitoredItemId
1134
+ assert(inputArguments.length === 2);
1135
+ if (!context.object) {
1136
+ throw new Error("Invalid context => missing Object");
1137
+ }
1138
+ const addressSpace = context.object.addressSpace as AddressSpacePrivate;
1139
+
1140
+ // istanbul ignore next
1141
+ if (doDebug) {
1142
+ debugLog(chalk.cyan.bgWhite(" ConditionType.conditionRefresh2 !"));
1143
+ }
1144
+
1145
+ // xx var subscriptionId = inputArguments[0].value;
1146
+ // xx var monitoredItemId = inputArguments[1].value;
1147
+
1148
+ const statusCode = _perform_condition_refresh(addressSpace, inputArguments, context);
1149
+ return callback(null, {
1150
+ statusCode
1151
+ });
1152
+ }
1153
+
1154
+ function _add_comment_method(inputArguments: VariantLike[], context: ISessionContext, callback: any) {
1155
+ //
1156
+ // The AddComment Method is used to apply a comment to a specific state of a Condition
1157
+ // instance. Normally, the NodeId of the object instance as the ObjectId is passed to the Call
1158
+ // Service. However, some Servers do not expose Condition instances in the AddressSpace.
1159
+ // Therefore all Servers shall also allow Clients to call the AddComment Method by specifying
1160
+ // ConditionId as the ObjectId. The Method cannot be called with an ObjectId of the
1161
+ // ConditionType Node.
1162
+ // Signature
1163
+ // - EventId EventId identifying a particular Event Notification where a state was reported for a
1164
+ // Condition.
1165
+ // - Comment A localized text to be applied to the Condition.
1166
+ //
1167
+ // AlwaysGeneratesEvent AuditConditionCommentEventType
1168
+ //
1169
+ UAConditionImpl.with_condition_method(
1170
+ inputArguments,
1171
+ context,
1172
+ callback,
1173
+ (conditionEventId: ByteString, comment: LocalizedText, branch: ConditionSnapshot, conditionNode: UAConditionImpl) => {
1174
+ assert(inputArguments instanceof Array);
1175
+ assert(conditionEventId instanceof Buffer || conditionEventId === null);
1176
+ assert(branch instanceof ConditionSnapshot);
1177
+ branch.setComment(comment);
1178
+
1179
+ const sourceName = "Method/AddComment";
1180
+
1181
+ conditionNode._raiseAuditConditionCommentEvent(sourceName, conditionEventId, comment);
1182
+
1183
+ // raise new event
1184
+ conditionNode.raiseConditionEvent(branch, true);
1185
+
1186
+ /**
1187
+ * raised when the branch has been added a comment
1188
+ * @event addComment
1189
+ * @param conditionEventId NodeId|null
1190
+ * @param comment {LocalizedText}
1191
+ * @param branch {ConditionSnapshot}
1192
+ */
1193
+ conditionNode.emit("addComment", conditionEventId, comment, branch);
1194
+
1195
+ return StatusCodes.Good;
1196
+ }
1197
+ );
1198
+ }
1199
+
1200
+ function sameBuffer(b1: Buffer | null, b2: Buffer | null) {
1201
+ if (!b1 && !b2) {
1202
+ return true;
1203
+ }
1204
+ if (b1 && !b2) {
1205
+ return false;
1206
+ }
1207
+ if (!b1 && b2) {
1208
+ return false;
1209
+ }
1210
+ assert(b1 instanceof Buffer);
1211
+ assert(b2 instanceof Buffer);
1212
+ if (b1!.length !== b2!.length) {
1213
+ return false;
1214
+ }
1215
+ /*
1216
+ var bb1 = (Buffer.from(b1)).toString("hex");
1217
+ var bb2 = (Buffer.from(b2)).toString("hex");
1218
+ return bb1 === bb2;
1219
+ */
1220
+ const n = b1!.length;
1221
+ for (let i = 0; i < n; i++) {
1222
+ if (b1![i] !== b2![i]) {
1223
+ return false;
1224
+ }
1225
+ }
1226
+ return true;
1227
+ }
1228
+
1229
+ function _create_new_branch_id() {
1230
+ return makeNodeId(randomGuid(), 1);
1231
+ }
1232
+
1233
+ function _update_sourceTimestamp<T, DT extends DataType>(this: UAConditionVariable<T, DT>, dataValue: DataValue /*, indexRange*/) {
1234
+ this.sourceTimestamp.setValueFromSource({
1235
+ dataType: DataType.DateTime,
1236
+ value: dataValue.sourceTimestamp
1237
+ });
1238
+ }
1239
+
1240
+ // tslint:disable:no-console
1241
+ function _install_condition_variable_type<T, DT extends DataType>(node: UAConditionVariable<T, DT>) {
1242
+ // from spec 1.03 : 5.3 condition variables
1243
+ // However, a change in their value is considered important and supposed to trigger
1244
+ // an Event Notification. These information elements are called ConditionVariables.
1245
+ if (node.sourceTimestamp) {
1246
+ node.sourceTimestamp.accessLevel = makeAccessLevelFlag("CurrentRead");
1247
+ } else {
1248
+ console.warn("cannot find node.sourceTimestamp", node.browseName.toString());
1249
+ }
1250
+ node.accessLevel = makeAccessLevelFlag("CurrentRead");
1251
+
1252
+ // from spec 1.03 : 5.3 condition variables
1253
+ // a condition VariableType has a sourceTimeStamp exposed property
1254
+ // SourceTimestamp indicates the time of the last change of the Value of this ConditionVariable.
1255
+ // It shall be the same time that would be returned from the Read Service inside the DataValue
1256
+ // structure for the ConditionVariable Value Attribute.
1257
+
1258
+ assert(node.typeDefinitionObj.browseName.toString() === "ConditionVariableType");
1259
+ assert(node.sourceTimestamp.browseName.toString() === "SourceTimestamp");
1260
+ node.on("value_changed", _update_sourceTimestamp);
1261
+ }
1262
+
1263
+ /**
1264
+ * @method _getCompositeKey
1265
+ * @param node {BaseNode}
1266
+ * @param key {String}
1267
+ * @return {BaseNode}
1268
+ * @private
1269
+ *
1270
+ * @example
1271
+ *
1272
+ * var node = _getComposite(node,"enabledState.id");
1273
+ *
1274
+ */
1275
+ function _getCompositeKey(node: BaseNode, key: string): UAVariableImpl {
1276
+ let cur = node as any;
1277
+ const elements = key.split(".");
1278
+ for (const e of elements) {
1279
+ // istanbul ignore next
1280
+ if (!Object.prototype.hasOwnProperty.call(cur,e)) {
1281
+ throw new Error(" cannot extract '" + key + "' from " + node.browseName.toString());
1282
+ }
1283
+ cur = (cur as any)[e];
1284
+ }
1285
+ return cur as UAVariableImpl;
1286
+ }
1287
+
1288
+ /**
1289
+ * verify that the subscription id belongs to the session that make the call.
1290
+ * @method _check_subscription_id_is_valid
1291
+ * @param subscriptionId {Number}
1292
+ * @param context {Object}
1293
+ * @private
1294
+ */
1295
+ function _check_subscription_id_is_valid(subscriptionId: number, context: ISessionContext) {
1296
+ /// todo: return StatusCodes.BadSubscriptionIdInvalid; if subscriptionId doesn't belong to session...
1297
+ return StatusCodes.Good;
1298
+ }