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,1144 +1,1144 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dumpXml = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opcua-address-space
|
|
6
|
-
*/
|
|
7
|
-
// produce nodeset xml files
|
|
8
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
10
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
11
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
12
|
-
const utils = require("node-opcua-utils");
|
|
13
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
14
|
-
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
15
|
-
const node_opcua_types_1 = require("node-opcua-types");
|
|
16
|
-
const reference_impl_1 = require("../reference_impl");
|
|
17
|
-
const base_node_impl_1 = require("../base_node_impl");
|
|
18
|
-
const ua_reference_type_impl_1 = require("../ua_reference_type_impl");
|
|
19
|
-
const ua_object_type_impl_1 = require("../ua_object_type_impl");
|
|
20
|
-
const ua_variable_impl_1 = require("../ua_variable_impl");
|
|
21
|
-
const ua_object_impl_1 = require("../ua_object_impl");
|
|
22
|
-
const namespace_impl_1 = require("../namespace_impl");
|
|
23
|
-
const ua_method_impl_1 = require("../ua_method_impl");
|
|
24
|
-
const ua_data_type_impl_1 = require("../ua_data_type_impl");
|
|
25
|
-
const ua_variable_type_impl_1 = require("../ua_variable_type_impl");
|
|
26
|
-
const decode_xml_extension_object_1 = require("../../source/loader/decode_xml_extension_object");
|
|
27
|
-
const construct_namespace_dependency_1 = require("./construct_namespace_dependency");
|
|
28
|
-
// tslint:disable:no-var-requires
|
|
29
|
-
const XMLWriter = require("xml-writer");
|
|
30
|
-
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
31
|
-
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
32
|
-
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
33
|
-
function _hash(node) {
|
|
34
|
-
return node.nodeId.toString();
|
|
35
|
-
}
|
|
36
|
-
function _dumpDisplayName(xw, node) {
|
|
37
|
-
if (node.displayName && node.displayName[0]) {
|
|
38
|
-
xw.startElement("DisplayName").text(node.displayName[0].text).endElement();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function _dumpDescription(xw, node) {
|
|
42
|
-
if (node.description && node.description.text && node.description.text.length) {
|
|
43
|
-
let desc = node.description.text;
|
|
44
|
-
desc = desc || "";
|
|
45
|
-
xw.startElement("Description").text(desc).endElement();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function translateNodeId(xw, nodeId) {
|
|
49
|
-
(0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
50
|
-
const nn = xw.translationTable[nodeId.namespace];
|
|
51
|
-
const translatedNode = new node_opcua_nodeid_1.NodeId(nodeId.identifierType, nodeId.value, nn);
|
|
52
|
-
return translatedNode;
|
|
53
|
-
}
|
|
54
|
-
function n(xw, nodeId) {
|
|
55
|
-
return translateNodeId(xw, nodeId).toString().replace("ns=0;", "");
|
|
56
|
-
}
|
|
57
|
-
function translateBrowseName(xw, browseName) {
|
|
58
|
-
(0, node_opcua_assert_1.assert)(browseName instanceof node_opcua_data_model_1.QualifiedName);
|
|
59
|
-
const nn = xw.translationTable[browseName.namespaceIndex];
|
|
60
|
-
const translatedBrowseName = new node_opcua_data_model_1.QualifiedName({ namespaceIndex: nn, name: browseName.name });
|
|
61
|
-
return translatedBrowseName;
|
|
62
|
-
}
|
|
63
|
-
function b(xw, browseName) {
|
|
64
|
-
return translateBrowseName(xw, browseName).toString().replace("ns=0;", "");
|
|
65
|
-
}
|
|
66
|
-
function _dumpReferences(xw, node) {
|
|
67
|
-
xw.startElement("References");
|
|
68
|
-
const addressSpace = node.addressSpace;
|
|
69
|
-
const aggregateReferenceType = addressSpace.findReferenceType("Aggregates");
|
|
70
|
-
const hasChildReferenceType = addressSpace.findReferenceType("HasChild");
|
|
71
|
-
const hasSubtypeReferenceType = addressSpace.findReferenceType("HasSubtype");
|
|
72
|
-
const hasTypeDefinitionReferenceType = addressSpace.findReferenceType("HasTypeDefinition");
|
|
73
|
-
const nonHierarchicalReferencesType = addressSpace.findReferenceType("NonHierarchicalReferences");
|
|
74
|
-
const organizesReferencesType = addressSpace.findReferenceType("Organizes");
|
|
75
|
-
const connectsToReferenceType = addressSpace.findReferenceType("ConnectsTo");
|
|
76
|
-
const hasEventSourceReferenceType = addressSpace.findReferenceType("HasEventSource");
|
|
77
|
-
function referenceToKeep(reference) {
|
|
78
|
-
const referenceType = reference._referenceType;
|
|
79
|
-
// get the direct backward reference to a external namespace
|
|
80
|
-
if (referenceType.isSupertypeOf(aggregateReferenceType) && !reference.isForward) {
|
|
81
|
-
if (reference.nodeId.namespace !== node.nodeId.namespace) {
|
|
82
|
-
// todo: may be check that reference.nodeId.namespace is one of the namespace
|
|
83
|
-
// on which our namespace is build and not a derived one !
|
|
84
|
-
// xx console.log("xxxxxxxxxxxxxx Keeping => ", referenceType.toString(), reference.node?.nodeId.toString());
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// only keep
|
|
89
|
-
if (referenceType.isSupertypeOf(aggregateReferenceType) && reference.isForward) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
else if (referenceType.isSupertypeOf(hasSubtypeReferenceType) && !reference.isForward) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
else if (referenceType.isSupertypeOf(hasTypeDefinitionReferenceType) && reference.isForward) {
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
else if (referenceType.isSupertypeOf(nonHierarchicalReferencesType) && reference.isForward) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
else if (referenceType.isSupertypeOf(organizesReferencesType) && !reference.isForward) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
else if (connectsToReferenceType && referenceType.isSupertypeOf(connectsToReferenceType) && reference.isForward) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
else if (referenceType.isSupertypeOf(hasEventSourceReferenceType) && reference.isForward) {
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
const references = node.allReferences().filter(referenceToKeep);
|
|
113
|
-
for (const reference of references.sort(sortByNodeId)) {
|
|
114
|
-
if ((0, base_node_impl_1.getReferenceType)(reference).browseName.toString() === "HasSubtype" && reference.isForward) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
// only output inverse Reference
|
|
118
|
-
xw.startElement("Reference");
|
|
119
|
-
xw.writeAttribute("ReferenceType", b(xw, (0, base_node_impl_1.getReferenceType)(reference).browseName));
|
|
120
|
-
if (!reference.isForward) {
|
|
121
|
-
xw.writeAttribute("IsForward", reference.isForward ? "true" : "false");
|
|
122
|
-
}
|
|
123
|
-
xw.text(n(xw, reference.nodeId));
|
|
124
|
-
xw.endElement();
|
|
125
|
-
}
|
|
126
|
-
xw.endElement();
|
|
127
|
-
}
|
|
128
|
-
function _dumpLocalizedText(xw, v) {
|
|
129
|
-
if (v.locale && v.locale.length) {
|
|
130
|
-
xw.startElement("Locale");
|
|
131
|
-
xw.text(v.locale);
|
|
132
|
-
xw.endElement();
|
|
133
|
-
}
|
|
134
|
-
xw.startElement("Text");
|
|
135
|
-
if (v.text) {
|
|
136
|
-
xw.text(v.text);
|
|
137
|
-
}
|
|
138
|
-
xw.endElement();
|
|
139
|
-
}
|
|
140
|
-
function _dumpQualifiedName(xw, v) {
|
|
141
|
-
const t = translateBrowseName(xw, v);
|
|
142
|
-
if (t.name) {
|
|
143
|
-
xw.startElement("Name");
|
|
144
|
-
xw.text(t.name);
|
|
145
|
-
xw.endElement();
|
|
146
|
-
}
|
|
147
|
-
if (t.namespaceIndex) {
|
|
148
|
-
xw.startElement("NamespaceIndex");
|
|
149
|
-
xw.text(t.namespaceIndex.toString());
|
|
150
|
-
xw.endElement();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function _dumpXmlElement(xw, v) {
|
|
154
|
-
xw.text(v);
|
|
155
|
-
}
|
|
156
|
-
/*
|
|
157
|
-
<uax:ExtensionObject>
|
|
158
|
-
<uax:TypeId>
|
|
159
|
-
<uax:Identifier>i=339</uax:Identifier>
|
|
160
|
-
</uax:TypeId>
|
|
161
|
-
<uax:Body>
|
|
162
|
-
<BuildInfo xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
|
|
163
|
-
<ProductUri></ProductUri>
|
|
164
|
-
<ManufacturerName></ManufacturerName>
|
|
165
|
-
<ProductName></ProductName>
|
|
166
|
-
<SoftwareVersion></SoftwareVersion>
|
|
167
|
-
<BuildNumber></BuildNumber>
|
|
168
|
-
<BuildDate>1900-01-01T00:00:00Z</BuildDate>
|
|
169
|
-
</BuildInfo>
|
|
170
|
-
</uax:Body>
|
|
171
|
-
</uax:ExtensionObject>
|
|
172
|
-
*/
|
|
173
|
-
function _dumpNodeId(xw, v) {
|
|
174
|
-
xw.startElement("Identifier");
|
|
175
|
-
xw.text(n(xw, v));
|
|
176
|
-
xw.endElement();
|
|
177
|
-
}
|
|
178
|
-
// eslint-disable-next-line complexity
|
|
179
|
-
function _dumpVariantValue(xw, dataType, node, value) {
|
|
180
|
-
const dataTypeNode = node.addressSpace.findDataType(node.dataType);
|
|
181
|
-
if (value === undefined || value === null) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (dataType === node_opcua_variant_1.DataType.Null) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
xw.startElement(node_opcua_variant_1.DataType[dataType]);
|
|
188
|
-
const definitionMap = (0, decode_xml_extension_object_1.makeDefinitionMap)(node.addressSpace);
|
|
189
|
-
_dumpVariantInnerValue(xw, dataType, dataTypeNode.nodeId, definitionMap, value);
|
|
190
|
-
xw.endElement();
|
|
191
|
-
}
|
|
192
|
-
function _dumpVariantInnerExtensionObject(xw, definitionMap, definition, value) {
|
|
193
|
-
for (const field of definition.fields || []) {
|
|
194
|
-
const dataTypeNodeId = field.dataType;
|
|
195
|
-
const fieldName = field.name;
|
|
196
|
-
const lowerFieldName = utils.lowerFirstLetter(fieldName);
|
|
197
|
-
const v = value[lowerFieldName];
|
|
198
|
-
if (v !== null && v !== undefined) {
|
|
199
|
-
if (dataTypeNodeId.namespace === 0 &&
|
|
200
|
-
dataTypeNodeId.value === 0 &&
|
|
201
|
-
dataTypeNodeId.identifierType === node_opcua_nodeid_1.NodeIdType.NUMERIC) {
|
|
202
|
-
// to do ?? shall we do a extension Object here ?
|
|
203
|
-
continue; // ns=0;i=0 is reserved
|
|
204
|
-
}
|
|
205
|
-
const { name, definition } = definitionMap.findDefinition(dataTypeNodeId);
|
|
206
|
-
xw.startElement(fieldName);
|
|
207
|
-
let fun = (value) => {
|
|
208
|
-
/** */
|
|
209
|
-
};
|
|
210
|
-
if (definition instanceof node_opcua_types_1.StructureDefinition) {
|
|
211
|
-
fun = _dumpVariantInnerExtensionObject.bind(null, xw, definitionMap, definition);
|
|
212
|
-
}
|
|
213
|
-
else if (definition instanceof node_opcua_types_1.EnumDefinition) {
|
|
214
|
-
fun = _dumpVariantInnerValueEnum.bind(null, xw, definition);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
const baseType = definition.dataType;
|
|
218
|
-
fun = _dumpVariantInnerValue.bind(null, xw, baseType, dataTypeNodeId, definitionMap);
|
|
219
|
-
}
|
|
220
|
-
try {
|
|
221
|
-
if (field.valueRank === -1) {
|
|
222
|
-
fun(v);
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
// array
|
|
226
|
-
for (const arrayItem of v) {
|
|
227
|
-
xw.startElement(name);
|
|
228
|
-
fun(arrayItem);
|
|
229
|
-
xw.endElement();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
catch (err) {
|
|
234
|
-
// eslint-disable-next-line max-depth
|
|
235
|
-
if (err instanceof Error) {
|
|
236
|
-
errorLog("Error in _dumpVariantExtensionObjectValue_Body !!!", err.message);
|
|
237
|
-
}
|
|
238
|
-
console.log(name);
|
|
239
|
-
console.log(field);
|
|
240
|
-
// throw err;
|
|
241
|
-
}
|
|
242
|
-
xw.endElement();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function _dumpVariantInnerValueEnum(xw, definition, value) {
|
|
247
|
-
if (!definition.fields) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
const field = definition.fields.find((f) => f.value[1] === value);
|
|
251
|
-
xw.text(`${field === null || field === void 0 ? void 0 : field.name}_${value}`);
|
|
252
|
-
}
|
|
253
|
-
// eslint-disable-next-line complexity
|
|
254
|
-
function _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, value) {
|
|
255
|
-
switch (dataType) {
|
|
256
|
-
case null:
|
|
257
|
-
case node_opcua_variant_1.DataType.Null:
|
|
258
|
-
break;
|
|
259
|
-
case node_opcua_variant_1.DataType.LocalizedText:
|
|
260
|
-
_dumpLocalizedText(xw, value);
|
|
261
|
-
break;
|
|
262
|
-
case node_opcua_variant_1.DataType.QualifiedName:
|
|
263
|
-
_dumpQualifiedName(xw, value);
|
|
264
|
-
break;
|
|
265
|
-
case node_opcua_variant_1.DataType.NodeId:
|
|
266
|
-
_dumpNodeId(xw, value);
|
|
267
|
-
break;
|
|
268
|
-
case node_opcua_variant_1.DataType.DateTime:
|
|
269
|
-
xw.text(value.toISOString());
|
|
270
|
-
break;
|
|
271
|
-
case node_opcua_variant_1.DataType.Int64:
|
|
272
|
-
case node_opcua_variant_1.DataType.UInt64:
|
|
273
|
-
xw.text(value[1].toString());
|
|
274
|
-
break;
|
|
275
|
-
case node_opcua_variant_1.DataType.Boolean:
|
|
276
|
-
case node_opcua_variant_1.DataType.SByte:
|
|
277
|
-
case node_opcua_variant_1.DataType.Byte:
|
|
278
|
-
case node_opcua_variant_1.DataType.SByte:
|
|
279
|
-
case node_opcua_variant_1.DataType.Float:
|
|
280
|
-
case node_opcua_variant_1.DataType.Double:
|
|
281
|
-
case node_opcua_variant_1.DataType.Int16:
|
|
282
|
-
case node_opcua_variant_1.DataType.Int32:
|
|
283
|
-
case node_opcua_variant_1.DataType.UInt16:
|
|
284
|
-
case node_opcua_variant_1.DataType.UInt32:
|
|
285
|
-
case node_opcua_variant_1.DataType.String:
|
|
286
|
-
xw.text(value.toString());
|
|
287
|
-
break;
|
|
288
|
-
case node_opcua_variant_1.DataType.ByteString:
|
|
289
|
-
{
|
|
290
|
-
const base64 = value.toString("base64");
|
|
291
|
-
xw.text(base64.length > 80 ? base64.match(/.{0,80}/g).join("\n") : base64);
|
|
292
|
-
}
|
|
293
|
-
break;
|
|
294
|
-
case node_opcua_variant_1.DataType.Guid:
|
|
295
|
-
/*
|
|
296
|
-
<uax:Guid>
|
|
297
|
-
<uax:String>947c29a7-490d-4dc9-adda-1109e3e8fcb7</uax:String>
|
|
298
|
-
</uax:Guid>
|
|
299
|
-
*/
|
|
300
|
-
if (value !== undefined && value !== null) {
|
|
301
|
-
// xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
302
|
-
xw.startElement("String");
|
|
303
|
-
xw.text(value.toString());
|
|
304
|
-
xw.endElement();
|
|
305
|
-
}
|
|
306
|
-
break;
|
|
307
|
-
case node_opcua_variant_1.DataType.ExtensionObject:
|
|
308
|
-
_dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, value);
|
|
309
|
-
break;
|
|
310
|
-
case node_opcua_variant_1.DataType.XmlElement:
|
|
311
|
-
_dumpXmlElement(xw, value);
|
|
312
|
-
break;
|
|
313
|
-
case node_opcua_variant_1.DataType.StatusCode:
|
|
314
|
-
xw.text(value.value.toString());
|
|
315
|
-
break;
|
|
316
|
-
default:
|
|
317
|
-
errorLog("_dumpVariantInnerValue incomplete " + value + " " + "DataType=" + dataType + "=" + node_opcua_variant_1.DataType[dataType]);
|
|
318
|
-
// throw new Error("_dumpVariantInnerValue incomplete " + value + " " + "DataType=" + dataType + "=" + DataType[dataType]);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
*
|
|
323
|
-
* @param xw
|
|
324
|
-
* @param schema
|
|
325
|
-
* @param value
|
|
326
|
-
* @private
|
|
327
|
-
*/
|
|
328
|
-
function _dumpVariantExtensionObjectValue_Body(xw, definitionMap, name, definition, value) {
|
|
329
|
-
if (value) {
|
|
330
|
-
xw.startElement(name);
|
|
331
|
-
if (value) {
|
|
332
|
-
_dumpVariantInnerExtensionObject(xw, definitionMap, definition, value);
|
|
333
|
-
}
|
|
334
|
-
xw.endElement();
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
function _dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, value) {
|
|
338
|
-
const { name, definition } = definitionMap.findDefinition(dataTypeNodeId);
|
|
339
|
-
// const encodingDefaultXml = (getStructureTypeConstructor(schema.name) as any).encodingDefaultXml;
|
|
340
|
-
const encodingDefaultXml = value.schema.encodingDefaultXml;
|
|
341
|
-
if (!encodingDefaultXml) {
|
|
342
|
-
// throw new Error("Extension Object doesn't provide a XML ");
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
xw.startElement("ExtensionObject");
|
|
346
|
-
{
|
|
347
|
-
xw.startElement("TypeId");
|
|
348
|
-
{
|
|
349
|
-
// find HasEncoding node
|
|
350
|
-
// xx var encodingDefaultXml = schema.encodingDefaultXml;
|
|
351
|
-
xw.startElement("Identifier");
|
|
352
|
-
xw.text(n(xw, encodingDefaultXml));
|
|
353
|
-
xw.endElement();
|
|
354
|
-
}
|
|
355
|
-
xw.endElement();
|
|
356
|
-
xw.startElement("Body");
|
|
357
|
-
_dumpVariantExtensionObjectValue_Body(xw, definitionMap, name, definition, value);
|
|
358
|
-
xw.endElement();
|
|
359
|
-
}
|
|
360
|
-
xw.endElement();
|
|
361
|
-
}
|
|
362
|
-
function _dumpVariantExtensionObjectValue2(xw, dataTypeNode, value) {
|
|
363
|
-
const addressSpace = dataTypeNode.addressSpace;
|
|
364
|
-
const definitionMap = (0, decode_xml_extension_object_1.makeDefinitionMap)(addressSpace);
|
|
365
|
-
_dumpVariantExtensionObjectValue(xw, dataTypeNode.nodeId, definitionMap, value);
|
|
366
|
-
}
|
|
367
|
-
// eslint-disable-next-line complexity
|
|
368
|
-
function _isDefaultValue(value) {
|
|
369
|
-
// detect default value
|
|
370
|
-
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
371
|
-
switch (value.dataType) {
|
|
372
|
-
case node_opcua_variant_1.DataType.ExtensionObject:
|
|
373
|
-
if (!value.value) {
|
|
374
|
-
return true;
|
|
375
|
-
}
|
|
376
|
-
break;
|
|
377
|
-
case node_opcua_variant_1.DataType.DateTime:
|
|
378
|
-
if (!value.value || value.value.getTime() === node_opcua_basic_types_1.minOPCUADate) {
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
break;
|
|
382
|
-
case node_opcua_variant_1.DataType.ByteString:
|
|
383
|
-
if (!value.value || value.value.length === 0) {
|
|
384
|
-
return true;
|
|
385
|
-
}
|
|
386
|
-
break;
|
|
387
|
-
case node_opcua_variant_1.DataType.Boolean:
|
|
388
|
-
if (!value.value) {
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
391
|
-
break;
|
|
392
|
-
case node_opcua_variant_1.DataType.SByte:
|
|
393
|
-
case node_opcua_variant_1.DataType.Byte:
|
|
394
|
-
case node_opcua_variant_1.DataType.UInt16:
|
|
395
|
-
case node_opcua_variant_1.DataType.UInt32:
|
|
396
|
-
case node_opcua_variant_1.DataType.Int16:
|
|
397
|
-
case node_opcua_variant_1.DataType.Int32:
|
|
398
|
-
case node_opcua_variant_1.DataType.Double:
|
|
399
|
-
case node_opcua_variant_1.DataType.Float:
|
|
400
|
-
if (value.value === 0 || value.value === null) {
|
|
401
|
-
return true;
|
|
402
|
-
}
|
|
403
|
-
break;
|
|
404
|
-
case node_opcua_variant_1.DataType.String:
|
|
405
|
-
if (value.value === null || value.value === "") {
|
|
406
|
-
return true;
|
|
407
|
-
}
|
|
408
|
-
break;
|
|
409
|
-
case node_opcua_variant_1.DataType.Int64:
|
|
410
|
-
case node_opcua_variant_1.DataType.UInt64:
|
|
411
|
-
if (0 === coerceInt64ToInt32(value.value)) {
|
|
412
|
-
return true;
|
|
413
|
-
}
|
|
414
|
-
break;
|
|
415
|
-
case node_opcua_variant_1.DataType.LocalizedText:
|
|
416
|
-
if (!value.value) {
|
|
417
|
-
return true;
|
|
418
|
-
}
|
|
419
|
-
{
|
|
420
|
-
const l = value.value;
|
|
421
|
-
if (!l.locale && !l.text) {
|
|
422
|
-
return true;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
if (!value.value || value.value.length === 0) {
|
|
431
|
-
return true;
|
|
432
|
-
}
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
// eslint-disable-next-line max-statements
|
|
437
|
-
function _dumpValue(xw, node, value) {
|
|
438
|
-
const addressSpace = node.addressSpace;
|
|
439
|
-
// istanbul ignore next
|
|
440
|
-
if (value === null || value === undefined) {
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
(0, node_opcua_assert_1.assert)(value instanceof node_opcua_variant_1.Variant);
|
|
444
|
-
const dataTypeNode = addressSpace.findNode(node.dataType);
|
|
445
|
-
if (!dataTypeNode) {
|
|
446
|
-
console.log("Cannot find dataType:", node.dataType);
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
const dataTypeName = dataTypeNode.browseName.name.toString();
|
|
450
|
-
const baseDataTypeName = node_opcua_variant_1.DataType[value.dataType];
|
|
451
|
-
if (baseDataTypeName === "Null") {
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
(0, node_opcua_assert_1.assert)(typeof baseDataTypeName === "string");
|
|
455
|
-
// determine if dataTypeName is a ExtensionObject
|
|
456
|
-
const isExtensionObject = value.dataType === node_opcua_variant_1.DataType.ExtensionObject;
|
|
457
|
-
if (_isDefaultValue(value)) {
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
xw.startElement("Value");
|
|
461
|
-
if (isExtensionObject) {
|
|
462
|
-
const dataTypeNode = addressSpace.findDataType(node.dataType);
|
|
463
|
-
if (!dataTypeNode) {
|
|
464
|
-
throw new Error("Cannot find data type " + node.dataType.toString());
|
|
465
|
-
}
|
|
466
|
-
const encodeXml = _dumpVariantExtensionObjectValue2.bind(null, xw, dataTypeNode);
|
|
467
|
-
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
468
|
-
xw.startElement("ListOf" + baseDataTypeName);
|
|
469
|
-
value.value.forEach(encodeXml);
|
|
470
|
-
xw.endElement();
|
|
471
|
-
}
|
|
472
|
-
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
473
|
-
encodeXml(value.value);
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
errorLog(node.toString());
|
|
477
|
-
errorLog("_dumpValue : unsupported case , Matrix of ExtensionObjects");
|
|
478
|
-
// throw new Error("Unsupported case");
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
const encodeXml = _dumpVariantValue.bind(null, xw, value.dataType, node);
|
|
483
|
-
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
484
|
-
// console.log("Warning _dumpValue : Matrix not supported yet");
|
|
485
|
-
xw.startElement("ListOf" + dataTypeName);
|
|
486
|
-
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
487
|
-
value.value.forEach(encodeXml);
|
|
488
|
-
xw.endElement();
|
|
489
|
-
}
|
|
490
|
-
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
491
|
-
xw.startElement("ListOf" + dataTypeName);
|
|
492
|
-
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
493
|
-
value.value.forEach(encodeXml);
|
|
494
|
-
xw.endElement();
|
|
495
|
-
}
|
|
496
|
-
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
497
|
-
encodeXml(value.value);
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
errorLog(node.toString());
|
|
501
|
-
errorLog("_dumpValue : unsupported case , Matrix");
|
|
502
|
-
// xx throw new Error("Unsupported case");
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
xw.endElement();
|
|
506
|
-
}
|
|
507
|
-
function _dumpArrayDimensionsAttribute(xw, node) {
|
|
508
|
-
if (node.arrayDimensions) {
|
|
509
|
-
if (node.valueRank === -1 || (node.arrayDimensions.length === 1 && node.arrayDimensions[0] === 0)) {
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
xw.writeAttribute("ArrayDimensions", node.arrayDimensions.join(","));
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
function visitUANode(node, options, forward) {
|
|
516
|
-
(0, node_opcua_assert_1.assert)(typeof forward === "boolean");
|
|
517
|
-
const addressSpace = node.addressSpace;
|
|
518
|
-
options.elements = options.elements || [];
|
|
519
|
-
options.index_el = options.index_el || {};
|
|
520
|
-
// visit references
|
|
521
|
-
function process_reference(reference) {
|
|
522
|
-
// only backward or forward references
|
|
523
|
-
if (reference.isForward !== forward) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
if (reference.nodeId.namespace === 0) {
|
|
527
|
-
return; // skip OPCUA namespace
|
|
528
|
-
}
|
|
529
|
-
const k = _hash(reference);
|
|
530
|
-
if (!options.index_el[k]) {
|
|
531
|
-
options.index_el[k] = 1;
|
|
532
|
-
const o = addressSpace.findNode(k);
|
|
533
|
-
if (o) {
|
|
534
|
-
visitUANode(o, options, forward);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
node.ownReferences().forEach(process_reference);
|
|
539
|
-
options.elements.push(node);
|
|
540
|
-
return node;
|
|
541
|
-
}
|
|
542
|
-
function dumpNodeInXml(xw, node) {
|
|
543
|
-
return node.dumpXML(xw);
|
|
544
|
-
}
|
|
545
|
-
function dumpReferencedNodes(xw, node, forward) {
|
|
546
|
-
const addressSpace = node.addressSpace;
|
|
547
|
-
if (!forward) {
|
|
548
|
-
{
|
|
549
|
-
const r = node.findReferencesEx("HasTypeDefinition");
|
|
550
|
-
if (r && r.length) {
|
|
551
|
-
(0, node_opcua_assert_1.assert)(r.length === 1);
|
|
552
|
-
const typeDefinitionObj = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, r[0]);
|
|
553
|
-
if (!typeDefinitionObj) {
|
|
554
|
-
warningLog(node.toString());
|
|
555
|
-
warningLog("dumpReferencedNodes: Warning : " + node.browseName.toString() + " unknown typeDefinition, ", r[0].toString());
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
(0, node_opcua_assert_1.assert)(typeDefinitionObj instanceof base_node_impl_1.BaseNodeImpl);
|
|
559
|
-
if (typeDefinitionObj.nodeId.namespace === node.nodeId.namespace) {
|
|
560
|
-
// only output node if it is on the same namespace
|
|
561
|
-
if (!xw.visitedNode[_hash(typeDefinitionObj)]) {
|
|
562
|
-
dumpNodeInXml(xw, typeDefinitionObj);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
//
|
|
569
|
-
{
|
|
570
|
-
const r = node.findReferencesEx("HasSubtype", node_opcua_data_model_1.BrowseDirection.Inverse);
|
|
571
|
-
if (r && r.length) {
|
|
572
|
-
const subTypeOf = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, r[0]);
|
|
573
|
-
(0, node_opcua_assert_1.assert)(r.length === 1);
|
|
574
|
-
if (subTypeOf.nodeId.namespace === node.nodeId.namespace) {
|
|
575
|
-
// only output node if it is on the same namespace
|
|
576
|
-
if (!xw.visitedNode[_hash(subTypeOf)]) {
|
|
577
|
-
dumpNodeInXml(xw, subTypeOf);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
const r = node.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
585
|
-
for (const reference of r) {
|
|
586
|
-
const nodeChild = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
587
|
-
(0, node_opcua_assert_1.assert)(nodeChild instanceof base_node_impl_1.BaseNodeImpl);
|
|
588
|
-
if (nodeChild.nodeId.namespace === node.nodeId.namespace) {
|
|
589
|
-
if (!xw.visitedNode[_hash(nodeChild)]) {
|
|
590
|
-
console.log(node.nodeId.toString(), " dumping child ", nodeChild.browseName.toString(), nodeChild.nodeId.toString());
|
|
591
|
-
dumpNodeInXml(xw, nodeChild);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
const currentReadFlag = (0, node_opcua_data_model_1.makeAccessLevelFlag)("CurrentRead");
|
|
598
|
-
function dumpCommonAttributes(xw, node) {
|
|
599
|
-
xw.writeAttribute("NodeId", n(xw, node.nodeId));
|
|
600
|
-
xw.writeAttribute("BrowseName", b(xw, node.browseName));
|
|
601
|
-
if (Object.prototype.hasOwnProperty.call(node, "symbolicName")) {
|
|
602
|
-
xw.writeAttribute("SymbolicName", node.symbolicName);
|
|
603
|
-
}
|
|
604
|
-
if (Object.prototype.hasOwnProperty.call(node, "isAbstract")) {
|
|
605
|
-
if (node.isAbstract) {
|
|
606
|
-
xw.writeAttribute("IsAbstract", node.isAbstract ? "true" : "false");
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
if (Object.prototype.hasOwnProperty.call(node, "accessLevel")) {
|
|
610
|
-
// CurrentRead is by default
|
|
611
|
-
if (node.accessLevel !== currentReadFlag) {
|
|
612
|
-
xw.writeAttribute("AccessLevel", node.accessLevel.toString());
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
function dumpCommonElements(xw, node) {
|
|
617
|
-
_dumpDisplayName(xw, node);
|
|
618
|
-
_dumpDescription(xw, node);
|
|
619
|
-
_dumpReferences(xw, node);
|
|
620
|
-
}
|
|
621
|
-
function coerceInt64ToInt32(int64) {
|
|
622
|
-
if (typeof int64 === "number") {
|
|
623
|
-
return int64;
|
|
624
|
-
}
|
|
625
|
-
if (int64[0] === 4294967295 && int64[1] === 4294967295) {
|
|
626
|
-
return 0xffffffff;
|
|
627
|
-
}
|
|
628
|
-
if (int64[0] !== 0) {
|
|
629
|
-
debugLog("coerceInt64ToInt32 , loosing high word in conversion");
|
|
630
|
-
}
|
|
631
|
-
return int64[1];
|
|
632
|
-
}
|
|
633
|
-
function _dumpEnumDefinition(xw, enumDefinition) {
|
|
634
|
-
enumDefinition.fields = enumDefinition.fields || [];
|
|
635
|
-
for (const defItem of enumDefinition.fields) {
|
|
636
|
-
xw.startElement("Field");
|
|
637
|
-
xw.writeAttribute("Name", defItem.name);
|
|
638
|
-
if (!utils.isNullOrUndefined(defItem.value)) {
|
|
639
|
-
xw.writeAttribute("Value", coerceInt64ToInt32(defItem.value));
|
|
640
|
-
}
|
|
641
|
-
_dumpDescription(xw, defItem);
|
|
642
|
-
xw.endElement();
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
function _dumpStructureDefinition(xw, structureDefinition, baseStructureDefinition) {
|
|
646
|
-
var _a;
|
|
647
|
-
/*
|
|
648
|
-
* note: baseDataType and defaultEncodingId are implicit and not stored in the XML file ??
|
|
649
|
-
*
|
|
650
|
-
*/
|
|
651
|
-
const baseDataType = structureDefinition.baseDataType;
|
|
652
|
-
const defaultEncodingId = structureDefinition.defaultEncodingId;
|
|
653
|
-
// do not repeat elements that are already defined in base structure in the xml ouput!
|
|
654
|
-
const fields = structureDefinition.fields || [];
|
|
655
|
-
const nbFieldsInBase = baseStructureDefinition ? ((_a = baseStructureDefinition.fields) === null || _a === void 0 ? void 0 : _a.length) || 0 : 0;
|
|
656
|
-
for (let index = nbFieldsInBase; index < fields.length; index++) {
|
|
657
|
-
const defItem = fields[index];
|
|
658
|
-
xw.startElement("Field");
|
|
659
|
-
xw.writeAttribute("Name", defItem.name);
|
|
660
|
-
if (defItem.arrayDimensions) {
|
|
661
|
-
xw.writeAttribute("ArrayDimensions", defItem.arrayDimensions.map((x) => x.toString()).join(","));
|
|
662
|
-
}
|
|
663
|
-
if (defItem.valueRank !== undefined && defItem.valueRank !== -1) {
|
|
664
|
-
xw.writeAttribute("ValueRank", defItem.valueRank);
|
|
665
|
-
}
|
|
666
|
-
if (defItem.isOptional /* && defItem.isOptional !== false */) {
|
|
667
|
-
xw.writeAttribute("IsOptional", defItem.isOptional.toString());
|
|
668
|
-
}
|
|
669
|
-
if (defItem.maxStringLength !== undefined && defItem.maxStringLength !== 0) {
|
|
670
|
-
xw.writeAttribute("MaxStringLength", defItem.maxStringLength);
|
|
671
|
-
}
|
|
672
|
-
// todo : SymbolicName ( see AutoId )
|
|
673
|
-
if (defItem.dataType) {
|
|
674
|
-
// todo : namespace translation !
|
|
675
|
-
xw.writeAttribute("DataType", n(xw, defItem.dataType));
|
|
676
|
-
}
|
|
677
|
-
_dumpDescription(xw, defItem);
|
|
678
|
-
xw.endElement();
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
function _dumpUADataTypeDefinition(xw, uaDataType) {
|
|
682
|
-
const uaDataTypeBase = uaDataType.subtypeOfObj;
|
|
683
|
-
if (uaDataType.isEnumeration()) {
|
|
684
|
-
xw.startElement("Definition");
|
|
685
|
-
xw.writeAttribute("Name", b(xw, uaDataType.browseName));
|
|
686
|
-
_dumpEnumDefinition(xw, uaDataType.getEnumDefinition());
|
|
687
|
-
xw.endElement();
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
if (uaDataType.isStructure()) {
|
|
691
|
-
const definition = uaDataType.getStructureDefinition();
|
|
692
|
-
const baseDefinition = uaDataTypeBase ? uaDataTypeBase.getStructureDefinition() : null;
|
|
693
|
-
xw.startElement("Definition");
|
|
694
|
-
xw.writeAttribute("Name", b(xw, uaDataType.browseName));
|
|
695
|
-
if (definition.structureType === node_opcua_types_1.StructureType.Union) {
|
|
696
|
-
xw.writeAttribute("IsUnion", "true");
|
|
697
|
-
}
|
|
698
|
-
_dumpStructureDefinition(xw, definition, baseDefinition);
|
|
699
|
-
xw.endElement();
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
function dumpUADataType(xw, node) {
|
|
704
|
-
_markAsVisited(xw, node);
|
|
705
|
-
xw.startElement("UADataType");
|
|
706
|
-
xw.writeAttribute("NodeId", n(xw, node.nodeId));
|
|
707
|
-
xw.writeAttribute("BrowseName", b(xw, node.browseName));
|
|
708
|
-
if (node.symbolicName !== node.browseName.name) {
|
|
709
|
-
xw.writeAttribute("SymbolicName", node.symbolicName);
|
|
710
|
-
}
|
|
711
|
-
if (node.isAbstract) {
|
|
712
|
-
xw.writeAttribute("IsAbstract", node.isAbstract ? "true" : "false");
|
|
713
|
-
}
|
|
714
|
-
_dumpDisplayName(xw, node);
|
|
715
|
-
_dumpReferences(xw, node);
|
|
716
|
-
_dumpUADataTypeDefinition(xw, node);
|
|
717
|
-
xw.endElement();
|
|
718
|
-
dumpAggregates(xw, node);
|
|
719
|
-
}
|
|
720
|
-
function _markAsVisited(xw, node) {
|
|
721
|
-
xw.visitedNode = xw.visitedNode || {};
|
|
722
|
-
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
723
|
-
xw.visitedNode[_hash(node)] = 1;
|
|
724
|
-
}
|
|
725
|
-
function dumpUAVariable(xw, node) {
|
|
726
|
-
_markAsVisited(xw, node);
|
|
727
|
-
dumpReferencedNodes(xw, node, false);
|
|
728
|
-
const addressSpace = node.addressSpace;
|
|
729
|
-
xw.startElement("UAVariable");
|
|
730
|
-
{
|
|
731
|
-
// attributes
|
|
732
|
-
dumpCommonAttributes(xw, node);
|
|
733
|
-
if (node.valueRank !== -1) {
|
|
734
|
-
// -1 = Scalar
|
|
735
|
-
xw.writeAttribute("ValueRank", node.valueRank);
|
|
736
|
-
}
|
|
737
|
-
_dumpArrayDimensionsAttribute(xw, node);
|
|
738
|
-
const dataTypeNode = addressSpace.findNode(node.dataType);
|
|
739
|
-
if (dataTypeNode) {
|
|
740
|
-
// verify that data Type is in alias
|
|
741
|
-
// xx const dataTypeName = dataTypeNode.browseName.toString();
|
|
742
|
-
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
|
|
743
|
-
xw.writeAttribute("DataType", dataTypeName);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
{
|
|
747
|
-
// sub elements
|
|
748
|
-
dumpCommonElements(xw, node);
|
|
749
|
-
const value = node.$dataValue.value;
|
|
750
|
-
if (value) {
|
|
751
|
-
_dumpValue(xw, node, value);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
xw.endElement();
|
|
755
|
-
dumpAggregates(xw, node);
|
|
756
|
-
}
|
|
757
|
-
function dumpUAVariableType(xw, node) {
|
|
758
|
-
xw.visitedNode = xw.visitedNode || {};
|
|
759
|
-
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
760
|
-
xw.visitedNode[_hash(node)] = 1;
|
|
761
|
-
dumpReferencedNodes(xw, node, false);
|
|
762
|
-
const addressSpace = node.addressSpace;
|
|
763
|
-
xw.startElement("UAVariableType");
|
|
764
|
-
{
|
|
765
|
-
// attributes
|
|
766
|
-
dumpCommonAttributes(xw, node);
|
|
767
|
-
if (node.valueRank !== -1) {
|
|
768
|
-
xw.writeAttribute("ValueRank", node.valueRank);
|
|
769
|
-
}
|
|
770
|
-
const dataTypeNode = addressSpace.findNode(node.dataType);
|
|
771
|
-
if (!dataTypeNode) {
|
|
772
|
-
// throw new Error(" cannot find datatype " + node.dataType);
|
|
773
|
-
console.log(" cannot find datatype " +
|
|
774
|
-
node.dataType +
|
|
775
|
-
" for node " +
|
|
776
|
-
node.browseName.toString() +
|
|
777
|
-
" id =" +
|
|
778
|
-
node.nodeId.toString());
|
|
779
|
-
}
|
|
780
|
-
else {
|
|
781
|
-
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
|
|
782
|
-
xw.writeAttribute("DataType", dataTypeName);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
{
|
|
786
|
-
_dumpArrayDimensionsAttribute(xw, node);
|
|
787
|
-
// sub elements
|
|
788
|
-
dumpCommonElements(xw, node);
|
|
789
|
-
const value = node.value;
|
|
790
|
-
if (value) {
|
|
791
|
-
_dumpValue(xw, node, value);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
xw.endElement();
|
|
795
|
-
dumpAggregates(xw, node);
|
|
796
|
-
}
|
|
797
|
-
function dumpUAObject(xw, node) {
|
|
798
|
-
xw.writeComment("Object - " + b(xw, node.browseName) + " {{{{ ");
|
|
799
|
-
xw.visitedNode = xw.visitedNode || {};
|
|
800
|
-
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
801
|
-
xw.visitedNode[_hash(node)] = 1;
|
|
802
|
-
// dump SubTypeOf and HasTypeDefinition
|
|
803
|
-
dumpReferencedNodes(xw, node, false);
|
|
804
|
-
xw.startElement("UAObject");
|
|
805
|
-
dumpCommonAttributes(xw, node);
|
|
806
|
-
dumpCommonElements(xw, node);
|
|
807
|
-
xw.endElement();
|
|
808
|
-
// dump aggregates nodes ( Properties / components )
|
|
809
|
-
dumpAggregates(xw, node);
|
|
810
|
-
dumpElementInFolder(xw, node);
|
|
811
|
-
xw.writeComment("Object - " + b(xw, node.browseName) + " }}}} ");
|
|
812
|
-
}
|
|
813
|
-
function dumpElementInFolder(xw, node) {
|
|
814
|
-
const aggregates = node
|
|
815
|
-
.getFolderElements()
|
|
816
|
-
.sort((x, y) => (x.browseName.name.toString() > y.browseName.name.toString() ? 1 : -1));
|
|
817
|
-
for (const aggregate of aggregates.sort(sortByNodeId)) {
|
|
818
|
-
// do not export node that do not belong to our namespace
|
|
819
|
-
if (node.nodeId.namespace !== aggregate.nodeId.namespace) {
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
if (!xw.visitedNode[_hash(aggregate)]) {
|
|
823
|
-
aggregate.dumpXML(xw);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
function dumpAggregates(xw, node) {
|
|
828
|
-
// Xx xw.writeComment("Aggregates {{ ");
|
|
829
|
-
const aggregates = node
|
|
830
|
-
.getAggregates()
|
|
831
|
-
.sort((x, y) => (x.browseName.name.toString() > y.browseName.name.toString() ? 1 : -1));
|
|
832
|
-
for (const aggregate of aggregates.sort(sortByNodeId)) {
|
|
833
|
-
// do not export node that do not belong to our namespace
|
|
834
|
-
if (node.nodeId.namespace !== aggregate.nodeId.namespace) {
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
if (!xw.visitedNode[_hash(aggregate)]) {
|
|
838
|
-
aggregate.dumpXML(xw);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
// Xx xw.writeComment("Aggregates }} ");
|
|
842
|
-
}
|
|
843
|
-
function dumpUAObjectType(xw, node) {
|
|
844
|
-
(0, node_opcua_assert_1.assert)(node instanceof ua_object_type_impl_1.UAObjectTypeImpl);
|
|
845
|
-
xw.writeComment("ObjectType - " + b(xw, node.browseName) + " {{{{ ");
|
|
846
|
-
_markAsVisited(xw, node);
|
|
847
|
-
// dump SubtypeOf and HasTypeDefinition
|
|
848
|
-
dumpReferencedNodes(xw, node, false);
|
|
849
|
-
xw.startElement("UAObjectType");
|
|
850
|
-
dumpCommonAttributes(xw, node);
|
|
851
|
-
dumpCommonElements(xw, node);
|
|
852
|
-
xw.endElement();
|
|
853
|
-
dumpAggregates(xw, node);
|
|
854
|
-
xw.writeComment("ObjectType - " + b(xw, node.browseName) + " }}}}");
|
|
855
|
-
}
|
|
856
|
-
function dumpUAMethod(xw, node) {
|
|
857
|
-
_markAsVisited(xw, node);
|
|
858
|
-
dumpReferencedNodes(xw, node, false);
|
|
859
|
-
xw.startElement("UAMethod");
|
|
860
|
-
dumpCommonAttributes(xw, node);
|
|
861
|
-
if (node.methodDeclarationId) {
|
|
862
|
-
xw.writeAttribute("MethodDeclarationId", n(xw, node.methodDeclarationId));
|
|
863
|
-
}
|
|
864
|
-
dumpCommonElements(xw, node);
|
|
865
|
-
xw.endElement();
|
|
866
|
-
dumpAggregates(xw, node);
|
|
867
|
-
}
|
|
868
|
-
function resolveDataTypeName(addressSpace, dataType) {
|
|
869
|
-
let dataTypeNode = null;
|
|
870
|
-
// istanbul ignore next
|
|
871
|
-
if (typeof dataType === "string") {
|
|
872
|
-
dataTypeNode = addressSpace.findDataType(dataType);
|
|
873
|
-
}
|
|
874
|
-
else {
|
|
875
|
-
(0, node_opcua_assert_1.assert)(dataType instanceof node_opcua_nodeid_1.NodeId);
|
|
876
|
-
const o = addressSpace.findNode(dataType.toString());
|
|
877
|
-
dataTypeNode = o ? o : null;
|
|
878
|
-
}
|
|
879
|
-
if (!dataTypeNode) {
|
|
880
|
-
errorLog("resolveDataTypeName: warning cannot find DataType " + dataType.toString());
|
|
881
|
-
return new node_opcua_data_model_1.QualifiedName({ name: "", namespaceIndex: 0 });
|
|
882
|
-
}
|
|
883
|
-
return dataTypeNode.browseName;
|
|
884
|
-
}
|
|
885
|
-
function buildUpAliases(node, xw, options) {
|
|
886
|
-
const addressSpace = node.addressSpace;
|
|
887
|
-
options.aliases = options.aliases || {};
|
|
888
|
-
options.aliases_visited = options.aliases_visited || {};
|
|
889
|
-
const k = _hash(node);
|
|
890
|
-
// istanbul ignore next
|
|
891
|
-
if (options.aliases_visited[k]) {
|
|
892
|
-
return;
|
|
893
|
-
}
|
|
894
|
-
options.aliases_visited[k] = 1;
|
|
895
|
-
// put datatype into aliases list
|
|
896
|
-
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
897
|
-
const nodeV = node;
|
|
898
|
-
if (nodeV.dataType && nodeV.dataType.namespace === 0 && nodeV.dataType.value !== 0) {
|
|
899
|
-
// name
|
|
900
|
-
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, nodeV.dataType));
|
|
901
|
-
if (dataTypeName) {
|
|
902
|
-
if (!options.aliases[dataTypeName]) {
|
|
903
|
-
options.aliases[dataTypeName] = n(xw, nodeV.dataType);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
if (nodeV.dataType && nodeV.dataType.namespace !== 0 && nodeV.dataType.value !== 0) {
|
|
908
|
-
// name
|
|
909
|
-
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, nodeV.dataType));
|
|
910
|
-
if (dataTypeName) {
|
|
911
|
-
if (!options.aliases[dataTypeName]) {
|
|
912
|
-
options.aliases[dataTypeName] = n(xw, nodeV.dataType);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
function collectReferenceNameInAlias(reference) {
|
|
918
|
-
// reference.referenceType
|
|
919
|
-
const key = b(xw, (0, base_node_impl_1.getReferenceType)(reference).browseName);
|
|
920
|
-
if (!options.aliases.key) {
|
|
921
|
-
if (reference.referenceType.namespace === 0) {
|
|
922
|
-
options.aliases[key] = reference.referenceType.toString().replace("ns=0;", "");
|
|
923
|
-
}
|
|
924
|
-
else {
|
|
925
|
-
options.aliases[key] = n(xw, reference.referenceType);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
node.allReferences().forEach(collectReferenceNameInAlias);
|
|
930
|
-
}
|
|
931
|
-
function writeAliases(xw, aliases) {
|
|
932
|
-
xw.startElement("Aliases");
|
|
933
|
-
if (aliases) {
|
|
934
|
-
const keys = Object.keys(aliases).sort();
|
|
935
|
-
for (const key of keys) {
|
|
936
|
-
xw.startElement("Alias");
|
|
937
|
-
xw.writeAttribute("Alias", key);
|
|
938
|
-
xw.text(aliases[key].toString().replace(/ns=0;/, ""));
|
|
939
|
-
xw.endElement();
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
xw.endElement();
|
|
943
|
-
}
|
|
944
|
-
function constructNamespaceTranslationTable(dependency) {
|
|
945
|
-
const translationTable = {};
|
|
946
|
-
for (let i = 0; i < dependency.length; i++) {
|
|
947
|
-
translationTable[dependency[i].index] = i;
|
|
948
|
-
}
|
|
949
|
-
return translationTable;
|
|
950
|
-
}
|
|
951
|
-
function dumpReferenceType(xw, referenceType) {
|
|
952
|
-
_markAsVisited(xw, referenceType);
|
|
953
|
-
xw.startElement("UAReferenceType");
|
|
954
|
-
dumpCommonAttributes(xw, referenceType);
|
|
955
|
-
dumpCommonElements(xw, referenceType);
|
|
956
|
-
if (referenceType.inverseName /* LocalizedText*/) {
|
|
957
|
-
xw.startElement("InverseName");
|
|
958
|
-
xw.text(referenceType.inverseName.text || "");
|
|
959
|
-
xw.endElement();
|
|
960
|
-
}
|
|
961
|
-
xw.endElement();
|
|
962
|
-
}
|
|
963
|
-
function sortByBrowseName(x, y) {
|
|
964
|
-
const x_str = x.browseName.toString();
|
|
965
|
-
const y_str = y.browseName.toString();
|
|
966
|
-
if (x_str > y_str) {
|
|
967
|
-
return -1;
|
|
968
|
-
}
|
|
969
|
-
else if (x_str < y_str) {
|
|
970
|
-
return 1;
|
|
971
|
-
}
|
|
972
|
-
return 0;
|
|
973
|
-
}
|
|
974
|
-
function sortByNodeId(a, b) {
|
|
975
|
-
return a.nodeId.toString() < b.nodeId.toString() ? -1 : 1;
|
|
976
|
-
}
|
|
977
|
-
function dumpXml(node, options) {
|
|
978
|
-
const namespace = node.namespace;
|
|
979
|
-
// make a first visit so that we determine which node to output and in which order
|
|
980
|
-
const nodesToVisit = {};
|
|
981
|
-
const dependency = (0, construct_namespace_dependency_1.constructNamespaceDependency)(namespace);
|
|
982
|
-
const translationTable = constructNamespaceTranslationTable(dependency);
|
|
983
|
-
const xw = new XMLWriter(true);
|
|
984
|
-
xw.translationTable = translationTable;
|
|
985
|
-
visitUANode(node, nodesToVisit, false);
|
|
986
|
-
xw.startDocument({ encoding: "utf-8" });
|
|
987
|
-
xw.startElement("UANodeSet");
|
|
988
|
-
xw.writeAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema-instance");
|
|
989
|
-
xw.writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
|
|
990
|
-
xw.writeAttribute("Version", "1.02");
|
|
991
|
-
xw.writeAttribute("LastModified", new Date().toISOString());
|
|
992
|
-
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd");
|
|
993
|
-
buildUpAliases(node, xw, nodesToVisit);
|
|
994
|
-
writeAliases(xw, nodesToVisit.aliases);
|
|
995
|
-
for (const el of nodesToVisit.elements) {
|
|
996
|
-
el.dumpXML(xw);
|
|
997
|
-
}
|
|
998
|
-
xw.endElement();
|
|
999
|
-
xw.endDocument();
|
|
1000
|
-
return xw.toString();
|
|
1001
|
-
}
|
|
1002
|
-
exports.dumpXml = dumpXml;
|
|
1003
|
-
ua_method_impl_1.UAMethodImpl.prototype.dumpXML = function (xw) {
|
|
1004
|
-
dumpUAMethod(xw, this);
|
|
1005
|
-
};
|
|
1006
|
-
ua_object_impl_1.UAObjectImpl.prototype.dumpXML = function (xw) {
|
|
1007
|
-
dumpUAObject(xw, this);
|
|
1008
|
-
};
|
|
1009
|
-
ua_variable_impl_1.UAVariableImpl.prototype.dumpXML = function (xw) {
|
|
1010
|
-
dumpUAVariable(xw, this);
|
|
1011
|
-
};
|
|
1012
|
-
ua_variable_type_impl_1.UAVariableTypeImpl.prototype.dumpXML = function (xw) {
|
|
1013
|
-
dumpUAVariableType(xw, this);
|
|
1014
|
-
};
|
|
1015
|
-
ua_reference_type_impl_1.UAReferenceTypeImpl.prototype.dumpXML = function (xw) {
|
|
1016
|
-
dumpReferenceType(xw, this);
|
|
1017
|
-
};
|
|
1018
|
-
ua_object_type_impl_1.UAObjectTypeImpl.prototype.dumpXML = function (xw) {
|
|
1019
|
-
dumpUAObjectType(xw, this);
|
|
1020
|
-
};
|
|
1021
|
-
ua_data_type_impl_1.UADataTypeImpl.prototype.dumpXML = function (xw) {
|
|
1022
|
-
dumpUADataType(xw, this);
|
|
1023
|
-
};
|
|
1024
|
-
// eslint-disable-next-line max-statements
|
|
1025
|
-
namespace_impl_1.NamespaceImpl.prototype.toNodeset2XML = function () {
|
|
1026
|
-
const dependency = (0, construct_namespace_dependency_1.constructNamespaceDependency)(this);
|
|
1027
|
-
const translationTable = constructNamespaceTranslationTable(dependency);
|
|
1028
|
-
const xw = new XMLWriter(true);
|
|
1029
|
-
xw.translationTable = translationTable;
|
|
1030
|
-
xw.startDocument({ encoding: "utf-8", version: "1.0" });
|
|
1031
|
-
xw.startElement("UANodeSet");
|
|
1032
|
-
xw.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
|
1033
|
-
xw.writeAttribute("xmlns:uax", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
1034
|
-
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd");
|
|
1035
|
-
// xx xw.writeAttribute("Version", "1.02");
|
|
1036
|
-
// xx xw.writeAttribute("LastModified", (new Date()).toISOString());
|
|
1037
|
-
// ------------- INamespace Uris
|
|
1038
|
-
xw.startElement("NamespaceUris");
|
|
1039
|
-
// xx const namespaceArray = namespace.addressSpace.getNamespaceArray();
|
|
1040
|
-
for (const depend of dependency) {
|
|
1041
|
-
if (depend.index === 0) {
|
|
1042
|
-
continue; // ignore namespace 0
|
|
1043
|
-
}
|
|
1044
|
-
xw.startElement("Uri");
|
|
1045
|
-
xw.text(depend.namespaceUri);
|
|
1046
|
-
xw.endElement();
|
|
1047
|
-
}
|
|
1048
|
-
xw.endElement();
|
|
1049
|
-
// ------------- INamespace Uris
|
|
1050
|
-
xw.startElement("Models");
|
|
1051
|
-
{
|
|
1052
|
-
xw.startElement("Model");
|
|
1053
|
-
xw.writeAttribute("ModelUri", this.namespaceUri);
|
|
1054
|
-
xw.writeAttribute("Version", this.version);
|
|
1055
|
-
xw.writeAttribute("PublicationDate", this.publicationDate.toISOString());
|
|
1056
|
-
for (const depend of dependency) {
|
|
1057
|
-
if (depend.index === this.index) {
|
|
1058
|
-
continue; // ignore our namespace 0
|
|
1059
|
-
}
|
|
1060
|
-
xw.startElement("RequiredModel");
|
|
1061
|
-
xw.writeAttribute("ModelUri", depend.namespaceUri);
|
|
1062
|
-
xw.writeAttribute("Version", depend.version);
|
|
1063
|
-
xw.writeAttribute("PublicationDate", depend.publicationDate.toISOString());
|
|
1064
|
-
xw.endElement();
|
|
1065
|
-
}
|
|
1066
|
-
xw.endElement();
|
|
1067
|
-
}
|
|
1068
|
-
xw.endElement();
|
|
1069
|
-
const s = {};
|
|
1070
|
-
for (const node of this.nodeIterator()) {
|
|
1071
|
-
buildUpAliases(node, xw, s);
|
|
1072
|
-
}
|
|
1073
|
-
writeAliases(xw, s.aliases);
|
|
1074
|
-
xw.visitedNode = {};
|
|
1075
|
-
// -------------- writeReferences
|
|
1076
|
-
xw.writeComment("ReferenceTypes");
|
|
1077
|
-
const referenceTypes = [...this._referenceTypeIterator()].sort(sortByBrowseName);
|
|
1078
|
-
for (const referenceType of referenceTypes) {
|
|
1079
|
-
dumpReferenceType(xw, referenceType);
|
|
1080
|
-
}
|
|
1081
|
-
// -------------- Dictionaries
|
|
1082
|
-
const addressSpace = this.addressSpace;
|
|
1083
|
-
const opcBinaryTypeSystem = addressSpace.findNode("OPCBinarySchema_TypeSystem");
|
|
1084
|
-
if (opcBinaryTypeSystem) {
|
|
1085
|
-
// let find all DataType dictionary node corresponding to a given namespace
|
|
1086
|
-
// (have DataTypeDictionaryType)
|
|
1087
|
-
const nodeToBrowse = new node_opcua_types_1.BrowseDescription({
|
|
1088
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
1089
|
-
includeSubtypes: false,
|
|
1090
|
-
nodeClassMask: (0, node_opcua_data_model_1.makeNodeClassMask)("Variable"),
|
|
1091
|
-
nodeId: opcBinaryTypeSystem.nodeId,
|
|
1092
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasComponent"),
|
|
1093
|
-
resultMask: (0, node_opcua_data_model_1.makeResultMask)("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
|
|
1094
|
-
});
|
|
1095
|
-
const result = opcBinaryTypeSystem.browseNode(nodeToBrowse).filter((r) => r.nodeId.namespace === this.index);
|
|
1096
|
-
(0, node_opcua_assert_1.assert)(result.length <= 1);
|
|
1097
|
-
if (result.length === 1) {
|
|
1098
|
-
xw.writeComment("DataSystem");
|
|
1099
|
-
const dataSystemType = addressSpace.findNode(result[0].nodeId);
|
|
1100
|
-
dumpNodeInXml(xw, dataSystemType);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
// -------------- DataTypes
|
|
1104
|
-
const dataTypes = [...this._dataTypeIterator()].sort(sortByBrowseName);
|
|
1105
|
-
if (dataTypes.length) {
|
|
1106
|
-
xw.writeComment("DataTypes");
|
|
1107
|
-
// xx xw.writeComment(" "+ objectTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1108
|
-
for (const dataType of dataTypes.sort(sortByNodeId)) {
|
|
1109
|
-
if (!xw.visitedNode[_hash(dataType)]) {
|
|
1110
|
-
dumpNodeInXml(xw, dataType);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
// -------------- ObjectTypes
|
|
1115
|
-
xw.writeComment("ObjectTypes");
|
|
1116
|
-
const objectTypes = [...this._objectTypeIterator()].sort(sortByBrowseName);
|
|
1117
|
-
// xx xw.writeComment(" "+ objectTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1118
|
-
for (const objectType of objectTypes.sort(sortByNodeId)) {
|
|
1119
|
-
if (!xw.visitedNode[_hash(objectType)]) {
|
|
1120
|
-
dumpNodeInXml(xw, objectType);
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
// -------------- VariableTypes
|
|
1124
|
-
xw.writeComment("VariableTypes");
|
|
1125
|
-
const variableTypes = [...this._variableTypeIterator()].sort(sortByBrowseName);
|
|
1126
|
-
// xx xw.writeComment("ObjectTypes "+ variableTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1127
|
-
for (const variableType of variableTypes.sort(sortByNodeId)) {
|
|
1128
|
-
if (!xw.visitedNode[_hash(variableType)]) {
|
|
1129
|
-
dumpNodeInXml(xw, variableType);
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
// -------------- Any thing else
|
|
1133
|
-
xw.writeComment("Other Nodes");
|
|
1134
|
-
const nodes = [...this.nodeIterator()].sort(sortByBrowseName);
|
|
1135
|
-
for (const node of nodes.sort(sortByNodeId)) {
|
|
1136
|
-
if (!xw.visitedNode[_hash(node)]) {
|
|
1137
|
-
dumpNodeInXml(xw, node);
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
xw.endElement();
|
|
1141
|
-
xw.endDocument();
|
|
1142
|
-
return xw.toString();
|
|
1143
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dumpXml = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-address-space
|
|
6
|
+
*/
|
|
7
|
+
// produce nodeset xml files
|
|
8
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
10
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
11
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
12
|
+
const utils = require("node-opcua-utils");
|
|
13
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
14
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
15
|
+
const node_opcua_types_1 = require("node-opcua-types");
|
|
16
|
+
const reference_impl_1 = require("../reference_impl");
|
|
17
|
+
const base_node_impl_1 = require("../base_node_impl");
|
|
18
|
+
const ua_reference_type_impl_1 = require("../ua_reference_type_impl");
|
|
19
|
+
const ua_object_type_impl_1 = require("../ua_object_type_impl");
|
|
20
|
+
const ua_variable_impl_1 = require("../ua_variable_impl");
|
|
21
|
+
const ua_object_impl_1 = require("../ua_object_impl");
|
|
22
|
+
const namespace_impl_1 = require("../namespace_impl");
|
|
23
|
+
const ua_method_impl_1 = require("../ua_method_impl");
|
|
24
|
+
const ua_data_type_impl_1 = require("../ua_data_type_impl");
|
|
25
|
+
const ua_variable_type_impl_1 = require("../ua_variable_type_impl");
|
|
26
|
+
const decode_xml_extension_object_1 = require("../../source/loader/decode_xml_extension_object");
|
|
27
|
+
const construct_namespace_dependency_1 = require("./construct_namespace_dependency");
|
|
28
|
+
// tslint:disable:no-var-requires
|
|
29
|
+
const XMLWriter = require("xml-writer");
|
|
30
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
31
|
+
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
32
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
33
|
+
function _hash(node) {
|
|
34
|
+
return node.nodeId.toString();
|
|
35
|
+
}
|
|
36
|
+
function _dumpDisplayName(xw, node) {
|
|
37
|
+
if (node.displayName && node.displayName[0]) {
|
|
38
|
+
xw.startElement("DisplayName").text(node.displayName[0].text).endElement();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function _dumpDescription(xw, node) {
|
|
42
|
+
if (node.description && node.description.text && node.description.text.length) {
|
|
43
|
+
let desc = node.description.text;
|
|
44
|
+
desc = desc || "";
|
|
45
|
+
xw.startElement("Description").text(desc).endElement();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function translateNodeId(xw, nodeId) {
|
|
49
|
+
(0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
50
|
+
const nn = xw.translationTable[nodeId.namespace];
|
|
51
|
+
const translatedNode = new node_opcua_nodeid_1.NodeId(nodeId.identifierType, nodeId.value, nn);
|
|
52
|
+
return translatedNode;
|
|
53
|
+
}
|
|
54
|
+
function n(xw, nodeId) {
|
|
55
|
+
return translateNodeId(xw, nodeId).toString().replace("ns=0;", "");
|
|
56
|
+
}
|
|
57
|
+
function translateBrowseName(xw, browseName) {
|
|
58
|
+
(0, node_opcua_assert_1.assert)(browseName instanceof node_opcua_data_model_1.QualifiedName);
|
|
59
|
+
const nn = xw.translationTable[browseName.namespaceIndex];
|
|
60
|
+
const translatedBrowseName = new node_opcua_data_model_1.QualifiedName({ namespaceIndex: nn, name: browseName.name });
|
|
61
|
+
return translatedBrowseName;
|
|
62
|
+
}
|
|
63
|
+
function b(xw, browseName) {
|
|
64
|
+
return translateBrowseName(xw, browseName).toString().replace("ns=0;", "");
|
|
65
|
+
}
|
|
66
|
+
function _dumpReferences(xw, node) {
|
|
67
|
+
xw.startElement("References");
|
|
68
|
+
const addressSpace = node.addressSpace;
|
|
69
|
+
const aggregateReferenceType = addressSpace.findReferenceType("Aggregates");
|
|
70
|
+
const hasChildReferenceType = addressSpace.findReferenceType("HasChild");
|
|
71
|
+
const hasSubtypeReferenceType = addressSpace.findReferenceType("HasSubtype");
|
|
72
|
+
const hasTypeDefinitionReferenceType = addressSpace.findReferenceType("HasTypeDefinition");
|
|
73
|
+
const nonHierarchicalReferencesType = addressSpace.findReferenceType("NonHierarchicalReferences");
|
|
74
|
+
const organizesReferencesType = addressSpace.findReferenceType("Organizes");
|
|
75
|
+
const connectsToReferenceType = addressSpace.findReferenceType("ConnectsTo");
|
|
76
|
+
const hasEventSourceReferenceType = addressSpace.findReferenceType("HasEventSource");
|
|
77
|
+
function referenceToKeep(reference) {
|
|
78
|
+
const referenceType = reference._referenceType;
|
|
79
|
+
// get the direct backward reference to a external namespace
|
|
80
|
+
if (referenceType.isSupertypeOf(aggregateReferenceType) && !reference.isForward) {
|
|
81
|
+
if (reference.nodeId.namespace !== node.nodeId.namespace) {
|
|
82
|
+
// todo: may be check that reference.nodeId.namespace is one of the namespace
|
|
83
|
+
// on which our namespace is build and not a derived one !
|
|
84
|
+
// xx console.log("xxxxxxxxxxxxxx Keeping => ", referenceType.toString(), reference.node?.nodeId.toString());
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// only keep
|
|
89
|
+
if (referenceType.isSupertypeOf(aggregateReferenceType) && reference.isForward) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
else if (referenceType.isSupertypeOf(hasSubtypeReferenceType) && !reference.isForward) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
else if (referenceType.isSupertypeOf(hasTypeDefinitionReferenceType) && reference.isForward) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
else if (referenceType.isSupertypeOf(nonHierarchicalReferencesType) && reference.isForward) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
else if (referenceType.isSupertypeOf(organizesReferencesType) && !reference.isForward) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
else if (connectsToReferenceType && referenceType.isSupertypeOf(connectsToReferenceType) && reference.isForward) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
else if (referenceType.isSupertypeOf(hasEventSourceReferenceType) && reference.isForward) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
const references = node.allReferences().filter(referenceToKeep);
|
|
113
|
+
for (const reference of references.sort(sortByNodeId)) {
|
|
114
|
+
if ((0, base_node_impl_1.getReferenceType)(reference).browseName.toString() === "HasSubtype" && reference.isForward) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
// only output inverse Reference
|
|
118
|
+
xw.startElement("Reference");
|
|
119
|
+
xw.writeAttribute("ReferenceType", b(xw, (0, base_node_impl_1.getReferenceType)(reference).browseName));
|
|
120
|
+
if (!reference.isForward) {
|
|
121
|
+
xw.writeAttribute("IsForward", reference.isForward ? "true" : "false");
|
|
122
|
+
}
|
|
123
|
+
xw.text(n(xw, reference.nodeId));
|
|
124
|
+
xw.endElement();
|
|
125
|
+
}
|
|
126
|
+
xw.endElement();
|
|
127
|
+
}
|
|
128
|
+
function _dumpLocalizedText(xw, v) {
|
|
129
|
+
if (v.locale && v.locale.length) {
|
|
130
|
+
xw.startElement("Locale");
|
|
131
|
+
xw.text(v.locale);
|
|
132
|
+
xw.endElement();
|
|
133
|
+
}
|
|
134
|
+
xw.startElement("Text");
|
|
135
|
+
if (v.text) {
|
|
136
|
+
xw.text(v.text);
|
|
137
|
+
}
|
|
138
|
+
xw.endElement();
|
|
139
|
+
}
|
|
140
|
+
function _dumpQualifiedName(xw, v) {
|
|
141
|
+
const t = translateBrowseName(xw, v);
|
|
142
|
+
if (t.name) {
|
|
143
|
+
xw.startElement("Name");
|
|
144
|
+
xw.text(t.name);
|
|
145
|
+
xw.endElement();
|
|
146
|
+
}
|
|
147
|
+
if (t.namespaceIndex) {
|
|
148
|
+
xw.startElement("NamespaceIndex");
|
|
149
|
+
xw.text(t.namespaceIndex.toString());
|
|
150
|
+
xw.endElement();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function _dumpXmlElement(xw, v) {
|
|
154
|
+
xw.text(v);
|
|
155
|
+
}
|
|
156
|
+
/*
|
|
157
|
+
<uax:ExtensionObject>
|
|
158
|
+
<uax:TypeId>
|
|
159
|
+
<uax:Identifier>i=339</uax:Identifier>
|
|
160
|
+
</uax:TypeId>
|
|
161
|
+
<uax:Body>
|
|
162
|
+
<BuildInfo xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
|
|
163
|
+
<ProductUri></ProductUri>
|
|
164
|
+
<ManufacturerName></ManufacturerName>
|
|
165
|
+
<ProductName></ProductName>
|
|
166
|
+
<SoftwareVersion></SoftwareVersion>
|
|
167
|
+
<BuildNumber></BuildNumber>
|
|
168
|
+
<BuildDate>1900-01-01T00:00:00Z</BuildDate>
|
|
169
|
+
</BuildInfo>
|
|
170
|
+
</uax:Body>
|
|
171
|
+
</uax:ExtensionObject>
|
|
172
|
+
*/
|
|
173
|
+
function _dumpNodeId(xw, v) {
|
|
174
|
+
xw.startElement("Identifier");
|
|
175
|
+
xw.text(n(xw, v));
|
|
176
|
+
xw.endElement();
|
|
177
|
+
}
|
|
178
|
+
// eslint-disable-next-line complexity
|
|
179
|
+
function _dumpVariantValue(xw, dataType, node, value) {
|
|
180
|
+
const dataTypeNode = node.addressSpace.findDataType(node.dataType);
|
|
181
|
+
if (value === undefined || value === null) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (dataType === node_opcua_variant_1.DataType.Null) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
xw.startElement(node_opcua_variant_1.DataType[dataType]);
|
|
188
|
+
const definitionMap = (0, decode_xml_extension_object_1.makeDefinitionMap)(node.addressSpace);
|
|
189
|
+
_dumpVariantInnerValue(xw, dataType, dataTypeNode.nodeId, definitionMap, value);
|
|
190
|
+
xw.endElement();
|
|
191
|
+
}
|
|
192
|
+
function _dumpVariantInnerExtensionObject(xw, definitionMap, definition, value) {
|
|
193
|
+
for (const field of definition.fields || []) {
|
|
194
|
+
const dataTypeNodeId = field.dataType;
|
|
195
|
+
const fieldName = field.name;
|
|
196
|
+
const lowerFieldName = utils.lowerFirstLetter(fieldName);
|
|
197
|
+
const v = value[lowerFieldName];
|
|
198
|
+
if (v !== null && v !== undefined) {
|
|
199
|
+
if (dataTypeNodeId.namespace === 0 &&
|
|
200
|
+
dataTypeNodeId.value === 0 &&
|
|
201
|
+
dataTypeNodeId.identifierType === node_opcua_nodeid_1.NodeIdType.NUMERIC) {
|
|
202
|
+
// to do ?? shall we do a extension Object here ?
|
|
203
|
+
continue; // ns=0;i=0 is reserved
|
|
204
|
+
}
|
|
205
|
+
const { name, definition } = definitionMap.findDefinition(dataTypeNodeId);
|
|
206
|
+
xw.startElement(fieldName);
|
|
207
|
+
let fun = (value) => {
|
|
208
|
+
/** */
|
|
209
|
+
};
|
|
210
|
+
if (definition instanceof node_opcua_types_1.StructureDefinition) {
|
|
211
|
+
fun = _dumpVariantInnerExtensionObject.bind(null, xw, definitionMap, definition);
|
|
212
|
+
}
|
|
213
|
+
else if (definition instanceof node_opcua_types_1.EnumDefinition) {
|
|
214
|
+
fun = _dumpVariantInnerValueEnum.bind(null, xw, definition);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
const baseType = definition.dataType;
|
|
218
|
+
fun = _dumpVariantInnerValue.bind(null, xw, baseType, dataTypeNodeId, definitionMap);
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
if (field.valueRank === -1) {
|
|
222
|
+
fun(v);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
// array
|
|
226
|
+
for (const arrayItem of v) {
|
|
227
|
+
xw.startElement(name);
|
|
228
|
+
fun(arrayItem);
|
|
229
|
+
xw.endElement();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
// eslint-disable-next-line max-depth
|
|
235
|
+
if (err instanceof Error) {
|
|
236
|
+
errorLog("Error in _dumpVariantExtensionObjectValue_Body !!!", err.message);
|
|
237
|
+
}
|
|
238
|
+
console.log(name);
|
|
239
|
+
console.log(field);
|
|
240
|
+
// throw err;
|
|
241
|
+
}
|
|
242
|
+
xw.endElement();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function _dumpVariantInnerValueEnum(xw, definition, value) {
|
|
247
|
+
if (!definition.fields) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const field = definition.fields.find((f) => f.value[1] === value);
|
|
251
|
+
xw.text(`${field === null || field === void 0 ? void 0 : field.name}_${value}`);
|
|
252
|
+
}
|
|
253
|
+
// eslint-disable-next-line complexity
|
|
254
|
+
function _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, value) {
|
|
255
|
+
switch (dataType) {
|
|
256
|
+
case null:
|
|
257
|
+
case node_opcua_variant_1.DataType.Null:
|
|
258
|
+
break;
|
|
259
|
+
case node_opcua_variant_1.DataType.LocalizedText:
|
|
260
|
+
_dumpLocalizedText(xw, value);
|
|
261
|
+
break;
|
|
262
|
+
case node_opcua_variant_1.DataType.QualifiedName:
|
|
263
|
+
_dumpQualifiedName(xw, value);
|
|
264
|
+
break;
|
|
265
|
+
case node_opcua_variant_1.DataType.NodeId:
|
|
266
|
+
_dumpNodeId(xw, value);
|
|
267
|
+
break;
|
|
268
|
+
case node_opcua_variant_1.DataType.DateTime:
|
|
269
|
+
xw.text(value.toISOString());
|
|
270
|
+
break;
|
|
271
|
+
case node_opcua_variant_1.DataType.Int64:
|
|
272
|
+
case node_opcua_variant_1.DataType.UInt64:
|
|
273
|
+
xw.text(value[1].toString());
|
|
274
|
+
break;
|
|
275
|
+
case node_opcua_variant_1.DataType.Boolean:
|
|
276
|
+
case node_opcua_variant_1.DataType.SByte:
|
|
277
|
+
case node_opcua_variant_1.DataType.Byte:
|
|
278
|
+
case node_opcua_variant_1.DataType.SByte:
|
|
279
|
+
case node_opcua_variant_1.DataType.Float:
|
|
280
|
+
case node_opcua_variant_1.DataType.Double:
|
|
281
|
+
case node_opcua_variant_1.DataType.Int16:
|
|
282
|
+
case node_opcua_variant_1.DataType.Int32:
|
|
283
|
+
case node_opcua_variant_1.DataType.UInt16:
|
|
284
|
+
case node_opcua_variant_1.DataType.UInt32:
|
|
285
|
+
case node_opcua_variant_1.DataType.String:
|
|
286
|
+
xw.text(value.toString());
|
|
287
|
+
break;
|
|
288
|
+
case node_opcua_variant_1.DataType.ByteString:
|
|
289
|
+
{
|
|
290
|
+
const base64 = value.toString("base64");
|
|
291
|
+
xw.text(base64.length > 80 ? base64.match(/.{0,80}/g).join("\n") : base64);
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
case node_opcua_variant_1.DataType.Guid:
|
|
295
|
+
/*
|
|
296
|
+
<uax:Guid>
|
|
297
|
+
<uax:String>947c29a7-490d-4dc9-adda-1109e3e8fcb7</uax:String>
|
|
298
|
+
</uax:Guid>
|
|
299
|
+
*/
|
|
300
|
+
if (value !== undefined && value !== null) {
|
|
301
|
+
// xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
302
|
+
xw.startElement("String");
|
|
303
|
+
xw.text(value.toString());
|
|
304
|
+
xw.endElement();
|
|
305
|
+
}
|
|
306
|
+
break;
|
|
307
|
+
case node_opcua_variant_1.DataType.ExtensionObject:
|
|
308
|
+
_dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, value);
|
|
309
|
+
break;
|
|
310
|
+
case node_opcua_variant_1.DataType.XmlElement:
|
|
311
|
+
_dumpXmlElement(xw, value);
|
|
312
|
+
break;
|
|
313
|
+
case node_opcua_variant_1.DataType.StatusCode:
|
|
314
|
+
xw.text(value.value.toString());
|
|
315
|
+
break;
|
|
316
|
+
default:
|
|
317
|
+
errorLog("_dumpVariantInnerValue incomplete " + value + " " + "DataType=" + dataType + "=" + node_opcua_variant_1.DataType[dataType]);
|
|
318
|
+
// throw new Error("_dumpVariantInnerValue incomplete " + value + " " + "DataType=" + dataType + "=" + DataType[dataType]);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
*
|
|
323
|
+
* @param xw
|
|
324
|
+
* @param schema
|
|
325
|
+
* @param value
|
|
326
|
+
* @private
|
|
327
|
+
*/
|
|
328
|
+
function _dumpVariantExtensionObjectValue_Body(xw, definitionMap, name, definition, value) {
|
|
329
|
+
if (value) {
|
|
330
|
+
xw.startElement(name);
|
|
331
|
+
if (value) {
|
|
332
|
+
_dumpVariantInnerExtensionObject(xw, definitionMap, definition, value);
|
|
333
|
+
}
|
|
334
|
+
xw.endElement();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function _dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, value) {
|
|
338
|
+
const { name, definition } = definitionMap.findDefinition(dataTypeNodeId);
|
|
339
|
+
// const encodingDefaultXml = (getStructureTypeConstructor(schema.name) as any).encodingDefaultXml;
|
|
340
|
+
const encodingDefaultXml = value.schema.encodingDefaultXml;
|
|
341
|
+
if (!encodingDefaultXml) {
|
|
342
|
+
// throw new Error("Extension Object doesn't provide a XML ");
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
xw.startElement("ExtensionObject");
|
|
346
|
+
{
|
|
347
|
+
xw.startElement("TypeId");
|
|
348
|
+
{
|
|
349
|
+
// find HasEncoding node
|
|
350
|
+
// xx var encodingDefaultXml = schema.encodingDefaultXml;
|
|
351
|
+
xw.startElement("Identifier");
|
|
352
|
+
xw.text(n(xw, encodingDefaultXml));
|
|
353
|
+
xw.endElement();
|
|
354
|
+
}
|
|
355
|
+
xw.endElement();
|
|
356
|
+
xw.startElement("Body");
|
|
357
|
+
_dumpVariantExtensionObjectValue_Body(xw, definitionMap, name, definition, value);
|
|
358
|
+
xw.endElement();
|
|
359
|
+
}
|
|
360
|
+
xw.endElement();
|
|
361
|
+
}
|
|
362
|
+
function _dumpVariantExtensionObjectValue2(xw, dataTypeNode, value) {
|
|
363
|
+
const addressSpace = dataTypeNode.addressSpace;
|
|
364
|
+
const definitionMap = (0, decode_xml_extension_object_1.makeDefinitionMap)(addressSpace);
|
|
365
|
+
_dumpVariantExtensionObjectValue(xw, dataTypeNode.nodeId, definitionMap, value);
|
|
366
|
+
}
|
|
367
|
+
// eslint-disable-next-line complexity
|
|
368
|
+
function _isDefaultValue(value) {
|
|
369
|
+
// detect default value
|
|
370
|
+
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
371
|
+
switch (value.dataType) {
|
|
372
|
+
case node_opcua_variant_1.DataType.ExtensionObject:
|
|
373
|
+
if (!value.value) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
break;
|
|
377
|
+
case node_opcua_variant_1.DataType.DateTime:
|
|
378
|
+
if (!value.value || value.value.getTime() === node_opcua_basic_types_1.minOPCUADate) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
break;
|
|
382
|
+
case node_opcua_variant_1.DataType.ByteString:
|
|
383
|
+
if (!value.value || value.value.length === 0) {
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
break;
|
|
387
|
+
case node_opcua_variant_1.DataType.Boolean:
|
|
388
|
+
if (!value.value) {
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
break;
|
|
392
|
+
case node_opcua_variant_1.DataType.SByte:
|
|
393
|
+
case node_opcua_variant_1.DataType.Byte:
|
|
394
|
+
case node_opcua_variant_1.DataType.UInt16:
|
|
395
|
+
case node_opcua_variant_1.DataType.UInt32:
|
|
396
|
+
case node_opcua_variant_1.DataType.Int16:
|
|
397
|
+
case node_opcua_variant_1.DataType.Int32:
|
|
398
|
+
case node_opcua_variant_1.DataType.Double:
|
|
399
|
+
case node_opcua_variant_1.DataType.Float:
|
|
400
|
+
if (value.value === 0 || value.value === null) {
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
break;
|
|
404
|
+
case node_opcua_variant_1.DataType.String:
|
|
405
|
+
if (value.value === null || value.value === "") {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
case node_opcua_variant_1.DataType.Int64:
|
|
410
|
+
case node_opcua_variant_1.DataType.UInt64:
|
|
411
|
+
if (0 === coerceInt64ToInt32(value.value)) {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
break;
|
|
415
|
+
case node_opcua_variant_1.DataType.LocalizedText:
|
|
416
|
+
if (!value.value) {
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
{
|
|
420
|
+
const l = value.value;
|
|
421
|
+
if (!l.locale && !l.text) {
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
if (!value.value || value.value.length === 0) {
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// eslint-disable-next-line max-statements
|
|
437
|
+
function _dumpValue(xw, node, value) {
|
|
438
|
+
const addressSpace = node.addressSpace;
|
|
439
|
+
// istanbul ignore next
|
|
440
|
+
if (value === null || value === undefined) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
(0, node_opcua_assert_1.assert)(value instanceof node_opcua_variant_1.Variant);
|
|
444
|
+
const dataTypeNode = addressSpace.findNode(node.dataType);
|
|
445
|
+
if (!dataTypeNode) {
|
|
446
|
+
console.log("Cannot find dataType:", node.dataType);
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const dataTypeName = dataTypeNode.browseName.name.toString();
|
|
450
|
+
const baseDataTypeName = node_opcua_variant_1.DataType[value.dataType];
|
|
451
|
+
if (baseDataTypeName === "Null") {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
(0, node_opcua_assert_1.assert)(typeof baseDataTypeName === "string");
|
|
455
|
+
// determine if dataTypeName is a ExtensionObject
|
|
456
|
+
const isExtensionObject = value.dataType === node_opcua_variant_1.DataType.ExtensionObject;
|
|
457
|
+
if (_isDefaultValue(value)) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
xw.startElement("Value");
|
|
461
|
+
if (isExtensionObject) {
|
|
462
|
+
const dataTypeNode = addressSpace.findDataType(node.dataType);
|
|
463
|
+
if (!dataTypeNode) {
|
|
464
|
+
throw new Error("Cannot find data type " + node.dataType.toString());
|
|
465
|
+
}
|
|
466
|
+
const encodeXml = _dumpVariantExtensionObjectValue2.bind(null, xw, dataTypeNode);
|
|
467
|
+
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
468
|
+
xw.startElement("ListOf" + baseDataTypeName);
|
|
469
|
+
value.value.forEach(encodeXml);
|
|
470
|
+
xw.endElement();
|
|
471
|
+
}
|
|
472
|
+
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
473
|
+
encodeXml(value.value);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
errorLog(node.toString());
|
|
477
|
+
errorLog("_dumpValue : unsupported case , Matrix of ExtensionObjects");
|
|
478
|
+
// throw new Error("Unsupported case");
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
const encodeXml = _dumpVariantValue.bind(null, xw, value.dataType, node);
|
|
483
|
+
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
484
|
+
// console.log("Warning _dumpValue : Matrix not supported yet");
|
|
485
|
+
xw.startElement("ListOf" + dataTypeName);
|
|
486
|
+
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
487
|
+
value.value.forEach(encodeXml);
|
|
488
|
+
xw.endElement();
|
|
489
|
+
}
|
|
490
|
+
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
491
|
+
xw.startElement("ListOf" + dataTypeName);
|
|
492
|
+
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
493
|
+
value.value.forEach(encodeXml);
|
|
494
|
+
xw.endElement();
|
|
495
|
+
}
|
|
496
|
+
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
497
|
+
encodeXml(value.value);
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
errorLog(node.toString());
|
|
501
|
+
errorLog("_dumpValue : unsupported case , Matrix");
|
|
502
|
+
// xx throw new Error("Unsupported case");
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
xw.endElement();
|
|
506
|
+
}
|
|
507
|
+
function _dumpArrayDimensionsAttribute(xw, node) {
|
|
508
|
+
if (node.arrayDimensions) {
|
|
509
|
+
if (node.valueRank === -1 || (node.arrayDimensions.length === 1 && node.arrayDimensions[0] === 0)) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
xw.writeAttribute("ArrayDimensions", node.arrayDimensions.join(","));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
function visitUANode(node, options, forward) {
|
|
516
|
+
(0, node_opcua_assert_1.assert)(typeof forward === "boolean");
|
|
517
|
+
const addressSpace = node.addressSpace;
|
|
518
|
+
options.elements = options.elements || [];
|
|
519
|
+
options.index_el = options.index_el || {};
|
|
520
|
+
// visit references
|
|
521
|
+
function process_reference(reference) {
|
|
522
|
+
// only backward or forward references
|
|
523
|
+
if (reference.isForward !== forward) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (reference.nodeId.namespace === 0) {
|
|
527
|
+
return; // skip OPCUA namespace
|
|
528
|
+
}
|
|
529
|
+
const k = _hash(reference);
|
|
530
|
+
if (!options.index_el[k]) {
|
|
531
|
+
options.index_el[k] = 1;
|
|
532
|
+
const o = addressSpace.findNode(k);
|
|
533
|
+
if (o) {
|
|
534
|
+
visitUANode(o, options, forward);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
node.ownReferences().forEach(process_reference);
|
|
539
|
+
options.elements.push(node);
|
|
540
|
+
return node;
|
|
541
|
+
}
|
|
542
|
+
function dumpNodeInXml(xw, node) {
|
|
543
|
+
return node.dumpXML(xw);
|
|
544
|
+
}
|
|
545
|
+
function dumpReferencedNodes(xw, node, forward) {
|
|
546
|
+
const addressSpace = node.addressSpace;
|
|
547
|
+
if (!forward) {
|
|
548
|
+
{
|
|
549
|
+
const r = node.findReferencesEx("HasTypeDefinition");
|
|
550
|
+
if (r && r.length) {
|
|
551
|
+
(0, node_opcua_assert_1.assert)(r.length === 1);
|
|
552
|
+
const typeDefinitionObj = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, r[0]);
|
|
553
|
+
if (!typeDefinitionObj) {
|
|
554
|
+
warningLog(node.toString());
|
|
555
|
+
warningLog("dumpReferencedNodes: Warning : " + node.browseName.toString() + " unknown typeDefinition, ", r[0].toString());
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
(0, node_opcua_assert_1.assert)(typeDefinitionObj instanceof base_node_impl_1.BaseNodeImpl);
|
|
559
|
+
if (typeDefinitionObj.nodeId.namespace === node.nodeId.namespace) {
|
|
560
|
+
// only output node if it is on the same namespace
|
|
561
|
+
if (!xw.visitedNode[_hash(typeDefinitionObj)]) {
|
|
562
|
+
dumpNodeInXml(xw, typeDefinitionObj);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
//
|
|
569
|
+
{
|
|
570
|
+
const r = node.findReferencesEx("HasSubtype", node_opcua_data_model_1.BrowseDirection.Inverse);
|
|
571
|
+
if (r && r.length) {
|
|
572
|
+
const subTypeOf = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, r[0]);
|
|
573
|
+
(0, node_opcua_assert_1.assert)(r.length === 1);
|
|
574
|
+
if (subTypeOf.nodeId.namespace === node.nodeId.namespace) {
|
|
575
|
+
// only output node if it is on the same namespace
|
|
576
|
+
if (!xw.visitedNode[_hash(subTypeOf)]) {
|
|
577
|
+
dumpNodeInXml(xw, subTypeOf);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
const r = node.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
585
|
+
for (const reference of r) {
|
|
586
|
+
const nodeChild = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
587
|
+
(0, node_opcua_assert_1.assert)(nodeChild instanceof base_node_impl_1.BaseNodeImpl);
|
|
588
|
+
if (nodeChild.nodeId.namespace === node.nodeId.namespace) {
|
|
589
|
+
if (!xw.visitedNode[_hash(nodeChild)]) {
|
|
590
|
+
console.log(node.nodeId.toString(), " dumping child ", nodeChild.browseName.toString(), nodeChild.nodeId.toString());
|
|
591
|
+
dumpNodeInXml(xw, nodeChild);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const currentReadFlag = (0, node_opcua_data_model_1.makeAccessLevelFlag)("CurrentRead");
|
|
598
|
+
function dumpCommonAttributes(xw, node) {
|
|
599
|
+
xw.writeAttribute("NodeId", n(xw, node.nodeId));
|
|
600
|
+
xw.writeAttribute("BrowseName", b(xw, node.browseName));
|
|
601
|
+
if (Object.prototype.hasOwnProperty.call(node, "symbolicName")) {
|
|
602
|
+
xw.writeAttribute("SymbolicName", node.symbolicName);
|
|
603
|
+
}
|
|
604
|
+
if (Object.prototype.hasOwnProperty.call(node, "isAbstract")) {
|
|
605
|
+
if (node.isAbstract) {
|
|
606
|
+
xw.writeAttribute("IsAbstract", node.isAbstract ? "true" : "false");
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (Object.prototype.hasOwnProperty.call(node, "accessLevel")) {
|
|
610
|
+
// CurrentRead is by default
|
|
611
|
+
if (node.accessLevel !== currentReadFlag) {
|
|
612
|
+
xw.writeAttribute("AccessLevel", node.accessLevel.toString());
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function dumpCommonElements(xw, node) {
|
|
617
|
+
_dumpDisplayName(xw, node);
|
|
618
|
+
_dumpDescription(xw, node);
|
|
619
|
+
_dumpReferences(xw, node);
|
|
620
|
+
}
|
|
621
|
+
function coerceInt64ToInt32(int64) {
|
|
622
|
+
if (typeof int64 === "number") {
|
|
623
|
+
return int64;
|
|
624
|
+
}
|
|
625
|
+
if (int64[0] === 4294967295 && int64[1] === 4294967295) {
|
|
626
|
+
return 0xffffffff;
|
|
627
|
+
}
|
|
628
|
+
if (int64[0] !== 0) {
|
|
629
|
+
debugLog("coerceInt64ToInt32 , loosing high word in conversion");
|
|
630
|
+
}
|
|
631
|
+
return int64[1];
|
|
632
|
+
}
|
|
633
|
+
function _dumpEnumDefinition(xw, enumDefinition) {
|
|
634
|
+
enumDefinition.fields = enumDefinition.fields || [];
|
|
635
|
+
for (const defItem of enumDefinition.fields) {
|
|
636
|
+
xw.startElement("Field");
|
|
637
|
+
xw.writeAttribute("Name", defItem.name);
|
|
638
|
+
if (!utils.isNullOrUndefined(defItem.value)) {
|
|
639
|
+
xw.writeAttribute("Value", coerceInt64ToInt32(defItem.value));
|
|
640
|
+
}
|
|
641
|
+
_dumpDescription(xw, defItem);
|
|
642
|
+
xw.endElement();
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function _dumpStructureDefinition(xw, structureDefinition, baseStructureDefinition) {
|
|
646
|
+
var _a;
|
|
647
|
+
/*
|
|
648
|
+
* note: baseDataType and defaultEncodingId are implicit and not stored in the XML file ??
|
|
649
|
+
*
|
|
650
|
+
*/
|
|
651
|
+
const baseDataType = structureDefinition.baseDataType;
|
|
652
|
+
const defaultEncodingId = structureDefinition.defaultEncodingId;
|
|
653
|
+
// do not repeat elements that are already defined in base structure in the xml ouput!
|
|
654
|
+
const fields = structureDefinition.fields || [];
|
|
655
|
+
const nbFieldsInBase = baseStructureDefinition ? ((_a = baseStructureDefinition.fields) === null || _a === void 0 ? void 0 : _a.length) || 0 : 0;
|
|
656
|
+
for (let index = nbFieldsInBase; index < fields.length; index++) {
|
|
657
|
+
const defItem = fields[index];
|
|
658
|
+
xw.startElement("Field");
|
|
659
|
+
xw.writeAttribute("Name", defItem.name);
|
|
660
|
+
if (defItem.arrayDimensions) {
|
|
661
|
+
xw.writeAttribute("ArrayDimensions", defItem.arrayDimensions.map((x) => x.toString()).join(","));
|
|
662
|
+
}
|
|
663
|
+
if (defItem.valueRank !== undefined && defItem.valueRank !== -1) {
|
|
664
|
+
xw.writeAttribute("ValueRank", defItem.valueRank);
|
|
665
|
+
}
|
|
666
|
+
if (defItem.isOptional /* && defItem.isOptional !== false */) {
|
|
667
|
+
xw.writeAttribute("IsOptional", defItem.isOptional.toString());
|
|
668
|
+
}
|
|
669
|
+
if (defItem.maxStringLength !== undefined && defItem.maxStringLength !== 0) {
|
|
670
|
+
xw.writeAttribute("MaxStringLength", defItem.maxStringLength);
|
|
671
|
+
}
|
|
672
|
+
// todo : SymbolicName ( see AutoId )
|
|
673
|
+
if (defItem.dataType) {
|
|
674
|
+
// todo : namespace translation !
|
|
675
|
+
xw.writeAttribute("DataType", n(xw, defItem.dataType));
|
|
676
|
+
}
|
|
677
|
+
_dumpDescription(xw, defItem);
|
|
678
|
+
xw.endElement();
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function _dumpUADataTypeDefinition(xw, uaDataType) {
|
|
682
|
+
const uaDataTypeBase = uaDataType.subtypeOfObj;
|
|
683
|
+
if (uaDataType.isEnumeration()) {
|
|
684
|
+
xw.startElement("Definition");
|
|
685
|
+
xw.writeAttribute("Name", b(xw, uaDataType.browseName));
|
|
686
|
+
_dumpEnumDefinition(xw, uaDataType.getEnumDefinition());
|
|
687
|
+
xw.endElement();
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (uaDataType.isStructure()) {
|
|
691
|
+
const definition = uaDataType.getStructureDefinition();
|
|
692
|
+
const baseDefinition = uaDataTypeBase ? uaDataTypeBase.getStructureDefinition() : null;
|
|
693
|
+
xw.startElement("Definition");
|
|
694
|
+
xw.writeAttribute("Name", b(xw, uaDataType.browseName));
|
|
695
|
+
if (definition.structureType === node_opcua_types_1.StructureType.Union) {
|
|
696
|
+
xw.writeAttribute("IsUnion", "true");
|
|
697
|
+
}
|
|
698
|
+
_dumpStructureDefinition(xw, definition, baseDefinition);
|
|
699
|
+
xw.endElement();
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function dumpUADataType(xw, node) {
|
|
704
|
+
_markAsVisited(xw, node);
|
|
705
|
+
xw.startElement("UADataType");
|
|
706
|
+
xw.writeAttribute("NodeId", n(xw, node.nodeId));
|
|
707
|
+
xw.writeAttribute("BrowseName", b(xw, node.browseName));
|
|
708
|
+
if (node.symbolicName !== node.browseName.name) {
|
|
709
|
+
xw.writeAttribute("SymbolicName", node.symbolicName);
|
|
710
|
+
}
|
|
711
|
+
if (node.isAbstract) {
|
|
712
|
+
xw.writeAttribute("IsAbstract", node.isAbstract ? "true" : "false");
|
|
713
|
+
}
|
|
714
|
+
_dumpDisplayName(xw, node);
|
|
715
|
+
_dumpReferences(xw, node);
|
|
716
|
+
_dumpUADataTypeDefinition(xw, node);
|
|
717
|
+
xw.endElement();
|
|
718
|
+
dumpAggregates(xw, node);
|
|
719
|
+
}
|
|
720
|
+
function _markAsVisited(xw, node) {
|
|
721
|
+
xw.visitedNode = xw.visitedNode || {};
|
|
722
|
+
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
723
|
+
xw.visitedNode[_hash(node)] = 1;
|
|
724
|
+
}
|
|
725
|
+
function dumpUAVariable(xw, node) {
|
|
726
|
+
_markAsVisited(xw, node);
|
|
727
|
+
dumpReferencedNodes(xw, node, false);
|
|
728
|
+
const addressSpace = node.addressSpace;
|
|
729
|
+
xw.startElement("UAVariable");
|
|
730
|
+
{
|
|
731
|
+
// attributes
|
|
732
|
+
dumpCommonAttributes(xw, node);
|
|
733
|
+
if (node.valueRank !== -1) {
|
|
734
|
+
// -1 = Scalar
|
|
735
|
+
xw.writeAttribute("ValueRank", node.valueRank);
|
|
736
|
+
}
|
|
737
|
+
_dumpArrayDimensionsAttribute(xw, node);
|
|
738
|
+
const dataTypeNode = addressSpace.findNode(node.dataType);
|
|
739
|
+
if (dataTypeNode) {
|
|
740
|
+
// verify that data Type is in alias
|
|
741
|
+
// xx const dataTypeName = dataTypeNode.browseName.toString();
|
|
742
|
+
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
|
|
743
|
+
xw.writeAttribute("DataType", dataTypeName);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
{
|
|
747
|
+
// sub elements
|
|
748
|
+
dumpCommonElements(xw, node);
|
|
749
|
+
const value = node.$dataValue.value;
|
|
750
|
+
if (value) {
|
|
751
|
+
_dumpValue(xw, node, value);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
xw.endElement();
|
|
755
|
+
dumpAggregates(xw, node);
|
|
756
|
+
}
|
|
757
|
+
function dumpUAVariableType(xw, node) {
|
|
758
|
+
xw.visitedNode = xw.visitedNode || {};
|
|
759
|
+
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
760
|
+
xw.visitedNode[_hash(node)] = 1;
|
|
761
|
+
dumpReferencedNodes(xw, node, false);
|
|
762
|
+
const addressSpace = node.addressSpace;
|
|
763
|
+
xw.startElement("UAVariableType");
|
|
764
|
+
{
|
|
765
|
+
// attributes
|
|
766
|
+
dumpCommonAttributes(xw, node);
|
|
767
|
+
if (node.valueRank !== -1) {
|
|
768
|
+
xw.writeAttribute("ValueRank", node.valueRank);
|
|
769
|
+
}
|
|
770
|
+
const dataTypeNode = addressSpace.findNode(node.dataType);
|
|
771
|
+
if (!dataTypeNode) {
|
|
772
|
+
// throw new Error(" cannot find datatype " + node.dataType);
|
|
773
|
+
console.log(" cannot find datatype " +
|
|
774
|
+
node.dataType +
|
|
775
|
+
" for node " +
|
|
776
|
+
node.browseName.toString() +
|
|
777
|
+
" id =" +
|
|
778
|
+
node.nodeId.toString());
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
|
|
782
|
+
xw.writeAttribute("DataType", dataTypeName);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
{
|
|
786
|
+
_dumpArrayDimensionsAttribute(xw, node);
|
|
787
|
+
// sub elements
|
|
788
|
+
dumpCommonElements(xw, node);
|
|
789
|
+
const value = node.value;
|
|
790
|
+
if (value) {
|
|
791
|
+
_dumpValue(xw, node, value);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
xw.endElement();
|
|
795
|
+
dumpAggregates(xw, node);
|
|
796
|
+
}
|
|
797
|
+
function dumpUAObject(xw, node) {
|
|
798
|
+
xw.writeComment("Object - " + b(xw, node.browseName) + " {{{{ ");
|
|
799
|
+
xw.visitedNode = xw.visitedNode || {};
|
|
800
|
+
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
801
|
+
xw.visitedNode[_hash(node)] = 1;
|
|
802
|
+
// dump SubTypeOf and HasTypeDefinition
|
|
803
|
+
dumpReferencedNodes(xw, node, false);
|
|
804
|
+
xw.startElement("UAObject");
|
|
805
|
+
dumpCommonAttributes(xw, node);
|
|
806
|
+
dumpCommonElements(xw, node);
|
|
807
|
+
xw.endElement();
|
|
808
|
+
// dump aggregates nodes ( Properties / components )
|
|
809
|
+
dumpAggregates(xw, node);
|
|
810
|
+
dumpElementInFolder(xw, node);
|
|
811
|
+
xw.writeComment("Object - " + b(xw, node.browseName) + " }}}} ");
|
|
812
|
+
}
|
|
813
|
+
function dumpElementInFolder(xw, node) {
|
|
814
|
+
const aggregates = node
|
|
815
|
+
.getFolderElements()
|
|
816
|
+
.sort((x, y) => (x.browseName.name.toString() > y.browseName.name.toString() ? 1 : -1));
|
|
817
|
+
for (const aggregate of aggregates.sort(sortByNodeId)) {
|
|
818
|
+
// do not export node that do not belong to our namespace
|
|
819
|
+
if (node.nodeId.namespace !== aggregate.nodeId.namespace) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (!xw.visitedNode[_hash(aggregate)]) {
|
|
823
|
+
aggregate.dumpXML(xw);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
function dumpAggregates(xw, node) {
|
|
828
|
+
// Xx xw.writeComment("Aggregates {{ ");
|
|
829
|
+
const aggregates = node
|
|
830
|
+
.getAggregates()
|
|
831
|
+
.sort((x, y) => (x.browseName.name.toString() > y.browseName.name.toString() ? 1 : -1));
|
|
832
|
+
for (const aggregate of aggregates.sort(sortByNodeId)) {
|
|
833
|
+
// do not export node that do not belong to our namespace
|
|
834
|
+
if (node.nodeId.namespace !== aggregate.nodeId.namespace) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
if (!xw.visitedNode[_hash(aggregate)]) {
|
|
838
|
+
aggregate.dumpXML(xw);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
// Xx xw.writeComment("Aggregates }} ");
|
|
842
|
+
}
|
|
843
|
+
function dumpUAObjectType(xw, node) {
|
|
844
|
+
(0, node_opcua_assert_1.assert)(node instanceof ua_object_type_impl_1.UAObjectTypeImpl);
|
|
845
|
+
xw.writeComment("ObjectType - " + b(xw, node.browseName) + " {{{{ ");
|
|
846
|
+
_markAsVisited(xw, node);
|
|
847
|
+
// dump SubtypeOf and HasTypeDefinition
|
|
848
|
+
dumpReferencedNodes(xw, node, false);
|
|
849
|
+
xw.startElement("UAObjectType");
|
|
850
|
+
dumpCommonAttributes(xw, node);
|
|
851
|
+
dumpCommonElements(xw, node);
|
|
852
|
+
xw.endElement();
|
|
853
|
+
dumpAggregates(xw, node);
|
|
854
|
+
xw.writeComment("ObjectType - " + b(xw, node.browseName) + " }}}}");
|
|
855
|
+
}
|
|
856
|
+
function dumpUAMethod(xw, node) {
|
|
857
|
+
_markAsVisited(xw, node);
|
|
858
|
+
dumpReferencedNodes(xw, node, false);
|
|
859
|
+
xw.startElement("UAMethod");
|
|
860
|
+
dumpCommonAttributes(xw, node);
|
|
861
|
+
if (node.methodDeclarationId) {
|
|
862
|
+
xw.writeAttribute("MethodDeclarationId", n(xw, node.methodDeclarationId));
|
|
863
|
+
}
|
|
864
|
+
dumpCommonElements(xw, node);
|
|
865
|
+
xw.endElement();
|
|
866
|
+
dumpAggregates(xw, node);
|
|
867
|
+
}
|
|
868
|
+
function resolveDataTypeName(addressSpace, dataType) {
|
|
869
|
+
let dataTypeNode = null;
|
|
870
|
+
// istanbul ignore next
|
|
871
|
+
if (typeof dataType === "string") {
|
|
872
|
+
dataTypeNode = addressSpace.findDataType(dataType);
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
(0, node_opcua_assert_1.assert)(dataType instanceof node_opcua_nodeid_1.NodeId);
|
|
876
|
+
const o = addressSpace.findNode(dataType.toString());
|
|
877
|
+
dataTypeNode = o ? o : null;
|
|
878
|
+
}
|
|
879
|
+
if (!dataTypeNode) {
|
|
880
|
+
errorLog("resolveDataTypeName: warning cannot find DataType " + dataType.toString());
|
|
881
|
+
return new node_opcua_data_model_1.QualifiedName({ name: "", namespaceIndex: 0 });
|
|
882
|
+
}
|
|
883
|
+
return dataTypeNode.browseName;
|
|
884
|
+
}
|
|
885
|
+
function buildUpAliases(node, xw, options) {
|
|
886
|
+
const addressSpace = node.addressSpace;
|
|
887
|
+
options.aliases = options.aliases || {};
|
|
888
|
+
options.aliases_visited = options.aliases_visited || {};
|
|
889
|
+
const k = _hash(node);
|
|
890
|
+
// istanbul ignore next
|
|
891
|
+
if (options.aliases_visited[k]) {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
options.aliases_visited[k] = 1;
|
|
895
|
+
// put datatype into aliases list
|
|
896
|
+
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
897
|
+
const nodeV = node;
|
|
898
|
+
if (nodeV.dataType && nodeV.dataType.namespace === 0 && nodeV.dataType.value !== 0) {
|
|
899
|
+
// name
|
|
900
|
+
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, nodeV.dataType));
|
|
901
|
+
if (dataTypeName) {
|
|
902
|
+
if (!options.aliases[dataTypeName]) {
|
|
903
|
+
options.aliases[dataTypeName] = n(xw, nodeV.dataType);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
if (nodeV.dataType && nodeV.dataType.namespace !== 0 && nodeV.dataType.value !== 0) {
|
|
908
|
+
// name
|
|
909
|
+
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, nodeV.dataType));
|
|
910
|
+
if (dataTypeName) {
|
|
911
|
+
if (!options.aliases[dataTypeName]) {
|
|
912
|
+
options.aliases[dataTypeName] = n(xw, nodeV.dataType);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
function collectReferenceNameInAlias(reference) {
|
|
918
|
+
// reference.referenceType
|
|
919
|
+
const key = b(xw, (0, base_node_impl_1.getReferenceType)(reference).browseName);
|
|
920
|
+
if (!options.aliases.key) {
|
|
921
|
+
if (reference.referenceType.namespace === 0) {
|
|
922
|
+
options.aliases[key] = reference.referenceType.toString().replace("ns=0;", "");
|
|
923
|
+
}
|
|
924
|
+
else {
|
|
925
|
+
options.aliases[key] = n(xw, reference.referenceType);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
node.allReferences().forEach(collectReferenceNameInAlias);
|
|
930
|
+
}
|
|
931
|
+
function writeAliases(xw, aliases) {
|
|
932
|
+
xw.startElement("Aliases");
|
|
933
|
+
if (aliases) {
|
|
934
|
+
const keys = Object.keys(aliases).sort();
|
|
935
|
+
for (const key of keys) {
|
|
936
|
+
xw.startElement("Alias");
|
|
937
|
+
xw.writeAttribute("Alias", key);
|
|
938
|
+
xw.text(aliases[key].toString().replace(/ns=0;/, ""));
|
|
939
|
+
xw.endElement();
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
xw.endElement();
|
|
943
|
+
}
|
|
944
|
+
function constructNamespaceTranslationTable(dependency) {
|
|
945
|
+
const translationTable = {};
|
|
946
|
+
for (let i = 0; i < dependency.length; i++) {
|
|
947
|
+
translationTable[dependency[i].index] = i;
|
|
948
|
+
}
|
|
949
|
+
return translationTable;
|
|
950
|
+
}
|
|
951
|
+
function dumpReferenceType(xw, referenceType) {
|
|
952
|
+
_markAsVisited(xw, referenceType);
|
|
953
|
+
xw.startElement("UAReferenceType");
|
|
954
|
+
dumpCommonAttributes(xw, referenceType);
|
|
955
|
+
dumpCommonElements(xw, referenceType);
|
|
956
|
+
if (referenceType.inverseName /* LocalizedText*/) {
|
|
957
|
+
xw.startElement("InverseName");
|
|
958
|
+
xw.text(referenceType.inverseName.text || "");
|
|
959
|
+
xw.endElement();
|
|
960
|
+
}
|
|
961
|
+
xw.endElement();
|
|
962
|
+
}
|
|
963
|
+
function sortByBrowseName(x, y) {
|
|
964
|
+
const x_str = x.browseName.toString();
|
|
965
|
+
const y_str = y.browseName.toString();
|
|
966
|
+
if (x_str > y_str) {
|
|
967
|
+
return -1;
|
|
968
|
+
}
|
|
969
|
+
else if (x_str < y_str) {
|
|
970
|
+
return 1;
|
|
971
|
+
}
|
|
972
|
+
return 0;
|
|
973
|
+
}
|
|
974
|
+
function sortByNodeId(a, b) {
|
|
975
|
+
return a.nodeId.toString() < b.nodeId.toString() ? -1 : 1;
|
|
976
|
+
}
|
|
977
|
+
function dumpXml(node, options) {
|
|
978
|
+
const namespace = node.namespace;
|
|
979
|
+
// make a first visit so that we determine which node to output and in which order
|
|
980
|
+
const nodesToVisit = {};
|
|
981
|
+
const dependency = (0, construct_namespace_dependency_1.constructNamespaceDependency)(namespace);
|
|
982
|
+
const translationTable = constructNamespaceTranslationTable(dependency);
|
|
983
|
+
const xw = new XMLWriter(true);
|
|
984
|
+
xw.translationTable = translationTable;
|
|
985
|
+
visitUANode(node, nodesToVisit, false);
|
|
986
|
+
xw.startDocument({ encoding: "utf-8" });
|
|
987
|
+
xw.startElement("UANodeSet");
|
|
988
|
+
xw.writeAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema-instance");
|
|
989
|
+
xw.writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
|
|
990
|
+
xw.writeAttribute("Version", "1.02");
|
|
991
|
+
xw.writeAttribute("LastModified", new Date().toISOString());
|
|
992
|
+
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd");
|
|
993
|
+
buildUpAliases(node, xw, nodesToVisit);
|
|
994
|
+
writeAliases(xw, nodesToVisit.aliases);
|
|
995
|
+
for (const el of nodesToVisit.elements) {
|
|
996
|
+
el.dumpXML(xw);
|
|
997
|
+
}
|
|
998
|
+
xw.endElement();
|
|
999
|
+
xw.endDocument();
|
|
1000
|
+
return xw.toString();
|
|
1001
|
+
}
|
|
1002
|
+
exports.dumpXml = dumpXml;
|
|
1003
|
+
ua_method_impl_1.UAMethodImpl.prototype.dumpXML = function (xw) {
|
|
1004
|
+
dumpUAMethod(xw, this);
|
|
1005
|
+
};
|
|
1006
|
+
ua_object_impl_1.UAObjectImpl.prototype.dumpXML = function (xw) {
|
|
1007
|
+
dumpUAObject(xw, this);
|
|
1008
|
+
};
|
|
1009
|
+
ua_variable_impl_1.UAVariableImpl.prototype.dumpXML = function (xw) {
|
|
1010
|
+
dumpUAVariable(xw, this);
|
|
1011
|
+
};
|
|
1012
|
+
ua_variable_type_impl_1.UAVariableTypeImpl.prototype.dumpXML = function (xw) {
|
|
1013
|
+
dumpUAVariableType(xw, this);
|
|
1014
|
+
};
|
|
1015
|
+
ua_reference_type_impl_1.UAReferenceTypeImpl.prototype.dumpXML = function (xw) {
|
|
1016
|
+
dumpReferenceType(xw, this);
|
|
1017
|
+
};
|
|
1018
|
+
ua_object_type_impl_1.UAObjectTypeImpl.prototype.dumpXML = function (xw) {
|
|
1019
|
+
dumpUAObjectType(xw, this);
|
|
1020
|
+
};
|
|
1021
|
+
ua_data_type_impl_1.UADataTypeImpl.prototype.dumpXML = function (xw) {
|
|
1022
|
+
dumpUADataType(xw, this);
|
|
1023
|
+
};
|
|
1024
|
+
// eslint-disable-next-line max-statements
|
|
1025
|
+
namespace_impl_1.NamespaceImpl.prototype.toNodeset2XML = function () {
|
|
1026
|
+
const dependency = (0, construct_namespace_dependency_1.constructNamespaceDependency)(this);
|
|
1027
|
+
const translationTable = constructNamespaceTranslationTable(dependency);
|
|
1028
|
+
const xw = new XMLWriter(true);
|
|
1029
|
+
xw.translationTable = translationTable;
|
|
1030
|
+
xw.startDocument({ encoding: "utf-8", version: "1.0" });
|
|
1031
|
+
xw.startElement("UANodeSet");
|
|
1032
|
+
xw.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
|
1033
|
+
xw.writeAttribute("xmlns:uax", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
1034
|
+
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd");
|
|
1035
|
+
// xx xw.writeAttribute("Version", "1.02");
|
|
1036
|
+
// xx xw.writeAttribute("LastModified", (new Date()).toISOString());
|
|
1037
|
+
// ------------- INamespace Uris
|
|
1038
|
+
xw.startElement("NamespaceUris");
|
|
1039
|
+
// xx const namespaceArray = namespace.addressSpace.getNamespaceArray();
|
|
1040
|
+
for (const depend of dependency) {
|
|
1041
|
+
if (depend.index === 0) {
|
|
1042
|
+
continue; // ignore namespace 0
|
|
1043
|
+
}
|
|
1044
|
+
xw.startElement("Uri");
|
|
1045
|
+
xw.text(depend.namespaceUri);
|
|
1046
|
+
xw.endElement();
|
|
1047
|
+
}
|
|
1048
|
+
xw.endElement();
|
|
1049
|
+
// ------------- INamespace Uris
|
|
1050
|
+
xw.startElement("Models");
|
|
1051
|
+
{
|
|
1052
|
+
xw.startElement("Model");
|
|
1053
|
+
xw.writeAttribute("ModelUri", this.namespaceUri);
|
|
1054
|
+
xw.writeAttribute("Version", this.version);
|
|
1055
|
+
xw.writeAttribute("PublicationDate", this.publicationDate.toISOString());
|
|
1056
|
+
for (const depend of dependency) {
|
|
1057
|
+
if (depend.index === this.index) {
|
|
1058
|
+
continue; // ignore our namespace 0
|
|
1059
|
+
}
|
|
1060
|
+
xw.startElement("RequiredModel");
|
|
1061
|
+
xw.writeAttribute("ModelUri", depend.namespaceUri);
|
|
1062
|
+
xw.writeAttribute("Version", depend.version);
|
|
1063
|
+
xw.writeAttribute("PublicationDate", depend.publicationDate.toISOString());
|
|
1064
|
+
xw.endElement();
|
|
1065
|
+
}
|
|
1066
|
+
xw.endElement();
|
|
1067
|
+
}
|
|
1068
|
+
xw.endElement();
|
|
1069
|
+
const s = {};
|
|
1070
|
+
for (const node of this.nodeIterator()) {
|
|
1071
|
+
buildUpAliases(node, xw, s);
|
|
1072
|
+
}
|
|
1073
|
+
writeAliases(xw, s.aliases);
|
|
1074
|
+
xw.visitedNode = {};
|
|
1075
|
+
// -------------- writeReferences
|
|
1076
|
+
xw.writeComment("ReferenceTypes");
|
|
1077
|
+
const referenceTypes = [...this._referenceTypeIterator()].sort(sortByBrowseName);
|
|
1078
|
+
for (const referenceType of referenceTypes) {
|
|
1079
|
+
dumpReferenceType(xw, referenceType);
|
|
1080
|
+
}
|
|
1081
|
+
// -------------- Dictionaries
|
|
1082
|
+
const addressSpace = this.addressSpace;
|
|
1083
|
+
const opcBinaryTypeSystem = addressSpace.findNode("OPCBinarySchema_TypeSystem");
|
|
1084
|
+
if (opcBinaryTypeSystem) {
|
|
1085
|
+
// let find all DataType dictionary node corresponding to a given namespace
|
|
1086
|
+
// (have DataTypeDictionaryType)
|
|
1087
|
+
const nodeToBrowse = new node_opcua_types_1.BrowseDescription({
|
|
1088
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
1089
|
+
includeSubtypes: false,
|
|
1090
|
+
nodeClassMask: (0, node_opcua_data_model_1.makeNodeClassMask)("Variable"),
|
|
1091
|
+
nodeId: opcBinaryTypeSystem.nodeId,
|
|
1092
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasComponent"),
|
|
1093
|
+
resultMask: (0, node_opcua_data_model_1.makeResultMask)("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
|
|
1094
|
+
});
|
|
1095
|
+
const result = opcBinaryTypeSystem.browseNode(nodeToBrowse).filter((r) => r.nodeId.namespace === this.index);
|
|
1096
|
+
(0, node_opcua_assert_1.assert)(result.length <= 1);
|
|
1097
|
+
if (result.length === 1) {
|
|
1098
|
+
xw.writeComment("DataSystem");
|
|
1099
|
+
const dataSystemType = addressSpace.findNode(result[0].nodeId);
|
|
1100
|
+
dumpNodeInXml(xw, dataSystemType);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
// -------------- DataTypes
|
|
1104
|
+
const dataTypes = [...this._dataTypeIterator()].sort(sortByBrowseName);
|
|
1105
|
+
if (dataTypes.length) {
|
|
1106
|
+
xw.writeComment("DataTypes");
|
|
1107
|
+
// xx xw.writeComment(" "+ objectTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1108
|
+
for (const dataType of dataTypes.sort(sortByNodeId)) {
|
|
1109
|
+
if (!xw.visitedNode[_hash(dataType)]) {
|
|
1110
|
+
dumpNodeInXml(xw, dataType);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
// -------------- ObjectTypes
|
|
1115
|
+
xw.writeComment("ObjectTypes");
|
|
1116
|
+
const objectTypes = [...this._objectTypeIterator()].sort(sortByBrowseName);
|
|
1117
|
+
// xx xw.writeComment(" "+ objectTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1118
|
+
for (const objectType of objectTypes.sort(sortByNodeId)) {
|
|
1119
|
+
if (!xw.visitedNode[_hash(objectType)]) {
|
|
1120
|
+
dumpNodeInXml(xw, objectType);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
// -------------- VariableTypes
|
|
1124
|
+
xw.writeComment("VariableTypes");
|
|
1125
|
+
const variableTypes = [...this._variableTypeIterator()].sort(sortByBrowseName);
|
|
1126
|
+
// xx xw.writeComment("ObjectTypes "+ variableTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1127
|
+
for (const variableType of variableTypes.sort(sortByNodeId)) {
|
|
1128
|
+
if (!xw.visitedNode[_hash(variableType)]) {
|
|
1129
|
+
dumpNodeInXml(xw, variableType);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
// -------------- Any thing else
|
|
1133
|
+
xw.writeComment("Other Nodes");
|
|
1134
|
+
const nodes = [...this.nodeIterator()].sort(sortByBrowseName);
|
|
1135
|
+
for (const node of nodes.sort(sortByNodeId)) {
|
|
1136
|
+
if (!xw.visitedNode[_hash(node)]) {
|
|
1137
|
+
dumpNodeInXml(xw, node);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
xw.endElement();
|
|
1141
|
+
xw.endDocument();
|
|
1142
|
+
return xw.toString();
|
|
1143
|
+
};
|
|
1144
1144
|
//# sourceMappingURL=nodeset_to_xml.js.map
|