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