node-opcua-address-space 2.178.0 → 2.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/source/address_space_ts.d.ts +16 -6
- package/dist/source/address_space_ts.js +1 -1
- package/dist/source/address_space_ts.js.map +1 -1
- package/dist/source/helpers/argument_list.js +2 -2
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/helpers/call_helpers.js +3 -0
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/helpers/dump_tools.js +6 -2
- package/dist/source/helpers/dump_tools.js.map +1 -1
- package/dist/source/helpers/make_optionals_map.d.ts +3 -1
- package/dist/source/helpers/make_optionals_map.js.map +1 -1
- package/dist/source/interfaces/extension_object_constructor.d.ts +1 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js +0 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -1
- package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +2 -1
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +12 -8
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/make_xml_extension_object_parser.js +26 -7
- package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/loader/parsers/extension_object_parser.d.ts +6 -4
- package/dist/source/loader/parsers/extension_object_parser.js +12 -6
- package/dist/source/loader/parsers/extension_object_parser.js.map +1 -1
- package/dist/source/loader/parsers/localized_text_parser.d.ts +1 -1
- package/dist/source/loader/parsers/nodeid_parser.d.ts +10 -2
- package/dist/source/loader/parsers/nodeid_parser.js.map +1 -1
- package/dist/source/loader/parsers/qualified_name_parser.d.ts +1 -2
- package/dist/source/loader/parsers/variant_parser.d.ts +8 -2
- package/dist/source/loader/parsers/variant_parser.js +11 -8
- package/dist/source/loader/parsers/variant_parser.js.map +1 -1
- package/dist/source/pseudo_session.js +70 -24
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/xml_writer.d.ts +1 -1
- package/dist/src/_instantiate_helpers.js +0 -3
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +3 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +0 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +7 -2
- package/dist/src/address_space.js +36 -28
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_private.d.ts +1 -0
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +6 -9
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +6 -6
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +8 -4
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +6 -5
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +3 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
- package/dist/src/base_node_impl.js +17 -8
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.js +0 -6
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/extension_object_array_node.d.ts +9 -1
- package/dist/src/extension_object_array_node.js +20 -3
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/get_basic_datatype.js +3 -1
- package/dist/src/get_basic_datatype.js.map +1 -1
- package/dist/src/historical_access/address_space_historical_data_node.js +2 -4
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/namespace_impl.js +6 -5
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeid_manager.js +4 -5
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +10 -11
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.js +2 -4
- package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +71 -43
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/reference_impl.d.ts +2 -2
- package/dist/src/reference_impl.js +5 -4
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.js +1 -1
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +9 -7
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/tool_isSubtypeOf.js.map +1 -1
- package/dist/src/ua_data_type_impl.js +4 -4
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.js +21 -11
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.d.ts +5 -2
- package/dist/src/ua_object_type_impl.js +4 -3
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.js +1 -2
- package/dist/src/ua_reference_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +9 -11
- package/dist/src/ua_variable_impl.js +103 -65
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.d.ts +6 -6
- package/dist/src/ua_variable_impl_ext_obj.js +33 -22
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +6 -2
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/distHelpers/add_event_generator_object.js +3 -0
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/boiler_system.js +27 -6
- package/distHelpers/boiler_system.js.map +1 -1
- package/distHelpers/create_minimalist_address_space_nodeset.js +3 -3
- package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -1
- package/distHelpers/date_utils.js.map +1 -1
- package/distHelpers/dump_statemachine.js +1 -1
- package/distHelpers/dump_statemachine.js.map +1 -1
- package/distHelpers/get_address_space_fixture.js +0 -1
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/package.json +41 -41
- package/source/address_space_ts.ts +19 -9
- package/source/helpers/argument_list.ts +2 -2
- package/source/helpers/call_helpers.ts +4 -1
- package/source/helpers/dump_tools.ts +7 -3
- package/source/helpers/make_optionals_map.ts +4 -2
- package/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.ts +4 -3
- package/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.ts +10 -11
- package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +6 -7
- package/source/interfaces/extension_object_constructor.ts +1 -1
- package/source/interfaces/state_machine/ua_program_state_machine_type.ts +0 -1
- package/source/interfaces/state_machine/ua_state_machine_type.ts +0 -1
- package/source/loader/decode_xml_extension_object.ts +3 -3
- package/source/loader/ensure_datatype_extracted.ts +6 -2
- package/source/loader/generateAddressSpaceRaw.ts +5 -4
- package/source/loader/load_nodeset2.ts +12 -8
- package/source/loader/make_xml_extension_object_parser.ts +78 -45
- package/source/loader/namespace_post_step.ts +1 -1
- package/source/loader/parsers/extension_object_parser.ts +36 -27
- package/source/loader/parsers/localized_text_parser.ts +1 -1
- package/source/loader/parsers/nodeid_parser.ts +10 -2
- package/source/loader/parsers/qualified_name_parser.ts +1 -1
- package/source/loader/parsers/variant_parser.ts +53 -40
- package/source/pseudo_session.ts +81 -28
- package/source/session_context.ts +1 -0
- package/source/xml_writer.ts +1 -1
- package/src/_instantiate_helpers.ts +0 -3
- package/src/_mandatory_child_or_requested_optional_filter.ts +3 -4
- package/src/address_space.ts +58 -42
- package/src/address_space_private.ts +2 -0
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +6 -10
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +5 -7
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +20 -13
- package/src/alarms_and_conditions/ua_base_event_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_condition_impl.ts +12 -10
- package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +8 -5
- package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +0 -1
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +0 -1
- package/src/apply_condition_refresh.ts +1 -1
- package/src/base_node_impl.ts +30 -35
- package/src/base_node_private.ts +0 -6
- package/src/extension_object_array_node.ts +44 -15
- package/src/get_basic_datatype.ts +4 -1
- package/src/historical_access/address_space_historical_data_node.ts +2 -5
- package/src/namespace_impl.ts +24 -17
- package/src/nodeid_manager.ts +8 -11
- package/src/nodeset_tools/construct_namespace_dependency.ts +18 -15
- package/src/nodeset_tools/dump_to_bsd.ts +6 -8
- package/src/nodeset_tools/nodeset_to_xml.ts +105 -75
- package/src/private_namespace.ts +7 -2
- package/src/reference_impl.ts +11 -10
- package/src/state_machine/finite_state_machine.ts +12 -10
- package/src/state_machine/ua_shelving_state_machine_ex.ts +4 -4
- package/src/state_machine/ua_two_state_variable.ts +12 -9
- package/src/tool_isSubtypeOf.ts +2 -9
- package/src/ua_data_type_impl.ts +4 -4
- package/src/ua_method_impl.ts +24 -14
- package/src/ua_object_type_impl.ts +12 -6
- package/src/ua_reference_type_impl.ts +2 -3
- package/src/ua_variable_impl.ts +142 -96
- package/src/ua_variable_impl_ext_obj.ts +110 -82
- package/src/ua_variable_type_impl.ts +17 -5
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
1
|
/**
|
|
3
2
|
* @module node-opcua-address-space
|
|
4
3
|
*/
|
|
@@ -56,7 +55,6 @@ import {
|
|
|
56
55
|
constructNamespacePriorityTable
|
|
57
56
|
} from "./construct_namespace_dependency";
|
|
58
57
|
|
|
59
|
-
// tslint:disable:no-var-requires
|
|
60
58
|
const XMLWriter = require("xml-writer");
|
|
61
59
|
|
|
62
60
|
const debugLog = make_debugLog(__filename);
|
|
@@ -70,7 +68,9 @@ function _hash(node: BaseNode | UAReference): string {
|
|
|
70
68
|
|
|
71
69
|
function _dumpDisplayName(xw: XmlWriter, node: BaseNode): void {
|
|
72
70
|
if (node.displayName?.[0]) {
|
|
73
|
-
xw.startElement("DisplayName")
|
|
71
|
+
xw.startElement("DisplayName")
|
|
72
|
+
.text(node.displayName[0].text || "")
|
|
73
|
+
.endElement();
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
function _dumpDescription(xw: XmlWriter, node: { description?: LocalizedText }): void {
|
|
@@ -116,22 +116,36 @@ function _hasHigherPriorityThan(xw: XmlWriter, namespaceIndex1: number, namespac
|
|
|
116
116
|
return hasHigherPriorityThan(namespaceIndex1, namespaceIndex2, xw.priorityTable);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
function _mustFindReferenceType(addressSpace: IAddressSpace, name: string): UAReferenceType {
|
|
120
|
+
const referenceType = addressSpace.findReferenceType(name);
|
|
121
|
+
// c8 ignore next
|
|
122
|
+
if (!referenceType) {
|
|
123
|
+
throw new Error(`Cannot find standard reference type ${name}: please check your nodeset file`);
|
|
124
|
+
}
|
|
125
|
+
return referenceType;
|
|
126
|
+
}
|
|
127
|
+
|
|
119
128
|
function _dumpReferences(xw: XmlWriter, node: BaseNode) {
|
|
120
129
|
xw.startElement("References");
|
|
121
130
|
|
|
122
131
|
const addressSpace = node.addressSpace;
|
|
123
132
|
|
|
124
|
-
const aggregateReferenceType = addressSpace
|
|
125
|
-
// const hasChildReferenceType = addressSpace
|
|
126
|
-
const hasSubtypeReferenceType = addressSpace
|
|
127
|
-
const hasTypeDefinitionReferenceType = addressSpace
|
|
128
|
-
const nonHierarchicalReferencesType = addressSpace
|
|
129
|
-
const organizesReferencesType = addressSpace
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
const aggregateReferenceType = _mustFindReferenceType(addressSpace, "Aggregates");
|
|
134
|
+
// const hasChildReferenceType = _mustFindReferenceType(addressSpace, "HasChild");
|
|
135
|
+
const hasSubtypeReferenceType = _mustFindReferenceType(addressSpace, "HasSubtype");
|
|
136
|
+
const hasTypeDefinitionReferenceType = _mustFindReferenceType(addressSpace, "HasTypeDefinition");
|
|
137
|
+
const nonHierarchicalReferencesType = _mustFindReferenceType(addressSpace, "NonHierarchicalReferences");
|
|
138
|
+
const organizesReferencesType = _mustFindReferenceType(addressSpace, "Organizes");
|
|
139
|
+
// ConnectsTo is genuinely optional: not every nodeset registers it, and the check
|
|
140
|
+
// below already tolerates it being absent.
|
|
141
|
+
const connectsToReferenceType = addressSpace.findReferenceType("ConnectsTo");
|
|
142
|
+
const hasEventSourceReferenceType = _mustFindReferenceType(addressSpace, "HasEventSource");
|
|
132
143
|
|
|
133
144
|
function referenceToKeep(reference: UAReference): boolean {
|
|
134
|
-
const referenceType = (reference as ReferenceImpl)._referenceType
|
|
145
|
+
const referenceType = (reference as ReferenceImpl)._referenceType;
|
|
146
|
+
if (!referenceType) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
135
149
|
const targetedNamespaceIndex = reference.nodeId.namespace;
|
|
136
150
|
|
|
137
151
|
// get the direct backward reference to a external namespace
|
|
@@ -275,7 +289,10 @@ function getPrefix(xw: XmlWriter, namespace: XmlNamespaceUri): XmlNs {
|
|
|
275
289
|
function restoreDefaultNamespace(xw: XmlWriter) {
|
|
276
290
|
const xwe = xw as XmlWriterEx;
|
|
277
291
|
if (!xwe.map) return;
|
|
278
|
-
|
|
292
|
+
const previousMap = xwe.stackMap.pop();
|
|
293
|
+
if (previousMap) {
|
|
294
|
+
xwe.map = previousMap;
|
|
295
|
+
}
|
|
279
296
|
}
|
|
280
297
|
|
|
281
298
|
function setDefaultNamespace(xw: XmlWriter, namespace: XmlNamespaceUri): void {
|
|
@@ -304,7 +321,7 @@ function _dumpNodeId(xw: XmlWriter, v: NodeId) {
|
|
|
304
321
|
xw.endElement();
|
|
305
322
|
}
|
|
306
323
|
|
|
307
|
-
function _dumpVariantValue(xw: XmlWriter, dataTypeNodeId: NodeId, dataType: DataType, addressSpace: IAddressSpace, value:
|
|
324
|
+
function _dumpVariantValue(xw: XmlWriter, dataTypeNodeId: NodeId, dataType: DataType, addressSpace: IAddressSpace, value: unknown) {
|
|
308
325
|
if (value === undefined || value === null) {
|
|
309
326
|
return;
|
|
310
327
|
}
|
|
@@ -334,7 +351,7 @@ function _dumpVariantInnerExtensionObject(
|
|
|
334
351
|
for (const field of definition.fields || []) {
|
|
335
352
|
const dataTypeNodeId = field.dataType;
|
|
336
353
|
|
|
337
|
-
const fieldName = field.name
|
|
354
|
+
const fieldName = field.name || "";
|
|
338
355
|
const lowerFieldName = lowerFirstLetter(fieldName);
|
|
339
356
|
const v = (value as unknown as Record<string, unknown>)[lowerFieldName];
|
|
340
357
|
if (v !== null && v !== undefined) {
|
|
@@ -352,17 +369,20 @@ function _dumpVariantInnerExtensionObject(
|
|
|
352
369
|
startElementEx(xw, ns, fieldName, namespaceUri);
|
|
353
370
|
// xw.startElement(fieldName);
|
|
354
371
|
|
|
355
|
-
let fun: (value:
|
|
372
|
+
let fun: (value: unknown) => void = (_value: unknown) => {
|
|
356
373
|
/** */
|
|
357
374
|
};
|
|
358
375
|
if (definition instanceof StructureDefinition) {
|
|
359
|
-
fun = _dumpVariantInnerExtensionObject.bind(null, xw, definitionMap, definition, addressSpace)
|
|
376
|
+
fun = _dumpVariantInnerExtensionObject.bind(null, xw, definitionMap, definition, addressSpace) as (
|
|
377
|
+
value: unknown
|
|
378
|
+
) => void;
|
|
360
379
|
} else if (definition instanceof EnumDefinition) {
|
|
361
380
|
fun = _dumpVariantInnerValueEnum.bind(null, xw, definition);
|
|
362
381
|
} else if (definition?.dataType === DataType.Variant) {
|
|
363
|
-
fun = (value:
|
|
382
|
+
fun = (value: unknown) => {
|
|
383
|
+
const variantValue = value as Variant;
|
|
364
384
|
xw.startElement("Value");
|
|
365
|
-
_dumpVariantValue(xw, field.dataType,
|
|
385
|
+
_dumpVariantValue(xw, field.dataType, variantValue.dataType, addressSpace, variantValue.value);
|
|
366
386
|
xw.endElement();
|
|
367
387
|
};
|
|
368
388
|
} else {
|
|
@@ -374,19 +394,21 @@ function _dumpVariantInnerExtensionObject(
|
|
|
374
394
|
fun(v);
|
|
375
395
|
} else {
|
|
376
396
|
// array
|
|
377
|
-
for (const arrayItem of v as
|
|
397
|
+
for (const arrayItem of v as unknown[]) {
|
|
378
398
|
xw.startElement(name);
|
|
379
399
|
fun(arrayItem);
|
|
380
400
|
xw.endElement();
|
|
381
401
|
}
|
|
382
402
|
}
|
|
383
403
|
} catch (err) {
|
|
384
|
-
// eslint-disable-next-line max-depth
|
|
385
404
|
if (types.isNativeError(err)) {
|
|
386
405
|
errorLog("Error in _dumpVariantExtensionObjectValue_Body !!!", err.message);
|
|
387
406
|
}
|
|
388
|
-
|
|
389
|
-
|
|
407
|
+
// c8 ignore next
|
|
408
|
+
if (doDebug) {
|
|
409
|
+
debugLog(name);
|
|
410
|
+
debugLog(field);
|
|
411
|
+
}
|
|
390
412
|
// throw err;
|
|
391
413
|
}
|
|
392
414
|
restoreDefaultNamespace(xw);
|
|
@@ -402,7 +424,7 @@ function _dumpVariantInnerExtensionObject(
|
|
|
402
424
|
}
|
|
403
425
|
}
|
|
404
426
|
|
|
405
|
-
function _dumpVariantInnerValueEnum(xw: XmlWriter, definition: EnumDefinition, value:
|
|
427
|
+
function _dumpVariantInnerValueEnum(xw: XmlWriter, definition: EnumDefinition, value: unknown): void {
|
|
406
428
|
if (!definition.fields) {
|
|
407
429
|
return;
|
|
408
430
|
}
|
|
@@ -410,14 +432,13 @@ function _dumpVariantInnerValueEnum(xw: XmlWriter, definition: EnumDefinition, v
|
|
|
410
432
|
xw.text(`${field?.name}_${field?.value[1]}`);
|
|
411
433
|
}
|
|
412
434
|
|
|
413
|
-
// eslint-disable-next-line complexity
|
|
414
435
|
function _dumpVariantInnerValue(
|
|
415
436
|
xw: XmlWriter,
|
|
416
437
|
dataType: DataType,
|
|
417
438
|
dataTypeNodeId: NodeId,
|
|
418
439
|
definitionMap: DefinitionMap2,
|
|
419
440
|
addressSpace: IAddressSpace,
|
|
420
|
-
value:
|
|
441
|
+
value: unknown
|
|
421
442
|
): void {
|
|
422
443
|
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
423
444
|
switch (dataType) {
|
|
@@ -434,11 +455,11 @@ function _dumpVariantInnerValue(
|
|
|
434
455
|
_dumpNodeId(xw, value as NodeId);
|
|
435
456
|
break;
|
|
436
457
|
case DataType.DateTime:
|
|
437
|
-
xw.text(value.toISOString());
|
|
458
|
+
xw.text((value as Date).toISOString());
|
|
438
459
|
break;
|
|
439
460
|
case DataType.Int64:
|
|
440
461
|
case DataType.UInt64:
|
|
441
|
-
xw.text(value[1].toString());
|
|
462
|
+
xw.text((value as [number, number])[1].toString());
|
|
442
463
|
break;
|
|
443
464
|
case DataType.Boolean:
|
|
444
465
|
case DataType.SByte:
|
|
@@ -450,12 +471,13 @@ function _dumpVariantInnerValue(
|
|
|
450
471
|
case DataType.UInt16:
|
|
451
472
|
case DataType.UInt32:
|
|
452
473
|
case DataType.String:
|
|
453
|
-
xw.text(value.toString());
|
|
474
|
+
xw.text((value as { toString(): string }).toString());
|
|
454
475
|
break;
|
|
455
476
|
case DataType.ByteString:
|
|
456
477
|
{
|
|
457
|
-
const base64 = value.toString("base64");
|
|
458
|
-
|
|
478
|
+
const base64 = (value as Buffer).toString("base64");
|
|
479
|
+
const chunks = base64.match(/.{0,80}/g);
|
|
480
|
+
xw.text(base64.length > 80 && chunks ? chunks.join("\n") : base64);
|
|
459
481
|
}
|
|
460
482
|
break;
|
|
461
483
|
case DataType.Guid:
|
|
@@ -467,7 +489,7 @@ function _dumpVariantInnerValue(
|
|
|
467
489
|
if (value !== undefined && value !== null) {
|
|
468
490
|
// xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
469
491
|
xw.startElement(`${uax}String`);
|
|
470
|
-
xw.text(value.toString());
|
|
492
|
+
xw.text((value as { toString(): string }).toString());
|
|
471
493
|
xw.endElement();
|
|
472
494
|
}
|
|
473
495
|
break;
|
|
@@ -481,9 +503,11 @@ function _dumpVariantInnerValue(
|
|
|
481
503
|
case DataType.StatusCode:
|
|
482
504
|
xw.text((value as StatusCode).value.toString());
|
|
483
505
|
break;
|
|
484
|
-
case DataType.Variant:
|
|
485
|
-
|
|
506
|
+
case DataType.Variant: {
|
|
507
|
+
const variantValue = value as Variant;
|
|
508
|
+
_dumpVariantInnerValue(xw, variantValue.dataType, dataTypeNodeId, definitionMap, addressSpace, variantValue.value);
|
|
486
509
|
break;
|
|
510
|
+
}
|
|
487
511
|
default:
|
|
488
512
|
errorLog(`_dumpVariantInnerValue incomplete ${value} DataType=${dataType}=${DataType[dataType]}`);
|
|
489
513
|
// throw new Error("_dumpVariantInnerValue incomplete " + value + " " + "DataType=" + dataType + "=" + DataType[dataType]);
|
|
@@ -503,7 +527,7 @@ function _dumpVariantExtensionObjectValue_Body(
|
|
|
503
527
|
name: string,
|
|
504
528
|
definition: StructureDefinition,
|
|
505
529
|
addressSpace: IAddressSpace,
|
|
506
|
-
value:
|
|
530
|
+
value: ExtensionObject
|
|
507
531
|
) {
|
|
508
532
|
if (value) {
|
|
509
533
|
const namespaceUri = findXsdNamespaceUri(xw, definition.defaultEncodingId);
|
|
@@ -557,7 +581,7 @@ function _dumpVariantExtensionObjectValue(
|
|
|
557
581
|
function _dumpVariantExtensionObjectValue2(xw: XmlWriter, addressSpace: IAddressSpace, value: ExtensionObject) {
|
|
558
582
|
const dataTypeNodeId = value.schema.dataTypeNodeId;
|
|
559
583
|
const definitionMap = makeDefinitionMap(addressSpace);
|
|
560
|
-
const dataTypeNode = addressSpace.findDataType(dataTypeNodeId)
|
|
584
|
+
const dataTypeNode = addressSpace.findDataType(dataTypeNodeId);
|
|
561
585
|
if (!dataTypeNode) {
|
|
562
586
|
warningLog("_dumpVariantExtensionObjectValue2: Cannot find dataType for ", dataTypeNodeId.toString());
|
|
563
587
|
return;
|
|
@@ -565,7 +589,6 @@ function _dumpVariantExtensionObjectValue2(xw: XmlWriter, addressSpace: IAddress
|
|
|
565
589
|
_dumpVariantExtensionObjectValue(xw, dataTypeNode.nodeId, definitionMap, addressSpace, value);
|
|
566
590
|
}
|
|
567
591
|
|
|
568
|
-
// eslint-disable-next-line complexity
|
|
569
592
|
function _isDefaultValue(value: Variant): boolean {
|
|
570
593
|
// detect default value
|
|
571
594
|
if (value.arrayType === VariantArrayType.Scalar) {
|
|
@@ -631,7 +654,6 @@ function _isDefaultValue(value: Variant): boolean {
|
|
|
631
654
|
}
|
|
632
655
|
}
|
|
633
656
|
|
|
634
|
-
// eslint-disable-next-line max-statements
|
|
635
657
|
function _dumpValue(xw: XmlWriter, node: UAVariable | UAVariableType, variant: Variant) {
|
|
636
658
|
const addressSpace = node.addressSpace;
|
|
637
659
|
|
|
@@ -645,7 +667,8 @@ function _dumpValue(xw: XmlWriter, node: UAVariable | UAVariableType, variant: V
|
|
|
645
667
|
|
|
646
668
|
// c8 ignore next
|
|
647
669
|
if (!dataTypeNode) {
|
|
648
|
-
|
|
670
|
+
// c8 ignore next
|
|
671
|
+
doDebug && debugLog("Cannot find dataType:", node.dataType.toString());
|
|
649
672
|
return;
|
|
650
673
|
}
|
|
651
674
|
|
|
@@ -732,7 +755,7 @@ function _visitUANode(node: BaseNode, data: DumpData, forward: boolean) {
|
|
|
732
755
|
if (!data.index_el[k]) {
|
|
733
756
|
data.index_el[k] = 1;
|
|
734
757
|
|
|
735
|
-
const o = addressSpace.findNode(k)
|
|
758
|
+
const o = addressSpace.findNode(k) as BaseNode | null;
|
|
736
759
|
if (o) {
|
|
737
760
|
_visitUANode(o, data, forward);
|
|
738
761
|
}
|
|
@@ -754,7 +777,7 @@ function dumpReferencedNodes(xw: XmlWriter, node: BaseNode, forward: boolean) {
|
|
|
754
777
|
const r = node.findReferencesEx("HasTypeDefinition");
|
|
755
778
|
if (r?.length) {
|
|
756
779
|
assert(r.length === 1);
|
|
757
|
-
const typeDefinitionObj = ReferenceImpl.resolveReferenceNode(addressSpace, r[0])
|
|
780
|
+
const typeDefinitionObj = ReferenceImpl.resolveReferenceNode(addressSpace, r[0]) as BaseNode | null;
|
|
758
781
|
if (!typeDefinitionObj) {
|
|
759
782
|
warningLog(node.toString());
|
|
760
783
|
warningLog(
|
|
@@ -777,9 +800,9 @@ function dumpReferencedNodes(xw: XmlWriter, node: BaseNode, forward: boolean) {
|
|
|
777
800
|
{
|
|
778
801
|
const r = node.findReferencesEx("HasSubtype", BrowseDirection.Inverse);
|
|
779
802
|
if (r?.length) {
|
|
780
|
-
const subTypeOf = ReferenceImpl.resolveReferenceNode(addressSpace, r[0])
|
|
803
|
+
const subTypeOf = ReferenceImpl.resolveReferenceNode(addressSpace, r[0]) as BaseNode | null;
|
|
781
804
|
assert(r.length === 1);
|
|
782
|
-
if (subTypeOf.nodeId.namespace === node.nodeId.namespace) {
|
|
805
|
+
if (subTypeOf && subTypeOf.nodeId.namespace === node.nodeId.namespace) {
|
|
783
806
|
// only output node if it is on the same namespace
|
|
784
807
|
if (!xw.visitedNode.has(_hash(subTypeOf))) {
|
|
785
808
|
dumpNodeInXml(xw, subTypeOf);
|
|
@@ -794,12 +817,14 @@ function dumpReferencedNodes(xw: XmlWriter, node: BaseNode, forward: boolean) {
|
|
|
794
817
|
assert(nodeChild instanceof BaseNodeImpl);
|
|
795
818
|
if (nodeChild.nodeId.namespace === node.nodeId.namespace) {
|
|
796
819
|
if (!xw.visitedNode.has(_hash(nodeChild))) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
820
|
+
// c8 ignore next
|
|
821
|
+
doDebug &&
|
|
822
|
+
debugLog(
|
|
823
|
+
node.nodeId.toString(),
|
|
824
|
+
" dumping child ",
|
|
825
|
+
nodeChild.browseName.toString(),
|
|
826
|
+
nodeChild.nodeId.toString()
|
|
827
|
+
);
|
|
803
828
|
dumpNodeInXml(xw, nodeChild);
|
|
804
829
|
}
|
|
805
830
|
}
|
|
@@ -826,11 +851,12 @@ function dumpCommonAttributes(xw: XmlWriter, node: BaseNode) {
|
|
|
826
851
|
}
|
|
827
852
|
}
|
|
828
853
|
if (Object.hasOwn(node, "symbolicName")) {
|
|
829
|
-
xw.writeAttribute("SymbolicName", (node as
|
|
854
|
+
xw.writeAttribute("SymbolicName", (node as unknown as { symbolicName: string }).symbolicName);
|
|
830
855
|
}
|
|
831
856
|
if (Object.hasOwn(node, "isAbstract")) {
|
|
832
|
-
|
|
833
|
-
|
|
857
|
+
const isAbstract = (node as unknown as { isAbstract: boolean }).isAbstract;
|
|
858
|
+
if (isAbstract) {
|
|
859
|
+
xw.writeAttribute("IsAbstract", isAbstract ? "true" : "false");
|
|
834
860
|
}
|
|
835
861
|
}
|
|
836
862
|
// AccessLevel and UserAccessLevel exist in the XSD on UAVariable only. Gate on the node
|
|
@@ -913,7 +939,7 @@ function coerceInt64ToInt32(int64: Int64): number {
|
|
|
913
939
|
function _dumpEnumDefinition(xw: XmlWriter, enumDefinition: EnumDefinition) {
|
|
914
940
|
enumDefinition.fields = enumDefinition.fields || [];
|
|
915
941
|
|
|
916
|
-
for (const defItem of enumDefinition.fields
|
|
942
|
+
for (const defItem of enumDefinition.fields) {
|
|
917
943
|
xw.startElement("Field");
|
|
918
944
|
xw.writeAttribute("Name", defItem.name as string);
|
|
919
945
|
if (!isNullOrUndefined(defItem.value)) {
|
|
@@ -1127,14 +1153,16 @@ function dumpUAVariableType(xw: XmlWriter, node: UAVariableType) {
|
|
|
1127
1153
|
const dataTypeNode = addressSpace.findNode(node.dataType);
|
|
1128
1154
|
if (!dataTypeNode) {
|
|
1129
1155
|
// throw new Error(" cannot find datatype " + node.dataType);
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
"
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1156
|
+
// c8 ignore next
|
|
1157
|
+
doDebug &&
|
|
1158
|
+
debugLog(
|
|
1159
|
+
" cannot find datatype " +
|
|
1160
|
+
node.dataType +
|
|
1161
|
+
" for node " +
|
|
1162
|
+
node.browseName.toString() +
|
|
1163
|
+
" id =" +
|
|
1164
|
+
node.nodeId.toString()
|
|
1165
|
+
);
|
|
1138
1166
|
} else {
|
|
1139
1167
|
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, dataTypeNode.nodeId));
|
|
1140
1168
|
xw.writeAttribute("DataType", dataTypeName);
|
|
@@ -1393,7 +1421,7 @@ interface DumpData extends BuildAliasesData {
|
|
|
1393
1421
|
index_el: Record<string, number>;
|
|
1394
1422
|
}
|
|
1395
1423
|
|
|
1396
|
-
export type DumpXMLOptions =
|
|
1424
|
+
export type DumpXMLOptions = Record<string, never>;
|
|
1397
1425
|
|
|
1398
1426
|
UAMethodImpl.prototype.dumpXML = function (xw) {
|
|
1399
1427
|
dumpUAMethod(xw, this);
|
|
@@ -1426,7 +1454,6 @@ function makeTypeXsd(namespaceUri: string): string {
|
|
|
1426
1454
|
return `${namespaceUri.replace(/\/$/, "")}/Type.xsd`;
|
|
1427
1455
|
}
|
|
1428
1456
|
|
|
1429
|
-
// eslint-disable-next-line max-statements
|
|
1430
1457
|
NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
1431
1458
|
const namespaceArrayNode = this.addressSpace.findNode(VariableIds.Server_NamespaceArray);
|
|
1432
1459
|
const namespaceArray: string[] = namespaceArrayNode
|
|
@@ -1474,7 +1501,7 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1474
1501
|
|
|
1475
1502
|
// let's sort the dependencies in the same order as the translation table
|
|
1476
1503
|
const sortedDependencies = dependency.sort((a, b) =>
|
|
1477
|
-
translationTable.get(a.index)
|
|
1504
|
+
(translationTable.get(a.index) ?? 0) > (translationTable.get(b.index) ?? 0) ? 1 : -1
|
|
1478
1505
|
);
|
|
1479
1506
|
|
|
1480
1507
|
doDebug && debugLog(sortedDependencies.map((a) => `${a.index} + ${a.namespaceUri}`).join("\n"));
|
|
@@ -1562,12 +1589,14 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1562
1589
|
const result = getDataTypeDescription(opcBinaryTypeSystem);
|
|
1563
1590
|
if (result.length === 1) {
|
|
1564
1591
|
xw.writeComment("DataSystem - Binary");
|
|
1565
|
-
const dataSystemType = addressSpace.findNode(result[0].nodeId)
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1592
|
+
const dataSystemType = addressSpace.findNode(result[0].nodeId) as UAVariable | null;
|
|
1593
|
+
if (dataSystemType) {
|
|
1594
|
+
const types = dataSystemType.getComponents();
|
|
1595
|
+
for (const f of types) {
|
|
1596
|
+
dumpNodeInXml(xw, f);
|
|
1597
|
+
}
|
|
1598
|
+
dumpNodeInXml(xw, dataSystemType);
|
|
1569
1599
|
}
|
|
1570
|
-
dumpNodeInXml(xw, dataSystemType);
|
|
1571
1600
|
}
|
|
1572
1601
|
}
|
|
1573
1602
|
|
|
@@ -1575,14 +1604,15 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1575
1604
|
const result = getDataTypeDescription(opcXmlSchemaTypeSystem);
|
|
1576
1605
|
if (result.length === 1) {
|
|
1577
1606
|
xw.writeComment("DataSystem - Xml");
|
|
1578
|
-
const dataSystemType = addressSpace.findNode(result[0].nodeId)
|
|
1607
|
+
const dataSystemType = addressSpace.findNode(result[0].nodeId) as UAVariable | null;
|
|
1608
|
+
if (dataSystemType) {
|
|
1609
|
+
const types = dataSystemType.getComponents();
|
|
1610
|
+
for (const f of types) {
|
|
1611
|
+
dumpNodeInXml(xw, f);
|
|
1612
|
+
}
|
|
1579
1613
|
|
|
1580
|
-
|
|
1581
|
-
for (const f of types) {
|
|
1582
|
-
dumpNodeInXml(xw, f);
|
|
1614
|
+
dumpNodeInXml(xw, dataSystemType);
|
|
1583
1615
|
}
|
|
1584
|
-
|
|
1585
|
-
dumpNodeInXml(xw, dataSystemType);
|
|
1586
1616
|
}
|
|
1587
1617
|
}
|
|
1588
1618
|
}
|
package/src/private_namespace.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { Namespace } from "../source/namespace";
|
|
2
2
|
import type { NodeEntry1, NodeIdManager } from "./nodeid_manager";
|
|
3
3
|
|
|
4
|
+
interface NamespaceWithNodeIdManager extends Namespace {
|
|
5
|
+
_nodeIdManager: NodeIdManager;
|
|
6
|
+
registerSymbolicNames: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
export function getNodeIdManager(ns: Namespace): NodeIdManager {
|
|
5
|
-
const nodeIdManager = (ns as
|
|
10
|
+
const nodeIdManager = (ns as NamespaceWithNodeIdManager)._nodeIdManager;
|
|
6
11
|
return nodeIdManager;
|
|
7
12
|
}
|
|
8
13
|
export function setSymbols(ns: Namespace, symbols: NodeEntry1[]) {
|
|
9
14
|
const nodeIdManager = getNodeIdManager(ns);
|
|
10
|
-
(ns as
|
|
15
|
+
(ns as NamespaceWithNodeIdManager).registerSymbolicNames = true;
|
|
11
16
|
nodeIdManager.setSymbols(symbols);
|
|
12
17
|
}
|
|
13
18
|
export function getSymbols(ns: Namespace): NodeEntry1[] {
|
package/src/reference_impl.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-address-space
|
|
3
3
|
*/
|
|
4
|
-
// tslint:disable:no-console
|
|
5
4
|
import chalk from "chalk";
|
|
6
|
-
import type { AddReferenceOpts, BaseNode, UAReference, UAReferenceType } from "node-opcua-address-space-base";
|
|
5
|
+
import type { AddReferenceOpts, BaseNode, IAddressSpace, UAReference, UAReferenceType } from "node-opcua-address-space-base";
|
|
7
6
|
import { assert } from "node-opcua-assert";
|
|
8
7
|
import { coerceNodeId, NodeId, type NodeIdLike, sameNodeId } from "node-opcua-nodeid";
|
|
9
8
|
import { isNullOrUndefined } from "node-opcua-utils";
|
|
@@ -52,7 +51,7 @@ function _w(str: string, width: number): string {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
function _localCoerceToNodeID(nodeIdLike: string | NodeIdLike | { nodeId: NodeId }): NodeId {
|
|
55
|
-
if (typeof nodeIdLike === "object" &&
|
|
54
|
+
if (typeof nodeIdLike === "object" && Object.hasOwn(nodeIdLike, "nodeId")) {
|
|
56
55
|
return (nodeIdLike as { nodeId: NodeId }).nodeId;
|
|
57
56
|
}
|
|
58
57
|
return coerceNodeId(nodeIdLike);
|
|
@@ -67,7 +66,7 @@ export interface MinimalistAddressSpace {
|
|
|
67
66
|
export function resolveReferenceNode(addressSpace: MinimalistAddressSpace, reference: UAReference): BaseNode {
|
|
68
67
|
const _reference = reference as ReferenceImpl;
|
|
69
68
|
if (!_reference.node) {
|
|
70
|
-
_reference.node = addressSpace.findNode(reference.nodeId)
|
|
69
|
+
_reference.node = addressSpace.findNode(reference.nodeId) as BaseNode;
|
|
71
70
|
}
|
|
72
71
|
return _reference.node;
|
|
73
72
|
}
|
|
@@ -78,7 +77,7 @@ export function resolveReferenceType(addressSpace: MinimalistAddressSpace, refer
|
|
|
78
77
|
if (!_reference.referenceType) {
|
|
79
78
|
errorLog(chalk.red("ERROR MISSING reference"), reference);
|
|
80
79
|
}
|
|
81
|
-
_reference._referenceType = addressSpace.findReferenceType(reference.referenceType)
|
|
80
|
+
_reference._referenceType = addressSpace.findReferenceType(reference.referenceType) as UAReferenceType;
|
|
82
81
|
}
|
|
83
82
|
return _reference._referenceType;
|
|
84
83
|
}
|
|
@@ -117,7 +116,7 @@ export class ReferenceImpl implements UAReference {
|
|
|
117
116
|
this.isForward = options.isForward === undefined ? true : !!options.isForward;
|
|
118
117
|
this.nodeId = _localCoerceToNodeID(options.nodeId);
|
|
119
118
|
// optional to speed up when AddReferenceOpts is in fact a Reference !
|
|
120
|
-
this._referenceType = (options as
|
|
119
|
+
this._referenceType = (options as Partial<ReferenceImpl>)._referenceType;
|
|
121
120
|
this.node = options.node;
|
|
122
121
|
assert(is_valid_reference(this));
|
|
123
122
|
}
|
|
@@ -127,17 +126,19 @@ export class ReferenceImpl implements UAReference {
|
|
|
127
126
|
|
|
128
127
|
* @return {String}
|
|
129
128
|
*/
|
|
130
|
-
public toString(options?: { addressSpace?:
|
|
129
|
+
public toString(options?: { addressSpace?: IAddressSpace }): string {
|
|
131
130
|
let infoNode = _w(this.nodeId.toString(), 24);
|
|
132
131
|
let refType = this.referenceType.toString();
|
|
133
132
|
|
|
134
133
|
if (options?.addressSpace) {
|
|
135
134
|
const node = options.addressSpace.findNode(this.nodeId);
|
|
136
|
-
infoNode = `[${infoNode}]${_w(node?.browseName.toString(), 40)}`;
|
|
135
|
+
infoNode = `[${infoNode}]${_w(node?.browseName.toString() || "", 40)}`;
|
|
137
136
|
|
|
138
137
|
const ref = options.addressSpace.findReferenceType(this.referenceType);
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
if (ref) {
|
|
139
|
+
const refNode = options.addressSpace.findNode(ref.nodeId);
|
|
140
|
+
refType = `${refNode?.browseName.toString() || "<unknown>"} (${ref.nodeId.toString()})`;
|
|
141
|
+
}
|
|
141
142
|
}
|
|
142
143
|
return _arrow(refType, 40, this.isForward) + infoNode;
|
|
143
144
|
}
|
|
@@ -32,14 +32,13 @@ import { UAObjectTypeImpl } from "../ua_object_type_impl";
|
|
|
32
32
|
const warningLog = make_warningLog(__filename);
|
|
33
33
|
|
|
34
34
|
const doDebug = false;
|
|
35
|
-
const debugLog = make_debugLog(__filename);
|
|
35
|
+
const debugLog = make_debugLog(__filename);
|
|
36
36
|
|
|
37
37
|
export class UATransitionImplBase extends BaseNodeImpl {
|
|
38
38
|
/* intentionnaly empty */
|
|
39
39
|
}
|
|
40
40
|
export type UATransitionImpl = UATransitionImplBase & UATransitionEx;
|
|
41
|
-
export const
|
|
42
|
-
|
|
41
|
+
export const UATransitionImpl = UATransitionImplBase as unknown as new () => UATransitionImpl;
|
|
43
42
|
|
|
44
43
|
function getComponentOfType(typeDef: UAObjectType, typedefinition: UAObjectType): UAObject[] {
|
|
45
44
|
const get = (typeDef: UAObjectType) =>
|
|
@@ -62,8 +61,6 @@ function getComponentOfType(typeDef: UAObjectType, typedefinition: UAObjectType)
|
|
|
62
61
|
return components_parts as UAObject[];
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
64
|
const defaultPredicate = (transitions: UATransition[], fromState: UAState, toState: UAState) => {
|
|
68
65
|
if (transitions.length === 0) {
|
|
69
66
|
return null;
|
|
@@ -122,10 +119,10 @@ export function getFiniteStateMachineTypeStateByName(uaFiniteStateMachineType: U
|
|
|
122
119
|
return s.browseName.name === stateName;
|
|
123
120
|
});
|
|
124
121
|
assert(states.length <= 1);
|
|
125
|
-
return states.length === 1 ?
|
|
122
|
+
return states.length === 1 ? states[0] : null;
|
|
126
123
|
}
|
|
127
124
|
|
|
128
|
-
const $ = (uaObject: UAStateMachineImplBase) =>
|
|
125
|
+
const $ = (uaObject: UAStateMachineImplBase) => uaObject as unknown as UAStateMachineEx;
|
|
129
126
|
/*
|
|
130
127
|
*
|
|
131
128
|
* @class StateMachine
|
|
@@ -302,7 +299,10 @@ export class UAStateMachineImplBase extends UAObjectImpl {
|
|
|
302
299
|
public setState(toStateNode: string | UAState | null, predicate?: TransitionSelector): void {
|
|
303
300
|
if (!toStateNode) {
|
|
304
301
|
this.currentStateNode = null;
|
|
305
|
-
$(this).currentState.setValueFromSource(
|
|
302
|
+
$(this).currentState.setValueFromSource(
|
|
303
|
+
{ dataType: DataType.LocalizedText, value: null },
|
|
304
|
+
StatusCodes.BadStateNotActive
|
|
305
|
+
);
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
308
|
|
|
@@ -322,7 +322,7 @@ export class UAStateMachineImplBase extends UAObjectImpl {
|
|
|
322
322
|
$(this).currentState.setValueFromSource(
|
|
323
323
|
{
|
|
324
324
|
dataType: DataType.LocalizedText,
|
|
325
|
-
value: coerceLocalizedText(toStateNode.displayName[0] || toStateNode.browseName.name
|
|
325
|
+
value: coerceLocalizedText(toStateNode.displayName[0] || toStateNode.browseName.name || "")
|
|
326
326
|
},
|
|
327
327
|
StatusCodes.Good
|
|
328
328
|
);
|
|
@@ -563,7 +563,9 @@ export class UAStateMachineImplBase extends UAObjectImpl {
|
|
|
563
563
|
|
|
564
564
|
// also update executable flags on methods
|
|
565
565
|
for (const method of this.getMethods()) {
|
|
566
|
-
(method as
|
|
566
|
+
(method as unknown as { _notifyAttributeChange(attributeId: AttributeIds): void })._notifyAttributeChange(
|
|
567
|
+
AttributeIds.Executable
|
|
568
|
+
);
|
|
567
569
|
}
|
|
568
570
|
}
|
|
569
571
|
|
|
@@ -82,7 +82,7 @@ export class UAShelvedStateMachineExImplBase extends UAStateMachineImpl {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export type UAShelvedStateMachineExImpl = UAShelvedStateMachineExImplBase & UAShelvedStateMachineEx;
|
|
85
|
-
export const
|
|
85
|
+
export const UAShelvedStateMachineExImpl = UAShelvedStateMachineExImplBase as unknown as new () => UAShelvedStateMachineExImpl;
|
|
86
86
|
|
|
87
87
|
// The Unshelve Method sets the AlarmCondition to the Unshelved state. Normally, the MethodId found
|
|
88
88
|
// the Shelving child of the Condition instance and the NodeId of the Shelving object as the ObjectId
|
|
@@ -112,7 +112,7 @@ function _unshelve_method(inputArguments: VariantLike[], context: ISessionContex
|
|
|
112
112
|
}
|
|
113
113
|
shelvingState.setState("Unshelved");
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
shelvingState._unshelvedTime = new Date(); // now
|
|
116
116
|
|
|
117
117
|
_clear_timer_if_any(shelvingState);
|
|
118
118
|
assert(!shelvingState._timer);
|
|
@@ -196,7 +196,7 @@ function _timedShelve_method(
|
|
|
196
196
|
if (!context.object) {
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
|
-
const shelvingState = context.object
|
|
199
|
+
const shelvingState = context.object as UAShelvedStateMachineExImpl;
|
|
200
200
|
|
|
201
201
|
if (shelvingState.getCurrentState() !== "Unshelved") {
|
|
202
202
|
return callback(null, {
|
|
@@ -254,7 +254,7 @@ function _oneShotShelve_method(
|
|
|
254
254
|
callback: CallbackT<CallMethodResultOptions>
|
|
255
255
|
) {
|
|
256
256
|
assert(inputArguments.length === 0);
|
|
257
|
-
const shelvingState = context.object
|
|
257
|
+
const shelvingState = context.object as UAShelvedStateMachineExImpl;
|
|
258
258
|
if (shelvingState.getCurrentState() === "OneShotShelved") {
|
|
259
259
|
return callback(null, {
|
|
260
260
|
statusCode: StatusCodes.BadConditionAlreadyShelved
|