node-opcua-address-space 2.113.0 → 2.113.1

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.
Files changed (47) hide show
  1. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +2 -0
  2. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +2 -1
  3. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +3 -2
  4. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +2 -1
  5. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +2 -1
  6. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +2 -1
  7. package/dist/source/interfaces/i_set_state_options.d.ts +4 -0
  8. package/dist/source/interfaces/i_set_state_options.js +3 -0
  9. package/dist/source/interfaces/i_set_state_options.js.map +1 -0
  10. package/dist/source/ua_two_state_variable_ex.d.ts +2 -1
  11. package/dist/src/alarms_and_conditions/condition.js.map +1 -1
  12. package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +6 -5
  13. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +11 -10
  14. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
  15. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +3 -2
  16. package/dist/src/alarms_and_conditions/ua_condition_impl.js +9 -7
  17. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  18. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +3 -2
  19. package/dist/src/data_access/ua_multistate_discrete_impl.js +2 -2
  20. package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -1
  21. package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +3 -2
  22. package/dist/src/data_access/ua_multistate_value_discrete_impl.js +3 -3
  23. package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -1
  24. package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +2 -1
  25. package/dist/src/data_access/ua_two_state_discrete_impl.js +3 -3
  26. package/dist/src/data_access/ua_two_state_discrete_impl.js.map +1 -1
  27. package/dist/src/state_machine/ua_two_state_variable.d.ts +2 -1
  28. package/dist/src/state_machine/ua_two_state_variable.js +10 -8
  29. package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
  30. package/dist/src/ua_reference_type_impl.d.ts +1 -1
  31. package/dist/tsconfig_common.tsbuildinfo +1 -1
  32. package/package.json +2 -2
  33. package/source/interfaces/alarms_and_conditions/condition_info_i.ts +3 -0
  34. package/source/interfaces/alarms_and_conditions/condition_snapshot.ts +2 -1
  35. package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +4 -2
  36. package/source/interfaces/data_access/ua_multistate_discrete_ex.ts +2 -1
  37. package/source/interfaces/data_access/ua_multistate_value_discrete_ex.ts +2 -1
  38. package/source/interfaces/data_access/ua_two_state_discrete_ex.ts +2 -1
  39. package/source/interfaces/i_set_state_options.ts +4 -0
  40. package/source/ua_two_state_variable_ex.ts +2 -1
  41. package/src/alarms_and_conditions/condition.ts +1 -1
  42. package/src/alarms_and_conditions/condition_snapshot_impl.ts +14 -10
  43. package/src/alarms_and_conditions/ua_condition_impl.ts +10 -7
  44. package/src/data_access/ua_multistate_discrete_impl.ts +5 -3
  45. package/src/data_access/ua_multistate_value_discrete_impl.ts +5 -4
  46. package/src/data_access/ua_two_state_discrete_impl.ts +5 -3
  47. package/src/state_machine/ua_two_state_variable.ts +14 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-address-space",
3
- "version": "2.113.0",
3
+ "version": "2.113.1",
4
4
  "description": "pure nodejs OPCUA SDK - module address-space",
5
5
  "main": "./dist/src/index_current.js",
6
6
  "types": "./dist/source/index.d.ts",
@@ -84,7 +84,7 @@
84
84
  "internet of things"
85
85
  ],
86
86
  "homepage": "http://node-opcua.github.io/",
