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.
- package/.mocharc.yml +12 -0
- package/LICENSE +20 -0
- package/dist/source/address_space_ts.d.ts +122 -0
- package/dist/source/address_space_ts.js +18 -0
- package/dist/source/address_space_ts.js.map +1 -0
- package/dist/source/continuation_points/continuation_point_manager.d.ts +21 -0
- package/dist/source/continuation_points/continuation_point_manager.js +100 -0
- package/dist/source/continuation_points/continuation_point_manager.js.map +1 -0
- package/dist/source/helpers/adjust_browse_direction.d.ts +5 -0
- package/dist/source/helpers/adjust_browse_direction.js +12 -0
- package/dist/source/helpers/adjust_browse_direction.js.map +1 -0
- package/dist/source/helpers/argument_list.d.ts +30 -0
- package/dist/source/helpers/argument_list.js +237 -0
- package/dist/source/helpers/argument_list.js.map +1 -0
- package/dist/source/helpers/call_helpers.d.ts +6 -0
- package/dist/source/helpers/call_helpers.js +71 -0
- package/dist/source/helpers/call_helpers.js.map +1 -0
- package/dist/source/helpers/check_event_clause.d.ts +17 -0
- package/dist/source/helpers/check_event_clause.js +53 -0
- package/dist/source/helpers/check_event_clause.js.map +1 -0
- package/dist/source/helpers/coerce_enum_value.d.ts +6 -0
- package/dist/source/helpers/coerce_enum_value.js +34 -0
- package/dist/source/helpers/coerce_enum_value.js.map +1 -0
- package/dist/source/helpers/dump_tools.d.ts +14 -0
- package/dist/source/helpers/dump_tools.js +79 -0
- package/dist/source/helpers/dump_tools.js.map +1 -0
- package/dist/source/helpers/ensure_secure_access.d.ts +9 -0
- package/dist/source/helpers/ensure_secure_access.js +90 -0
- package/dist/source/helpers/ensure_secure_access.js.map +1 -0
- package/dist/source/helpers/make_optionals_map.d.ts +21 -0
- package/dist/source/helpers/make_optionals_map.js +30 -0
- package/dist/source/helpers/make_optionals_map.js.map +1 -0
- package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -0
- package/dist/source/helpers/resolve_opaque_on_address_space.js +37 -0
- package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -0
- package/dist/source/index.d.ts +39 -0
- package/dist/source/index.js +62 -0
- package/dist/source/index.js.map +1 -0
- package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +12 -0
- package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +3 -0
- package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js.map +1 -0
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.d.ts +1 -0
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js +3 -0
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_discrete_item.d.ts +4 -0
- package/dist/source/interfaces/data_access/ua_discrete_item.js +3 -0
- package/dist/source/interfaces/data_access/ua_discrete_item.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_multistate_discrete.d.ts +25 -0
- package/dist/source/interfaces/data_access/ua_multistate_discrete.js +3 -0
- package/dist/source/interfaces/data_access/ua_multistate_discrete.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -0
- package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +3 -0
- package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.d.ts +27 -0
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js +3 -0
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -0
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +3 -0
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_two_state_discrete.d.ts +17 -0
- package/dist/source/interfaces/data_access/ua_two_state_discrete.js +3 -0
- package/dist/source/interfaces/data_access/ua_two_state_discrete.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -0
- package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +3 -0
- package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_y_array_item.d.ts +4 -0
- package/dist/source/interfaces/data_access/ua_y_array_item.js +3 -0
- package/dist/source/interfaces/data_access/ua_y_array_item.js.map +1 -0
- package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -0
- package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +3 -0
- package/dist/source/interfaces/data_access/ua_y_array_item_ex.js.map +1 -0
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.d.ts +11 -0
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js +3 -0
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js.map +1 -0
- package/dist/source/interfaces/state_machine/finite_state_machine.d.ts +69 -0
- package/dist/source/interfaces/state_machine/finite_state_machine.js +3 -0
- package/dist/source/interfaces/state_machine/finite_state_machine.js.map +1 -0
- package/dist/source/interfaces/state_machine/program_finite_state_machine.d.ts +74 -0
- package/dist/source/interfaces/state_machine/program_finite_state_machine.js +3 -0
- package/dist/source/interfaces/state_machine/program_finite_state_machine.js.map +1 -0
- package/dist/source/interfaces/state_machine/state_machine.d.ts +342 -0
- package/dist/source/interfaces/state_machine/state_machine.js +3 -0
- package/dist/source/interfaces/state_machine/state_machine.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -0
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +3 -0
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -0
- package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +3 -0
- package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.d.ts +18 -0
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.js +3 -0
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -0
- package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +3 -0
- package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +222 -0
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js +3 -0
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_state_variable.d.ts +29 -0
- package/dist/source/interfaces/state_machine/ua_state_variable.js +3 -0
- package/dist/source/interfaces/state_machine/ua_state_variable.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -0
- package/dist/source/interfaces/state_machine/ua_transition_ex.js +3 -0
- package/dist/source/interfaces/state_machine/ua_transition_ex.js.map +1 -0
- package/dist/source/interfaces/state_machine/ua_two_state_variable.d.ts +26 -0
- package/dist/source/interfaces/state_machine/ua_two_state_variable.js +3 -0
- package/dist/source/interfaces/state_machine/ua_two_state_variable.js.map +1 -0
- package/dist/source/interfaces/subscription_diagnostics_variable.d.ts +41 -0
- package/dist/source/interfaces/subscription_diagnostics_variable.js +3 -0
- package/dist/source/interfaces/subscription_diagnostics_variable.js.map +1 -0
- package/dist/source/interfaces/ua_authorisation_service.d.ts +1 -0
- package/dist/source/interfaces/ua_authorisation_service.js +3 -0
- package/dist/source/interfaces/ua_authorisation_service.js.map +1 -0
- package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -0
- package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +3 -0
- package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js.map +1 -0
- package/dist/source/loader/generateAddressSpaceRaw.d.ts +10 -0
- package/dist/source/loader/generateAddressSpaceRaw.js +59 -0
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -0
- package/dist/source/loader/load_nodeset2.d.ts +13 -0
- package/dist/source/loader/load_nodeset2.js +1392 -0
- package/dist/source/loader/load_nodeset2.js.map +1 -0
- package/dist/source/loader/namespace_post_step.d.ts +6 -0
- package/dist/source/loader/namespace_post_step.js +48 -0
- package/dist/source/loader/namespace_post_step.js.map +1 -0
- package/dist/source/loader/register_node_promoter.d.ts +3 -0
- package/dist/source/loader/register_node_promoter.js +10 -0
- package/dist/source/loader/register_node_promoter.js.map +1 -0
- package/dist/source/namespace.d.ts +6 -0
- package/dist/source/namespace.js +3 -0
- package/dist/source/namespace.js.map +1 -0
- package/dist/source/namespace_alarm_and_condition.d.ts +24 -0
- package/dist/source/namespace_alarm_and_condition.js +3 -0
- package/dist/source/namespace_alarm_and_condition.js.map +1 -0
- package/dist/source/namespace_data_access.d.ts +42 -0
- package/dist/source/namespace_data_access.js +3 -0
- package/dist/source/namespace_data_access.js.map +1 -0
- package/dist/source/namespace_machine_state.d.ts +7 -0
- package/dist/source/namespace_machine_state.js +3 -0
- package/dist/source/namespace_machine_state.js.map +1 -0
- package/dist/source/pseudo_session.d.ts +55 -0
- package/dist/source/pseudo_session.js +205 -0
- package/dist/source/pseudo_session.js.map +1 -0
- package/dist/source/session_context.d.ts +111 -0
- package/dist/source/session_context.js +266 -0
- package/dist/source/session_context.js.map +1 -0
- package/dist/source/set_namespace_meta_data.d.ts +2 -0
- package/dist/source/set_namespace_meta_data.js +60 -0
- package/dist/source/set_namespace_meta_data.js.map +1 -0
- package/dist/source/ua_namespace_meta_data_type.d.ts +71 -0
- package/dist/source/ua_namespace_meta_data_type.js +3 -0
- package/dist/source/ua_namespace_meta_data_type.js.map +1 -0
- package/dist/source/ua_root_folder.d.ts +9 -0
- package/dist/source/ua_root_folder.js +3 -0
- package/dist/source/ua_root_folder.js.map +1 -0
- package/dist/source/ua_two_state_variable_ex.d.ts +23 -0
- package/dist/source/ua_two_state_variable_ex.js +3 -0
- package/dist/source/ua_two_state_variable_ex.js.map +1 -0
- package/dist/source/xml_writer.d.ts +9 -0
- package/dist/source/xml_writer.js +3 -0
- package/dist/source/xml_writer.js.map +1 -0
- package/dist/src/address_space.d.ts +393 -0
- package/dist/src/address_space.js +1375 -0
- package/dist/src/address_space.js.map +1 -0
- package/dist/src/address_space_change_event_tools.d.ts +6 -0
- package/dist/src/address_space_change_event_tools.js +150 -0
- package/dist/src/address_space_change_event_tools.js.map +1 -0
- package/dist/src/address_space_private.d.ts +44 -0
- package/dist/src/address_space_private.js +3 -0
- package/dist/src/address_space_private.js.map +1 -0
- package/dist/src/alarms_and_conditions/base_event_type.d.ts +26 -0
- package/dist/src/alarms_and_conditions/base_event_type.js +41 -0
- package/dist/src/alarms_and_conditions/base_event_type.js.map +1 -0
- package/dist/src/alarms_and_conditions/check_where_clause.d.ts +4 -0
- package/dist/src/alarms_and_conditions/check_where_clause.js +110 -0
- package/dist/src/alarms_and_conditions/check_where_clause.js.map +1 -0
- package/dist/src/alarms_and_conditions/condition.d.ts +5 -0
- package/dist/src/alarms_and_conditions/condition.js +81 -0
- package/dist/src/alarms_and_conditions/condition.js.map +1 -0
- package/dist/src/alarms_and_conditions/condition_info.d.ts +27 -0
- package/dist/src/alarms_and_conditions/condition_info.js +55 -0
- package/dist/src/alarms_and_conditions/condition_info.js.map +1 -0
- package/dist/src/alarms_and_conditions/condition_snapshot.d.ts +232 -0
- package/dist/src/alarms_and_conditions/condition_snapshot.js +667 -0
- package/dist/src/alarms_and_conditions/condition_snapshot.js.map +1 -0
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +21 -0
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +47 -0
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -0
- package/dist/src/alarms_and_conditions/extract_event_fields.d.ts +10 -0
- package/dist/src/alarms_and_conditions/extract_event_fields.js +90 -0
- package/dist/src/alarms_and_conditions/extract_event_fields.js.map +1 -0
- package/dist/src/alarms_and_conditions/index.d.ts +18 -0
- package/dist/src/alarms_and_conditions/index.js +31 -0
- package/dist/src/alarms_and_conditions/index.js.map +1 -0
- package/dist/src/alarms_and_conditions/shelving_state_machine.d.ts +22 -0
- package/dist/src/alarms_and_conditions/shelving_state_machine.js +241 -0
- package/dist/src/alarms_and_conditions/shelving_state_machine.js.map +1 -0
- package/dist/src/alarms_and_conditions/trip_alarm.d.ts +16 -0
- package/dist/src/alarms_and_conditions/trip_alarm.js +21 -0
- package/dist/src/alarms_and_conditions/trip_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.d.ts +54 -0
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js +255 -0
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +62 -0
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -0
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.d.ts +138 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js +460 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +118 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +417 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +29 -0
- package/dist/src/alarms_and_conditions/ua_base_event_impl.js +39 -0
- package/dist/src/alarms_and_conditions/ua_base_event_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.d.ts +35 -0
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js +32 -0
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +21 -0
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +26 -0
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_condition_base.d.ts +191 -0
- package/dist/src/alarms_and_conditions/ua_condition_base.js +1029 -0
- package/dist/src/alarms_and_conditions/ua_condition_base.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +182 -0
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +1021 -0
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.d.ts +11 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.js +58 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +17 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +58 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.d.ts +24 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js +59 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +27 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +57 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.d.ts +14 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js +17 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +9 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +12 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.d.ts +22 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js +87 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +38 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +87 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.d.ts +6 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js +11 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +10 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +8 -0
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_limit_alarm.d.ts +76 -0
- package/dist/src/alarms_and_conditions/ua_limit_alarm.js +237 -0
- package/dist/src/alarms_and_conditions/ua_limit_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +98 -0
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +233 -0
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.d.ts +27 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js +62 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +28 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +51 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.d.ts +49 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js +176 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +25 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +163 -0
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.d.ts +47 -0
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js +151 -0
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +39 -0
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +136 -0
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.d.ts +16 -0
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js +18 -0
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +16 -0
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +18 -0
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js.map +1 -0
- package/dist/src/apply_condition_refresh.d.ts +6 -0
- package/dist/src/apply_condition_refresh.js +28 -0
- package/dist/src/apply_condition_refresh.js.map +1 -0
- package/dist/src/base_node.d.ts +279 -0
- package/dist/src/base_node.js +1364 -0
- package/dist/src/base_node.js.map +1 -0
- package/dist/src/base_node_impl.d.ts +281 -0
- package/dist/src/base_node_impl.js +1394 -0
- package/dist/src/base_node_impl.js.map +1 -0
- package/dist/src/base_node_private.d.ts +61 -0
- package/dist/src/base_node_private.js +521 -0
- package/dist/src/base_node_private.js.map +1 -0
- package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -0
- package/dist/src/data_access/add_dataItem_stuff.js +62 -0
- package/dist/src/data_access/add_dataItem_stuff.js.map +1 -0
- package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -0
- package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +35 -0
- package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js.map +1 -0
- package/dist/src/data_access/ua_analog_item.d.ts +13 -0
- package/dist/src/data_access/ua_analog_item.js +37 -0
- package/dist/src/data_access/ua_analog_item.js.map +1 -0
- package/dist/src/data_access/ua_data_item.d.ts +16 -0
- package/dist/src/data_access/ua_data_item.js +66 -0
- package/dist/src/data_access/ua_data_item.js.map +1 -0
- package/dist/src/data_access/ua_multistate_discrete.d.ts +23 -0
- package/dist/src/data_access/ua_multistate_discrete.js +131 -0
- package/dist/src/data_access/ua_multistate_discrete.js.map +1 -0
- package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -0
- package/dist/src/data_access/ua_multistate_discrete_impl.js +131 -0
- package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -0
- package/dist/src/data_access/ua_multistate_value_discrete.d.ts +51 -0
- package/dist/src/data_access/ua_multistate_value_discrete.js +249 -0
- package/dist/src/data_access/ua_multistate_value_discrete.js.map +1 -0
- package/dist/src/data_access/ua_two_state_discrete.d.ts +25 -0
- package/dist/src/data_access/ua_two_state_discrete.js +154 -0
- package/dist/src/data_access/ua_two_state_discrete.js.map +1 -0
- package/dist/src/event_data.d.ts +29 -0
- package/dist/src/event_data.js +96 -0
- package/dist/src/event_data.js.map +1 -0
- package/dist/src/extension_object_array_node.d.ts +61 -0
- package/dist/src/extension_object_array_node.js +266 -0
- package/dist/src/extension_object_array_node.js.map +1 -0
- package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -0
- package/dist/src/historical_access/address_space_historical_data_node.js +662 -0
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -0
- package/dist/src/index_current.d.ts +42 -0
- package/dist/src/index_current.js +71 -0
- package/dist/src/index_current.js.map +1 -0
- package/dist/src/namespace.d.ts +475 -0
- package/dist/src/namespace.js +1775 -0
- package/dist/src/namespace.js.map +1 -0
- package/dist/src/namespace_impl.d.ts +463 -0
- package/dist/src/namespace_impl.js +1763 -0
- package/dist/src/namespace_impl.js.map +1 -0
- package/dist/src/namespace_private.d.ts +21 -0
- package/dist/src/namespace_private.js +29 -0
- package/dist/src/namespace_private.js.map +1 -0
- package/dist/src/nodeid_manager.d.ts +36 -0
- package/dist/src/nodeid_manager.js +196 -0
- package/dist/src/nodeid_manager.js.map +1 -0
- package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -0
- package/dist/src/nodeset_tools/adjust_namespace_array.js +14 -0
- package/dist/src/nodeset_tools/adjust_namespace_array.js.map +1 -0
- package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +2 -0
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +39 -0
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -0
- package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +2 -0
- package/dist/src/nodeset_tools/nodeset_to_xml.js +1155 -0
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -0
- package/dist/src/nodeset_tools/typedictionary_to_xml.d.ts +2 -0
- package/dist/src/nodeset_tools/typedictionary_to_xml.js +147 -0
- package/dist/src/nodeset_tools/typedictionary_to_xml.js.map +1 -0
- package/dist/src/reference.d.ts +43 -0
- package/dist/src/reference.js +138 -0
- package/dist/src/reference.js.map +1 -0
- package/dist/src/reference_impl.d.ts +43 -0
- package/dist/src/reference_impl.js +138 -0
- package/dist/src/reference_impl.js.map +1 -0
- package/dist/src/role_permissions.d.ts +2 -0
- package/dist/src/role_permissions.js +11 -0
- package/dist/src/role_permissions.js.map +1 -0
- package/dist/src/session_context.d.ts +4 -0
- package/dist/src/session_context.js +9 -0
- package/dist/src/session_context.js.map +1 -0
- package/dist/src/state_machine/finite_state_machine.d.ts +67 -0
- package/dist/src/state_machine/finite_state_machine.js +354 -0
- package/dist/src/state_machine/finite_state_machine.js.map +1 -0
- package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +34 -0
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +244 -0
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -0
- package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -0
- package/dist/src/state_machine/ua_two_state_variable.js +332 -0
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -0
- package/dist/src/tool_isSupertypeOf.d.ts +17 -0
- package/dist/src/tool_isSupertypeOf.js +103 -0
- package/dist/src/tool_isSupertypeOf.js.map +1 -0
- package/dist/src/ua_condition_type.d.ts +8 -0
- package/dist/src/ua_condition_type.js +3 -0
- package/dist/src/ua_condition_type.js.map +1 -0
- package/dist/src/ua_data_type.d.ts +83 -0
- package/dist/src/ua_data_type.js +289 -0
- package/dist/src/ua_data_type.js.map +1 -0
- package/dist/src/ua_data_type_impl.d.ts +83 -0
- package/dist/src/ua_data_type_impl.js +291 -0
- package/dist/src/ua_data_type_impl.js.map +1 -0
- package/dist/src/ua_method.d.ts +42 -0
- package/dist/src/ua_method.js +204 -0
- package/dist/src/ua_method.js.map +1 -0
- package/dist/src/ua_method_impl.d.ts +40 -0
- package/dist/src/ua_method_impl.js +203 -0
- package/dist/src/ua_method_impl.js.map +1 -0
- package/dist/src/ua_object.d.ts +29 -0
- package/dist/src/ua_object.js +153 -0
- package/dist/src/ua_object.js.map +1 -0
- package/dist/src/ua_object_impl.d.ts +29 -0
- package/dist/src/ua_object_impl.js +156 -0
- package/dist/src/ua_object_impl.js.map +1 -0
- package/dist/src/ua_object_type.d.ts +49 -0
- package/dist/src/ua_object_type.js +124 -0
- package/dist/src/ua_object_type.js.map +1 -0
- package/dist/src/ua_object_type_impl.d.ts +48 -0
- package/dist/src/ua_object_type_impl.js +124 -0
- package/dist/src/ua_object_type_impl.js.map +1 -0
- package/dist/src/ua_reference_type.d.ts +42 -0
- package/dist/src/ua_reference_type.js +138 -0
- package/dist/src/ua_reference_type.js.map +1 -0
- package/dist/src/ua_reference_type_impl.d.ts +43 -0
- package/dist/src/ua_reference_type_impl.js +138 -0
- package/dist/src/ua_reference_type_impl.js.map +1 -0
- package/dist/src/ua_variable.d.ts +346 -0
- package/dist/src/ua_variable.js +1721 -0
- package/dist/src/ua_variable.js.map +1 -0
- package/dist/src/ua_variable_impl.d.ts +353 -0
- package/dist/src/ua_variable_impl.js +1719 -0
- package/dist/src/ua_variable_impl.js.map +1 -0
- package/dist/src/ua_variable_type.d.ts +54 -0
- package/dist/src/ua_variable_type.js +555 -0
- package/dist/src/ua_variable_type.js.map +1 -0
- package/dist/src/ua_variable_type_impl.d.ts +63 -0
- package/dist/src/ua_variable_type_impl.js +556 -0
- package/dist/src/ua_variable_type_impl.js.map +1 -0
- package/dist/src/ua_view.d.ts +16 -0
- package/dist/src/ua_view.js +42 -0
- package/dist/src/ua_view.js.map +1 -0
- package/dist/src/ua_view_impl.d.ts +15 -0
- package/dist/src/ua_view_impl.js +37 -0
- package/dist/src/ua_view_impl.js.map +1 -0
- package/distHelpers/add_event_generator_object.d.ts +3 -0
- package/distHelpers/add_event_generator_object.js +66 -0
- package/distHelpers/add_event_generator_object.js.map +1 -0
- package/distHelpers/alarms_and_conditions_demo.d.ts +10 -0
- package/distHelpers/alarms_and_conditions_demo.js +115 -0
- package/distHelpers/alarms_and_conditions_demo.js.map +1 -0
- package/distHelpers/assertHasMatchingReference.d.ts +19 -0
- package/distHelpers/assertHasMatchingReference.js +41 -0
- package/distHelpers/assertHasMatchingReference.js.map +1 -0
- package/distHelpers/boiler_system.d.ts +113 -0
- package/distHelpers/boiler_system.js +397 -0
- package/distHelpers/boiler_system.js.map +1 -0
- package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -0
- package/distHelpers/create_minimalist_address_space_nodeset.js +171 -0
- package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -0
- package/distHelpers/dump_statemachine.d.ts +6 -0
- package/distHelpers/dump_statemachine.js +116 -0
- package/distHelpers/dump_statemachine.js.map +1 -0
- package/distHelpers/get_address_space_fixture.d.ts +1 -0
- package/distHelpers/get_address_space_fixture.js +31 -0
- package/distHelpers/get_address_space_fixture.js.map +1 -0
- package/distHelpers/get_mini_address_space.d.ts +7 -0
- package/distHelpers/get_mini_address_space.js +37 -0
- package/distHelpers/get_mini_address_space.js.map +1 -0
- package/distHelpers/index.d.ts +11 -0
- package/distHelpers/index.js +24 -0
- package/distHelpers/index.js.map +1 -0
- package/distNodeJS/generate_address_space.d.ts +4 -0
- package/distNodeJS/generate_address_space.js +31 -0
- package/distNodeJS/generate_address_space.js.map +1 -0
- package/distNodeJS/index.d.ts +1 -0
- package/distNodeJS/index.js +14 -0
- package/distNodeJS/index.js.map +1 -0
- package/generate.js +1 -0
- package/nodeJS.d.ts +1 -0
- package/nodeJS.js +1 -0
- package/package.json +87 -0
- package/source/address_space_ts.ts +217 -0
- package/source/continuation_points/continuation_point_manager.ts +121 -0
- package/source/helpers/adjust_browse_direction.ts +15 -0
- package/source/helpers/argument_list.ts +286 -0
- package/source/helpers/call_helpers.ts +112 -0
- package/source/helpers/check_event_clause.ts +62 -0
- package/source/helpers/coerce_enum_value.ts +33 -0
- package/source/helpers/dump_tools.ts +92 -0
- package/source/helpers/ensure_secure_access.ts +88 -0
- package/source/helpers/make_optionals_map.ts +49 -0
- package/source/helpers/resolve_opaque_on_address_space.ts +23 -0
- package/source/index.ts +49 -0
- package/source/interfaces/alarms_and_conditions/condition_info_i.ts +13 -0
- package/source/interfaces/data_access/ua_multistate_discrete_ex.ts +26 -0
- package/source/interfaces/data_access/ua_multistate_value_discrete_ex.ts +34 -0
- package/source/interfaces/data_access/ua_two_state_discrete_ex.ts +14 -0
- package/source/interfaces/data_access/ua_y_array_item_ex.ts +10 -0
- package/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.ts +14 -0
- package/source/interfaces/state_machine/ua_finite_state_machine_type.ts +50 -0
- package/source/interfaces/state_machine/ua_program_state_machine_type.ts +13 -0
- package/source/interfaces/state_machine/ua_state_machine_type.ts +261 -0
- package/source/interfaces/state_machine/ua_transition_ex.ts +7 -0
- package/source/interfaces/ua_subscription_diagnostics_variable_ex.ts +8 -0
- package/source/loader/generateAddressSpaceRaw.ts +79 -0
- package/source/loader/load_nodeset2.ts +1600 -0
- package/source/loader/namespace_post_step.ts +36 -0
- package/source/loader/register_node_promoter.ts +8 -0
- package/source/namespace.ts +9 -0
- package/source/namespace_alarm_and_condition.ts +47 -0
- package/source/namespace_data_access.ts +60 -0
- package/source/namespace_machine_state.ts +13 -0
- package/source/pseudo_session.ts +288 -0
- package/source/session_context.ts +345 -0
- package/source/set_namespace_meta_data.ts +68 -0
- package/source/ua_root_folder.ts +10 -0
- package/source/ua_two_state_variable_ex.ts +35 -0
- package/source/xml_writer.ts +15 -0
- package/source_nodejs/generate_address_space.ts +36 -0
- package/source_nodejs/index.ts +1 -0
- package/src/address_space.ts +1575 -0
- package/src/address_space_change_event_tools.ts +177 -0
- package/src/address_space_private.ts +98 -0
- package/src/alarms_and_conditions/check_where_clause.ts +148 -0
- package/src/alarms_and_conditions/condition.ts +89 -0
- package/src/alarms_and_conditions/condition_info.ts +66 -0
- package/src/alarms_and_conditions/condition_snapshot.ts +766 -0
- package/src/alarms_and_conditions/deviation_alarm_helper.ts +66 -0
- package/src/alarms_and_conditions/extract_event_fields.ts +104 -0
- package/src/alarms_and_conditions/index.ts +18 -0
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +339 -0
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +513 -0
- package/src/alarms_and_conditions/ua_base_event_impl.ts +55 -0
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +50 -0
- package/src/alarms_and_conditions/ua_condition_impl.ts +1298 -0
- package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +81 -0
- package/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.ts +110 -0
- package/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.ts +19 -0
- package/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.ts +130 -0
- package/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.ts +24 -0
- package/src/alarms_and_conditions/ua_limit_alarm_impl.ts +305 -0
- package/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.ts +108 -0
- package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +224 -0
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +186 -0
- package/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.ts +27 -0
- package/src/apply_condition_refresh.ts +30 -0
- package/src/base_node_impl.ts +1749 -0
- package/src/base_node_private.ts +690 -0
- package/src/data_access/add_dataItem_stuff.ts +75 -0
- package/src/data_access/check_variant_compatibility_ua_analog_item.ts +41 -0
- package/src/data_access/ua_multistate_discrete_impl.ts +168 -0
- package/src/data_access/ua_multistate_value_discrete.ts +299 -0
- package/src/data_access/ua_two_state_discrete.ts +185 -0
- package/src/event_data.ts +117 -0
- package/src/extension_object_array_node.ts +325 -0
- package/src/historical_access/address_space_historical_data_node.ts +828 -0
- package/src/index_current.ts +52 -0
- package/src/namespace_impl.ts +2181 -0
- package/src/namespace_private.ts +60 -0
- package/src/nodeid_manager.ts +228 -0
- package/src/nodeset_tools/adjust_namespace_array.ts +11 -0
- package/src/nodeset_tools/construct_namespace_dependency.ts +40 -0
- package/src/nodeset_tools/nodeset_to_xml.ts +1317 -0
- package/src/nodeset_tools/typedictionary_to_xml.ts +175 -0
- package/src/reference_impl.ts +169 -0
- package/src/role_permissions.ts +6 -0
- package/src/state_machine/finite_state_machine.ts +428 -0
- package/src/state_machine/ua_shelving_state_machine_ex.ts +314 -0
- package/src/state_machine/ua_two_state_variable.ts +421 -0
- package/src/tool_isSupertypeOf.ts +129 -0
- package/src/ua_condition_type.ts +10 -0
- package/src/ua_data_type_impl.ts +356 -0
- package/src/ua_method_impl.ts +278 -0
- package/src/ua_object_impl.ts +203 -0
- package/src/ua_object_type_impl.ts +158 -0
- package/src/ua_reference_type_impl.ts +174 -0
- package/src/ua_variable_impl.ts +2277 -0
- package/src/ua_variable_type_impl.ts +741 -0
- package/src/ua_view_impl.ts +54 -0
- package/testHelpers.d.ts +1 -0
- package/testHelpers.js +1 -0
- package/test_helpers/add_event_generator_object.ts +71 -0
- package/test_helpers/alarms_and_conditions_demo.ts +147 -0
- package/test_helpers/assertHasMatchingReference.ts +43 -0
- package/test_helpers/boiler_system.ts +618 -0
- package/test_helpers/create_minimalist_address_space_nodeset.ts +208 -0
- package/test_helpers/dump_statemachine.ts +155 -0
- package/test_helpers/get_address_space_fixture.ts +30 -0
- package/test_helpers/get_mini_address_space.ts +42 -0
- package/test_helpers/index.ts +11 -0
- package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +150 -0
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +57 -0
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +136 -0
- package/test_helpers/test_fixtures/dataType_withEnumeration.xml +82 -0
- package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +194 -0
- package/test_helpers/test_fixtures/dataType_with_structures.xml +605 -0
- package/test_helpers/test_fixtures/dataType_with_union.xml +1 -0
- package/test_helpers/test_fixtures/datatype_as_per_1.04.xml +91 -0
- package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +106 -0
- package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +1303 -0
- package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +362 -0
- package/test_helpers/test_fixtures/issue_846.xml +3172 -0
- package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +33 -0
- package/test_helpers/test_fixtures/mini.Node.Set2.xml +4508 -0
- package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +194 -0
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +8 -0
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +16 -0
- package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +45 -0
|
@@ -0,0 +1,1719 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UAVariableImplT = exports.UAVariableImpl = exports.verifyRankAndDimensions = exports.adjust_userAccessLevel = exports.adjust_accessLevel = void 0;
|
|
4
|
+
/* eslint-disable max-statements */
|
|
5
|
+
/* eslint-disable complexity */
|
|
6
|
+
/**
|
|
7
|
+
* @module node-opcua-address-space
|
|
8
|
+
*/
|
|
9
|
+
// tslint:disable:no-bitwise
|
|
10
|
+
// tslint:disable:no-console
|
|
11
|
+
// tslint:disable:max-line-length
|
|
12
|
+
const chalk = require("chalk");
|
|
13
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
14
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
15
|
+
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
16
|
+
const node_opcua_date_time_1 = require("node-opcua-date-time");
|
|
17
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
18
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
19
|
+
const node_opcua_numeric_range_1 = require("node-opcua-numeric-range");
|
|
20
|
+
const node_opcua_service_write_1 = require("node-opcua-service-write");
|
|
21
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
22
|
+
const node_opcua_types_1 = require("node-opcua-types");
|
|
23
|
+
const utils = require("node-opcua-utils");
|
|
24
|
+
const node_opcua_utils_1 = require("node-opcua-utils");
|
|
25
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
26
|
+
const session_context_1 = require("../source/session_context");
|
|
27
|
+
const base_node_impl_1 = require("./base_node_impl");
|
|
28
|
+
const base_node_private_1 = require("./base_node_private");
|
|
29
|
+
const ua_data_type_impl_1 = require("./ua_data_type_impl");
|
|
30
|
+
const apply_condition_refresh_1 = require("./apply_condition_refresh");
|
|
31
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
32
|
+
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
33
|
+
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
34
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
35
|
+
function isGoodish(statusCode) {
|
|
36
|
+
return statusCode.value < 0x10000000;
|
|
37
|
+
}
|
|
38
|
+
function adjust_accessLevel(accessLevel) {
|
|
39
|
+
accessLevel = utils.isNullOrUndefined(accessLevel) ? "CurrentRead | CurrentWrite" : accessLevel;
|
|
40
|
+
accessLevel = (0, node_opcua_data_model_1.makeAccessLevelFlag)(accessLevel);
|
|
41
|
+
(0, node_opcua_assert_1.assert)(isFinite(accessLevel));
|
|
42
|
+
return accessLevel;
|
|
43
|
+
}
|
|
44
|
+
exports.adjust_accessLevel = adjust_accessLevel;
|
|
45
|
+
function adjust_userAccessLevel(userAccessLevel, accessLevel) {
|
|
46
|
+
if (userAccessLevel === undefined) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
userAccessLevel = adjust_accessLevel(userAccessLevel);
|
|
50
|
+
accessLevel = adjust_accessLevel(accessLevel);
|
|
51
|
+
return (0, node_opcua_data_model_1.makeAccessLevelFlag)(accessLevel & userAccessLevel);
|
|
52
|
+
}
|
|
53
|
+
exports.adjust_userAccessLevel = adjust_userAccessLevel;
|
|
54
|
+
function adjust_samplingInterval(minimumSamplingInterval) {
|
|
55
|
+
(0, node_opcua_assert_1.assert)(isFinite(minimumSamplingInterval));
|
|
56
|
+
if (minimumSamplingInterval < 0) {
|
|
57
|
+
return -1; // only -1 is a valid negative value for samplingInterval and means "unspecified"
|
|
58
|
+
}
|
|
59
|
+
return minimumSamplingInterval;
|
|
60
|
+
}
|
|
61
|
+
function is_Variant(v) {
|
|
62
|
+
return v instanceof node_opcua_variant_1.Variant;
|
|
63
|
+
}
|
|
64
|
+
function is_StatusCode(v) {
|
|
65
|
+
return (v &&
|
|
66
|
+
v.constructor &&
|
|
67
|
+
(v.constructor.name === "ConstantStatusCode" ||
|
|
68
|
+
v.constructor.name === "StatusCode" ||
|
|
69
|
+
v.constructor.name === "ModifiableStatusCode"));
|
|
70
|
+
}
|
|
71
|
+
function is_Variant_or_StatusCode(v) {
|
|
72
|
+
if (is_Variant(v)) {
|
|
73
|
+
// /@@assert(v.isValid());
|
|
74
|
+
}
|
|
75
|
+
return is_Variant(v) || is_StatusCode(v);
|
|
76
|
+
}
|
|
77
|
+
function _dataType_toUADataType(addressSpace, dataType) {
|
|
78
|
+
(0, node_opcua_assert_1.assert)(addressSpace);
|
|
79
|
+
(0, node_opcua_assert_1.assert)(dataType !== node_opcua_variant_1.DataType.Null);
|
|
80
|
+
const dataTypeNode = addressSpace.findDataType(node_opcua_variant_1.DataType[dataType]);
|
|
81
|
+
/* istanbul ignore next */
|
|
82
|
+
if (!dataTypeNode) {
|
|
83
|
+
throw new Error(" Cannot find DataType " + node_opcua_variant_1.DataType[dataType] + " in address Space");
|
|
84
|
+
}
|
|
85
|
+
return dataTypeNode;
|
|
86
|
+
}
|
|
87
|
+
/*=
|
|
88
|
+
*
|
|
89
|
+
* @param addressSpace
|
|
90
|
+
* @param dataTypeNodeId : the nodeId matching the dataType of the destination variable.
|
|
91
|
+
* @param variantDataType: the dataType of the variant to write to the destination variable
|
|
92
|
+
* @param nodeId
|
|
93
|
+
* @return {boolean} true if the variant dataType is compatible with the Variable DataType
|
|
94
|
+
*/
|
|
95
|
+
function validateDataType(addressSpace, dataTypeNodeId, variantDataType, nodeId, allowNulls) {
|
|
96
|
+
if (variantDataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (variantDataType === node_opcua_variant_1.DataType.Null && allowNulls) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (variantDataType === node_opcua_variant_1.DataType.Null && !allowNulls) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
let builtInType;
|
|
106
|
+
let builtInUADataType;
|
|
107
|
+
const destUADataType = addressSpace.findNode(dataTypeNodeId);
|
|
108
|
+
(0, node_opcua_assert_1.assert)(destUADataType instanceof ua_data_type_impl_1.UADataTypeImpl);
|
|
109
|
+
if (destUADataType.isAbstract || destUADataType.nodeId.namespace !== 0) {
|
|
110
|
+
builtInUADataType = destUADataType;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
builtInType = node_opcua_variant_1.DataType[addressSpace.findCorrespondingBasicDataType(destUADataType)];
|
|
114
|
+
builtInUADataType = addressSpace.findDataType(builtInType);
|
|
115
|
+
}
|
|
116
|
+
(0, node_opcua_assert_1.assert)(builtInUADataType instanceof ua_data_type_impl_1.UADataTypeImpl);
|
|
117
|
+
const enumerationUADataType = addressSpace.findDataType("Enumeration");
|
|
118
|
+
if (!enumerationUADataType) {
|
|
119
|
+
throw new Error("cannot find Enumeration DataType node in standard address space");
|
|
120
|
+
}
|
|
121
|
+
if (destUADataType.isSupertypeOf(enumerationUADataType)) {
|
|
122
|
+
// istanbul ignore next
|
|
123
|
+
if (doDebug) {
|
|
124
|
+
console.log("destUADataType.", destUADataType.browseName.toString(), destUADataType.nodeId.toString());
|
|
125
|
+
console.log("enumerationUADataType.", enumerationUADataType.browseName.toString(), enumerationUADataType.nodeId.toString());
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
// The value supplied for the attribute is not of the same type as the value.
|
|
130
|
+
const variantUADataType = _dataType_toUADataType(addressSpace, variantDataType);
|
|
131
|
+
(0, node_opcua_assert_1.assert)(variantUADataType instanceof ua_data_type_impl_1.UADataTypeImpl);
|
|
132
|
+
const dest_isSuperTypeOf_variant = variantUADataType.isSupertypeOf(builtInUADataType);
|
|
133
|
+
/* istanbul ignore next */
|
|
134
|
+
if (doDebug) {
|
|
135
|
+
if (dest_isSuperTypeOf_variant) {
|
|
136
|
+
/* istanbul ignore next*/
|
|
137
|
+
console.log(chalk.green(" ---------- Type match !!! "), " on ", nodeId.toString());
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
/* istanbul ignore next*/
|
|
141
|
+
console.log(chalk.red(" ---------- Type mismatch "), " on ", nodeId.toString());
|
|
142
|
+
}
|
|
143
|
+
console.log(chalk.cyan(" Variable data Type is = "), destUADataType.browseName.toString());
|
|
144
|
+
console.log(chalk.cyan(" which matches basic Type = "), builtInUADataType.browseName.toString());
|
|
145
|
+
console.log(chalk.yellow(" Actual dataType = "), variantUADataType.browseName.toString());
|
|
146
|
+
}
|
|
147
|
+
return dest_isSuperTypeOf_variant;
|
|
148
|
+
}
|
|
149
|
+
function verifyRankAndDimensions(options) {
|
|
150
|
+
// evaluate valueRank arrayDimensions is specified but valueRank is null
|
|
151
|
+
if (options.arrayDimensions && options.valueRank === undefined) {
|
|
152
|
+
options.valueRank = options.arrayDimensions.length;
|
|
153
|
+
}
|
|
154
|
+
options.valueRank = options.valueRank === undefined ? -1 : options.valueRank || 0; // UInt32
|
|
155
|
+
(0, node_opcua_assert_1.assert)(typeof options.valueRank === "number");
|
|
156
|
+
options.arrayDimensions = options.arrayDimensions || null;
|
|
157
|
+
(0, node_opcua_assert_1.assert)(options.arrayDimensions === null || Array.isArray(options.arrayDimensions));
|
|
158
|
+
if (options.arrayDimensions && options.valueRank <= 0) {
|
|
159
|
+
throw new Error("[CONFORMANCE] arrayDimensions must be null if valueRank <=0");
|
|
160
|
+
}
|
|
161
|
+
// specify default arrayDimension if not provided
|
|
162
|
+
if (options.valueRank > 0 && !options.arrayDimensions) {
|
|
163
|
+
options.arrayDimensions = new Array(options.valueRank).fill(0);
|
|
164
|
+
}
|
|
165
|
+
if (!options.arrayDimensions && options.valueRank > 0) {
|
|
166
|
+
throw new Error("[CONFORMANCE] arrayDimension must be specified if valueRank >0 " + options.valueRank);
|
|
167
|
+
}
|
|
168
|
+
if (options.valueRank > 0 && options.arrayDimensions.length !== options.valueRank) {
|
|
169
|
+
throw new Error("[CONFORMANCE] when valueRank> 0, arrayDimensions must have valueRank elements, this.valueRank =" +
|
|
170
|
+
options.valueRank +
|
|
171
|
+
" whereas arrayDimensions.length =" +
|
|
172
|
+
options.arrayDimensions.length);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.verifyRankAndDimensions = verifyRankAndDimensions;
|
|
176
|
+
/**
|
|
177
|
+
* A OPCUA Variable Node
|
|
178
|
+
*
|
|
179
|
+
* @class UAVariable
|
|
180
|
+
* @constructor
|
|
181
|
+
* @extends BaseNode
|
|
182
|
+
* The AccessLevel Attribute is used to indicate how the Value of a Variable can be accessed (read/write) and if it
|
|
183
|
+
* contains current and/or historic data. The AccessLevel does not take any user access rights into account,
|
|
184
|
+
* i.e. although the Variable is writable this may be restricted to a certain user / user group.
|
|
185
|
+
* The AccessLevel is an 8-bit unsigned integer with the structure defined in the following table:
|
|
186
|
+
*
|
|
187
|
+
* Field Bit Description
|
|
188
|
+
* CurrentRead 0 Indicates if the current value is readable
|
|
189
|
+
* (0 means not readable, 1 means readable).
|
|
190
|
+
* CurrentWrite 1 Indicates if the current value is writable
|
|
191
|
+
* (0 means not writable, 1 means writable).
|
|
192
|
+
* HistoryRead 2 Indicates if the history of the value is readable
|
|
193
|
+
* (0 means not readable, 1 means readable).
|
|
194
|
+
* HistoryWrite 3 Indicates if the history of the value is writable (0 means not writable, 1 means writable).
|
|
195
|
+
* SemanticChange 4 Indicates if the Variable used as Property generates SemanticChangeEvents (see 9.31).
|
|
196
|
+
* Reserved 5:7 Reserved for future use. Shall always be zero.
|
|
197
|
+
*
|
|
198
|
+
* The first two bits also indicate if a current value of this Variable is available and the second two bits
|
|
199
|
+
* indicates if the history of the Variable is available via the OPC UA server.
|
|
200
|
+
*
|
|
201
|
+
*/
|
|
202
|
+
class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
203
|
+
constructor(options) {
|
|
204
|
+
super(options);
|
|
205
|
+
this.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
|
|
206
|
+
verifyRankAndDimensions(options);
|
|
207
|
+
this.valueRank = options.valueRank;
|
|
208
|
+
this.arrayDimensions = options.arrayDimensions;
|
|
209
|
+
this.dataType = this.resolveNodeId(options.dataType); // DataType (NodeId)
|
|
210
|
+
this.accessLevel = adjust_accessLevel(options.accessLevel);
|
|
211
|
+
this.userAccessLevel = adjust_userAccessLevel(options.userAccessLevel, this.accessLevel);
|
|
212
|
+
this.minimumSamplingInterval = adjust_samplingInterval(options.minimumSamplingInterval || 0);
|
|
213
|
+
this.historizing = !!options.historizing; // coerced to boolean
|
|
214
|
+
this._dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.UncertainInitialValue, value: {} });
|
|
215
|
+
// xx options.value = options.value || { dataType: DataType.Null };
|
|
216
|
+
if (options.value) {
|
|
217
|
+
this.bindVariable(options.value);
|
|
218
|
+
}
|
|
219
|
+
this.setMaxListeners(5000);
|
|
220
|
+
this.semantic_version = 0;
|
|
221
|
+
}
|
|
222
|
+
get typeDefinitionObj() {
|
|
223
|
+
return super.typeDefinitionObj;
|
|
224
|
+
}
|
|
225
|
+
get typeDefinition() {
|
|
226
|
+
return super.typeDefinition;
|
|
227
|
+
}
|
|
228
|
+
checkPermissionAndAccessLevelPrivate(context, permission, accessLevel) {
|
|
229
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
230
|
+
if (context.checkPermission) {
|
|
231
|
+
(0, node_opcua_assert_1.assert)(context.checkPermission instanceof Function);
|
|
232
|
+
if (!context.checkPermission(this, permission)) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (this.userAccessLevel === undefined) {
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
return (this.userAccessLevel & accessLevel) === accessLevel;
|
|
240
|
+
}
|
|
241
|
+
isReadable(context) {
|
|
242
|
+
return (this.accessLevel & node_opcua_data_model_1.AccessLevelFlag.CurrentRead) === node_opcua_data_model_1.AccessLevelFlag.CurrentRead;
|
|
243
|
+
}
|
|
244
|
+
isUserReadable(context) {
|
|
245
|
+
if (!this.isReadable(context)) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
return this.checkPermissionAndAccessLevelPrivate(context, node_opcua_types_1.PermissionType.Read, node_opcua_data_model_1.AccessLevelFlag.CurrentRead);
|
|
249
|
+
}
|
|
250
|
+
isWritable(context) {
|
|
251
|
+
return (this.accessLevel & node_opcua_data_model_1.AccessLevelFlag.CurrentWrite) === node_opcua_data_model_1.AccessLevelFlag.CurrentWrite;
|
|
252
|
+
}
|
|
253
|
+
isUserWritable(context) {
|
|
254
|
+
if (!this.isWritable(context)) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
return this.checkPermissionAndAccessLevelPrivate(context, node_opcua_types_1.PermissionType.Write, node_opcua_data_model_1.AccessLevelFlag.CurrentWrite);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
*
|
|
261
|
+
*
|
|
262
|
+
* from OPC.UA.Spec 1.02 part 4
|
|
263
|
+
* 5.10.2.4 StatusCodes
|
|
264
|
+
* Table 51 defines values for the operation level statusCode contained in the DataValue structure of
|
|
265
|
+
* each values element. Common StatusCodes are defined in Table 166.
|
|
266
|
+
*
|
|
267
|
+
* Table 51 Read Operation Level Result Codes
|
|
268
|
+
*
|
|
269
|
+
* Symbolic Id Description
|
|
270
|
+
*
|
|
271
|
+
* BadNodeIdInvalid The syntax of the node id is not valid.
|
|
272
|
+
* BadNodeIdUnknown The node id refers to a node that does not exist in the server address space.
|
|
273
|
+
* BadAttributeIdInvalid BadAttributeIdInvalid The attribute is not supported for the specified node.
|
|
274
|
+
* BadIndexRangeInvalid The syntax of the index range parameter is invalid.
|
|
275
|
+
* BadIndexRangeNoData No data exists within the range of indexes specified.
|
|
276
|
+
* BadDataEncodingInvalid The data encoding is invalid.
|
|
277
|
+
* This result is used if no dataEncoding can be applied because an Attribute other
|
|
278
|
+
* than Value was requested or the DataType of the Value Attribute is not a subtype
|
|
279
|
+
* of the Structure DataType.
|
|
280
|
+
* BadDataEncodingUnsupported The server does not support the requested data encoding for the node.
|
|
281
|
+
* This result is used if a dataEncoding can be applied but the passed data encoding
|
|
282
|
+
* is not known to the Server.
|
|
283
|
+
* BadNotReadable The access level does not allow reading or subscribing to the Node.
|
|
284
|
+
* BadUserAccessDenied User does not have permission to perform the requested operation. (table 165)
|
|
285
|
+
*/
|
|
286
|
+
readValue(context, indexRange, dataEncoding) {
|
|
287
|
+
if (!context) {
|
|
288
|
+
context = session_context_1.SessionContext.defaultContext;
|
|
289
|
+
}
|
|
290
|
+
if (context.isAccessRestricted(this)) {
|
|
291
|
+
return new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadSecurityModeInsufficient });
|
|
292
|
+
}
|
|
293
|
+
if (!this.isReadable(context)) {
|
|
294
|
+
return new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadNotReadable });
|
|
295
|
+
}
|
|
296
|
+
if (!this.isUserReadable(context)) {
|
|
297
|
+
return new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadUserAccessDenied });
|
|
298
|
+
}
|
|
299
|
+
if (!(0, node_opcua_data_model_1.isValidDataEncoding)(dataEncoding)) {
|
|
300
|
+
return new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadDataEncodingInvalid });
|
|
301
|
+
}
|
|
302
|
+
if (this._timestamped_get_func) {
|
|
303
|
+
if (this._timestamped_get_func.length === 0) {
|
|
304
|
+
this._dataValue = this._timestamped_get_func();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
let dataValue = this._dataValue;
|
|
308
|
+
if (isGoodish(dataValue.statusCode)) {
|
|
309
|
+
// note : extractRange will clone the dataValue
|
|
310
|
+
dataValue = (0, node_opcua_data_value_1.extractRange)(dataValue, indexRange);
|
|
311
|
+
}
|
|
312
|
+
/* istanbul ignore next */
|
|
313
|
+
if (dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.BadWaitingForInitialData) ||
|
|
314
|
+
dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.UncertainInitialValue)) {
|
|
315
|
+
debugLog(chalk.red(" Warning: UAVariable#readValue ") +
|
|
316
|
+
chalk.cyan(this.browseName.toString()) +
|
|
317
|
+
" (" +
|
|
318
|
+
chalk.yellow(this.nodeId.toString()) +
|
|
319
|
+
") exists but dataValue has not been defined");
|
|
320
|
+
}
|
|
321
|
+
return dataValue;
|
|
322
|
+
}
|
|
323
|
+
isEnumeration() {
|
|
324
|
+
return this.addressSpacePrivate.isEnumeration(this.dataType);
|
|
325
|
+
}
|
|
326
|
+
isExtensionObject() {
|
|
327
|
+
// DataType must be one of Structure
|
|
328
|
+
const dataTypeNode = this.addressSpace.findDataType(this.dataType);
|
|
329
|
+
if (!dataTypeNode) {
|
|
330
|
+
throw new Error(" Cannot find DataType " + this.dataType.toString() + " in standard address Space");
|
|
331
|
+
}
|
|
332
|
+
const structureNode = this.addressSpace.findDataType("Structure");
|
|
333
|
+
if (!structureNode) {
|
|
334
|
+
throw new Error(" Cannot find 'Structure' DataType in standard address Space");
|
|
335
|
+
}
|
|
336
|
+
return dataTypeNode.isSupertypeOf(structureNode);
|
|
337
|
+
}
|
|
338
|
+
_getEnumerationInfo() {
|
|
339
|
+
// DataType must be one of Enumeration
|
|
340
|
+
(0, node_opcua_assert_1.assert)(this.isEnumeration(), "Variable is not an enumeration");
|
|
341
|
+
const dataTypeNode = this.addressSpace.findDataType(this.dataType);
|
|
342
|
+
return dataTypeNode._getEnumerationInfo();
|
|
343
|
+
}
|
|
344
|
+
asyncRefresh(...args) {
|
|
345
|
+
const oldestDate = args[0];
|
|
346
|
+
(0, node_opcua_assert_1.assert)(oldestDate instanceof Date);
|
|
347
|
+
const callback = args[1];
|
|
348
|
+
if (!this.refreshFunc) {
|
|
349
|
+
// no refresh func
|
|
350
|
+
const dataValue = this.readValue();
|
|
351
|
+
dataValue.serverTimestamp = oldestDate;
|
|
352
|
+
dataValue.serverPicoseconds = 0;
|
|
353
|
+
if (oldestDate.getTime() <= dataValue.serverTimestamp.getTime()) {
|
|
354
|
+
return callback(null, dataValue);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
// fake
|
|
358
|
+
return callback(null, dataValue);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (this._dataValue.serverTimestamp && oldestDate.getTime() <= this._dataValue.serverTimestamp.getTime()) {
|
|
362
|
+
const dataValue = this.readValue();
|
|
363
|
+
dataValue.serverTimestamp = oldestDate;
|
|
364
|
+
dataValue.serverPicoseconds = 0;
|
|
365
|
+
return callback(null, dataValue);
|
|
366
|
+
}
|
|
367
|
+
this.refreshFunc.call(this, (err, dataValue) => {
|
|
368
|
+
if (err || !dataValue) {
|
|
369
|
+
dataValue = { statusCode: node_opcua_status_code_1.StatusCodes.BadNoDataAvailable };
|
|
370
|
+
}
|
|
371
|
+
if (dataValue !== this._dataValue) {
|
|
372
|
+
this._internal_set_dataValue(coerceDataValue(dataValue), null);
|
|
373
|
+
}
|
|
374
|
+
callback(err, this._dataValue);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
readEnumValue() {
|
|
378
|
+
const value = this.readValue().value.value;
|
|
379
|
+
const enumInfo = this._getEnumerationInfo();
|
|
380
|
+
const enumV = enumInfo.valueIndex[value];
|
|
381
|
+
return { value, name: enumV ? enumV.name : "?????" };
|
|
382
|
+
}
|
|
383
|
+
writeEnumValue(value) {
|
|
384
|
+
const enumInfo = this._getEnumerationInfo();
|
|
385
|
+
if (typeof value === "string") {
|
|
386
|
+
if (!Object.prototype.hasOwnProperty.call(enumInfo.nameIndex, value)) {
|
|
387
|
+
const possibleValues = Object.keys(enumInfo.nameIndex).join(",");
|
|
388
|
+
throw new Error("UAVariable#writeEnumValue: cannot find value " + value + " in [" + possibleValues + "]");
|
|
389
|
+
}
|
|
390
|
+
const valueIndex = enumInfo.nameIndex[value].value;
|
|
391
|
+
value = valueIndex;
|
|
392
|
+
}
|
|
393
|
+
if (isFinite(value)) {
|
|
394
|
+
const possibleValues = Object.keys(enumInfo.nameIndex).join(",");
|
|
395
|
+
if (!enumInfo.valueIndex[value]) {
|
|
396
|
+
throw new Error("UAVariable#writeEnumValue : value out of range " + value + " in [" + possibleValues + "]");
|
|
397
|
+
}
|
|
398
|
+
this.setValueFromSource({
|
|
399
|
+
dataType: node_opcua_variant_1.DataType.Int32,
|
|
400
|
+
value
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
throw new Error("UAVariable#writeEnumValue: value type mismatch");
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
readAttribute(context, attributeId, indexRange, dataEncoding) {
|
|
408
|
+
context = context || session_context_1.SessionContext.defaultContext;
|
|
409
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
410
|
+
const options = {};
|
|
411
|
+
if (attributeId !== node_opcua_data_model_1.AttributeIds.Value) {
|
|
412
|
+
if (indexRange && indexRange.isDefined()) {
|
|
413
|
+
options.statusCode = node_opcua_status_code_1.StatusCodes.BadIndexRangeNoData;
|
|
414
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
415
|
+
}
|
|
416
|
+
if ((0, node_opcua_data_model_1.isDataEncoding)(dataEncoding)) {
|
|
417
|
+
options.statusCode = node_opcua_status_code_1.StatusCodes.BadDataEncodingInvalid;
|
|
418
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
switch (attributeId) {
|
|
422
|
+
case node_opcua_data_model_1.AttributeIds.Value:
|
|
423
|
+
return this.readValue(context, indexRange, dataEncoding);
|
|
424
|
+
case node_opcua_data_model_1.AttributeIds.DataType:
|
|
425
|
+
return this._readDataType();
|
|
426
|
+
case node_opcua_data_model_1.AttributeIds.ValueRank:
|
|
427
|
+
return this._readValueRank();
|
|
428
|
+
case node_opcua_data_model_1.AttributeIds.ArrayDimensions:
|
|
429
|
+
return this._readArrayDimensions();
|
|
430
|
+
case node_opcua_data_model_1.AttributeIds.AccessLevel:
|
|
431
|
+
return this._readAccessLevel(context);
|
|
432
|
+
case node_opcua_data_model_1.AttributeIds.UserAccessLevel:
|
|
433
|
+
return this._readUserAccessLevel(context);
|
|
434
|
+
case node_opcua_data_model_1.AttributeIds.MinimumSamplingInterval:
|
|
435
|
+
return this._readMinimumSamplingInterval();
|
|
436
|
+
case node_opcua_data_model_1.AttributeIds.Historizing:
|
|
437
|
+
return this._readHistorizing();
|
|
438
|
+
case node_opcua_data_model_1.AttributeIds.AccessLevelEx:
|
|
439
|
+
return this._readAccessLevelEx(context);
|
|
440
|
+
default:
|
|
441
|
+
return base_node_impl_1.BaseNodeImpl.prototype.readAttribute.call(this, context, attributeId);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
adjustVariant(variant) {
|
|
445
|
+
const addressSpace = this.addressSpace;
|
|
446
|
+
const dataTypeNodeId = addressSpace.findCorrespondingBasicDataType(this.dataType);
|
|
447
|
+
return (0, node_opcua_variant_1.adjustVariant)(variant, this.valueRank, dataTypeNodeId);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* setValueFromSource is used to let the device sets the variable values
|
|
451
|
+
* this method also records the current time as sourceTimestamp and serverTimestamp.
|
|
452
|
+
. *
|
|
453
|
+
* The method will raise an exception if the value is not compatible with the dataType and expected dimension
|
|
454
|
+
*
|
|
455
|
+
* @method setValueFromSource
|
|
456
|
+
* @param variant {Variant}
|
|
457
|
+
* @param [statusCode {StatusCode} = StatusCodes.Good]
|
|
458
|
+
* @param [sourceTimestamp= Now]
|
|
459
|
+
*/
|
|
460
|
+
setValueFromSource(variant, statusCode, sourceTimestamp) {
|
|
461
|
+
statusCode = statusCode || node_opcua_status_code_1.StatusCodes.Good;
|
|
462
|
+
// istanbul ignore next
|
|
463
|
+
if (Object.prototype.hasOwnProperty.call(variant, "value")) {
|
|
464
|
+
if (variant.dataType === null || variant.dataType === undefined) {
|
|
465
|
+
throw new Error("Variant must provide a valid dataType" + variant.toString());
|
|
466
|
+
}
|
|
467
|
+
if (variant.dataType === node_opcua_variant_1.DataType.Boolean &&
|
|
468
|
+
(this.dataType.namespace !== 0 || this.dataType.value !== node_opcua_variant_1.DataType.Boolean)) {
|
|
469
|
+
throw new Error("Variant must provide a valid Boolean" + variant.toString());
|
|
470
|
+
}
|
|
471
|
+
if (this.dataType.namespace === 0 &&
|
|
472
|
+
this.dataType.value === node_opcua_variant_1.DataType.LocalizedText &&
|
|
473
|
+
variant.dataType !== node_opcua_variant_1.DataType.LocalizedText) {
|
|
474
|
+
throw new Error("Variant must provide a valid LocalizedText" + variant.toString());
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const variant1 = node_opcua_variant_1.Variant.coerce(variant);
|
|
478
|
+
const now = (0, node_opcua_date_time_1.coerceClock)(sourceTimestamp, 0);
|
|
479
|
+
const dataValue = new node_opcua_data_value_1.DataValue(null);
|
|
480
|
+
dataValue.serverPicoseconds = now.picoseconds;
|
|
481
|
+
dataValue.serverTimestamp = now.timestamp;
|
|
482
|
+
dataValue.sourcePicoseconds = now.picoseconds;
|
|
483
|
+
dataValue.sourceTimestamp = now.timestamp;
|
|
484
|
+
dataValue.statusCode = statusCode;
|
|
485
|
+
dataValue.value = variant1;
|
|
486
|
+
this._internal_set_dataValue(dataValue);
|
|
487
|
+
}
|
|
488
|
+
writeValue(context, dataValue, ...args) {
|
|
489
|
+
context = context || session_context_1.SessionContext.defaultContext;
|
|
490
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
491
|
+
if (!dataValue.sourceTimestamp) {
|
|
492
|
+
// source timestamp was not specified by the caller
|
|
493
|
+
// we will set the timestamp ourself with the current clock
|
|
494
|
+
if (context.currentTime) {
|
|
495
|
+
dataValue.sourceTimestamp = context.currentTime.timestamp;
|
|
496
|
+
dataValue.sourcePicoseconds = context.currentTime.picoseconds;
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
const { timestamp, picoseconds } = (0, node_opcua_date_time_1.getCurrentClock)();
|
|
500
|
+
dataValue.sourceTimestamp = timestamp;
|
|
501
|
+
dataValue.sourcePicoseconds = picoseconds;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (context.currentTime && !dataValue.serverTimestamp) {
|
|
505
|
+
dataValue.serverTimestamp = context.currentTime.timestamp;
|
|
506
|
+
dataValue.serverPicoseconds = context.currentTime.picoseconds;
|
|
507
|
+
}
|
|
508
|
+
// adjust arguments if optional indexRange Parameter is not given
|
|
509
|
+
let indexRange = null;
|
|
510
|
+
let callback;
|
|
511
|
+
if (args.length === 1) {
|
|
512
|
+
indexRange = new node_opcua_numeric_range_1.NumericRange();
|
|
513
|
+
callback = args[0];
|
|
514
|
+
}
|
|
515
|
+
else if (args.length === 2) {
|
|
516
|
+
indexRange = args[0];
|
|
517
|
+
callback = args[1];
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
throw new Error("Invalid Number of args");
|
|
521
|
+
}
|
|
522
|
+
(0, node_opcua_assert_1.assert)(typeof callback === "function");
|
|
523
|
+
(0, node_opcua_assert_1.assert)(dataValue instanceof node_opcua_data_value_1.DataValue);
|
|
524
|
+
// index range could be string
|
|
525
|
+
indexRange = node_opcua_numeric_range_1.NumericRange.coerce(indexRange);
|
|
526
|
+
// test write permission
|
|
527
|
+
if (!this.isWritable(context)) {
|
|
528
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadNotWritable);
|
|
529
|
+
}
|
|
530
|
+
if (!this.isUserWritable(context)) {
|
|
531
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadUserAccessDenied);
|
|
532
|
+
}
|
|
533
|
+
// adjust special case
|
|
534
|
+
const variant = adjustVariant2.call(this, dataValue.value);
|
|
535
|
+
const statusCode = this.checkVariantCompatibility(variant);
|
|
536
|
+
if (statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
537
|
+
return callback(null, statusCode);
|
|
538
|
+
}
|
|
539
|
+
function default_func(dataValue1, indexRange1, callback1) {
|
|
540
|
+
// xx assert(!indexRange,"indexRange Not Implemented");
|
|
541
|
+
return _default_writable_timestamped_set_func.call(this, dataValue1, callback1);
|
|
542
|
+
}
|
|
543
|
+
const write_func = (this._timestamped_set_func || default_func);
|
|
544
|
+
if (!write_func) {
|
|
545
|
+
warningLog(" warning " + this.nodeId.toString() + " " + this.browseName.toString() + " has no setter. \n");
|
|
546
|
+
warningLog("Please make sure to bind the variable or to pass a valid value: new Variant({}) during construction time");
|
|
547
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadNotWritable);
|
|
548
|
+
}
|
|
549
|
+
(0, node_opcua_assert_1.assert)(write_func);
|
|
550
|
+
write_func.call(this, dataValue, indexRange, (err, statusCode1, correctedDataValue) => {
|
|
551
|
+
if (!err) {
|
|
552
|
+
correctedDataValue = correctedDataValue || dataValue;
|
|
553
|
+
(0, node_opcua_assert_1.assert)(correctedDataValue instanceof node_opcua_data_value_1.DataValue);
|
|
554
|
+
// xx assert(correctedDataValue.serverTimestamp);
|
|
555
|
+
if (indexRange && !indexRange.isEmpty()) {
|
|
556
|
+
if (!indexRange.isValid()) {
|
|
557
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadIndexRangeInvalid);
|
|
558
|
+
}
|
|
559
|
+
const newArrayOrMatrix = correctedDataValue.value.value;
|
|
560
|
+
if (correctedDataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
561
|
+
if (this._dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Array) {
|
|
562
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
563
|
+
}
|
|
564
|
+
// check that destination data is also an array
|
|
565
|
+
(0, node_opcua_assert_1.assert)(check_valid_array(this._dataValue.value.dataType, this._dataValue.value.value));
|
|
566
|
+
const destArr = this._dataValue.value.value;
|
|
567
|
+
const result = indexRange.set_values(destArr, newArrayOrMatrix);
|
|
568
|
+
if (result.statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
569
|
+
return callback(null, result.statusCode);
|
|
570
|
+
}
|
|
571
|
+
correctedDataValue.value.value = result.array;
|
|
572
|
+
// scrap original array so we detect range
|
|
573
|
+
this._dataValue.value.value = null;
|
|
574
|
+
}
|
|
575
|
+
else if (correctedDataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
576
|
+
const dimensions = this._dataValue.value.dimensions;
|
|
577
|
+
if (this._dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Matrix || !dimensions) {
|
|
578
|
+
// not a matrix !
|
|
579
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
580
|
+
}
|
|
581
|
+
const matrix = this._dataValue.value.value;
|
|
582
|
+
const result = indexRange.set_values_matrix({
|
|
583
|
+
matrix,
|
|
584
|
+
dimensions
|
|
585
|
+
}, newArrayOrMatrix);
|
|
586
|
+
if (result.statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
587
|
+
return callback(null, result.statusCode);
|
|
588
|
+
}
|
|
589
|
+
correctedDataValue.value.dimensions = this._dataValue.value.dimensions;
|
|
590
|
+
correctedDataValue.value.value = result.matrix;
|
|
591
|
+
// scrap original array so we detect range
|
|
592
|
+
this._dataValue.value.value = null;
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
try {
|
|
599
|
+
this._internal_set_dataValue(correctedDataValue, indexRange);
|
|
600
|
+
}
|
|
601
|
+
catch (err) {
|
|
602
|
+
if (err instanceof Error) {
|
|
603
|
+
warningLog(err.message);
|
|
604
|
+
}
|
|
605
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadInternalError);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
callback(err, statusCode1);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
writeAttribute(context, writeValueOptions, callback) {
|
|
612
|
+
// istanbul ignore next
|
|
613
|
+
if (!callback) {
|
|
614
|
+
throw new Error("Internal error");
|
|
615
|
+
}
|
|
616
|
+
const writeValue = writeValueOptions instanceof node_opcua_service_write_1.WriteValue ? writeValueOptions : new node_opcua_service_write_1.WriteValue(writeValueOptions);
|
|
617
|
+
context = context || session_context_1.SessionContext.defaultContext;
|
|
618
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
619
|
+
(0, node_opcua_assert_1.assert)(writeValue instanceof node_opcua_service_write_1.WriteValue);
|
|
620
|
+
(0, node_opcua_assert_1.assert)(writeValue.value instanceof node_opcua_data_value_1.DataValue);
|
|
621
|
+
(0, node_opcua_assert_1.assert)(writeValue.value.value instanceof node_opcua_variant_1.Variant);
|
|
622
|
+
(0, node_opcua_assert_1.assert)(typeof callback === "function");
|
|
623
|
+
// Spec 1.0.2 Part 4 page 58
|
|
624
|
+
// If the SourceTimestamp or the ServerTimestamp is specified, the Server shall
|
|
625
|
+
// use these values.
|
|
626
|
+
// xx _apply_default_timestamps(writeValue.value);
|
|
627
|
+
switch (writeValue.attributeId) {
|
|
628
|
+
case node_opcua_data_model_1.AttributeIds.Value:
|
|
629
|
+
this.writeValue(context, writeValue.value, writeValue.indexRange, callback);
|
|
630
|
+
break;
|
|
631
|
+
case node_opcua_data_model_1.AttributeIds.Historizing:
|
|
632
|
+
if (writeValue.value.value.dataType !== node_opcua_variant_1.DataType.Boolean) {
|
|
633
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadNotSupported);
|
|
634
|
+
}
|
|
635
|
+
// if the variable has no historizing in place reject
|
|
636
|
+
if (!this["hA Configuration"]) {
|
|
637
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadNotSupported);
|
|
638
|
+
}
|
|
639
|
+
// check if user is allowed to do that !
|
|
640
|
+
// TODO
|
|
641
|
+
this.historizing = !!writeValue.value.value.value; // yes ! indeed !
|
|
642
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.Good);
|
|
643
|
+
default:
|
|
644
|
+
super.writeAttribute(context, writeValue, callback);
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* @method checkVariantCompatibility
|
|
650
|
+
* note:
|
|
651
|
+
* this method is overridden in address-space-data-access
|
|
652
|
+
* @return {StatusCode}
|
|
653
|
+
*/
|
|
654
|
+
checkVariantCompatibility(value) {
|
|
655
|
+
// test dataType
|
|
656
|
+
if (!this._validate_DataType(value.dataType)) {
|
|
657
|
+
return node_opcua_status_code_1.StatusCodes.BadTypeMismatch;
|
|
658
|
+
}
|
|
659
|
+
return node_opcua_status_code_1.StatusCodes.Good;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* @method touchValue
|
|
663
|
+
* touch the source timestamp of a Variable and cascade up the change
|
|
664
|
+
* to the parent variable if any.
|
|
665
|
+
*
|
|
666
|
+
* @param [optionalNow=null] {Object}
|
|
667
|
+
* @param optionalNow.timestamp {Date}
|
|
668
|
+
* @param optionalNow.picoseconds {Number}
|
|
669
|
+
*/
|
|
670
|
+
touchValue(optionalNow) {
|
|
671
|
+
const now = optionalNow || (0, node_opcua_date_time_1.getCurrentClock)();
|
|
672
|
+
this._dataValue.sourceTimestamp = now.timestamp;
|
|
673
|
+
this._dataValue.sourcePicoseconds = now.picoseconds;
|
|
674
|
+
this._dataValue.serverTimestamp = now.timestamp;
|
|
675
|
+
this._dataValue.serverPicoseconds = now.picoseconds;
|
|
676
|
+
this._dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
677
|
+
if (this.minimumSamplingInterval === 0) {
|
|
678
|
+
if (this.listenerCount("value_changed") > 0) {
|
|
679
|
+
const clonedDataValue = this.readValue();
|
|
680
|
+
this.emit("value_changed", clonedDataValue);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (this.parent && this.parent.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
684
|
+
this.parent.touchValue(now);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* bind a variable with a get and set functions.
|
|
689
|
+
*
|
|
690
|
+
* properties:
|
|
691
|
+
* - value: a Variant or a status code
|
|
692
|
+
* - sourceTimestamp
|
|
693
|
+
* - sourcePicoseconds
|
|
694
|
+
* @param [options.timestamped_set]
|
|
695
|
+
* @param [options.refreshFunc] the variable asynchronous getter function.
|
|
696
|
+
* @param [overwrite {Boolean} = false] set overwrite to true to overwrite existing binding
|
|
697
|
+
* @return void
|
|
698
|
+
*
|
|
699
|
+
*
|
|
700
|
+
* ### Providing read access to the underlying value
|
|
701
|
+
*
|
|
702
|
+
* #### Variation 1
|
|
703
|
+
*
|
|
704
|
+
* In this variation, the user provides a function that returns a Variant with the current value.
|
|
705
|
+
*
|
|
706
|
+
* The sourceTimestamp will be set automatically.
|
|
707
|
+
*
|
|
708
|
+
* The get function is called synchronously.
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
*
|
|
712
|
+
*
|
|
713
|
+
* ```javascript
|
|
714
|
+
* ...
|
|
715
|
+
* var options = {
|
|
716
|
+
* get : () => {
|
|
717
|
+
* return new Variant({...});
|
|
718
|
+
* },
|
|
719
|
+
* set : function(variant) {
|
|
720
|
+
* // store the variant somewhere
|
|
721
|
+
* return StatusCodes.Good;
|
|
722
|
+
* }
|
|
723
|
+
* };
|
|
724
|
+
* ...
|
|
725
|
+
* engine.bindVariable(nodeId,options):
|
|
726
|
+
* ...
|
|
727
|
+
* ```
|
|
728
|
+
*
|
|
729
|
+
*
|
|
730
|
+
* #### Variation 2:
|
|
731
|
+
*
|
|
732
|
+
* This variation can be used when the user wants to specify a specific '''sourceTimestamp''' associated
|
|
733
|
+
* with the current value of the UAVariable.
|
|
734
|
+
*
|
|
735
|
+
* The provided ```timestamped_get``` function should return an object with three properties:
|
|
736
|
+
* * value: containing the variant value or a error StatusCode,
|
|
737
|
+
* * sourceTimestamp
|
|
738
|
+
* * sourcePicoseconds
|
|
739
|
+
*
|
|
740
|
+
* ```javascript
|
|
741
|
+
* ...
|
|
742
|
+
* var myDataValue = new DataValue({
|
|
743
|
+
* value: {dataType: DataType.Double , value: 10.0},
|
|
744
|
+
* sourceTimestamp : new Date(),
|
|
745
|
+
* sourcePicoseconds: 0
|
|
746
|
+
* });
|
|
747
|
+
* ...
|
|
748
|
+
* var options = {
|
|
749
|
+
* timestamped_get : () => { return myDataValue; }
|
|
750
|
+
* };
|
|
751
|
+
* ...
|
|
752
|
+
* engine.bindVariable(nodeId,options):
|
|
753
|
+
* ...
|
|
754
|
+
* // record a new value
|
|
755
|
+
* myDataValue.value.value = 5.0;
|
|
756
|
+
* myDataValue.sourceTimestamp = new Date();
|
|
757
|
+
* ...
|
|
758
|
+
* ```
|
|
759
|
+
*
|
|
760
|
+
*
|
|
761
|
+
* #### Variation 3:
|
|
762
|
+
*
|
|
763
|
+
* This variation can be used when the value associated with the variables requires a asynchronous function call to be
|
|
764
|
+
* extracted. In this case, the user should provide an async method ```refreshFunc```.
|
|
765
|
+
*
|
|
766
|
+
*
|
|
767
|
+
* The ```refreshFunc``` shall do whatever is necessary to fetch the most up to date version of the variable value, and
|
|
768
|
+
* call the ```callback``` function when the data is ready.
|
|
769
|
+
*
|
|
770
|
+
*
|
|
771
|
+
* The ```callback``` function follow the standard callback function signature:
|
|
772
|
+
* * the first argument shall be **null** or **Error**, depending of the outcome of the fetch operation,
|
|
773
|
+
* * the second argument shall be a DataValue with the new UAVariable Value, a StatusCode, and time stamps.
|
|
774
|
+
*
|
|
775
|
+
*
|
|
776
|
+
* Optionally, it is possible to pass a sourceTimestamp and a sourcePicoseconds value as a third and fourth arguments
|
|
777
|
+
* of the callback. When sourceTimestamp and sourcePicoseconds are missing, the system will set their default value
|
|
778
|
+
* to the current time..
|
|
779
|
+
*
|
|
780
|
+
*
|
|
781
|
+
* ```javascript
|
|
782
|
+
* ...
|
|
783
|
+
* var options = {
|
|
784
|
+
* refreshFunc : function(callback) {
|
|
785
|
+
* ... do_some_async_stuff_to_get_the_new_variable_value
|
|
786
|
+
* var dataValue = new DataValue({
|
|
787
|
+
* value: new Variant({...}),
|
|
788
|
+
* statusCode: StatusCodes.Good,
|
|
789
|
+
* sourceTimestamp: new Date()
|
|
790
|
+
* });
|
|
791
|
+
* callback(null,dataValue);
|
|
792
|
+
* }
|
|
793
|
+
* };
|
|
794
|
+
* ...
|
|
795
|
+
* variable.bindVariable(nodeId,options):
|
|
796
|
+
* ...
|
|
797
|
+
* ```
|
|
798
|
+
*
|
|
799
|
+
* ### Providing write access to the underlying value
|
|
800
|
+
*
|
|
801
|
+
* #### Variation1 - provide a simple synchronous set function
|
|
802
|
+
*
|
|
803
|
+
*
|
|
804
|
+
* #### Notes
|
|
805
|
+
* to do : explain return StatusCodes.GoodCompletesAsynchronously;
|
|
806
|
+
*
|
|
807
|
+
*/
|
|
808
|
+
bindVariable(options, overwrite) {
|
|
809
|
+
if (overwrite) {
|
|
810
|
+
this._timestamped_set_func = null;
|
|
811
|
+
this._timestamped_get_func = null;
|
|
812
|
+
this._get_func = null;
|
|
813
|
+
this._set_func = null;
|
|
814
|
+
this.refreshFunc = undefined;
|
|
815
|
+
this._historyRead = UAVariableImpl.prototype._historyRead;
|
|
816
|
+
}
|
|
817
|
+
options = options || {};
|
|
818
|
+
(0, node_opcua_assert_1.assert)(typeof this._timestamped_set_func !== "function", "UAVariable already bound");
|
|
819
|
+
(0, node_opcua_assert_1.assert)(typeof this._timestamped_get_func !== "function", "UAVariable already bound");
|
|
820
|
+
bind_getter.call(this, options);
|
|
821
|
+
bind_setter.call(this, options);
|
|
822
|
+
const _historyRead = options.historyRead;
|
|
823
|
+
if (_historyRead) {
|
|
824
|
+
(0, node_opcua_assert_1.assert)(typeof this._historyRead !== "function" || this._historyRead === UAVariableImpl.prototype._historyRead);
|
|
825
|
+
(0, node_opcua_assert_1.assert)(typeof _historyRead === "function");
|
|
826
|
+
this._historyRead = _historyRead;
|
|
827
|
+
(0, node_opcua_assert_1.assert)(this._historyRead.length === 6);
|
|
828
|
+
}
|
|
829
|
+
(0, node_opcua_assert_1.assert)(typeof this._timestamped_set_func === "function");
|
|
830
|
+
(0, node_opcua_assert_1.assert)(this._timestamped_set_func.length === 3);
|
|
831
|
+
}
|
|
832
|
+
readValueAsync(context, callback) {
|
|
833
|
+
if (!context) {
|
|
834
|
+
context = session_context_1.SessionContext.defaultContext;
|
|
835
|
+
}
|
|
836
|
+
(0, node_opcua_assert_1.assert)(callback instanceof Function);
|
|
837
|
+
this.__waiting_callbacks = this.__waiting_callbacks || [];
|
|
838
|
+
this.__waiting_callbacks.push(callback);
|
|
839
|
+
const _readValueAsync_in_progress = this.__waiting_callbacks.length >= 2;
|
|
840
|
+
if (_readValueAsync_in_progress) {
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
const readImmediate = (innerCallback) => {
|
|
844
|
+
(0, node_opcua_assert_1.assert)(this._dataValue instanceof node_opcua_data_value_1.DataValue);
|
|
845
|
+
const dataValue = this.readValue();
|
|
846
|
+
innerCallback(null, dataValue);
|
|
847
|
+
};
|
|
848
|
+
let func;
|
|
849
|
+
if (!this.isReadable(context)) {
|
|
850
|
+
func = (innerCallback) => {
|
|
851
|
+
const dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadNotReadable });
|
|
852
|
+
innerCallback(null, dataValue);
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
else if (!this.isUserReadable(context)) {
|
|
856
|
+
func = (innerCallback) => {
|
|
857
|
+
const dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadUserAccessDenied });
|
|
858
|
+
innerCallback(null, dataValue);
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
func = typeof this.refreshFunc === "function" ? this.asyncRefresh.bind(this, new Date()) : readImmediate;
|
|
863
|
+
}
|
|
864
|
+
const satisfy_callbacks = (err, dataValue) => {
|
|
865
|
+
// now call all pending callbacks
|
|
866
|
+
const callbacks = this.__waiting_callbacks || [];
|
|
867
|
+
this.__waiting_callbacks = [];
|
|
868
|
+
const n = callbacks.length;
|
|
869
|
+
for (const callback1 of callbacks) {
|
|
870
|
+
callback1.call(this, err, dataValue);
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
try {
|
|
874
|
+
func.call(this, satisfy_callbacks);
|
|
875
|
+
}
|
|
876
|
+
catch (err) {
|
|
877
|
+
// istanbul ignore next
|
|
878
|
+
if (doDebug) {
|
|
879
|
+
debugLog(chalk.red("func readValueAsync has failed "));
|
|
880
|
+
if (err instanceof Error) {
|
|
881
|
+
debugLog(" stack", err.stack);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
satisfy_callbacks(err);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
getWriteMask() {
|
|
888
|
+
return super.getWriteMask();
|
|
889
|
+
}
|
|
890
|
+
getUserWriteMask() {
|
|
891
|
+
return super.getUserWriteMask();
|
|
892
|
+
}
|
|
893
|
+
clone(options, optionalFilter, extraInfo) {
|
|
894
|
+
options = Object.assign(Object.assign({}, options), {
|
|
895
|
+
// check this eventNotifier: this.eventNotifier,
|
|
896
|
+
// check this symbolicName: this.symbolicName,
|
|
897
|
+
accessLevel: this.accessLevel, arrayDimensions: this.arrayDimensions, dataType: this.dataType, historizing: this.historizing, minimumSamplingInterval: this.minimumSamplingInterval, userAccessLevel: this.userAccessLevel, valueRank: this.valueRank });
|
|
898
|
+
const newVariable = base_node_private_1._clone.call(this, UAVariableImpl, options, optionalFilter, extraInfo);
|
|
899
|
+
newVariable.bindVariable();
|
|
900
|
+
(0, node_opcua_assert_1.assert)(typeof newVariable._timestamped_set_func === "function");
|
|
901
|
+
(0, node_opcua_assert_1.assert)(newVariable.dataType === this.dataType);
|
|
902
|
+
newVariable._dataValue = this._dataValue.clone();
|
|
903
|
+
return newVariable;
|
|
904
|
+
}
|
|
905
|
+
getDataTypeNode() {
|
|
906
|
+
const addressSpace = this.addressSpace;
|
|
907
|
+
const dt = addressSpace.findNode(this.dataType);
|
|
908
|
+
// istanbul ignore next
|
|
909
|
+
if (!dt) {
|
|
910
|
+
throw new Error("cannot find dataType " + this.dataType.toString());
|
|
911
|
+
}
|
|
912
|
+
return dt;
|
|
913
|
+
}
|
|
914
|
+
get dataTypeObj() {
|
|
915
|
+
return this.getDataTypeNode();
|
|
916
|
+
}
|
|
917
|
+
checkExtensionObjectIsCorrect(extObj) {
|
|
918
|
+
if (!extObj) {
|
|
919
|
+
return true;
|
|
920
|
+
}
|
|
921
|
+
const addressSpace = this.addressSpace;
|
|
922
|
+
if (!(extObj && extObj.constructor)) {
|
|
923
|
+
console.log(extObj);
|
|
924
|
+
throw new Error("expecting an valid extension object");
|
|
925
|
+
}
|
|
926
|
+
const dataType = addressSpace.findDataType(this.dataType);
|
|
927
|
+
if (!dataType) {
|
|
928
|
+
// may be we are in the process of loading a xml file and the corresponding dataType
|
|
929
|
+
// has not yet been loaded !
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
932
|
+
try {
|
|
933
|
+
const Constructor = addressSpace.getExtensionObjectConstructor(this.dataType);
|
|
934
|
+
if (extObj instanceof Array) {
|
|
935
|
+
for (const e of extObj) {
|
|
936
|
+
if (!e) {
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
if (e.constructor.name !== Constructor.name) {
|
|
940
|
+
debugLog("extObj.constructor.name ", e.constructor.name, "expected", Constructor.name);
|
|
941
|
+
return false;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
return extObj.constructor.name === Constructor.name;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
catch (err) {
|
|
951
|
+
console.log(err);
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* @method bindExtensionObject
|
|
957
|
+
* @return {ExtensionObject}
|
|
958
|
+
*/
|
|
959
|
+
bindExtensionObject(optionalExtensionObject) {
|
|
960
|
+
var _a, _b, _c;
|
|
961
|
+
const addressSpace = this.addressSpace;
|
|
962
|
+
const structure = addressSpace.findDataType("Structure");
|
|
963
|
+
let extensionObject_;
|
|
964
|
+
if (!structure) {
|
|
965
|
+
// the addressSpace is limited and doesn't provide extension object
|
|
966
|
+
// bindExtensionObject cannot be performed and shall finish here.
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
// istanbul ignore next
|
|
970
|
+
if (doDebug) {
|
|
971
|
+
console.log(" ------------------------------ binding ", this.browseName.toString(), this.nodeId.toString());
|
|
972
|
+
}
|
|
973
|
+
(0, node_opcua_assert_1.assert)(structure && structure.browseName.toString() === "Structure", "expecting DataType Structure to be in IAddressSpace");
|
|
974
|
+
const dt = this.getDataTypeNode();
|
|
975
|
+
if (!dt.isSupertypeOf(structure)) {
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
// the namespace for the structure browse name elements
|
|
979
|
+
const structureNamespace = dt.nodeId.namespace;
|
|
980
|
+
// -------------------- make sure we do not bind a variable twice ....
|
|
981
|
+
if (this.$extensionObject) {
|
|
982
|
+
// istanbul ignore next
|
|
983
|
+
// if (!force && !utils.isNullOrUndefined(optionalExtensionObject)) {
|
|
984
|
+
// throw new Error(
|
|
985
|
+
// "bindExtensionObject: unsupported case : $extensionObject already exists on " +
|
|
986
|
+
// this.browseName.toString() +
|
|
987
|
+
// " " +
|
|
988
|
+
// this.nodeId.toString()
|
|
989
|
+
// );
|
|
990
|
+
// }
|
|
991
|
+
// istanbul ignore next
|
|
992
|
+
if (!this.checkExtensionObjectIsCorrect(this.$extensionObject)) {
|
|
993
|
+
console.log("on node : ", this.browseName.toString(), this.nodeId.toString(), "dataType=", this.dataType.toString({ addressSpace: this.addressSpace }));
|
|
994
|
+
console.log((_a = this.$extensionObject) === null || _a === void 0 ? void 0 : _a.toString());
|
|
995
|
+
throw new Error("bindExtensionObject: $extensionObject is incorrect: we are expecting a " +
|
|
996
|
+
this.dataType.toString({ addressSpace: this.addressSpace }) +
|
|
997
|
+
" but we got a " +
|
|
998
|
+
((_b = this.$extensionObject) === null || _b === void 0 ? void 0 : _b.constructor.name));
|
|
999
|
+
}
|
|
1000
|
+
return this.$extensionObject;
|
|
1001
|
+
// throw new Error("Variable already bound");
|
|
1002
|
+
}
|
|
1003
|
+
this.$extensionObject = optionalExtensionObject;
|
|
1004
|
+
// ------------------------------------------------------------------
|
|
1005
|
+
function prepareVariantValue(dataType, value) {
|
|
1006
|
+
if (typeof dataType === "string") {
|
|
1007
|
+
dataType = node_opcua_variant_1.DataType[dataType];
|
|
1008
|
+
}
|
|
1009
|
+
if ((dataType === node_opcua_variant_1.DataType.Int32 || dataType === node_opcua_variant_1.DataType.UInt32) && value && value.key) {
|
|
1010
|
+
value = value.value;
|
|
1011
|
+
}
|
|
1012
|
+
return value;
|
|
1013
|
+
}
|
|
1014
|
+
const bindProperty = (propertyNode, name, extensionObject, dataTypeNodeId) => {
|
|
1015
|
+
const dataTypeAsString = node_opcua_variant_1.DataType[dataTypeNodeId];
|
|
1016
|
+
/*
|
|
1017
|
+
property.setValueFromSource(new Variant({
|
|
1018
|
+
dataType: dataType,
|
|
1019
|
+
value: prepareVariantValue(dataType, this.$extensionObject[name])
|
|
1020
|
+
}));
|
|
1021
|
+
*/
|
|
1022
|
+
(0, node_opcua_assert_1.assert)(propertyNode.readValue().statusCode.equals(node_opcua_status_code_1.StatusCodes.Good));
|
|
1023
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1024
|
+
const self = this;
|
|
1025
|
+
propertyNode.bindVariable({
|
|
1026
|
+
timestamped_get: () => {
|
|
1027
|
+
const prop = self.$extensionObject[name];
|
|
1028
|
+
if (prop === undefined) {
|
|
1029
|
+
propertyNode._dataValue.value.dataType = node_opcua_variant_1.DataType.Null;
|
|
1030
|
+
propertyNode._dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
1031
|
+
propertyNode._dataValue.value.value = null;
|
|
1032
|
+
return new node_opcua_data_value_1.DataValue(propertyNode._dataValue);
|
|
1033
|
+
}
|
|
1034
|
+
const value = prepareVariantValue(dataTypeNodeId, prop);
|
|
1035
|
+
propertyNode._dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
1036
|
+
propertyNode._dataValue.value.value = value;
|
|
1037
|
+
return new node_opcua_data_value_1.DataValue(propertyNode._dataValue);
|
|
1038
|
+
},
|
|
1039
|
+
timestamped_set: (dataValue, callback) => {
|
|
1040
|
+
dataValue;
|
|
1041
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadNotWritable);
|
|
1042
|
+
}
|
|
1043
|
+
}, true);
|
|
1044
|
+
};
|
|
1045
|
+
const components = this.getComponents();
|
|
1046
|
+
// ------------------------------------------------------
|
|
1047
|
+
// make sure we have a structure
|
|
1048
|
+
// ------------------------------------------------------
|
|
1049
|
+
const s = this.readValue();
|
|
1050
|
+
// istanbul ignore next
|
|
1051
|
+
if (this.dataTypeObj.isAbstract) {
|
|
1052
|
+
console.log("Warning the DataType associated with this Variable is abstract ", this.dataTypeObj.browseName.toString());
|
|
1053
|
+
console.log("You need to provide a extension object yourself ");
|
|
1054
|
+
throw new Error("bindExtensionObject requires a extensionObject as associated dataType is only abstract");
|
|
1055
|
+
}
|
|
1056
|
+
if (s.value && (s.value.dataType === node_opcua_variant_1.DataType.Null || (s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject && !s.value.value))) {
|
|
1057
|
+
// create a structure and bind it
|
|
1058
|
+
extensionObject_ = this.$extensionObject || addressSpace.constructExtensionObject(this.dataType, {});
|
|
1059
|
+
extensionObject_ = new Proxy(extensionObject_, makeHandler(this));
|
|
1060
|
+
this.$extensionObject = extensionObject_;
|
|
1061
|
+
const theValue = new node_opcua_variant_1.Variant({
|
|
1062
|
+
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
1063
|
+
value: this.$extensionObject
|
|
1064
|
+
});
|
|
1065
|
+
this.setValueFromSource(theValue, node_opcua_status_code_1.StatusCodes.Good);
|
|
1066
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1067
|
+
const self = this;
|
|
1068
|
+
this.bindVariable({
|
|
1069
|
+
timestamped_get() {
|
|
1070
|
+
self._dataValue.value.value = self.$extensionObject;
|
|
1071
|
+
const d = new node_opcua_data_value_1.DataValue(self._dataValue);
|
|
1072
|
+
d.value = new node_opcua_variant_1.Variant(d.value);
|
|
1073
|
+
return d;
|
|
1074
|
+
},
|
|
1075
|
+
timestamped_set(dataValue, callback) {
|
|
1076
|
+
const ext = dataValue.value.value;
|
|
1077
|
+
if (!self.checkExtensionObjectIsCorrect(ext)) {
|
|
1078
|
+
return callback(null, node_opcua_status_code_1.StatusCodes.BadInvalidArgument);
|
|
1079
|
+
}
|
|
1080
|
+
self.$extensionObject = new Proxy(ext, makeHandler(self));
|
|
1081
|
+
self.touchValue();
|
|
1082
|
+
callback(null, node_opcua_status_code_1.StatusCodes.Good);
|
|
1083
|
+
}
|
|
1084
|
+
}, true);
|
|
1085
|
+
}
|
|
1086
|
+
else {
|
|
1087
|
+
// verify that variant has the correct type
|
|
1088
|
+
(0, node_opcua_assert_1.assert)(s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject);
|
|
1089
|
+
this.$extensionObject = s.value.value;
|
|
1090
|
+
(0, node_opcua_assert_1.assert)(this.checkExtensionObjectIsCorrect(this.$extensionObject));
|
|
1091
|
+
(0, node_opcua_assert_1.assert)(s.statusCode.equals(node_opcua_status_code_1.StatusCodes.Good));
|
|
1092
|
+
}
|
|
1093
|
+
let property;
|
|
1094
|
+
let camelCaseName;
|
|
1095
|
+
// ------------------------------------------------------
|
|
1096
|
+
// now bind each member
|
|
1097
|
+
// ------------------------------------------------------
|
|
1098
|
+
const definition = dt._getDefinition(false);
|
|
1099
|
+
// istanbul ignore next
|
|
1100
|
+
if (!definition) {
|
|
1101
|
+
throw new Error("xx definition missing in " + dt.toString());
|
|
1102
|
+
}
|
|
1103
|
+
for (const field of definition.fields || []) {
|
|
1104
|
+
camelCaseName = (0, node_opcua_utils_1.lowerFirstLetter)(field.name);
|
|
1105
|
+
const component = components.filter((f) => f.browseName.name.toString() === field.name);
|
|
1106
|
+
if (component.length === 1) {
|
|
1107
|
+
property = component[0];
|
|
1108
|
+
/* istanbul ignore next */
|
|
1109
|
+
}
|
|
1110
|
+
else {
|
|
1111
|
+
// todo: Handle array appropriately...
|
|
1112
|
+
(0, node_opcua_assert_1.assert)(component.length === 0);
|
|
1113
|
+
// create a variable (Note we may use ns=1;s=parentName/0:PropertyName)
|
|
1114
|
+
property = this.namespace.addVariable({
|
|
1115
|
+
browseName: { namespaceIndex: structureNamespace, name: field.name.toString() },
|
|
1116
|
+
componentOf: this,
|
|
1117
|
+
dataType: field.dataType,
|
|
1118
|
+
minimumSamplingInterval: this.minimumSamplingInterval
|
|
1119
|
+
});
|
|
1120
|
+
(0, node_opcua_assert_1.assert)(property.minimumSamplingInterval === this.minimumSamplingInterval);
|
|
1121
|
+
}
|
|
1122
|
+
property._dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
1123
|
+
property.touchValue();
|
|
1124
|
+
if (node_opcua_nodeid_1.NodeId.sameNodeId(node_opcua_nodeid_1.NodeId.nullNodeId, field.dataType)) {
|
|
1125
|
+
debugLog("field.dataType is null ! " + field.name + " " + ((_c = field.description) === null || _c === void 0 ? void 0 : _c.text));
|
|
1126
|
+
debugLog(" dataType replaced with BaseDataType ");
|
|
1127
|
+
field.dataType = this.resolveNodeId("BaseDataType");
|
|
1128
|
+
}
|
|
1129
|
+
const dataTypeNodeId = addressSpace.findCorrespondingBasicDataType(field.dataType);
|
|
1130
|
+
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this.$extensionObject, camelCaseName));
|
|
1131
|
+
// istanbul ignore next
|
|
1132
|
+
if (doDebug) {
|
|
1133
|
+
const x = addressSpace.findNode(field.dataType).browseName.toString();
|
|
1134
|
+
const basicType = addressSpace.findCorrespondingBasicDataType(field.dataType);
|
|
1135
|
+
debugLog(chalk.cyan("xxx"), " dataType", w(field.dataType.toString(), 8), w(field.name, 35), "valueRank", chalk.cyan(w((0, base_node_private_1.valueRankToString)(field.valueRank), 10)), chalk.green(w(x, 25)), "basicType = ", chalk.yellow(w(basicType.toString(), 20)), property.nodeId.toString(), property.readValue().statusCode.toString());
|
|
1136
|
+
}
|
|
1137
|
+
if (this.$extensionObject[camelCaseName] !== undefined && dataTypeNodeId === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
1138
|
+
(0, node_opcua_assert_1.assert)(this.$extensionObject[camelCaseName] instanceof Object);
|
|
1139
|
+
this.$extensionObject[camelCaseName] = new Proxy(this.$extensionObject[camelCaseName], makeHandler(property));
|
|
1140
|
+
property._dataValue.value = new node_opcua_variant_1.Variant({
|
|
1141
|
+
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
1142
|
+
value: this.$extensionObject[camelCaseName]
|
|
1143
|
+
});
|
|
1144
|
+
property.bindExtensionObject();
|
|
1145
|
+
property.$extensionObject = this.$extensionObject[camelCaseName];
|
|
1146
|
+
}
|
|
1147
|
+
else {
|
|
1148
|
+
const dataTypeAsString = node_opcua_variant_1.DataType[dataTypeNodeId];
|
|
1149
|
+
(0, node_opcua_assert_1.assert)(typeof dataTypeAsString === "string");
|
|
1150
|
+
const prop = this.$extensionObject[camelCaseName];
|
|
1151
|
+
if (prop === undefined) {
|
|
1152
|
+
property._dataValue.value = new node_opcua_variant_1.Variant({
|
|
1153
|
+
dataType: node_opcua_variant_1.DataType.Null
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
else {
|
|
1157
|
+
const preparedValue = prepareVariantValue(dataTypeNodeId, prop);
|
|
1158
|
+
property._dataValue.value = new node_opcua_variant_1.Variant({
|
|
1159
|
+
dataType: dataTypeAsString,
|
|
1160
|
+
value: preparedValue
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1164
|
+
const self = this;
|
|
1165
|
+
property.camelCaseName = camelCaseName;
|
|
1166
|
+
property.setValueFromSource = function (variant) {
|
|
1167
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1168
|
+
const inner_this = this;
|
|
1169
|
+
variant = node_opcua_variant_1.Variant.coerce(variant);
|
|
1170
|
+
// xx console.log("PropertySetValueFromSource this", inner_this.nodeId.toString(), inner_this.browseName.toString(), variant.toString(), inner_this.dataType.toString());
|
|
1171
|
+
// xx assert(variant.dataType === this.dataType);
|
|
1172
|
+
self.$extensionObject[inner_this.camelCaseName] = variant.value;
|
|
1173
|
+
self.touchValue();
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
(0, node_opcua_assert_1.assert)(property.readValue().statusCode.equals(node_opcua_status_code_1.StatusCodes.Good));
|
|
1177
|
+
bindProperty(property, camelCaseName, this.$extensionObject, dataTypeNodeId);
|
|
1178
|
+
}
|
|
1179
|
+
(0, node_opcua_assert_1.assert)(this.$extensionObject instanceof Object);
|
|
1180
|
+
return this.$extensionObject;
|
|
1181
|
+
}
|
|
1182
|
+
updateExtensionObjectPartial(partialExtensionObject) {
|
|
1183
|
+
setExtensionObjectValue(this, partialExtensionObject);
|
|
1184
|
+
return this.$extensionObject;
|
|
1185
|
+
}
|
|
1186
|
+
incrementExtensionObjectPartial(path) {
|
|
1187
|
+
let name;
|
|
1188
|
+
if (typeof path === "string") {
|
|
1189
|
+
path = path.split(".");
|
|
1190
|
+
}
|
|
1191
|
+
(0, node_opcua_assert_1.assert)(path instanceof Array);
|
|
1192
|
+
const extensionObject = this.constructExtensionObjectFromComponents();
|
|
1193
|
+
let i;
|
|
1194
|
+
// read partial value
|
|
1195
|
+
const partialData = {};
|
|
1196
|
+
let p = partialData;
|
|
1197
|
+
for (i = 0; i < path.length - 1; i++) {
|
|
1198
|
+
name = path[i];
|
|
1199
|
+
p[name] = {};
|
|
1200
|
+
p = p[name];
|
|
1201
|
+
}
|
|
1202
|
+
name = path[path.length - 1];
|
|
1203
|
+
p[name] = 0;
|
|
1204
|
+
let c1 = partialData;
|
|
1205
|
+
let c2 = extensionObject;
|
|
1206
|
+
for (i = 0; i < path.length - 1; i++) {
|
|
1207
|
+
name = path[i];
|
|
1208
|
+
c1 = partialData[name];
|
|
1209
|
+
c2 = extensionObject[name];
|
|
1210
|
+
}
|
|
1211
|
+
name = path[path.length - 1];
|
|
1212
|
+
c1[name] = c2[name];
|
|
1213
|
+
c1[name] += 1;
|
|
1214
|
+
// xx console.log(partialData);
|
|
1215
|
+
setExtensionObjectValue(this, partialData);
|
|
1216
|
+
}
|
|
1217
|
+
constructExtensionObjectFromComponents() {
|
|
1218
|
+
return this.readValue().value.value;
|
|
1219
|
+
}
|
|
1220
|
+
toString() {
|
|
1221
|
+
const options = new base_node_private_1.ToStringBuilder();
|
|
1222
|
+
base_node_private_1.UAVariable_toString.call(this, options);
|
|
1223
|
+
return options.toString();
|
|
1224
|
+
}
|
|
1225
|
+
historyRead(context, historyReadDetails, indexRange, dataEncoding, continuationPoint, callback) {
|
|
1226
|
+
if (!callback) {
|
|
1227
|
+
callback = continuationPoint;
|
|
1228
|
+
continuationPoint = undefined;
|
|
1229
|
+
}
|
|
1230
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
1231
|
+
(0, node_opcua_assert_1.assert)(callback instanceof Function);
|
|
1232
|
+
if (typeof this._historyRead !== "function") {
|
|
1233
|
+
return callback(null, new node_opcua_types_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadNotReadable }));
|
|
1234
|
+
}
|
|
1235
|
+
this._historyRead(context, historyReadDetails, indexRange, dataEncoding, continuationPoint || null, callback);
|
|
1236
|
+
}
|
|
1237
|
+
_historyReadRaw(context, historyReadRawModifiedDetails, indexRange, dataEncoding, continuationPoint, callback) {
|
|
1238
|
+
throw new Error("");
|
|
1239
|
+
}
|
|
1240
|
+
_historyReadRawModify(context, historyReadRawModifiedDetails, indexRange, dataEncoding, continuationPoint, callback) {
|
|
1241
|
+
throw new Error("");
|
|
1242
|
+
}
|
|
1243
|
+
_historyRead(context, historyReadDetails, indexRange, dataEncoding, continuationPoint, callback) {
|
|
1244
|
+
const result = new node_opcua_types_1.HistoryReadResult({
|
|
1245
|
+
statusCode: node_opcua_status_code_1.StatusCodes.BadHistoryOperationUnsupported
|
|
1246
|
+
});
|
|
1247
|
+
callback(null, result);
|
|
1248
|
+
}
|
|
1249
|
+
_historyPush(newDataValue) {
|
|
1250
|
+
throw new Error("");
|
|
1251
|
+
}
|
|
1252
|
+
_historyReadRawAsync(historyReadRawModifiedDetails, maxNumberToExtract, isReversed, reverseDataValue, callback) {
|
|
1253
|
+
throw new Error("");
|
|
1254
|
+
}
|
|
1255
|
+
_historyReadModify(context, historyReadRawModifiedDetails, indexRange, dataEncoding, continuationPoint, callback) {
|
|
1256
|
+
throw new Error("");
|
|
1257
|
+
}
|
|
1258
|
+
_update_startOfOnlineArchive(newDate) {
|
|
1259
|
+
// please install
|
|
1260
|
+
throw new Error("");
|
|
1261
|
+
}
|
|
1262
|
+
_update_startOfArchive(newDate) {
|
|
1263
|
+
throw new Error("");
|
|
1264
|
+
}
|
|
1265
|
+
_validate_DataType(variantDataType) {
|
|
1266
|
+
return validateDataType(this.addressSpace, this.dataType, variantDataType, this.nodeId, /* allow Nulls */ false);
|
|
1267
|
+
}
|
|
1268
|
+
_internal_set_dataValue(dataValue, indexRange) {
|
|
1269
|
+
(0, node_opcua_assert_1.assert)(dataValue, "expecting a dataValue");
|
|
1270
|
+
(0, node_opcua_assert_1.assert)(dataValue instanceof node_opcua_data_value_1.DataValue, "expecting dataValue to be a DataValue");
|
|
1271
|
+
(0, node_opcua_assert_1.assert)(dataValue !== this._dataValue, "expecting dataValue to be different from previous DataValue instance");
|
|
1272
|
+
if (dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
1273
|
+
if (!dataValue.value.dimensions) {
|
|
1274
|
+
throw new Error("missing dimensions: a Matrix Variant needs a dimension");
|
|
1275
|
+
}
|
|
1276
|
+
const nbElements = dataValue.value.dimensions.reduce((acc, x) => acc * x, 1);
|
|
1277
|
+
if (dataValue.value.value.length !== 0 && dataValue.value.value.length !== nbElements) {
|
|
1278
|
+
throw new Error(`Internal Error: matrix dimension doesn't match the number of element in the array : ${dataValue.toString()} "\n expecting ${nbElements} elements but got ${dataValue.value.value.length}`);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
if (dataValue.value.dataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
1282
|
+
if (!this.checkExtensionObjectIsCorrect(dataValue.value.value)) {
|
|
1283
|
+
warningLog(dataValue.toString());
|
|
1284
|
+
throw new Error("Invalid Extension Object on nodeId =" + this.nodeId.toString());
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
// istanbul ignore next
|
|
1288
|
+
if (this.dataType.namespace === 0) {
|
|
1289
|
+
if (this.dataType.value === node_opcua_variant_1.DataType.LocalizedText && dataValue.value.dataType !== node_opcua_variant_1.DataType.LocalizedText) {
|
|
1290
|
+
throw new Error("Invalid dataValue provided (expecting a LocalizedText) but got " + dataValue.toString());
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
const old_dataValue = this._dataValue;
|
|
1294
|
+
this._dataValue = dataValue;
|
|
1295
|
+
this._dataValue.statusCode = this._dataValue.statusCode || node_opcua_status_code_1.StatusCodes.Good;
|
|
1296
|
+
// repair missing timestamps
|
|
1297
|
+
if (!dataValue.serverTimestamp) {
|
|
1298
|
+
this._dataValue.serverTimestamp = old_dataValue.serverTimestamp;
|
|
1299
|
+
this._dataValue.serverPicoseconds = old_dataValue.serverPicoseconds;
|
|
1300
|
+
}
|
|
1301
|
+
if (!dataValue.sourceTimestamp) {
|
|
1302
|
+
this._dataValue.sourceTimestamp = old_dataValue.sourceTimestamp;
|
|
1303
|
+
this._dataValue.sourcePicoseconds = old_dataValue.sourcePicoseconds;
|
|
1304
|
+
}
|
|
1305
|
+
if (!(0, node_opcua_data_value_1.sameDataValue)(old_dataValue, dataValue)) {
|
|
1306
|
+
this.emit("value_changed", this._dataValue, indexRange);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
_conditionRefresh(_cache) {
|
|
1310
|
+
apply_condition_refresh_1.apply_condition_refresh.call(this, _cache);
|
|
1311
|
+
}
|
|
1312
|
+
handle_semantic_changed() {
|
|
1313
|
+
this.semantic_version = this.semantic_version + 1;
|
|
1314
|
+
this.emit("semantic_changed");
|
|
1315
|
+
}
|
|
1316
|
+
_readDataType() {
|
|
1317
|
+
(0, node_opcua_assert_1.assert)(this.dataType instanceof node_opcua_nodeid_1.NodeId);
|
|
1318
|
+
const options = {
|
|
1319
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Good,
|
|
1320
|
+
value: {
|
|
1321
|
+
dataType: node_opcua_variant_1.DataType.NodeId,
|
|
1322
|
+
value: this.dataType
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1326
|
+
}
|
|
1327
|
+
_readValueRank() {
|
|
1328
|
+
(0, node_opcua_assert_1.assert)(typeof this.valueRank === "number");
|
|
1329
|
+
const options = {
|
|
1330
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Good,
|
|
1331
|
+
value: { dataType: node_opcua_variant_1.DataType.Int32, value: this.valueRank }
|
|
1332
|
+
};
|
|
1333
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1334
|
+
}
|
|
1335
|
+
_readArrayDimensions() {
|
|
1336
|
+
(0, node_opcua_assert_1.assert)(Array.isArray(this.arrayDimensions) || this.arrayDimensions === null);
|
|
1337
|
+
(0, node_opcua_assert_1.assert)(!this.arrayDimensions || this.valueRank > 0, "arrayDimension must be null if valueRank <0");
|
|
1338
|
+
const options = {
|
|
1339
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Good,
|
|
1340
|
+
value: { dataType: node_opcua_variant_1.DataType.UInt32, arrayType: node_opcua_variant_1.VariantArrayType.Array, value: this.arrayDimensions }
|
|
1341
|
+
};
|
|
1342
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1343
|
+
}
|
|
1344
|
+
_readAccessLevel(context) {
|
|
1345
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
1346
|
+
const options = {
|
|
1347
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Good,
|
|
1348
|
+
value: { dataType: node_opcua_variant_1.DataType.Byte, value: (0, node_opcua_data_model_1.convertAccessLevelFlagToByte)(this.accessLevel) }
|
|
1349
|
+
};
|
|
1350
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1351
|
+
}
|
|
1352
|
+
_readAccessLevelEx(context) {
|
|
1353
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
1354
|
+
const options = {
|
|
1355
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Good,
|
|
1356
|
+
// Extra flags are not supported yet. to do:
|
|
1357
|
+
value: { dataType: node_opcua_variant_1.DataType.UInt32, value: (0, node_opcua_data_model_1.convertAccessLevelFlagToByte)(this.accessLevel) }
|
|
1358
|
+
};
|
|
1359
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1360
|
+
}
|
|
1361
|
+
_readUserAccessLevel(context) {
|
|
1362
|
+
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
1363
|
+
const effectiveUserAccessLevel = _calculateEffectiveUserAccessLevelFromPermission(this, context, this.userAccessLevel);
|
|
1364
|
+
const options = {
|
|
1365
|
+
value: {
|
|
1366
|
+
dataType: node_opcua_variant_1.DataType.Byte,
|
|
1367
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Good,
|
|
1368
|
+
value: (0, node_opcua_data_model_1.convertAccessLevelFlagToByte)(effectiveUserAccessLevel)
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1372
|
+
}
|
|
1373
|
+
_readMinimumSamplingInterval() {
|
|
1374
|
+
// expect a Duration => Double
|
|
1375
|
+
const options = {};
|
|
1376
|
+
if (this.minimumSamplingInterval === undefined) {
|
|
1377
|
+
options.statusCode = node_opcua_status_code_1.StatusCodes.BadAttributeIdInvalid;
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
options.value = { dataType: node_opcua_variant_1.DataType.Double, value: this.minimumSamplingInterval };
|
|
1381
|
+
options.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
1382
|
+
}
|
|
1383
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1384
|
+
}
|
|
1385
|
+
_readHistorizing() {
|
|
1386
|
+
(0, node_opcua_assert_1.assert)(typeof this.historizing === "boolean");
|
|
1387
|
+
const options = {
|
|
1388
|
+
statusCode: node_opcua_status_code_1.StatusCodes.Good,
|
|
1389
|
+
value: { dataType: node_opcua_variant_1.DataType.Boolean, value: !!this.historizing }
|
|
1390
|
+
};
|
|
1391
|
+
return new node_opcua_data_value_1.DataValue(options);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
exports.UAVariableImpl = UAVariableImpl;
|
|
1395
|
+
// tslint:disable:no-var-requires
|
|
1396
|
+
const thenify = require("thenify");
|
|
1397
|
+
UAVariableImpl.prototype.asyncRefresh = thenify.withCallback(UAVariableImpl.prototype.asyncRefresh);
|
|
1398
|
+
UAVariableImpl.prototype.writeValue = thenify.withCallback(UAVariableImpl.prototype.writeValue);
|
|
1399
|
+
UAVariableImpl.prototype.writeAttribute = thenify.withCallback(UAVariableImpl.prototype.writeAttribute);
|
|
1400
|
+
UAVariableImpl.prototype.historyRead = thenify.withCallback(UAVariableImpl.prototype.historyRead);
|
|
1401
|
+
UAVariableImpl.prototype.readValueAsync = thenify.withCallback(UAVariableImpl.prototype.readValueAsync);
|
|
1402
|
+
function check_valid_array(dataType, array) {
|
|
1403
|
+
if (Array.isArray(array)) {
|
|
1404
|
+
return true;
|
|
1405
|
+
}
|
|
1406
|
+
switch (dataType) {
|
|
1407
|
+
case node_opcua_variant_1.DataType.Double:
|
|
1408
|
+
return array instanceof Float64Array;
|
|
1409
|
+
case node_opcua_variant_1.DataType.Float:
|
|
1410
|
+
return array instanceof Float32Array;
|
|
1411
|
+
case node_opcua_variant_1.DataType.Int32:
|
|
1412
|
+
return array instanceof Int32Array;
|
|
1413
|
+
case node_opcua_variant_1.DataType.Int16:
|
|
1414
|
+
return array instanceof Int16Array;
|
|
1415
|
+
case node_opcua_variant_1.DataType.SByte:
|
|
1416
|
+
return array instanceof Int8Array;
|
|
1417
|
+
case node_opcua_variant_1.DataType.UInt32:
|
|
1418
|
+
return array instanceof Uint32Array;
|
|
1419
|
+
case node_opcua_variant_1.DataType.UInt16:
|
|
1420
|
+
return array instanceof Uint16Array;
|
|
1421
|
+
case node_opcua_variant_1.DataType.Byte:
|
|
1422
|
+
return array instanceof Uint8Array || array instanceof Buffer;
|
|
1423
|
+
}
|
|
1424
|
+
return false;
|
|
1425
|
+
}
|
|
1426
|
+
function _apply_default_timestamps(dataValue) {
|
|
1427
|
+
const now = (0, node_opcua_date_time_1.getCurrentClock)();
|
|
1428
|
+
(0, node_opcua_assert_1.assert)(dataValue instanceof node_opcua_data_value_1.DataValue);
|
|
1429
|
+
if (!dataValue.sourceTimestamp) {
|
|
1430
|
+
dataValue.sourceTimestamp = now.timestamp;
|
|
1431
|
+
dataValue.sourcePicoseconds = now.picoseconds;
|
|
1432
|
+
}
|
|
1433
|
+
if (!dataValue.serverTimestamp) {
|
|
1434
|
+
dataValue.serverTimestamp = now.timestamp;
|
|
1435
|
+
dataValue.serverPicoseconds = now.picoseconds;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
function unsetFlag(flags, mask) {
|
|
1439
|
+
return flags & ~mask;
|
|
1440
|
+
}
|
|
1441
|
+
function setFlag(flags, mask) {
|
|
1442
|
+
return flags | mask;
|
|
1443
|
+
}
|
|
1444
|
+
function _calculateEffectiveUserAccessLevelFromPermission(node, context, userAccessLevel) {
|
|
1445
|
+
function __adjustFlag(permissionType, access, userAccessLevel1) {
|
|
1446
|
+
if ((node.accessLevel & access) === 0 || (userAccessLevel1 & access) === 0) {
|
|
1447
|
+
userAccessLevel1 = unsetFlag(userAccessLevel1, access);
|
|
1448
|
+
}
|
|
1449
|
+
else {
|
|
1450
|
+
if (!context.checkPermission(node, permissionType)) {
|
|
1451
|
+
userAccessLevel1 = unsetFlag(userAccessLevel1, access);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
return userAccessLevel1;
|
|
1455
|
+
}
|
|
1456
|
+
userAccessLevel = node.userAccessLevel === undefined ? node.accessLevel : node.userAccessLevel & node.accessLevel;
|
|
1457
|
+
if (context.checkPermission) {
|
|
1458
|
+
(0, node_opcua_assert_1.assert)(context.checkPermission instanceof Function);
|
|
1459
|
+
userAccessLevel = __adjustFlag(node_opcua_types_1.PermissionType.Read, node_opcua_data_model_1.AccessLevelFlag.CurrentRead, userAccessLevel);
|
|
1460
|
+
userAccessLevel = __adjustFlag(node_opcua_types_1.PermissionType.Write, node_opcua_data_model_1.AccessLevelFlag.CurrentWrite, userAccessLevel);
|
|
1461
|
+
userAccessLevel = __adjustFlag(node_opcua_types_1.PermissionType.Write, node_opcua_data_model_1.AccessLevelFlag.StatusWrite, userAccessLevel);
|
|
1462
|
+
userAccessLevel = __adjustFlag(node_opcua_types_1.PermissionType.Write, node_opcua_data_model_1.AccessLevelFlag.TimestampWrite, userAccessLevel);
|
|
1463
|
+
userAccessLevel = __adjustFlag(node_opcua_types_1.PermissionType.ReadHistory, node_opcua_data_model_1.AccessLevelFlag.HistoryRead, userAccessLevel);
|
|
1464
|
+
userAccessLevel = __adjustFlag(node_opcua_types_1.PermissionType.DeleteHistory, node_opcua_data_model_1.AccessLevelFlag.HistoryWrite, userAccessLevel);
|
|
1465
|
+
return userAccessLevel;
|
|
1466
|
+
}
|
|
1467
|
+
else {
|
|
1468
|
+
return userAccessLevel;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
function adjustVariant2(variant) {
|
|
1472
|
+
// convert Variant( Scalar|ByteString) => Variant(Array|ByteArray)
|
|
1473
|
+
const addressSpace = this.addressSpace;
|
|
1474
|
+
const basicType = addressSpace.findCorrespondingBasicDataType(this.dataType);
|
|
1475
|
+
variant = (0, node_opcua_variant_1.adjustVariant)(variant, this.valueRank, basicType);
|
|
1476
|
+
return variant;
|
|
1477
|
+
}
|
|
1478
|
+
function _not_writable_timestamped_set_func(dataValue, callback) {
|
|
1479
|
+
(0, node_opcua_assert_1.assert)(dataValue instanceof node_opcua_data_value_1.DataValue);
|
|
1480
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadNotWritable, null);
|
|
1481
|
+
}
|
|
1482
|
+
function _default_writable_timestamped_set_func(dataValue, callback) {
|
|
1483
|
+
/* jshint validthis: true */
|
|
1484
|
+
(0, node_opcua_assert_1.assert)(dataValue instanceof node_opcua_data_value_1.DataValue);
|
|
1485
|
+
callback(null, node_opcua_status_code_1.StatusCodes.Good, dataValue);
|
|
1486
|
+
}
|
|
1487
|
+
function turn_sync_to_async(f, numberOfArgs) {
|
|
1488
|
+
if (f.length <= numberOfArgs) {
|
|
1489
|
+
return function (data, callback) {
|
|
1490
|
+
const r = f.call(this, data);
|
|
1491
|
+
setImmediate(() => {
|
|
1492
|
+
return callback(null, r);
|
|
1493
|
+
});
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
else {
|
|
1497
|
+
(0, node_opcua_assert_1.assert)(f.length === numberOfArgs + 1);
|
|
1498
|
+
return f;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
const _default_minimumSamplingInterval = 1000;
|
|
1502
|
+
function coerceDataValue(dataValue) {
|
|
1503
|
+
if (dataValue instanceof node_opcua_data_value_1.DataValue) {
|
|
1504
|
+
return dataValue;
|
|
1505
|
+
}
|
|
1506
|
+
return new node_opcua_data_value_1.DataValue(dataValue);
|
|
1507
|
+
}
|
|
1508
|
+
// variation #3 :
|
|
1509
|
+
function _Variable_bind_with_async_refresh(options) {
|
|
1510
|
+
/* jshint validthis: true */
|
|
1511
|
+
(0, node_opcua_assert_1.assert)(this instanceof UAVariableImpl);
|
|
1512
|
+
(0, node_opcua_assert_1.assert)(typeof options.refreshFunc === "function");
|
|
1513
|
+
(0, node_opcua_assert_1.assert)(!options.get, "a getter shall not be specified when refreshFunc is set");
|
|
1514
|
+
(0, node_opcua_assert_1.assert)(!options.timestamped_get, "a getter shall not be specified when refreshFunc is set");
|
|
1515
|
+
(0, node_opcua_assert_1.assert)(!this.refreshFunc);
|
|
1516
|
+
this.refreshFunc = options.refreshFunc;
|
|
1517
|
+
// assert(this.readValue().statusCode === StatusCodes.BadNodeIdUnknown);
|
|
1518
|
+
this._dataValue.statusCode = node_opcua_status_code_1.StatusCodes.UncertainInitialValue;
|
|
1519
|
+
// TO DO : REVISIT THIS ASSUMPTION
|
|
1520
|
+
if (false && this.minimumSamplingInterval === 0) {
|
|
1521
|
+
// when a getter /timestamped_getter or async_getter is provided
|
|
1522
|
+
// samplingInterval cannot be 0, as the item value must be scanned to be updated.
|
|
1523
|
+
this.minimumSamplingInterval = _default_minimumSamplingInterval; // MonitoredItem.minimumSamplingInterval;
|
|
1524
|
+
debugLog("adapting minimumSamplingInterval on " + this.browseName.toString() + " to " + this.minimumSamplingInterval);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
// variation 2
|
|
1528
|
+
function _Variable_bind_with_timestamped_get(options) {
|
|
1529
|
+
/* jshint validthis: true */
|
|
1530
|
+
(0, node_opcua_assert_1.assert)(this instanceof UAVariableImpl);
|
|
1531
|
+
(0, node_opcua_assert_1.assert)(typeof options.timestamped_get === "function");
|
|
1532
|
+
(0, node_opcua_assert_1.assert)(!options.get, "should not specify 'get' when 'timestamped_get' exists ");
|
|
1533
|
+
(0, node_opcua_assert_1.assert)(!this._timestamped_get_func);
|
|
1534
|
+
const async_refresh_func = (callback) => {
|
|
1535
|
+
Promise.resolve(this._timestamped_get_func.call(this))
|
|
1536
|
+
.then((dataValue) => callback(null, dataValue))
|
|
1537
|
+
.catch((err) => callback(err));
|
|
1538
|
+
};
|
|
1539
|
+
if (options.timestamped_get.length === 0) {
|
|
1540
|
+
const timestamped_get = options.timestamped_get;
|
|
1541
|
+
// sync version | Promise version
|
|
1542
|
+
this._timestamped_get_func = timestamped_get;
|
|
1543
|
+
const dataValue_verify = timestamped_get.call(this);
|
|
1544
|
+
// dataValue_verify should be a DataValue or a Promise
|
|
1545
|
+
/* istanbul ignore next */
|
|
1546
|
+
if (!(dataValue_verify instanceof node_opcua_data_value_1.DataValue) && typeof dataValue_verify.then !== "function") {
|
|
1547
|
+
errorLog(chalk.red(" Bind variable error: "), " the timestamped_get function must return a DataValue or a Promise<DataValue>" +
|
|
1548
|
+
"\n value_check.constructor.name ", dataValue_verify ? dataValue_verify.constructor.name : "null");
|
|
1549
|
+
throw new Error(" Bind variable error: " + " the timestamped_get function must return a DataValue");
|
|
1550
|
+
}
|
|
1551
|
+
_Variable_bind_with_async_refresh.call(this, { refreshFunc: async_refresh_func });
|
|
1552
|
+
}
|
|
1553
|
+
else if (options.timestamped_get.length === 1) {
|
|
1554
|
+
_Variable_bind_with_async_refresh.call(this, { refreshFunc: options.timestamped_get });
|
|
1555
|
+
}
|
|
1556
|
+
else {
|
|
1557
|
+
errorLog("timestamped_get has a invalid number of argument , should be 0 or 1 ");
|
|
1558
|
+
throw new Error("timestamped_get has a invalid number of argument , should be 0 or 1 ");
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
// variation 1
|
|
1562
|
+
function _Variable_bind_with_simple_get(options) {
|
|
1563
|
+
/* jshint validthis: true */
|
|
1564
|
+
(0, node_opcua_assert_1.assert)(this instanceof UAVariableImpl);
|
|
1565
|
+
(0, node_opcua_assert_1.assert)(typeof options.get === "function", "should specify get function");
|
|
1566
|
+
(0, node_opcua_assert_1.assert)(options.get.length === 0, "get function should not have arguments");
|
|
1567
|
+
(0, node_opcua_assert_1.assert)(!options.timestamped_get, "should not specify a timestamped_get function when get is specified");
|
|
1568
|
+
(0, node_opcua_assert_1.assert)(!this._timestamped_get_func);
|
|
1569
|
+
(0, node_opcua_assert_1.assert)(!this._get_func);
|
|
1570
|
+
this._get_func = options.get;
|
|
1571
|
+
const timestamped_get_func_from__Variable_bind_with_simple_get = () => {
|
|
1572
|
+
const value = this._get_func();
|
|
1573
|
+
/* istanbul ignore next */
|
|
1574
|
+
if (!is_Variant_or_StatusCode(value)) {
|
|
1575
|
+
errorLog(chalk.red(" Bind variable error: "), " : the getter must return a Variant or a StatusCode" + "\nvalue_check.constructor.name ", value ? value.constructor.name : "null");
|
|
1576
|
+
throw new Error(" bindVariable : the value getter function returns a invalid result ( expecting a Variant or a StatusCode !!!");
|
|
1577
|
+
}
|
|
1578
|
+
if (is_StatusCode(value)) {
|
|
1579
|
+
return new node_opcua_data_value_1.DataValue({ statusCode: value });
|
|
1580
|
+
}
|
|
1581
|
+
else {
|
|
1582
|
+
if (!this._dataValue || !isGoodish(this._dataValue.statusCode) || !(0, node_opcua_variant_1.sameVariant)(this._dataValue.value, value)) {
|
|
1583
|
+
this.setValueFromSource(value, node_opcua_status_code_1.StatusCodes.Good);
|
|
1584
|
+
}
|
|
1585
|
+
else {
|
|
1586
|
+
// XX console.log("YYYYYYYYYYYYYYYYYYYYYYYYYY",this.browseName.toString());
|
|
1587
|
+
}
|
|
1588
|
+
return this._dataValue;
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
_Variable_bind_with_timestamped_get.call(this, {
|
|
1592
|
+
timestamped_get: timestamped_get_func_from__Variable_bind_with_simple_get
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
function _Variable_bind_with_simple_set(options) {
|
|
1596
|
+
(0, node_opcua_assert_1.assert)(this instanceof UAVariableImpl);
|
|
1597
|
+
(0, node_opcua_assert_1.assert)(typeof options.set === "function", "should specify set function");
|
|
1598
|
+
(0, node_opcua_assert_1.assert)(!options.timestamped_set, "should not specify a timestamped_set function");
|
|
1599
|
+
(0, node_opcua_assert_1.assert)(!this._timestamped_set_func);
|
|
1600
|
+
(0, node_opcua_assert_1.assert)(!this._set_func);
|
|
1601
|
+
this._set_func = turn_sync_to_async(options.set, 1);
|
|
1602
|
+
(0, node_opcua_assert_1.assert)(this._set_func.length === 2, " set function must have 2 arguments ( variant, callback)");
|
|
1603
|
+
this._timestamped_set_func = (timestamped_value, indexRange, callback) => {
|
|
1604
|
+
(0, node_opcua_assert_1.assert)(timestamped_value instanceof node_opcua_data_value_1.DataValue);
|
|
1605
|
+
this._set_func(timestamped_value.value, (err, statusCode) => {
|
|
1606
|
+
if (!err && !statusCode) {
|
|
1607
|
+
console.log(chalk.red("UAVariable Binding Error _set_func must return a StatusCode, check the bindVariable parameters"));
|
|
1608
|
+
console.log(chalk.yellow("StatusCode.Good is assumed"));
|
|
1609
|
+
return callback(err, node_opcua_status_code_1.StatusCodes.Good, timestamped_value);
|
|
1610
|
+
}
|
|
1611
|
+
callback(err, statusCode, timestamped_value);
|
|
1612
|
+
});
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
function _Variable_bind_with_timestamped_set(options) {
|
|
1616
|
+
(0, node_opcua_assert_1.assert)(this instanceof UAVariableImpl);
|
|
1617
|
+
(0, node_opcua_assert_1.assert)(typeof options.timestamped_set === "function");
|
|
1618
|
+
(0, node_opcua_assert_1.assert)(options.timestamped_set.length === 2, "timestamped_set must have 2 parameters timestamped_set: function(dataValue,callback){}");
|
|
1619
|
+
(0, node_opcua_assert_1.assert)(!options.set, "should not specify set when timestamped_set_func exists ");
|
|
1620
|
+
this._timestamped_set_func = (dataValue, indexRange, callback) => {
|
|
1621
|
+
// xx assert(!indexRange,"indexRange Not Implemented");
|
|
1622
|
+
return options.timestamped_set.call(this, dataValue, callback);
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
function bind_setter(options) {
|
|
1626
|
+
if (typeof options.set === "function") {
|
|
1627
|
+
// variation 1
|
|
1628
|
+
_Variable_bind_with_simple_set.call(this, options);
|
|
1629
|
+
}
|
|
1630
|
+
else if (typeof options.timestamped_set === "function") {
|
|
1631
|
+
// variation 2
|
|
1632
|
+
(0, node_opcua_assert_1.assert)(typeof options.timestamped_get === "function", "timestamped_set must be used with timestamped_get ");
|
|
1633
|
+
_Variable_bind_with_timestamped_set.call(this, options);
|
|
1634
|
+
}
|
|
1635
|
+
else if (typeof options.timestamped_get === "function") {
|
|
1636
|
+
// timestamped_get is specified but timestamped_set is not
|
|
1637
|
+
// => Value is read-only
|
|
1638
|
+
_Variable_bind_with_timestamped_set.call(this, {
|
|
1639
|
+
timestamped_set: _not_writable_timestamped_set_func
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
else {
|
|
1643
|
+
_Variable_bind_with_timestamped_set.call(this, {
|
|
1644
|
+
timestamped_set: _default_writable_timestamped_set_func
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
function bind_getter(options) {
|
|
1649
|
+
if (typeof options.get === "function") {
|
|
1650
|
+
// variation 1
|
|
1651
|
+
_Variable_bind_with_simple_get.call(this, options);
|
|
1652
|
+
}
|
|
1653
|
+
else if (typeof options.timestamped_get === "function") {
|
|
1654
|
+
// variation 2
|
|
1655
|
+
_Variable_bind_with_timestamped_get.call(this, options);
|
|
1656
|
+
}
|
|
1657
|
+
else if (typeof options.refreshFunc === "function") {
|
|
1658
|
+
// variation 3
|
|
1659
|
+
_Variable_bind_with_async_refresh.call(this, options);
|
|
1660
|
+
}
|
|
1661
|
+
else {
|
|
1662
|
+
(0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "set"), "getter is missing : a getter must be provided if a setter is provided");
|
|
1663
|
+
// xx bind_variant.call(this,options);
|
|
1664
|
+
if (options.dataType !== undefined) {
|
|
1665
|
+
// if (options.dataType !== DataType.ExtensionObject) {
|
|
1666
|
+
this.setValueFromSource(options);
|
|
1667
|
+
// }
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
function w(str, n) {
|
|
1672
|
+
return (str + " ").substr(0, n);
|
|
1673
|
+
}
|
|
1674
|
+
function _getter(target, key /*, receiver*/) {
|
|
1675
|
+
if (target[key] === undefined) {
|
|
1676
|
+
return undefined;
|
|
1677
|
+
}
|
|
1678
|
+
return target[key];
|
|
1679
|
+
}
|
|
1680
|
+
function _setter(variable, target, key, value /*, receiver*/) {
|
|
1681
|
+
target[key] = value;
|
|
1682
|
+
const child = variable[key];
|
|
1683
|
+
if (child && child.touchValue) {
|
|
1684
|
+
child.touchValue();
|
|
1685
|
+
}
|
|
1686
|
+
return true; // true means the set operation has succeeded
|
|
1687
|
+
}
|
|
1688
|
+
function makeHandler(variable) {
|
|
1689
|
+
const handler = {
|
|
1690
|
+
get: _getter,
|
|
1691
|
+
set: _setter.bind(null, variable)
|
|
1692
|
+
};
|
|
1693
|
+
return handler;
|
|
1694
|
+
}
|
|
1695
|
+
function setExtensionObjectValue(node, partialObject) {
|
|
1696
|
+
const extensionObject = node.$extensionObject;
|
|
1697
|
+
if (!extensionObject) {
|
|
1698
|
+
throw new Error("setExtensionObjectValue node has no extension object " + node.browseName.toString());
|
|
1699
|
+
}
|
|
1700
|
+
function _update_extension_object(extObject, partialObject1) {
|
|
1701
|
+
const keys = Object.keys(partialObject1);
|
|
1702
|
+
for (const prop of keys) {
|
|
1703
|
+
if (extObject[prop] instanceof Object) {
|
|
1704
|
+
_update_extension_object(extObject[prop], partialObject1[prop]);
|
|
1705
|
+
}
|
|
1706
|
+
else {
|
|
1707
|
+
extObject[prop] = partialObject1[prop];
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
_update_extension_object(extensionObject, partialObject);
|
|
1712
|
+
}
|
|
1713
|
+
class UAVariableImplT extends UAVariableImpl {
|
|
1714
|
+
}
|
|
1715
|
+
exports.UAVariableImplT = UAVariableImplT;
|
|
1716
|
+
// x TO DO
|
|
1717
|
+
// require("./data_access/ua_variable_data_access");
|
|
1718
|
+
// require("./historical_access/ua_variable_history");
|
|
1719
|
+
//# sourceMappingURL=ua_variable_impl.js.map
|