node-opcua-address-space 2.71.0 → 2.72.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/dist/source/address_space_ts.d.ts +118 -118
  2. package/dist/source/address_space_ts.js +17 -17
  3. package/dist/source/continuation_points/continuation_point_manager.d.ts +32 -32
  4. package/dist/source/continuation_points/continuation_point_manager.js +195 -195
  5. package/dist/source/helpers/adjust_browse_direction.d.ts +5 -5
  6. package/dist/source/helpers/adjust_browse_direction.js +11 -11
  7. package/dist/source/helpers/argument_list.d.ts +34 -34
  8. package/dist/source/helpers/argument_list.js +285 -285
  9. package/dist/source/helpers/call_helpers.d.ts +6 -6
  10. package/dist/source/helpers/call_helpers.js +70 -70
  11. package/dist/source/helpers/check_event_clause.d.ts +17 -17
  12. package/dist/source/helpers/check_event_clause.js +52 -52
  13. package/dist/source/helpers/coerce_enum_value.d.ts +6 -6
  14. package/dist/source/helpers/coerce_enum_value.js +33 -33
  15. package/dist/source/helpers/dump_tools.d.ts +14 -14
  16. package/dist/source/helpers/dump_tools.js +78 -78
  17. package/dist/source/helpers/ensure_secure_access.d.ts +9 -9
  18. package/dist/source/helpers/ensure_secure_access.js +76 -76
  19. package/dist/source/helpers/make_optionals_map.d.ts +21 -21
  20. package/dist/source/helpers/make_optionals_map.js +29 -29
  21. package/dist/source/helpers/multiform_func.d.ts +11 -11
  22. package/dist/source/helpers/multiform_func.js +73 -73
  23. package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -3
  24. package/dist/source/helpers/resolve_opaque_on_address_space.js +36 -36
  25. package/dist/source/index.d.ts +40 -40
  26. package/dist/source/index.js +66 -66
  27. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +12 -12
  28. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +2 -2
  29. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -21
  30. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +2 -2
  31. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -24
  32. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +2 -2
  33. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -12
  34. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +2 -2
  35. package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -8
  36. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +2 -2
  37. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -12
  38. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +2 -2
  39. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -49
  40. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +2 -2
  41. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -11
  42. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +2 -2
  43. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +222 -222
  44. package/dist/source/interfaces/state_machine/ua_state_machine_type.js +2 -2
  45. package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -6
  46. package/dist/source/interfaces/state_machine/ua_transition_ex.js +2 -2
  47. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -8
  48. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +2 -2
  49. package/dist/source/loader/decode_xml_extension_object.d.ts +6 -6
  50. package/dist/source/loader/decode_xml_extension_object.js +71 -71
  51. package/dist/source/loader/ensure_datatype_extracted.d.ts +5 -5
  52. package/dist/source/loader/ensure_datatype_extracted.js +45 -45
  53. package/dist/source/loader/generateAddressSpaceRaw.d.ts +10 -10
  54. package/dist/source/loader/generateAddressSpaceRaw.js +45 -45
  55. package/dist/source/loader/load_nodeset2.d.ts +16 -16
  56. package/dist/source/loader/load_nodeset2.js +1468 -1464
  57. package/dist/source/loader/load_nodeset2.js.map +1 -1
  58. package/dist/source/loader/make_semver_compatible.d.ts +6 -0
  59. package/dist/source/loader/make_semver_compatible.js +26 -0
  60. package/dist/source/loader/make_semver_compatible.js.map +1 -0
  61. package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -28
  62. package/dist/source/loader/make_xml_extension_object_parser.js +325 -315
  63. package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
  64. package/dist/source/loader/namespace_post_step.d.ts +6 -6
  65. package/dist/source/loader/namespace_post_step.js +47 -47
  66. package/dist/source/loader/register_node_promoter.d.ts +3 -3
  67. package/dist/source/loader/register_node_promoter.js +9 -9
  68. package/dist/source/namespace.d.ts +6 -6
  69. package/dist/source/namespace.js +2 -2
  70. package/dist/source/namespace_alarm_and_condition.d.ts +24 -24
  71. package/dist/source/namespace_alarm_and_condition.js +2 -2
  72. package/dist/source/namespace_data_access.d.ts +42 -42
  73. package/dist/source/namespace_data_access.js +2 -2
  74. package/dist/source/namespace_machine_state.d.ts +7 -7
  75. package/dist/source/namespace_machine_state.js +2 -2
  76. package/dist/source/pseudo_session.d.ts +55 -55
  77. package/dist/source/pseudo_session.js +203 -203
  78. package/dist/source/session_context.d.ts +111 -111
  79. package/dist/source/session_context.js +265 -265
  80. package/dist/source/set_namespace_meta_data.d.ts +2 -2
  81. package/dist/source/set_namespace_meta_data.js +59 -59
  82. package/dist/source/ua_root_folder.d.ts +9 -9
  83. package/dist/source/ua_root_folder.js +2 -2
  84. package/dist/source/ua_two_state_variable_ex.d.ts +23 -23
  85. package/dist/source/ua_two_state_variable_ex.js +2 -2
  86. package/dist/source/xml_writer.d.ts +9 -9
  87. package/dist/source/xml_writer.js +2 -2
  88. package/dist/src/address_space.d.ts +392 -392
  89. package/dist/src/address_space.js +1387 -1387
  90. package/dist/src/address_space_change_event_tools.d.ts +6 -6
  91. package/dist/src/address_space_change_event_tools.js +149 -149
  92. package/dist/src/address_space_private.d.ts +43 -43
  93. package/dist/src/address_space_private.js +2 -2
  94. package/dist/src/alarms_and_conditions/check_where_clause.d.ts +4 -4
  95. package/dist/src/alarms_and_conditions/check_where_clause.js +109 -109
  96. package/dist/src/alarms_and_conditions/condition.d.ts +5 -5
  97. package/dist/src/alarms_and_conditions/condition.js +80 -80
  98. package/dist/src/alarms_and_conditions/condition_info.d.ts +27 -27
  99. package/dist/src/alarms_and_conditions/condition_info.js +54 -54
  100. package/dist/src/alarms_and_conditions/condition_snapshot.d.ts +233 -233
  101. package/dist/src/alarms_and_conditions/condition_snapshot.js +666 -666
  102. package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +21 -21
  103. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +46 -46
  104. package/dist/src/alarms_and_conditions/extract_event_fields.d.ts +10 -10
  105. package/dist/src/alarms_and_conditions/extract_event_fields.js +89 -89
  106. package/dist/src/alarms_and_conditions/index.d.ts +18 -18
  107. package/dist/src/alarms_and_conditions/index.js +34 -34
  108. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +64 -62
  109. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -244
  110. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
  111. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +124 -118
  112. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +416 -416
  113. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  114. package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +29 -29
  115. package/dist/src/alarms_and_conditions/ua_base_event_impl.js +38 -38
  116. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +36 -21
  117. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +115 -25
  118. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  119. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +187 -182
  120. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1024 -1022
  121. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  122. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +18 -17
  123. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +57 -57
  124. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -1
  125. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +30 -27
  126. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +56 -56
  127. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js.map +1 -1
  128. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +11 -9
  129. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +11 -11
  130. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js.map +1 -1
  131. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +40 -38
  132. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +86 -86
  133. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -1
  134. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +10 -10
  135. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +7 -7
  136. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +105 -97
  137. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +250 -250
  138. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -1
  139. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +29 -28
  140. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +50 -50
  141. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js.map +1 -1
  142. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +26 -25
  143. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +162 -162
  144. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -1
  145. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +48 -39
  146. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +161 -135
  147. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
  148. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +17 -16
  149. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +17 -17
  150. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js.map +1 -1
  151. package/dist/src/apply_condition_refresh.d.ts +6 -6
  152. package/dist/src/apply_condition_refresh.js +27 -27
  153. package/dist/src/base_node_impl.d.ts +281 -281
  154. package/dist/src/base_node_impl.js +1395 -1395
  155. package/dist/src/base_node_private.d.ts +61 -61
  156. package/dist/src/base_node_private.js +705 -705
  157. package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -11
  158. package/dist/src/data_access/add_dataItem_stuff.js +61 -61
  159. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -1
  160. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +34 -34
  161. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -32
  162. package/dist/src/data_access/ua_multistate_discrete_impl.js +130 -130
  163. package/dist/src/data_access/ua_multistate_value_discrete.d.ts +51 -51
  164. package/dist/src/data_access/ua_multistate_value_discrete.js +249 -249
  165. package/dist/src/data_access/ua_two_state_discrete.d.ts +25 -25
  166. package/dist/src/data_access/ua_two_state_discrete.js +153 -153
  167. package/dist/src/event_data.d.ts +29 -29
  168. package/dist/src/event_data.js +95 -95
  169. package/dist/src/extension_object_array_node.d.ts +61 -61
  170. package/dist/src/extension_object_array_node.js +276 -276
  171. package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -26
  172. package/dist/src/historical_access/address_space_historical_data_node.js +630 -630
  173. package/dist/src/index_current.d.ts +45 -45
  174. package/dist/src/index_current.js +77 -77
  175. package/dist/src/namespace_impl.d.ts +457 -457
  176. package/dist/src/namespace_impl.js +1733 -1733
  177. package/dist/src/namespace_private.d.ts +21 -21
  178. package/dist/src/namespace_private.js +32 -32
  179. package/dist/src/nodeid_manager.d.ts +36 -36
  180. package/dist/src/nodeid_manager.js +197 -197
  181. package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -2
  182. package/dist/src/nodeset_tools/adjust_namespace_array.js +13 -13
  183. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +2 -2
  184. package/dist/src/nodeset_tools/construct_namespace_dependency.js +83 -83
  185. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +2 -2
  186. package/dist/src/nodeset_tools/nodeset_to_xml.js +1143 -1143
  187. package/dist/src/nodeset_tools/typedictionary_to_xml.d.ts +2 -2
  188. package/dist/src/nodeset_tools/typedictionary_to_xml.js +154 -154
  189. package/dist/src/reference_impl.d.ts +43 -43
  190. package/dist/src/reference_impl.js +139 -139
  191. package/dist/src/role_permissions.d.ts +2 -2
  192. package/dist/src/role_permissions.js +10 -10
  193. package/dist/src/state_machine/finite_state_machine.d.ts +67 -67
  194. package/dist/src/state_machine/finite_state_machine.js +353 -353
  195. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +34 -34
  196. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +250 -250
  197. package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -61
  198. package/dist/src/state_machine/ua_two_state_variable.js +331 -331
  199. package/dist/src/tool_isSupertypeOf.d.ts +17 -17
  200. package/dist/src/tool_isSupertypeOf.js +108 -108
  201. package/dist/src/ua_condition_type.d.ts +8 -8
  202. package/dist/src/ua_condition_type.js +2 -2
  203. package/dist/src/ua_data_type_impl.d.ts +93 -93
  204. package/dist/src/ua_data_type_impl.js +368 -368
  205. package/dist/src/ua_method_impl.d.ts +41 -41
  206. package/dist/src/ua_method_impl.js +208 -208
  207. package/dist/src/ua_object_impl.d.ts +35 -33
  208. package/dist/src/ua_object_impl.js +162 -156
  209. package/dist/src/ua_object_impl.js.map +1 -1
  210. package/dist/src/ua_object_type_impl.d.ts +48 -48
  211. package/dist/src/ua_object_type_impl.js +124 -124
  212. package/dist/src/ua_reference_type_impl.d.ts +43 -43
  213. package/dist/src/ua_reference_type_impl.js +139 -139
  214. package/dist/src/ua_variable_impl.d.ts +351 -351
  215. package/dist/src/ua_variable_impl.js +1604 -1604
  216. package/dist/src/ua_variable_impl_ext_obj.d.ts +17 -17
  217. package/dist/src/ua_variable_impl_ext_obj.js +437 -437
  218. package/dist/src/ua_variable_type_impl.d.ts +62 -62
  219. package/dist/src/ua_variable_type_impl.js +570 -570
  220. package/dist/src/ua_view_impl.d.ts +19 -15
  221. package/dist/src/ua_view_impl.js +43 -36
  222. package/dist/src/ua_view_impl.js.map +1 -1
  223. package/distHelpers/add_event_generator_object.d.ts +3 -3
  224. package/distHelpers/add_event_generator_object.js +65 -65
  225. package/distHelpers/alarms_and_conditions_demo.d.ts +10 -10
  226. package/distHelpers/alarms_and_conditions_demo.js +114 -114
  227. package/distHelpers/assertHasMatchingReference.d.ts +19 -19
  228. package/distHelpers/assertHasMatchingReference.js +40 -40
  229. package/distHelpers/boiler_system.d.ts +113 -113
  230. package/distHelpers/boiler_system.js +395 -395
  231. package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -5
  232. package/distHelpers/create_minimalist_address_space_nodeset.js +171 -171
  233. package/distHelpers/date_utils.d.ts +3 -3
  234. package/distHelpers/date_utils.js +9 -9
  235. package/distHelpers/dump_statemachine.js +127 -127
  236. package/distHelpers/get_address_space_fixture.d.ts +1 -1
  237. package/distHelpers/get_address_space_fixture.js +30 -30
  238. package/distHelpers/get_mini_address_space.d.ts +7 -7
  239. package/distHelpers/get_mini_address_space.js +36 -36
  240. package/distHelpers/index.d.ts +12 -12
  241. package/distHelpers/index.js +28 -28
  242. package/distHelpers/mock_session.d.ts +14 -14
  243. package/distHelpers/mock_session.js +25 -25
  244. package/distNodeJS/generate_address_space.d.ts +4 -4
  245. package/distNodeJS/generate_address_space.js +41 -41
  246. package/distNodeJS/index.d.ts +1 -1
  247. package/distNodeJS/index.js +17 -17
  248. package/package.json +23 -23
  249. package/source/loader/load_nodeset2.ts +21 -17
  250. package/source/loader/make_semver_compatible.ts +23 -0
  251. package/source/loader/make_xml_extension_object_parser.ts +16 -6
  252. package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +13 -6
  253. package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +15 -10
  254. package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +126 -10
  255. package/src/alarms_and_conditions/ua_condition_impl.ts +26 -13
  256. package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +10 -4
  257. package/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.ts +7 -6
  258. package/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.ts +5 -3
  259. package/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.ts +7 -6
  260. package/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.ts +1 -1
  261. package/src/alarms_and_conditions/ua_limit_alarm_impl.ts +23 -13
  262. package/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.ts +6 -7
  263. package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +6 -7
  264. package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +62 -30
  265. package/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.ts +5 -5
  266. package/src/ua_object_impl.ts +11 -3
  267. package/src/ua_view_impl.ts +6 -4
  268. package/test_helpers/test_fixtures/dataType_issue.xml +9 -9
  269. package/test_helpers/test_fixtures/nodeset_with_guid.xml +1442 -0
  270. package/test_helpers/test_fixtures/nodeset_with_int64_values.xml +31 -0
  271. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.d.ts +0 -23
  272. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js +0 -3
  273. package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js.map +0 -1
  274. package/dist/source/interfaces/data_access/ua_discrete_item.d.ts +0 -6
  275. package/dist/source/interfaces/data_access/ua_discrete_item.js +0 -3
  276. package/dist/source/interfaces/data_access/ua_discrete_item.js.map +0 -1
  277. package/dist/source/interfaces/data_access/ua_multistate_discrete.d.ts +0 -25
  278. package/dist/source/interfaces/data_access/ua_multistate_discrete.js +0 -3
  279. package/dist/source/interfaces/data_access/ua_multistate_discrete.js.map +0 -1
  280. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.d.ts +0 -27
  281. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js +0 -3
  282. package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js.map +0 -1
  283. package/dist/source/interfaces/data_access/ua_two_state_discrete.d.ts +0 -17
  284. package/dist/source/interfaces/data_access/ua_two_state_discrete.js +0 -3
  285. package/dist/source/interfaces/data_access/ua_two_state_discrete.js.map +0 -1
  286. package/dist/source/interfaces/data_access/ua_y_array_item.d.ts +0 -19
  287. package/dist/source/interfaces/data_access/ua_y_array_item.js +0 -3
  288. package/dist/source/interfaces/data_access/ua_y_array_item.js.map +0 -1
  289. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.d.ts +0 -11
  290. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js +0 -3
  291. package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js.map +0 -1
  292. package/dist/source/interfaces/state_machine/finite_state_machine.d.ts +0 -70
  293. package/dist/source/interfaces/state_machine/finite_state_machine.js +0 -3
  294. package/dist/source/interfaces/state_machine/finite_state_machine.js.map +0 -1
  295. package/dist/source/interfaces/state_machine/program_finite_state_machine.d.ts +0 -74
  296. package/dist/source/interfaces/state_machine/program_finite_state_machine.js +0 -3
  297. package/dist/source/interfaces/state_machine/program_finite_state_machine.js.map +0 -1
  298. package/dist/source/interfaces/state_machine/state_machine.d.ts +0 -342
  299. package/dist/source/interfaces/state_machine/state_machine.js +0 -3
  300. package/dist/source/interfaces/state_machine/state_machine.js.map +0 -1
  301. package/dist/source/interfaces/state_machine/ua_finite_state_variable.d.ts +0 -18
  302. package/dist/source/interfaces/state_machine/ua_finite_state_variable.js +0 -3
  303. package/dist/source/interfaces/state_machine/ua_finite_state_variable.js.map +0 -1
  304. package/dist/source/interfaces/state_machine/ua_state_variable.d.ts +0 -29
  305. package/dist/source/interfaces/state_machine/ua_state_variable.js +0 -3
  306. package/dist/source/interfaces/state_machine/ua_state_variable.js.map +0 -1
  307. package/dist/source/interfaces/state_machine/ua_two_state_variable.d.ts +0 -26
  308. package/dist/source/interfaces/state_machine/ua_two_state_variable.js +0 -3
  309. package/dist/source/interfaces/state_machine/ua_two_state_variable.js.map +0 -1
  310. package/dist/source/interfaces/subscription_diagnostics_variable.d.ts +0 -41
  311. package/dist/source/interfaces/subscription_diagnostics_variable.js +0 -3
  312. package/dist/source/interfaces/subscription_diagnostics_variable.js.map +0 -1
  313. package/dist/src/alarms_and_conditions/base_event_type.d.ts +0 -26
  314. package/dist/src/alarms_and_conditions/base_event_type.js +0 -41
  315. package/dist/src/alarms_and_conditions/base_event_type.js.map +0 -1
  316. package/dist/src/alarms_and_conditions/shelving_state_machine.d.ts +0 -22
  317. package/dist/src/alarms_and_conditions/shelving_state_machine.js +0 -241
  318. package/dist/src/alarms_and_conditions/shelving_state_machine.js.map +0 -1
  319. package/dist/src/alarms_and_conditions/trip_alarm.d.ts +0 -16
  320. package/dist/src/alarms_and_conditions/trip_alarm.js +0 -21
  321. package/dist/src/alarms_and_conditions/trip_alarm.js.map +0 -1
  322. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.d.ts +0 -54
  323. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js +0 -255
  324. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js.map +0 -1
  325. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.d.ts +0 -138
  326. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js +0 -460
  327. package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js.map +0 -1
  328. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.d.ts +0 -35
  329. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js +0 -32
  330. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js.map +0 -1
  331. package/dist/src/alarms_and_conditions/ua_condition_base.d.ts +0 -191
  332. package/dist/src/alarms_and_conditions/ua_condition_base.js +0 -1029
  333. package/dist/src/alarms_and_conditions/ua_condition_base.js.map +0 -1
  334. package/dist/src/alarms_and_conditions/ua_discrete_alarm.d.ts +0 -11
  335. package/dist/src/alarms_and_conditions/ua_discrete_alarm.js +0 -58
  336. package/dist/src/alarms_and_conditions/ua_discrete_alarm.js.map +0 -1
  337. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.d.ts +0 -24
  338. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js +0 -59
  339. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js.map +0 -1
  340. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.d.ts +0 -14
  341. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js +0 -17
  342. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js.map +0 -1
  343. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.d.ts +0 -22
  344. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js +0 -87
  345. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js.map +0 -1
  346. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.d.ts +0 -6
  347. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js +0 -11
  348. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js.map +0 -1
  349. package/dist/src/alarms_and_conditions/ua_limit_alarm.d.ts +0 -76
  350. package/dist/src/alarms_and_conditions/ua_limit_alarm.js +0 -237
  351. package/dist/src/alarms_and_conditions/ua_limit_alarm.js.map +0 -1
  352. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.d.ts +0 -27
  353. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js +0 -62
  354. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js.map +0 -1
  355. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.d.ts +0 -49
  356. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js +0 -176
  357. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js.map +0 -1
  358. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.d.ts +0 -47
  359. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js +0 -151
  360. package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js.map +0 -1
  361. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.d.ts +0 -16
  362. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js +0 -18
  363. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js.map +0 -1
  364. package/dist/src/base_node.d.ts +0 -270
  365. package/dist/src/base_node.js +0 -1299
  366. package/dist/src/base_node.js.map +0 -1
  367. package/dist/src/data_access/ua_analog_item.d.ts +0 -13
  368. package/dist/src/data_access/ua_analog_item.js +0 -37
  369. package/dist/src/data_access/ua_analog_item.js.map +0 -1
  370. package/dist/src/data_access/ua_data_item.d.ts +0 -16
  371. package/dist/src/data_access/ua_data_item.js +0 -66
  372. package/dist/src/data_access/ua_data_item.js.map +0 -1
  373. package/dist/src/data_access/ua_multistate_discrete.d.ts +0 -24
  374. package/dist/src/data_access/ua_multistate_discrete.js +0 -132
  375. package/dist/src/data_access/ua_multistate_discrete.js.map +0 -1
  376. package/dist/src/namespace.d.ts +0 -472
  377. package/dist/src/namespace.js +0 -1759
  378. package/dist/src/namespace.js.map +0 -1
  379. package/dist/src/reference.d.ts +0 -43
  380. package/dist/src/reference.js +0 -138
  381. package/dist/src/reference.js.map +0 -1
  382. package/dist/src/session_context.d.ts +0 -4
  383. package/dist/src/session_context.js +0 -9
  384. package/dist/src/session_context.js.map +0 -1
  385. package/dist/src/ua_data_type.d.ts +0 -81
  386. package/dist/src/ua_data_type.js +0 -259
  387. package/dist/src/ua_data_type.js.map +0 -1
  388. package/dist/src/ua_method.d.ts +0 -33
  389. package/dist/src/ua_method.js +0 -194
  390. package/dist/src/ua_method.js.map +0 -1
  391. package/dist/src/ua_object.d.ts +0 -27
  392. package/dist/src/ua_object.js +0 -153
  393. package/dist/src/ua_object.js.map +0 -1
  394. package/dist/src/ua_object_type.d.ts +0 -49
  395. package/dist/src/ua_object_type.js +0 -123
  396. package/dist/src/ua_object_type.js.map +0 -1
  397. package/dist/src/ua_reference_type.d.ts +0 -31
  398. package/dist/src/ua_reference_type.js +0 -108
  399. package/dist/src/ua_reference_type.js.map +0 -1
  400. package/dist/src/ua_variable.d.ts +0 -346
  401. package/dist/src/ua_variable.js +0 -1651
  402. package/dist/src/ua_variable.js.map +0 -1
  403. package/dist/src/ua_variable_type.d.ts +0 -57
  404. package/dist/src/ua_variable_type.js +0 -530
  405. package/dist/src/ua_variable_type.js.map +0 -1
  406. package/dist/src/ua_view.d.ts +0 -16
  407. package/dist/src/ua_view.js +0 -41
  408. package/dist/src/ua_view.js.map +0 -1
