node-opcua-address-space 2.112.0 → 2.114.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/helpers/call_helpers.js +1 -2
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/helpers/resolve_opaque_on_address_space.js +15 -26
- package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -1
- package/dist/source/loader/decode_xml_extension_object.js +0 -2
- package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js +19 -30
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +16 -27
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +101 -98
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/make_xml_extension_object_parser.js +2 -4
- package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
- package/dist/source/loader/namespace_post_step.js +24 -37
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/session_context.js +3 -6
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/set_namespace_meta_data.js +2 -3
- package/dist/source/set_namespace_meta_data.js.map +1 -1
- package/dist/src/address_space.js +18 -37
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_change_event_tools.js +1 -1
- package/dist/src/address_space_change_event_tools.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +2 -5
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +7 -4
- 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 +6 -7
- 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 +2 -5
- 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 +3 -7
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/base_node_impl.js +9 -19
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.js +17 -11
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/data_access/ua_multistate_discrete_impl.js +7 -1
- package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -1
- package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +2 -2
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js +10 -5
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -1
- package/dist/src/extension_object_array_node.js +1 -2
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/get_basic_datatype.d.ts +8 -0
- package/dist/src/get_basic_datatype.js +26 -0
- package/dist/src/get_basic_datatype.js.map +1 -0
- package/dist/src/historical_access/address_space_historical_data_node.js +31 -48
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/namespace_impl.js +17 -13
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +58 -9
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.js +4 -6
- package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +36 -35
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/private_namespace.js +1 -1
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/reference_impl.js +5 -2
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.js +2 -3
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +2 -2
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +1 -3
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/ua_data_type_impl.js +6 -29
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.js +6 -4
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +5 -1
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.js +1 -2
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.js +18 -26
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.js +25 -17
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/src/ua_variable_type_impl.d.ts +2 -0
- package/dist/src/ua_variable_type_impl.js +7 -6
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/distHelpers/add_event_generator_object.js +0 -4
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distNodeJS/generate_address_space.js +10 -21
- package/distNodeJS/generate_address_space.js.map +1 -1
- package/package.json +39 -39
- package/source/loader/decode_xml_extension_object.ts +0 -2
- package/source/loader/load_nodeset2.ts +16 -12
- package/source/loader/make_xml_extension_object_parser.ts +1 -4
- package/source/loader/namespace_post_step.ts +1 -0
- package/src/address_space.ts +7 -15
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +2 -6
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +6 -3
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +6 -6
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +0 -1
- package/src/alarms_and_conditions/ua_condition_impl.ts +3 -7
- package/src/base_node_impl.ts +12 -20
- package/src/data_access/ua_multistate_value_discrete_impl.ts +9 -11
- package/src/get_basic_datatype.ts +32 -0
- package/src/namespace_impl.ts +5 -6
- package/src/nodeset_tools/construct_namespace_dependency.ts +60 -18
- package/src/nodeset_tools/nodeset_to_xml.ts +42 -39
- package/src/reference_impl.ts +5 -1
- package/src/state_machine/finite_state_machine.ts +3 -4
- package/src/state_machine/ua_shelving_state_machine_ex.ts +2 -3
- package/src/state_machine/ua_two_state_variable.ts +0 -1
- package/src/ua_data_type_impl.ts +6 -26
- package/src/ua_variable_impl.ts +5 -22
- package/src/ua_variable_impl_ext_obj.ts +119 -86
- package/src/ua_variable_type_impl.ts +5 -4
package/src/reference_impl.ts
CHANGED
|
@@ -78,7 +78,7 @@ export function resolveReferenceType(addressSpace: MinimalistAddressSpace, refer
|
|
|
78
78
|
const _reference = reference as ReferenceImpl;
|
|
79
79
|
if (!_reference._referenceType) {
|
|
80
80
|
if (!_reference.referenceType) {
|
|
81
|
-
|
|
81
|
+
errorLog(chalk.red("ERROR MISSING reference"), reference);
|
|
82
82
|
}
|
|
83
83
|
_reference._referenceType = addressSpace.findReferenceType(reference.referenceType)!;
|
|
84
84
|
}
|
|
@@ -169,3 +169,7 @@ export class ReferenceImpl implements UAReference {
|
|
|
169
169
|
*/
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
function errorLog(arg0: string, reference: UAReference) {
|
|
173
|
+
throw new Error("Function not implemented.");
|
|
174
|
+
}
|
|
175
|
+
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
QualifiedName
|
|
15
15
|
} from "node-opcua-data-model";
|
|
16
16
|
import { AttributeIds } from "node-opcua-data-model";
|
|
17
|
-
import { make_warningLog } from "node-opcua-debug";
|
|
17
|
+
import { make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
18
18
|
import { NodeId, sameNodeId } from "node-opcua-nodeid";
|
|
19
19
|
import { StatusCodes } from "node-opcua-status-code";
|
|
20
20
|
import { DataType, Variant, VariantArrayType } from "node-opcua-variant";
|
|
@@ -35,6 +35,7 @@ import { UAObjectTypeImpl } from "../ua_object_type_impl";
|
|
|
35
35
|
const warningLog = make_warningLog(__filename);
|
|
36
36
|
|
|
37
37
|
const doDebug = false;
|
|
38
|
+
const debugLog = make_debugLog(__filename);
|
|
38
39
|
|
|
39
40
|
export declare interface UATransitionImpl extends UATransition, UATransitionEx {}
|
|
40
41
|
export class UATransitionImpl implements UATransition, UATransitionEx {}
|
|
@@ -217,8 +218,7 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
|
|
|
217
218
|
if (!transition) {
|
|
218
219
|
// istanbul ignore next
|
|
219
220
|
if (doDebug) {
|
|
220
|
-
|
|
221
|
-
console.log(" No transition from ", this.currentStateNode.browseName.toString(), " to ", toStateNode.toString());
|
|
221
|
+
debugLog(" No transition from ", this.currentStateNode.browseName.toString(), " to ", toStateNode.toString());
|
|
222
222
|
}
|
|
223
223
|
return false;
|
|
224
224
|
}
|
|
@@ -522,7 +522,6 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
|
|
|
522
522
|
}
|
|
523
523
|
};
|
|
524
524
|
applyLastTransitionOptionalProps();
|
|
525
|
-
// xx console.log("transitionNode ",transitionNode.toString());
|
|
526
525
|
// The inherited Property SourceNode shall be filled with the NodeId of the StateMachine instance where the
|
|
527
526
|
// Transition occurs. If the Transition occurs in a SubStateMachine, then the NodeId of the SubStateMachine
|
|
528
527
|
// has to be used. If the Transition occurs between a StateMachine and a SubStateMachine, then the NodeId of
|
|
@@ -125,7 +125,6 @@ function _unshelve_method(inputArguments: VariantLike[], context: ISessionContex
|
|
|
125
125
|
export function _clear_timer_if_any(shelvingState: UAShelvedStateMachineExImpl): void {
|
|
126
126
|
if (shelvingState._timer) {
|
|
127
127
|
clearTimeout(shelvingState._timer);
|
|
128
|
-
// xx console.log("_clear_timer_if_any shelvingState = ",shelvingState._timer,shelvingState.constructor.name);
|
|
129
128
|
shelvingState._timer = null;
|
|
130
129
|
}
|
|
131
130
|
}
|
|
@@ -134,6 +133,7 @@ function _automatically_unshelve(shelvingState: UAShelvedStateMachineExImpl) {
|
|
|
134
133
|
assert(shelvingState._timer, "expecting timerId to be set");
|
|
135
134
|
shelvingState._timer = null;
|
|
136
135
|
|
|
136
|
+
// istanbul ignore next
|
|
137
137
|
if (doDebug) {
|
|
138
138
|
debugLog("Automatically unshelving variable ", shelvingState.browseName.toString());
|
|
139
139
|
}
|
|
@@ -157,6 +157,7 @@ function _start_timer_for_automatic_unshelve(shelvingState: UAShelvedStateMachin
|
|
|
157
157
|
shelvingState._sheveldTime = new Date(); // now
|
|
158
158
|
shelvingState._duration = duration;
|
|
159
159
|
|
|
160
|
+
// istanbul ignore next
|
|
160
161
|
if (doDebug) {
|
|
161
162
|
debugLog("shelvingState._duration", shelvingState._duration);
|
|
162
163
|
}
|
|
@@ -217,8 +218,6 @@ function _timedShelve_method(
|
|
|
217
218
|
assert(inputArguments[0].dataType === DataType.Double); // Duration
|
|
218
219
|
assert(inputArguments[0] instanceof Variant);
|
|
219
220
|
|
|
220
|
-
// xx console.log("inputArguments",inputArguments[0].toString());
|
|
221
|
-
|
|
222
221
|
const proposedDuration = inputArguments[0].value; // as double (milliseconds)
|
|
223
222
|
if (proposedDuration > maxTimeShelved) {
|
|
224
223
|
return callback(null, {
|
|
@@ -63,7 +63,6 @@ function _updateTransitionTime(node: UATwoStateVariableEx, _subState?: UAVariabl
|
|
|
63
63
|
|
|
64
64
|
function _updateEffectiveTransitionTime(node: UATwoStateVariableImpl) {
|
|
65
65
|
if (node.effectiveTransitionTime) {
|
|
66
|
-
// xx console.log("xxxx _updateEffectiveTransitionTime
|
|
67
66
|
// because subStateNode ",subStateNode.browseName.toString());
|
|
68
67
|
node.effectiveTransitionTime.setValueFromSource({
|
|
69
68
|
dataType: DataType.DateTime,
|
package/src/ua_data_type_impl.ts
CHANGED
|
@@ -30,6 +30,7 @@ import * as tools from "./tool_isSubtypeOf";
|
|
|
30
30
|
import { get_subtypeOf } from "./tool_isSubtypeOf";
|
|
31
31
|
import { get_subtypeOfObj } from "./tool_isSubtypeOf";
|
|
32
32
|
import { BaseNode_getCache } from "./base_node_private";
|
|
33
|
+
import { Int64, coerceInt32, coerceInt64, coerceInt64toInt32 } from "node-opcua-basic-types";
|
|
33
34
|
|
|
34
35
|
export interface UADataTypeImpl {
|
|
35
36
|
_extensionObjectConstructor: ExtensionObjectConstructorFuncWithSchema;
|
|
@@ -230,7 +231,7 @@ export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
|
230
231
|
definition = enumValues.map((e: any) => {
|
|
231
232
|
return {
|
|
232
233
|
name: e.displayName.text,
|
|
233
|
-
value: e.value
|
|
234
|
+
value: coerceInt64toInt32(e.value)
|
|
234
235
|
};
|
|
235
236
|
});
|
|
236
237
|
}
|
|
@@ -395,12 +396,15 @@ export function DataType_toString(this: UADataTypeImpl, options: ToStringOption)
|
|
|
395
396
|
dataTypeDefinition_toString.call(this, options);
|
|
396
397
|
}
|
|
397
398
|
|
|
399
|
+
|
|
400
|
+
const defaultEnumValue: Int64 = coerceInt64(-1);
|
|
401
|
+
|
|
398
402
|
function makeEnumDefinition(definitionFields: EnumFieldOptions[]) {
|
|
399
403
|
return new EnumDefinition({
|
|
400
404
|
fields: definitionFields.map((x) => ({
|
|
401
405
|
description: x.description,
|
|
402
406
|
name: x.name,
|
|
403
|
-
value: x.value
|
|
407
|
+
value: x.value === undefined ? defaultEnumValue : coerceInt64(x.value)
|
|
404
408
|
}))
|
|
405
409
|
});
|
|
406
410
|
}
|
|
@@ -431,27 +435,3 @@ function makeStructureDefinition(
|
|
|
431
435
|
});
|
|
432
436
|
return sd;
|
|
433
437
|
}
|
|
434
|
-
|
|
435
|
-
/*
|
|
436
|
-
function lockReadOnlyWithWriteDetection<T>(obj: T): T {
|
|
437
|
-
if (obj instanceof Array) {
|
|
438
|
-
return obj.map(lockReadOnlyWithWriteDetection) as unknown as T;
|
|
439
|
-
}
|
|
440
|
-
if (obj instanceof Object) {
|
|
441
|
-
const _org = obj;
|
|
442
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
443
|
-
lockReadOnlyWithWriteDetection(value);
|
|
444
|
-
}
|
|
445
|
-
obj = new Proxy(obj, {
|
|
446
|
-
get: (target: any, prop: string) => {
|
|
447
|
-
return target[prop];
|
|
448
|
-
},
|
|
449
|
-
set: (target: any, prop: string | symbol, value: any, receiver: any) => {
|
|
450
|
-
console.log("QQQQQ Cannot modify stuff ");
|
|
451
|
-
throw new Error("Invalid");
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
return obj;
|
|
456
|
-
}
|
|
457
|
-
*/
|
package/src/ua_variable_impl.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
|
-
/* eslint-disable complexity */
|
|
3
2
|
/**
|
|
4
3
|
* @module node-opcua-address-space
|
|
5
4
|
*/
|
|
6
|
-
// tslint:disable:no-bitwise
|
|
7
|
-
// tslint:disable:no-console
|
|
8
|
-
// tslint:disable:max-line-length
|
|
9
5
|
import { types } from "util";
|
|
10
6
|
import chalk from "chalk";
|
|
11
7
|
|
|
@@ -97,6 +93,7 @@ import {
|
|
|
97
93
|
_touchValue
|
|
98
94
|
} from "./ua_variable_impl_ext_obj";
|
|
99
95
|
import { adjustDataValueStatusCode } from "./data_access/adjust_datavalue_status_code";
|
|
96
|
+
import { _getBasicDataType } from "./get_basic_datatype";
|
|
100
97
|
|
|
101
98
|
const debugLog = make_debugLog(__filename);
|
|
102
99
|
const warningLog = make_warningLog(__filename);
|
|
@@ -714,23 +711,7 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
|
|
|
714
711
|
}
|
|
715
712
|
|
|
716
713
|
public getBasicDataType(): DataType {
|
|
717
|
-
|
|
718
|
-
return this._basicDataType;
|
|
719
|
-
}
|
|
720
|
-
if (this.dataType.namespace === 0 && this.dataType.value === 0) {
|
|
721
|
-
return DataType.Null;
|
|
722
|
-
}
|
|
723
|
-
const addressSpace = this.addressSpace;
|
|
724
|
-
if (!addressSpace) {
|
|
725
|
-
// may be node has been deleted already
|
|
726
|
-
return DataType.Null;
|
|
727
|
-
}
|
|
728
|
-
const dataTypeNode = addressSpace.findDataType(this.dataType)!;
|
|
729
|
-
const basicDataType =
|
|
730
|
-
dataTypeNode && dataTypeNode.nodeClass === NodeClass.DataType ? dataTypeNode.getBasicDataType() : DataType.Null;
|
|
731
|
-
// const basicDataType = addressSpace.findCorrespondingBasicDataType(this.dataType);
|
|
732
|
-
this._basicDataType = basicDataType;
|
|
733
|
-
return basicDataType;
|
|
714
|
+
return _getBasicDataType(this);
|
|
734
715
|
}
|
|
735
716
|
public adjustVariant(variant: Variant): Variant {
|
|
736
717
|
return adjustVariant(variant, this.valueRank, this.getBasicDataType());
|
|
@@ -1425,7 +1406,9 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
|
|
|
1425
1406
|
// has not yet been loaded !
|
|
1426
1407
|
return true;
|
|
1427
1408
|
}
|
|
1428
|
-
|
|
1409
|
+
if (dataType.nodeId.namespace === 0 && dataType.nodeId.value === DataType.ExtensionObject) {
|
|
1410
|
+
return true;
|
|
1411
|
+
}
|
|
1429
1412
|
const Constructor = addressSpace.getExtensionObjectConstructor(this.dataType);
|
|
1430
1413
|
|
|
1431
1414
|
if (this.valueRank === -1) {
|
|
@@ -70,7 +70,12 @@ function _extensionObjectFieldGetter(getVariable: () => UAVariable | null, targe
|
|
|
70
70
|
}
|
|
71
71
|
return target[key];
|
|
72
72
|
}
|
|
73
|
-
function _extensionObjectFieldSetter(
|
|
73
|
+
function _extensionObjectFieldSetter(
|
|
74
|
+
getVariable: () => UAVariable | null,
|
|
75
|
+
target: any,
|
|
76
|
+
key: string,
|
|
77
|
+
value: any /*, receiver*/
|
|
78
|
+
): boolean {
|
|
74
79
|
target[key] = value;
|
|
75
80
|
if (isProxy(target)) {
|
|
76
81
|
return true;
|
|
@@ -132,7 +137,6 @@ export function propagateTouchValueDownward(self: UAVariableImpl, now: PreciseCl
|
|
|
132
137
|
const property = self.getChildByName(field.name!) as UAVariableImpl;
|
|
133
138
|
|
|
134
139
|
if (property) {
|
|
135
|
-
|
|
136
140
|
if (cache) {
|
|
137
141
|
if (cache.has(property)) {
|
|
138
142
|
continue;
|
|
@@ -146,9 +150,7 @@ export function propagateTouchValueDownward(self: UAVariableImpl, now: PreciseCl
|
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
|
|
149
|
-
|
|
150
153
|
export function setExtensionObjectPartialValue(node: UAVariableImpl, partialObject: any, sourceTimestamp?: PreciseClock) {
|
|
151
|
-
|
|
152
154
|
const variablesToUpdate: Set<UAVariableImpl> = new Set();
|
|
153
155
|
|
|
154
156
|
const extensionObject = node.$extensionObject;
|
|
@@ -162,7 +164,6 @@ export function setExtensionObjectPartialValue(node: UAVariableImpl, partialObje
|
|
|
162
164
|
if (extObject[prop] instanceof Object) {
|
|
163
165
|
_update_extension_object(extObject[prop], partialObject1[prop]);
|
|
164
166
|
} else {
|
|
165
|
-
|
|
166
167
|
if (isProxy(extObject)) {
|
|
167
168
|
// collect element we have to update
|
|
168
169
|
const target = getProxyTarget(extObject);
|
|
@@ -242,8 +243,10 @@ function prepareVariantValue(dataType: DataType, value: VariantLike): VariantLik
|
|
|
242
243
|
|
|
243
244
|
function installExt(uaVariable: UAVariableImpl, ext: ExtensionObject) {
|
|
244
245
|
ext = unProxy(ext);
|
|
245
|
-
uaVariable.$extensionObject = new Proxy(
|
|
246
|
-
|
|
246
|
+
uaVariable.$extensionObject = new Proxy(
|
|
247
|
+
ext,
|
|
248
|
+
makeHandler(() => uaVariable)
|
|
249
|
+
);
|
|
247
250
|
|
|
248
251
|
const addressSpace = uaVariable.addressSpace;
|
|
249
252
|
const definition = uaVariable.dataTypeObj.getStructureDefinition();
|
|
@@ -258,9 +261,12 @@ function installExt(uaVariable: UAVariableImpl, ext: ExtensionObject) {
|
|
|
258
261
|
|
|
259
262
|
const subExtObj = uaVariable.$extensionObject[camelCaseName];
|
|
260
263
|
if (subExtObj) {
|
|
261
|
-
uaVariable.$extensionObject[camelCaseName] = new Proxy(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
+
uaVariable.$extensionObject[camelCaseName] = new Proxy(
|
|
265
|
+
subExtObj,
|
|
266
|
+
makeHandler(() => {
|
|
267
|
+
return uaVariable.getComponentByName(field.name!) as UAVariable | null;
|
|
268
|
+
})
|
|
269
|
+
);
|
|
264
270
|
} else {
|
|
265
271
|
doDebug && warningLog("extension object is null");
|
|
266
272
|
}
|
|
@@ -269,11 +275,7 @@ function installExt(uaVariable: UAVariableImpl, ext: ExtensionObject) {
|
|
|
269
275
|
}
|
|
270
276
|
}
|
|
271
277
|
|
|
272
|
-
export function _installExtensionObjectBindingOnProperties(
|
|
273
|
-
uaVariable: UAVariableImpl,
|
|
274
|
-
options?: BindExtensionObjectOptions
|
|
275
|
-
): void {
|
|
276
|
-
|
|
278
|
+
export function _installExtensionObjectBindingOnProperties(uaVariable: UAVariableImpl, options?: BindExtensionObjectOptions): void {
|
|
277
279
|
// may be extension object mechanism has alreday been install
|
|
278
280
|
// in this case we just need to rebind the properties...
|
|
279
281
|
if (uaVariable.$extensionObject) {
|
|
@@ -292,7 +294,6 @@ export function _installExtensionObjectBindingOnProperties(
|
|
|
292
294
|
if (extObj instanceof ExtensionObject) {
|
|
293
295
|
uaVariable.bindExtensionObject(extObj, { createMissingProp: true, force: true });
|
|
294
296
|
} else if (extObj instanceof Array) {
|
|
295
|
-
|
|
296
297
|
// istanbul ignore else
|
|
297
298
|
if (dataValue.value.arrayType === VariantArrayType.Array || dataValue.value.arrayType === VariantArrayType.Matrix) {
|
|
298
299
|
_bindExtensionObjectArrayOrMatrix(uaVariable, extObj, { createMissingProp: true, force: true });
|
|
@@ -302,17 +303,22 @@ export function _installExtensionObjectBindingOnProperties(
|
|
|
302
303
|
}
|
|
303
304
|
}
|
|
304
305
|
|
|
305
|
-
function _installFields2(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
function _installFields2(
|
|
307
|
+
uaVariable: UAVariableImpl,
|
|
308
|
+
{
|
|
309
|
+
get,
|
|
310
|
+
set
|
|
311
|
+
}: {
|
|
312
|
+
get: (fieldName: string) => any;
|
|
313
|
+
set: (fieldName: string, value: any, sourceTime: PreciseClock) => void;
|
|
314
|
+
},
|
|
315
|
+
options?: BindExtensionObjectOptions
|
|
316
|
+
) {
|
|
310
317
|
options = options || { createMissingProp: false };
|
|
311
318
|
const dt = uaVariable.getDataTypeNode();
|
|
312
319
|
const definition = dt.getStructureDefinition();
|
|
313
320
|
|
|
314
321
|
for (const field of definition.fields || []) {
|
|
315
|
-
|
|
316
322
|
if (NodeId.sameNodeId(NodeId.nullNodeId, field.dataType)) {
|
|
317
323
|
warningLog("field.dataType is null ! ", field.name, NodeId.nullNodeId.toString());
|
|
318
324
|
warningLog(field.toString());
|
|
@@ -332,7 +338,12 @@ function _installFields2(uaVariable: UAVariableImpl, { get, set }: {
|
|
|
332
338
|
propertyNode.$dataValue.serverTimestamp = uaVariable.$dataValue.serverTimestamp;
|
|
333
339
|
propertyNode.$dataValue.serverPicoseconds = uaVariable.$dataValue.serverPicoseconds;
|
|
334
340
|
propertyNode.$dataValue.value.dataType = propertyNode.dataTypeObj.basicDataType;
|
|
335
|
-
propertyNode.$dataValue.value.arrayType =
|
|
341
|
+
propertyNode.$dataValue.value.arrayType =
|
|
342
|
+
propertyNode.valueRank === -1
|
|
343
|
+
? VariantArrayType.Scalar
|
|
344
|
+
: propertyNode.valueRank === 1
|
|
345
|
+
? VariantArrayType.Array
|
|
346
|
+
: VariantArrayType.Matrix;
|
|
336
347
|
propertyNode.$dataValue.value.dimensions = propertyNode.valueRank > 1 ? propertyNode.arrayDimensions : null;
|
|
337
348
|
|
|
338
349
|
const fieldName = field.name!;
|
|
@@ -344,19 +355,23 @@ function _installFields2(uaVariable: UAVariableImpl, { get, set }: {
|
|
|
344
355
|
const value = dataValue.value.value;
|
|
345
356
|
set(field.name!, value, sourceTime);
|
|
346
357
|
propertyNode.touchValue(sourceTime);
|
|
347
|
-
}
|
|
358
|
+
};
|
|
348
359
|
|
|
349
360
|
if (propertyNode.dataTypeObj.basicDataType === DataType.ExtensionObject) {
|
|
350
|
-
_installFields2(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
361
|
+
_installFields2(
|
|
362
|
+
propertyNode,
|
|
363
|
+
{
|
|
364
|
+
get: (fieldName: string) => {
|
|
365
|
+
const mainFieldName = field.name!;
|
|
366
|
+
return get(mainFieldName)[lowerFirstLetter(fieldName)];
|
|
367
|
+
},
|
|
368
|
+
set: (fieldName: string, value: any, sourceTime: PreciseClock) => {
|
|
369
|
+
const mainFieldName = field.name!;
|
|
370
|
+
get(mainFieldName)[lowerFirstLetter(fieldName)] = value;
|
|
371
|
+
}
|
|
354
372
|
},
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
get(mainFieldName)[lowerFirstLetter(fieldName)] = value;
|
|
358
|
-
}
|
|
359
|
-
}, options);
|
|
373
|
+
options
|
|
374
|
+
);
|
|
360
375
|
}
|
|
361
376
|
}
|
|
362
377
|
}
|
|
@@ -393,15 +408,19 @@ function isVariableContainingExtensionObject(uaVariable: UAVariableImpl): boolea
|
|
|
393
408
|
return true;
|
|
394
409
|
}
|
|
395
410
|
|
|
396
|
-
function _innerBindExtensionObjectScalar(
|
|
397
|
-
|
|
411
|
+
function _innerBindExtensionObjectScalar(
|
|
412
|
+
uaVariable: UAVariableImpl,
|
|
413
|
+
{
|
|
414
|
+
get,
|
|
415
|
+
set,
|
|
416
|
+
setField
|
|
417
|
+
}: {
|
|
398
418
|
get: () => ExtensionObject;
|
|
399
419
|
set: (value: ExtensionObject, sourceTimestamp: PreciseClock, cache: Set<UAVariableImpl>) => void;
|
|
400
420
|
setField: (fieldName: string, value: any, sourceTimestamp: PreciseClock, cache?: Set<UAVariableImpl>) => void;
|
|
401
421
|
},
|
|
402
422
|
options?: BindExtensionObjectOptions
|
|
403
423
|
) {
|
|
404
|
-
|
|
405
424
|
uaVariable.$dataValue.statusCode = StatusCodes.Good;
|
|
406
425
|
uaVariable.$dataValue.value.dataType = DataType.ExtensionObject;
|
|
407
426
|
uaVariable.$dataValue.value.arrayType = VariantArrayType.Scalar;
|
|
@@ -413,19 +432,21 @@ function _innerBindExtensionObjectScalar(uaVariable: UAVariableImpl,
|
|
|
413
432
|
installDataValueGetter(uaVariable, get);
|
|
414
433
|
uaVariable.$set_ExtensionObject = set;
|
|
415
434
|
|
|
416
|
-
_installFields2(
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
435
|
+
_installFields2(
|
|
436
|
+
uaVariable,
|
|
437
|
+
{
|
|
438
|
+
get: (fieldName: string) => {
|
|
439
|
+
const extObj = get() as any;
|
|
440
|
+
return extObj[lowerFirstLetter(fieldName)];
|
|
441
|
+
},
|
|
442
|
+
set: (fieldName: string, value: any, sourceTime: PreciseClock) => {
|
|
443
|
+
setField(fieldName, value, sourceTime);
|
|
444
|
+
}
|
|
420
445
|
},
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
}, options);
|
|
425
|
-
|
|
446
|
+
options
|
|
447
|
+
);
|
|
426
448
|
}
|
|
427
449
|
|
|
428
|
-
|
|
429
450
|
// eslint-disable-next-line complexity
|
|
430
451
|
export function _bindExtensionObject(
|
|
431
452
|
uaVariable: UAVariableImpl,
|
|
@@ -441,7 +462,10 @@ export function _bindExtensionObject(
|
|
|
441
462
|
|
|
442
463
|
// istanbul ignore next
|
|
443
464
|
if (optionalExtensionObject && uaVariable.valueRank === 0) {
|
|
444
|
-
warningLog(
|
|
465
|
+
warningLog(
|
|
466
|
+
uaVariable.browseName.toString() +
|
|
467
|
+
": valueRank was zero but needed to be adjusted to -1 (Scalar) in bindExtensionObject"
|
|
468
|
+
);
|
|
445
469
|
uaVariable.valueRank = -1;
|
|
446
470
|
}
|
|
447
471
|
const addressSpace = uaVariable.addressSpace;
|
|
@@ -491,19 +515,24 @@ export function _bindExtensionObject(
|
|
|
491
515
|
warningLog(uaVariable.$extensionObject?.toString());
|
|
492
516
|
throw new Error(
|
|
493
517
|
"bindExtensionObject: $extensionObject is incorrect: we are expecting a " +
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
518
|
+
uaVariable.dataType.toString({ addressSpace: uaVariable.addressSpace }) +
|
|
519
|
+
" but we got a " +
|
|
520
|
+
uaVariable.$extensionObject?.schema.name
|
|
497
521
|
);
|
|
498
522
|
}
|
|
499
523
|
return uaVariable.$extensionObject;
|
|
500
524
|
}
|
|
501
525
|
|
|
502
|
-
// istanbul ignore next
|
|
503
526
|
if (uaVariable.dataTypeObj.isAbstract) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
527
|
+
// istanbul ignore next
|
|
528
|
+
if (!optionalExtensionObject) {
|
|
529
|
+
warningLog(
|
|
530
|
+
"Warning the DataType associated with this Variable is abstract ",
|
|
531
|
+
uaVariable.dataTypeObj.browseName.toString()
|
|
532
|
+
);
|
|
533
|
+
warningLog("You need to provide a extension object yourself ");
|
|
534
|
+
throw new Error("bindExtensionObject requires a extensionObject as associated dataType is only abstract");
|
|
535
|
+
}
|
|
507
536
|
}
|
|
508
537
|
|
|
509
538
|
const s = uaVariable.readValue();
|
|
@@ -516,14 +545,14 @@ export function _bindExtensionObject(
|
|
|
516
545
|
return uaVariable.$extensionObject;
|
|
517
546
|
|
|
518
547
|
function innerBindExtensionObject() {
|
|
519
|
-
|
|
520
548
|
if (s.value && (s.value.dataType === DataType.Null || (s.value.dataType === DataType.ExtensionObject && !s.value.value))) {
|
|
521
549
|
if (uaVariable.valueRank === -1 /** Scalar */) {
|
|
522
550
|
extensionObject_ = optionalExtensionObject || addressSpace.constructExtensionObject(uaVariable.dataType, {});
|
|
523
551
|
|
|
524
552
|
installExt(uaVariable, extensionObject_);
|
|
525
553
|
|
|
526
|
-
_innerBindExtensionObjectScalar(
|
|
554
|
+
_innerBindExtensionObjectScalar(
|
|
555
|
+
uaVariable,
|
|
527
556
|
{
|
|
528
557
|
get: () => uaVariable.$extensionObject,
|
|
529
558
|
set: (value: ExtensionObject) => installExt(uaVariable, value),
|
|
@@ -531,8 +560,9 @@ export function _bindExtensionObject(
|
|
|
531
560
|
const extObj = uaVariable.$extensionObject;
|
|
532
561
|
getProxyTarget(extObj)[lowerFirstLetter(fieldName)] = value;
|
|
533
562
|
}
|
|
534
|
-
|
|
535
|
-
|
|
563
|
+
},
|
|
564
|
+
options
|
|
565
|
+
);
|
|
536
566
|
return;
|
|
537
567
|
} else if (uaVariable.valueRank === 1 /** Array */) {
|
|
538
568
|
throw new Error("Should not get there ! Please fix me");
|
|
@@ -544,7 +574,8 @@ export function _bindExtensionObject(
|
|
|
544
574
|
// verify that variant has the correct type
|
|
545
575
|
assert(s.value.dataType === DataType.ExtensionObject);
|
|
546
576
|
installExt(uaVariable, s.value.value);
|
|
547
|
-
_innerBindExtensionObjectScalar(
|
|
577
|
+
_innerBindExtensionObjectScalar(
|
|
578
|
+
uaVariable,
|
|
548
579
|
{
|
|
549
580
|
get: () => uaVariable.$extensionObject,
|
|
550
581
|
set: (value: ExtensionObject) => installExt(uaVariable, value),
|
|
@@ -552,26 +583,26 @@ export function _bindExtensionObject(
|
|
|
552
583
|
const extObj = uaVariable.$extensionObject;
|
|
553
584
|
getProxyTarget(extObj)[lowerFirstLetter(fieldName)] = value;
|
|
554
585
|
}
|
|
555
|
-
},
|
|
586
|
+
},
|
|
587
|
+
options
|
|
588
|
+
);
|
|
556
589
|
}
|
|
557
590
|
}
|
|
558
591
|
}
|
|
559
592
|
|
|
560
593
|
const getIndexAsText = (index: number | number[]): string => {
|
|
561
|
-
if (typeof index === "number")
|
|
562
|
-
return `${index}`;
|
|
594
|
+
if (typeof index === "number") return `${index}`;
|
|
563
595
|
return `${index.map((a) => a.toString()).join(",")}`;
|
|
564
|
-
}
|
|
596
|
+
};
|
|
565
597
|
const composeBrowseNameAndNodeId = (uaVariable: UAVariable, indexes: number[]) => {
|
|
566
598
|
const iAsText = getIndexAsText(indexes);
|
|
567
599
|
const browseName = coerceQualifiedName(iAsText);
|
|
568
600
|
let nodeId: NodeId | undefined;
|
|
569
601
|
if (uaVariable.nodeId.identifierType === NodeIdType.STRING) {
|
|
570
|
-
nodeId = new NodeId(NodeIdType.STRING, uaVariable.nodeId.value as string + `[${iAsText}]`, uaVariable.nodeId.namespace);
|
|
602
|
+
nodeId = new NodeId(NodeIdType.STRING, (uaVariable.nodeId.value as string) + `[${iAsText}]`, uaVariable.nodeId.namespace);
|
|
571
603
|
}
|
|
572
604
|
return { browseName, nodeId };
|
|
573
|
-
}
|
|
574
|
-
|
|
605
|
+
};
|
|
575
606
|
|
|
576
607
|
// eslint-disable-next-line max-statements, complexity
|
|
577
608
|
export function _bindExtensionObjectArrayOrMatrix(
|
|
@@ -579,7 +610,6 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
579
610
|
optionalExtensionObjectArray?: ExtensionObject[],
|
|
580
611
|
options?: BindExtensionObjectOptions
|
|
581
612
|
): ExtensionObject[] {
|
|
582
|
-
|
|
583
613
|
options = options || { createMissingProp: false };
|
|
584
614
|
options.createMissingProp = options.createMissingProp || false;
|
|
585
615
|
|
|
@@ -598,7 +628,10 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
598
628
|
optionalExtensionObjectArray = uaVariable.$dataValue.value.value;
|
|
599
629
|
}
|
|
600
630
|
|
|
601
|
-
if (
|
|
631
|
+
if (
|
|
632
|
+
(arrayDimensions.length === 0 || (arrayDimensions.length === 1 && arrayDimensions[0] === 0)) &&
|
|
633
|
+
optionalExtensionObjectArray
|
|
634
|
+
) {
|
|
602
635
|
arrayDimensions[0] = optionalExtensionObjectArray.length;
|
|
603
636
|
}
|
|
604
637
|
|
|
@@ -616,16 +649,15 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
616
649
|
if (!optionalExtensionObjectArray) {
|
|
617
650
|
optionalExtensionObjectArray = [];
|
|
618
651
|
for (let i = 0; i < totalLength; i++) {
|
|
619
|
-
optionalExtensionObjectArray[i] = addressSpace.constructExtensionObject(uaVariable.dataType, {})
|
|
652
|
+
optionalExtensionObjectArray[i] = addressSpace.constructExtensionObject(uaVariable.dataType, {});
|
|
620
653
|
}
|
|
621
654
|
}
|
|
622
655
|
uaVariable.$$extensionObjectArray = optionalExtensionObjectArray;
|
|
623
656
|
uaVariable.$dataValue.value.arrayType = uaVariable.valueRank === 1 ? VariantArrayType.Array : VariantArrayType.Matrix;
|
|
624
|
-
uaVariable.$dataValue.value.dimensions = uaVariable.valueRank === 1 ? null :
|
|
657
|
+
uaVariable.$dataValue.value.dimensions = uaVariable.valueRank === 1 ? null : uaVariable.arrayDimensions || [];
|
|
625
658
|
uaVariable.$dataValue.value.dataType = DataType.ExtensionObject;
|
|
626
659
|
uaVariable.$dataValue.value.value = uaVariable.$$extensionObjectArray;
|
|
627
660
|
|
|
628
|
-
|
|
629
661
|
// make sure uaVariable.$dataValue cannot be inadvertantly changed from this point onward
|
|
630
662
|
const $dataValue = uaVariable.$dataValue;
|
|
631
663
|
Object.defineProperty(uaVariable, "$dataValue", {
|
|
@@ -637,25 +669,25 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
637
669
|
},
|
|
638
670
|
// writable: true,
|
|
639
671
|
enumerable: true,
|
|
640
|
-
configurable: true
|
|
672
|
+
configurable: true
|
|
641
673
|
});
|
|
642
674
|
|
|
643
|
-
uaVariable.bindVariable(
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
675
|
+
uaVariable.bindVariable(
|
|
676
|
+
{
|
|
677
|
+
get: () => uaVariable.$dataValue.value
|
|
678
|
+
},
|
|
679
|
+
true
|
|
680
|
+
);
|
|
647
681
|
|
|
648
682
|
const namespace = uaVariable.namespace;
|
|
649
683
|
const indexIterator = new IndexIterator(arrayDimensions);
|
|
650
684
|
for (let i = 0; i < totalLength; i++) {
|
|
651
|
-
|
|
652
685
|
const index = indexIterator.next();
|
|
653
686
|
|
|
654
687
|
const { browseName, nodeId } = composeBrowseNameAndNodeId(uaVariable, index);
|
|
655
688
|
|
|
656
689
|
let uaElement = uaVariable.getComponentByName(browseName) as UAVariableImpl | null;
|
|
657
690
|
if (!uaElement) {
|
|
658
|
-
|
|
659
691
|
if (!options.createMissingProp) {
|
|
660
692
|
continue;
|
|
661
693
|
}
|
|
@@ -681,15 +713,17 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
681
713
|
{
|
|
682
714
|
const capturedIndex = i;
|
|
683
715
|
const capturedUaElement = uaElement as UAVariableImpl;
|
|
684
|
-
_innerBindExtensionObjectScalar(
|
|
716
|
+
_innerBindExtensionObjectScalar(
|
|
717
|
+
uaElement,
|
|
685
718
|
{
|
|
686
719
|
get: () => uaVariable.$$extensionObjectArray[capturedIndex],
|
|
687
720
|
set: (newValue: ExtensionObject, sourceTimestamp: PreciseClock, cache: Set<UAVariableImpl>) => {
|
|
688
721
|
assert(!isProxy(uaVariable.$$extensionObjectArray[capturedIndex]));
|
|
689
722
|
uaVariable.$$extensionObjectArray[capturedIndex] = newValue;
|
|
723
|
+
// istanbul ignore next
|
|
690
724
|
if (uaVariable.$$extensionObjectArray !== uaVariable.$dataValue.value.value) {
|
|
691
|
-
|
|
692
|
-
|
|
725
|
+
warningLog("uaVariable", uaVariable.nodeId.toString());
|
|
726
|
+
warningLog("Houston! We have a problem ");
|
|
693
727
|
}
|
|
694
728
|
propagateTouchValueDownward(capturedUaElement, sourceTimestamp, cache);
|
|
695
729
|
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
@@ -700,8 +734,9 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
700
734
|
(isProxy(extObj) ? getProxyTarget(extObj) : extObj)[lowerFirstLetter(fieldName)] = newValue;
|
|
701
735
|
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
702
736
|
}
|
|
703
|
-
},
|
|
704
|
-
|
|
737
|
+
},
|
|
738
|
+
{ ...options, force: true }
|
|
739
|
+
);
|
|
705
740
|
}
|
|
706
741
|
}
|
|
707
742
|
return uaVariable.$$extensionObjectArray;
|
|
@@ -764,14 +799,12 @@ export function extractPartialData(path: string | string[], extensionObject: Ext
|
|
|
764
799
|
}
|
|
765
800
|
|
|
766
801
|
export function propagateTouchValueDownwardArray(uaVariable: UAVariableImpl, now: PreciseClock, cache: Set<UAVariable>) {
|
|
767
|
-
|
|
768
802
|
if (!uaVariable.$$extensionObjectArray) return;
|
|
769
803
|
const arrayDimensions = uaVariable.arrayDimensions || [];
|
|
770
804
|
const totalLength = uaVariable.$$extensionObjectArray.length;
|
|
771
805
|
|
|
772
806
|
const indexIterator = new IndexIterator(arrayDimensions);
|
|
773
807
|
for (let i = 0; i < totalLength; i++) {
|
|
774
|
-
|
|
775
808
|
const index = indexIterator.next();
|
|
776
809
|
|
|
777
810
|
const { browseName, nodeId } = composeBrowseNameAndNodeId(uaVariable, index);
|
|
@@ -781,4 +814,4 @@ export function propagateTouchValueDownwardArray(uaVariable: UAVariableImpl, now
|
|
|
781
814
|
propagateTouchValueDownward(uaElement, now, cache);
|
|
782
815
|
}
|
|
783
816
|
}
|
|
784
|
-
}
|
|
817
|
+
}
|