87
- "gitHead": "36db335391fedd39726990a1b37f7768da16466a",
87
+ "gitHead": "5990ba93b03458f3d7304c36a99e5eb814bbcf3c",
88
88
  "files": [
89
89
  "dist",
90
90
  "distHelpers",
@@ -10,6 +10,9 @@ export interface ConditionInfoOptions {
10
10
  quality?: StatusCode | null;
11
11
  severity?: UInt16 | null;
12
12
  retain?: boolean | null;
13
+
14
+ time?: Date | null;
15
+ receiveTime?: Date | null;
13
16
  }
14
17
 
15
18
  export interface ConditionInfo {
@@ -10,6 +10,7 @@ import { NodeId } from "node-opcua-nodeid";
10
10
  import { StatusCode } from "node-opcua-status-code";
11
11
  import { TimeZoneDataType } from "node-opcua-types";
12
12
  import { UtcTime } from "../state_machine/ua_state_machine_type";
13
+ import { ISetStateOptions } from "../i_set_state_options";
13
14
 
14
15
  export interface ConditionSnapshot {
15
16
  on(eventName: "value_changed", eventHandler: (node: UAVariable, variant: Variant) => void): this;
@@ -62,7 +63,7 @@ export interface ConditionSnapshot extends EventEmitter {
62
63
  * @param value {Boolean}
63
64
  * @return void
64
65
  */
65
- setEnabledState(value: boolean): void;
66
+ setEnabledState(value: boolean, options?: ISetStateOptions): void;
66
67
  /**
67
68
  * @method getEnabledStateAsString
68
69
  * @return {String}
@@ -4,10 +4,11 @@ import { NodeId } from "node-opcua-nodeid";
4
4
  import { UACondition_Base } from "node-opcua-nodeset-ua";
5
5
  import { StatusCode } from "node-opcua-status-code";
6
6
  import { TimeZoneDataType } from "node-opcua-types";
7
+ import { DataType } from "node-opcua-basic-types";
8
+ import { ISetStateOptions } from "../i_set_state_options";
7
9
  import { UATwoStateVariableEx } from "../../ua_two_state_variable_ex";
8
10
  import { ConditionInfoOptions } from "./condition_info_i";
9
11
  import { ConditionSnapshot } from "./condition_snapshot";
10
- import { DataType } from "node-opcua-basic-types";
11
12
 
12
13
 
13
14
 
@@ -26,6 +27,7 @@ export interface UAConditionHelper {
26
27
  on(eventName: "branch_deleted", eventHandler: (branchId: string) => void): this;
27
28
  }
28
29
 
30
+
29
31
  export interface UAConditionHelper extends UABaseEventHelper {
30
32
  getBranchCount(): number;
31
33
  getBranches(): ConditionSnapshot[];
@@ -34,7 +36,7 @@ export interface UAConditionHelper extends UABaseEventHelper {
34
36
  deleteBranch(branch: ConditionSnapshot): void;
35
37
  getEnabledState(): boolean;
36
38
  getEnabledStateAsString(): string;
37
- setEnabledState(requestedEnabledState: boolean): StatusCode;
39
+ setEnabledState(requestedEnabledState: boolean, options?: ISetStateOptions): StatusCode;
38
40
  setReceiveTime(time: Date): void;
39
41
  setLocalTime(time: TimeZoneDataType): void;
40
42
  setTime(time: Date): void;
@@ -13,6 +13,7 @@ import { DataType, Variant } from "node-opcua-variant";
13
13
  import { StatusCode } from "node-opcua-status-code";
14
14
  import { UAMultiStateDiscrete_Base } from "node-opcua-nodeset-ua";
15
15
  import { UAVariableT } from "node-opcua-address-space-base";
16
+ import { ISetStateOptions } from "../i_set_state_options";
16
17
 
17
18
  export { UAMultiStateDiscrete } from "node-opcua-nodeset-ua";
18
19
 
@@ -21,6 +22,6 @@ export interface UAMultiStateDiscreteEx<T, DT extends DataType> extends UAVariab
21
22
  getValue(): number;
22
23
  getValueAsString(): string;
23
24
  getIndex(value: string): number;
24
- setValue(value: string | number): void;
25
+ setValue(value: string | number, options?: ISetStateOptions): void;
25
26
  checkVariantCompatibility(value: Variant): StatusCode;
26
27
  }
@@ -5,6 +5,7 @@ import { DataType, Variant } from "node-opcua-variant";
5
5
  import { Int64, UInt64 } from "node-opcua-basic-types";
6
6
  import { UAMultiStateValueDiscrete_Base } from "node-opcua-nodeset-ua";
7
7
  import { UAVariableT } from "node-opcua-address-space-base";
8
+ import { ISetStateOptions } from "../i_set_state_options";
8
9
 
9
10
  /**
10
11
  * @see https://reference.opcfoundation.org/v104/Core/docs/Part8/5.3.3/#5.3.3.4
@@ -27,7 +28,7 @@ export interface UAMultiStateValueDiscreteEx<T, DT extends DataType>
27
28
  getValueAsString(): string;
28
29
  getValueAsNumber(): number;
29
30
 
30
- setValue(value: string | number | Int64): void;
31
+ setValue(value: string | number | Int64, options?: ISetStateOptions): void;
31
32
 
32
33
  findValueAsText(value: number | UInt64): Variant;
33
34
  }
@@ -2,6 +2,7 @@ import { LocalizedTextLike } from "node-opcua-data-model";
2
2
  import { DataType } from "node-opcua-variant";
3
3
  import { UAVariableT } from "node-opcua-address-space-base";
4
4
  import { UATwoStateDiscrete_Base } from "node-opcua-nodeset-ua";
5
+ import { ISetStateOptions } from "../i_set_state_options";
5
6
 
6
7
  /**
7
8
  * @see https://reference.opcfoundation.org/v104/Core/VariableTypes/TwoStateDiscreteType/
@@ -10,5 +11,5 @@ export interface UATwoStateDiscreteEx extends UAVariableT<boolean, DataType.Bool
10
11
  // --- helpers ---
11
12
  getValue(): boolean;
12
13
  getValueAsString(): string;
13
- setValue(value: boolean | LocalizedTextLike): void;
14
+ setValue(value: boolean | LocalizedTextLike, options?: ISetStateOptions): void;
14
15
  }
@@ -0,0 +1,4 @@
1
+ export interface ISetStateOptions {
2
+ transitionTime?: Date;
3
+ effectiveTransitionTime?: Date;
4
+ }
@@ -5,6 +5,7 @@ import { UAVariableT } from "node-opcua-address-space-base";
5
5
  import { LocalizedText } from "node-opcua-data-model";
6
6
  import { UAStateVariable, UATwoStateVariable_Base } from "node-opcua-nodeset-ua";
7
7
  import { DataType } from "node-opcua-variant";
8
+ import { ISetStateOptions } from "./interfaces/i_set_state_options";
8
9
 
9
10
  /**
10
11
  * @see https://reference.opcfoundation.org/v104/Core/docs/Part9/5.2/
@@ -18,7 +19,7 @@ export interface UATwoStateVariableHelper {
18
19
  readonly isTrueSubStateOf: UAStateVariable<LocalizedText> | null;
19
20
 
20
21
  // --- helpers ---
21
- setValue(boolValue: boolean): void;
22
+ setValue(boolValue: boolean, options?: ISetStateOptions): void;
22
23
 
23
24
  getValue(): boolean;
24
25
 
@@ -21,7 +21,7 @@ export function _setAckedState(
21
21
  if (ackedState && requestedAckedState) {
22
22
  return StatusCodes.BadConditionBranchAlreadyAcked;
23
23
  }
24
- self._set_twoStateVariable("AckedState", requestedAckedState);
24
+ self._set_twoStateVariable("AckedState", requestedAckedState,/* effective transition time will be now*/);
25
25
  return StatusCodes.Good;
26
26
  }
27
27
 
@@ -17,6 +17,7 @@ import { DataType, Variant } from "node-opcua-variant";
17
17
 
18
18
  import { ConditionSnapshot } from "../../source/interfaces/alarms_and_conditions/condition_snapshot";
19
19
  import { UtcTime } from "../../source/interfaces/state_machine/ua_state_machine_type";
20
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
20
21
  import { EventData } from "../event_data";
21
22
  import { UATwoStateVariableImpl } from "../state_machine/ua_two_state_variable";
22
23
  import { _setAckedState } from "./condition";
@@ -136,6 +137,7 @@ const _varTable = {
136
137
  "EnabledState.EffectiveDisplayName": 1,
137
138
  "EnabledState.Id": 1,
138
139
  "EnabledState.TransitionTime": 1,
140
+ "EnabledState.EffectiveTransitionTime": 1,
139
141
  EventId: 1,
140
142
  EventType: 1,
141
143
  LocalTime: 1,
@@ -143,6 +145,8 @@ const _varTable = {
143
145
  SourceNode: 1,
144
146
  Time: 1
145
147
  };
148
+
149
+
146
150
  type FullBrowsePath = string;
147
151
  export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnapshot {
148
152
  public static normalizeName = normalizeName;
@@ -327,8 +331,8 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
327
331
  * @param value {Boolean}
328
332
  * @return void
329
333
  */
330
- public setEnabledState(value: boolean): void {
331
- return this._set_twoStateVariable("EnabledState", value);
334
+ public setEnabledState(value: boolean, options?: ISetStateOptions): void {
335
+ return this._set_twoStateVariable("EnabledState", value, options);
332
336
  }
333
337
 
334
338
  /**
@@ -613,7 +617,7 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
613
617
  return this._get_twoStateVariable("ConfirmedState");
614
618
  }
615
619
 
616
- public setConfirmedStateIfExists(confirmedState: boolean): void {
620
+ public setConfirmedStateIfExists(confirmedState: boolean, options?: ISetStateOptions): void {
617
621
  confirmedState = !!confirmedState;
618
622
  const acknowledgeableCondition = this.condition as UAAcknowledgeableCondition;
619
623
  if (!acknowledgeableCondition.confirmedState) {
@@ -622,7 +626,7 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
622
626
  return;
623
627
  }
624
628
  // todo deal with Error code BadConditionBranchAlreadyConfirmed
625
- return this._set_twoStateVariable("ConfirmedState", confirmedState);
629
+ return this._set_twoStateVariable("ConfirmedState", confirmedState, options);
626
630
  }
627
631
 
628
632
  public setConfirmedState(confirmedState: boolean): void {
@@ -647,21 +651,21 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
647
651
  * @method setSuppressedState
648
652
  * @param suppressed {Boolean}
649
653
  */
650
- public setSuppressedState(suppressed: boolean): void {
654
+ public setSuppressedState(suppressed: boolean, options?: ISetStateOptions): void {
651
655
  suppressed = !!suppressed;
652
- this._set_twoStateVariable("SuppressedState", suppressed);
656
+ this._set_twoStateVariable("SuppressedState", suppressed, options);
653
657
  }
654
658
 
655
659
  public getActiveState(): boolean {
656
660
  return this._get_twoStateVariable("ActiveState");
657
661
  }
658
662
 
659
- public setActiveState(newActiveState: boolean): StatusCode {
663
+ public setActiveState(newActiveState: boolean, options?: ISetStateOptions): StatusCode {
660
664
  // xx var activeState = self.getActiveState();
661
665
  // xx if (activeState === newActiveState) {
662
666
  // xx return StatusCodes.Bad;
663
667
  // xx }
664
- this._set_twoStateVariable("ActiveState", newActiveState);
668
+ this._set_twoStateVariable("ActiveState", newActiveState, options);
665
669
  return StatusCodes.Good;
666
670
  }
667
671
 
@@ -704,7 +708,7 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
704
708
  * @param value
705
709
  * @private
706
710
  */
707
- public _set_twoStateVariable(varName: string, value: boolean): void {
711
+ public _set_twoStateVariable(varName: string, value: boolean, options?: ISetStateOptions): void {
708
712
  value = !!value;
709
713
 
710
714
  const hrKey = ConditionSnapshotImpl.normalizeName(varName);
@@ -733,7 +737,7 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
733
737
  // also change ConditionNode if we are on currentBranch
734
738
  if (this.isCurrentBranch()) {
735
739
  assert(twoStateNode instanceof UATwoStateVariableImpl);
736
- twoStateNode.setValue(value as boolean);
740
+ twoStateNode.setValue(value as boolean, options);
737
741
  }
738
742
  this.emit("value_changed", node, variant);
739
743
  }
@@ -41,6 +41,7 @@ import { ConditionInfoOptions } from "../../source/interfaces/alarms_and_conditi
41
41
  import { UAConditionEx } from "../../source/interfaces/alarms_and_conditions/ua_condition_ex";
42
42
  import { ConditionSnapshot } from "../../source/interfaces/alarms_and_conditions/condition_snapshot";
43
43
  import { InstantiateConditionOptions } from "../../source/interfaces/alarms_and_conditions/instantiate_condition_options";
44
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
44
45
 
45
46
  import { AddressSpacePrivate } from "../address_space_private";
46
47
  import { _install_TwoStateVariable_machinery } from "../state_machine/ua_two_state_variable";
@@ -277,7 +278,7 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
277
278
  * returns {StatusCode} StatusCodes.Good if successful or BadConditionAlreadyEnabled/BadConditionAlreadyDisabled
278
279
  * @private
279
280
  */
280
- public _setEnabledState(requestedEnabledState: boolean): StatusCode {
281
+ public _setEnabledState(requestedEnabledState: boolean, options?: ISetStateOptions): StatusCode {
281
282
  assert(typeof requestedEnabledState === "boolean");
282
283
 
283
284
  const enabledState = this.getEnabledState();
@@ -288,7 +289,7 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
288
289
  return StatusCodes.BadConditionAlreadyDisabled;
289
290
  }
290
291
 
291
- this._branch0.setEnabledState(requestedEnabledState);
292
+ this._branch0.setEnabledState(requestedEnabledState, options);
292
293
  // conditionNode.enabledState.setValue(requestedEnabledState);
293
294
 
294
295
  // xx assert(conditionNode.enabledState.id.readValue().value.value === requestedEnabledState,"sanity check 1");
@@ -346,8 +347,8 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
346
347
  * @param requestedEnabledState {Boolean}
347
348
  * @private
348
349
  */
349
- public setEnabledState(requestedEnabledState: boolean): StatusCode {
350
- return this._setEnabledState(requestedEnabledState);
350
+ public setEnabledState(requestedEnabledState: boolean, options?:ISetStateOptions): StatusCode {
351
+ return this._setEnabledState(requestedEnabledState, options);
351
352
  }
352
353
 
353
354
  /**
@@ -491,11 +492,13 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
491
492
 
492
493
  const branch = this.currentBranch();
493
494
 
494
- const now = new Date();
495
+ const currentDefaultDate = new Date();
496
+ const time = conditionInfo.time || currentDefaultDate;
497
+ const receiveTime = conditionInfo.receiveTime || currentDefaultDate;
495
498
  // install the eventTimestamp
496
499
  // set the received Time
497
- branch.setTime(now);
498
- branch.setReceiveTime(now);
500
+ branch.setTime(time);
501
+ branch.setReceiveTime(receiveTime);
499
502
 
500
503
  // note : in 1.04 LocalTime property is optional
501
504
  if (Object.prototype.hasOwnProperty.call(this, "localTime")) {
@@ -11,6 +11,8 @@ import { BindVariableOptions, INamespace, UAVariable, UAProperty } from "node-op
11
11
  import { UAMultiStateDiscrete, UAMultiStateDiscrete_Base } from "node-opcua-nodeset-ua";
12
12
  import { registerNodePromoter } from "../../source/loader/register_node_promoter";
13
13
  import { UAVariableImpl } from "../ua_variable_impl";
14
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
15
+
14
16
  import { AddMultiStateDiscreteOptions } from "../../source/address_space_ts";
15
17
  import { add_dataItem_stuff } from "./add_dataItem_stuff";
16
18
 
@@ -21,7 +23,7 @@ export interface UAMultiStateDiscreteEx<T, DT extends DataType> extends UAMultiS
21
23
  getValue(): number;
22
24
  getValueAsString(): string;
23
25
  getIndex(value: string): number;
24
- setValue(value: string | number): void;
26
+ setValue(value: string | number, options?: ISetStateOptions): void;
25
27
  checkVariantCompatibility(value: Variant): StatusCode;
26
28
  }
27
29
 
@@ -50,13 +52,13 @@ export class UAMultiStateDiscreteImpl<T, DT extends DataType> extends UAVariable
50
52
  return index;
51
53
  }
52
54
 
53
- public setValue(value: string | number): void {
55
+ public setValue(value: string | number, options?: ISetStateOptions): void {
54
56
  if (typeof value === "string") {
55
57
  const index = this.getIndex(value);
56
58
  if (index < 0) {
57
59
  throw new Error("UAMultiStateDiscrete#setValue invalid multi state value provided : " + value);
58
60
  }
59
- return this.setValue(index);
61
+ return this.setValue(index, options);
60
62
  }
61
63
  const arrayEnumStrings = this.enumStrings.readValue().value.value;
62
64
  if (value >= arrayEnumStrings.length) {
@@ -17,6 +17,7 @@ import { registerNodePromoter } from "../../source/loader/register_node_promoter
17
17
  import { coerceEnumValues } from "../../source/helpers/coerce_enum_value";
18
18
  import { UAMultiStateValueDiscreteEx } from "../../source/interfaces/data_access/ua_multistate_value_discrete_ex";
19
19
  import { AddMultiStateValueDiscreteOptions } from "../../source/address_space_ts";
20
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
20
21
  import { UAVariableImpl } from "../ua_variable_impl";
21
22
 
22
23
  import { add_dataItem_stuff } from "./add_dataItem_stuff";
@@ -50,7 +51,7 @@ export class UAMultiStateValueDiscreteImpl<T, DT extends DataType>
50
51
  extends UAVariableImpl
51
52
  implements UAMultiStateValueDiscreteEx<T, DT>
52
53
  {
53
- public setValue(value: string | number | Int64): void {
54
+ public setValue(value: string | number | Int64, options?: ISetStateOptions): void {
54
55
  if (typeof value === "string") {
55
56
  const enumValues = this.enumValues.readValue().value.value;
56
57
  const selected = enumValues.filter((a: any) => a.displayName.text === value)[0];
@@ -60,7 +61,7 @@ export class UAMultiStateValueDiscreteImpl<T, DT extends DataType>
60
61
  throw new Error("cannot find enum string " + value + " in " + enumValues.toString());
61
62
  }
62
63
  } else {
63
- this._setValue(coerceUInt64(value));
64
+ this._setValue(coerceUInt64(value), options);
64
65
  }
65
66
  }
66
67
 
@@ -116,7 +117,7 @@ export class UAMultiStateValueDiscreteImpl<T, DT extends DataType>
116
117
  *
117
118
  * @private
118
119
  */
119
- public _setValue(value: Int64): void {
120
+ public _setValue(value: Int64, options?: ISetStateOptions): void {
120
121
  // check that value is in bound
121
122
  if (!this._isValueInRange(coerceInt32(value))) {
122
123
  throw new Error("UAMultiStateValueDiscrete#_setValue out of range " + value);
@@ -301,4 +302,4 @@ export function validateDataType(dataTypeValue: any): void {
301
302
  if (typeof dataTypeValue !== "number" || validTypes.indexOf(dataTypeValue) < 0) {
302
303
  throw new Error(`Invalid DataType in UAMultiStateValueDiscrete => ${dataTypeValue.toString()}`);
303
304
  }
304
- }
305
+ }
@@ -10,9 +10,11 @@ import { UAVariableImpl } from "../ua_variable_impl";
10
10
  import { registerNodePromoter } from "../../source/loader/register_node_promoter";
11
11
  import { AddTwoStateDiscreteOptions } from "../../source/address_space_ts";
12
12
  import { UATwoStateDiscreteEx } from "../../source/interfaces/data_access/ua_two_state_discrete_ex";
13
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
13
14
 
14
15
  import { add_dataItem_stuff } from "./add_dataItem_stuff";
15
16
 
17
+
16
18
  export interface UATwoStateDiscreteImpl {
17
19
  falseState: UAProperty<LocalizedText, /*c*/ DataType.LocalizedText>;
18
20
  trueState: UAProperty<LocalizedText, /*c*/ DataType.LocalizedText>;
@@ -58,15 +60,15 @@ export class UATwoStateDiscreteImpl extends UAVariableImpl implements UATwoState
58
60
  );
59
61
  }
60
62
  }
61
- setValue(value: boolean | LocalizedTextLike): void {
63
+ setValue(value: boolean | LocalizedTextLike, options?: ISetStateOptions): void {
62
64
  if (typeof value === "boolean") {
63
65
  this.setValueFromSource({ dataType: DataType.Boolean, value });
64
66
  } else {
65
67
  const text: string = (typeof value === "string" ? value : value.text) || "";
66
68
  if (text === this.getTrueStateAsString()) {
67
- this.setValue(true);
69
+ this.setValue(true, options);
68
70
  } else if (text === this.getFalseStateAsString()) {
69
- this.setValue(false);
71
+ this.setValue(false, options);
70
72
  } else {
71
73
  throw new Error("setValue invalid value " + value);
72
74
  }
@@ -21,6 +21,8 @@ import { AddTwoStateVariableOptions } from "../../source/address_space_ts";
21
21
  import { UATwoStateVariableEx } from "../../source/ua_two_state_variable_ex";
22
22
  // private types
23
23
  import { UAVariableImpl, UAVariableImplT } from "../ua_variable_impl";
24
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
25
+
24
26
 
25
27
  const hasTrueSubState_ReferenceTypeNodeId = resolveNodeId("HasTrueSubState");
26
28
  const hasFalseSubState_ReferenceTypeNodeId = resolveNodeId("HasFalseSubState");
@@ -54,19 +56,23 @@ const hasFalseSubState_ReferenceTypeNodeId = resolveNodeId("HasFalseSubState");
54
56
  // TwoStateVariableType
55
57
  // <StateIdentifier> Defined in Clause 5.4.3 Optional
56
58
 
57
- function _updateTransitionTime(node: UATwoStateVariableEx, _subState?: UAVariable) {
59
+ function _updateTransitionTime(node: UATwoStateVariableEx, _subState?: UAVariable, options?: ISetStateOptions) {
58
60
  // TransitionTime specifies the time when the current state was entered.
59
61
  if (node.transitionTime) {
60
- node.transitionTime.setValueFromSource({ dataType: DataType.DateTime, value: new Date() });
62
+ const transitionTime = options?.transitionTime || new Date();
63
+ node.transitionTime.setValueFromSource({ dataType: DataType.DateTime, value: transitionTime });
61
64
  }
62
65
  }
63
66
 
64
- function _updateEffectiveTransitionTime(node: UATwoStateVariableImpl) {
67
+ function _updateEffectiveTransitionTime(node: UATwoStateVariableImpl,options?: ISetStateOptions) {
65
68
  if (node.effectiveTransitionTime) {
69
+
70
+ const effectiveTransitionTime = options?.effectiveTransitionTime || new Date();
71
+
66
72
  // because subStateNode ",subStateNode.browseName.toString());
67
73
  node.effectiveTransitionTime.setValueFromSource({
68
74
  dataType: DataType.DateTime,
69
- value: new Date()
75
+ value: effectiveTransitionTime
70
76
  });
71
77
  }
72
78
  }
@@ -308,7 +314,7 @@ export class UATwoStateVariableImpl extends UAVariableImplT<LocalizedText, DataT
308
314
  * @method setValue
309
315
  * @param boolValue {Boolean}
310
316
  */
311
- public setValue(boolValue: boolean): void {
317
+ public setValue(boolValue: boolean, options?: ISetStateOptions): void {
312
318
  assert(typeof boolValue === "boolean");
313
319
  const dataValue = this.id!.readValue();
314
320
  const oldValue = dataValue.value.value;
@@ -317,8 +323,8 @@ export class UATwoStateVariableImpl extends UAVariableImplT<LocalizedText, DataT
317
323
  }
318
324
  //
319
325
  this.id.setValueFromSource(new Variant({ dataType: DataType.Boolean, value: boolValue }));
320
- _updateTransitionTime(this);
321
- _updateEffectiveTransitionTime(this);
326
+ _updateTransitionTime(this, undefined, options);
327
+ _updateEffectiveTransitionTime(this, options);
322
328
  }
323
329
 
324
330
  /**
@@ -369,7 +375,7 @@ export class UATwoStateVariableImpl extends UAVariableImplT<LocalizedText, DataT
369
375
  const addressSpace = this.addressSpace;
370
376
  // add event handle
371
377
  const subState = addressSpace.findNode(reference.nodeId) as UAVariable;
372
- subState.on("value_changed", _updateEffectiveTransitionTime.bind(null, this));
378
+ subState.on("value_changed", _updateEffectiveTransitionTime.bind(null, this, undefined));
373
379
  }
374
380
  }
375
381
  }