node-opcua-address-space 2.97.0 → 2.98.1
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/dist/source/address_space_ts.d.ts +118 -118
- package/dist/source/address_space_ts.js +17 -17
- package/dist/source/continuation_points/continuation_point_manager.d.ts +91 -91
- package/dist/source/continuation_points/continuation_point_manager.js +200 -200
- package/dist/source/helpers/adjust_browse_direction.d.ts +5 -5
- package/dist/source/helpers/adjust_browse_direction.js +11 -11
- package/dist/source/helpers/argument_list.d.ts +33 -33
- package/dist/source/helpers/argument_list.js +254 -254
- package/dist/source/helpers/call_helpers.d.ts +6 -6
- package/dist/source/helpers/call_helpers.js +71 -71
- package/dist/source/helpers/coerce_enum_value.d.ts +6 -6
- package/dist/source/helpers/coerce_enum_value.js +33 -33
- package/dist/source/helpers/dump_tools.d.ts +14 -14
- package/dist/source/helpers/dump_tools.js +78 -78
- package/dist/source/helpers/ensure_secure_access.d.ts +9 -9
- package/dist/source/helpers/ensure_secure_access.js +76 -76
- package/dist/source/helpers/make_optionals_map.d.ts +21 -21
- package/dist/source/helpers/make_optionals_map.js +29 -29
- package/dist/source/helpers/multiform_func.d.ts +11 -11
- package/dist/source/helpers/multiform_func.js +75 -75
- package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -3
- package/dist/source/helpers/resolve_opaque_on_address_space.js +36 -36
- package/dist/source/index.d.ts +61 -61
- package/dist/source/index.js +89 -89
- package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +19 -19
- package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +193 -193
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.d.ts +12 -12
- package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.d.ts +10 -10
- package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.d.ts +7 -7
- package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.d.ts +7 -7
- package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.d.ts +9 -9
- package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.d.ts +20 -20
- package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +23 -23
- package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.d.ts +32 -32
- package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.d.ts +19 -19
- package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +45 -42
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.d.ts +7 -7
- package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js +25 -25
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.d.ts +5 -5
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.d.ts +20 -20
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.d.ts +26 -26
- package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.d.ts +8 -8
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.d.ts +10 -10
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -21
- package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -24
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -12
- package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -8
- package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +2 -2
- package/dist/source/interfaces/extension_object_constructor.d.ts +10 -10
- package/dist/source/interfaces/extension_object_constructor.js +2 -2
- package/dist/source/interfaces/nodeset_loader_options.d.ts +4 -4
- package/dist/source/interfaces/nodeset_loader_options.js +2 -2
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -12
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +2 -2
- package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -49
- package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +2 -2
- package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -11
- package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +2 -2
- package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +30 -30
- package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js +2 -2
- package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +234 -234
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js +2 -2
- package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -6
- package/dist/source/interfaces/state_machine/ua_transition_ex.js +2 -2
- package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -8
- package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +2 -2
- package/dist/source/loader/decode_xml_extension_object.d.ts +6 -6
- package/dist/source/loader/decode_xml_extension_object.js +71 -71
- package/dist/source/loader/ensure_datatype_extracted.d.ts +5 -5
- package/dist/source/loader/ensure_datatype_extracted.js +70 -70
- package/dist/source/loader/generateAddressSpaceRaw.d.ts +11 -11
- package/dist/source/loader/generateAddressSpaceRaw.js +45 -45
- package/dist/source/loader/load_nodeset2.d.ts +17 -17
- package/dist/source/loader/load_nodeset2.js +1483 -1483
- package/dist/source/loader/make_semver_compatible.d.ts +6 -6
- package/dist/source/loader/make_semver_compatible.js +25 -25
- package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -28
- package/dist/source/loader/make_xml_extension_object_parser.js +326 -326
- package/dist/source/loader/namespace_post_step.d.ts +10 -10
- package/dist/source/loader/namespace_post_step.js +61 -61
- package/dist/source/loader/register_node_promoter.d.ts +2 -2
- package/dist/source/loader/register_node_promoter.js +9 -9
- package/dist/source/namespace.d.ts +6 -6
- package/dist/source/namespace.js +2 -2
- package/dist/source/namespace_alarm_and_condition.d.ts +32 -32
- package/dist/source/namespace_alarm_and_condition.js +2 -2
- package/dist/source/namespace_data_access.d.ts +42 -42
- package/dist/source/namespace_data_access.js +2 -2
- package/dist/source/namespace_machine_state.d.ts +8 -8
- package/dist/source/namespace_machine_state.js +2 -2
- package/dist/source/pseudo_session.d.ts +72 -72
- package/dist/source/pseudo_session.js +254 -254
- package/dist/source/session_context.d.ts +111 -111
- package/dist/source/session_context.js +264 -264
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/set_namespace_meta_data.d.ts +2 -2
- package/dist/source/set_namespace_meta_data.js +59 -59
- package/dist/source/ua_root_folder.d.ts +9 -9
- package/dist/source/ua_root_folder.js +2 -2
- package/dist/source/ua_two_state_variable_ex.d.ts +23 -23
- package/dist/source/ua_two_state_variable_ex.js +2 -2
- package/dist/source/xml_writer.d.ts +18 -18
- package/dist/source/xml_writer.js +2 -2
- package/dist/src/address_space.d.ts +387 -387
- package/dist/src/address_space.js +1385 -1385
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_change_event_tools.d.ts +6 -6
- package/dist/src/address_space_change_event_tools.js +152 -152
- package/dist/src/address_space_private.d.ts +43 -43
- package/dist/src/address_space_private.js +2 -2
- package/dist/src/alarms_and_conditions/condition.d.ts +5 -5
- package/dist/src/alarms_and_conditions/condition.js +78 -78
- package/dist/src/alarms_and_conditions/condition_info_impl.d.ts +26 -26
- package/dist/src/alarms_and_conditions/condition_info_impl.js +54 -54
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +222 -222
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +657 -657
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +9 -9
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +60 -60
- package/dist/src/alarms_and_conditions/index.d.ts +16 -16
- package/dist/src/alarms_and_conditions/index.js +32 -32
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +44 -44
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -244
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +93 -93
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +418 -418
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +26 -26
- package/dist/src/alarms_and_conditions/ua_base_event_impl.js +38 -38
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +44 -44
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +183 -183
- package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +155 -153
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +1028 -1028
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +14 -14
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +34 -34
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +24 -24
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +56 -56
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +11 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +11 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +23 -23
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +86 -86
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +11 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +7 -7
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +79 -79
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +250 -250
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +24 -24
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +50 -50
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +19 -19
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +162 -162
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +46 -46
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +165 -165
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +18 -18
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +17 -17
- package/dist/src/apply_condition_refresh.d.ts +6 -6
- package/dist/src/apply_condition_refresh.js +27 -27
- package/dist/src/base_node_impl.d.ts +284 -284
- package/dist/src/base_node_impl.js +1454 -1454
- package/dist/src/base_node_private.d.ts +81 -81
- package/dist/src/base_node_private.js +832 -803
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/check_value_rank_compatibility.d.ts +15 -15
- package/dist/src/check_value_rank_compatibility.js +81 -81
- package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -11
- package/dist/src/data_access/add_dataItem_stuff.js +61 -61
- package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -1
- package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +34 -34
- package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -32
- package/dist/src/data_access/ua_multistate_discrete_impl.js +130 -130
- package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +52 -52
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js +253 -253
- package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +25 -25
- package/dist/src/data_access/ua_two_state_discrete_impl.js +155 -155
- package/dist/src/event_data.d.ts +34 -34
- package/dist/src/event_data.js +64 -64
- package/dist/src/extension_object_array_node.d.ts +23 -23
- package/dist/src/extension_object_array_node.js +248 -248
- package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -26
- package/dist/src/historical_access/address_space_historical_data_node.js +652 -652
- package/dist/src/idx_iterator.d.ts +8 -8
- package/dist/src/idx_iterator.js +50 -50
- package/dist/src/index_current.d.ts +46 -46
- package/dist/src/index_current.js +77 -77
- package/dist/src/namespace_impl.d.ts +456 -456
- package/dist/src/namespace_impl.js +1762 -1762
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/namespace_private.d.ts +23 -23
- package/dist/src/namespace_private.js +32 -32
- package/dist/src/nodeid_manager.d.ts +37 -37
- package/dist/src/nodeid_manager.js +183 -183
- package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -2
- package/dist/src/nodeset_tools/adjust_namespace_array.js +13 -13
- package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +18 -18
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +140 -140
- package/dist/src/nodeset_tools/dump_to_bsd.d.ts +2 -2
- package/dist/src/nodeset_tools/dump_to_bsd.js +164 -164
- package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +10 -10
- package/dist/src/nodeset_tools/nodeset_to_xml.js +1287 -1287
- package/dist/src/private_namespace.d.ts +5 -5
- package/dist/src/private_namespace.js +19 -19
- package/dist/src/reference_impl.d.ts +43 -43
- package/dist/src/reference_impl.js +139 -139
- package/dist/src/role_permissions.d.ts +2 -2
- package/dist/src/role_permissions.js +10 -10
- package/dist/src/state_machine/finite_state_machine.d.ts +81 -81
- package/dist/src/state_machine/finite_state_machine.js +388 -388
- package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +38 -38
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +250 -250
- package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -61
- package/dist/src/state_machine/ua_two_state_variable.js +331 -331
- package/dist/src/tool_isSubtypeOf.d.ts +18 -18
- package/dist/src/tool_isSubtypeOf.js +124 -124
- package/dist/src/ua_condition_type.d.ts +8 -8
- package/dist/src/ua_condition_type.js +2 -2
- package/dist/src/ua_data_type_impl.d.ts +89 -89
- package/dist/src/ua_data_type_impl.js +368 -368
- package/dist/src/ua_method_impl.d.ts +42 -42
- package/dist/src/ua_method_impl.js +217 -217
- package/dist/src/ua_object_impl.d.ts +35 -35
- package/dist/src/ua_object_impl.js +168 -168
- package/dist/src/ua_object_type_impl.d.ts +50 -50
- package/dist/src/ua_object_type_impl.js +126 -126
- package/dist/src/ua_reference_type_impl.d.ts +45 -45
- package/dist/src/ua_reference_type_impl.js +141 -141
- package/dist/src/ua_variable_impl.d.ts +380 -380
- package/dist/src/ua_variable_impl.js +1738 -1738
- package/dist/src/ua_variable_impl_ext_obj.d.ts +23 -23
- package/dist/src/ua_variable_impl_ext_obj.js +670 -670
- package/dist/src/ua_variable_type_impl.d.ts +74 -74
- package/dist/src/ua_variable_type_impl.js +597 -581
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/src/ua_view_impl.d.ts +19 -19
- package/dist/src/ua_view_impl.js +43 -43
- package/dist/tsconfig_common.tsbuildinfo +1 -0
- package/distHelpers/add_event_generator_object.d.ts +3 -3
- package/distHelpers/add_event_generator_object.js +64 -64
- package/distHelpers/alarms_and_conditions_demo.d.ts +9 -9
- package/distHelpers/alarms_and_conditions_demo.js +115 -115
- package/distHelpers/assertHasMatchingReference.d.ts +19 -19
- package/distHelpers/assertHasMatchingReference.js +40 -40
- package/distHelpers/boiler_system.d.ts +113 -113
- package/distHelpers/boiler_system.js +395 -395
- package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -5
- package/distHelpers/create_minimalist_address_space_nodeset.js +171 -171
- package/distHelpers/date_utils.d.ts +3 -3
- package/distHelpers/date_utils.js +9 -9
- package/distHelpers/dump_statemachine.js +127 -127
- package/distHelpers/get_address_space_fixture.d.ts +1 -1
- package/distHelpers/get_address_space_fixture.js +30 -30
- package/distHelpers/get_mini_address_space.d.ts +7 -7
- package/distHelpers/get_mini_address_space.js +36 -36
- package/distHelpers/index.d.ts +12 -12
- package/distHelpers/index.js +28 -28
- package/distHelpers/mock_session.d.ts +10 -10
- package/distHelpers/mock_session.js +25 -25
- package/distNodeJS/generate_address_space.d.ts +6 -6
- package/distNodeJS/generate_address_space.js +52 -52
- package/distNodeJS/index.d.ts +1 -1
- package/distNodeJS/index.js +17 -17
- package/package.json +51 -40
- package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +4 -3
- package/src/alarms_and_conditions/ua_condition_impl.ts +14 -9
- package/src/base_node_private.ts +73 -28
- package/src/ua_variable_type_impl.ts +35 -17
- package/.mocharc.yml +0 -12
- package/dist/src/tool_isSupertypeOf.d.ts +0 -18
- package/dist/src/tool_isSupertypeOf.js +0 -125
- package/dist/src/tool_isSupertypeOf.js.map +0 -1
- package/generate.js +0 -1
- package/source_nodejs/generate_address_space.ts +0 -60
- package/source_nodejs/index.ts +0 -1
- package/test_helpers/add_event_generator_object.ts +0 -71
- package/test_helpers/alarms_and_conditions_demo.ts +0 -151
- package/test_helpers/assertHasMatchingReference.ts +0 -43
- package/test_helpers/boiler_system.ts +0 -610
- package/test_helpers/create_minimalist_address_space_nodeset.ts +0 -208
- package/test_helpers/date_utils.ts +0 -5
- package/test_helpers/dump_statemachine.ts +0 -155
- package/test_helpers/get_address_space_fixture.ts +0 -30
- package/test_helpers/get_mini_address_space.ts +0 -42
- package/test_helpers/index.ts +0 -12
- package/test_helpers/mock_session.ts +0 -34
- package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +0 -150
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +0 -57
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +0 -136
- package/test_helpers/test_fixtures/dataType_issue.xml +0 -80
- package/test_helpers/test_fixtures/dataType_withEnumeration.xml +0 -82
- package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +0 -194
- package/test_helpers/test_fixtures/dataType_with_qualifiedname.xml +0 -71
- package/test_helpers/test_fixtures/dataType_with_recursive_structure.xml +0 -155
- package/test_helpers/test_fixtures/dataType_with_structures.xml +0 -605
- package/test_helpers/test_fixtures/dataType_with_union.xml +0 -90
- package/test_helpers/test_fixtures/datatype_as_per_1.04.xml +0 -118
- package/test_helpers/test_fixtures/datatype_with_allow_subtype.xml +0 -104
- package/test_helpers/test_fixtures/eurange_issue.xml +0 -74
- package/test_helpers/test_fixtures/example_issue1096.xml +0 -267
- package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +0 -106
- package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +0 -1305
- package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +0 -370
- package/test_helpers/test_fixtures/issue_1132_variable_with_nodeid_value.xml +0 -68
- package/test_helpers/test_fixtures/issue_846.xml +0 -3172
- package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +0 -33
- package/test_helpers/test_fixtures/mini.Node.Set2.xml +0 -4736
- package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +0 -196
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +0 -8
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +0 -20
- package/test_helpers/test_fixtures/nodeset_no_aliases.xml +0 -30
- package/test_helpers/test_fixtures/nodeset_no_aliases_with_aliases.xml +0 -31
- package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +0 -45
- package/test_helpers/test_fixtures/nodeset_with_guid.xml +0 -1442
- package/test_helpers/test_fixtures/nodeset_with_int64_values.xml +0 -31
- package/test_helpers/test_fixtures/nodeset_with_special_char.xml +0 -34
- package/test_helpers/test_fixtures/nodeset_with_utf8_special_characters.xml +0 -20
- package/test_helpers/test_fixtures/variable_with_value.xml +0 -143
- package/test_helpers/test_fixtures/variabletype_with_value.xml +0 -324
|
@@ -1,671 +1,671 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propagateTouchValueDownwardArray = exports.extractPartialData = exports.incrementElement = exports.setElement = exports.getElement = exports._bindExtensionObjectArrayOrMatrix = exports._bindExtensionObject = exports._installExtensionObjectBindingOnProperties = exports.setExtensionObjectPartialValue = exports.propagateTouchValueDownward = exports.propagateTouchValueUpward = exports._touchValue = exports.getProxyTarget = void 0;
|
|
4
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
5
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
6
|
-
const node_opcua_date_time_1 = require("node-opcua-date-time");
|
|
7
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
8
|
-
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
9
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
10
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
11
|
-
const node_opcua_utils_1 = require("node-opcua-utils");
|
|
12
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
13
|
-
const ua_variable_impl_1 = require("./ua_variable_impl");
|
|
14
|
-
const idx_iterator_1 = require("./idx_iterator");
|
|
15
|
-
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
16
|
-
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
17
|
-
// const doDebug = true; // checkDebugFlag(__filename);
|
|
18
|
-
// const debugLog = make_warningLog(__filename);
|
|
19
|
-
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
20
|
-
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
21
|
-
function w(str, n) {
|
|
22
|
-
return str.padEnd(n).substring(n);
|
|
23
|
-
}
|
|
24
|
-
function isProxy(ext) {
|
|
25
|
-
return ext.$isProxy ? true : false;
|
|
26
|
-
}
|
|
27
|
-
function getProxyVariable(ext) {
|
|
28
|
-
(0, node_opcua_assert_1.default)(isProxy(ext));
|
|
29
|
-
return ext.$variable;
|
|
30
|
-
}
|
|
31
|
-
function getProxyVariableForProp(ext, prop) {
|
|
32
|
-
const uaVariable = getProxyVariable(ext);
|
|
33
|
-
if (!uaVariable)
|
|
34
|
-
return undefined;
|
|
35
|
-
return uaVariable[prop];
|
|
36
|
-
}
|
|
37
|
-
function getProxyTarget(ext) {
|
|
38
|
-
(0, node_opcua_assert_1.default)(isProxy(ext));
|
|
39
|
-
const target = ext.$proxyTarget;
|
|
40
|
-
if (target && isProxy(target)) {
|
|
41
|
-
return getProxyTarget(target);
|
|
42
|
-
}
|
|
43
|
-
return target;
|
|
44
|
-
}
|
|
45
|
-
exports.getProxyTarget = getProxyTarget;
|
|
46
|
-
function unProxy(ext) {
|
|
47
|
-
return isProxy(ext) ? getProxyTarget(ext) : ext;
|
|
48
|
-
}
|
|
49
|
-
function _extensionObjectFieldGetter(getVariable, target, key /*, receiver*/) {
|
|
50
|
-
if (key === "$isProxy") {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
if (key === "$proxyTarget") {
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
56
|
-
if (key === "$variable") {
|
|
57
|
-
return getVariable();
|
|
58
|
-
}
|
|
59
|
-
if (target[key] === undefined) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
return target[key];
|
|
63
|
-
}
|
|
64
|
-
function _extensionObjectFieldSetter(getVariable, target, key, value /*, receiver*/) {
|
|
65
|
-
target[key] = value;
|
|
66
|
-
if (isProxy(target)) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
const uaVariable = getVariable();
|
|
70
|
-
if (!uaVariable)
|
|
71
|
-
return true;
|
|
72
|
-
const child = uaVariable[key];
|
|
73
|
-
if (child && child.touchValue) {
|
|
74
|
-
child.touchValue();
|
|
75
|
-
}
|
|
76
|
-
return true; // true means the set operation has succeeded
|
|
77
|
-
}
|
|
78
|
-
function makeHandler(getVariable) {
|
|
79
|
-
const handler = {
|
|
80
|
-
get: _extensionObjectFieldGetter.bind(null, getVariable),
|
|
81
|
-
set: _extensionObjectFieldSetter.bind(null, getVariable)
|
|
82
|
-
};
|
|
83
|
-
return handler;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* inconditionnaly change the time stamp of the variable
|
|
87
|
-
* if the variable is being listened to, and if the minimumSamplingInterval is exactly zero,
|
|
88
|
-
* then the change will be reported to the observer
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
function _touchValue(property, now) {
|
|
92
|
-
property.$dataValue.sourceTimestamp = now.timestamp;
|
|
93
|
-
property.$dataValue.sourcePicoseconds = now.picoseconds;
|
|
94
|
-
property.$dataValue.serverTimestamp = now.timestamp;
|
|
95
|
-
property.$dataValue.serverPicoseconds = now.picoseconds;
|
|
96
|
-
property.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
97
|
-
if (property.listenerCount("value_changed") > 0) {
|
|
98
|
-
property.emit("value_changed", property.$dataValue.clone());
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports._touchValue = _touchValue;
|
|
102
|
-
function propagateTouchValueUpward(self, now, cache) {
|
|
103
|
-
_touchValue(self, now);
|
|
104
|
-
if (self.parent && self.parent.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
105
|
-
const parentVar = self.parent;
|
|
106
|
-
if (!parentVar.isExtensionObject())
|
|
107
|
-
return;
|
|
108
|
-
if (cache) {
|
|
109
|
-
if (cache.has(parentVar))
|
|
110
|
-
return;
|
|
111
|
-
cache.add(parentVar);
|
|
112
|
-
}
|
|
113
|
-
propagateTouchValueUpward(parentVar, now, cache);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.propagateTouchValueUpward = propagateTouchValueUpward;
|
|
117
|
-
function propagateTouchValueDownward(self, now, cache) {
|
|
118
|
-
if (!self.isExtensionObject())
|
|
119
|
-
return;
|
|
120
|
-
// also propagate changes to embeded variables
|
|
121
|
-
const dataTypeNode = self.getDataTypeNode();
|
|
122
|
-
const definition = dataTypeNode.getStructureDefinition();
|
|
123
|
-
for (const field of definition.fields || []) {
|
|
124
|
-
const property = self.getChildByName(field.name);
|
|
125
|
-
if (property) {
|
|
126
|
-
if (cache) {
|
|
127
|
-
if (cache.has(property)) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
cache.add(property);
|
|
131
|
-
}
|
|
132
|
-
_touchValue(property, now);
|
|
133
|
-
// to do cascade recursivelly ?
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.propagateTouchValueDownward = propagateTouchValueDownward;
|
|
138
|
-
function setExtensionObjectPartialValue(node, partialObject, sourceTimestamp) {
|
|
139
|
-
const variablesToUpdate = new Set();
|
|
140
|
-
const extensionObject = node.$extensionObject;
|
|
141
|
-
if (!extensionObject) {
|
|
142
|
-
throw new Error("setExtensionObjectValue node has no extension object " + node.browseName.toString());
|
|
143
|
-
}
|
|
144
|
-
function _update_extension_object(extObject, partialObject1) {
|
|
145
|
-
const keys = Object.keys(partialObject1);
|
|
146
|
-
for (const prop of keys) {
|
|
147
|
-
if (extObject[prop] instanceof Object) {
|
|
148
|
-
_update_extension_object(extObject[prop], partialObject1[prop]);
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
if (isProxy(extObject)) {
|
|
152
|
-
// collect element we have to update
|
|
153
|
-
const target = getProxyTarget(extObject);
|
|
154
|
-
(0, node_opcua_assert_1.default)(!isProxy(target), "something wierd!");
|
|
155
|
-
target[prop] = partialObject1[prop];
|
|
156
|
-
const variable = getProxyVariableForProp(extObject, prop);
|
|
157
|
-
variable && variablesToUpdate.add(variable);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
extObject[prop] = partialObject1[prop];
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
_update_extension_object(extensionObject, partialObject);
|
|
166
|
-
const now = sourceTimestamp || (0, node_opcua_date_time_1.getCurrentClock)();
|
|
167
|
-
const cache = new Set();
|
|
168
|
-
for (const c of variablesToUpdate) {
|
|
169
|
-
if (cache.has(c))
|
|
170
|
-
continue;
|
|
171
|
-
propagateTouchValueUpward(c, now, cache);
|
|
172
|
-
propagateTouchValueDownward(c, now, cache);
|
|
173
|
-
cache.add(c);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.setExtensionObjectPartialValue = setExtensionObjectPartialValue;
|
|
177
|
-
function getOrCreateProperty(variableNode, field, options) {
|
|
178
|
-
const dt = variableNode.getDataTypeNode();
|
|
179
|
-
// the namespace for the structure browse name elements
|
|
180
|
-
const structureNamespace = dt.nodeId.namespace;
|
|
181
|
-
const components = variableNode.getComponents();
|
|
182
|
-
let property;
|
|
183
|
-
const selectedComponents = components.filter((f) => f instanceof ua_variable_impl_1.UAVariableImpl && f.browseName.name.toString() === field.name);
|
|
184
|
-
// istanbul ignore next
|
|
185
|
-
if (field.dataType.value === node_opcua_variant_1.DataType.Variant) {
|
|
186
|
-
warningLog("Warning : variant is not supported in ExtensionObject");
|
|
187
|
-
}
|
|
188
|
-
if (selectedComponents.length === 1) {
|
|
189
|
-
property = selectedComponents[0];
|
|
190
|
-
/* istanbul ignore next */
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
if (!options.createMissingProp) {
|
|
194
|
-
return null;
|
|
195
|
-
}
|
|
196
|
-
debugLog("adding missing array variable", field.name, variableNode.browseName.toString(), variableNode.nodeId.toString());
|
|
197
|
-
// todo: Handle array appropriately...
|
|
198
|
-
(0, node_opcua_assert_1.default)(selectedComponents.length === 0);
|
|
199
|
-
// create a variable (Note we may use ns=1;s=parentName/0:PropertyName)
|
|
200
|
-
property = variableNode.namespace.addVariable({
|
|
201
|
-
browseName: { namespaceIndex: structureNamespace, name: field.name.toString() },
|
|
202
|
-
componentOf: variableNode,
|
|
203
|
-
dataType: field.dataType,
|
|
204
|
-
minimumSamplingInterval: variableNode.minimumSamplingInterval,
|
|
205
|
-
accessLevel: variableNode.accessLevel,
|
|
206
|
-
accessRestrictions: variableNode.accessRestrictions,
|
|
207
|
-
rolePermissions: variableNode.rolePermissions
|
|
208
|
-
});
|
|
209
|
-
(0, node_opcua_assert_1.default)(property.minimumSamplingInterval === variableNode.minimumSamplingInterval);
|
|
210
|
-
}
|
|
211
|
-
return property;
|
|
212
|
-
}
|
|
213
|
-
function prepareVariantValue(dataType, value) {
|
|
214
|
-
if ((dataType === node_opcua_variant_1.DataType.Int32 || dataType === node_opcua_variant_1.DataType.UInt32) && value && value.key) {
|
|
215
|
-
value = value.value;
|
|
216
|
-
}
|
|
217
|
-
return value;
|
|
218
|
-
}
|
|
219
|
-
function installExt(uaVariable, ext) {
|
|
220
|
-
ext = unProxy(ext);
|
|
221
|
-
uaVariable.$extensionObject = new Proxy(ext, makeHandler(() => uaVariable));
|
|
222
|
-
const addressSpace = uaVariable.addressSpace;
|
|
223
|
-
const definition = uaVariable.dataTypeObj.getStructureDefinition();
|
|
224
|
-
const structure = addressSpace.findDataType("Structure");
|
|
225
|
-
for (const field of definition.fields || []) {
|
|
226
|
-
if (field.dataType) {
|
|
227
|
-
const dataTypeNode = addressSpace.findDataType(field.dataType);
|
|
228
|
-
// istanbul ignore next
|
|
229
|
-
if (dataTypeNode && dataTypeNode.isSubtypeOf(structure)) {
|
|
230
|
-
// sub structure .. let make an handler too
|
|
231
|
-
const camelCaseName = (0, node_opcua_utils_1.lowerFirstLetter)(field.name);
|
|
232
|
-
const subExtObj = uaVariable.$extensionObject[camelCaseName];
|
|
233
|
-
if (subExtObj) {
|
|
234
|
-
uaVariable.$extensionObject[camelCaseName] = new Proxy(subExtObj, makeHandler(() => {
|
|
235
|
-
return uaVariable.getComponentByName(field.name);
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
doDebug && warningLog("extension object is null");
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
function _installExtensionObjectBindingOnProperties(uaVariable, options) {
|
|
246
|
-
// may be extension object mechanism has alreday been install
|
|
247
|
-
// in this case we just need to rebind the properties...
|
|
248
|
-
if (uaVariable.$extensionObject) {
|
|
249
|
-
const extObj = uaVariable.$extensionObject;
|
|
250
|
-
uaVariable.bindExtensionObject(extObj, { createMissingProp: true, force: true });
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
if (uaVariable.$$extensionObjectArray) {
|
|
254
|
-
const extObj = uaVariable.$$extensionObjectArray;
|
|
255
|
-
_bindExtensionObjectArrayOrMatrix(uaVariable, extObj, { createMissingProp: true, force: true });
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
const dataValue = uaVariable.readValue();
|
|
259
|
-
const extObj = dataValue.value.value;
|
|
260
|
-
if (extObj instanceof node_opcua_extension_object_1.ExtensionObject) {
|
|
261
|
-
uaVariable.bindExtensionObject(extObj, { createMissingProp: true, force: true });
|
|
262
|
-
}
|
|
263
|
-
else if (extObj instanceof Array) {
|
|
264
|
-
// istanbul ignore else
|
|
265
|
-
if (dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Array || dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
266
|
-
_bindExtensionObjectArrayOrMatrix(uaVariable, extObj, { createMissingProp: true, force: true });
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
throw new Error("Internal Error, unexpected case");
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
exports._installExtensionObjectBindingOnProperties = _installExtensionObjectBindingOnProperties;
|
|
274
|
-
function _installFields2(uaVariable, { get, set }, options) {
|
|
275
|
-
options = options || { createMissingProp: false };
|
|
276
|
-
const dt = uaVariable.getDataTypeNode();
|
|
277
|
-
const definition = dt.getStructureDefinition();
|
|
278
|
-
for (const field of definition.fields || []) {
|
|
279
|
-
if (node_opcua_nodeid_1.NodeId.sameNodeId(node_opcua_nodeid_1.NodeId.nullNodeId, field.dataType)) {
|
|
280
|
-
warningLog("field.dataType is null ! ", field.name, node_opcua_nodeid_1.NodeId.nullNodeId.toString());
|
|
281
|
-
warningLog(field.toString());
|
|
282
|
-
warningLog(" dataType replaced with BaseDataType ");
|
|
283
|
-
warningLog(definition.toString());
|
|
284
|
-
field.dataType = uaVariable.resolveNodeId("BaseDataType");
|
|
285
|
-
}
|
|
286
|
-
const propertyNode = getOrCreateProperty(uaVariable, field, options);
|
|
287
|
-
if (!propertyNode) {
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
propertyNode.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
291
|
-
propertyNode.$dataValue.sourceTimestamp = uaVariable.$dataValue.sourceTimestamp;
|
|
292
|
-
propertyNode.$dataValue.sourcePicoseconds = uaVariable.$dataValue.sourcePicoseconds;
|
|
293
|
-
propertyNode.$dataValue.serverTimestamp = uaVariable.$dataValue.serverTimestamp;
|
|
294
|
-
propertyNode.$dataValue.serverPicoseconds = uaVariable.$dataValue.serverPicoseconds;
|
|
295
|
-
propertyNode.$dataValue.value.dataType = propertyNode.dataTypeObj.basicDataType;
|
|
296
|
-
propertyNode.$dataValue.value.arrayType = propertyNode.valueRank === -1 ? node_opcua_variant_1.VariantArrayType.Scalar : (propertyNode.valueRank === 1 ? node_opcua_variant_1.VariantArrayType.Array : node_opcua_variant_1.VariantArrayType.Matrix);
|
|
297
|
-
propertyNode.$dataValue.value.dimensions = propertyNode.valueRank > 1 ? propertyNode.arrayDimensions : null;
|
|
298
|
-
const fieldName = field.name;
|
|
299
|
-
installDataValueGetter(propertyNode, () => get(fieldName));
|
|
300
|
-
(0, node_opcua_assert_1.default)(propertyNode._inner_replace_dataValue);
|
|
301
|
-
propertyNode._inner_replace_dataValue = (dataValue, indexRange) => {
|
|
302
|
-
/** */
|
|
303
|
-
const sourceTime = (0, node_opcua_date_time_1.coerceClock)(dataValue.sourceTimestamp, dataValue.sourcePicoseconds);
|
|
304
|
-
const value = dataValue.value.value;
|
|
305
|
-
set(field.name, value, sourceTime);
|
|
306
|
-
propertyNode.touchValue(sourceTime);
|
|
307
|
-
};
|
|
308
|
-
if (propertyNode.dataTypeObj.basicDataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
309
|
-
_installFields2(propertyNode, {
|
|
310
|
-
get: (fieldName) => {
|
|
311
|
-
const mainFieldName = field.name;
|
|
312
|
-
return get(mainFieldName)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)];
|
|
313
|
-
},
|
|
314
|
-
set: (fieldName, value, sourceTime) => {
|
|
315
|
-
const mainFieldName = field.name;
|
|
316
|
-
get(mainFieldName)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = value;
|
|
317
|
-
}
|
|
318
|
-
}, options);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
function installDataValueGetter(propertyNode, get) {
|
|
323
|
-
Object.defineProperty(propertyNode.$dataValue.value, "value", { get });
|
|
324
|
-
const $ = propertyNode.$dataValue;
|
|
325
|
-
Object.defineProperty(propertyNode, "$dataValue", {
|
|
326
|
-
get() {
|
|
327
|
-
return $;
|
|
328
|
-
},
|
|
329
|
-
set: (value) => {
|
|
330
|
-
throw new Error("$dataValue is now frozen and should not be modified this way !\n contact sterfive.com");
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
function isVariableContainingExtensionObject(uaVariable) {
|
|
335
|
-
const addressSpace = uaVariable.addressSpace;
|
|
336
|
-
const structure = addressSpace.findDataType("Structure");
|
|
337
|
-
if (!structure) {
|
|
338
|
-
// the addressSpace is limited and doesn't provide extension object
|
|
339
|
-
// bindExtensionObject cannot be performed and shall finish here.
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
(0, node_opcua_assert_1.default)(structure.browseName.toString() === "Structure", "expecting DataType Structure to be in IAddressSpace");
|
|
343
|
-
const dt = uaVariable.getDataTypeNode();
|
|
344
|
-
if (!dt.isSubtypeOf(structure)) {
|
|
345
|
-
return false;
|
|
346
|
-
}
|
|
347
|
-
return true;
|
|
348
|
-
}
|
|
349
|
-
function _innerBindExtensionObjectScalar(uaVariable, { get, set, setField }, options) {
|
|
350
|
-
uaVariable.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
351
|
-
uaVariable.$dataValue.value.dataType = node_opcua_variant_1.DataType.ExtensionObject;
|
|
352
|
-
uaVariable.$dataValue.value.arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
|
|
353
|
-
uaVariable.setValueFromSource = function (variant) {
|
|
354
|
-
setExtensionObjectPartialValue(this, variant.value);
|
|
355
|
-
};
|
|
356
|
-
installDataValueGetter(uaVariable, get);
|
|
357
|
-
uaVariable.$set_ExtensionObject = set;
|
|
358
|
-
_installFields2(uaVariable, {
|
|
359
|
-
get: (fieldName) => {
|
|
360
|
-
const extObj = get();
|
|
361
|
-
return extObj[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)];
|
|
362
|
-
},
|
|
363
|
-
set: (fieldName, value, sourceTime) => {
|
|
364
|
-
setField(fieldName, value, sourceTime);
|
|
365
|
-
}
|
|
366
|
-
}, options);
|
|
367
|
-
}
|
|
368
|
-
// eslint-disable-next-line complexity
|
|
369
|
-
function _bindExtensionObject(uaVariable, optionalExtensionObject, options) {
|
|
370
|
-
var _a, _b;
|
|
371
|
-
options = options || { createMissingProp: false };
|
|
372
|
-
// istanbul ignore next
|
|
373
|
-
if (!isVariableContainingExtensionObject(uaVariable)) {
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
// istanbul ignore next
|
|
377
|
-
if (optionalExtensionObject && uaVariable.valueRank === 0) {
|
|
378
|
-
warningLog(uaVariable.browseName.toString() + ": valueRank was zero but needed to be adjusted to -1 (Scalar) in bindExtensionObject");
|
|
379
|
-
uaVariable.valueRank = -1;
|
|
380
|
-
}
|
|
381
|
-
const addressSpace = uaVariable.addressSpace;
|
|
382
|
-
let extensionObject_;
|
|
383
|
-
// istanbul ignore next
|
|
384
|
-
if (uaVariable.valueRank !== -1 && uaVariable.valueRank !== 1) {
|
|
385
|
-
throw new Error("Cannot bind an extension object here, valueRank must be scalar (-1) or one-dimensional (1)");
|
|
386
|
-
}
|
|
387
|
-
// istanbul ignore next
|
|
388
|
-
doDebug && debugLog(" ------------------------------ binding ", uaVariable.browseName.toString(), uaVariable.nodeId.toString());
|
|
389
|
-
// ignore bindExtensionObject on sub extension object, bindExtensionObject has to be called from the top most object
|
|
390
|
-
if (!options.force &&
|
|
391
|
-
uaVariable.parent &&
|
|
392
|
-
(uaVariable.parent.nodeClass === node_opcua_data_model_1.NodeClass.Variable || uaVariable.parent.nodeClass === node_opcua_data_model_1.NodeClass.VariableType)) {
|
|
393
|
-
const parentDataType = uaVariable.parent.dataType;
|
|
394
|
-
const dataTypeNode = addressSpace.findNode(parentDataType);
|
|
395
|
-
const structure = addressSpace.findDataType("Structure");
|
|
396
|
-
// istanbul ignore next
|
|
397
|
-
if (dataTypeNode && dataTypeNode.isSubtypeOf(structure)) {
|
|
398
|
-
// warningLog(
|
|
399
|
-
// "Ignoring bindExtensionObject on sub extension object",
|
|
400
|
-
// "child=",
|
|
401
|
-
// self.browseName.toString(),
|
|
402
|
-
// "parent=",
|
|
403
|
-
// self.parent.browseName.toString()
|
|
404
|
-
// );
|
|
405
|
-
return null;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
// -------------------- make sure we do not bind a variable twice ....
|
|
409
|
-
if (uaVariable.$extensionObject && !optionalExtensionObject) {
|
|
410
|
-
// istanbul ignore next
|
|
411
|
-
if (!uaVariable.checkExtensionObjectIsCorrect(uaVariable.$extensionObject)) {
|
|
412
|
-
warningLog("on node : ", uaVariable.browseName.toString(), uaVariable.nodeId.toString(), "dataType=", uaVariable.dataType.toString({ addressSpace: uaVariable.addressSpace }));
|
|
413
|
-
warningLog((_a = uaVariable.$extensionObject) === null || _a === void 0 ? void 0 : _a.toString());
|
|
414
|
-
throw new Error("bindExtensionObject: $extensionObject is incorrect: we are expecting a " +
|
|
415
|
-
uaVariable.dataType.toString({ addressSpace: uaVariable.addressSpace }) +
|
|
416
|
-
" but we got a " +
|
|
417
|
-
((_b = uaVariable.$extensionObject) === null || _b === void 0 ? void 0 : _b.schema.name));
|
|
418
|
-
}
|
|
419
|
-
return uaVariable.$extensionObject;
|
|
420
|
-
}
|
|
421
|
-
// istanbul ignore next
|
|
422
|
-
if (uaVariable.dataTypeObj.isAbstract) {
|
|
423
|
-
warningLog("Warning the DataType associated with this Variable is abstract ", uaVariable.dataTypeObj.browseName.toString());
|
|
424
|
-
warningLog("You need to provide a extension object yourself ");
|
|
425
|
-
throw new Error("bindExtensionObject requires a extensionObject as associated dataType is only abstract");
|
|
426
|
-
}
|
|
427
|
-
const s = uaVariable.readValue();
|
|
428
|
-
if (s.value && s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject && s.value.value && optionalExtensionObject) {
|
|
429
|
-
// we want to replace the extension object
|
|
430
|
-
s.value.value = null;
|
|
431
|
-
}
|
|
432
|
-
innerBindExtensionObject();
|
|
433
|
-
(0, node_opcua_assert_1.default)(uaVariable.$extensionObject instanceof Object);
|
|
434
|
-
return uaVariable.$extensionObject;
|
|
435
|
-
function innerBindExtensionObject() {
|
|
436
|
-
if (s.value && (s.value.dataType === node_opcua_variant_1.DataType.Null || (s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject && !s.value.value))) {
|
|
437
|
-
if (uaVariable.valueRank === -1 /** Scalar */) {
|
|
438
|
-
extensionObject_ = optionalExtensionObject || addressSpace.constructExtensionObject(uaVariable.dataType, {});
|
|
439
|
-
installExt(uaVariable, extensionObject_);
|
|
440
|
-
_innerBindExtensionObjectScalar(uaVariable, {
|
|
441
|
-
get: () => uaVariable.$extensionObject,
|
|
442
|
-
set: (value) => installExt(uaVariable, value),
|
|
443
|
-
setField: (fieldName, value) => {
|
|
444
|
-
const extObj = uaVariable.$extensionObject;
|
|
445
|
-
getProxyTarget(extObj)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = value;
|
|
446
|
-
}
|
|
447
|
-
}, options);
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
else if (uaVariable.valueRank === 1 /** Array */) {
|
|
451
|
-
throw new Error("Should not get there ! Please fix me");
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
errorLog(uaVariable.toString());
|
|
455
|
-
errorLog("Unsupported case ! valueRank= ", uaVariable.valueRank);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
// verify that variant has the correct type
|
|
460
|
-
(0, node_opcua_assert_1.default)(s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject);
|
|
461
|
-
installExt(uaVariable, s.value.value);
|
|
462
|
-
_innerBindExtensionObjectScalar(uaVariable, {
|
|
463
|
-
get: () => uaVariable.$extensionObject,
|
|
464
|
-
set: (value) => installExt(uaVariable, value),
|
|
465
|
-
setField: (fieldName, value) => {
|
|
466
|
-
const extObj = uaVariable.$extensionObject;
|
|
467
|
-
getProxyTarget(extObj)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = value;
|
|
468
|
-
}
|
|
469
|
-
}, options);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
exports._bindExtensionObject = _bindExtensionObject;
|
|
474
|
-
const getIndexAsText = (index) => {
|
|
475
|
-
if (typeof index === "number")
|
|
476
|
-
return `${index}`;
|
|
477
|
-
return `${index.map((a) => a.toString()).join(",")}`;
|
|
478
|
-
};
|
|
479
|
-
const composeBrowseNameAndNodeId = (uaVariable, indexes) => {
|
|
480
|
-
const iAsText = getIndexAsText(indexes);
|
|
481
|
-
const browseName = (0, node_opcua_data_model_1.coerceQualifiedName)(iAsText);
|
|
482
|
-
let nodeId;
|
|
483
|
-
if (uaVariable.nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.STRING) {
|
|
484
|
-
nodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.STRING, uaVariable.nodeId.value + `[${iAsText}]`, uaVariable.nodeId.namespace);
|
|
485
|
-
}
|
|
486
|
-
return { browseName, nodeId };
|
|
487
|
-
};
|
|
488
|
-
// eslint-disable-next-line max-statements, complexity
|
|
489
|
-
function _bindExtensionObjectArrayOrMatrix(uaVariable, optionalExtensionObjectArray, options) {
|
|
490
|
-
options = options || { createMissingProp: false };
|
|
491
|
-
options.createMissingProp = options.createMissingProp || false;
|
|
492
|
-
// istanbul ignore next
|
|
493
|
-
if (uaVariable.valueRank < 1) {
|
|
494
|
-
throw new Error("Variable must be a MultiDimensional array");
|
|
495
|
-
}
|
|
496
|
-
const arrayDimensions = uaVariable.arrayDimensions || [];
|
|
497
|
-
// istanbul ignore next
|
|
498
|
-
if (!isVariableContainingExtensionObject(uaVariable)) {
|
|
499
|
-
return [];
|
|
500
|
-
}
|
|
501
|
-
if (!optionalExtensionObjectArray && uaVariable.$dataValue.value.value) {
|
|
502
|
-
(0, node_opcua_assert_1.default)(Array.isArray(uaVariable.$dataValue.value.value));
|
|
503
|
-
optionalExtensionObjectArray = uaVariable.$dataValue.value.value;
|
|
504
|
-
}
|
|
505
|
-
if ((arrayDimensions.length === 0 || arrayDimensions.length === 1 && arrayDimensions[0] === 0) && optionalExtensionObjectArray) {
|
|
506
|
-
arrayDimensions[0] = optionalExtensionObjectArray.length;
|
|
507
|
-
}
|
|
508
|
-
const totalLength = arrayDimensions.reduce((p, c) => p * c, 1);
|
|
509
|
-
/** */
|
|
510
|
-
const addressSpace = uaVariable.addressSpace;
|
|
511
|
-
if (optionalExtensionObjectArray) {
|
|
512
|
-
if (optionalExtensionObjectArray.length !== totalLength) {
|
|
513
|
-
throw new Error(`optionalExtensionObjectArray must have the expected number of element matching ${arrayDimensions}`);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
if (!optionalExtensionObjectArray) {
|
|
517
|
-
optionalExtensionObjectArray = [];
|
|
518
|
-
for (let i = 0; i < totalLength; i++) {
|
|
519
|
-
optionalExtensionObjectArray[i] = addressSpace.constructExtensionObject(uaVariable.dataType, {});
|
|
520
|
-
;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
uaVariable.$$extensionObjectArray = optionalExtensionObjectArray;
|
|
524
|
-
uaVariable.$dataValue.value.arrayType = uaVariable.valueRank === 1 ? node_opcua_variant_1.VariantArrayType.Array : node_opcua_variant_1.VariantArrayType.Matrix;
|
|
525
|
-
uaVariable.$dataValue.value.dimensions = uaVariable.valueRank === 1 ? null : (uaVariable.arrayDimensions || []);
|
|
526
|
-
uaVariable.$dataValue.value.dataType = node_opcua_variant_1.DataType.ExtensionObject;
|
|
527
|
-
uaVariable.$dataValue.value.value = uaVariable.$$extensionObjectArray;
|
|
528
|
-
// make sure uaVariable.$dataValue cannot be inadvertantly changed from this point onward
|
|
529
|
-
const $dataValue = uaVariable.$dataValue;
|
|
530
|
-
Object.defineProperty(uaVariable, "$dataValue", {
|
|
531
|
-
get() {
|
|
532
|
-
return $dataValue;
|
|
533
|
-
},
|
|
534
|
-
set() {
|
|
535
|
-
throw new Error("$dataValue is now sealed , you should not change internal $dataValue!");
|
|
536
|
-
},
|
|
537
|
-
// writable: true,
|
|
538
|
-
enumerable: true,
|
|
539
|
-
configurable: true,
|
|
540
|
-
});
|
|
541
|
-
uaVariable.bindVariable({
|
|
542
|
-
get: () => uaVariable.$dataValue.value
|
|
543
|
-
}, true);
|
|
544
|
-
const namespace = uaVariable.namespace;
|
|
545
|
-
const indexIterator = new idx_iterator_1.IndexIterator(arrayDimensions);
|
|
546
|
-
for (let i = 0; i < totalLength; i++) {
|
|
547
|
-
const index = indexIterator.next();
|
|
548
|
-
const { browseName, nodeId } = composeBrowseNameAndNodeId(uaVariable, index);
|
|
549
|
-
let uaElement = uaVariable.getComponentByName(browseName);
|
|
550
|
-
if (!uaElement) {
|
|
551
|
-
if (!options.createMissingProp) {
|
|
552
|
-
continue;
|
|
553
|
-
}
|
|
554
|
-
uaElement = namespace.addVariable({
|
|
555
|
-
browseName,
|
|
556
|
-
nodeId,
|
|
557
|
-
componentOf: uaVariable,
|
|
558
|
-
dataType: uaVariable.dataType,
|
|
559
|
-
valueRank: -1,
|
|
560
|
-
accessLevel: uaVariable.accessLevel
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
uaElement.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
564
|
-
uaElement.$dataValue.sourceTimestamp = uaVariable.$dataValue.sourceTimestamp;
|
|
565
|
-
uaElement.$dataValue.sourcePicoseconds = uaVariable.$dataValue.sourcePicoseconds;
|
|
566
|
-
uaElement.$dataValue.serverTimestamp = uaVariable.$dataValue.serverTimestamp;
|
|
567
|
-
uaElement.$dataValue.serverPicoseconds = uaVariable.$dataValue.serverPicoseconds;
|
|
568
|
-
uaElement.$dataValue.value.dataType = node_opcua_variant_1.DataType.ExtensionObject;
|
|
569
|
-
uaElement.$dataValue.value.arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
|
|
570
|
-
{
|
|
571
|
-
const capturedIndex = i;
|
|
572
|
-
const capturedUaElement = uaElement;
|
|
573
|
-
_innerBindExtensionObjectScalar(uaElement, {
|
|
574
|
-
get: () => uaVariable.$$extensionObjectArray[capturedIndex],
|
|
575
|
-
set: (newValue, sourceTimestamp, cache) => {
|
|
576
|
-
(0, node_opcua_assert_1.default)(!isProxy(uaVariable.$$extensionObjectArray[capturedIndex]));
|
|
577
|
-
uaVariable.$$extensionObjectArray[capturedIndex] = newValue;
|
|
578
|
-
if (uaVariable.$$extensionObjectArray !== uaVariable.$dataValue.value.value) {
|
|
579
|
-
console.log("uaVariable", uaVariable.nodeId.toString());
|
|
580
|
-
console.log("Houston! We have a problem ");
|
|
581
|
-
}
|
|
582
|
-
propagateTouchValueDownward(capturedUaElement, sourceTimestamp, cache);
|
|
583
|
-
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
584
|
-
},
|
|
585
|
-
setField: (fieldName, newValue, sourceTimestamp, cache) => {
|
|
586
|
-
// istanbul ignore next doDebug && debugLog("setField", fieldName, newValue, sourceTimestamp, cache);
|
|
587
|
-
const extObj = uaVariable.$$extensionObjectArray[capturedIndex];
|
|
588
|
-
(isProxy(extObj) ? getProxyTarget(extObj) : extObj)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = newValue;
|
|
589
|
-
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
590
|
-
}
|
|
591
|
-
}, Object.assign(Object.assign({}, options), { force: true }));
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
return uaVariable.$$extensionObjectArray;
|
|
595
|
-
}
|
|
596
|
-
exports._bindExtensionObjectArrayOrMatrix = _bindExtensionObjectArrayOrMatrix;
|
|
597
|
-
function getElement(path, data) {
|
|
598
|
-
if (typeof path === "string") {
|
|
599
|
-
path = path.split(".");
|
|
600
|
-
}
|
|
601
|
-
let a = data;
|
|
602
|
-
for (const e of path) {
|
|
603
|
-
a = a[e];
|
|
604
|
-
}
|
|
605
|
-
return a;
|
|
606
|
-
}
|
|
607
|
-
exports.getElement = getElement;
|
|
608
|
-
function setElement(path, data, value) {
|
|
609
|
-
if (typeof path === "string") {
|
|
610
|
-
path = path.split(".");
|
|
611
|
-
}
|
|
612
|
-
const last = path.pop();
|
|
613
|
-
let a = data;
|
|
614
|
-
for (const e of path) {
|
|
615
|
-
a = a[e];
|
|
616
|
-
}
|
|
617
|
-
a[last] = value;
|
|
618
|
-
}
|
|
619
|
-
exports.setElement = setElement;
|
|
620
|
-
function incrementElement(path, data) {
|
|
621
|
-
const value = getElement(path, data);
|
|
622
|
-
setElement(path, data, value + 1);
|
|
623
|
-
}
|
|
624
|
-
exports.incrementElement = incrementElement;
|
|
625
|
-
function extractPartialData(path, extensionObject) {
|
|
626
|
-
let name;
|
|
627
|
-
if (typeof path === "string") {
|
|
628
|
-
path = path.split(".");
|
|
629
|
-
}
|
|
630
|
-
(0, node_opcua_assert_1.default)(path instanceof Array);
|
|
631
|
-
let i;
|
|
632
|
-
// read partial value
|
|
633
|
-
const partialData = {};
|
|
634
|
-
let p = partialData;
|
|
635
|
-
for (i = 0; i < path.length - 1; i++) {
|
|
636
|
-
name = path[i];
|
|
637
|
-
p[name] = {};
|
|
638
|
-
p = p[name];
|
|
639
|
-
}
|
|
640
|
-
name = path[path.length - 1];
|
|
641
|
-
p[name] = 0;
|
|
642
|
-
let c1 = partialData;
|
|
643
|
-
let c2 = extensionObject;
|
|
644
|
-
for (i = 0; i < path.length - 1; i++) {
|
|
645
|
-
name = path[i];
|
|
646
|
-
c1 = partialData[name];
|
|
647
|
-
c2 = extensionObject[name];
|
|
648
|
-
}
|
|
649
|
-
name = path[path.length - 1];
|
|
650
|
-
c1[name] = c2[name];
|
|
651
|
-
return partialData;
|
|
652
|
-
}
|
|
653
|
-
exports.extractPartialData = extractPartialData;
|
|
654
|
-
function propagateTouchValueDownwardArray(uaVariable, now, cache) {
|
|
655
|
-
if (!uaVariable.$$extensionObjectArray)
|
|
656
|
-
return;
|
|
657
|
-
const arrayDimensions = uaVariable.arrayDimensions || [];
|
|
658
|
-
const totalLength = uaVariable.$$extensionObjectArray.length;
|
|
659
|
-
const indexIterator = new idx_iterator_1.IndexIterator(arrayDimensions);
|
|
660
|
-
for (let i = 0; i < totalLength; i++) {
|
|
661
|
-
const index = indexIterator.next();
|
|
662
|
-
const { browseName, nodeId } = composeBrowseNameAndNodeId(uaVariable, index);
|
|
663
|
-
const uaElement = uaVariable.getComponentByName(browseName);
|
|
664
|
-
if ((uaElement === null || uaElement === void 0 ? void 0 : uaElement.nodeClass) === node_opcua_data_model_1.NodeClass.Variable) {
|
|
665
|
-
uaElement.touchValue(now);
|
|
666
|
-
propagateTouchValueDownward(uaElement, now, cache);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
exports.propagateTouchValueDownwardArray = propagateTouchValueDownwardArray;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.propagateTouchValueDownwardArray = exports.extractPartialData = exports.incrementElement = exports.setElement = exports.getElement = exports._bindExtensionObjectArrayOrMatrix = exports._bindExtensionObject = exports._installExtensionObjectBindingOnProperties = exports.setExtensionObjectPartialValue = exports.propagateTouchValueDownward = exports.propagateTouchValueUpward = exports._touchValue = exports.getProxyTarget = void 0;
|
|
4
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
5
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
6
|
+
const node_opcua_date_time_1 = require("node-opcua-date-time");
|
|
7
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
8
|
+
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
9
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
10
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
11
|
+
const node_opcua_utils_1 = require("node-opcua-utils");
|
|
12
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
13
|
+
const ua_variable_impl_1 = require("./ua_variable_impl");
|
|
14
|
+
const idx_iterator_1 = require("./idx_iterator");
|
|
15
|
+
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
16
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
17
|
+
// const doDebug = true; // checkDebugFlag(__filename);
|
|
18
|
+
// const debugLog = make_warningLog(__filename);
|
|
19
|
+
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
20
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
21
|
+
function w(str, n) {
|
|
22
|
+
return str.padEnd(n).substring(n);
|
|
23
|
+
}
|
|
24
|
+
function isProxy(ext) {
|
|
25
|
+
return ext.$isProxy ? true : false;
|
|
26
|
+
}
|
|
27
|
+
function getProxyVariable(ext) {
|
|
28
|
+
(0, node_opcua_assert_1.default)(isProxy(ext));
|
|
29
|
+
return ext.$variable;
|
|
30
|
+
}
|
|
31
|
+
function getProxyVariableForProp(ext, prop) {
|
|
32
|
+
const uaVariable = getProxyVariable(ext);
|
|
33
|
+
if (!uaVariable)
|
|
34
|
+
return undefined;
|
|
35
|
+
return uaVariable[prop];
|
|
36
|
+
}
|
|
37
|
+
function getProxyTarget(ext) {
|
|
38
|
+
(0, node_opcua_assert_1.default)(isProxy(ext));
|
|
39
|
+
const target = ext.$proxyTarget;
|
|
40
|
+
if (target && isProxy(target)) {
|
|
41
|
+
return getProxyTarget(target);
|
|
42
|
+
}
|
|
43
|
+
return target;
|
|
44
|
+
}
|
|
45
|
+
exports.getProxyTarget = getProxyTarget;
|
|
46
|
+
function unProxy(ext) {
|
|
47
|
+
return isProxy(ext) ? getProxyTarget(ext) : ext;
|
|
48
|
+
}
|
|
49
|
+
function _extensionObjectFieldGetter(getVariable, target, key /*, receiver*/) {
|
|
50
|
+
if (key === "$isProxy") {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (key === "$proxyTarget") {
|
|
54
|
+
return target;
|
|
55
|
+
}
|
|
56
|
+
if (key === "$variable") {
|
|
57
|
+
return getVariable();
|
|
58
|
+
}
|
|
59
|
+
if (target[key] === undefined) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return target[key];
|
|
63
|
+
}
|
|
64
|
+
function _extensionObjectFieldSetter(getVariable, target, key, value /*, receiver*/) {
|
|
65
|
+
target[key] = value;
|
|
66
|
+
if (isProxy(target)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
const uaVariable = getVariable();
|
|
70
|
+
if (!uaVariable)
|
|
71
|
+
return true;
|
|
72
|
+
const child = uaVariable[key];
|
|
73
|
+
if (child && child.touchValue) {
|
|
74
|
+
child.touchValue();
|
|
75
|
+
}
|
|
76
|
+
return true; // true means the set operation has succeeded
|
|
77
|
+
}
|
|
78
|
+
function makeHandler(getVariable) {
|
|
79
|
+
const handler = {
|
|
80
|
+
get: _extensionObjectFieldGetter.bind(null, getVariable),
|
|
81
|
+
set: _extensionObjectFieldSetter.bind(null, getVariable)
|
|
82
|
+
};
|
|
83
|
+
return handler;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* inconditionnaly change the time stamp of the variable
|
|
87
|
+
* if the variable is being listened to, and if the minimumSamplingInterval is exactly zero,
|
|
88
|
+
* then the change will be reported to the observer
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
function _touchValue(property, now) {
|
|
92
|
+
property.$dataValue.sourceTimestamp = now.timestamp;
|
|
93
|
+
property.$dataValue.sourcePicoseconds = now.picoseconds;
|
|
94
|
+
property.$dataValue.serverTimestamp = now.timestamp;
|
|
95
|
+
property.$dataValue.serverPicoseconds = now.picoseconds;
|
|
96
|
+
property.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
97
|
+
if (property.listenerCount("value_changed") > 0) {
|
|
98
|
+
property.emit("value_changed", property.$dataValue.clone());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports._touchValue = _touchValue;
|
|
102
|
+
function propagateTouchValueUpward(self, now, cache) {
|
|
103
|
+
_touchValue(self, now);
|
|
104
|
+
if (self.parent && self.parent.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
105
|
+
const parentVar = self.parent;
|
|
106
|
+
if (!parentVar.isExtensionObject())
|
|
107
|
+
return;
|
|
108
|
+
if (cache) {
|
|
109
|
+
if (cache.has(parentVar))
|
|
110
|
+
return;
|
|
111
|
+
cache.add(parentVar);
|
|
112
|
+
}
|
|
113
|
+
propagateTouchValueUpward(parentVar, now, cache);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.propagateTouchValueUpward = propagateTouchValueUpward;
|
|
117
|
+
function propagateTouchValueDownward(self, now, cache) {
|
|
118
|
+
if (!self.isExtensionObject())
|
|
119
|
+
return;
|
|
120
|
+
// also propagate changes to embeded variables
|
|
121
|
+
const dataTypeNode = self.getDataTypeNode();
|
|
122
|
+
const definition = dataTypeNode.getStructureDefinition();
|
|
123
|
+
for (const field of definition.fields || []) {
|
|
124
|
+
const property = self.getChildByName(field.name);
|
|
125
|
+
if (property) {
|
|
126
|
+
if (cache) {
|
|
127
|
+
if (cache.has(property)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
cache.add(property);
|
|
131
|
+
}
|
|
132
|
+
_touchValue(property, now);
|
|
133
|
+
// to do cascade recursivelly ?
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.propagateTouchValueDownward = propagateTouchValueDownward;
|
|
138
|
+
function setExtensionObjectPartialValue(node, partialObject, sourceTimestamp) {
|
|
139
|
+
const variablesToUpdate = new Set();
|
|
140
|
+
const extensionObject = node.$extensionObject;
|
|
141
|
+
if (!extensionObject) {
|
|
142
|
+
throw new Error("setExtensionObjectValue node has no extension object " + node.browseName.toString());
|
|
143
|
+
}
|
|
144
|
+
function _update_extension_object(extObject, partialObject1) {
|
|
145
|
+
const keys = Object.keys(partialObject1);
|
|
146
|
+
for (const prop of keys) {
|
|
147
|
+
if (extObject[prop] instanceof Object) {
|
|
148
|
+
_update_extension_object(extObject[prop], partialObject1[prop]);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
if (isProxy(extObject)) {
|
|
152
|
+
// collect element we have to update
|
|
153
|
+
const target = getProxyTarget(extObject);
|
|
154
|
+
(0, node_opcua_assert_1.default)(!isProxy(target), "something wierd!");
|
|
155
|
+
target[prop] = partialObject1[prop];
|
|
156
|
+
const variable = getProxyVariableForProp(extObject, prop);
|
|
157
|
+
variable && variablesToUpdate.add(variable);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
extObject[prop] = partialObject1[prop];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
_update_extension_object(extensionObject, partialObject);
|
|
166
|
+
const now = sourceTimestamp || (0, node_opcua_date_time_1.getCurrentClock)();
|
|
167
|
+
const cache = new Set();
|
|
168
|
+
for (const c of variablesToUpdate) {
|
|
169
|
+
if (cache.has(c))
|
|
170
|
+
continue;
|
|
171
|
+
propagateTouchValueUpward(c, now, cache);
|
|
172
|
+
propagateTouchValueDownward(c, now, cache);
|
|
173
|
+
cache.add(c);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.setExtensionObjectPartialValue = setExtensionObjectPartialValue;
|
|
177
|
+
function getOrCreateProperty(variableNode, field, options) {
|
|
178
|
+
const dt = variableNode.getDataTypeNode();
|
|
179
|
+
// the namespace for the structure browse name elements
|
|
180
|
+
const structureNamespace = dt.nodeId.namespace;
|
|
181
|
+
const components = variableNode.getComponents();
|
|
182
|
+
let property;
|
|
183
|
+
const selectedComponents = components.filter((f) => f instanceof ua_variable_impl_1.UAVariableImpl && f.browseName.name.toString() === field.name);
|
|
184
|
+
// istanbul ignore next
|
|
185
|
+
if (field.dataType.value === node_opcua_variant_1.DataType.Variant) {
|
|
186
|
+
warningLog("Warning : variant is not supported in ExtensionObject");
|
|
187
|
+
}
|
|
188
|
+
if (selectedComponents.length === 1) {
|
|
189
|
+
property = selectedComponents[0];
|
|
190
|
+
/* istanbul ignore next */
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
if (!options.createMissingProp) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
debugLog("adding missing array variable", field.name, variableNode.browseName.toString(), variableNode.nodeId.toString());
|
|
197
|
+
// todo: Handle array appropriately...
|
|
198
|
+
(0, node_opcua_assert_1.default)(selectedComponents.length === 0);
|
|
199
|
+
// create a variable (Note we may use ns=1;s=parentName/0:PropertyName)
|
|
200
|
+
property = variableNode.namespace.addVariable({
|
|
201
|
+
browseName: { namespaceIndex: structureNamespace, name: field.name.toString() },
|
|
202
|
+
componentOf: variableNode,
|
|
203
|
+
dataType: field.dataType,
|
|
204
|
+
minimumSamplingInterval: variableNode.minimumSamplingInterval,
|
|
205
|
+
accessLevel: variableNode.accessLevel,
|
|
206
|
+
accessRestrictions: variableNode.accessRestrictions,
|
|
207
|
+
rolePermissions: variableNode.rolePermissions
|
|
208
|
+
});
|
|
209
|
+
(0, node_opcua_assert_1.default)(property.minimumSamplingInterval === variableNode.minimumSamplingInterval);
|
|
210
|
+
}
|
|
211
|
+
return property;
|
|
212
|
+
}
|
|
213
|
+
function prepareVariantValue(dataType, value) {
|
|
214
|
+
if ((dataType === node_opcua_variant_1.DataType.Int32 || dataType === node_opcua_variant_1.DataType.UInt32) && value && value.key) {
|
|
215
|
+
value = value.value;
|
|
216
|
+
}
|
|
217
|
+
return value;
|
|
218
|
+
}
|
|
219
|
+
function installExt(uaVariable, ext) {
|
|
220
|
+
ext = unProxy(ext);
|
|
221
|
+
uaVariable.$extensionObject = new Proxy(ext, makeHandler(() => uaVariable));
|
|
222
|
+
const addressSpace = uaVariable.addressSpace;
|
|
223
|
+
const definition = uaVariable.dataTypeObj.getStructureDefinition();
|
|
224
|
+
const structure = addressSpace.findDataType("Structure");
|
|
225
|
+
for (const field of definition.fields || []) {
|
|
226
|
+
if (field.dataType) {
|
|
227
|
+
const dataTypeNode = addressSpace.findDataType(field.dataType);
|
|
228
|
+
// istanbul ignore next
|
|
229
|
+
if (dataTypeNode && dataTypeNode.isSubtypeOf(structure)) {
|
|
230
|
+
// sub structure .. let make an handler too
|
|
231
|
+
const camelCaseName = (0, node_opcua_utils_1.lowerFirstLetter)(field.name);
|
|
232
|
+
const subExtObj = uaVariable.$extensionObject[camelCaseName];
|
|
233
|
+
if (subExtObj) {
|
|
234
|
+
uaVariable.$extensionObject[camelCaseName] = new Proxy(subExtObj, makeHandler(() => {
|
|
235
|
+
return uaVariable.getComponentByName(field.name);
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
doDebug && warningLog("extension object is null");
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function _installExtensionObjectBindingOnProperties(uaVariable, options) {
|
|
246
|
+
// may be extension object mechanism has alreday been install
|
|
247
|
+
// in this case we just need to rebind the properties...
|
|
248
|
+
if (uaVariable.$extensionObject) {
|
|
249
|
+
const extObj = uaVariable.$extensionObject;
|
|
250
|
+
uaVariable.bindExtensionObject(extObj, { createMissingProp: true, force: true });
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (uaVariable.$$extensionObjectArray) {
|
|
254
|
+
const extObj = uaVariable.$$extensionObjectArray;
|
|
255
|
+
_bindExtensionObjectArrayOrMatrix(uaVariable, extObj, { createMissingProp: true, force: true });
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const dataValue = uaVariable.readValue();
|
|
259
|
+
const extObj = dataValue.value.value;
|
|
260
|
+
if (extObj instanceof node_opcua_extension_object_1.ExtensionObject) {
|
|
261
|
+
uaVariable.bindExtensionObject(extObj, { createMissingProp: true, force: true });
|
|
262
|
+
}
|
|
263
|
+
else if (extObj instanceof Array) {
|
|
264
|
+
// istanbul ignore else
|
|
265
|
+
if (dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Array || dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
266
|
+
_bindExtensionObjectArrayOrMatrix(uaVariable, extObj, { createMissingProp: true, force: true });
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
throw new Error("Internal Error, unexpected case");
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports._installExtensionObjectBindingOnProperties = _installExtensionObjectBindingOnProperties;
|
|
274
|
+
function _installFields2(uaVariable, { get, set }, options) {
|
|
275
|
+
options = options || { createMissingProp: false };
|
|
276
|
+
const dt = uaVariable.getDataTypeNode();
|
|
277
|
+
const definition = dt.getStructureDefinition();
|
|
278
|
+
for (const field of definition.fields || []) {
|
|
279
|
+
if (node_opcua_nodeid_1.NodeId.sameNodeId(node_opcua_nodeid_1.NodeId.nullNodeId, field.dataType)) {
|
|
280
|
+
warningLog("field.dataType is null ! ", field.name, node_opcua_nodeid_1.NodeId.nullNodeId.toString());
|
|
281
|
+
warningLog(field.toString());
|
|
282
|
+
warningLog(" dataType replaced with BaseDataType ");
|
|
283
|
+
warningLog(definition.toString());
|
|
284
|
+
field.dataType = uaVariable.resolveNodeId("BaseDataType");
|
|
285
|
+
}
|
|
286
|
+
const propertyNode = getOrCreateProperty(uaVariable, field, options);
|
|
287
|
+
if (!propertyNode) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
propertyNode.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
291
|
+
propertyNode.$dataValue.sourceTimestamp = uaVariable.$dataValue.sourceTimestamp;
|
|
292
|
+
propertyNode.$dataValue.sourcePicoseconds = uaVariable.$dataValue.sourcePicoseconds;
|
|
293
|
+
propertyNode.$dataValue.serverTimestamp = uaVariable.$dataValue.serverTimestamp;
|
|
294
|
+
propertyNode.$dataValue.serverPicoseconds = uaVariable.$dataValue.serverPicoseconds;
|
|
295
|
+
propertyNode.$dataValue.value.dataType = propertyNode.dataTypeObj.basicDataType;
|
|
296
|
+
propertyNode.$dataValue.value.arrayType = propertyNode.valueRank === -1 ? node_opcua_variant_1.VariantArrayType.Scalar : (propertyNode.valueRank === 1 ? node_opcua_variant_1.VariantArrayType.Array : node_opcua_variant_1.VariantArrayType.Matrix);
|
|
297
|
+
propertyNode.$dataValue.value.dimensions = propertyNode.valueRank > 1 ? propertyNode.arrayDimensions : null;
|
|
298
|
+
const fieldName = field.name;
|
|
299
|
+
installDataValueGetter(propertyNode, () => get(fieldName));
|
|
300
|
+
(0, node_opcua_assert_1.default)(propertyNode._inner_replace_dataValue);
|
|
301
|
+
propertyNode._inner_replace_dataValue = (dataValue, indexRange) => {
|
|
302
|
+
/** */
|
|
303
|
+
const sourceTime = (0, node_opcua_date_time_1.coerceClock)(dataValue.sourceTimestamp, dataValue.sourcePicoseconds);
|
|
304
|
+
const value = dataValue.value.value;
|
|
305
|
+
set(field.name, value, sourceTime);
|
|
306
|
+
propertyNode.touchValue(sourceTime);
|
|
307
|
+
};
|
|
308
|
+
if (propertyNode.dataTypeObj.basicDataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
309
|
+
_installFields2(propertyNode, {
|
|
310
|
+
get: (fieldName) => {
|
|
311
|
+
const mainFieldName = field.name;
|
|
312
|
+
return get(mainFieldName)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)];
|
|
313
|
+
},
|
|
314
|
+
set: (fieldName, value, sourceTime) => {
|
|
315
|
+
const mainFieldName = field.name;
|
|
316
|
+
get(mainFieldName)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = value;
|
|
317
|
+
}
|
|
318
|
+
}, options);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function installDataValueGetter(propertyNode, get) {
|
|
323
|
+
Object.defineProperty(propertyNode.$dataValue.value, "value", { get });
|
|
324
|
+
const $ = propertyNode.$dataValue;
|
|
325
|
+
Object.defineProperty(propertyNode, "$dataValue", {
|
|
326
|
+
get() {
|
|
327
|
+
return $;
|
|
328
|
+
},
|
|
329
|
+
set: (value) => {
|
|
330
|
+
throw new Error("$dataValue is now frozen and should not be modified this way !\n contact sterfive.com");
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function isVariableContainingExtensionObject(uaVariable) {
|
|
335
|
+
const addressSpace = uaVariable.addressSpace;
|
|
336
|
+
const structure = addressSpace.findDataType("Structure");
|
|
337
|
+
if (!structure) {
|
|
338
|
+
// the addressSpace is limited and doesn't provide extension object
|
|
339
|
+
// bindExtensionObject cannot be performed and shall finish here.
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
(0, node_opcua_assert_1.default)(structure.browseName.toString() === "Structure", "expecting DataType Structure to be in IAddressSpace");
|
|
343
|
+
const dt = uaVariable.getDataTypeNode();
|
|
344
|
+
if (!dt.isSubtypeOf(structure)) {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
function _innerBindExtensionObjectScalar(uaVariable, { get, set, setField }, options) {
|
|
350
|
+
uaVariable.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
351
|
+
uaVariable.$dataValue.value.dataType = node_opcua_variant_1.DataType.ExtensionObject;
|
|
352
|
+
uaVariable.$dataValue.value.arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
|
|
353
|
+
uaVariable.setValueFromSource = function (variant) {
|
|
354
|
+
setExtensionObjectPartialValue(this, variant.value);
|
|
355
|
+
};
|
|
356
|
+
installDataValueGetter(uaVariable, get);
|
|
357
|
+
uaVariable.$set_ExtensionObject = set;
|
|
358
|
+
_installFields2(uaVariable, {
|
|
359
|
+
get: (fieldName) => {
|
|
360
|
+
const extObj = get();
|
|
361
|
+
return extObj[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)];
|
|
362
|
+
},
|
|
363
|
+
set: (fieldName, value, sourceTime) => {
|
|
364
|
+
setField(fieldName, value, sourceTime);
|
|
365
|
+
}
|
|
366
|
+
}, options);
|
|
367
|
+
}
|
|
368
|
+
// eslint-disable-next-line complexity
|
|
369
|
+
function _bindExtensionObject(uaVariable, optionalExtensionObject, options) {
|
|
370
|
+
var _a, _b;
|
|
371
|
+
options = options || { createMissingProp: false };
|
|
372
|
+
// istanbul ignore next
|
|
373
|
+
if (!isVariableContainingExtensionObject(uaVariable)) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
// istanbul ignore next
|
|
377
|
+
if (optionalExtensionObject && uaVariable.valueRank === 0) {
|
|
378
|
+
warningLog(uaVariable.browseName.toString() + ": valueRank was zero but needed to be adjusted to -1 (Scalar) in bindExtensionObject");
|
|
379
|
+
uaVariable.valueRank = -1;
|
|
380
|
+
}
|
|
381
|
+
const addressSpace = uaVariable.addressSpace;
|
|
382
|
+
let extensionObject_;
|
|
383
|
+
// istanbul ignore next
|
|
384
|
+
if (uaVariable.valueRank !== -1 && uaVariable.valueRank !== 1) {
|
|
385
|
+
throw new Error("Cannot bind an extension object here, valueRank must be scalar (-1) or one-dimensional (1)");
|
|
386
|
+
}
|
|
387
|
+
// istanbul ignore next
|
|
388
|
+
doDebug && debugLog(" ------------------------------ binding ", uaVariable.browseName.toString(), uaVariable.nodeId.toString());
|
|
389
|
+
// ignore bindExtensionObject on sub extension object, bindExtensionObject has to be called from the top most object
|
|
390
|
+
if (!options.force &&
|
|
391
|
+
uaVariable.parent &&
|
|
392
|
+
(uaVariable.parent.nodeClass === node_opcua_data_model_1.NodeClass.Variable || uaVariable.parent.nodeClass === node_opcua_data_model_1.NodeClass.VariableType)) {
|
|
393
|
+
const parentDataType = uaVariable.parent.dataType;
|
|
394
|
+
const dataTypeNode = addressSpace.findNode(parentDataType);
|
|
395
|
+
const structure = addressSpace.findDataType("Structure");
|
|
396
|
+
// istanbul ignore next
|
|
397
|
+
if (dataTypeNode && dataTypeNode.isSubtypeOf(structure)) {
|
|
398
|
+
// warningLog(
|
|
399
|
+
// "Ignoring bindExtensionObject on sub extension object",
|
|
400
|
+
// "child=",
|
|
401
|
+
// self.browseName.toString(),
|
|
402
|
+
// "parent=",
|
|
403
|
+
// self.parent.browseName.toString()
|
|
404
|
+
// );
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
// -------------------- make sure we do not bind a variable twice ....
|
|
409
|
+
if (uaVariable.$extensionObject && !optionalExtensionObject) {
|
|
410
|
+
// istanbul ignore next
|
|
411
|
+
if (!uaVariable.checkExtensionObjectIsCorrect(uaVariable.$extensionObject)) {
|
|
412
|
+
warningLog("on node : ", uaVariable.browseName.toString(), uaVariable.nodeId.toString(), "dataType=", uaVariable.dataType.toString({ addressSpace: uaVariable.addressSpace }));
|
|
413
|
+
warningLog((_a = uaVariable.$extensionObject) === null || _a === void 0 ? void 0 : _a.toString());
|
|
414
|
+
throw new Error("bindExtensionObject: $extensionObject is incorrect: we are expecting a " +
|
|
415
|
+
uaVariable.dataType.toString({ addressSpace: uaVariable.addressSpace }) +
|
|
416
|
+
" but we got a " +
|
|
417
|
+
((_b = uaVariable.$extensionObject) === null || _b === void 0 ? void 0 : _b.schema.name));
|
|
418
|
+
}
|
|
419
|
+
return uaVariable.$extensionObject;
|
|
420
|
+
}
|
|
421
|
+
// istanbul ignore next
|
|
422
|
+
if (uaVariable.dataTypeObj.isAbstract) {
|
|
423
|
+
warningLog("Warning the DataType associated with this Variable is abstract ", uaVariable.dataTypeObj.browseName.toString());
|
|
424
|
+
warningLog("You need to provide a extension object yourself ");
|
|
425
|
+
throw new Error("bindExtensionObject requires a extensionObject as associated dataType is only abstract");
|
|
426
|
+
}
|
|
427
|
+
const s = uaVariable.readValue();
|
|
428
|
+
if (s.value && s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject && s.value.value && optionalExtensionObject) {
|
|
429
|
+
// we want to replace the extension object
|
|
430
|
+
s.value.value = null;
|
|
431
|
+
}
|
|
432
|
+
innerBindExtensionObject();
|
|
433
|
+
(0, node_opcua_assert_1.default)(uaVariable.$extensionObject instanceof Object);
|
|
434
|
+
return uaVariable.$extensionObject;
|
|
435
|
+
function innerBindExtensionObject() {
|
|
436
|
+
if (s.value && (s.value.dataType === node_opcua_variant_1.DataType.Null || (s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject && !s.value.value))) {
|
|
437
|
+
if (uaVariable.valueRank === -1 /** Scalar */) {
|
|
438
|
+
extensionObject_ = optionalExtensionObject || addressSpace.constructExtensionObject(uaVariable.dataType, {});
|
|
439
|
+
installExt(uaVariable, extensionObject_);
|
|
440
|
+
_innerBindExtensionObjectScalar(uaVariable, {
|
|
441
|
+
get: () => uaVariable.$extensionObject,
|
|
442
|
+
set: (value) => installExt(uaVariable, value),
|
|
443
|
+
setField: (fieldName, value) => {
|
|
444
|
+
const extObj = uaVariable.$extensionObject;
|
|
445
|
+
getProxyTarget(extObj)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = value;
|
|
446
|
+
}
|
|
447
|
+
}, options);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
else if (uaVariable.valueRank === 1 /** Array */) {
|
|
451
|
+
throw new Error("Should not get there ! Please fix me");
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
errorLog(uaVariable.toString());
|
|
455
|
+
errorLog("Unsupported case ! valueRank= ", uaVariable.valueRank);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
// verify that variant has the correct type
|
|
460
|
+
(0, node_opcua_assert_1.default)(s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject);
|
|
461
|
+
installExt(uaVariable, s.value.value);
|
|
462
|
+
_innerBindExtensionObjectScalar(uaVariable, {
|
|
463
|
+
get: () => uaVariable.$extensionObject,
|
|
464
|
+
set: (value) => installExt(uaVariable, value),
|
|
465
|
+
setField: (fieldName, value) => {
|
|
466
|
+
const extObj = uaVariable.$extensionObject;
|
|
467
|
+
getProxyTarget(extObj)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = value;
|
|
468
|
+
}
|
|
469
|
+
}, options);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
exports._bindExtensionObject = _bindExtensionObject;
|
|
474
|
+
const getIndexAsText = (index) => {
|
|
475
|
+
if (typeof index === "number")
|
|
476
|
+
return `${index}`;
|
|
477
|
+
return `${index.map((a) => a.toString()).join(",")}`;
|
|
478
|
+
};
|
|
479
|
+
const composeBrowseNameAndNodeId = (uaVariable, indexes) => {
|
|
480
|
+
const iAsText = getIndexAsText(indexes);
|
|
481
|
+
const browseName = (0, node_opcua_data_model_1.coerceQualifiedName)(iAsText);
|
|
482
|
+
let nodeId;
|
|
483
|
+
if (uaVariable.nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.STRING) {
|
|
484
|
+
nodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.STRING, uaVariable.nodeId.value + `[${iAsText}]`, uaVariable.nodeId.namespace);
|
|
485
|
+
}
|
|
486
|
+
return { browseName, nodeId };
|
|
487
|
+
};
|
|
488
|
+
// eslint-disable-next-line max-statements, complexity
|
|
489
|
+
function _bindExtensionObjectArrayOrMatrix(uaVariable, optionalExtensionObjectArray, options) {
|
|
490
|
+
options = options || { createMissingProp: false };
|
|
491
|
+
options.createMissingProp = options.createMissingProp || false;
|
|
492
|
+
// istanbul ignore next
|
|
493
|
+
if (uaVariable.valueRank < 1) {
|
|
494
|
+
throw new Error("Variable must be a MultiDimensional array");
|
|
495
|
+
}
|
|
496
|
+
const arrayDimensions = uaVariable.arrayDimensions || [];
|
|
497
|
+
// istanbul ignore next
|
|
498
|
+
if (!isVariableContainingExtensionObject(uaVariable)) {
|
|
499
|
+
return [];
|
|
500
|
+
}
|
|
501
|
+
if (!optionalExtensionObjectArray && uaVariable.$dataValue.value.value) {
|
|
502
|
+
(0, node_opcua_assert_1.default)(Array.isArray(uaVariable.$dataValue.value.value));
|
|
503
|
+
optionalExtensionObjectArray = uaVariable.$dataValue.value.value;
|
|
504
|
+
}
|
|
505
|
+
if ((arrayDimensions.length === 0 || arrayDimensions.length === 1 && arrayDimensions[0] === 0) && optionalExtensionObjectArray) {
|
|
506
|
+
arrayDimensions[0] = optionalExtensionObjectArray.length;
|
|
507
|
+
}
|
|
508
|
+
const totalLength = arrayDimensions.reduce((p, c) => p * c, 1);
|
|
509
|
+
/** */
|
|
510
|
+
const addressSpace = uaVariable.addressSpace;
|
|
511
|
+
if (optionalExtensionObjectArray) {
|
|
512
|
+
if (optionalExtensionObjectArray.length !== totalLength) {
|
|
513
|
+
throw new Error(`optionalExtensionObjectArray must have the expected number of element matching ${arrayDimensions}`);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
if (!optionalExtensionObjectArray) {
|
|
517
|
+
optionalExtensionObjectArray = [];
|
|
518
|
+
for (let i = 0; i < totalLength; i++) {
|
|
519
|
+
optionalExtensionObjectArray[i] = addressSpace.constructExtensionObject(uaVariable.dataType, {});
|
|
520
|
+
;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
uaVariable.$$extensionObjectArray = optionalExtensionObjectArray;
|
|
524
|
+
uaVariable.$dataValue.value.arrayType = uaVariable.valueRank === 1 ? node_opcua_variant_1.VariantArrayType.Array : node_opcua_variant_1.VariantArrayType.Matrix;
|
|
525
|
+
uaVariable.$dataValue.value.dimensions = uaVariable.valueRank === 1 ? null : (uaVariable.arrayDimensions || []);
|
|
526
|
+
uaVariable.$dataValue.value.dataType = node_opcua_variant_1.DataType.ExtensionObject;
|
|
527
|
+
uaVariable.$dataValue.value.value = uaVariable.$$extensionObjectArray;
|
|
528
|
+
// make sure uaVariable.$dataValue cannot be inadvertantly changed from this point onward
|
|
529
|
+
const $dataValue = uaVariable.$dataValue;
|
|
530
|
+
Object.defineProperty(uaVariable, "$dataValue", {
|
|
531
|
+
get() {
|
|
532
|
+
return $dataValue;
|
|
533
|
+
},
|
|
534
|
+
set() {
|
|
535
|
+
throw new Error("$dataValue is now sealed , you should not change internal $dataValue!");
|
|
536
|
+
},
|
|
537
|
+
// writable: true,
|
|
538
|
+
enumerable: true,
|
|
539
|
+
configurable: true,
|
|
540
|
+
});
|
|
541
|
+
uaVariable.bindVariable({
|
|
542
|
+
get: () => uaVariable.$dataValue.value
|
|
543
|
+
}, true);
|
|
544
|
+
const namespace = uaVariable.namespace;
|
|
545
|
+
const indexIterator = new idx_iterator_1.IndexIterator(arrayDimensions);
|
|
546
|
+
for (let i = 0; i < totalLength; i++) {
|
|
547
|
+
const index = indexIterator.next();
|
|
548
|
+
const { browseName, nodeId } = composeBrowseNameAndNodeId(uaVariable, index);
|
|
549
|
+
let uaElement = uaVariable.getComponentByName(browseName);
|
|
550
|
+
if (!uaElement) {
|
|
551
|
+
if (!options.createMissingProp) {
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
uaElement = namespace.addVariable({
|
|
555
|
+
browseName,
|
|
556
|
+
nodeId,
|
|
557
|
+
componentOf: uaVariable,
|
|
558
|
+
dataType: uaVariable.dataType,
|
|
559
|
+
valueRank: -1,
|
|
560
|
+
accessLevel: uaVariable.accessLevel
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
uaElement.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
564
|
+
uaElement.$dataValue.sourceTimestamp = uaVariable.$dataValue.sourceTimestamp;
|
|
565
|
+
uaElement.$dataValue.sourcePicoseconds = uaVariable.$dataValue.sourcePicoseconds;
|
|
566
|
+
uaElement.$dataValue.serverTimestamp = uaVariable.$dataValue.serverTimestamp;
|
|
567
|
+
uaElement.$dataValue.serverPicoseconds = uaVariable.$dataValue.serverPicoseconds;
|
|
568
|
+
uaElement.$dataValue.value.dataType = node_opcua_variant_1.DataType.ExtensionObject;
|
|
569
|
+
uaElement.$dataValue.value.arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
|
|
570
|
+
{
|
|
571
|
+
const capturedIndex = i;
|
|
572
|
+
const capturedUaElement = uaElement;
|
|
573
|
+
_innerBindExtensionObjectScalar(uaElement, {
|
|
574
|
+
get: () => uaVariable.$$extensionObjectArray[capturedIndex],
|
|
575
|
+
set: (newValue, sourceTimestamp, cache) => {
|
|
576
|
+
(0, node_opcua_assert_1.default)(!isProxy(uaVariable.$$extensionObjectArray[capturedIndex]));
|
|
577
|
+
uaVariable.$$extensionObjectArray[capturedIndex] = newValue;
|
|
578
|
+
if (uaVariable.$$extensionObjectArray !== uaVariable.$dataValue.value.value) {
|
|
579
|
+
console.log("uaVariable", uaVariable.nodeId.toString());
|
|
580
|
+
console.log("Houston! We have a problem ");
|
|
581
|
+
}
|
|
582
|
+
propagateTouchValueDownward(capturedUaElement, sourceTimestamp, cache);
|
|
583
|
+
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
584
|
+
},
|
|
585
|
+
setField: (fieldName, newValue, sourceTimestamp, cache) => {
|
|
586
|
+
// istanbul ignore next doDebug && debugLog("setField", fieldName, newValue, sourceTimestamp, cache);
|
|
587
|
+
const extObj = uaVariable.$$extensionObjectArray[capturedIndex];
|
|
588
|
+
(isProxy(extObj) ? getProxyTarget(extObj) : extObj)[(0, node_opcua_utils_1.lowerFirstLetter)(fieldName)] = newValue;
|
|
589
|
+
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
590
|
+
}
|
|
591
|
+
}, Object.assign(Object.assign({}, options), { force: true }));
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return uaVariable.$$extensionObjectArray;
|
|
595
|
+
}
|
|
596
|
+
exports._bindExtensionObjectArrayOrMatrix = _bindExtensionObjectArrayOrMatrix;
|
|
597
|
+
function getElement(path, data) {
|
|
598
|
+
if (typeof path === "string") {
|
|
599
|
+
path = path.split(".");
|
|
600
|
+
}
|
|
601
|
+
let a = data;
|
|
602
|
+
for (const e of path) {
|
|
603
|
+
a = a[e];
|
|
604
|
+
}
|
|
605
|
+
return a;
|
|
606
|
+
}
|
|
607
|
+
exports.getElement = getElement;
|
|
608
|
+
function setElement(path, data, value) {
|
|
609
|
+
if (typeof path === "string") {
|
|
610
|
+
path = path.split(".");
|
|
611
|
+
}
|
|
612
|
+
const last = path.pop();
|
|
613
|
+
let a = data;
|
|
614
|
+
for (const e of path) {
|
|
615
|
+
a = a[e];
|
|
616
|
+
}
|
|
617
|
+
a[last] = value;
|
|
618
|
+
}
|
|
619
|
+
exports.setElement = setElement;
|
|
620
|
+
function incrementElement(path, data) {
|
|
621
|
+
const value = getElement(path, data);
|
|
622
|
+
setElement(path, data, value + 1);
|
|
623
|
+
}
|
|
624
|
+
exports.incrementElement = incrementElement;
|
|
625
|
+
function extractPartialData(path, extensionObject) {
|
|
626
|
+
let name;
|
|
627
|
+
if (typeof path === "string") {
|
|
628
|
+
path = path.split(".");
|
|
629
|
+
}
|
|
630
|
+
(0, node_opcua_assert_1.default)(path instanceof Array);
|
|
631
|
+
let i;
|
|
632
|
+
// read partial value
|
|
633
|
+
const partialData = {};
|
|
634
|
+
let p = partialData;
|
|
635
|
+
for (i = 0; i < path.length - 1; i++) {
|
|
636
|
+
name = path[i];
|
|
637
|
+
p[name] = {};
|
|
638
|
+
p = p[name];
|
|
639
|
+
}
|
|
640
|
+
name = path[path.length - 1];
|
|
641
|
+
p[name] = 0;
|
|
642
|
+
let c1 = partialData;
|
|
643
|
+
let c2 = extensionObject;
|
|
644
|
+
for (i = 0; i < path.length - 1; i++) {
|
|
645
|
+
name = path[i];
|
|
646
|
+
c1 = partialData[name];
|
|
647
|
+
c2 = extensionObject[name];
|
|
648
|
+
}
|
|
649
|
+
name = path[path.length - 1];
|
|
650
|
+
c1[name] = c2[name];
|
|
651
|
+
return partialData;
|
|
652
|
+
}
|
|
653
|
+
exports.extractPartialData = extractPartialData;
|
|
654
|
+
function propagateTouchValueDownwardArray(uaVariable, now, cache) {
|
|
655
|
+
if (!uaVariable.$$extensionObjectArray)
|
|
656
|
+
return;
|
|
657
|
+
const arrayDimensions = uaVariable.arrayDimensions || [];
|
|
658
|
+
const totalLength = uaVariable.$$extensionObjectArray.length;
|
|
659
|
+
const indexIterator = new idx_iterator_1.IndexIterator(arrayDimensions);
|
|
660
|
+
for (let i = 0; i < totalLength; i++) {
|
|
661
|
+
const index = indexIterator.next();
|
|
662
|
+
const { browseName, nodeId } = composeBrowseNameAndNodeId(uaVariable, index);
|
|
663
|
+
const uaElement = uaVariable.getComponentByName(browseName);
|
|
664
|
+
if ((uaElement === null || uaElement === void 0 ? void 0 : uaElement.nodeClass) === node_opcua_data_model_1.NodeClass.Variable) {
|
|
665
|
+
uaElement.touchValue(now);
|
|
666
|
+
propagateTouchValueDownward(uaElement, now, cache);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
exports.propagateTouchValueDownwardArray = propagateTouchValueDownwardArray;
|
|
671
671
|
//# sourceMappingURL=ua_variable_impl_ext_obj.js.map
|