@@ -1,1029 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UAConditionBase = void 0;
4
- /**
5
- * @module node-opcua-address-space.AlarmsAndConditions
6
- */
7
- const chalk = require("chalk");
8
- const node_opcua_assert_1 = require("node-opcua-assert");
9
- const node_opcua_basic_types_1 = require("node-opcua-basic-types");
10
- const node_opcua_data_model_1 = require("node-opcua-data-model");
11
- const node_opcua_debug_1 = require("node-opcua-debug");
12
- const node_opcua_factory_1 = require("node-opcua-factory");
13
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
14
- const node_opcua_status_code_1 = require("node-opcua-status-code");
15
- const node_opcua_types_1 = require("node-opcua-types");
16
- const node_opcua_variant_1 = require("node-opcua-variant");
17
- const source_1 = require("../../source");
18
- const base_node_1 = require("../base_node");
19
- const ua_object_1 = require("../ua_object");
20
- const ua_object_type_1 = require("../ua_object_type");
21
- const ua_two_state_variable_1 = require("../state_machine/ua_two_state_variable");
22
- const base_event_type_1 = require("./base_event_type");
23
- const condition_snapshot_1 = require("./condition_snapshot");
24
- const debugLog = node_opcua_debug_1.make_debugLog(__filename);
25
- const errorLog = node_opcua_debug_1.make_errorLog(__filename);
26
- const doDebug = node_opcua_debug_1.checkDebugFlag(__filename);
27
- /**
28
- * @class UAConditionBase
29
- * @constructor
30
- * @extends BaseEventType
31
- *
32
- *
33
- * └─ ConditionType
34
- * ├─ DialogConditionType
35
- * └─ AcknowledgeableConditionType
36
- * └─ AlarmConditionType
37
- * ├─ LimitAlarmType
38
- * │ ├─ ExclusiveLimitAlarmType
39
- * │ │ ├─ ExclusiveLevelAlarmType
40
- * │ │ ├─ ExclusiveDeviationAlarmType
41
- * │ │ └─ ExclusiveRateOfChangeAlarmType
42
- * │ └─ NonExclusiveLimitAlarmType
43
- * │ ├─ NonExclusiveLevelAlarmType
44
- * │ ├─ NonExclusiveDeviationAlarmType
45
- * │ └─ NonExclusiveRateOfChangeAlarmType
46
- * └─ DiscreteAlarmType
47
- * ├─ OffNormalAlarmType
48
- * │ ├─ SystemOffNormalAlarmType
49
- * │ │ └─ CertificateExpirationAlarmType
50
- * │ └─ TripAlarmType
51
- *
52
- */
53
- class UAConditionBase extends base_event_type_1.BaseEventType {
54
- constructor() {
55
- super(...arguments);
56
- this._branch0 = null;
57
- this._previousRetainFlag = false;
58
- this._branches = {};
59
- }
60
- static instantiate(namespace, conditionTypeId, options, data) {
61
- return UAConditionBase_instantiate(namespace, conditionTypeId, options, data);
62
- }
63
- static install_condition_refresh_handle(addressSpace) {
64
- //
65
- // install ConditionRefresh
66
- //
67
- // NOTE:
68
- // OPCUA doesn't implement the condition refresh method ! yet
69
- // .5.7 ConditionRefresh Method
70
- // ConditionRefresh allows a Client to request a Refresh of all Condition instances that currently
71
- // are in an interesting state (they have the Retain flag set). This includes previous states of a
72
- // Condition instance for which the Server maintains Branches. A Client would typically invoke
73
- // this Method when it initially connects to a Server and following any situations, such as
74
- // communication disruptions, in which it would require resynchronization with the Server. This
75
- // Method is only available on the ConditionType or its subtypes. To invoke this Method, the call
76
- // shall pass the well known MethodId of the Method on the ConditionType and the ObjectId
77
- // shall be the well known ObjectId of the ConditionType Object.
78
- const conditionType = addressSpace.findEventType("ConditionType");
79
- node_opcua_assert_1.assert(conditionType !== null);
80
- conditionType.disable.bindMethod(_disable_method);
81
- conditionType.enable.bindMethod(_enable_method);
82
- conditionType.conditionRefresh.bindMethod(_condition_refresh_method);
83
- conditionType.conditionRefresh2.bindMethod(_condition_refresh2_method);
84
- // those methods can be call on the ConditionType or on the ConditionInstance itself...
85
- conditionType.addComment.bindMethod(_add_comment_method);
86
- }
87
- /**
88
- *
89
- * Helper method to handle condition methods that takes a branchId and a comment
90
- *
91
- */
92
- static with_condition_method(inputArguments, context, callback, inner_func) {
93
- const conditionNode = context.object;
94
- // xx console.log(inputArguments.map(function(a){return a.toString()}));
95
- if (!(conditionNode instanceof UAConditionBase)) {
96
- callback(null, {
97
- statusCode: node_opcua_status_code_1.StatusCodes.BadNodeIdInvalid
98
- });
99
- return;
100
- }
101
- if (!conditionNode.getEnabledState()) {
102
- callback(null, {
103
- statusCode: node_opcua_status_code_1.StatusCodes.BadConditionDisabled
104
- });
105
- return;
106
- }
107
- // inputArguments has 2 arguments
108
- // EventId => ByteString The Identifier of the event to comment
109
- // Comment => LocalizedText The Comment to add to the condition
110
- node_opcua_assert_1.assert(inputArguments.length === 2);
111
- node_opcua_assert_1.assert(inputArguments[0].dataType === node_opcua_variant_1.DataType.ByteString);
112
- node_opcua_assert_1.assert(inputArguments[1].dataType === node_opcua_variant_1.DataType.LocalizedText);
113
- const eventId = inputArguments[0].value;
114
- node_opcua_assert_1.assert(!eventId || eventId instanceof Buffer);
115
- const comment = inputArguments[1].value;
116
- node_opcua_assert_1.assert(comment instanceof node_opcua_data_model_1.LocalizedText);
117
- const branch = conditionNode._findBranchForEventId(eventId);
118
- if (!branch) {
119
- callback(null, {
120
- statusCode: node_opcua_status_code_1.StatusCodes.BadEventIdUnknown
121
- });
122
- return;
123
- }
124
- node_opcua_assert_1.assert(branch instanceof condition_snapshot_1.ConditionSnapshot);
125
- const statusCode = inner_func(eventId, comment, branch, conditionNode);
126
- // record also who did the call
127
- branch.setClientUserId(context.userIdentity || "<unknown client user id>");
128
- callback(null, {
129
- statusCode
130
- });
131
- }
132
- /**
133
- * @method initialize
134
- * @private
135
- */
136
- initialize() {
137
- this._branches = {};
138
- }
139
- /**
140
- * @method post_initialize
141
- * @private
142
- */
143
- post_initialize() {
144
- node_opcua_assert_1.assert(!this._branch0);
145
- this._branch0 = new condition_snapshot_1.ConditionSnapshot(this, node_opcua_nodeid_1.NodeId.nullNodeId);
146
- // the condition OPCUA object alway reflects the default branch states
147
- // so we set a mechanism that automatically keeps self in sync
148
- // with the default branch.
149
- // the implication of this convention is that interacting with the condition variable
150
- // shall be made by using branch0, any value change made
151
- // using the standard setValueFromSource mechanism will not be work properly.
152
- this._branch0.on("value_changed", (node, variant) => {
153
- node_opcua_assert_1.assert(node.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
154
- node.setValueFromSource(variant);
155
- });
156
- }
157
- getBranchCount() {
158
- return Object.keys(this._branches).length;
159
- }
160
- getBranches() {
161
- return Object.keys(this._branches).map((x) => {
162
- return this._branches[x];
163
- });
164
- }
165
- getBranchIds() {
166
- return this.getBranches().map((b) => b.getBranchId());
167
- }
168
- /**
169
- * @method createBranch
170
- * @return {ConditionSnapshot}
171
- */
172
- createBranch() {
173
- const branchId = _create_new_branch_id();
174
- const snapshot = new condition_snapshot_1.ConditionSnapshot(this, branchId);
175
- this._branches[branchId.toString()] = snapshot;
176
- return snapshot;
177
- }
178
- /**
179
- * @method deleteBranch
180
- * @param branch {ConditionSnapshot}
181
- */
182
- deleteBranch(branch) {
183
- const key = branch.getBranchId().toString();
184
- node_opcua_assert_1.assert(branch.getBranchId() !== node_opcua_nodeid_1.NodeId.nullNodeId, "cannot delete branch zero");
185
- node_opcua_assert_1.assert(this._branches.hasOwnProperty(key));
186
- delete this._branches[key];
187
- this.emit("branch_deleted", key);
188
- }
189
- /**
190
- * @method getEnabledState
191
- * @return {Boolean}
192
- */
193
- getEnabledState() {
194
- return this.enabledState.getValue();
195
- }
196
- /**
197
- * @method getEnabledStateAsString
198
- * @return {String}
199
- */
200
- getEnabledStateAsString() {
201
- return this.enabledState.getValueAsString();
202
- }
203
- /**
204
- * @method _setEnabledState
205
- * @param requestedEnabledState {Boolean}
206
- * @return {StatusCode} StatusCodes.Good if successful or BadConditionAlreadyEnabled/BadConditionAlreadyDisabled
207
- * @private
208
- */
209
- _setEnabledState(requestedEnabledState) {
210
- node_opcua_assert_1.assert(typeof requestedEnabledState === "boolean");
211
- const enabledState = this.getEnabledState();
212
- if (enabledState && requestedEnabledState) {
213
- return node_opcua_status_code_1.StatusCodes.BadConditionAlreadyEnabled;
214
- }
215
- if (!enabledState && !requestedEnabledState) {
216
- return node_opcua_status_code_1.StatusCodes.BadConditionAlreadyDisabled;
217
- }
218
- this._branch0.setEnabledState(requestedEnabledState);
219
- // conditionNode.enabledState.setValue(requestedEnabledState);
220
- // xx assert(conditionNode.enabledState.id.readValue().value.value === requestedEnabledState,"sanity check 1");
221
- // xx assert(conditionNode.currentBranch().getEnabledState() === requestedEnabledState,"sanity check 2");
222
- if (!requestedEnabledState) {
223
- // as per Spec 1.0.3 part 9:
224
- // * When the Condition instance enters the Disabled state, the Retain Property of this
225
- // Condition shall be set to FALSE by the Server to indicate to the Client that the
226
- // Condition instance is currently not of interest to Clients.
227
- // TODO : shall we really set retain to false or artificially expose the retain false as false
228
- // whist enabled state is false ?
229
- this._previousRetainFlag = this.currentBranch().getRetain();
230
- this.currentBranch().setRetain(false);
231
- // todo: install the mechanism by which all condition values will be return
232
- // as Null | BadConditionDisabled;
233
- const statusCode = node_opcua_status_code_1.StatusCodes.BadConditionDisabled;
234
- // a notification must be send
235
- this.raiseConditionEvent(this.currentBranch(), true);
236
- }
237
- else {
238
- // * When the Condition instance enters the enabled state, the Condition shall be
239
- // evaluated and all of its Properties updated to reflect the current values. If this
240
- // evaluation causes the Retain Property to transition to TRUE for any ConditionBranch,
241
- // then an Event Notification shall be generated for that ConditionBranch.
242
- this.evaluateConditionsAfterEnabled();
243
- // todo evaluate branches
244
- // conditionNode.evaluateBranches();
245
- // restore retain flag
246
- if (this.hasOwnProperty("_previousRetainFlag")) {
247
- this.currentBranch().setRetain(this._previousRetainFlag);
248
- }
249
- // todo send notification for branches with retain = true
250
- let nb_condition_resent = 0;
251
- if (this.currentBranch().getRetain()) {
252
- nb_condition_resent += this._resend_conditionEvents();
253
- }
254
- if (nb_condition_resent === 0) {
255
- // a notification must be send
256
- this.raiseConditionEvent(this.currentBranch(), true);
257
- }
258
- }
259
- return node_opcua_status_code_1.StatusCodes.Good;
260
- }
261
- /**
262
- *
263
- * @method setEnabledState
264
- * @param requestedEnabledState {Boolean}
265
- * @private
266
- */
267
- setEnabledState(requestedEnabledState) {
268
- return this._setEnabledState(requestedEnabledState);
269
- }
270
- /**
271
- * @method setReceiveTime
272
- * @param time {Date}
273
- */
274
- setReceiveTime(time) {
275
- return this._branch0.setReceiveTime(time);
276
- }
277
- /**
278
- * @method setLocalTime (optional)
279
- * @param time
280
- */
281
- setLocalTime(time) {
282
- return this._branch0.setLocalTime(time);
283
- }
284
- /**
285
- * @method setTime
286
- * @param time {Date}
287
- */
288
- setTime(time) {
289
- return this._branch0.setTime(time);
290
- }
291
- _assert_valid() {
292
- node_opcua_assert_1.assert(this.receiveTime.readValue().value.dataType === node_opcua_variant_1.DataType.DateTime);
293
- node_opcua_assert_1.assert(this.receiveTime.readValue().value.value instanceof Date);
294
- node_opcua_assert_1.assert(this.message.readValue().value.dataType === node_opcua_variant_1.DataType.LocalizedText);
295
- node_opcua_assert_1.assert(this.severity.readValue().value.dataType === node_opcua_variant_1.DataType.UInt16);
296
- node_opcua_assert_1.assert(this.time.readValue().value.dataType === node_opcua_variant_1.DataType.DateTime);
297
- node_opcua_assert_1.assert(this.time.readValue().value.value instanceof Date);
298
- node_opcua_assert_1.assert(this.quality.readValue().value.dataType === node_opcua_variant_1.DataType.StatusCode);
299
- node_opcua_assert_1.assert(this.enabledState.readValue().value.dataType === node_opcua_variant_1.DataType.LocalizedText);
300
- node_opcua_assert_1.assert(this.branchId.readValue().value.dataType === node_opcua_variant_1.DataType.NodeId);
301
- // note localTime has been made optional in 1.04
302
- node_opcua_assert_1.assert(!this.localTime || this.localTime.readValue().value.dataType === node_opcua_variant_1.DataType.ExtensionObject);
303
- }
304
- /**
305
- * @method conditionOfNode
306
- * @return {UAObject}
307
- */
308
- conditionOfNode() {
309
- const refs = this.findReferencesExAsObject("HasCondition", node_opcua_data_model_1.BrowseDirection.Inverse);
310
- if (refs.length === 0) {
311
- return null;
312
- }
313
- node_opcua_assert_1.assert(refs.length !== 0, "UAConditionBase must be the condition of some node");
314
- node_opcua_assert_1.assert(refs.length === 1, "expecting only one ConditionOf");
315
- const node = refs[0];
316
- node_opcua_assert_1.assert(node.nodeClass === node_opcua_data_model_1.NodeClass.Object || node.nodeClass === node_opcua_data_model_1.NodeClass.Variable, "node for which we are the condition shall be an UAObject or UAVariable");
317
- return node;
318
- }
319
- /**
320
- * @method raiseConditionEvent
321
- * Raise a Instance Event
322
- * (see also UAObject#raiseEvent to raise a transient event)
323
- * @param branch the condition branch to raise
324
- * @param renewEventId true if event Id of the condition branch should be renewed
325
- */
326
- raiseConditionEvent(branch, renewEventId) {
327
- node_opcua_assert_1.assert(arguments.length === 2, "expecting 2 arguments");
328
- if (renewEventId) {
329
- branch.renewEventId();
330
- }
331
- // xx console.log("MMMMMMMM%%%%%%%%%%%%%%%%%%%%% branch " +
332
- // branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
333
- node_opcua_assert_1.assert(branch instanceof condition_snapshot_1.ConditionSnapshot);
334
- this._assert_valid();
335
- // In fact the event is raised by the object of which we are the condition
336
- const conditionOfNode = this.conditionOfNode();
337
- if (conditionOfNode) {
338
- const eventData = branch._constructEventData();
339
- this.emit("event", eventData);
340
- if (conditionOfNode instanceof ua_object_1.UAObject) {
341
- // xx assert(conditionOfNode.eventNotifier === 0x01);
342
- conditionOfNode._bubble_up_event(eventData);
343
- }
344
- else {
345
- node_opcua_assert_1.assert(conditionOfNode.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
346
- // in this case
347
- const eventOfs = conditionOfNode.getEventSourceOfs();
348
- node_opcua_assert_1.assert(eventOfs.length === 1);
349
- const node = eventOfs[0];
350
- node_opcua_assert_1.assert(node instanceof ua_object_1.UAObject);
351
- node._bubble_up_event(eventData);
352
- }
353
- }
354
- // xx console.log("MMMMMMMM%%%%%%%%%%%%%%%%%%%%% branch " +
355
- // branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
356
- }
357
- /**
358
- *
359
- * @method raiseNewCondition
360
- * @param conditionInfo {ConditionInfo}
361
- *
362
- */
363
- raiseNewCondition(conditionInfo) {
364
- if (!this.getEnabledState()) {
365
- throw new Error("UAConditionBase#raiseNewCondition Condition is not enabled");
366
- }
367
- conditionInfo = conditionInfo || {};
368
- conditionInfo.severity = conditionInfo.hasOwnProperty("severity")
369
- ? conditionInfo.severity
370
- : UAConditionBase.defaultSeverity;
371
- // only valid for ConditionObjects
372
- // todo check that object is of type ConditionType
373
- const addressSpace = this.addressSpace;
374
- const selfConditionType = this.typeDefinitionObj;
375
- const conditionType = addressSpace.findObjectType("ConditionType");
376
- node_opcua_assert_1.assert(selfConditionType.isSupertypeOf(conditionType));
377
- const branch = this.currentBranch();
378
- const now = new Date();
379
- // install the eventTimestamp
380
- // set the received Time
381
- branch.setTime(now);
382
- branch.setReceiveTime(now);
383
- // note : in 1.04 LocalTime property is optional
384
- if (this.hasOwnProperty("localTime")) {
385
- branch.setLocalTime(new node_opcua_types_1.TimeZoneDataType({
386
- daylightSavingInOffset: false,
387
- offset: 0
388
- }));
389
- }
390
- if (conditionInfo.hasOwnProperty("message") && conditionInfo.message) {
391
- branch.setMessage(conditionInfo.message);
392
- }
393
- // todo receive time : when the server received the event from the underlying system.
394
- // self.receiveTime.setValueFromSource();
395
- if (conditionInfo.hasOwnProperty("severity") && conditionInfo.severity !== null) {
396
- node_opcua_assert_1.assert(isFinite(conditionInfo.severity));
397
- branch.setSeverity(conditionInfo.severity);
398
- }
399
- if (conditionInfo.hasOwnProperty("quality") && conditionInfo.quality !== null) {
400
- node_opcua_assert_1.assert(conditionInfo.quality instanceof node_opcua_status_code_1.StatusCode);
401
- branch.setQuality(conditionInfo.quality);
402
- }
403
- if (conditionInfo.hasOwnProperty("retain") && conditionInfo.retain !== null) {
404
- node_opcua_assert_1.assert(typeof conditionInfo.retain === "boolean");
405
- branch.setRetain(!!conditionInfo.retain);
406
- }
407
- this.raiseConditionEvent(branch, true);
408
- }
409
- raiseNewBranchState(branch) {
410
- this.raiseConditionEvent(branch, true);
411
- if (branch.getBranchId() !== node_opcua_nodeid_1.NodeId.nullNodeId && !branch.getRetain()) {
412
- // xx console.log(" Deleting not longer needed branch ", branch.getBranchId().toString());
413
- // branch can be deleted
414
- this.deleteBranch(branch);
415
- }
416
- }
417
- /**
418
- * @method currentBranch
419
- * @return {ConditionSnapshot}
420
- */
421
- currentBranch() {
422
- return this._branch0;
423
- }
424
- _resend_conditionEvents() {
425
- // for the time being , only current branch
426
- const currentBranch = this.currentBranch();
427
- if (currentBranch.getRetain()) {
428
- debugLog(" resending condition event for " + this.browseName.toString());
429
- this.raiseConditionEvent(currentBranch, false);
430
- return 1;
431
- }
432
- return 0;
433
- }
434
- // ------------------------------------------------------------------------------------
435
- // Acknowledgeable
436
- // ------------------------------------------------------------------------------------
437
- /**
438
- * @method _raiseAuditConditionCommentEvent
439
- * @param sourceName {string}
440
- * @param conditionEventId {Buffer}
441
- * @param comment {LocalizedText}
442
- * @private
443
- */
444
- _raiseAuditConditionCommentEvent(sourceName, conditionEventId, comment) {
445
- node_opcua_assert_1.assert(conditionEventId === null || conditionEventId instanceof Buffer);
446
- node_opcua_assert_1.assert(comment instanceof node_opcua_data_model_1.LocalizedText);
447
- const server = this.addressSpace.rootFolder.objects.server;
448
- const now = new Date();
449
- // xx if (true || server.isAuditing) {
450
- // ----------------------------------------------------------------------------------------------------
451
- server.raiseEvent("AuditConditionCommentEventType", {
452
- // AuditEventType
453
- /* part 5 - 6.4.3 AuditEventType */
454
- actionTimeStamp: {
455
- dataType: "DateTime",
456
- value: now
457
- },
458
- status: {
459
- dataType: "Boolean",
460
- value: true
461
- },
462
- serverId: {
463
- dataType: "String",
464
- value: ""
465
- },
466
- // ClientAuditEntryId contains the human-readable AuditEntryId defined in Part 3.
467
- clientAuditEntryId: {
468
- dataType: "String",
469
- value: ""
470
- },
471
- // The ClientUserId identifies the user of the client requesting an action. The ClientUserId can be
472
- // obtained from the UserIdentityToken passed in the ActivateSession call.
473
- clientUserId: {
474
- dataType: "String",
475
- value: ""
476
- },
477
- sourceName: {
478
- dataType: "String",
479
- value: sourceName
480
- },
481
- // AuditUpdateMethodEventType
482
- methodId: {
483
- dataType: "Null"
484
- },
485
- inputArguments: {
486
- dataType: "Null"
487
- },
488
- // AuditConditionCommentEventType
489
- conditionEventId: {
490
- dataType: "ByteString",
491
- value: conditionEventId
492
- },
493
- comment: {
494
- dataType: "LocalizedText",
495
- value: comment
496
- }
497
- });
498
- // xx }
499
- }
500
- _findBranchForEventId(eventId) {
501
- const conditionNode = this;
502
- if (sameBuffer(conditionNode.eventId.readValue().value.value, eventId)) {
503
- return conditionNode.currentBranch();
504
- }
505
- const e = Object.values(conditionNode._branches).filter((branch) => sameBuffer(branch.getEventId(), eventId));
506
- if (e.length === 1) {
507
- return e[0];
508
- }
509
- node_opcua_assert_1.assert(e.length === 0, "cannot have 2 branches with same eventId");
510
- return null; // not found
511
- }
512
- evaluateConditionsAfterEnabled() {
513
- node_opcua_assert_1.assert(this.getEnabledState() === true);
514
- throw new Error("Unimplemented , please override");
515
- }
516
- }
517
- exports.UAConditionBase = UAConditionBase;
518
- UAConditionBase.defaultSeverity = 250;
519
- UAConditionBase.typeDefinition = node_opcua_nodeid_1.resolveNodeId("ConditionType");
520
- /**
521
- * instantiate a Condition.
522
- * this will create the unique EventId and will set eventType
523
- * @method instantiate
524
- * @param namespace {Namespace}
525
- * @param conditionTypeId {String|NodeId} the EventType to instantiate
526
- * @param options {object}
527
- * @param options.browseName {String|QualifiedName}
528
- * @param options.componentOf {NodeId|UAObject}
529
- * @param options.conditionOf {NodeId|UAObject} Mandatory
530
- * @param options.organizedBy {NodeId|UAObject} ( only provide componentOf or organizedBy but not both)
531
- * @param [options.conditionClass =BaseConditionClassType] {NodeId|UAObject}
532
- * The condition Class nodeId or object used to set the ConditionClassId and
533
- * ConditionClassName properties of the condition.
534
- *
535
- * @param options.conditionSource {NodeId|UAObject} the condition source node.
536
- * this node must be marked a EventSource.
537
- * the conditionSource is used to populate the sourceNode and
538
- * sourceName variables defined by BaseEventType
539
- * @param options.conditionName {String} the condition Name
540
- * @param [options.optionals] [Array<String>] an Array of optionals fields
541
- *
542
- * @param data a object containing the value to set
543
- * @param data.eventId {String|NodeId} the EventType Identifier to instantiate (type cannot be abstract)
544
- * @return a instantiated UAConditionBase
545
- */
546
- function UAConditionBase_instantiate(namespace, conditionTypeId, options, data) {
547
- /* eslint max-statements: ["error", 100] */
548
- const addressSpace = namespace.addressSpace;
549
- const conditionType = addressSpace.findEventType(conditionTypeId);
550
- /* istanbul ignore next */
551
- if (!conditionType) {
552
- throw new Error(" cannot find Condition Type for " + conditionTypeId);
553
- }
554
- // reminder : abstract event type cannot be instantiated directly !
555
- node_opcua_assert_1.assert(!conditionType.isAbstract, "Cannot instantiate abstract conditionType");
556
- const baseConditionEventType = addressSpace.findEventType("ConditionType");
557
- /* istanbul ignore next */
558
- if (!baseConditionEventType) {
559
- throw new Error("cannot find ConditionType");
560
- }
561
- node_opcua_assert_1.assert(conditionType.isSupertypeOf(baseConditionEventType));
562
- // assert((typeof options.browseName === "string"));
563
- options.browseName = options.browseName || "??? instantiateCondition - missing browseName";
564
- options.optionals = options.optionals || [];
565
- // now optionals in 1.04
566
- options.optionals.push("EventType");
567
- options.optionals.push("BranchId");
568
- //
569
- options.optionals.push("Comment");
570
- options.optionals.push("Comment.SourceTimestamp");
571
- options.optionals.push("EnabledState.TrueState");
572
- options.optionals.push("EnabledState.TrueState");
573
- options.optionals.push("EnabledState.FalseState");
574
- options.optionals.push("EnabledState.TransitionTime");
575
- options.optionals.push("EnabledState.EffectiveTransitionTime");
576
- options.optionals.push("EnabledState.EffectiveDisplayName");
577
- const conditionNode = conditionType.instantiate(options);
578
- Object.setPrototypeOf(conditionNode, UAConditionBase.prototype);
579
- conditionNode.initialize();
580
- node_opcua_assert_1.assert(options.hasOwnProperty("conditionSource"), "must specify a condition source either as null or as a UAObject");
581
- if (!options.conditionOf) {
582
- options.conditionOf = options.conditionSource;
583
- }
584
- if (options.conditionOf) {
585
- node_opcua_assert_1.assert(options.hasOwnProperty("conditionOf")); // must provide a conditionOf
586
- options.conditionOf = addressSpace._coerceNode(options.conditionOf);
587
- // HasCondition References can be used in the Type definition of an Object or a Variable.
588
- node_opcua_assert_1.assert(options.conditionOf.nodeClass === node_opcua_data_model_1.NodeClass.Object || options.conditionOf.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
589
- conditionNode.addReference({
590
- isForward: false,
591
- nodeId: options.conditionOf,
592
- referenceType: "HasCondition"
593
- });
594
- node_opcua_assert_1.assert(conditionNode.conditionOfNode().nodeId === options.conditionOf.nodeId);
595
- }
596
- // the constant property of this condition
597
- conditionNode.eventType.setValueFromSource({
598
- dataType: node_opcua_variant_1.DataType.NodeId,
599
- value: conditionType.nodeId
600
- });
601
- data = data || {};
602
- // install initial branch ID (null NodeId);
603
- conditionNode.branchId.setValueFromSource({
604
- dataType: node_opcua_variant_1.DataType.NodeId,
605
- value: node_opcua_nodeid_1.NodeId.nullNodeId
606
- });
607
- // install 'Comment' condition variable
608
- _install_condition_variable_type(conditionNode.comment);
609
- // install 'Quality' condition variable
610
- _install_condition_variable_type(conditionNode.quality);
611
- // xx conditionNode.quality.setValueFromSource({dataType: DataType.StatusCode,value: StatusCodes.Good });
612
- // install 'LastSeverity' condition variable
613
- _install_condition_variable_type(conditionNode.lastSeverity);
614
- // xx conditionNode.severity.setValueFromSource({dataType: DataType.UInt16,value: 0 });
615
- // xx conditionNode.lastSeverity.setValueFromSource({dataType: DataType.UInt16,value: 0 });
616
- // install 'EnabledState' TwoStateVariable
617
- /**
618
- * @property enabledState
619
- * @type {UATwoStateVariable}
620
- */
621
- // -------------- fixing missing EnabledState.EffectiveDisplayName
622
- if (!conditionNode.enabledState.effectiveDisplayName) {
623
- namespace.addVariable({
624
- browseName: new node_opcua_data_model_1.QualifiedName({ namespaceIndex: 0, name: "EffectiveDisplayName" }),
625
- dataType: "LocalizedText",
626
- propertyOf: conditionNode.enabledState
627
- });
628
- }
629
- ua_two_state_variable_1._install_TwoStateVariable_machinery(conditionNode.enabledState, {
630
- falseState: "Disabled",
631
- trueState: "Enabled"
632
- });
633
- // installing sourceName and sourceNode
634
- conditionNode.enabledState.setValue(true);
635
- // set properties to in initial values
636
- Object.keys(data).forEach((key) => {
637
- const varNode = _getCompositeKey(conditionNode, key);
638
- node_opcua_assert_1.assert(varNode.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
639
- const variant = new node_opcua_variant_1.Variant(data[key]);
640
- // check that Variant DataType is compatible with the UAVariable dataType
641
- // xx var nodeDataType = addressSpace.findNode(varNode.dataType).browseName;
642
- /* istanbul ignore next */
643
- if (!varNode._validate_DataType(variant.dataType)) {
644
- throw new Error(" Invalid variant dataType " + variant + " " + varNode.browseName.toString());
645
- }
646
- const value = new node_opcua_variant_1.Variant(data[key]);
647
- varNode.setValueFromSource(value);
648
- });
649
- // bind condition methods -
650
- /**
651
- * @property enable
652
- * @type {UAMethod}
653
- */
654
- conditionNode.enable.bindMethod(_enable_method);
655
- /**
656
- * @property disable
657
- * @type {UAMethod}
658
- */
659
- conditionNode.disable.bindMethod(_disable_method);
660
- // bind condition methods - AddComment
661
- /**
662
- * @property addComment
663
- * @type {UAMethod}
664
- */
665
- conditionNode.addComment.bindMethod(_add_comment_method);
666
- node_opcua_assert_1.assert(conditionNode instanceof UAConditionBase);
667
- // ConditionSource => cf SourceNode
668
- // As per spec OPCUA 1.03 part 9 page 54:
669
- // The ConditionType inherits all Properties of the BaseEventType. Their semantic is defined in
670
- // Part 5. SourceNode identifies the ConditionSource.
671
- // The SourceNode is the Node which the condition is associated with, it may be the same as the
672
- // InputNode for an alarm, but it may be a separate node. For example a motor, which is a
673
- // variable with a value that is an RPM, may be the ConditionSource for Conditions that are
674
- // related to the motor as well as a temperature sensor associated with the motor. In the former
675
- // the InputNode for the High RPM alarm is the value of the Motor RPM, while in the later the
676
- // InputNode of the High Alarm would be the value of the temperature sensor that is associated
677
- // with the motor.
678
- if (options.conditionSource) {
679
- options.conditionSource = addressSpace._coerceNode(options.conditionSource);
680
- if (options.conditionSource.nodeClass !== node_opcua_data_model_1.NodeClass.Object && options.conditionSource.nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
681
- // tslint:disable:no-console
682
- console.log(options.conditionSource);
683
- throw new Error("Expecting condition source to be NodeClass.Object or Variable");
684
- }
685
- const conditionSourceNode = addressSpace.findNode(options.conditionSource.nodeId);
686
- if (conditionSourceNode) {
687
- conditionNode.sourceNode.setValueFromSource({
688
- dataType: node_opcua_variant_1.DataType.NodeId,
689
- value: conditionSourceNode.nodeId
690
- });
691
- // conditionSourceNode node must be registered as a EventSource of an other node.
692
- // As per spec OPCUA 1.03 part 9 page 54:
693
- // HasNotifier and HasEventSource References are used to expose the hierarchical organization
694
- // of Event notifying Objects and ConditionSources. An Event notifying Object represents
695
- // typically an area of Operator responsibility. The definition of such an area configuration is
696
- // outside the scope of this standard. If areas are available they shall be linked together and
697
- // with the included ConditionSources using the HasNotifier and the HasEventSource Reference
698
- // Types. The Server Object shall be the root of this hierarchy.
699
- if (!node_opcua_nodeid_1.sameNodeId(conditionSourceNode.nodeId, node_opcua_nodeid_1.coerceNodeId("ns=0;i=2253"))) {
700
- // server object
701
- /* istanbul ignore next */
702
- if (conditionSourceNode.getEventSourceOfs().length === 0) {
703
- errorLog("conditionSourceNode = ", conditionSourceNode.browseName.toString());
704
- errorLog("conditionSourceNode = ", conditionSourceNode.nodeId.toString());
705
- throw new Error("conditionSourceNode must be an event source " +
706
- conditionSourceNode.browseName.toString() +
707
- conditionSourceNode.nodeId.toString());
708
- }
709
- }
710
- const context = source_1.SessionContext.defaultContext;
711
- // set source Node (defined in UABaseEventType)
712
- conditionNode.sourceNode.setValueFromSource(conditionSourceNode.readAttribute(context, node_opcua_data_model_1.AttributeIds.NodeId).value);
713
- // set source Name (defined in UABaseEventType)
714
- conditionNode.sourceName.setValueFromSource(conditionSourceNode.readAttribute(context, node_opcua_data_model_1.AttributeIds.DisplayName).value);
715
- }
716
- }
717
- conditionNode.eventType.setValueFromSource({
718
- dataType: node_opcua_variant_1.DataType.NodeId,
719
- value: conditionType.nodeId
720
- });
721
- // as per spec:
722
- /**
723
- *
724
- * dataType: DataType.NodeId
725
- *
726
- * As per spec OPCUA 1.03 part 9:
727
- * ConditionClassId specifies in which domain this Condition is used. It is the NodeId of the
728
- * corresponding ConditionClassType. See 5.9 for the definition of ConditionClass and a set of
729
- * ConditionClasses defined in this standard. When using this Property for filtering, Clients have
730
- * to specify all individual ConditionClassType NodeIds. The OfType operator cannot be applied.
731
- * BaseConditionClassType is used as class whenever a Condition cannot be assigned to a
732
- * more concrete class.
733
- *
734
- * BaseConditionClassType
735
- * |
736
- * +---------------------------+----------------------------+
737
- * | | |
738
- * ProcessConditionClassType MaintenanceConditionClassType SystemConditionClassType
739
- *
740
- * @property conditionName
741
- * @type {UAVariable}
742
- */
743
- const baseConditionClassType = addressSpace.findObjectType("ProcessConditionClassType");
744
- // assert(baseConditionClassType,"Expecting BaseConditionClassType to be in addressSpace");
745
- let conditionClassId = baseConditionClassType ? baseConditionClassType.nodeId : node_opcua_nodeid_1.NodeId.nullNodeId;
746
- let conditionClassName = baseConditionClassType ? baseConditionClassType.displayName[0] : "";
747
- if (options.conditionClass) {
748
- if (typeof options.conditionClass === "string") {
749
- options.conditionClass = addressSpace.findObjectType(options.conditionClass);
750
- }
751
- const conditionClassNode = addressSpace._coerceNode(options.conditionClass);
752
- if (!conditionClassNode) {
753
- throw new Error("cannot find condition class " + options.conditionClass.toString());
754
- }
755
- conditionClassId = conditionClassNode.nodeId;
756
- conditionClassName = conditionClassNode.displayName[0];
757
- }
758
- conditionNode.conditionClassId.setValueFromSource({
759
- dataType: node_opcua_variant_1.DataType.NodeId,
760
- value: conditionClassId
761
- });
762
- // as per spec:
763
- // ConditionClassName provides the display name of the ConditionClassType.
764
- conditionNode.conditionClassName.setValueFromSource({
765
- dataType: node_opcua_variant_1.DataType.LocalizedText,
766
- value: node_opcua_data_model_1.coerceLocalizedText(conditionClassName)
767
- });
768
- // as per spec:
769
- /**
770
- *
771
- * dataType: DataType.String
772
- *
773
- * As per spec OPCUA 1.03 part 9:
774
- * ConditionName identifies the Condition instance that the Event originated from. It can be used
775
- * together with the SourceName in a user display to distinguish between different Condition
776
- * instances. If a ConditionSource has only one instance of a ConditionType, and the Server has
777
- * no instance name, the Server shall supply the ConditionType browse name.
778
- * @property conditionName
779
- * @type {UAVariable}
780
- */
781
- const conditionName = options.conditionName || "Unset Condition Name";
782
- node_opcua_assert_1.assert(typeof conditionName === "string");
783
- conditionNode.conditionName.setValueFromSource({
784
- dataType: node_opcua_variant_1.DataType.String,
785
- value: conditionName
786
- });
787
- // set SourceNode and SourceName based on HasCondition node
788
- const sourceNodes = conditionNode.findReferencesAsObject("HasCondition", false);
789
- if (sourceNodes.length) {
790
- node_opcua_assert_1.assert(sourceNodes.length === 1);
791
- conditionNode.setSourceNode(sourceNodes[0].nodeId);
792
- conditionNode.setSourceName(sourceNodes[0].browseName.toString());
793
- }
794
- conditionNode.post_initialize();
795
- const branch0 = conditionNode.currentBranch();
796
- branch0.setRetain(false);
797
- branch0.setComment("");
798
- branch0.setQuality(node_opcua_status_code_1.StatusCodes.Good);
799
- branch0.setSeverity(0);
800
- branch0.setLocalTime(new node_opcua_types_1.TimeZoneDataType({
801
- daylightSavingInOffset: false,
802
- offset: 0
803
- }));
804
- branch0.setMessage("");
805
- branch0.setReceiveTime(node_opcua_factory_1.minDate);
806
- branch0.setTime(node_opcua_factory_1.minDate);
807
- // UAConditionBase
808
- return conditionNode;
809
- }
810
- function _disable_method(inputArguments, context, callback) {
811
- node_opcua_assert_1.assert(inputArguments.length === 0);
812
- const conditionNode = context.object;
813
- node_opcua_assert_1.assert(conditionNode);
814
- if (!(conditionNode instanceof UAConditionBase)) {
815
- return callback(null, {
816
- statusCode: node_opcua_status_code_1.StatusCodes.BadNodeIdInvalid
817
- });
818
- }
819
- const statusCode = conditionNode._setEnabledState(false);
820
- return callback(null, {
821
- statusCode
822
- });
823
- }
824
- function _enable_method(inputArguments, context, callback) {
825
- node_opcua_assert_1.assert(inputArguments.length === 0);
826
- const conditionNode = context.object;
827
- node_opcua_assert_1.assert(conditionNode);
828
- if (!(conditionNode instanceof UAConditionBase)) {
829
- return callback(null, {
830
- statusCode: node_opcua_status_code_1.StatusCodes.BadNodeIdInvalid
831
- });
832
- }
833
- const statusCode = conditionNode._setEnabledState(true);
834
- return callback(null, {
835
- statusCode
836
- });
837
- }
838
- function _condition_refresh_method(inputArguments, context, callback) {
839
- // arguments : IntegerId SubscriptionId
840
- node_opcua_assert_1.assert(inputArguments.length === 1);
841
- const addressSpace = context.object.addressSpace;
842
- if (doDebug) {
843
- debugLog(chalk.red(" ConditionType.ConditionRefresh ! subscriptionId ="), inputArguments[0].toString());
844
- }
845
- const subscriptionId = inputArguments[0].value;
846
- let statusCode = _check_subscription_id_is_valid(subscriptionId, context);
847
- if (statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
848
- return statusCode;
849
- }
850
- statusCode = _perform_condition_refresh(addressSpace, inputArguments, context);
851
- return callback(null, {
852
- statusCode
853
- });
854
- }
855
- function _perform_condition_refresh(addressSpace, inputArguments, context) {
856
- // --- possible StatusCodes:
857
- //
858
- // Bad_SubscriptionIdInvalid See Part 4 for the description of this result code
859
- // Bad_RefreshInProgress See Table 74 for the description of this result code
860
- // Bad_UserAccessDenied The Method was not called in the context of the Session
861
- // that owns the Subscription
862
- //
863
- // istanbul ignore next
864
- if (addressSpace._condition_refresh_in_progress) {
865
- // a refresh operation is already in progress....
866
- return node_opcua_status_code_1.StatusCodes.BadRefreshInProgress;
867
- }
868
- addressSpace._condition_refresh_in_progress = true;
869
- const server = context.object.addressSpace.rootFolder.objects.server;
870
- node_opcua_assert_1.assert(server instanceof ua_object_1.UAObject);
871
- const refreshStartEventType = addressSpace.findEventType("RefreshStartEventType");
872
- const refreshEndEventType = addressSpace.findEventType("RefreshEndEventType");
873
- node_opcua_assert_1.assert(refreshStartEventType instanceof ua_object_type_1.UAObjectType);
874
- node_opcua_assert_1.assert(refreshEndEventType instanceof ua_object_type_1.UAObjectType);
875
- server.raiseEvent(refreshStartEventType, {});
876
- // todo : resend retained conditions
877
- // starting from server object ..
878
- // evaluated all --> hasNotifier/hasEventSource -> node
879
- server._conditionRefresh();
880
- server.raiseEvent(refreshEndEventType, {});
881
- addressSpace._condition_refresh_in_progress = false;
882
- return node_opcua_status_code_1.StatusCodes.Good;
883
- }
884
- function _condition_refresh2_method(inputArguments, context, callback) {
885
- // arguments : IntegerId SubscriptionId
886
- // arguments : IntegerId MonitoredItemId
887
- node_opcua_assert_1.assert(inputArguments.length === 2);
888
- const addressSpace = context.object.addressSpace;
889
- // istanbul ignore next
890
- if (doDebug) {
891
- debugLog(chalk.cyan.bgWhite(" ConditionType.conditionRefresh2 !"));
892
- }
893
- // xx var subscriptionId = inputArguments[0].value;
894
- // xx var monitoredItemId = inputArguments[1].value;
895
- const statusCode = _perform_condition_refresh(addressSpace, inputArguments, context);
896
- return callback(null, {
897
- statusCode
898
- });
899
- }
900
- function _add_comment_method(inputArguments, context, callback) {
901
- //
902
- // The AddComment Method is used to apply a comment to a specific state of a Condition
903
- // instance. Normally, the NodeId of the object instance as the ObjectId is passed to the Call
904
- // Service. However, some Servers do not expose Condition instances in the AddressSpace.
905
- // Therefore all Servers shall also allow Clients to call the AddComment Method by specifying
906
- // ConditionId as the ObjectId. The Method cannot be called with an ObjectId of the
907
- // ConditionType Node.
908
- // Signature
909
- // - EventId EventId identifying a particular Event Notification where a state was reported for a
910
- // Condition.
911
- // - Comment A localized text to be applied to the Condition.
912
- //
913
- // AlwaysGeneratesEvent AuditConditionCommentEventType
914
- //
915
- UAConditionBase.with_condition_method(inputArguments, context, callback, (conditionEventId, comment, branch, conditionNode) => {
916
- node_opcua_assert_1.assert(inputArguments instanceof Array);
917
- node_opcua_assert_1.assert(conditionEventId instanceof Buffer || conditionEventId === null);
918
- node_opcua_assert_1.assert(branch instanceof condition_snapshot_1.ConditionSnapshot);
919
- branch.setComment(comment);
920
- const sourceName = "Method/AddComment";
921
- conditionNode._raiseAuditConditionCommentEvent(sourceName, conditionEventId, comment);
922
- // raise new event
923
- conditionNode.raiseConditionEvent(branch, true);
924
- /**
925
- * raised when the branch has been added a comment
926
- * @event addComment
927
- * @param conditionEventId NodeId|null
928
- * @param comment {LocalizedText}
929
- * @param branch {ConditionSnapshot}
930
- */
931
- conditionNode.emit("addComment", conditionEventId, comment, branch);
932
- return node_opcua_status_code_1.StatusCodes.Good;
933
- });
934
- }
935
- function sameBuffer(b1, b2) {
936
- if (!b1 && !b2) {
937
- return true;
938
- }
939
- if (b1 && !b2) {
940
- return false;
941
- }
942
- if (!b1 && b2) {
943
- return false;
944
- }
945
- node_opcua_assert_1.assert(b1 instanceof Buffer);
946
- node_opcua_assert_1.assert(b2 instanceof Buffer);
947
- if (b1.length !== b2.length) {
948
- return false;
949
- }
950
- /*
951
- var bb1 = (Buffer.from(b1)).toString("hex");
952
- var bb2 = (Buffer.from(b2)).toString("hex");
953
- return bb1 === bb2;
954
- */
955
- const n = b1.length;
956
- for (let i = 0; i < n; i++) {
957
- if (b1[i] !== b2[i]) {
958
- return false;
959
- }
960
- }
961
- return true;
962
- }
963
- function _create_new_branch_id() {
964
- return node_opcua_nodeid_1.makeNodeId(node_opcua_basic_types_1.randomGuid(), 1);
965
- }
966
- function _update_sourceTimestamp(dataValue /*, indexRange*/) {
967
- this.sourceTimestamp.setValueFromSource({
968
- dataType: node_opcua_variant_1.DataType.DateTime,
969
- value: dataValue.sourceTimestamp
970
- });
971
- }
972
- // tslint:disable:no-console
973
- function _install_condition_variable_type(node) {
974
- node_opcua_assert_1.assert(node instanceof base_node_1.BaseNode);
975
- // from spec 1.03 : 5.3 condition variables
976
- // However, a change in their value is considered important and supposed to trigger
977
- // an Event Notification. These information elements are called ConditionVariables.
978
- if (node.sourceTimestamp) {
979
- node.sourceTimestamp.accessLevel = node_opcua_data_model_1.makeAccessLevelFlag("CurrentRead");
980
- }
981
- else {
982
- console.warn("cannot find node.sourceTimestamp", node.browseName.toString());
983
- }
984
- node.accessLevel = node_opcua_data_model_1.makeAccessLevelFlag("CurrentRead");
985
- // from spec 1.03 : 5.3 condition variables
986
- // a condition VariableType has a sourceTimeStamp exposed property
987
- // SourceTimestamp indicates the time of the last change of the Value of this ConditionVariable.
988
- // It shall be the same time that would be returned from the Read Service inside the DataValue
989
- // structure for the ConditionVariable Value Attribute.
990
- node_opcua_assert_1.assert(node.typeDefinitionObj.browseName.toString() === "ConditionVariableType");
991
- node_opcua_assert_1.assert(node.sourceTimestamp.browseName.toString() === "SourceTimestamp");
992
- node.on("value_changed", _update_sourceTimestamp);
993
- }
994
- /**
995
- * @method _getCompositeKey
996
- * @param node {BaseNode}
997
- * @param key {String}
998
- * @return {BaseNode}
999
- * @private
1000
- *
1001
- * @example
1002
- *
1003
- * var node = _getComposite(node,"enabledState.id");
1004
- *
1005
- */
1006
- function _getCompositeKey(node, key) {
1007
- let cur = node;
1008
- const elements = key.split(".");
1009
- for (const e of elements) {
1010
- // istanbul ignore next
1011
- if (!cur.hasOwnProperty(e)) {
1012
- throw new Error(" cannot extract '" + key + "' from " + node.browseName.toString());
1013
- }
1014
- cur = cur[e];
1015
- }
1016
- return cur;
1017
- }
1018
- /**
1019
- * verify that the subscription id belongs to the session that make the call.
1020
- * @method _check_subscription_id_is_valid
1021
- * @param subscriptionId {Number}
1022
- * @param context {Object}
1023
- * @private
1024
- */
1025
- function _check_subscription_id_is_valid(subscriptionId, context) {
1026
- /// todo: return StatusCodes.BadSubscriptionIdInvalid; if subscriptionId doesn't belong to session...
1027
- return node_opcua_status_code_1.StatusCodes.Good;
1028
- }
1029
- //# sourceMappingURL=ua_condition_base.js.map