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,5 +1,5 @@
|
|
|
1
1
|
import type { BindVariableOptions, CloneFilter, CloneOptions, ISessionContext, IVariableHistorian, ListenerSignature, TimestampGetFunc, UADataType, UAVariable, UAVariableEvents, UAVariableType } from "node-opcua-address-space-base";
|
|
2
|
-
import { type BindExtensionObjectOptions, type CloneExtraInfo, type ContinuationData, type VariableDataValueSetterWithCallback } from "node-opcua-address-space-base";
|
|
2
|
+
import { type BindExtensionObjectOptions, type CloneExtraInfo, type ContinuationData, type GetFunc, type VariableDataValueSetterWithCallback } from "node-opcua-address-space-base";
|
|
3
3
|
import { AccessLevelFlag, AttributeIds, NodeClass, type QualifiedName, type QualifiedNameLike } from "node-opcua-data-model";
|
|
4
4
|
import { DataValue, type DataValueT } from "node-opcua-data-value";
|
|
5
5
|
import { type PreciseClock } from "node-opcua-date-time";
|
|
@@ -89,10 +89,10 @@ export declare class UAVariableImpl<T extends UAVariableEvents & ListenerSignatu
|
|
|
89
89
|
arrayDimensions: null | number[];
|
|
90
90
|
_timestamped_get_func?: TimestampGetFunc | null;
|
|
91
91
|
_timestamped_set_func?: VariableDataValueSetterWithCallback | null;
|
|
92
|
-
_get_func
|
|
93
|
-
_set_func:
|
|
92
|
+
_get_func?: GetFunc | null;
|
|
93
|
+
_set_func?: ((value: Variant, callback: (err: Error | null, statusCode?: StatusCode) => void) => void) | null;
|
|
94
94
|
refreshFunc?: (callback: CallbackT<DataValue>) => void;
|
|
95
|
-
__waiting_callbacks?:
|
|
95
|
+
__waiting_callbacks?: CallbackT<DataValue>[];
|
|
96
96
|
get typeDefinitionObj(): UAVariableType;
|
|
97
97
|
get typeDefinition(): NodeId;
|
|
98
98
|
constructor(options: UAVariableOptions);
|
|
@@ -329,20 +329,18 @@ export declare class UAVariableImpl<T extends UAVariableEvents & ListenerSignatu
|
|
|
329
329
|
bindExtensionObjectScalar(optionalExtensionObject?: ExtensionObject, options?: BindExtensionObjectOptions): ExtensionObject | null;
|
|
330
330
|
bindExtensionObjectArray(optionalExtensionObject?: ExtensionObject[], options?: BindExtensionObjectOptions): ExtensionObject[] | null;
|
|
331
331
|
bindExtensionObject(optionalExtensionObject?: ExtensionObject | ExtensionObject[], options?: BindExtensionObjectOptions): ExtensionObject | ExtensionObject[] | null;
|
|
332
|
-
updateExtensionObjectPartial(partialExtensionObject?:
|
|
333
|
-
[key: string]: any;
|
|
334
|
-
}): ExtensionObject;
|
|
332
|
+
updateExtensionObjectPartial(partialExtensionObject?: Record<string, unknown>): ExtensionObject;
|
|
335
333
|
incrementExtensionObjectPartial(path: string | string[]): void;
|
|
336
334
|
toString(): string;
|
|
337
335
|
toJSON(): Record<string, unknown>;
|
|
338
336
|
historyRead(context: ISessionContext, historyReadDetails: HistoryReadDetails | ReadRawModifiedDetails | ReadEventDetails | ReadProcessedDetails | ReadAtTimeDetails, indexRange: NumericRange | null, dataEncoding: QualifiedNameLike | null, continuationData: ContinuationData): Promise<HistoryReadResult>;
|
|
339
337
|
historyRead(context: ISessionContext, historyReadDetails: HistoryReadDetails | ReadRawModifiedDetails | ReadEventDetails | ReadProcessedDetails | ReadAtTimeDetails, indexRange: NumericRange | null, dataEncoding: QualifiedNameLike | null, continuationData: ContinuationData, callback: CallbackT<HistoryReadResult>): void;
|
|
340
338
|
_historyReadRaw(_context: ISessionContext, _historyReadRawModifiedDetails: ReadRawModifiedDetails, _indexRange: NumericRange | null, _dataEncoding: QualifiedNameLike | null, _continuationData: ContinuationData, _callback: CallbackT<HistoryReadResult>): void;
|
|
341
|
-
_historyReadRawModify(_context: ISessionContext, _historyReadRawModifiedDetails: ReadRawModifiedDetails, _indexRange: NumericRange | null, _dataEncoding: QualifiedNameLike | null, _continuationData: ContinuationData, _callback?: CallbackT<HistoryReadResult>):
|
|
339
|
+
_historyReadRawModify(_context: ISessionContext, _historyReadRawModifiedDetails: ReadRawModifiedDetails, _indexRange: NumericRange | null, _dataEncoding: QualifiedNameLike | null, _continuationData: ContinuationData, _callback?: CallbackT<HistoryReadResult>): void;
|
|
342
340
|
_historyRead(context: ISessionContext, _historyReadDetails: HistoryReadDetails | ReadRawModifiedDetails | ReadEventDetails | ReadProcessedDetails | ReadAtTimeDetails, _indexRange: NumericRange | null, _dataEncoding: QualifiedNameLike | null, _continuationData: ContinuationData, callback: CallbackT<HistoryReadResult>): void;
|
|
343
|
-
_historyPush(_newDataValue: DataValue):
|
|
344
|
-
_historyReadRawAsync(_historyReadRawModifiedDetails: ReadRawModifiedDetails, _maxNumberToExtract: number, _isReversed: boolean, _reverseDataValue: boolean, _callback: CallbackT<DataValue[]>):
|
|
345
|
-
_historyReadModify(_context: ISessionContext, _historyReadRawModifiedDetails: ReadRawModifiedDetails, _indexRange: NumericRange | null, _dataEncoding: QualifiedNameLike | null, _continuationData: ContinuationData, _callback: CallbackT<HistoryReadResult>):
|
|
341
|
+
_historyPush(_newDataValue: DataValue): void;
|
|
342
|
+
_historyReadRawAsync(_historyReadRawModifiedDetails: ReadRawModifiedDetails, _maxNumberToExtract: number, _isReversed: boolean, _reverseDataValue: boolean, _callback: CallbackT<DataValue[]>): void;
|
|
343
|
+
_historyReadModify(_context: ISessionContext, _historyReadRawModifiedDetails: ReadRawModifiedDetails, _indexRange: NumericRange | null, _dataEncoding: QualifiedNameLike | null, _continuationData: ContinuationData, _callback: CallbackT<HistoryReadResult>): void;
|
|
346
344
|
_update_startOfOnlineArchive(_newDate: Date): void;
|
|
347
345
|
_update_startOfArchive(_newDate: Date): void;
|
|
348
346
|
_validate_DataType(variantDataType: DataType): boolean;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.UAVariableImplT = exports.UAVariableImpl = void 0;
|
|
7
7
|
exports.adjust_accessLevel = adjust_accessLevel;
|
|
8
8
|
exports.adjust_userAccessLevel = adjust_userAccessLevel;
|
|
9
|
-
/* eslint-disable max-statements */
|
|
10
9
|
/**
|
|
11
10
|
* @module node-opcua-address-space
|
|
12
11
|
*/
|
|
@@ -116,6 +115,10 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
116
115
|
nodeClass = node_opcua_data_model_1.NodeClass.Variable;
|
|
117
116
|
dataType;
|
|
118
117
|
_basicDataType;
|
|
118
|
+
// narrowing this to ExtensionObject breaks declaration-merging in ua_two_state_variable.ts and elsewhere
|
|
119
|
+
// (concrete *T variants bind $extensionObject to a different, more specific shape) — see the matching
|
|
120
|
+
// comment on UAVariable.$extensionObject in node-opcua-address-space-base for the documented precedent.
|
|
121
|
+
// biome-ignore lint/suspicious/noExplicitAny: see comment above
|
|
119
122
|
$extensionObject;
|
|
120
123
|
$set_ExtensionObject;
|
|
121
124
|
$historicalDataConfiguration;
|
|
@@ -289,7 +292,6 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
289
292
|
if (dataValueOrPromise !== this.$dataValue) {
|
|
290
293
|
// we may have a problem here if we use a getter that returns a dataValue that is a ExtensionObject
|
|
291
294
|
if (dataValueOrPromise.value?.dataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
292
|
-
// eslint-disable-next-line max-depth
|
|
293
295
|
if (this.$extensionObject || this.$$extensionObjectArray) {
|
|
294
296
|
// we have an extension object already bound to this node
|
|
295
297
|
// the client is asking us to replace the object entirely by a new one
|
|
@@ -318,11 +320,13 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
318
320
|
/* c8 ignore next */
|
|
319
321
|
if (dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.BadWaitingForInitialData) ||
|
|
320
322
|
dataValue.statusCode.equals(node_opcua_status_code_1.StatusCodes.UncertainInitialValue)) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
"
|
|
324
|
-
|
|
325
|
-
|
|
323
|
+
// c8 ignore next
|
|
324
|
+
doDebug &&
|
|
325
|
+
debugLog(chalk_1.default.red(" Warning: UAVariable#readValue ") +
|
|
326
|
+
chalk_1.default.cyan(this.browseName.toString()) +
|
|
327
|
+
" (" +
|
|
328
|
+
chalk_1.default.yellow(this.nodeId.toString()) +
|
|
329
|
+
") exists but dataValue has not been defined");
|
|
326
330
|
}
|
|
327
331
|
return dataValue;
|
|
328
332
|
}
|
|
@@ -353,12 +357,14 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
353
357
|
const dataTypeNode = this.addressSpace.findDataType(this.dataType);
|
|
354
358
|
return dataTypeNode._getEnumerationInfo();
|
|
355
359
|
}
|
|
356
|
-
asyncRefresh(
|
|
360
|
+
asyncRefresh(oldestDate, callback) {
|
|
361
|
+
// asyncRefresh is always invoked with a callback at runtime: the public overload without
|
|
362
|
+
// a callback is only reachable through the withCallback() wrapper installed below, which
|
|
363
|
+
// synthesizes one before calling into this implementation.
|
|
364
|
+
const cb = callback;
|
|
357
365
|
if (this.$dataValue.statusCode.isGoodish()) {
|
|
358
366
|
this.verifyVariantCompatibility(this.$dataValue.value);
|
|
359
367
|
}
|
|
360
|
-
const oldestDate = args[0];
|
|
361
|
-
const callback = args[1];
|
|
362
368
|
const lessOrEqual = (a, b) => {
|
|
363
369
|
return (a.timestamp.getTime() < b.timestamp.getTime() ||
|
|
364
370
|
(a.timestamp.getTime() === b.timestamp.getTime() && a.picoseconds <= b.picoseconds));
|
|
@@ -370,21 +376,24 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
370
376
|
dataValue.serverPicoseconds = oldestDate.picoseconds;
|
|
371
377
|
const serverClock = (0, node_opcua_date_time_1.coerceClock)(dataValue.serverTimestamp, dataValue.serverPicoseconds);
|
|
372
378
|
if (lessOrEqual(oldestDate, serverClock)) {
|
|
373
|
-
|
|
379
|
+
cb(null, dataValue);
|
|
380
|
+
return;
|
|
374
381
|
}
|
|
375
382
|
else {
|
|
376
383
|
// fake
|
|
377
|
-
|
|
384
|
+
cb(null, dataValue);
|
|
385
|
+
return;
|
|
378
386
|
}
|
|
379
387
|
}
|
|
380
388
|
const c1 = this.$dataValue.serverTimestamp
|
|
381
389
|
? (0, node_opcua_date_time_1.coerceClock)(this.$dataValue.serverTimestamp, this.$dataValue.serverPicoseconds)
|
|
382
390
|
: null;
|
|
383
|
-
if (
|
|
391
|
+
if (c1 && lessOrEqual(oldestDate, c1)) {
|
|
384
392
|
const dataValue = this.readValue().clone();
|
|
385
393
|
dataValue.serverTimestamp = oldestDate.timestamp;
|
|
386
394
|
dataValue.serverPicoseconds = oldestDate.picoseconds;
|
|
387
|
-
|
|
395
|
+
cb(null, dataValue);
|
|
396
|
+
return;
|
|
388
397
|
}
|
|
389
398
|
try {
|
|
390
399
|
this.refreshFunc.call(this, (err, dataValue) => {
|
|
@@ -396,7 +405,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
396
405
|
if (dataValue && dataValue !== this.$dataValue) {
|
|
397
406
|
this._internal_set_dataValue(coerceDataValue(dataValue), null);
|
|
398
407
|
}
|
|
399
|
-
|
|
408
|
+
cb(err, this.$dataValue);
|
|
400
409
|
});
|
|
401
410
|
}
|
|
402
411
|
catch (err) {
|
|
@@ -404,8 +413,9 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
404
413
|
errorLog(err);
|
|
405
414
|
const dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError });
|
|
406
415
|
this._internal_set_dataValue(dataValue, null);
|
|
407
|
-
|
|
416
|
+
cb(err, this.$dataValue);
|
|
408
417
|
}
|
|
418
|
+
return undefined;
|
|
409
419
|
}
|
|
410
420
|
readEnumValue() {
|
|
411
421
|
const value = this.readValue().value.value;
|
|
@@ -638,30 +648,36 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
638
648
|
indexRange = node_opcua_numeric_range_1.NumericRange.coerce(indexRange);
|
|
639
649
|
// test write permission
|
|
640
650
|
if (!this.isWritable(context)) {
|
|
641
|
-
|
|
651
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadNotWritable);
|
|
652
|
+
return;
|
|
642
653
|
}
|
|
643
654
|
if (!this.checkPermissionPrivate(context, node_opcua_types_1.PermissionType.Write)) {
|
|
644
|
-
|
|
655
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadUserAccessDenied);
|
|
656
|
+
return;
|
|
645
657
|
}
|
|
646
658
|
if (!this.isUserWritable(context)) {
|
|
647
|
-
|
|
659
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadWriteNotSupported);
|
|
660
|
+
return;
|
|
648
661
|
}
|
|
649
662
|
// adjust special case
|
|
650
663
|
const variant = adjustVariant2.call(this, dataValue.value);
|
|
651
664
|
const statusCode = this.checkVariantCompatibility(variant);
|
|
652
665
|
if (statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
653
|
-
|
|
666
|
+
callback?.(null, statusCode);
|
|
667
|
+
return;
|
|
654
668
|
}
|
|
655
669
|
// adjust dataValue.statusCode based on InstrumentRange and EngineeringUnits
|
|
656
670
|
const statusCode2 = this.adjustDataValueStatusCode(dataValue);
|
|
657
671
|
if (statusCode2.isNotGood()) {
|
|
658
|
-
|
|
672
|
+
callback?.(null, statusCode2);
|
|
673
|
+
return;
|
|
659
674
|
}
|
|
660
675
|
const write_func = this._timestamped_set_func || default_func;
|
|
661
676
|
if (!write_func) {
|
|
662
677
|
warningLog(` warning ${this.nodeId.toString()} ${this.browseName.toString()} has no setter. \n`);
|
|
663
678
|
warningLog("Please make sure to bind the variable or to pass a valid value: new Variant({}) during construction time");
|
|
664
|
-
|
|
679
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadNotWritable);
|
|
680
|
+
return;
|
|
665
681
|
}
|
|
666
682
|
(0, node_opcua_assert_1.assert)(write_func);
|
|
667
683
|
write_func.call(this, dataValue, (err, statusCode1) => {
|
|
@@ -669,19 +685,22 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
669
685
|
dataValue && this.verifyVariantCompatibility(dataValue.value);
|
|
670
686
|
if (indexRange && !indexRange.isEmpty()) {
|
|
671
687
|
if (!indexRange.isValid()) {
|
|
672
|
-
|
|
688
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadIndexRangeInvalid);
|
|
689
|
+
return;
|
|
673
690
|
}
|
|
674
691
|
const newArrayOrMatrix = dataValue.value.value;
|
|
675
692
|
if (dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
676
693
|
if (this.$dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Array) {
|
|
677
|
-
|
|
694
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
695
|
+
return;
|
|
678
696
|
}
|
|
679
697
|
// check that destination data is also an array
|
|
680
698
|
(0, node_opcua_assert_1.assert)(check_valid_array(this.$dataValue.value.dataType, this.$dataValue.value.value));
|
|
681
699
|
const destArr = this.$dataValue.value.value;
|
|
682
700
|
const result = indexRange.set_values(destArr, newArrayOrMatrix);
|
|
683
701
|
if (result.statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
684
|
-
|
|
702
|
+
callback?.(null, result.statusCode);
|
|
703
|
+
return;
|
|
685
704
|
}
|
|
686
705
|
dataValue.value.value = result.array;
|
|
687
706
|
// scrap original array so we detect range
|
|
@@ -691,7 +710,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
691
710
|
const dimensions = this.$dataValue.value.dimensions;
|
|
692
711
|
if (this.$dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Matrix || !dimensions) {
|
|
693
712
|
// not a matrix !
|
|
694
|
-
|
|
713
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
714
|
+
return;
|
|
695
715
|
}
|
|
696
716
|
const matrix = this.$dataValue.value.value;
|
|
697
717
|
const result = indexRange.set_values_matrix({
|
|
@@ -699,7 +719,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
699
719
|
dimensions
|
|
700
720
|
}, newArrayOrMatrix);
|
|
701
721
|
if (result.statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
702
|
-
|
|
722
|
+
callback?.(null, result.statusCode);
|
|
723
|
+
return;
|
|
703
724
|
}
|
|
704
725
|
dataValue.value.dimensions = this.$dataValue.value.dimensions;
|
|
705
726
|
dataValue.value.value = result.matrix;
|
|
@@ -707,7 +728,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
707
728
|
this.$dataValue.value.value = null;
|
|
708
729
|
}
|
|
709
730
|
else {
|
|
710
|
-
|
|
731
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
732
|
+
return;
|
|
711
733
|
}
|
|
712
734
|
}
|
|
713
735
|
try {
|
|
@@ -717,11 +739,13 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
717
739
|
if (node_util_1.types.isNativeError(err)) {
|
|
718
740
|
warningLog(err.message);
|
|
719
741
|
}
|
|
720
|
-
|
|
742
|
+
callback?.(null, node_opcua_status_code_1.StatusCodes.BadInternalError);
|
|
743
|
+
return;
|
|
721
744
|
}
|
|
722
745
|
}
|
|
723
746
|
callback?.(err || null, statusCode1);
|
|
724
747
|
});
|
|
748
|
+
return undefined;
|
|
725
749
|
}
|
|
726
750
|
writeAttribute(context, writeValueOptions, callback) {
|
|
727
751
|
// c8 ignore next
|
|
@@ -729,7 +753,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
729
753
|
throw new Error("Internal error");
|
|
730
754
|
}
|
|
731
755
|
if (!this.canUserWriteAttribute(context, writeValueOptions.attributeId)) {
|
|
732
|
-
|
|
756
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadUserAccessDenied);
|
|
757
|
+
return;
|
|
733
758
|
}
|
|
734
759
|
const writeValue = writeValueOptions instanceof node_opcua_service_write_1.WriteValue ? writeValueOptions : new node_opcua_service_write_1.WriteValue(writeValueOptions);
|
|
735
760
|
context = context || session_context_1.SessionContext.defaultContext;
|
|
@@ -748,26 +773,32 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
748
773
|
break;
|
|
749
774
|
case node_opcua_data_model_1.AttributeIds.Historizing:
|
|
750
775
|
if (writeValue.value?.value.dataType !== node_opcua_variant_1.DataType.Boolean) {
|
|
751
|
-
|
|
776
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
777
|
+
break;
|
|
752
778
|
}
|
|
753
779
|
if (!this.checkPermissionPrivate(context, node_opcua_types_1.PermissionType.WriteHistorizing)) {
|
|
754
|
-
|
|
780
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadUserAccessDenied);
|
|
781
|
+
break;
|
|
755
782
|
}
|
|
756
783
|
if (!this.canUserWriteHistorizingAttribute(context)) {
|
|
757
|
-
|
|
784
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadHistoryOperationUnsupported);
|
|
785
|
+
break;
|
|
758
786
|
}
|
|
759
787
|
// if the variable has no historizing in place reject
|
|
760
788
|
if (!this.getChildByName("HA Configuration")) {
|
|
761
|
-
|
|
789
|
+
callback(null, node_opcua_status_code_1.StatusCodes.BadNotSupported);
|
|
790
|
+
break;
|
|
762
791
|
}
|
|
763
792
|
// check if user is allowed to do that !
|
|
764
793
|
// TODO
|
|
765
794
|
this.historizing = !!writeValue.value?.value.value; // yes ! indeed !
|
|
766
|
-
|
|
795
|
+
callback(null, node_opcua_status_code_1.StatusCodes.Good);
|
|
796
|
+
break;
|
|
767
797
|
default:
|
|
768
798
|
super.writeAttribute(context, writeValue, callback);
|
|
769
799
|
break;
|
|
770
800
|
}
|
|
801
|
+
return undefined;
|
|
771
802
|
}
|
|
772
803
|
/**
|
|
773
804
|
|
|
@@ -952,7 +983,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
952
983
|
return;
|
|
953
984
|
}
|
|
954
985
|
if (this.isDisposed()) {
|
|
955
|
-
|
|
986
|
+
callback?.(null, new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadNodeIdUnknown }));
|
|
987
|
+
return;
|
|
956
988
|
}
|
|
957
989
|
const readImmediate = (innerCallback) => {
|
|
958
990
|
(0, node_opcua_assert_1.assert)(this.$dataValue instanceof node_opcua_data_value_1.DataValue);
|
|
@@ -960,23 +992,24 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
960
992
|
innerCallback(null, dataValue);
|
|
961
993
|
};
|
|
962
994
|
let func;
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
995
|
+
const answerStatusOnly = (statusCode) => (innerCallback) => innerCallback(null, new node_opcua_data_value_1.DataValue({ statusCode }));
|
|
996
|
+
if (context.isAccessRestricted(this)) {
|
|
997
|
+
// same gate as readValue(): a variable bound with a simple get()
|
|
998
|
+
// also gets a refreshFunc, sending every read down the asyncRefresh
|
|
999
|
+
// branch below - which calls the getter directly and never passes
|
|
1000
|
+
// through readValue(). Without this check here, a node hardened
|
|
1001
|
+
// with AccessRestrictions(EncryptionRequired) answered its value
|
|
1002
|
+
// over an unencrypted channel.
|
|
1003
|
+
func = answerStatusOnly(node_opcua_status_code_1.StatusCodes.BadSecurityModeInsufficient);
|
|
1004
|
+
}
|
|
1005
|
+
else if (!this.isReadable(context)) {
|
|
1006
|
+
func = answerStatusOnly(node_opcua_status_code_1.StatusCodes.BadNotReadable);
|
|
968
1007
|
}
|
|
969
1008
|
else if (!this.checkPermissionPrivate(context, node_opcua_types_1.PermissionType.Read)) {
|
|
970
|
-
func = (
|
|
971
|
-
const dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadUserAccessDenied });
|
|
972
|
-
innerCallback(null, dataValue);
|
|
973
|
-
};
|
|
1009
|
+
func = answerStatusOnly(node_opcua_status_code_1.StatusCodes.BadUserAccessDenied);
|
|
974
1010
|
}
|
|
975
1011
|
else if (!this.isUserReadable(context)) {
|
|
976
|
-
func = (
|
|
977
|
-
const dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadNotReadable });
|
|
978
|
-
innerCallback(null, dataValue);
|
|
979
|
-
};
|
|
1012
|
+
func = answerStatusOnly(node_opcua_status_code_1.StatusCodes.BadNotReadable);
|
|
980
1013
|
}
|
|
981
1014
|
else {
|
|
982
1015
|
const clock = (0, node_opcua_date_time_1.getCurrentClock)();
|
|
@@ -1004,6 +1037,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1004
1037
|
}
|
|
1005
1038
|
satisfy_callbacks(err);
|
|
1006
1039
|
}
|
|
1040
|
+
return undefined;
|
|
1007
1041
|
}
|
|
1008
1042
|
getWriteMask() {
|
|
1009
1043
|
return super.getWriteMask();
|
|
@@ -1147,7 +1181,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1147
1181
|
continue;
|
|
1148
1182
|
}
|
|
1149
1183
|
if (e.constructor.name !== Constructor.name) {
|
|
1150
|
-
|
|
1184
|
+
// c8 ignore next
|
|
1185
|
+
doDebug && debugLog("extObj.constructor.name ", e.constructor.name, "expected", Constructor.name);
|
|
1151
1186
|
return false;
|
|
1152
1187
|
}
|
|
1153
1188
|
}
|
|
@@ -1313,9 +1348,11 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1313
1348
|
(0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
|
|
1314
1349
|
(0, node_opcua_assert_1.assert)(typeof callback === "function");
|
|
1315
1350
|
if (typeof this._historyRead !== "function") {
|
|
1316
|
-
|
|
1351
|
+
callback?.(null, new node_opcua_types_1.HistoryReadResult({ statusCode: node_opcua_status_code_1.StatusCodes.BadNotReadable }));
|
|
1352
|
+
return;
|
|
1317
1353
|
}
|
|
1318
1354
|
this._historyRead(context, historyReadDetails, indexRange, dataEncoding, continuationData, callback);
|
|
1355
|
+
return undefined;
|
|
1319
1356
|
}
|
|
1320
1357
|
_historyReadRaw(_context, _historyReadRawModifiedDetails, _indexRange, _dataEncoding, _continuationData, _callback) {
|
|
1321
1358
|
throw new Error("");
|
|
@@ -1544,7 +1581,6 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1544
1581
|
}
|
|
1545
1582
|
}
|
|
1546
1583
|
exports.UAVariableImpl = UAVariableImpl;
|
|
1547
|
-
// tslint:disable:no-var-requires
|
|
1548
1584
|
const thenify_ex_1 = require("thenify-ex");
|
|
1549
1585
|
UAVariableImpl.prototype.asyncRefresh = (0, thenify_ex_1.withCallback)(UAVariableImpl.prototype.asyncRefresh);
|
|
1550
1586
|
UAVariableImpl.prototype.writeValue = (0, thenify_ex_1.withCallback)(UAVariableImpl.prototype.writeValue);
|
|
@@ -1683,14 +1719,15 @@ function _Variable_bind_with_async_refresh(options) {
|
|
|
1683
1719
|
(0, node_opcua_assert_1.assert)(!this.refreshFunc);
|
|
1684
1720
|
this.refreshFunc = options.refreshFunc;
|
|
1685
1721
|
/*
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1722
|
+
// TO DO : REVISIT THIS ASSUMPTION
|
|
1723
|
+
if (false && this.minimumSamplingInterval === 0) {
|
|
1724
|
+
// when a getter /timestamped_getter or async_getter is provided
|
|
1725
|
+
// samplingInterval cannot be 0, as the item value must be scanned to be updated.
|
|
1726
|
+
this.minimumSamplingInterval = _default_minimumSamplingInterval; // MonitoredItem.minimumSamplingInterval;
|
|
1727
|
+
// c8 ignore next
|
|
1728
|
+
doDebug && debugLog(`adapting minimumSamplingInterval on ${this.browseName.toString()} to ${this.minimumSamplingInterval}`);
|
|
1729
|
+
}
|
|
1730
|
+
*/
|
|
1694
1731
|
}
|
|
1695
1732
|
// variation 2
|
|
1696
1733
|
function _Variable_bind_with_timestamped_get(options) {
|
|
@@ -1773,11 +1810,12 @@ function _Variable_bind_with_simple_set(options) {
|
|
|
1773
1810
|
(0, node_opcua_assert_1.assert)(!this._timestamped_set_func);
|
|
1774
1811
|
(0, node_opcua_assert_1.assert)(!this._set_func);
|
|
1775
1812
|
//
|
|
1776
|
-
|
|
1777
|
-
|
|
1813
|
+
const set_func = turn_sync_to_async(options.set, 1);
|
|
1814
|
+
this._set_func = set_func;
|
|
1815
|
+
(0, node_opcua_assert_1.assert)(set_func.length === 2, " set function must have 2 arguments ( variant, callback)");
|
|
1778
1816
|
this._timestamped_set_func = (timestamped_value, callback) => {
|
|
1779
1817
|
(0, node_opcua_assert_1.assert)(timestamped_value instanceof node_opcua_data_value_1.DataValue);
|
|
1780
|
-
|
|
1818
|
+
set_func.call(this, timestamped_value.value, (err, statusCode) => {
|
|
1781
1819
|
// c8 ignore next
|
|
1782
1820
|
if (!err && !statusCode) {
|
|
1783
1821
|
errorLog(chalk_1.default.red("UAVariable Binding Error _set_func must return a StatusCode, check the bindVariable parameters"));
|
|
@@ -1788,7 +1826,7 @@ function _Variable_bind_with_simple_set(options) {
|
|
|
1788
1826
|
// record the value but still record the statusCode !
|
|
1789
1827
|
timestamped_value.statusCode = statusCode;
|
|
1790
1828
|
}
|
|
1791
|
-
callback(err, statusCode, timestamped_value);
|
|
1829
|
+
callback(err, statusCode ?? node_opcua_status_code_1.StatusCodes.BadInternalError, timestamped_value);
|
|
1792
1830
|
});
|
|
1793
1831
|
};
|
|
1794
1832
|
}
|
|
@@ -1894,7 +1932,7 @@ function changeUAVariableDataType(uaVariable, newDataType, valueLike) {
|
|
|
1894
1932
|
// change uaVariable.dataType
|
|
1895
1933
|
uaVariable.dataType = newDataTypeNode.nodeId;
|
|
1896
1934
|
uaVariable._basicDataType = null;
|
|
1897
|
-
uaVariable.$dataValue.value.dataType =
|
|
1935
|
+
uaVariable.$dataValue.value.dataType = newBaseDataType;
|
|
1898
1936
|
uaVariable.$dataValue.value = value;
|
|
1899
1937
|
// also change the value to ensure that we have a default value with the correct dataType
|
|
1900
1938
|
uaVariable._internal_set_value(value);
|