node-opcua-address-space 2.76.1 → 2.76.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 +33 -33
- package/dist/source/helpers/argument_list.js +258 -258
- 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 -0
- package/dist/source/helpers/check_event_clause.js +53 -0
- package/dist/source/helpers/check_event_clause.js.map +1 -0
- package/dist/source/helpers/coerce_enum_value.d.ts +6 -6
- package/dist/source/helpers/coerce_enum_value.js +33 -33
- package/dist/source/helpers/dump_tools.d.ts +14 -14
- package/dist/source/helpers/dump_tools.js +78 -78
- package/dist/source/helpers/ensure_secure_access.d.ts +9 -9
- package/dist/source/helpers/ensure_secure_access.js +76 -76
- package/dist/source/helpers/make_optionals_map.d.ts +21 -21
- package/dist/source/helpers/make_optionals_map.js +29 -29
- package/dist/source/helpers/multiform_func.d.ts +11 -11
- package/dist/source/helpers/multiform_func.js +75 -75
- package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -3
- package/dist/source/helpers/resolve_opaque_on_address_space.js +36 -36
- package/dist/source/index.d.ts +56 -56
- package/dist/source/index.js +83 -83
- package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +19 -19
- package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +193 -193
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.d.ts +12 -12
- package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.d.ts +10 -10
- package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.d.ts +7 -7
- package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.d.ts +7 -7
- package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.d.ts +9 -9
- package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.d.ts +4 -4
- package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.d.ts +20 -20
- package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +23 -23
- package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.d.ts +32 -32
- package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.d.ts +19 -19
- package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +42 -42
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.d.ts +7 -7
- package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js +25 -25
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.d.ts +5 -5
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.d.ts +20 -20
- package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.d.ts +26 -26
- package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.d.ts +8 -8
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js +2 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.d.ts +10 -10
- package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -21
- package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -24
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -12
- package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +2 -2
- package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -8
- package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +2 -2
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -12
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +2 -2
- package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -49
- package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +2 -2
- package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -11
- package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +2 -2
- package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +30 -30
- package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js +2 -2
- package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +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 +1461 -1461
- package/dist/source/loader/make_semver_compatible.d.ts +6 -6
- package/dist/source/loader/make_semver_compatible.js +25 -25
- package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -28
- package/dist/source/loader/make_xml_extension_object_parser.js +325 -325
- package/dist/source/loader/namespace_post_step.d.ts +10 -10
- package/dist/source/loader/namespace_post_step.js +61 -61
- package/dist/source/loader/register_node_promoter.d.ts +2 -2
- package/dist/source/loader/register_node_promoter.js +9 -9
- package/dist/source/namespace.d.ts +6 -6
- package/dist/source/namespace.js +2 -2
- package/dist/source/namespace_alarm_and_condition.d.ts +32 -32
- package/dist/source/namespace_alarm_and_condition.js +2 -2
- package/dist/source/namespace_data_access.d.ts +42 -42
- package/dist/source/namespace_data_access.js +2 -2
- package/dist/source/namespace_machine_state.d.ts +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 +1392 -1392
- 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 -0
- package/dist/src/alarms_and_conditions/check_where_clause.js +110 -0
- package/dist/src/alarms_and_conditions/check_where_clause.js.map +1 -0
- package/dist/src/alarms_and_conditions/condition.d.ts +5 -5
- package/dist/src/alarms_and_conditions/condition.js +78 -78
- package/dist/src/alarms_and_conditions/condition_info.d.ts +27 -0
- package/dist/src/alarms_and_conditions/condition_info.js +55 -0
- package/dist/src/alarms_and_conditions/condition_info.js.map +1 -0
- package/dist/src/alarms_and_conditions/condition_info_impl.d.ts +26 -26
- package/dist/src/alarms_and_conditions/condition_info_impl.js +54 -54
- package/dist/src/alarms_and_conditions/condition_snapshot.d.ts +233 -0
- package/dist/src/alarms_and_conditions/condition_snapshot.js +667 -0
- package/dist/src/alarms_and_conditions/condition_snapshot.js.map +1 -0
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +222 -222
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +657 -657
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +9 -9
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +61 -61
- package/dist/src/alarms_and_conditions/extract_event_fields.d.ts +10 -0
- package/dist/src/alarms_and_conditions/extract_event_fields.js +90 -0
- package/dist/src/alarms_and_conditions/extract_event_fields.js.map +1 -0
- package/dist/src/alarms_and_conditions/index.d.ts +16 -16
- package/dist/src/alarms_and_conditions/index.js +32 -32
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +44 -44
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +244 -244
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +93 -93
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +419 -419
- package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +26 -26
- package/dist/src/alarms_and_conditions/ua_base_event_impl.js +38 -38
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +44 -44
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +183 -183
- package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +153 -153
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +1028 -1028
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +14 -14
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +34 -34
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +24 -24
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +56 -56
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +11 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +11 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +23 -23
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +86 -86
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +11 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +7 -7
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +79 -79
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +250 -250
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +24 -24
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +50 -50
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +19 -19
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +162 -162
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +46 -46
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +166 -166
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +18 -18
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +17 -17
- package/dist/src/apply_condition_refresh.d.ts +6 -6
- package/dist/src/apply_condition_refresh.js +27 -27
- package/dist/src/base_node_impl.d.ts +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 -0
- package/dist/src/data_access/ua_multistate_value_discrete.js +250 -0
- package/dist/src/data_access/ua_multistate_value_discrete.js.map +1 -0
- package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +51 -51
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js +249 -249
- package/dist/src/data_access/ua_two_state_discrete.d.ts +25 -0
- package/dist/src/data_access/ua_two_state_discrete.js +154 -0
- package/dist/src/data_access/ua_two_state_discrete.js.map +1 -0
- package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +25 -25
- package/dist/src/data_access/ua_two_state_discrete_impl.js +153 -153
- package/dist/src/event_data.d.ts +34 -34
- package/dist/src/event_data.js +64 -64
- package/dist/src/extension_object_array_node.d.ts +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 +43 -43
- package/dist/src/index_current.js +74 -74
- package/dist/src/namespace_impl.d.ts +461 -461
- package/dist/src/namespace_impl.js +1732 -1732
- 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 +1155 -1155
- 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 +38 -38
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +250 -250
- package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -61
- package/dist/src/state_machine/ua_two_state_variable.js +331 -331
- package/dist/src/tool_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 +371 -371
- 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 -35
- package/dist/src/ua_object_impl.js +161 -161
- 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 -19
- package/dist/src/ua_view_impl.js +43 -43
- package/distHelpers/add_event_generator_object.d.ts +3 -3
- package/distHelpers/add_event_generator_object.js +64 -64
- package/distHelpers/alarms_and_conditions_demo.d.ts +9 -9
- package/distHelpers/alarms_and_conditions_demo.js +115 -115
- package/distHelpers/assertHasMatchingReference.d.ts +19 -19
- package/distHelpers/assertHasMatchingReference.js +40 -40
- package/distHelpers/boiler_system.d.ts +113 -113
- package/distHelpers/boiler_system.js +395 -395
- package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -5
- package/distHelpers/create_minimalist_address_space_nodeset.js +171 -171
- package/distHelpers/date_utils.d.ts +3 -3
- package/distHelpers/date_utils.js +9 -9
- package/distHelpers/dump_statemachine.js +127 -127
- package/distHelpers/get_address_space_fixture.d.ts +1 -1
- package/distHelpers/get_address_space_fixture.js +30 -30
- package/distHelpers/get_mini_address_space.d.ts +7 -7
- package/distHelpers/get_mini_address_space.js +36 -36
- package/distHelpers/index.d.ts +12 -12
- package/distHelpers/index.js +28 -28
- package/distHelpers/mock_session.d.ts +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 +36 -35
|
@@ -1,1462 +1,1462 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.NodeSetLoader = exports.makeNodeSetParserEngine = void 0;
|
|
13
|
-
/* eslint-disable max-statements */
|
|
14
|
-
/**
|
|
15
|
-
* @module node-opcua-address-space
|
|
16
|
-
*/
|
|
17
|
-
const util_1 = require("util");
|
|
18
|
-
const chalk = require("chalk");
|
|
19
|
-
const ec = require("node-opcua-basic-types");
|
|
20
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
21
|
-
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
22
|
-
const node_opcua_data_access_1 = require("node-opcua-data-access");
|
|
23
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
24
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
25
|
-
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
26
|
-
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
27
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
28
|
-
const node_opcua_service_call_1 = require("node-opcua-service-call");
|
|
29
|
-
const node_opcua_types_1 = require("node-opcua-types");
|
|
30
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
31
|
-
const node_opcua_xml2json_1 = require("node-opcua-xml2json");
|
|
32
|
-
const semver = require("semver");
|
|
33
|
-
const namespace_post_step_1 = require("./namespace_post_step");
|
|
34
|
-
const ensure_datatype_extracted_1 = require("./ensure_datatype_extracted");
|
|
35
|
-
const decode_xml_extension_object_1 = require("./decode_xml_extension_object");
|
|
36
|
-
const make_semver_compatible_1 = require("./make_semver_compatible");
|
|
37
|
-
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
38
|
-
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
39
|
-
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
40
|
-
function __make_back_references(namespace) {
|
|
41
|
-
const namespaceP = namespace;
|
|
42
|
-
for (const node of namespaceP.nodeIterator()) {
|
|
43
|
-
node.propagate_back_references();
|
|
44
|
-
}
|
|
45
|
-
for (const node of namespaceP.nodeIterator()) {
|
|
46
|
-
node.install_extra_properties();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function make_back_references(addressSpace) {
|
|
50
|
-
const addressSpacePrivate = addressSpace;
|
|
51
|
-
addressSpacePrivate.suspendBackReference = false;
|
|
52
|
-
addressSpace.getNamespaceArray().map(__make_back_references);
|
|
53
|
-
}
|
|
54
|
-
function stringToUInt32Array(str) {
|
|
55
|
-
const array = str ? str.split(",").map((value) => parseInt(value, 10)) : null;
|
|
56
|
-
return array;
|
|
57
|
-
}
|
|
58
|
-
function convertAccessLevel(accessLevel) {
|
|
59
|
-
const accessLevelN = parseInt(accessLevel || "1", 10); // CurrentRead if not specified
|
|
60
|
-
return (0, node_opcua_data_model_1.makeAccessLevelFlag)(accessLevelN);
|
|
61
|
-
}
|
|
62
|
-
function makeDefaultVariant(addressSpace, dataTypeNode, valueRank) {
|
|
63
|
-
let variant = { dataType: node_opcua_variant_1.DataType.Null };
|
|
64
|
-
const nodeDataType = addressSpace.findNode(dataTypeNode);
|
|
65
|
-
if (nodeDataType) {
|
|
66
|
-
const basicDataType = nodeDataType.basicDataType;
|
|
67
|
-
if (basicDataType === node_opcua_variant_1.DataType.Variant) {
|
|
68
|
-
/// we don't now what is the variant
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
if (basicDataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
72
|
-
return { dataType: node_opcua_variant_1.DataType.ExtensionObject, value: null };
|
|
73
|
-
}
|
|
74
|
-
const builtInType = (0, node_opcua_factory_1.getBuiltInType)(node_opcua_variant_1.DataType[basicDataType]);
|
|
75
|
-
if (builtInType === undefined || builtInType === null) {
|
|
76
|
-
errorLog("Cannot find builtInType for ", basicDataType);
|
|
77
|
-
return { dataType: node_opcua_variant_1.DataType.Null };
|
|
78
|
-
}
|
|
79
|
-
const dv = builtInType.defaultValue;
|
|
80
|
-
const value = typeof dv === "function" ? dv() : dv;
|
|
81
|
-
let arrayType;
|
|
82
|
-
/*
|
|
83
|
-
* * n > 1 : the Value is an array with the specified number of dimensions.
|
|
84
|
-
* * OneDimension (1): The value is an array with one dimension.
|
|
85
|
-
* * OneOrMoreDimensions (0): The value is an array with one or more dimensions.
|
|
86
|
-
* * Scalar (-1): The value is not an array.
|
|
87
|
-
* * Any (-2): The value can be a scalar or an array with any number of dimensions.
|
|
88
|
-
* * ScalarOrOneDimension (-3): The value can be a scalar or a one dimensional array.
|
|
89
|
-
*/
|
|
90
|
-
switch (valueRank) {
|
|
91
|
-
case -3: // ScalarOrOneDimension (-3):
|
|
92
|
-
case -2: // any
|
|
93
|
-
case -1:
|
|
94
|
-
arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
|
|
95
|
-
variant = { dataType: basicDataType, value, arrayType };
|
|
96
|
-
break;
|
|
97
|
-
case 0: // one or more dimension
|
|
98
|
-
case 1: // one dimension
|
|
99
|
-
arrayType = node_opcua_variant_1.VariantArrayType.Array;
|
|
100
|
-
variant = { dataType: basicDataType, value: [], arrayType };
|
|
101
|
-
break;
|
|
102
|
-
default:
|
|
103
|
-
arrayType = node_opcua_variant_1.VariantArrayType.Matrix;
|
|
104
|
-
variant = { dataType: basicDataType, value: [], arrayType, dimensions: [] };
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return variant;
|
|
109
|
-
}
|
|
110
|
-
function makeNodeSetParserEngine(addressSpace) {
|
|
111
|
-
const addressSpace1 = addressSpace;
|
|
112
|
-
addressSpace1.suspendBackReference = true;
|
|
113
|
-
const postTasks = [];
|
|
114
|
-
const postTasks0_DecodePojoString = [];
|
|
115
|
-
const postTasks1_InitializeVariable = [];
|
|
116
|
-
const postTasks2_AssignedExtensionObjectToDataValue = [];
|
|
117
|
-
let alias_map = {};
|
|
118
|
-
/**
|
|
119
|
-
* @param aliasName
|
|
120
|
-
*/
|
|
121
|
-
function addAlias(aliasName, nodeIdInXmlContext) {
|
|
122
|
-
(0, node_opcua_assert_1.assert)(typeof nodeIdInXmlContext === "string");
|
|
123
|
-
const nodeId = _translateNodeId(nodeIdInXmlContext);
|
|
124
|
-
(0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
125
|
-
alias_map[aliasName] = nodeId;
|
|
126
|
-
addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
|
|
127
|
-
}
|
|
128
|
-
let namespace_uri_translation = {};
|
|
129
|
-
let namespaceCounter = 0;
|
|
130
|
-
let found_namespace_in_uri = {};
|
|
131
|
-
let models = [];
|
|
132
|
-
function _reset_namespace_translation() {
|
|
133
|
-
debugLog("_reset_namespace_translation");
|
|
134
|
-
namespace_uri_translation = {};
|
|
135
|
-
found_namespace_in_uri = {};
|
|
136
|
-
namespaceCounter = 0;
|
|
137
|
-
alias_map = {};
|
|
138
|
-
models = [];
|
|
139
|
-
}
|
|
140
|
-
function _translateNamespaceIndex(innerIndex) {
|
|
141
|
-
const namespaceIndex = namespace_uri_translation[innerIndex];
|
|
142
|
-
// istanbul ignore next
|
|
143
|
-
if (namespaceIndex === undefined) {
|
|
144
|
-
// tslint:disable-next-line: no-console
|
|
145
|
-
debugLog("Warning: namespace_uri_translation = ", namespace_uri_translation);
|
|
146
|
-
throw new Error("_translateNamespaceIndex! Cannot find namespace definition for index " + innerIndex);
|
|
147
|
-
}
|
|
148
|
-
return namespaceIndex;
|
|
149
|
-
}
|
|
150
|
-
function _internal_addReferenceType(params) {
|
|
151
|
-
// istanbul ignore next
|
|
152
|
-
if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
|
|
153
|
-
throw new Error("invalid param");
|
|
154
|
-
} // already translated
|
|
155
|
-
const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
|
|
156
|
-
namespace.addReferenceType(params);
|
|
157
|
-
}
|
|
158
|
-
function _internal_createNode(params) {
|
|
159
|
-
// istanbul ignore next
|
|
160
|
-
if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
|
|
161
|
-
throw new Error("invalid param expecting a valid nodeId");
|
|
162
|
-
} // already translated
|
|
163
|
-
const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
|
|
164
|
-
return namespace.internalCreateNode(params);
|
|
165
|
-
}
|
|
166
|
-
function _register_namespace_uri_in_translation_table(namespaceUri) {
|
|
167
|
-
if (found_namespace_in_uri[namespaceUri]) {
|
|
168
|
-
return found_namespace_in_uri[namespaceUri];
|
|
169
|
-
}
|
|
170
|
-
const namespace = addressSpace1.getNamespace(namespaceUri);
|
|
171
|
-
if (!namespace) {
|
|
172
|
-
throw new Error("cannot find namespace for " +
|
|
173
|
-
namespaceUri +
|
|
174
|
-
"\nplease make sure to initialize your address space with the corresponding nodeset files");
|
|
175
|
-
}
|
|
176
|
-
found_namespace_in_uri[namespaceUri] = namespace;
|
|
177
|
-
const index_in_xml = namespaceCounter;
|
|
178
|
-
namespaceCounter++;
|
|
179
|
-
namespace_uri_translation[index_in_xml] = namespace.index;
|
|
180
|
-
doDebug &&
|
|
181
|
-
debugLog(" _register_namespace_uri = ", namespaceUri, "index in Xml=", index_in_xml, " index in addressSpace", namespace.index);
|
|
182
|
-
return namespace;
|
|
183
|
-
}
|
|
184
|
-
function _add_namespace(model) {
|
|
185
|
-
if (model.requiredModels.length > 0) {
|
|
186
|
-
// check that required models exist already in the address space
|
|
187
|
-
for (const requiredModel of model.requiredModels) {
|
|
188
|
-
const existingNamespace = addressSpace1.getNamespace(requiredModel.modelUri);
|
|
189
|
-
if (!existingNamespace) {
|
|
190
|
-
errorLog("Please ensure that the required namespace ", requiredModel.modelUri, "is loaded firs when loading ", model.modelUri);
|
|
191
|
-
throw new Error("LoadNodeSet : Cannot find namespace for " + requiredModel.modelUri);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* from https://reference.opcfoundation.org/Core/docs/Part6/F.2/
|
|
195
|
-
* The version of the model defined in the UANodeSet.
|
|
196
|
-
* This is a human readable string and not intended for programmatic comparisons.
|
|
197
|
-
*
|
|
198
|
-
*/
|
|
199
|
-
const isLowerVersion = (existingVersion, requiredVersion) => {
|
|
200
|
-
const existingSemver = (0, make_semver_compatible_1.makeSemverCompatible)(existingVersion);
|
|
201
|
-
const requiredSemver = (0, make_semver_compatible_1.makeSemverCompatible)(requiredVersion);
|
|
202
|
-
return semver.lt(existingSemver, requiredSemver);
|
|
203
|
-
};
|
|
204
|
-
if (isLowerVersion(existingNamespace.version, requiredModel.version)) {
|
|
205
|
-
errorLog("Expecting ", requiredModel.modelUri, " with version to be at least", requiredModel.version, " but namespace version is ", existingNamespace.version);
|
|
206
|
-
}
|
|
207
|
-
if (existingNamespace.publicationDate.getTime() < requiredModel.publicationDate.getTime()) {
|
|
208
|
-
errorLog("Expecting ", requiredModel.modelUri, " with publicationDatea at least ", requiredModel.publicationDate.toUTCString(), " but namespace publicationDate is ", existingNamespace.publicationDate.toUTCString());
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
let namespace;
|
|
213
|
-
// Model must not be already registered
|
|
214
|
-
const existingNamespace = addressSpace1.getNamespace(model.modelUri);
|
|
215
|
-
if (existingNamespace) {
|
|
216
|
-
// special treatment for namespace 0
|
|
217
|
-
if (model.modelUri === "http://opcfoundation.org/UA/") {
|
|
218
|
-
namespace = existingNamespace;
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
throw new Error(" namespace already registered " + model.modelUri);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
namespace = addressSpace1.registerNamespace(model.modelUri);
|
|
226
|
-
}
|
|
227
|
-
namespace.version = model.version;
|
|
228
|
-
namespace.publicationDate = model.publicationDate || namespace.publicationDate;
|
|
229
|
-
return namespace;
|
|
230
|
-
}
|
|
231
|
-
const reg = /ns=([0-9]+);(.*)/;
|
|
232
|
-
function _translateNodeId(nodeId) {
|
|
233
|
-
if (alias_map[nodeId]) {
|
|
234
|
-
return alias_map[nodeId];
|
|
235
|
-
}
|
|
236
|
-
const m = nodeId.match(reg);
|
|
237
|
-
if (m) {
|
|
238
|
-
const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
|
|
239
|
-
nodeId = "ns=" + namespaceIndex + ";" + m[2];
|
|
240
|
-
}
|
|
241
|
-
return (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
|
|
242
|
-
}
|
|
243
|
-
function _translateReferenceType(refType) {
|
|
244
|
-
return _translateNodeId(refType);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* convert a nodeId
|
|
248
|
-
*
|
|
249
|
-
* @method convertToNodeId
|
|
250
|
-
* @param nodeId {String|null}
|
|
251
|
-
* @return {NodeId}
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* convertToNodeId("String") => resolve alias
|
|
255
|
-
* convertToNodeId("i=58") => resolve to nodeId in namespace 0
|
|
256
|
-
* convertToNodeId("ns=1;i=100") => convert namespace from xml namespace
|
|
257
|
-
* table to corresponding namespace in addressSpace
|
|
258
|
-
*/
|
|
259
|
-
function convertToNodeId(nodeIdLike) {
|
|
260
|
-
// treat alias
|
|
261
|
-
if (!nodeIdLike) {
|
|
262
|
-
return null;
|
|
263
|
-
}
|
|
264
|
-
const nodeId = _translateNodeId(nodeIdLike);
|
|
265
|
-
return addressSpace1.resolveNodeId(nodeId);
|
|
266
|
-
}
|
|
267
|
-
function convertQualifiedName(qualifiedName) {
|
|
268
|
-
const qn = (0, node_opcua_data_model_1.stringToQualifiedName)(qualifiedName);
|
|
269
|
-
// Xx if (qn.namespaceIndex > 0) {
|
|
270
|
-
qn.namespaceIndex = _translateNamespaceIndex(qn.namespaceIndex);
|
|
271
|
-
// Xx }
|
|
272
|
-
return qn;
|
|
273
|
-
}
|
|
274
|
-
const state_Alias = {
|
|
275
|
-
finish() {
|
|
276
|
-
addAlias(this.attrs.Alias, this.text);
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
const references_parser = {
|
|
280
|
-
init() {
|
|
281
|
-
this.parent.obj.references = [];
|
|
282
|
-
this.array = this.parent.obj.references;
|
|
283
|
-
},
|
|
284
|
-
parser: {
|
|
285
|
-
Reference: {
|
|
286
|
-
finish() {
|
|
287
|
-
this.parent.array.push({
|
|
288
|
-
isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward === "false" ? false : true,
|
|
289
|
-
nodeId: convertToNodeId(this.text),
|
|
290
|
-
referenceType: _translateReferenceType(this.attrs.ReferenceType)
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
const state_UAObject = {
|
|
297
|
-
init(name, attrs) {
|
|
298
|
-
this.obj = {};
|
|
299
|
-
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Object;
|
|
300
|
-
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
301
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
302
|
-
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
303
|
-
this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
|
|
304
|
-
this.obj.symbolicName = attrs.SymbolicName || null;
|
|
305
|
-
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
306
|
-
this.obj.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
307
|
-
},
|
|
308
|
-
finish() {
|
|
309
|
-
if (this.isDraft || this.isDeprecated) {
|
|
310
|
-
// ignore Draft or Deprecated element
|
|
311
|
-
debugLog("Ignoring Draft/Deprecated UAObject =", this.obj.browseName.toString());
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
_internal_createNode(this.obj);
|
|
315
|
-
},
|
|
316
|
-
parser: {
|
|
317
|
-
DisplayName: {
|
|
318
|
-
finish() {
|
|
319
|
-
this.parent.obj.displayName = this.text;
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
Description: {
|
|
323
|
-
finish() {
|
|
324
|
-
this.parent.obj.description = this.text;
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
References: references_parser
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
const state_UAObjectType = {
|
|
331
|
-
init(name, attrs) {
|
|
332
|
-
this.obj = {};
|
|
333
|
-
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ObjectType;
|
|
334
|
-
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
335
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
336
|
-
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
337
|
-
this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
|
|
338
|
-
},
|
|
339
|
-
finish() {
|
|
340
|
-
_internal_createNode(this.obj);
|
|
341
|
-
},
|
|
342
|
-
parser: {
|
|
343
|
-
DisplayName: {
|
|
344
|
-
finish() {
|
|
345
|
-
this.parent.obj.displayName = this.text;
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
Description: {
|
|
349
|
-
finish() {
|
|
350
|
-
this.parent.obj.description = this.text;
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
References: references_parser
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
const state_UAReferenceType = {
|
|
357
|
-
init(name, attrs) {
|
|
358
|
-
this.obj = {};
|
|
359
|
-
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ReferenceType;
|
|
360
|
-
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
361
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
362
|
-
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
363
|
-
},
|
|
364
|
-
finish() {
|
|
365
|
-
_internal_addReferenceType(this.obj);
|
|
366
|
-
},
|
|
367
|
-
parser: {
|
|
368
|
-
DisplayName: {
|
|
369
|
-
finish() {
|
|
370
|
-
this.parent.obj.displayName = this.text;
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
Description: {
|
|
374
|
-
finish() {
|
|
375
|
-
this.parent.obj.description = this.text;
|
|
376
|
-
}
|
|
377
|
-
},
|
|
378
|
-
InverseName: {
|
|
379
|
-
finish() {
|
|
380
|
-
this.parent.obj.inverseName = this.text;
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
References: references_parser
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
const pendingSimpleTypeToRegister = [];
|
|
387
|
-
const state_UADataType = {
|
|
388
|
-
init(name, attrs) {
|
|
389
|
-
this.obj = {};
|
|
390
|
-
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.DataType;
|
|
391
|
-
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract) || false;
|
|
392
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
393
|
-
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
394
|
-
this.obj.displayName = "";
|
|
395
|
-
this.obj.description = "";
|
|
396
|
-
this.obj.symbolicName = attrs.SymbolicName;
|
|
397
|
-
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
398
|
-
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
399
|
-
this.definitionFields = [];
|
|
400
|
-
},
|
|
401
|
-
finish() {
|
|
402
|
-
if (this.isDraft || this.isDeprecated) {
|
|
403
|
-
// ignore Draft or Deprecated element
|
|
404
|
-
debugLog("Ignoring Draft/Deprecated dataType =", this.obj.browseName.toString());
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
/*
|
|
408
|
-
export interface StructureFieldOptions {
|
|
409
|
-
name?: UAString ; // **
|
|
410
|
-
description?: (LocalizedTextLike | null); // **
|
|
411
|
-
dataType?: (NodeIdLike | null);
|
|
412
|
-
valueRank?: Int32 ;
|
|
413
|
-
arrayDimensions?: UInt32 [] | null;
|
|
414
|
-
maxStringLength?: UInt32 ;
|
|
415
|
-
isOptional?: UABoolean ;
|
|
416
|
-
}
|
|
417
|
-
export interface EnumValueTypeOptions {
|
|
418
|
-
value?: Int64 ;
|
|
419
|
-
displayName?: (LocalizedTextLike | null);
|
|
420
|
-
description?: (LocalizedTextLike | null); // **
|
|
421
|
-
}
|
|
422
|
-
export interface EnumFieldOptions extends EnumValueTypeOptions {
|
|
423
|
-
name?: UAString ; // **
|
|
424
|
-
}
|
|
425
|
-
*/
|
|
426
|
-
const definitionFields = this.definitionFields;
|
|
427
|
-
// replace DataType with nodeId, and description to LocalizedText
|
|
428
|
-
definitionFields.map((x) => {
|
|
429
|
-
if (x.description) {
|
|
430
|
-
x.description = { text: x.description };
|
|
431
|
-
}
|
|
432
|
-
if (x.displayName) {
|
|
433
|
-
x.displayName = { text: x.displayName };
|
|
434
|
-
}
|
|
435
|
-
if (x.dataType) {
|
|
436
|
-
x.dataType = convertToNodeId(x.dataType);
|
|
437
|
-
}
|
|
438
|
-
return x;
|
|
439
|
-
});
|
|
440
|
-
this.obj.partialDefinition = definitionFields;
|
|
441
|
-
let capturedDataTypeNode = _internal_createNode(this.obj);
|
|
442
|
-
const processBasicDataType = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
443
|
-
const definitionName = capturedDataTypeNode.browseName.name;
|
|
444
|
-
const isStructure = capturedDataTypeNode.isStructure();
|
|
445
|
-
const isEnumeration = capturedDataTypeNode.isEnumeration();
|
|
446
|
-
if (!isEnumeration && !isStructure && capturedDataTypeNode.nodeId.namespace !== 0) {
|
|
447
|
-
// add a custom basic type that is not a structure nor a enumeration
|
|
448
|
-
pendingSimpleTypeToRegister.push({ name: definitionName, dataTypeNodeId: capturedDataTypeNode.nodeId });
|
|
449
|
-
}
|
|
450
|
-
capturedDataTypeNode = undefined;
|
|
451
|
-
});
|
|
452
|
-
postTasks.push(processBasicDataType);
|
|
453
|
-
},
|
|
454
|
-
parser: {
|
|
455
|
-
DisplayName: {
|
|
456
|
-
finish() {
|
|
457
|
-
this.parent.obj.displayName = this.text;
|
|
458
|
-
}
|
|
459
|
-
},
|
|
460
|
-
Description: {
|
|
461
|
-
finish() {
|
|
462
|
-
this.parent.obj.description = this.text;
|
|
463
|
-
}
|
|
464
|
-
},
|
|
465
|
-
References: references_parser,
|
|
466
|
-
Definition: node_opcua_xml2json_1._definitionParser
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
const localizedText_parser = {
|
|
470
|
-
LocalizedText: {
|
|
471
|
-
init() {
|
|
472
|
-
this.localizedText = {};
|
|
473
|
-
},
|
|
474
|
-
parser: {
|
|
475
|
-
Locale: {
|
|
476
|
-
finish() {
|
|
477
|
-
this.parent.localizedText.locale = this.text.trim();
|
|
478
|
-
}
|
|
479
|
-
},
|
|
480
|
-
Text: {
|
|
481
|
-
finish() {
|
|
482
|
-
this.parent.localizedText.text = this.text.trim();
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
const qualifiedName_parser = {
|
|
489
|
-
QualifiedName: {
|
|
490
|
-
init() {
|
|
491
|
-
this.qualifiedName = {
|
|
492
|
-
namespaceIndex: 0,
|
|
493
|
-
name: null
|
|
494
|
-
};
|
|
495
|
-
},
|
|
496
|
-
parser: {
|
|
497
|
-
Name: {
|
|
498
|
-
finish() {
|
|
499
|
-
this.parent.qualifiedName.name = this.text.trim();
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
NamespaceIndex: {
|
|
503
|
-
finish() {
|
|
504
|
-
const ns = parseInt(this.text, 10);
|
|
505
|
-
const t = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(`ns=${ns};i=1`).toString());
|
|
506
|
-
this.parent.qualifiedName.namespaceIndex = t.namespace;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
const nodeId_parser = {
|
|
513
|
-
NodeId: {
|
|
514
|
-
init() {
|
|
515
|
-
this.nodeId = "";
|
|
516
|
-
},
|
|
517
|
-
parser: {
|
|
518
|
-
Identifier: {
|
|
519
|
-
finish() {
|
|
520
|
-
this.parent.nodeId = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
const enumValueType_parser = {
|
|
527
|
-
EnumValueType: {
|
|
528
|
-
init() {
|
|
529
|
-
this.enumValueType = new node_opcua_types_1.EnumValueType({
|
|
530
|
-
description: undefined,
|
|
531
|
-
displayName: undefined,
|
|
532
|
-
value: [0, 0] // Int64
|
|
533
|
-
});
|
|
534
|
-
},
|
|
535
|
-
parser: {
|
|
536
|
-
Value: {
|
|
537
|
-
finish() {
|
|
538
|
-
// Low part
|
|
539
|
-
this.parent.enumValueType.value[1] = parseInt(this.text, 10);
|
|
540
|
-
}
|
|
541
|
-
},
|
|
542
|
-
DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
543
|
-
this.parent.enumValueType.displayName = Object.assign({}, this.localizedText);
|
|
544
|
-
} }),
|
|
545
|
-
Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
546
|
-
this.parent.enumValueType.description = Object.assign({}, this.localizedText);
|
|
547
|
-
} })
|
|
548
|
-
},
|
|
549
|
-
finish() {
|
|
550
|
-
this.enumValueType = new node_opcua_types_1.EnumValueType(this.enumValueType);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
const argument_parser = {
|
|
555
|
-
Argument: {
|
|
556
|
-
init() {
|
|
557
|
-
this.argument = new node_opcua_service_call_1.Argument({});
|
|
558
|
-
},
|
|
559
|
-
parser: {
|
|
560
|
-
Name: {
|
|
561
|
-
finish() {
|
|
562
|
-
this.parent.argument.name = this.text.trim();
|
|
563
|
-
}
|
|
564
|
-
},
|
|
565
|
-
DataType: {
|
|
566
|
-
parser: {
|
|
567
|
-
Identifier: {
|
|
568
|
-
finish() {
|
|
569
|
-
this.parent.parent.argument.dataType = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
ValueRank: {
|
|
575
|
-
finish() {
|
|
576
|
-
this.parent.argument.valueRank = parseInt(this.text.trim(), 10);
|
|
577
|
-
}
|
|
578
|
-
},
|
|
579
|
-
ArrayDimensions: {
|
|
580
|
-
finish() {
|
|
581
|
-
// xx this.parent.argument.arrayDimensions =[];
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
Description: {
|
|
585
|
-
init() {
|
|
586
|
-
this._text = "";
|
|
587
|
-
this.locale = null;
|
|
588
|
-
this.text = null;
|
|
589
|
-
},
|
|
590
|
-
parser: {
|
|
591
|
-
Locale: {
|
|
592
|
-
init() {
|
|
593
|
-
this.text = "";
|
|
594
|
-
},
|
|
595
|
-
finish() {
|
|
596
|
-
this.parent.locale = this.text.trim();
|
|
597
|
-
}
|
|
598
|
-
},
|
|
599
|
-
Text: {
|
|
600
|
-
finish() {
|
|
601
|
-
this.text = this.text || "";
|
|
602
|
-
this.parent._text = this.text.trim();
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
},
|
|
606
|
-
finish() {
|
|
607
|
-
this.parent.argument.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this._text);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
},
|
|
611
|
-
finish() {
|
|
612
|
-
// xx this.argument = new Argument(this.argument);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
const Range_parser = {
|
|
617
|
-
Range: {
|
|
618
|
-
init() {
|
|
619
|
-
this.range = new node_opcua_types_1.Range({});
|
|
620
|
-
},
|
|
621
|
-
parser: {
|
|
622
|
-
Low: {
|
|
623
|
-
finish() {
|
|
624
|
-
this.parent.range.low = parseFloat(this.text);
|
|
625
|
-
}
|
|
626
|
-
},
|
|
627
|
-
High: {
|
|
628
|
-
finish() {
|
|
629
|
-
this.parent.range.high = parseFloat(this.text);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
const EUInformation_parser = {
|
|
636
|
-
EUInformation: {
|
|
637
|
-
init() {
|
|
638
|
-
this.euInformation = new node_opcua_data_access_1.EUInformation({});
|
|
639
|
-
},
|
|
640
|
-
parser: {
|
|
641
|
-
NamespaceUri: {
|
|
642
|
-
finish() {
|
|
643
|
-
this.parent.euInformation.namespaceUri = this.text;
|
|
644
|
-
}
|
|
645
|
-
},
|
|
646
|
-
UnitId: {
|
|
647
|
-
finish() {
|
|
648
|
-
this.parent.euInformation.unitId = parseInt(this.text, 10);
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
652
|
-
this.parent.euInformation.displayName = Object.assign({}, this.localizedText);
|
|
653
|
-
} }),
|
|
654
|
-
Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
655
|
-
this.parent.euInformation.description = Object.assign({}, this.localizedText);
|
|
656
|
-
} })
|
|
657
|
-
},
|
|
658
|
-
finish() {
|
|
659
|
-
this.euInformation = new node_opcua_data_access_1.EUInformation(this.euInformation);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
const _extensionObject_inner_parser = {
|
|
664
|
-
TypeId: {
|
|
665
|
-
parser: {
|
|
666
|
-
Identifier: {
|
|
667
|
-
finish() {
|
|
668
|
-
const typeDefinitionId = this.text.trim();
|
|
669
|
-
const self = this.parent.parent; // ExtensionObject
|
|
670
|
-
self.typeDefinitionId = (0, node_opcua_nodeid_1.resolveNodeId)(typeDefinitionId);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
},
|
|
675
|
-
Body2: new node_opcua_xml2json_1.FragmentClonerParser(),
|
|
676
|
-
Body: {
|
|
677
|
-
parser: {
|
|
678
|
-
Argument: argument_parser.Argument,
|
|
679
|
-
EUInformation: EUInformation_parser.EUInformation,
|
|
680
|
-
EnumValueType: enumValueType_parser.EnumValueType,
|
|
681
|
-
Range: Range_parser.Range
|
|
682
|
-
},
|
|
683
|
-
startElement(elementName, attrs) {
|
|
684
|
-
const self = this.parent; // ExtensionObject
|
|
685
|
-
self.extensionObject = null;
|
|
686
|
-
self.extensionObjectPojo = null;
|
|
687
|
-
if (!Object.prototype.hasOwnProperty.call(this.parser, elementName)) {
|
|
688
|
-
// treat it as a opaque XML bloc for the time being
|
|
689
|
-
// until we find the definition of this object, so we know how to interpret the fields
|
|
690
|
-
this._cloneFragment = new node_opcua_xml2json_1.InternalFragmentClonerReaderState();
|
|
691
|
-
this.engine._promote(this._cloneFragment, this.engine.currentLevel, elementName, attrs);
|
|
692
|
-
}
|
|
693
|
-
},
|
|
694
|
-
finish() {
|
|
695
|
-
const self = this.parent; // ExtensionObject
|
|
696
|
-
// typeDefinitionId is also the "Default XML" encoding nodeId !
|
|
697
|
-
switch (self.typeDefinitionId.toString()) {
|
|
698
|
-
case "i=7616": // EnumValueType
|
|
699
|
-
case "ns=0;i=7616": // EnumValueType
|
|
700
|
-
self.extensionObject = self.parser.Body.parser.EnumValueType.enumValueType;
|
|
701
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
702
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
703
|
-
break;
|
|
704
|
-
case "i=297": // Arguments
|
|
705
|
-
case "ns=0;i=297": // Arguments
|
|
706
|
-
self.extensionObject = self.parser.Body.parser.Argument.argument;
|
|
707
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
708
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
709
|
-
break;
|
|
710
|
-
case "i=888":
|
|
711
|
-
case "ns=0;i=888": // EUInformation
|
|
712
|
-
self.extensionObject = self.parser.Body.parser.EUInformation.euInformation;
|
|
713
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
714
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
715
|
-
break;
|
|
716
|
-
case "i=885": // Range
|
|
717
|
-
case "ns=0;i=885":
|
|
718
|
-
self.extensionObject = self.parser.Body.parser.Range.range;
|
|
719
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
720
|
-
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
721
|
-
break;
|
|
722
|
-
default: {
|
|
723
|
-
this.bodyXML = this._cloneFragment.value;
|
|
724
|
-
this._cloneFragment.value = null;
|
|
725
|
-
// the "Default Xml" encoding nodeId
|
|
726
|
-
const xmlEncodingNodeId = _translateNodeId(self.typeDefinitionId.toString());
|
|
727
|
-
if (xmlEncodingNodeId.isEmpty()) {
|
|
728
|
-
debugLog("xmlEncodingNodeId is empty for " + self.typeDefinitionId.toString());
|
|
729
|
-
break;
|
|
730
|
-
}
|
|
731
|
-
let captureXmlBody = this.bodyXML;
|
|
732
|
-
if (doDebug) {
|
|
733
|
-
debugLog("xxxx ", chalk.yellow(captureXmlBody));
|
|
734
|
-
}
|
|
735
|
-
// this is a user defined Extension Object
|
|
736
|
-
debugLog("load nodeset2: typeDefinitionId in ExtensionObject Default XML = " + xmlEncodingNodeId.toString());
|
|
737
|
-
let captured = self.postTaskData;
|
|
738
|
-
self.extensionObjectPojo = null;
|
|
739
|
-
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
740
|
-
const extensionObject = yield (0, decode_xml_extension_object_1.decodeXmlExtensionObject)(addressSpace2, xmlEncodingNodeId, captureXmlBody);
|
|
741
|
-
if (captured) {
|
|
742
|
-
captured.postponedExtensionObject = extensionObject;
|
|
743
|
-
}
|
|
744
|
-
captureXmlBody = undefined;
|
|
745
|
-
captured = undefined;
|
|
746
|
-
});
|
|
747
|
-
postTasks0_DecodePojoString.push(task);
|
|
748
|
-
(0, node_opcua_assert_1.assert)(!self.extensionObject || self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
749
|
-
break;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
};
|
|
755
|
-
const extensionObject_parser = {
|
|
756
|
-
ExtensionObject: {
|
|
757
|
-
init() {
|
|
758
|
-
this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
|
|
759
|
-
this.extensionObject = null;
|
|
760
|
-
this.extensionObjectPojo = null;
|
|
761
|
-
this.postTaskData = { postponedExtensionObject: null };
|
|
762
|
-
},
|
|
763
|
-
parser: _extensionObject_inner_parser,
|
|
764
|
-
finish() {
|
|
765
|
-
/* empty */
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
function BasicType_parser(dataType, parseFunc) {
|
|
770
|
-
const _parser = {};
|
|
771
|
-
const r = {
|
|
772
|
-
init(name, attrs) {
|
|
773
|
-
this.value = undefined;
|
|
774
|
-
},
|
|
775
|
-
finish() {
|
|
776
|
-
this.value = parseFunc.call(this, this.text);
|
|
777
|
-
}
|
|
778
|
-
};
|
|
779
|
-
_parser[dataType] = r;
|
|
780
|
-
return _parser;
|
|
781
|
-
}
|
|
782
|
-
function ListOf(dataType, parseFunc) {
|
|
783
|
-
return {
|
|
784
|
-
init() {
|
|
785
|
-
this.listData = [];
|
|
786
|
-
},
|
|
787
|
-
parser: BasicType_parser(dataType, parseFunc),
|
|
788
|
-
finish() {
|
|
789
|
-
this.parent.parent.obj.value = {
|
|
790
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
791
|
-
dataType: node_opcua_variant_1.DataType[dataType],
|
|
792
|
-
value: this.listData
|
|
793
|
-
};
|
|
794
|
-
},
|
|
795
|
-
endElement(element) {
|
|
796
|
-
this.listData.push(this.parser[dataType].value);
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
function parser2(type, p) {
|
|
801
|
-
return {
|
|
802
|
-
finish() {
|
|
803
|
-
this.parent.parent.obj.value = {
|
|
804
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
805
|
-
dataType: node_opcua_variant_1.DataType[type],
|
|
806
|
-
value: p(this.text)
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
const parseUInt64 = (str) => (0, node_opcua_basic_types_1.coerceUInt64)(str);
|
|
812
|
-
const parseInt64 = (str) => (0, node_opcua_basic_types_1.coerceInt64)(str);
|
|
813
|
-
const state_Variant = {
|
|
814
|
-
init: () => {
|
|
815
|
-
/* empty */
|
|
816
|
-
},
|
|
817
|
-
parser: {
|
|
818
|
-
QualifiedName: Object.assign(Object.assign({}, qualifiedName_parser.QualifiedName), { finish() {
|
|
819
|
-
this.parent.parent.obj.value = {
|
|
820
|
-
dataType: node_opcua_variant_1.DataType.QualifiedName,
|
|
821
|
-
value: this.qualifiedName
|
|
822
|
-
};
|
|
823
|
-
} }),
|
|
824
|
-
LocalizedText: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
825
|
-
this.parent.parent.obj.value = {
|
|
826
|
-
dataType: node_opcua_variant_1.DataType.LocalizedText,
|
|
827
|
-
value: this.localizedText
|
|
828
|
-
};
|
|
829
|
-
} }),
|
|
830
|
-
XmlElement: {
|
|
831
|
-
finish() {
|
|
832
|
-
this.parent.parent.obj.value = {
|
|
833
|
-
dataType: node_opcua_variant_1.DataType.XmlElement,
|
|
834
|
-
value: this.text
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
},
|
|
838
|
-
String: {
|
|
839
|
-
finish() {
|
|
840
|
-
this.parent.parent.obj.value = {
|
|
841
|
-
dataType: node_opcua_variant_1.DataType.String,
|
|
842
|
-
value: this.text
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
},
|
|
846
|
-
Guid: {
|
|
847
|
-
parser: {
|
|
848
|
-
String: {
|
|
849
|
-
finish() {
|
|
850
|
-
const guid = this.text;
|
|
851
|
-
if (!(0, node_opcua_basic_types_1.isValidGuid)(guid)) {
|
|
852
|
-
/* ?*/
|
|
853
|
-
}
|
|
854
|
-
this.parent.parent.parent.obj.value = {
|
|
855
|
-
dataType: node_opcua_variant_1.DataType.Guid,
|
|
856
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
857
|
-
value: this.text
|
|
858
|
-
};
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
},
|
|
863
|
-
NodeId: {
|
|
864
|
-
parser: {
|
|
865
|
-
Identifier: {
|
|
866
|
-
finish() {
|
|
867
|
-
const nodeId = this.text;
|
|
868
|
-
this.parent.parent.parent.obj.value = {
|
|
869
|
-
dataType: node_opcua_variant_1.DataType.NodeId,
|
|
870
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
871
|
-
value: _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(nodeId).toString())
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
},
|
|
877
|
-
Boolean: parser2("Boolean", ec.coerceBoolean),
|
|
878
|
-
Byte: parser2("Byte", parseInt),
|
|
879
|
-
Int16: parser2("Int16", parseInt),
|
|
880
|
-
Int32: parser2("Int32", parseInt),
|
|
881
|
-
Int8: parser2("Int8", parseInt),
|
|
882
|
-
SByte: parser2("SByte", parseInt),
|
|
883
|
-
UInt16: parser2("UInt16", parseInt),
|
|
884
|
-
UInt32: parser2("UInt32", parseInt),
|
|
885
|
-
UInt8: parser2("UInt8", parseInt),
|
|
886
|
-
UInt64: parser2("UInt64", parseUInt64),
|
|
887
|
-
Int64: parser2("Int64", parseInt64),
|
|
888
|
-
ByteString: {
|
|
889
|
-
init() {
|
|
890
|
-
this.value = null;
|
|
891
|
-
},
|
|
892
|
-
finish() {
|
|
893
|
-
const base64text = this.text;
|
|
894
|
-
const byteString = Buffer.from(base64text, "base64");
|
|
895
|
-
this.parent.parent.obj.value = {
|
|
896
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
897
|
-
dataType: node_opcua_variant_1.DataType.ByteString,
|
|
898
|
-
value: byteString
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
},
|
|
902
|
-
Float: {
|
|
903
|
-
finish() {
|
|
904
|
-
this.parent.parent.obj.value = {
|
|
905
|
-
dataType: node_opcua_variant_1.DataType.Float,
|
|
906
|
-
value: parseFloat(this.text)
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
},
|
|
910
|
-
Double: {
|
|
911
|
-
finish() {
|
|
912
|
-
this.parent.parent.obj.value = {
|
|
913
|
-
dataType: node_opcua_variant_1.DataType.Double,
|
|
914
|
-
value: parseFloat(this.text)
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
},
|
|
918
|
-
ListOfExtensionObject: {
|
|
919
|
-
init() {
|
|
920
|
-
this.listExtensionObject = [];
|
|
921
|
-
},
|
|
922
|
-
parser: extensionObject_parser,
|
|
923
|
-
finish() {
|
|
924
|
-
installExtensionObjectListInitializationPostTask(this);
|
|
925
|
-
},
|
|
926
|
-
startElement(elementName) {
|
|
927
|
-
/* empty */
|
|
928
|
-
const extensionObjectParser = this.parser.ExtensionObject;
|
|
929
|
-
extensionObjectParser.postTaskData = { postponedExtensionObject: null };
|
|
930
|
-
},
|
|
931
|
-
endElement(elementName) {
|
|
932
|
-
const extensionObjectParser = this.parser.ExtensionObject;
|
|
933
|
-
this.listExtensionObject.push(extensionObjectParser.extensionObject);
|
|
934
|
-
if (this.parser.ExtensionObject.extensionObject === null) {
|
|
935
|
-
// extension object creation will be postponed
|
|
936
|
-
const index = this.listExtensionObject.length - 1;
|
|
937
|
-
let capturedData = extensionObjectParser.postTaskData;
|
|
938
|
-
// istanbul ignore next
|
|
939
|
-
if (!capturedData) {
|
|
940
|
-
throw new Error("Internal Error : postponedExtensionObject not resolved");
|
|
941
|
-
}
|
|
942
|
-
let listExtensionObject = this.listExtensionObject;
|
|
943
|
-
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
944
|
-
// istanbul ignore next
|
|
945
|
-
if (!capturedData.postponedExtensionObject) {
|
|
946
|
-
throw new Error("Internal Error : postponedExtensionObject not resolved");
|
|
947
|
-
}
|
|
948
|
-
listExtensionObject[index] = capturedData.postponedExtensionObject;
|
|
949
|
-
capturedData = undefined;
|
|
950
|
-
listExtensionObject = undefined;
|
|
951
|
-
});
|
|
952
|
-
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
},
|
|
956
|
-
ListOfLocalizedText: {
|
|
957
|
-
init() {
|
|
958
|
-
this.listData = [];
|
|
959
|
-
},
|
|
960
|
-
parser: localizedText_parser,
|
|
961
|
-
finish() {
|
|
962
|
-
this.parent.parent.obj.value = {
|
|
963
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
964
|
-
dataType: node_opcua_variant_1.DataType.LocalizedText,
|
|
965
|
-
value: this.listData
|
|
966
|
-
};
|
|
967
|
-
},
|
|
968
|
-
endElement() {
|
|
969
|
-
this.listData.push(this.parser.LocalizedText.localizedText);
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
ListOfQualifiedName: {
|
|
973
|
-
init() {
|
|
974
|
-
this.listData = [];
|
|
975
|
-
},
|
|
976
|
-
parser: qualifiedName_parser,
|
|
977
|
-
finish() {
|
|
978
|
-
this.parent.parent.obj.value = {
|
|
979
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
980
|
-
dataType: node_opcua_variant_1.DataType.QualifiedName,
|
|
981
|
-
value: this.listData
|
|
982
|
-
};
|
|
983
|
-
},
|
|
984
|
-
endElement() {
|
|
985
|
-
this.listData.push(this.parser.QualifiedName.qualifiedName);
|
|
986
|
-
}
|
|
987
|
-
},
|
|
988
|
-
ListOfNodeId: {
|
|
989
|
-
init() {
|
|
990
|
-
this.listData = [];
|
|
991
|
-
},
|
|
992
|
-
parser: nodeId_parser,
|
|
993
|
-
finish() {
|
|
994
|
-
this.parent.parent.obj.value = {
|
|
995
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
996
|
-
dataType: node_opcua_variant_1.DataType.NodeId,
|
|
997
|
-
value: this.listData
|
|
998
|
-
};
|
|
999
|
-
},
|
|
1000
|
-
endElement(elementName) {
|
|
1001
|
-
this.listData.push(this.parser.NodeId.nodeId);
|
|
1002
|
-
}
|
|
1003
|
-
},
|
|
1004
|
-
ListOfBoolean: ListOf("Boolean", ec.coerceBoolean),
|
|
1005
|
-
ListOfByte: ListOf("Byte", parseInt),
|
|
1006
|
-
ListOfDouble: ListOf("Double", parseFloat),
|
|
1007
|
-
ListOfFloat: ListOf("Float", parseFloat),
|
|
1008
|
-
ListOfInt32: ListOf("Int32", parseInt),
|
|
1009
|
-
ListOfInt16: ListOf("Int16", parseInt),
|
|
1010
|
-
ListOfInt8: ListOf("Int8", parseInt),
|
|
1011
|
-
ListOfUInt32: ListOf("UInt32", parseInt),
|
|
1012
|
-
ListOfUInt16: ListOf("UInt16", parseInt),
|
|
1013
|
-
ListOfUInt8: ListOf("UInt8", parseInt),
|
|
1014
|
-
ListOfString: ListOf("String", (value) => value),
|
|
1015
|
-
ListOfXmlElement: ListOf("XmlElement", (value) => value),
|
|
1016
|
-
ExtensionObject: {
|
|
1017
|
-
init() {
|
|
1018
|
-
this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
|
|
1019
|
-
this.extensionObject = null;
|
|
1020
|
-
this.postTaskData = { postponedExtensionObject: null };
|
|
1021
|
-
},
|
|
1022
|
-
parser: _extensionObject_inner_parser,
|
|
1023
|
-
finish() {
|
|
1024
|
-
// istanbul ignore next
|
|
1025
|
-
if (this.extensionObject && !(this.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject)) {
|
|
1026
|
-
throw new Error("expecting an extension object");
|
|
1027
|
-
}
|
|
1028
|
-
this.parent.parent.obj.value = {
|
|
1029
|
-
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
1030
|
-
value: this.extensionObject
|
|
1031
|
-
};
|
|
1032
|
-
if (!this.extensionObject) {
|
|
1033
|
-
installExtensionObjectInitializationPostTask(this);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
function installExtensionObjectListInitializationPostTask(element) {
|
|
1040
|
-
let listExtensionObject = element.listExtensionObject;
|
|
1041
|
-
let nodeId = element.parent.parent.obj.nodeId;
|
|
1042
|
-
(0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
|
|
1043
|
-
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1044
|
-
const node = addressSpace2.findNode(nodeId);
|
|
1045
|
-
if (!node) {
|
|
1046
|
-
debugLog("Cannot find node with nodeId " + nodeId + ". may be the node was marked as deprecated");
|
|
1047
|
-
}
|
|
1048
|
-
else if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
1049
|
-
const v = node;
|
|
1050
|
-
v.setValueFromSource({
|
|
1051
|
-
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
1052
|
-
value: listExtensionObject
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
1056
|
-
const v = node;
|
|
1057
|
-
v /*fix me*/.value.value = listExtensionObject;
|
|
1058
|
-
}
|
|
1059
|
-
listExtensionObject.slice(0);
|
|
1060
|
-
listExtensionObject = undefined;
|
|
1061
|
-
nodeId = undefined;
|
|
1062
|
-
});
|
|
1063
|
-
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
1064
|
-
}
|
|
1065
|
-
function installExtensionObjectInitializationPostTask(element) {
|
|
1066
|
-
// let's create the mechanism that postpone the creation of the
|
|
1067
|
-
// extension object
|
|
1068
|
-
let data = element.postTaskData;
|
|
1069
|
-
let variant = element.parent.parent.obj.value;
|
|
1070
|
-
let nodeId = element.parent.parent.obj.nodeId;
|
|
1071
|
-
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1072
|
-
variant.value = data.postponedExtensionObject;
|
|
1073
|
-
(0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
|
|
1074
|
-
const node = addressSpace2.findNode(nodeId);
|
|
1075
|
-
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
1076
|
-
const v = node;
|
|
1077
|
-
v.setValueFromSource(variant);
|
|
1078
|
-
}
|
|
1079
|
-
else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
1080
|
-
const v = node;
|
|
1081
|
-
v /*fix me*/.value.value = variant.value;
|
|
1082
|
-
}
|
|
1083
|
-
data.postponedExtensionObject = null;
|
|
1084
|
-
data = undefined;
|
|
1085
|
-
variant = undefined;
|
|
1086
|
-
nodeId = undefined;
|
|
1087
|
-
});
|
|
1088
|
-
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
1089
|
-
}
|
|
1090
|
-
const state_UAVariable = {
|
|
1091
|
-
init(name, attrs) {
|
|
1092
|
-
this.obj = {};
|
|
1093
|
-
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
|
|
1094
|
-
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
1095
|
-
this.obj.parentNodeId = convertToNodeId(attrs.ParentNodeId);
|
|
1096
|
-
this.obj.dataType = convertToNodeId(attrs.DataType);
|
|
1097
|
-
this.obj.valueRank = attrs.ValueRank === undefined ? -1 : ec.coerceInt32(attrs.ValueRank);
|
|
1098
|
-
this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
|
|
1099
|
-
this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
|
|
1100
|
-
this.obj.minimumSamplingInterval = parseInt(this.obj.minimumSamplingInterval, 10);
|
|
1101
|
-
this.obj.historizing = false;
|
|
1102
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
1103
|
-
this.obj.accessLevel = convertAccessLevel(attrs.AccessLevel);
|
|
1104
|
-
this.obj.userAccessLevel = this.obj.accessLevel; // convertAccessLevel(attrs.UserAccessLevel || attrs.AccessLevel);
|
|
1105
|
-
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1106
|
-
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1107
|
-
},
|
|
1108
|
-
finish() {
|
|
1109
|
-
if (this.isDraft || this.isDeprecated) {
|
|
1110
|
-
debugLog("Ignoring Draft/Deprecated UAVariable =", this.obj.browseName.toString());
|
|
1111
|
-
return;
|
|
1112
|
-
}
|
|
1113
|
-
/*
|
|
1114
|
-
// set default value based on obj data Type
|
|
1115
|
-
if (this.obj.value === undefined) {
|
|
1116
|
-
const dataTypeNode = this.obj.dataType;
|
|
1117
|
-
const valueRank = this.obj.valueRank;
|
|
1118
|
-
this.obj.value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
|
|
1119
|
-
}
|
|
1120
|
-
*/
|
|
1121
|
-
// eslint-disable-next-line prefer-const
|
|
1122
|
-
let capturedVariable;
|
|
1123
|
-
if (this.obj.value) {
|
|
1124
|
-
let capturedValue = this.obj.value;
|
|
1125
|
-
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1126
|
-
if (false && doDebug) {
|
|
1127
|
-
debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new node_opcua_variant_1.Variant(capturedValue).toString());
|
|
1128
|
-
}
|
|
1129
|
-
capturedVariable.setValueFromSource(capturedValue);
|
|
1130
|
-
capturedValue = undefined;
|
|
1131
|
-
capturedVariable = undefined;
|
|
1132
|
-
});
|
|
1133
|
-
postTasks1_InitializeVariable.push(task);
|
|
1134
|
-
}
|
|
1135
|
-
else {
|
|
1136
|
-
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1137
|
-
const dataTypeNode = capturedVariable.dataType;
|
|
1138
|
-
const valueRank = capturedVariable.valueRank;
|
|
1139
|
-
const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
|
|
1140
|
-
if (value) {
|
|
1141
|
-
if (false && doDebug) {
|
|
1142
|
-
debugLog("2 setting value to ", capturedVariable.nodeId.toString(), value);
|
|
1143
|
-
}
|
|
1144
|
-
if (value.dataType === node_opcua_variant_1.DataType.Null) {
|
|
1145
|
-
capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.BadWaitingForInitialData);
|
|
1146
|
-
}
|
|
1147
|
-
else {
|
|
1148
|
-
capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.Good);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
capturedVariable = undefined;
|
|
1152
|
-
});
|
|
1153
|
-
postTasks1_InitializeVariable.push(task);
|
|
1154
|
-
}
|
|
1155
|
-
this.obj.value = undefined;
|
|
1156
|
-
capturedVariable = _internal_createNode(this.obj);
|
|
1157
|
-
},
|
|
1158
|
-
parser: {
|
|
1159
|
-
DisplayName: {
|
|
1160
|
-
finish() {
|
|
1161
|
-
this.parent.obj.displayName = this.text;
|
|
1162
|
-
}
|
|
1163
|
-
},
|
|
1164
|
-
Description: {
|
|
1165
|
-
finish() {
|
|
1166
|
-
this.parent.obj.description = this.text;
|
|
1167
|
-
}
|
|
1168
|
-
},
|
|
1169
|
-
References: references_parser,
|
|
1170
|
-
Value: state_Variant
|
|
1171
|
-
}
|
|
1172
|
-
};
|
|
1173
|
-
const state_UAVariableType = {
|
|
1174
|
-
init(name, attrs) {
|
|
1175
|
-
this.obj = {};
|
|
1176
|
-
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
1177
|
-
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.VariableType;
|
|
1178
|
-
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
1179
|
-
this.obj.parentNodeId = attrs.ParentNodeId || null;
|
|
1180
|
-
this.obj.dataType = convertToNodeId(attrs.DataType) || null;
|
|
1181
|
-
this.obj.valueRank = ec.coerceInt32(attrs.ValueRank) || -1;
|
|
1182
|
-
this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
|
|
1183
|
-
this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
|
|
1184
|
-
this.obj.historizing = false;
|
|
1185
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
1186
|
-
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1187
|
-
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1188
|
-
},
|
|
1189
|
-
finish() {
|
|
1190
|
-
if (this.isDraft || this.isDeprecated) {
|
|
1191
|
-
debugLog("Ignoring Draft/Deprecated UAVariableType =", this.obj.browseName.toString());
|
|
1192
|
-
return;
|
|
1193
|
-
}
|
|
1194
|
-
try {
|
|
1195
|
-
_internal_createNode(this.obj);
|
|
1196
|
-
} /* istanbul ignore next */
|
|
1197
|
-
catch (err) {
|
|
1198
|
-
this.obj.addressSpace = null;
|
|
1199
|
-
// tslint:disable:no-console
|
|
1200
|
-
console.warn(" Cannot create object", JSON.stringify(this.obj, null, " "));
|
|
1201
|
-
throw err;
|
|
1202
|
-
}
|
|
1203
|
-
},
|
|
1204
|
-
parser: {
|
|
1205
|
-
DisplayName: {
|
|
1206
|
-
finish() {
|
|
1207
|
-
this.parent.obj.displayName = this.text;
|
|
1208
|
-
}
|
|
1209
|
-
},
|
|
1210
|
-
Description: {
|
|
1211
|
-
finish() {
|
|
1212
|
-
this.parent.obj.description = this.text;
|
|
1213
|
-
}
|
|
1214
|
-
},
|
|
1215
|
-
References: references_parser,
|
|
1216
|
-
Value: state_Variant
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
|
-
const state_UAMethod = {
|
|
1220
|
-
init(name, attrs) {
|
|
1221
|
-
this.obj = {};
|
|
1222
|
-
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Method;
|
|
1223
|
-
// MethodDeclarationId
|
|
1224
|
-
// ParentNodeId
|
|
1225
|
-
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
1226
|
-
this.obj.parentNodeId = attrs.ParentNodeId || null;
|
|
1227
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
1228
|
-
this.obj.methodDeclarationId = attrs.MethodDeclarationId ? _translateNodeId(attrs.MethodDeclarationId) : null;
|
|
1229
|
-
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1230
|
-
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1231
|
-
},
|
|
1232
|
-
finish() {
|
|
1233
|
-
if (this.isDraft || this.isDeprecated) {
|
|
1234
|
-
debugLog("Ignoring Draft/Deprecated UAMethod =", this.obj.browseName.toString());
|
|
1235
|
-
return;
|
|
1236
|
-
}
|
|
1237
|
-
_internal_createNode(this.obj);
|
|
1238
|
-
},
|
|
1239
|
-
parser: {
|
|
1240
|
-
DisplayName: {
|
|
1241
|
-
finish() {
|
|
1242
|
-
this.parent.obj.displayName = this.text;
|
|
1243
|
-
}
|
|
1244
|
-
},
|
|
1245
|
-
References: references_parser
|
|
1246
|
-
}
|
|
1247
|
-
};
|
|
1248
|
-
const state_ModelTableEntry = new node_opcua_xml2json_1.ReaderState({
|
|
1249
|
-
// ModelTableEntry
|
|
1250
|
-
init() {
|
|
1251
|
-
this._requiredModels = [];
|
|
1252
|
-
},
|
|
1253
|
-
parser: {
|
|
1254
|
-
RequiredModel: {
|
|
1255
|
-
init(name, attrs) {
|
|
1256
|
-
const modelUri = attrs.ModelUri;
|
|
1257
|
-
const version = attrs.Version;
|
|
1258
|
-
const publicationDate = new Date(Date.parse(attrs.PublicationDate));
|
|
1259
|
-
this.parent._requiredModels.push({ modelUri, version, publicationDate });
|
|
1260
|
-
},
|
|
1261
|
-
finish() {
|
|
1262
|
-
/** */
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
},
|
|
1266
|
-
finish() {
|
|
1267
|
-
const modelUri = this.attrs.ModelUri; // //"http://opcfoundation.org/UA/"
|
|
1268
|
-
const version = this.attrs.Version; // 1.04
|
|
1269
|
-
const publicationDate = this.attrs.PublicationDate ? new Date(Date.parse(this.attrs.PublicationDate)) : undefined; // "2018-05-15T00:00:00Z" "
|
|
1270
|
-
// optional,
|
|
1271
|
-
const symbolicName = this.attrs.SymbolicName;
|
|
1272
|
-
const accessRestrictions = this.attrs.AccessRestrictions;
|
|
1273
|
-
const model = {
|
|
1274
|
-
accessRestrictions,
|
|
1275
|
-
modelUri,
|
|
1276
|
-
publicationDate,
|
|
1277
|
-
requiredModels: this._requiredModels,
|
|
1278
|
-
symbolicName,
|
|
1279
|
-
version
|
|
1280
|
-
};
|
|
1281
|
-
const namespace = _add_namespace(model);
|
|
1282
|
-
models.push(model);
|
|
1283
|
-
}
|
|
1284
|
-
});
|
|
1285
|
-
function _perform() {
|
|
1286
|
-
/**special case for old nodeset file version 1.02 where no models exists */
|
|
1287
|
-
if (models.length === 0) {
|
|
1288
|
-
for (const namespaceuri of _namespaceUris) {
|
|
1289
|
-
const existingNamespace = addressSpace1.getNamespace(namespaceuri);
|
|
1290
|
-
if (existingNamespace) {
|
|
1291
|
-
continue;
|
|
1292
|
-
}
|
|
1293
|
-
_add_namespace({
|
|
1294
|
-
modelUri: namespaceuri,
|
|
1295
|
-
version: "1.0.0",
|
|
1296
|
-
requiredModels: []
|
|
1297
|
-
});
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
doDebug && debugLog("xxx models =", JSON.stringify(models, null, " "));
|
|
1301
|
-
doDebug && debugLog("xxx _namespaceUris =", _namespaceUris);
|
|
1302
|
-
_register_namespace_uri_in_translation_table("http://opcfoundation.org/UA/");
|
|
1303
|
-
for (const namespaceUri of _namespaceUris) {
|
|
1304
|
-
_register_namespace_uri_in_translation_table(namespaceUri);
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
// state_ModelTableEntry.parser["RequiredModel"] = state_ModelTableEntry;
|
|
1308
|
-
let _namespaceUris = [];
|
|
1309
|
-
const state_0 = {
|
|
1310
|
-
parser: {
|
|
1311
|
-
Aliases: {
|
|
1312
|
-
init() {
|
|
1313
|
-
_perform();
|
|
1314
|
-
},
|
|
1315
|
-
parser: { Alias: state_Alias }
|
|
1316
|
-
},
|
|
1317
|
-
NamespaceUris: {
|
|
1318
|
-
init() {
|
|
1319
|
-
//
|
|
1320
|
-
_namespaceUris = [];
|
|
1321
|
-
},
|
|
1322
|
-
parser: {
|
|
1323
|
-
Uri: {
|
|
1324
|
-
finish() {
|
|
1325
|
-
_namespaceUris.push(this.text);
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
},
|
|
1329
|
-
finish() {
|
|
1330
|
-
// verify that requested namespaces are already loaded or abort with a message
|
|
1331
|
-
}
|
|
1332
|
-
},
|
|
1333
|
-
Models: {
|
|
1334
|
-
// ModelTable
|
|
1335
|
-
init(name, attrs) {
|
|
1336
|
-
/* */
|
|
1337
|
-
},
|
|
1338
|
-
parser: {
|
|
1339
|
-
Model: state_ModelTableEntry
|
|
1340
|
-
},
|
|
1341
|
-
finish() {
|
|
1342
|
-
/** */
|
|
1343
|
-
}
|
|
1344
|
-
},
|
|
1345
|
-
UADataType: state_UADataType,
|
|
1346
|
-
UAMethod: state_UAMethod,
|
|
1347
|
-
UAObject: state_UAObject,
|
|
1348
|
-
UAObjectType: state_UAObjectType,
|
|
1349
|
-
UAReferenceType: state_UAReferenceType,
|
|
1350
|
-
UAVariable: state_UAVariable,
|
|
1351
|
-
UAVariableType: state_UAVariableType
|
|
1352
|
-
}
|
|
1353
|
-
};
|
|
1354
|
-
const parser = new node_opcua_xml2json_1.Xml2Json(state_0);
|
|
1355
|
-
function terminate(callback) {
|
|
1356
|
-
var _a, _b, _c;
|
|
1357
|
-
make_back_references(addressSpace1);
|
|
1358
|
-
// setting up Server_NamespaceArray
|
|
1359
|
-
if ((_c = (_b = (_a = addressSpace1.rootFolder) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.server) === null || _c === void 0 ? void 0 : _c.namespaceArray) {
|
|
1360
|
-
addressSpace1.rootFolder.objects.server.namespaceArray.setValueFromSource({
|
|
1361
|
-
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
1362
|
-
dataType: node_opcua_variant_1.DataType.String,
|
|
1363
|
-
value: addressSpace1.getNamespaceArray().map((ns) => ns.namespaceUri)
|
|
1364
|
-
});
|
|
1365
|
-
// istanbul ignore next
|
|
1366
|
-
if (doDebug) {
|
|
1367
|
-
debugLog("addressSpace NS = ", addressSpace1.rootFolder.objects.server.namespaceArray.readValue().value.value.join(" "));
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
doDebug &&
|
|
1371
|
-
debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------") +
|
|
1372
|
-
chalk.green("DONE"));
|
|
1373
|
-
function performPostLoadingTasks(tasks) {
|
|
1374
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1375
|
-
for (const task of tasks) {
|
|
1376
|
-
try {
|
|
1377
|
-
yield task(addressSpace1);
|
|
1378
|
-
}
|
|
1379
|
-
catch (err) {
|
|
1380
|
-
// istanbul ignore next
|
|
1381
|
-
// tslint:disable:no-console
|
|
1382
|
-
if (err instanceof Error) {
|
|
1383
|
-
console.log(" performPostLoadingTasks Err => ", err.message, "\n", err);
|
|
1384
|
-
}
|
|
1385
|
-
yield task(addressSpace1);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
tasks.splice(0);
|
|
1389
|
-
});
|
|
1390
|
-
}
|
|
1391
|
-
function finalSteps() {
|
|
1392
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1393
|
-
/// ----------------------------------------------------------------------------------------
|
|
1394
|
-
// perform post task
|
|
1395
|
-
doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------"));
|
|
1396
|
-
yield performPostLoadingTasks(postTasks);
|
|
1397
|
-
doDebug && debugLog(chalk.bgGreenBright("Performing DataType extraction -------------------------------------------"));
|
|
1398
|
-
(0, node_opcua_assert_1.assert)(!addressSpace1.suspendBackReference);
|
|
1399
|
-
yield (0, ensure_datatype_extracted_1.ensureDatatypeExtracted)(addressSpace);
|
|
1400
|
-
const dataTypeManager = addressSpace.getDataTypeManager();
|
|
1401
|
-
/// ----------------------------------------------------------------------------------------
|
|
1402
|
-
doDebug && debugLog(chalk.bgGreenBright("DataType extraction done ") + chalk.green("DONE"));
|
|
1403
|
-
for (const { name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
|
|
1404
|
-
if (dataTypeNodeId.namespace === 0) {
|
|
1405
|
-
continue;
|
|
1406
|
-
}
|
|
1407
|
-
const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(dataTypeNodeId.namespace);
|
|
1408
|
-
}
|
|
1409
|
-
pendingSimpleTypeToRegister.splice(0);
|
|
1410
|
-
doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Decoding Pojo String (parsing XML objects) -"));
|
|
1411
|
-
yield performPostLoadingTasks(postTasks0_DecodePojoString);
|
|
1412
|
-
doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Variables ---------------------"));
|
|
1413
|
-
yield performPostLoadingTasks(postTasks1_InitializeVariable);
|
|
1414
|
-
doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks: (assigning Extension Object to Variables) -"));
|
|
1415
|
-
yield performPostLoadingTasks(postTasks2_AssignedExtensionObjectToDataValue);
|
|
1416
|
-
doDebug && debugLog(chalk.bgGreenBright("Performing post variable initialization ---------------------"));
|
|
1417
|
-
(0, namespace_post_step_1.promoteObjectsAndVariables)(addressSpace);
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
finalSteps()
|
|
1421
|
-
.then(() => callback())
|
|
1422
|
-
.catch((err1) => {
|
|
1423
|
-
console.log("Error ", (0, node_opcua_assert_1.renderError)(err1));
|
|
1424
|
-
callback(err1);
|
|
1425
|
-
});
|
|
1426
|
-
}
|
|
1427
|
-
function addNodeSet(xmlData, callback1) {
|
|
1428
|
-
_reset_namespace_translation();
|
|
1429
|
-
parser.parseString(xmlData, callback1);
|
|
1430
|
-
}
|
|
1431
|
-
return {
|
|
1432
|
-
addNodeSet,
|
|
1433
|
-
terminate
|
|
1434
|
-
};
|
|
1435
|
-
}
|
|
1436
|
-
exports.makeNodeSetParserEngine = makeNodeSetParserEngine;
|
|
1437
|
-
class NodeSetLoader {
|
|
1438
|
-
constructor(addressSpace) {
|
|
1439
|
-
this._s = makeNodeSetParserEngine(addressSpace);
|
|
1440
|
-
}
|
|
1441
|
-
addNodeSet(xmlData, callback) {
|
|
1442
|
-
if (!callback) {
|
|
1443
|
-
throw new Error("Expecting callback function");
|
|
1444
|
-
}
|
|
1445
|
-
return this._s.addNodeSet(xmlData, callback);
|
|
1446
|
-
}
|
|
1447
|
-
addNodeSetAsync(xmlData) {
|
|
1448
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1449
|
-
return (0, util_1.promisify)(this.addNodeSet).call(this, xmlData);
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
terminate(callback) {
|
|
1453
|
-
this._s.terminate(callback);
|
|
1454
|
-
}
|
|
1455
|
-
terminateAsync() {
|
|
1456
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1457
|
-
return (0, util_1.promisify)(this.terminate).call(this);
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
exports.NodeSetLoader = NodeSetLoader;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NodeSetLoader = exports.makeNodeSetParserEngine = void 0;
|
|
13
|
+
/* eslint-disable max-statements */
|
|
14
|
+
/**
|
|
15
|
+
* @module node-opcua-address-space
|
|
16
|
+
*/
|
|
17
|
+
const util_1 = require("util");
|
|
18
|
+
const chalk = require("chalk");
|
|
19
|
+
const ec = require("node-opcua-basic-types");
|
|
20
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
21
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
22
|
+
const node_opcua_data_access_1 = require("node-opcua-data-access");
|
|
23
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
24
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
25
|
+
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
26
|
+
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
27
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
28
|
+
const node_opcua_service_call_1 = require("node-opcua-service-call");
|
|
29
|
+
const node_opcua_types_1 = require("node-opcua-types");
|
|
30
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
31
|
+
const node_opcua_xml2json_1 = require("node-opcua-xml2json");
|
|
32
|
+
const semver = require("semver");
|
|
33
|
+
const namespace_post_step_1 = require("./namespace_post_step");
|
|
34
|
+
const ensure_datatype_extracted_1 = require("./ensure_datatype_extracted");
|
|
35
|
+
const decode_xml_extension_object_1 = require("./decode_xml_extension_object");
|
|
36
|
+
const make_semver_compatible_1 = require("./make_semver_compatible");
|
|
37
|
+
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
38
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
39
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
40
|
+
function __make_back_references(namespace) {
|
|
41
|
+
const namespaceP = namespace;
|
|
42
|
+
for (const node of namespaceP.nodeIterator()) {
|
|
43
|
+
node.propagate_back_references();
|
|
44
|
+
}
|
|
45
|
+
for (const node of namespaceP.nodeIterator()) {
|
|
46
|
+
node.install_extra_properties();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function make_back_references(addressSpace) {
|
|
50
|
+
const addressSpacePrivate = addressSpace;
|
|
51
|
+
addressSpacePrivate.suspendBackReference = false;
|
|
52
|
+
addressSpace.getNamespaceArray().map(__make_back_references);
|
|
53
|
+
}
|
|
54
|
+
function stringToUInt32Array(str) {
|
|
55
|
+
const array = str ? str.split(",").map((value) => parseInt(value, 10)) : null;
|
|
56
|
+
return array;
|
|
57
|
+
}
|
|
58
|
+
function convertAccessLevel(accessLevel) {
|
|
59
|
+
const accessLevelN = parseInt(accessLevel || "1", 10); // CurrentRead if not specified
|
|
60
|
+
return (0, node_opcua_data_model_1.makeAccessLevelFlag)(accessLevelN);
|
|
61
|
+
}
|
|
62
|
+
function makeDefaultVariant(addressSpace, dataTypeNode, valueRank) {
|
|
63
|
+
let variant = { dataType: node_opcua_variant_1.DataType.Null };
|
|
64
|
+
const nodeDataType = addressSpace.findNode(dataTypeNode);
|
|
65
|
+
if (nodeDataType) {
|
|
66
|
+
const basicDataType = nodeDataType.basicDataType;
|
|
67
|
+
if (basicDataType === node_opcua_variant_1.DataType.Variant) {
|
|
68
|
+
/// we don't now what is the variant
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
if (basicDataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
72
|
+
return { dataType: node_opcua_variant_1.DataType.ExtensionObject, value: null };
|
|
73
|
+
}
|
|
74
|
+
const builtInType = (0, node_opcua_factory_1.getBuiltInType)(node_opcua_variant_1.DataType[basicDataType]);
|
|
75
|
+
if (builtInType === undefined || builtInType === null) {
|
|
76
|
+
errorLog("Cannot find builtInType for ", basicDataType);
|
|
77
|
+
return { dataType: node_opcua_variant_1.DataType.Null };
|
|
78
|
+
}
|
|
79
|
+
const dv = builtInType.defaultValue;
|
|
80
|
+
const value = typeof dv === "function" ? dv() : dv;
|
|
81
|
+
let arrayType;
|
|
82
|
+
/*
|
|
83
|
+
* * n > 1 : the Value is an array with the specified number of dimensions.
|
|
84
|
+
* * OneDimension (1): The value is an array with one dimension.
|
|
85
|
+
* * OneOrMoreDimensions (0): The value is an array with one or more dimensions.
|
|
86
|
+
* * Scalar (-1): The value is not an array.
|
|
87
|
+
* * Any (-2): The value can be a scalar or an array with any number of dimensions.
|
|
88
|
+
* * ScalarOrOneDimension (-3): The value can be a scalar or a one dimensional array.
|
|
89
|
+
*/
|
|
90
|
+
switch (valueRank) {
|
|
91
|
+
case -3: // ScalarOrOneDimension (-3):
|
|
92
|
+
case -2: // any
|
|
93
|
+
case -1:
|
|
94
|
+
arrayType = node_opcua_variant_1.VariantArrayType.Scalar;
|
|
95
|
+
variant = { dataType: basicDataType, value, arrayType };
|
|
96
|
+
break;
|
|
97
|
+
case 0: // one or more dimension
|
|
98
|
+
case 1: // one dimension
|
|
99
|
+
arrayType = node_opcua_variant_1.VariantArrayType.Array;
|
|
100
|
+
variant = { dataType: basicDataType, value: [], arrayType };
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
arrayType = node_opcua_variant_1.VariantArrayType.Matrix;
|
|
104
|
+
variant = { dataType: basicDataType, value: [], arrayType, dimensions: [] };
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return variant;
|
|
109
|
+
}
|
|
110
|
+
function makeNodeSetParserEngine(addressSpace) {
|
|
111
|
+
const addressSpace1 = addressSpace;
|
|
112
|
+
addressSpace1.suspendBackReference = true;
|
|
113
|
+
const postTasks = [];
|
|
114
|
+
const postTasks0_DecodePojoString = [];
|
|
115
|
+
const postTasks1_InitializeVariable = [];
|
|
116
|
+
const postTasks2_AssignedExtensionObjectToDataValue = [];
|
|
117
|
+
let alias_map = {};
|
|
118
|
+
/**
|
|
119
|
+
* @param aliasName
|
|
120
|
+
*/
|
|
121
|
+
function addAlias(aliasName, nodeIdInXmlContext) {
|
|
122
|
+
(0, node_opcua_assert_1.assert)(typeof nodeIdInXmlContext === "string");
|
|
123
|
+
const nodeId = _translateNodeId(nodeIdInXmlContext);
|
|
124
|
+
(0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
125
|
+
alias_map[aliasName] = nodeId;
|
|
126
|
+
addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
|
|
127
|
+
}
|
|
128
|
+
let namespace_uri_translation = {};
|
|
129
|
+
let namespaceCounter = 0;
|
|
130
|
+
let found_namespace_in_uri = {};
|
|
131
|
+
let models = [];
|
|
132
|
+
function _reset_namespace_translation() {
|
|
133
|
+
debugLog("_reset_namespace_translation");
|
|
134
|
+
namespace_uri_translation = {};
|
|
135
|
+
found_namespace_in_uri = {};
|
|
136
|
+
namespaceCounter = 0;
|
|
137
|
+
alias_map = {};
|
|
138
|
+
models = [];
|
|
139
|
+
}
|
|
140
|
+
function _translateNamespaceIndex(innerIndex) {
|
|
141
|
+
const namespaceIndex = namespace_uri_translation[innerIndex];
|
|
142
|
+
// istanbul ignore next
|
|
143
|
+
if (namespaceIndex === undefined) {
|
|
144
|
+
// tslint:disable-next-line: no-console
|
|
145
|
+
debugLog("Warning: namespace_uri_translation = ", namespace_uri_translation);
|
|
146
|
+
throw new Error("_translateNamespaceIndex! Cannot find namespace definition for index " + innerIndex);
|
|
147
|
+
}
|
|
148
|
+
return namespaceIndex;
|
|
149
|
+
}
|
|
150
|
+
function _internal_addReferenceType(params) {
|
|
151
|
+
// istanbul ignore next
|
|
152
|
+
if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
|
|
153
|
+
throw new Error("invalid param");
|
|
154
|
+
} // already translated
|
|
155
|
+
const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
|
|
156
|
+
namespace.addReferenceType(params);
|
|
157
|
+
}
|
|
158
|
+
function _internal_createNode(params) {
|
|
159
|
+
// istanbul ignore next
|
|
160
|
+
if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
|
|
161
|
+
throw new Error("invalid param expecting a valid nodeId");
|
|
162
|
+
} // already translated
|
|
163
|
+
const namespace = addressSpace1.getNamespace(params.nodeId.namespace);
|
|
164
|
+
return namespace.internalCreateNode(params);
|
|
165
|
+
}
|
|
166
|
+
function _register_namespace_uri_in_translation_table(namespaceUri) {
|
|
167
|
+
if (found_namespace_in_uri[namespaceUri]) {
|
|
168
|
+
return found_namespace_in_uri[namespaceUri];
|
|
169
|
+
}
|
|
170
|
+
const namespace = addressSpace1.getNamespace(namespaceUri);
|
|
171
|
+
if (!namespace) {
|
|
172
|
+
throw new Error("cannot find namespace for " +
|
|
173
|
+
namespaceUri +
|
|
174
|
+
"\nplease make sure to initialize your address space with the corresponding nodeset files");
|
|
175
|
+
}
|
|
176
|
+
found_namespace_in_uri[namespaceUri] = namespace;
|
|
177
|
+
const index_in_xml = namespaceCounter;
|
|
178
|
+
namespaceCounter++;
|
|
179
|
+
namespace_uri_translation[index_in_xml] = namespace.index;
|
|
180
|
+
doDebug &&
|
|
181
|
+
debugLog(" _register_namespace_uri = ", namespaceUri, "index in Xml=", index_in_xml, " index in addressSpace", namespace.index);
|
|
182
|
+
return namespace;
|
|
183
|
+
}
|
|
184
|
+
function _add_namespace(model) {
|
|
185
|
+
if (model.requiredModels.length > 0) {
|
|
186
|
+
// check that required models exist already in the address space
|
|
187
|
+
for (const requiredModel of model.requiredModels) {
|
|
188
|
+
const existingNamespace = addressSpace1.getNamespace(requiredModel.modelUri);
|
|
189
|
+
if (!existingNamespace) {
|
|
190
|
+
errorLog("Please ensure that the required namespace ", requiredModel.modelUri, "is loaded firs when loading ", model.modelUri);
|
|
191
|
+
throw new Error("LoadNodeSet : Cannot find namespace for " + requiredModel.modelUri);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* from https://reference.opcfoundation.org/Core/docs/Part6/F.2/
|
|
195
|
+
* The version of the model defined in the UANodeSet.
|
|
196
|
+
* This is a human readable string and not intended for programmatic comparisons.
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
const isLowerVersion = (existingVersion, requiredVersion) => {
|
|
200
|
+
const existingSemver = (0, make_semver_compatible_1.makeSemverCompatible)(existingVersion);
|
|
201
|
+
const requiredSemver = (0, make_semver_compatible_1.makeSemverCompatible)(requiredVersion);
|
|
202
|
+
return semver.lt(existingSemver, requiredSemver);
|
|
203
|
+
};
|
|
204
|
+
if (isLowerVersion(existingNamespace.version, requiredModel.version)) {
|
|
205
|
+
errorLog("Expecting ", requiredModel.modelUri, " with version to be at least", requiredModel.version, " but namespace version is ", existingNamespace.version);
|
|
206
|
+
}
|
|
207
|
+
if (existingNamespace.publicationDate.getTime() < requiredModel.publicationDate.getTime()) {
|
|
208
|
+
errorLog("Expecting ", requiredModel.modelUri, " with publicationDatea at least ", requiredModel.publicationDate.toUTCString(), " but namespace publicationDate is ", existingNamespace.publicationDate.toUTCString());
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
let namespace;
|
|
213
|
+
// Model must not be already registered
|
|
214
|
+
const existingNamespace = addressSpace1.getNamespace(model.modelUri);
|
|
215
|
+
if (existingNamespace) {
|
|
216
|
+
// special treatment for namespace 0
|
|
217
|
+
if (model.modelUri === "http://opcfoundation.org/UA/") {
|
|
218
|
+
namespace = existingNamespace;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
throw new Error(" namespace already registered " + model.modelUri);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
namespace = addressSpace1.registerNamespace(model.modelUri);
|
|
226
|
+
}
|
|
227
|
+
namespace.version = model.version;
|
|
228
|
+
namespace.publicationDate = model.publicationDate || namespace.publicationDate;
|
|
229
|
+
return namespace;
|
|
230
|
+
}
|
|
231
|
+
const reg = /ns=([0-9]+);(.*)/;
|
|
232
|
+
function _translateNodeId(nodeId) {
|
|
233
|
+
if (alias_map[nodeId]) {
|
|
234
|
+
return alias_map[nodeId];
|
|
235
|
+
}
|
|
236
|
+
const m = nodeId.match(reg);
|
|
237
|
+
if (m) {
|
|
238
|
+
const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
|
|
239
|
+
nodeId = "ns=" + namespaceIndex + ";" + m[2];
|
|
240
|
+
}
|
|
241
|
+
return (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
|
|
242
|
+
}
|
|
243
|
+
function _translateReferenceType(refType) {
|
|
244
|
+
return _translateNodeId(refType);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* convert a nodeId
|
|
248
|
+
*
|
|
249
|
+
* @method convertToNodeId
|
|
250
|
+
* @param nodeId {String|null}
|
|
251
|
+
* @return {NodeId}
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* convertToNodeId("String") => resolve alias
|
|
255
|
+
* convertToNodeId("i=58") => resolve to nodeId in namespace 0
|
|
256
|
+
* convertToNodeId("ns=1;i=100") => convert namespace from xml namespace
|
|
257
|
+
* table to corresponding namespace in addressSpace
|
|
258
|
+
*/
|
|
259
|
+
function convertToNodeId(nodeIdLike) {
|
|
260
|
+
// treat alias
|
|
261
|
+
if (!nodeIdLike) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
const nodeId = _translateNodeId(nodeIdLike);
|
|
265
|
+
return addressSpace1.resolveNodeId(nodeId);
|
|
266
|
+
}
|
|
267
|
+
function convertQualifiedName(qualifiedName) {
|
|
268
|
+
const qn = (0, node_opcua_data_model_1.stringToQualifiedName)(qualifiedName);
|
|
269
|
+
// Xx if (qn.namespaceIndex > 0) {
|
|
270
|
+
qn.namespaceIndex = _translateNamespaceIndex(qn.namespaceIndex);
|
|
271
|
+
// Xx }
|
|
272
|
+
return qn;
|
|
273
|
+
}
|
|
274
|
+
const state_Alias = {
|
|
275
|
+
finish() {
|
|
276
|
+
addAlias(this.attrs.Alias, this.text);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const references_parser = {
|
|
280
|
+
init() {
|
|
281
|
+
this.parent.obj.references = [];
|
|
282
|
+
this.array = this.parent.obj.references;
|
|
283
|
+
},
|
|
284
|
+
parser: {
|
|
285
|
+
Reference: {
|
|
286
|
+
finish() {
|
|
287
|
+
this.parent.array.push({
|
|
288
|
+
isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward === "false" ? false : true,
|
|
289
|
+
nodeId: convertToNodeId(this.text),
|
|
290
|
+
referenceType: _translateReferenceType(this.attrs.ReferenceType)
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
const state_UAObject = {
|
|
297
|
+
init(name, attrs) {
|
|
298
|
+
this.obj = {};
|
|
299
|
+
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Object;
|
|
300
|
+
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
301
|
+
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
302
|
+
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
303
|
+
this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
|
|
304
|
+
this.obj.symbolicName = attrs.SymbolicName || null;
|
|
305
|
+
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
306
|
+
this.obj.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
307
|
+
},
|
|
308
|
+
finish() {
|
|
309
|
+
if (this.isDraft || this.isDeprecated) {
|
|
310
|
+
// ignore Draft or Deprecated element
|
|
311
|
+
debugLog("Ignoring Draft/Deprecated UAObject =", this.obj.browseName.toString());
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
_internal_createNode(this.obj);
|
|
315
|
+
},
|
|
316
|
+
parser: {
|
|
317
|
+
DisplayName: {
|
|
318
|
+
finish() {
|
|
319
|
+
this.parent.obj.displayName = this.text;
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
Description: {
|
|
323
|
+
finish() {
|
|
324
|
+
this.parent.obj.description = this.text;
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
References: references_parser
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const state_UAObjectType = {
|
|
331
|
+
init(name, attrs) {
|
|
332
|
+
this.obj = {};
|
|
333
|
+
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ObjectType;
|
|
334
|
+
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
335
|
+
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
336
|
+
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
337
|
+
this.obj.eventNotifier = ec.coerceByte(attrs.EventNotifier) || 0;
|
|
338
|
+
},
|
|
339
|
+
finish() {
|
|
340
|
+
_internal_createNode(this.obj);
|
|
341
|
+
},
|
|
342
|
+
parser: {
|
|
343
|
+
DisplayName: {
|
|
344
|
+
finish() {
|
|
345
|
+
this.parent.obj.displayName = this.text;
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
Description: {
|
|
349
|
+
finish() {
|
|
350
|
+
this.parent.obj.description = this.text;
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
References: references_parser
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const state_UAReferenceType = {
|
|
357
|
+
init(name, attrs) {
|
|
358
|
+
this.obj = {};
|
|
359
|
+
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.ReferenceType;
|
|
360
|
+
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
361
|
+
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
362
|
+
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
363
|
+
},
|
|
364
|
+
finish() {
|
|
365
|
+
_internal_addReferenceType(this.obj);
|
|
366
|
+
},
|
|
367
|
+
parser: {
|
|
368
|
+
DisplayName: {
|
|
369
|
+
finish() {
|
|
370
|
+
this.parent.obj.displayName = this.text;
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
Description: {
|
|
374
|
+
finish() {
|
|
375
|
+
this.parent.obj.description = this.text;
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
InverseName: {
|
|
379
|
+
finish() {
|
|
380
|
+
this.parent.obj.inverseName = this.text;
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
References: references_parser
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const pendingSimpleTypeToRegister = [];
|
|
387
|
+
const state_UADataType = {
|
|
388
|
+
init(name, attrs) {
|
|
389
|
+
this.obj = {};
|
|
390
|
+
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.DataType;
|
|
391
|
+
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract) || false;
|
|
392
|
+
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
393
|
+
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
394
|
+
this.obj.displayName = "";
|
|
395
|
+
this.obj.description = "";
|
|
396
|
+
this.obj.symbolicName = attrs.SymbolicName;
|
|
397
|
+
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
398
|
+
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
399
|
+
this.definitionFields = [];
|
|
400
|
+
},
|
|
401
|
+
finish() {
|
|
402
|
+
if (this.isDraft || this.isDeprecated) {
|
|
403
|
+
// ignore Draft or Deprecated element
|
|
404
|
+
debugLog("Ignoring Draft/Deprecated dataType =", this.obj.browseName.toString());
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
/*
|
|
408
|
+
export interface StructureFieldOptions {
|
|
409
|
+
name?: UAString ; // **
|
|
410
|
+
description?: (LocalizedTextLike | null); // **
|
|
411
|
+
dataType?: (NodeIdLike | null);
|
|
412
|
+
valueRank?: Int32 ;
|
|
413
|
+
arrayDimensions?: UInt32 [] | null;
|
|
414
|
+
maxStringLength?: UInt32 ;
|
|
415
|
+
isOptional?: UABoolean ;
|
|
416
|
+
}
|
|
417
|
+
export interface EnumValueTypeOptions {
|
|
418
|
+
value?: Int64 ;
|
|
419
|
+
displayName?: (LocalizedTextLike | null);
|
|
420
|
+
description?: (LocalizedTextLike | null); // **
|
|
421
|
+
}
|
|
422
|
+
export interface EnumFieldOptions extends EnumValueTypeOptions {
|
|
423
|
+
name?: UAString ; // **
|
|
424
|
+
}
|
|
425
|
+
*/
|
|
426
|
+
const definitionFields = this.definitionFields;
|
|
427
|
+
// replace DataType with nodeId, and description to LocalizedText
|
|
428
|
+
definitionFields.map((x) => {
|
|
429
|
+
if (x.description) {
|
|
430
|
+
x.description = { text: x.description };
|
|
431
|
+
}
|
|
432
|
+
if (x.displayName) {
|
|
433
|
+
x.displayName = { text: x.displayName };
|
|
434
|
+
}
|
|
435
|
+
if (x.dataType) {
|
|
436
|
+
x.dataType = convertToNodeId(x.dataType);
|
|
437
|
+
}
|
|
438
|
+
return x;
|
|
439
|
+
});
|
|
440
|
+
this.obj.partialDefinition = definitionFields;
|
|
441
|
+
let capturedDataTypeNode = _internal_createNode(this.obj);
|
|
442
|
+
const processBasicDataType = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
443
|
+
const definitionName = capturedDataTypeNode.browseName.name;
|
|
444
|
+
const isStructure = capturedDataTypeNode.isStructure();
|
|
445
|
+
const isEnumeration = capturedDataTypeNode.isEnumeration();
|
|
446
|
+
if (!isEnumeration && !isStructure && capturedDataTypeNode.nodeId.namespace !== 0) {
|
|
447
|
+
// add a custom basic type that is not a structure nor a enumeration
|
|
448
|
+
pendingSimpleTypeToRegister.push({ name: definitionName, dataTypeNodeId: capturedDataTypeNode.nodeId });
|
|
449
|
+
}
|
|
450
|
+
capturedDataTypeNode = undefined;
|
|
451
|
+
});
|
|
452
|
+
postTasks.push(processBasicDataType);
|
|
453
|
+
},
|
|
454
|
+
parser: {
|
|
455
|
+
DisplayName: {
|
|
456
|
+
finish() {
|
|
457
|
+
this.parent.obj.displayName = this.text;
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
Description: {
|
|
461
|
+
finish() {
|
|
462
|
+
this.parent.obj.description = this.text;
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
References: references_parser,
|
|
466
|
+
Definition: node_opcua_xml2json_1._definitionParser
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const localizedText_parser = {
|
|
470
|
+
LocalizedText: {
|
|
471
|
+
init() {
|
|
472
|
+
this.localizedText = {};
|
|
473
|
+
},
|
|
474
|
+
parser: {
|
|
475
|
+
Locale: {
|
|
476
|
+
finish() {
|
|
477
|
+
this.parent.localizedText.locale = this.text.trim();
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
Text: {
|
|
481
|
+
finish() {
|
|
482
|
+
this.parent.localizedText.text = this.text.trim();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
const qualifiedName_parser = {
|
|
489
|
+
QualifiedName: {
|
|
490
|
+
init() {
|
|
491
|
+
this.qualifiedName = {
|
|
492
|
+
namespaceIndex: 0,
|
|
493
|
+
name: null
|
|
494
|
+
};
|
|
495
|
+
},
|
|
496
|
+
parser: {
|
|
497
|
+
Name: {
|
|
498
|
+
finish() {
|
|
499
|
+
this.parent.qualifiedName.name = this.text.trim();
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
NamespaceIndex: {
|
|
503
|
+
finish() {
|
|
504
|
+
const ns = parseInt(this.text, 10);
|
|
505
|
+
const t = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(`ns=${ns};i=1`).toString());
|
|
506
|
+
this.parent.qualifiedName.namespaceIndex = t.namespace;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
const nodeId_parser = {
|
|
513
|
+
NodeId: {
|
|
514
|
+
init() {
|
|
515
|
+
this.nodeId = "";
|
|
516
|
+
},
|
|
517
|
+
parser: {
|
|
518
|
+
Identifier: {
|
|
519
|
+
finish() {
|
|
520
|
+
this.parent.nodeId = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
const enumValueType_parser = {
|
|
527
|
+
EnumValueType: {
|
|
528
|
+
init() {
|
|
529
|
+
this.enumValueType = new node_opcua_types_1.EnumValueType({
|
|
530
|
+
description: undefined,
|
|
531
|
+
displayName: undefined,
|
|
532
|
+
value: [0, 0] // Int64
|
|
533
|
+
});
|
|
534
|
+
},
|
|
535
|
+
parser: {
|
|
536
|
+
Value: {
|
|
537
|
+
finish() {
|
|
538
|
+
// Low part
|
|
539
|
+
this.parent.enumValueType.value[1] = parseInt(this.text, 10);
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
543
|
+
this.parent.enumValueType.displayName = Object.assign({}, this.localizedText);
|
|
544
|
+
} }),
|
|
545
|
+
Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
546
|
+
this.parent.enumValueType.description = Object.assign({}, this.localizedText);
|
|
547
|
+
} })
|
|
548
|
+
},
|
|
549
|
+
finish() {
|
|
550
|
+
this.enumValueType = new node_opcua_types_1.EnumValueType(this.enumValueType);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const argument_parser = {
|
|
555
|
+
Argument: {
|
|
556
|
+
init() {
|
|
557
|
+
this.argument = new node_opcua_service_call_1.Argument({});
|
|
558
|
+
},
|
|
559
|
+
parser: {
|
|
560
|
+
Name: {
|
|
561
|
+
finish() {
|
|
562
|
+
this.parent.argument.name = this.text.trim();
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
DataType: {
|
|
566
|
+
parser: {
|
|
567
|
+
Identifier: {
|
|
568
|
+
finish() {
|
|
569
|
+
this.parent.parent.argument.dataType = _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(this.text.trim()).toString());
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
ValueRank: {
|
|
575
|
+
finish() {
|
|
576
|
+
this.parent.argument.valueRank = parseInt(this.text.trim(), 10);
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
ArrayDimensions: {
|
|
580
|
+
finish() {
|
|
581
|
+
// xx this.parent.argument.arrayDimensions =[];
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
Description: {
|
|
585
|
+
init() {
|
|
586
|
+
this._text = "";
|
|
587
|
+
this.locale = null;
|
|
588
|
+
this.text = null;
|
|
589
|
+
},
|
|
590
|
+
parser: {
|
|
591
|
+
Locale: {
|
|
592
|
+
init() {
|
|
593
|
+
this.text = "";
|
|
594
|
+
},
|
|
595
|
+
finish() {
|
|
596
|
+
this.parent.locale = this.text.trim();
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
Text: {
|
|
600
|
+
finish() {
|
|
601
|
+
this.text = this.text || "";
|
|
602
|
+
this.parent._text = this.text.trim();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
finish() {
|
|
607
|
+
this.parent.argument.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this._text);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
finish() {
|
|
612
|
+
// xx this.argument = new Argument(this.argument);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
const Range_parser = {
|
|
617
|
+
Range: {
|
|
618
|
+
init() {
|
|
619
|
+
this.range = new node_opcua_types_1.Range({});
|
|
620
|
+
},
|
|
621
|
+
parser: {
|
|
622
|
+
Low: {
|
|
623
|
+
finish() {
|
|
624
|
+
this.parent.range.low = parseFloat(this.text);
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
High: {
|
|
628
|
+
finish() {
|
|
629
|
+
this.parent.range.high = parseFloat(this.text);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
const EUInformation_parser = {
|
|
636
|
+
EUInformation: {
|
|
637
|
+
init() {
|
|
638
|
+
this.euInformation = new node_opcua_data_access_1.EUInformation({});
|
|
639
|
+
},
|
|
640
|
+
parser: {
|
|
641
|
+
NamespaceUri: {
|
|
642
|
+
finish() {
|
|
643
|
+
this.parent.euInformation.namespaceUri = this.text;
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
UnitId: {
|
|
647
|
+
finish() {
|
|
648
|
+
this.parent.euInformation.unitId = parseInt(this.text, 10);
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
DisplayName: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
652
|
+
this.parent.euInformation.displayName = Object.assign({}, this.localizedText);
|
|
653
|
+
} }),
|
|
654
|
+
Description: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
655
|
+
this.parent.euInformation.description = Object.assign({}, this.localizedText);
|
|
656
|
+
} })
|
|
657
|
+
},
|
|
658
|
+
finish() {
|
|
659
|
+
this.euInformation = new node_opcua_data_access_1.EUInformation(this.euInformation);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
const _extensionObject_inner_parser = {
|
|
664
|
+
TypeId: {
|
|
665
|
+
parser: {
|
|
666
|
+
Identifier: {
|
|
667
|
+
finish() {
|
|
668
|
+
const typeDefinitionId = this.text.trim();
|
|
669
|
+
const self = this.parent.parent; // ExtensionObject
|
|
670
|
+
self.typeDefinitionId = (0, node_opcua_nodeid_1.resolveNodeId)(typeDefinitionId);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
Body2: new node_opcua_xml2json_1.FragmentClonerParser(),
|
|
676
|
+
Body: {
|
|
677
|
+
parser: {
|
|
678
|
+
Argument: argument_parser.Argument,
|
|
679
|
+
EUInformation: EUInformation_parser.EUInformation,
|
|
680
|
+
EnumValueType: enumValueType_parser.EnumValueType,
|
|
681
|
+
Range: Range_parser.Range
|
|
682
|
+
},
|
|
683
|
+
startElement(elementName, attrs) {
|
|
684
|
+
const self = this.parent; // ExtensionObject
|
|
685
|
+
self.extensionObject = null;
|
|
686
|
+
self.extensionObjectPojo = null;
|
|
687
|
+
if (!Object.prototype.hasOwnProperty.call(this.parser, elementName)) {
|
|
688
|
+
// treat it as a opaque XML bloc for the time being
|
|
689
|
+
// until we find the definition of this object, so we know how to interpret the fields
|
|
690
|
+
this._cloneFragment = new node_opcua_xml2json_1.InternalFragmentClonerReaderState();
|
|
691
|
+
this.engine._promote(this._cloneFragment, this.engine.currentLevel, elementName, attrs);
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
finish() {
|
|
695
|
+
const self = this.parent; // ExtensionObject
|
|
696
|
+
// typeDefinitionId is also the "Default XML" encoding nodeId !
|
|
697
|
+
switch (self.typeDefinitionId.toString()) {
|
|
698
|
+
case "i=7616": // EnumValueType
|
|
699
|
+
case "ns=0;i=7616": // EnumValueType
|
|
700
|
+
self.extensionObject = self.parser.Body.parser.EnumValueType.enumValueType;
|
|
701
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
702
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
703
|
+
break;
|
|
704
|
+
case "i=297": // Arguments
|
|
705
|
+
case "ns=0;i=297": // Arguments
|
|
706
|
+
self.extensionObject = self.parser.Body.parser.Argument.argument;
|
|
707
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
708
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
709
|
+
break;
|
|
710
|
+
case "i=888":
|
|
711
|
+
case "ns=0;i=888": // EUInformation
|
|
712
|
+
self.extensionObject = self.parser.Body.parser.EUInformation.euInformation;
|
|
713
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
714
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
715
|
+
break;
|
|
716
|
+
case "i=885": // Range
|
|
717
|
+
case "ns=0;i=885":
|
|
718
|
+
self.extensionObject = self.parser.Body.parser.Range.range;
|
|
719
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
720
|
+
(0, node_opcua_assert_1.assert)(self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
721
|
+
break;
|
|
722
|
+
default: {
|
|
723
|
+
this.bodyXML = this._cloneFragment.value;
|
|
724
|
+
this._cloneFragment.value = null;
|
|
725
|
+
// the "Default Xml" encoding nodeId
|
|
726
|
+
const xmlEncodingNodeId = _translateNodeId(self.typeDefinitionId.toString());
|
|
727
|
+
if (xmlEncodingNodeId.isEmpty()) {
|
|
728
|
+
debugLog("xmlEncodingNodeId is empty for " + self.typeDefinitionId.toString());
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
let captureXmlBody = this.bodyXML;
|
|
732
|
+
if (doDebug) {
|
|
733
|
+
debugLog("xxxx ", chalk.yellow(captureXmlBody));
|
|
734
|
+
}
|
|
735
|
+
// this is a user defined Extension Object
|
|
736
|
+
debugLog("load nodeset2: typeDefinitionId in ExtensionObject Default XML = " + xmlEncodingNodeId.toString());
|
|
737
|
+
let captured = self.postTaskData;
|
|
738
|
+
self.extensionObjectPojo = null;
|
|
739
|
+
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
740
|
+
const extensionObject = yield (0, decode_xml_extension_object_1.decodeXmlExtensionObject)(addressSpace2, xmlEncodingNodeId, captureXmlBody);
|
|
741
|
+
if (captured) {
|
|
742
|
+
captured.postponedExtensionObject = extensionObject;
|
|
743
|
+
}
|
|
744
|
+
captureXmlBody = undefined;
|
|
745
|
+
captured = undefined;
|
|
746
|
+
});
|
|
747
|
+
postTasks0_DecodePojoString.push(task);
|
|
748
|
+
(0, node_opcua_assert_1.assert)(!self.extensionObject || self.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject);
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
const extensionObject_parser = {
|
|
756
|
+
ExtensionObject: {
|
|
757
|
+
init() {
|
|
758
|
+
this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
|
|
759
|
+
this.extensionObject = null;
|
|
760
|
+
this.extensionObjectPojo = null;
|
|
761
|
+
this.postTaskData = { postponedExtensionObject: null };
|
|
762
|
+
},
|
|
763
|
+
parser: _extensionObject_inner_parser,
|
|
764
|
+
finish() {
|
|
765
|
+
/* empty */
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
function BasicType_parser(dataType, parseFunc) {
|
|
770
|
+
const _parser = {};
|
|
771
|
+
const r = {
|
|
772
|
+
init(name, attrs) {
|
|
773
|
+
this.value = undefined;
|
|
774
|
+
},
|
|
775
|
+
finish() {
|
|
776
|
+
this.value = parseFunc.call(this, this.text);
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
_parser[dataType] = r;
|
|
780
|
+
return _parser;
|
|
781
|
+
}
|
|
782
|
+
function ListOf(dataType, parseFunc) {
|
|
783
|
+
return {
|
|
784
|
+
init() {
|
|
785
|
+
this.listData = [];
|
|
786
|
+
},
|
|
787
|
+
parser: BasicType_parser(dataType, parseFunc),
|
|
788
|
+
finish() {
|
|
789
|
+
this.parent.parent.obj.value = {
|
|
790
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
791
|
+
dataType: node_opcua_variant_1.DataType[dataType],
|
|
792
|
+
value: this.listData
|
|
793
|
+
};
|
|
794
|
+
},
|
|
795
|
+
endElement(element) {
|
|
796
|
+
this.listData.push(this.parser[dataType].value);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
function parser2(type, p) {
|
|
801
|
+
return {
|
|
802
|
+
finish() {
|
|
803
|
+
this.parent.parent.obj.value = {
|
|
804
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
805
|
+
dataType: node_opcua_variant_1.DataType[type],
|
|
806
|
+
value: p(this.text)
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
const parseUInt64 = (str) => (0, node_opcua_basic_types_1.coerceUInt64)(str);
|
|
812
|
+
const parseInt64 = (str) => (0, node_opcua_basic_types_1.coerceInt64)(str);
|
|
813
|
+
const state_Variant = {
|
|
814
|
+
init: () => {
|
|
815
|
+
/* empty */
|
|
816
|
+
},
|
|
817
|
+
parser: {
|
|
818
|
+
QualifiedName: Object.assign(Object.assign({}, qualifiedName_parser.QualifiedName), { finish() {
|
|
819
|
+
this.parent.parent.obj.value = {
|
|
820
|
+
dataType: node_opcua_variant_1.DataType.QualifiedName,
|
|
821
|
+
value: this.qualifiedName
|
|
822
|
+
};
|
|
823
|
+
} }),
|
|
824
|
+
LocalizedText: Object.assign(Object.assign({}, localizedText_parser.LocalizedText), { finish() {
|
|
825
|
+
this.parent.parent.obj.value = {
|
|
826
|
+
dataType: node_opcua_variant_1.DataType.LocalizedText,
|
|
827
|
+
value: this.localizedText
|
|
828
|
+
};
|
|
829
|
+
} }),
|
|
830
|
+
XmlElement: {
|
|
831
|
+
finish() {
|
|
832
|
+
this.parent.parent.obj.value = {
|
|
833
|
+
dataType: node_opcua_variant_1.DataType.XmlElement,
|
|
834
|
+
value: this.text
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
String: {
|
|
839
|
+
finish() {
|
|
840
|
+
this.parent.parent.obj.value = {
|
|
841
|
+
dataType: node_opcua_variant_1.DataType.String,
|
|
842
|
+
value: this.text
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
Guid: {
|
|
847
|
+
parser: {
|
|
848
|
+
String: {
|
|
849
|
+
finish() {
|
|
850
|
+
const guid = this.text;
|
|
851
|
+
if (!(0, node_opcua_basic_types_1.isValidGuid)(guid)) {
|
|
852
|
+
/* ?*/
|
|
853
|
+
}
|
|
854
|
+
this.parent.parent.parent.obj.value = {
|
|
855
|
+
dataType: node_opcua_variant_1.DataType.Guid,
|
|
856
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
857
|
+
value: this.text
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
NodeId: {
|
|
864
|
+
parser: {
|
|
865
|
+
Identifier: {
|
|
866
|
+
finish() {
|
|
867
|
+
const nodeId = this.text;
|
|
868
|
+
this.parent.parent.parent.obj.value = {
|
|
869
|
+
dataType: node_opcua_variant_1.DataType.NodeId,
|
|
870
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
871
|
+
value: _translateNodeId((0, node_opcua_nodeid_1.resolveNodeId)(nodeId).toString())
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
},
|
|
877
|
+
Boolean: parser2("Boolean", ec.coerceBoolean),
|
|
878
|
+
Byte: parser2("Byte", parseInt),
|
|
879
|
+
Int16: parser2("Int16", parseInt),
|
|
880
|
+
Int32: parser2("Int32", parseInt),
|
|
881
|
+
Int8: parser2("Int8", parseInt),
|
|
882
|
+
SByte: parser2("SByte", parseInt),
|
|
883
|
+
UInt16: parser2("UInt16", parseInt),
|
|
884
|
+
UInt32: parser2("UInt32", parseInt),
|
|
885
|
+
UInt8: parser2("UInt8", parseInt),
|
|
886
|
+
UInt64: parser2("UInt64", parseUInt64),
|
|
887
|
+
Int64: parser2("Int64", parseInt64),
|
|
888
|
+
ByteString: {
|
|
889
|
+
init() {
|
|
890
|
+
this.value = null;
|
|
891
|
+
},
|
|
892
|
+
finish() {
|
|
893
|
+
const base64text = this.text;
|
|
894
|
+
const byteString = Buffer.from(base64text, "base64");
|
|
895
|
+
this.parent.parent.obj.value = {
|
|
896
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
897
|
+
dataType: node_opcua_variant_1.DataType.ByteString,
|
|
898
|
+
value: byteString
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
},
|
|
902
|
+
Float: {
|
|
903
|
+
finish() {
|
|
904
|
+
this.parent.parent.obj.value = {
|
|
905
|
+
dataType: node_opcua_variant_1.DataType.Float,
|
|
906
|
+
value: parseFloat(this.text)
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
Double: {
|
|
911
|
+
finish() {
|
|
912
|
+
this.parent.parent.obj.value = {
|
|
913
|
+
dataType: node_opcua_variant_1.DataType.Double,
|
|
914
|
+
value: parseFloat(this.text)
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
ListOfExtensionObject: {
|
|
919
|
+
init() {
|
|
920
|
+
this.listExtensionObject = [];
|
|
921
|
+
},
|
|
922
|
+
parser: extensionObject_parser,
|
|
923
|
+
finish() {
|
|
924
|
+
installExtensionObjectListInitializationPostTask(this);
|
|
925
|
+
},
|
|
926
|
+
startElement(elementName) {
|
|
927
|
+
/* empty */
|
|
928
|
+
const extensionObjectParser = this.parser.ExtensionObject;
|
|
929
|
+
extensionObjectParser.postTaskData = { postponedExtensionObject: null };
|
|
930
|
+
},
|
|
931
|
+
endElement(elementName) {
|
|
932
|
+
const extensionObjectParser = this.parser.ExtensionObject;
|
|
933
|
+
this.listExtensionObject.push(extensionObjectParser.extensionObject);
|
|
934
|
+
if (this.parser.ExtensionObject.extensionObject === null) {
|
|
935
|
+
// extension object creation will be postponed
|
|
936
|
+
const index = this.listExtensionObject.length - 1;
|
|
937
|
+
let capturedData = extensionObjectParser.postTaskData;
|
|
938
|
+
// istanbul ignore next
|
|
939
|
+
if (!capturedData) {
|
|
940
|
+
throw new Error("Internal Error : postponedExtensionObject not resolved");
|
|
941
|
+
}
|
|
942
|
+
let listExtensionObject = this.listExtensionObject;
|
|
943
|
+
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
944
|
+
// istanbul ignore next
|
|
945
|
+
if (!capturedData.postponedExtensionObject) {
|
|
946
|
+
throw new Error("Internal Error : postponedExtensionObject not resolved");
|
|
947
|
+
}
|
|
948
|
+
listExtensionObject[index] = capturedData.postponedExtensionObject;
|
|
949
|
+
capturedData = undefined;
|
|
950
|
+
listExtensionObject = undefined;
|
|
951
|
+
});
|
|
952
|
+
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
ListOfLocalizedText: {
|
|
957
|
+
init() {
|
|
958
|
+
this.listData = [];
|
|
959
|
+
},
|
|
960
|
+
parser: localizedText_parser,
|
|
961
|
+
finish() {
|
|
962
|
+
this.parent.parent.obj.value = {
|
|
963
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
964
|
+
dataType: node_opcua_variant_1.DataType.LocalizedText,
|
|
965
|
+
value: this.listData
|
|
966
|
+
};
|
|
967
|
+
},
|
|
968
|
+
endElement() {
|
|
969
|
+
this.listData.push(this.parser.LocalizedText.localizedText);
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
ListOfQualifiedName: {
|
|
973
|
+
init() {
|
|
974
|
+
this.listData = [];
|
|
975
|
+
},
|
|
976
|
+
parser: qualifiedName_parser,
|
|
977
|
+
finish() {
|
|
978
|
+
this.parent.parent.obj.value = {
|
|
979
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
980
|
+
dataType: node_opcua_variant_1.DataType.QualifiedName,
|
|
981
|
+
value: this.listData
|
|
982
|
+
};
|
|
983
|
+
},
|
|
984
|
+
endElement() {
|
|
985
|
+
this.listData.push(this.parser.QualifiedName.qualifiedName);
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
ListOfNodeId: {
|
|
989
|
+
init() {
|
|
990
|
+
this.listData = [];
|
|
991
|
+
},
|
|
992
|
+
parser: nodeId_parser,
|
|
993
|
+
finish() {
|
|
994
|
+
this.parent.parent.obj.value = {
|
|
995
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
996
|
+
dataType: node_opcua_variant_1.DataType.NodeId,
|
|
997
|
+
value: this.listData
|
|
998
|
+
};
|
|
999
|
+
},
|
|
1000
|
+
endElement(elementName) {
|
|
1001
|
+
this.listData.push(this.parser.NodeId.nodeId);
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
ListOfBoolean: ListOf("Boolean", ec.coerceBoolean),
|
|
1005
|
+
ListOfByte: ListOf("Byte", parseInt),
|
|
1006
|
+
ListOfDouble: ListOf("Double", parseFloat),
|
|
1007
|
+
ListOfFloat: ListOf("Float", parseFloat),
|
|
1008
|
+
ListOfInt32: ListOf("Int32", parseInt),
|
|
1009
|
+
ListOfInt16: ListOf("Int16", parseInt),
|
|
1010
|
+
ListOfInt8: ListOf("Int8", parseInt),
|
|
1011
|
+
ListOfUInt32: ListOf("UInt32", parseInt),
|
|
1012
|
+
ListOfUInt16: ListOf("UInt16", parseInt),
|
|
1013
|
+
ListOfUInt8: ListOf("UInt8", parseInt),
|
|
1014
|
+
ListOfString: ListOf("String", (value) => value),
|
|
1015
|
+
ListOfXmlElement: ListOf("XmlElement", (value) => value),
|
|
1016
|
+
ExtensionObject: {
|
|
1017
|
+
init() {
|
|
1018
|
+
this.typeDefinitionId = node_opcua_nodeid_1.NodeId.nullNodeId;
|
|
1019
|
+
this.extensionObject = null;
|
|
1020
|
+
this.postTaskData = { postponedExtensionObject: null };
|
|
1021
|
+
},
|
|
1022
|
+
parser: _extensionObject_inner_parser,
|
|
1023
|
+
finish() {
|
|
1024
|
+
// istanbul ignore next
|
|
1025
|
+
if (this.extensionObject && !(this.extensionObject instanceof node_opcua_extension_object_1.ExtensionObject)) {
|
|
1026
|
+
throw new Error("expecting an extension object");
|
|
1027
|
+
}
|
|
1028
|
+
this.parent.parent.obj.value = {
|
|
1029
|
+
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
1030
|
+
value: this.extensionObject
|
|
1031
|
+
};
|
|
1032
|
+
if (!this.extensionObject) {
|
|
1033
|
+
installExtensionObjectInitializationPostTask(this);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
function installExtensionObjectListInitializationPostTask(element) {
|
|
1040
|
+
let listExtensionObject = element.listExtensionObject;
|
|
1041
|
+
let nodeId = element.parent.parent.obj.nodeId;
|
|
1042
|
+
(0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
|
|
1043
|
+
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1044
|
+
const node = addressSpace2.findNode(nodeId);
|
|
1045
|
+
if (!node) {
|
|
1046
|
+
debugLog("Cannot find node with nodeId " + nodeId + ". may be the node was marked as deprecated");
|
|
1047
|
+
}
|
|
1048
|
+
else if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
1049
|
+
const v = node;
|
|
1050
|
+
v.setValueFromSource({
|
|
1051
|
+
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
1052
|
+
value: listExtensionObject
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
1056
|
+
const v = node;
|
|
1057
|
+
v /*fix me*/.value.value = listExtensionObject;
|
|
1058
|
+
}
|
|
1059
|
+
listExtensionObject.slice(0);
|
|
1060
|
+
listExtensionObject = undefined;
|
|
1061
|
+
nodeId = undefined;
|
|
1062
|
+
});
|
|
1063
|
+
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
1064
|
+
}
|
|
1065
|
+
function installExtensionObjectInitializationPostTask(element) {
|
|
1066
|
+
// let's create the mechanism that postpone the creation of the
|
|
1067
|
+
// extension object
|
|
1068
|
+
let data = element.postTaskData;
|
|
1069
|
+
let variant = element.parent.parent.obj.value;
|
|
1070
|
+
let nodeId = element.parent.parent.obj.nodeId;
|
|
1071
|
+
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1072
|
+
variant.value = data.postponedExtensionObject;
|
|
1073
|
+
(0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
|
|
1074
|
+
const node = addressSpace2.findNode(nodeId);
|
|
1075
|
+
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
1076
|
+
const v = node;
|
|
1077
|
+
v.setValueFromSource(variant);
|
|
1078
|
+
}
|
|
1079
|
+
else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
1080
|
+
const v = node;
|
|
1081
|
+
v /*fix me*/.value.value = variant.value;
|
|
1082
|
+
}
|
|
1083
|
+
data.postponedExtensionObject = null;
|
|
1084
|
+
data = undefined;
|
|
1085
|
+
variant = undefined;
|
|
1086
|
+
nodeId = undefined;
|
|
1087
|
+
});
|
|
1088
|
+
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
1089
|
+
}
|
|
1090
|
+
const state_UAVariable = {
|
|
1091
|
+
init(name, attrs) {
|
|
1092
|
+
this.obj = {};
|
|
1093
|
+
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
|
|
1094
|
+
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
1095
|
+
this.obj.parentNodeId = convertToNodeId(attrs.ParentNodeId);
|
|
1096
|
+
this.obj.dataType = convertToNodeId(attrs.DataType);
|
|
1097
|
+
this.obj.valueRank = attrs.ValueRank === undefined ? -1 : ec.coerceInt32(attrs.ValueRank);
|
|
1098
|
+
this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
|
|
1099
|
+
this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
|
|
1100
|
+
this.obj.minimumSamplingInterval = parseInt(this.obj.minimumSamplingInterval, 10);
|
|
1101
|
+
this.obj.historizing = false;
|
|
1102
|
+
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
1103
|
+
this.obj.accessLevel = convertAccessLevel(attrs.AccessLevel);
|
|
1104
|
+
this.obj.userAccessLevel = this.obj.accessLevel; // convertAccessLevel(attrs.UserAccessLevel || attrs.AccessLevel);
|
|
1105
|
+
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1106
|
+
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1107
|
+
},
|
|
1108
|
+
finish() {
|
|
1109
|
+
if (this.isDraft || this.isDeprecated) {
|
|
1110
|
+
debugLog("Ignoring Draft/Deprecated UAVariable =", this.obj.browseName.toString());
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
/*
|
|
1114
|
+
// set default value based on obj data Type
|
|
1115
|
+
if (this.obj.value === undefined) {
|
|
1116
|
+
const dataTypeNode = this.obj.dataType;
|
|
1117
|
+
const valueRank = this.obj.valueRank;
|
|
1118
|
+
this.obj.value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
|
|
1119
|
+
}
|
|
1120
|
+
*/
|
|
1121
|
+
// eslint-disable-next-line prefer-const
|
|
1122
|
+
let capturedVariable;
|
|
1123
|
+
if (this.obj.value) {
|
|
1124
|
+
let capturedValue = this.obj.value;
|
|
1125
|
+
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1126
|
+
if (false && doDebug) {
|
|
1127
|
+
debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new node_opcua_variant_1.Variant(capturedValue).toString());
|
|
1128
|
+
}
|
|
1129
|
+
capturedVariable.setValueFromSource(capturedValue);
|
|
1130
|
+
capturedValue = undefined;
|
|
1131
|
+
capturedVariable = undefined;
|
|
1132
|
+
});
|
|
1133
|
+
postTasks1_InitializeVariable.push(task);
|
|
1134
|
+
}
|
|
1135
|
+
else {
|
|
1136
|
+
const task = (addressSpace2) => __awaiter(this, void 0, void 0, function* () {
|
|
1137
|
+
const dataTypeNode = capturedVariable.dataType;
|
|
1138
|
+
const valueRank = capturedVariable.valueRank;
|
|
1139
|
+
const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank);
|
|
1140
|
+
if (value) {
|
|
1141
|
+
if (false && doDebug) {
|
|
1142
|
+
debugLog("2 setting value to ", capturedVariable.nodeId.toString(), value);
|
|
1143
|
+
}
|
|
1144
|
+
if (value.dataType === node_opcua_variant_1.DataType.Null) {
|
|
1145
|
+
capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.BadWaitingForInitialData);
|
|
1146
|
+
}
|
|
1147
|
+
else {
|
|
1148
|
+
capturedVariable.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.Good);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
capturedVariable = undefined;
|
|
1152
|
+
});
|
|
1153
|
+
postTasks1_InitializeVariable.push(task);
|
|
1154
|
+
}
|
|
1155
|
+
this.obj.value = undefined;
|
|
1156
|
+
capturedVariable = _internal_createNode(this.obj);
|
|
1157
|
+
},
|
|
1158
|
+
parser: {
|
|
1159
|
+
DisplayName: {
|
|
1160
|
+
finish() {
|
|
1161
|
+
this.parent.obj.displayName = this.text;
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
Description: {
|
|
1165
|
+
finish() {
|
|
1166
|
+
this.parent.obj.description = this.text;
|
|
1167
|
+
}
|
|
1168
|
+
},
|
|
1169
|
+
References: references_parser,
|
|
1170
|
+
Value: state_Variant
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
const state_UAVariableType = {
|
|
1174
|
+
init(name, attrs) {
|
|
1175
|
+
this.obj = {};
|
|
1176
|
+
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
|
|
1177
|
+
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.VariableType;
|
|
1178
|
+
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
1179
|
+
this.obj.parentNodeId = attrs.ParentNodeId || null;
|
|
1180
|
+
this.obj.dataType = convertToNodeId(attrs.DataType) || null;
|
|
1181
|
+
this.obj.valueRank = ec.coerceInt32(attrs.ValueRank) || -1;
|
|
1182
|
+
this.obj.arrayDimensions = this.obj.valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions);
|
|
1183
|
+
this.obj.minimumSamplingInterval = attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0;
|
|
1184
|
+
this.obj.historizing = false;
|
|
1185
|
+
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
1186
|
+
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1187
|
+
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1188
|
+
},
|
|
1189
|
+
finish() {
|
|
1190
|
+
if (this.isDraft || this.isDeprecated) {
|
|
1191
|
+
debugLog("Ignoring Draft/Deprecated UAVariableType =", this.obj.browseName.toString());
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
try {
|
|
1195
|
+
_internal_createNode(this.obj);
|
|
1196
|
+
} /* istanbul ignore next */
|
|
1197
|
+
catch (err) {
|
|
1198
|
+
this.obj.addressSpace = null;
|
|
1199
|
+
// tslint:disable:no-console
|
|
1200
|
+
console.warn(" Cannot create object", JSON.stringify(this.obj, null, " "));
|
|
1201
|
+
throw err;
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
parser: {
|
|
1205
|
+
DisplayName: {
|
|
1206
|
+
finish() {
|
|
1207
|
+
this.parent.obj.displayName = this.text;
|
|
1208
|
+
}
|
|
1209
|
+
},
|
|
1210
|
+
Description: {
|
|
1211
|
+
finish() {
|
|
1212
|
+
this.parent.obj.description = this.text;
|
|
1213
|
+
}
|
|
1214
|
+
},
|
|
1215
|
+
References: references_parser,
|
|
1216
|
+
Value: state_Variant
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
const state_UAMethod = {
|
|
1220
|
+
init(name, attrs) {
|
|
1221
|
+
this.obj = {};
|
|
1222
|
+
this.obj.nodeClass = node_opcua_data_model_1.NodeClass.Method;
|
|
1223
|
+
// MethodDeclarationId
|
|
1224
|
+
// ParentNodeId
|
|
1225
|
+
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
|
|
1226
|
+
this.obj.parentNodeId = attrs.ParentNodeId || null;
|
|
1227
|
+
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
1228
|
+
this.obj.methodDeclarationId = attrs.MethodDeclarationId ? _translateNodeId(attrs.MethodDeclarationId) : null;
|
|
1229
|
+
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1230
|
+
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1231
|
+
},
|
|
1232
|
+
finish() {
|
|
1233
|
+
if (this.isDraft || this.isDeprecated) {
|
|
1234
|
+
debugLog("Ignoring Draft/Deprecated UAMethod =", this.obj.browseName.toString());
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
_internal_createNode(this.obj);
|
|
1238
|
+
},
|
|
1239
|
+
parser: {
|
|
1240
|
+
DisplayName: {
|
|
1241
|
+
finish() {
|
|
1242
|
+
this.parent.obj.displayName = this.text;
|
|
1243
|
+
}
|
|
1244
|
+
},
|
|
1245
|
+
References: references_parser
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
const state_ModelTableEntry = new node_opcua_xml2json_1.ReaderState({
|
|
1249
|
+
// ModelTableEntry
|
|
1250
|
+
init() {
|
|
1251
|
+
this._requiredModels = [];
|
|
1252
|
+
},
|
|
1253
|
+
parser: {
|
|
1254
|
+
RequiredModel: {
|
|
1255
|
+
init(name, attrs) {
|
|
1256
|
+
const modelUri = attrs.ModelUri;
|
|
1257
|
+
const version = attrs.Version;
|
|
1258
|
+
const publicationDate = new Date(Date.parse(attrs.PublicationDate));
|
|
1259
|
+
this.parent._requiredModels.push({ modelUri, version, publicationDate });
|
|
1260
|
+
},
|
|
1261
|
+
finish() {
|
|
1262
|
+
/** */
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
finish() {
|
|
1267
|
+
const modelUri = this.attrs.ModelUri; // //"http://opcfoundation.org/UA/"
|
|
1268
|
+
const version = this.attrs.Version; // 1.04
|
|
1269
|
+
const publicationDate = this.attrs.PublicationDate ? new Date(Date.parse(this.attrs.PublicationDate)) : undefined; // "2018-05-15T00:00:00Z" "
|
|
1270
|
+
// optional,
|
|
1271
|
+
const symbolicName = this.attrs.SymbolicName;
|
|
1272
|
+
const accessRestrictions = this.attrs.AccessRestrictions;
|
|
1273
|
+
const model = {
|
|
1274
|
+
accessRestrictions,
|
|
1275
|
+
modelUri,
|
|
1276
|
+
publicationDate,
|
|
1277
|
+
requiredModels: this._requiredModels,
|
|
1278
|
+
symbolicName,
|
|
1279
|
+
version
|
|
1280
|
+
};
|
|
1281
|
+
const namespace = _add_namespace(model);
|
|
1282
|
+
models.push(model);
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
function _perform() {
|
|
1286
|
+
/**special case for old nodeset file version 1.02 where no models exists */
|
|
1287
|
+
if (models.length === 0) {
|
|
1288
|
+
for (const namespaceuri of _namespaceUris) {
|
|
1289
|
+
const existingNamespace = addressSpace1.getNamespace(namespaceuri);
|
|
1290
|
+
if (existingNamespace) {
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
_add_namespace({
|
|
1294
|
+
modelUri: namespaceuri,
|
|
1295
|
+
version: "1.0.0",
|
|
1296
|
+
requiredModels: []
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
doDebug && debugLog("xxx models =", JSON.stringify(models, null, " "));
|
|
1301
|
+
doDebug && debugLog("xxx _namespaceUris =", _namespaceUris);
|
|
1302
|
+
_register_namespace_uri_in_translation_table("http://opcfoundation.org/UA/");
|
|
1303
|
+
for (const namespaceUri of _namespaceUris) {
|
|
1304
|
+
_register_namespace_uri_in_translation_table(namespaceUri);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
// state_ModelTableEntry.parser["RequiredModel"] = state_ModelTableEntry;
|
|
1308
|
+
let _namespaceUris = [];
|
|
1309
|
+
const state_0 = {
|
|
1310
|
+
parser: {
|
|
1311
|
+
Aliases: {
|
|
1312
|
+
init() {
|
|
1313
|
+
_perform();
|
|
1314
|
+
},
|
|
1315
|
+
parser: { Alias: state_Alias }
|
|
1316
|
+
},
|
|
1317
|
+
NamespaceUris: {
|
|
1318
|
+
init() {
|
|
1319
|
+
//
|
|
1320
|
+
_namespaceUris = [];
|
|
1321
|
+
},
|
|
1322
|
+
parser: {
|
|
1323
|
+
Uri: {
|
|
1324
|
+
finish() {
|
|
1325
|
+
_namespaceUris.push(this.text);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
1329
|
+
finish() {
|
|
1330
|
+
// verify that requested namespaces are already loaded or abort with a message
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
Models: {
|
|
1334
|
+
// ModelTable
|
|
1335
|
+
init(name, attrs) {
|
|
1336
|
+
/* */
|
|
1337
|
+
},
|
|
1338
|
+
parser: {
|
|
1339
|
+
Model: state_ModelTableEntry
|
|
1340
|
+
},
|
|
1341
|
+
finish() {
|
|
1342
|
+
/** */
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
UADataType: state_UADataType,
|
|
1346
|
+
UAMethod: state_UAMethod,
|
|
1347
|
+
UAObject: state_UAObject,
|
|
1348
|
+
UAObjectType: state_UAObjectType,
|
|
1349
|
+
UAReferenceType: state_UAReferenceType,
|
|
1350
|
+
UAVariable: state_UAVariable,
|
|
1351
|
+
UAVariableType: state_UAVariableType
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
const parser = new node_opcua_xml2json_1.Xml2Json(state_0);
|
|
1355
|
+
function terminate(callback) {
|
|
1356
|
+
var _a, _b, _c;
|
|
1357
|
+
make_back_references(addressSpace1);
|
|
1358
|
+
// setting up Server_NamespaceArray
|
|
1359
|
+
if ((_c = (_b = (_a = addressSpace1.rootFolder) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.server) === null || _c === void 0 ? void 0 : _c.namespaceArray) {
|
|
1360
|
+
addressSpace1.rootFolder.objects.server.namespaceArray.setValueFromSource({
|
|
1361
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
1362
|
+
dataType: node_opcua_variant_1.DataType.String,
|
|
1363
|
+
value: addressSpace1.getNamespaceArray().map((ns) => ns.namespaceUri)
|
|
1364
|
+
});
|
|
1365
|
+
// istanbul ignore next
|
|
1366
|
+
if (doDebug) {
|
|
1367
|
+
debugLog("addressSpace NS = ", addressSpace1.rootFolder.objects.server.namespaceArray.readValue().value.value.join(" "));
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
doDebug &&
|
|
1371
|
+
debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------") +
|
|
1372
|
+
chalk.green("DONE"));
|
|
1373
|
+
function performPostLoadingTasks(tasks) {
|
|
1374
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1375
|
+
for (const task of tasks) {
|
|
1376
|
+
try {
|
|
1377
|
+
yield task(addressSpace1);
|
|
1378
|
+
}
|
|
1379
|
+
catch (err) {
|
|
1380
|
+
// istanbul ignore next
|
|
1381
|
+
// tslint:disable:no-console
|
|
1382
|
+
if (err instanceof Error) {
|
|
1383
|
+
console.log(" performPostLoadingTasks Err => ", err.message, "\n", err);
|
|
1384
|
+
}
|
|
1385
|
+
yield task(addressSpace1);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
tasks.splice(0);
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
function finalSteps() {
|
|
1392
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1393
|
+
/// ----------------------------------------------------------------------------------------
|
|
1394
|
+
// perform post task
|
|
1395
|
+
doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------"));
|
|
1396
|
+
yield performPostLoadingTasks(postTasks);
|
|
1397
|
+
doDebug && debugLog(chalk.bgGreenBright("Performing DataType extraction -------------------------------------------"));
|
|
1398
|
+
(0, node_opcua_assert_1.assert)(!addressSpace1.suspendBackReference);
|
|
1399
|
+
yield (0, ensure_datatype_extracted_1.ensureDatatypeExtracted)(addressSpace);
|
|
1400
|
+
const dataTypeManager = addressSpace.getDataTypeManager();
|
|
1401
|
+
/// ----------------------------------------------------------------------------------------
|
|
1402
|
+
doDebug && debugLog(chalk.bgGreenBright("DataType extraction done ") + chalk.green("DONE"));
|
|
1403
|
+
for (const { name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
|
|
1404
|
+
if (dataTypeNodeId.namespace === 0) {
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(dataTypeNodeId.namespace);
|
|
1408
|
+
}
|
|
1409
|
+
pendingSimpleTypeToRegister.splice(0);
|
|
1410
|
+
doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Decoding Pojo String (parsing XML objects) -"));
|
|
1411
|
+
yield performPostLoadingTasks(postTasks0_DecodePojoString);
|
|
1412
|
+
doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Variables ---------------------"));
|
|
1413
|
+
yield performPostLoadingTasks(postTasks1_InitializeVariable);
|
|
1414
|
+
doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks: (assigning Extension Object to Variables) -"));
|
|
1415
|
+
yield performPostLoadingTasks(postTasks2_AssignedExtensionObjectToDataValue);
|
|
1416
|
+
doDebug && debugLog(chalk.bgGreenBright("Performing post variable initialization ---------------------"));
|
|
1417
|
+
(0, namespace_post_step_1.promoteObjectsAndVariables)(addressSpace);
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
finalSteps()
|
|
1421
|
+
.then(() => callback())
|
|
1422
|
+
.catch((err1) => {
|
|
1423
|
+
console.log("Error ", (0, node_opcua_assert_1.renderError)(err1));
|
|
1424
|
+
callback(err1);
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
function addNodeSet(xmlData, callback1) {
|
|
1428
|
+
_reset_namespace_translation();
|
|
1429
|
+
parser.parseString(xmlData, callback1);
|
|
1430
|
+
}
|
|
1431
|
+
return {
|
|
1432
|
+
addNodeSet,
|
|
1433
|
+
terminate
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
exports.makeNodeSetParserEngine = makeNodeSetParserEngine;
|
|
1437
|
+
class NodeSetLoader {
|
|
1438
|
+
constructor(addressSpace) {
|
|
1439
|
+
this._s = makeNodeSetParserEngine(addressSpace);
|
|
1440
|
+
}
|
|
1441
|
+
addNodeSet(xmlData, callback) {
|
|
1442
|
+
if (!callback) {
|
|
1443
|
+
throw new Error("Expecting callback function");
|
|
1444
|
+
}
|
|
1445
|
+
return this._s.addNodeSet(xmlData, callback);
|
|
1446
|
+
}
|
|
1447
|
+
addNodeSetAsync(xmlData) {
|
|
1448
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1449
|
+
return (0, util_1.promisify)(this.addNodeSet).call(this, xmlData);
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
terminate(callback) {
|
|
1453
|
+
this._s.terminate(callback);
|
|
1454
|
+
}
|
|
1455
|
+
terminateAsync() {
|
|
1456
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1457
|
+
return (0, util_1.promisify)(this.terminate).call(this);
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
exports.NodeSetLoader = NodeSetLoader;
|
|
1462
1462
|
//# sourceMappingURL=load_nodeset2.js.map
|