node-opcua-server 2.131.0 → 2.133.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.
Files changed (43) hide show
  1. package/dist/addressSpace_accessor.js +1 -1
  2. package/dist/addressSpace_accessor.js.map +1 -1
  3. package/dist/base_server.d.ts +0 -11
  4. package/dist/base_server.js +0 -11
  5. package/dist/base_server.js.map +1 -1
  6. package/dist/filter/extract_event_fields.d.ts +1 -1
  7. package/dist/filter/extract_event_fields.js +1 -1
  8. package/dist/monitored_item.d.ts +2 -6
  9. package/dist/monitored_item.js +2 -6
  10. package/dist/monitored_item.js.map +1 -1
  11. package/dist/opcua_server.d.ts +2 -19
  12. package/dist/opcua_server.js +2 -17
  13. package/dist/opcua_server.js.map +1 -1
  14. package/dist/register_server_manager.d.ts +0 -4
  15. package/dist/register_server_manager.js +0 -4
  16. package/dist/register_server_manager.js.map +1 -1
  17. package/dist/server_end_point.d.ts +0 -16
  18. package/dist/server_end_point.js +0 -16
  19. package/dist/server_end_point.js.map +1 -1
  20. package/dist/server_engine.d.ts +8 -24
  21. package/dist/server_engine.js +43 -57
  22. package/dist/server_engine.js.map +1 -1
  23. package/dist/server_publish_engine.d.ts +0 -1
  24. package/dist/server_publish_engine.js +0 -1
  25. package/dist/server_publish_engine.js.map +1 -1
  26. package/dist/server_session.d.ts +0 -6
  27. package/dist/server_session.js +1 -7
  28. package/dist/server_session.js.map +1 -1
  29. package/dist/server_subscription.d.ts +2 -1
  30. package/dist/server_subscription.js +2 -1
  31. package/dist/server_subscription.js.map +1 -1
  32. package/package.json +43 -43
  33. package/source/addressSpace_accessor.ts +2 -2
  34. package/source/base_server.ts +0 -11
  35. package/source/filter/extract_event_fields.ts +1 -1
  36. package/source/monitored_item.ts +2 -6
  37. package/source/opcua_server.ts +2 -25
  38. package/source/register_server_manager.ts +0 -4
  39. package/source/server_end_point.ts +0 -16
  40. package/source/server_engine.ts +508 -500
  41. package/source/server_publish_engine.ts +0 -1
  42. package/source/server_session.ts +2 -8
  43. package/source/server_subscription.ts +2 -1
@@ -41,7 +41,7 @@ import { BrowseResult } from "node-opcua-service-browse";
41
41
  import { UInt32 } from "node-opcua-basic-types";
42
42
  import { CreateSubscriptionRequestLike } from "node-opcua-client";
43
43
  import { DataTypeIds, MethodIds, ObjectIds, VariableIds } from "node-opcua-constants";
44
- import { getCurrentClock, minOPCUADate } from "node-opcua-date-time";
44
+ import { getCurrentClock, getMinOPCUADate } from "node-opcua-date-time";
45
45
  import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog, traceFromThisProjectOnly } from "node-opcua-debug";
46
46
  import { nodesets } from "node-opcua-nodesets";
47
47
  import { ObjectRegistry } from "node-opcua-object-registry";
@@ -533,7 +533,6 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
533
533
 
534
534
  /**
535
535
  * register a function that will be called when the server will perform its shut down.
536
- * @method registerShutdownTask
537
536
  */
538
537
  public registerShutdownTask(task: ServerEngineShutdownTask): void {
539
538
  assert(typeof task === "function");
@@ -541,7 +540,6 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
541
540
  }
542
541
 
543
542
  /**
544
- * @method shutdown
545
543
  */
546
544
  public async shutdown(): Promise<void> {
547
545
  debugLog("ServerEngine#shutdown");
@@ -687,7 +685,6 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
687
685
  });
688
686
  }
689
687
  /**
690
- * @method secondsTillShutdown
691
688
  * @return the approximate number of seconds until the server will be shut down. The
692
689
  * value is only relevant once the state changes into SHUTDOWN.
693
690
  */
@@ -742,12 +739,7 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
742
739
  }
743
740
 
744
741
  /**
745
- * @method initialize
746
- * @async
747
742
  *
748
- * @param options {Object}
749
- * @param options.nodeset_filename {String} - [option](default : 'mini.Node.Set2.xml' )
750
- * @param callback
751
743
  */
752
744
  public initialize(options: OPCUAServerOptions, callback: (err?: Error | null) => void): void {
753
745
  assert(!this.addressSpace); // check that 'initialize' has not been already called
@@ -773,464 +765,482 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
773
765
  assert(serverNamespace.index === 1);
774
766
  }
775
767
  // eslint-disable-next-line max-statements
776
- generateAddressSpace(this.addressSpace, options.nodeset_filename).catch((err) => {
777
- console.log(err.message);
778
- callback(err);
779
- }).then(() => {
780
- /* istanbul ignore next */
781
- if (!this.addressSpace) {
782
- throw new Error("Internal error");
783
- }
784
- const addressSpace = this.addressSpace;
785
-
786
- const endTime = new Date();
787
- debugLog("Loading ", options.nodeset_filename, " done : ", endTime.getTime() - startTime.getTime(), " ms");
788
-
789
- const bindVariableIfPresent = (nodeId: NodeId, opts: any) => {
790
- assert(!nodeId.isEmpty());
791
- const obj = addressSpace.findNode(nodeId);
792
- if (obj) {
793
- __bindVariable(this, nodeId, opts);
768
+ generateAddressSpace(this.addressSpace, options.nodeset_filename)
769
+ .catch((err) => {
770
+ console.log(err.message);
771
+ callback(err);
772
+ })
773
+ .then(() => {
774
+ /* istanbul ignore next */
775
+ if (!this.addressSpace) {
776
+ throw new Error("Internal error");
794
777
  }
795
- return obj;
796
- };
797
-
798
- // -------------------------------------------- install default get/put handler
799
- const server_NamespaceArray_Id = makeNodeId(VariableIds.Server_NamespaceArray); // ns=0;i=2255
800
- bindVariableIfPresent(server_NamespaceArray_Id, {
801
- get() {
802
- return new Variant({
803
- arrayType: VariantArrayType.Array,
804
- dataType: DataType.String,
805
- value: addressSpace.getNamespaceArray().map((x) => x.namespaceUri)
806
- });
807
- },
808
- set: null // read only
809
- });
810
-
811
- const server_NameUrn_var = new Variant({
812
- arrayType: VariantArrayType.Array,
813
- dataType: DataType.String,
814
- value: [
815
- this.serverNameUrn // this is us !
816
- ]
817
- });
818
- const server_ServerArray_Id = makeNodeId(VariableIds.Server_ServerArray); // ns=0;i=2254
778
+ const addressSpace = this.addressSpace;
819
779
 
820
- bindVariableIfPresent(server_ServerArray_Id, {
821
- get() {
822
- return server_NameUrn_var;
823
- },
824
- set: null // read only
825
- });
780
+ const endTime = new Date();
781
+ debugLog("Loading ", options.nodeset_filename, " done : ", endTime.getTime() - startTime.getTime(), " ms");
826
782
 
827
- // fix DefaultUserRolePermissions and DefaultUserRolePermissions
828
- // of namespaces
829
- const namespaces = makeNodeId(ObjectIds.Server_Namespaces);
830
- const namespacesNode = addressSpace.findNode(namespaces) as UAObject;
831
- if (namespacesNode) {
832
- for (const ns of namespacesNode.getComponents()) {
833
- const defaultUserRolePermissions = ns.getChildByName("DefaultUserRolePermissions") as UAVariable | null;
834
- if (defaultUserRolePermissions) {
835
- defaultUserRolePermissions.setValueFromSource({ dataType: DataType.Null });
836
- }
837
- const defaultRolePermissions = ns.getChildByName("DefaultRolePermissions") as UAVariable | null;
838
- if (defaultRolePermissions) {
839
- defaultRolePermissions.setValueFromSource({ dataType: DataType.Null });
783
+ const bindVariableIfPresent = (nodeId: NodeId, opts: any) => {
784
+ assert(!nodeId.isEmpty());
785
+ const obj = addressSpace.findNode(nodeId);
786
+ if (obj) {
787
+ __bindVariable(this, nodeId, opts);
840
788
  }
841
- }
842
- }
843
-
844
- const bindStandardScalar = (id: number, dataType: DataType, func: () => any, setter_func?: (value: any) => void) => {
845
- assert(typeof id === "number", "expecting id to be a number");
846
- assert(typeof func === "function");
847
- assert(typeof setter_func === "function" || !setter_func);
848
- assert(dataType !== null); // check invalid dataType
849
-
850
- let setter_func2 = null;
851
- if (setter_func) {
852
- setter_func2 = (variant: Variant) => {
853
- const variable2 = !!variant.value;
854
- setter_func(variable2);
855
- return StatusCodes.Good;
856
- };
857
- }
858
-
859
- const nodeId = makeNodeId(id);
860
-
861
- // make sur the provided function returns a valid value for the variant type
862
- // This test may not be exhaustive but it will detect obvious mistakes.
863
-
864
- /* istanbul ignore next */
865
- if (!isValidVariant(VariantArrayType.Scalar, dataType, func())) {
866
- errorLog("func", func());
867
- throw new Error("bindStandardScalar : func doesn't provide an value of type " + DataType[dataType]);
868
- }
789
+ return obj;
790
+ };
869
791
 
870
- return bindVariableIfPresent(nodeId, {
792
+ // -------------------------------------------- install default get/put handler
793
+ const server_NamespaceArray_Id = makeNodeId(VariableIds.Server_NamespaceArray); // ns=0;i=2255
794
+ bindVariableIfPresent(server_NamespaceArray_Id, {
871
795
  get() {
872
796
  return new Variant({
873
- arrayType: VariantArrayType.Scalar,
874
- dataType,
875
- value: func()
797
+ arrayType: VariantArrayType.Array,
798
+ dataType: DataType.String,
799
+ value: addressSpace.getNamespaceArray().map((x) => x.namespaceUri)
876
800
  });
877
801
  },
878
- set: setter_func2
802
+ set: null // read only
879
803
  });
880
- };
881
-
882
- const bindStandardArray = (id: number, variantDataType: DataType, dataType: any, func: () => any[]) => {
883
- assert(typeof func === "function");
884
- assert(variantDataType !== null); // check invalid dataType
885
-
886
- const nodeId = makeNodeId(id);
887
804
 
888
- // make sur the provided function returns a valid value for the variant type
889
- // This test may not be exhaustive but it will detect obvious mistakes.
890
- assert(isValidVariant(VariantArrayType.Array, variantDataType, func()));
805
+ const server_NameUrn_var = new Variant({
806
+ arrayType: VariantArrayType.Array,
807
+ dataType: DataType.String,
808
+ value: [
809
+ this.serverNameUrn // this is us !
810
+ ]
811
+ });
812
+ const server_ServerArray_Id = makeNodeId(VariableIds.Server_ServerArray); // ns=0;i=2254
891
813
 
892
- bindVariableIfPresent(nodeId, {
814
+ bindVariableIfPresent(server_ServerArray_Id, {
893
815
  get() {
894
- const value = func();
895
- assert(Array.isArray(value));
896
- return new Variant({
897
- arrayType: VariantArrayType.Array,
898
- dataType: variantDataType,
899
- value
900
- });
816
+ return server_NameUrn_var;
901
817
  },
902
818
  set: null // read only
903
819
  });
904
- };
905
-
906
- bindStandardScalar(VariableIds.Server_EstimatedReturnTime, DataType.DateTime, () => minOPCUADate);
907
820
 
908
- // TimeZoneDataType
909
- const timeZoneDataType = addressSpace.findDataType(resolveNodeId(DataTypeIds.TimeZoneDataType))!;
821
+ // fix DefaultUserRolePermissions and DefaultUserRolePermissions
822
+ // of namespaces
823
+ const namespaces = makeNodeId(ObjectIds.Server_Namespaces);
824
+ const namespacesNode = addressSpace.findNode(namespaces) as UAObject;
825
+ if (namespacesNode) {
826
+ for (const ns of namespacesNode.getComponents()) {
827
+ const defaultUserRolePermissions = ns.getChildByName("DefaultUserRolePermissions") as UAVariable | null;
828
+ if (defaultUserRolePermissions) {
829
+ defaultUserRolePermissions.setValueFromSource({ dataType: DataType.Null });
830
+ }
831
+ const defaultRolePermissions = ns.getChildByName("DefaultRolePermissions") as UAVariable | null;
832
+ if (defaultRolePermissions) {
833
+ defaultRolePermissions.setValueFromSource({ dataType: DataType.Null });
834
+ }
835
+ }
836
+ }
910
837
 
911
- const timeZone = new TimeZoneDataType({
912
- daylightSavingInOffset: /* boolean*/ false,
913
- offset: /* int16 */ 0
914
- });
915
- bindStandardScalar(VariableIds.Server_LocalTime, DataType.ExtensionObject, () => {
916
- return timeZone;
917
- });
838
+ const bindStandardScalar = (
839
+ id: number,
840
+ dataType: DataType,
841
+ func: () => any,
842
+ setter_func?: (value: any) => void
843
+ ) => {
844
+ assert(typeof id === "number", "expecting id to be a number");
845
+ assert(typeof func === "function");
846
+ assert(typeof setter_func === "function" || !setter_func);
847
+ assert(dataType !== null); // check invalid dataType
848
+
849
+ let setter_func2 = null;
850
+ if (setter_func) {
851
+ setter_func2 = (variant: Variant) => {
852
+ const variable2 = !!variant.value;
853
+ setter_func(variable2);
854
+ return StatusCodes.Good;
855
+ };
856
+ }
918
857
 
919
- bindStandardScalar(VariableIds.Server_ServiceLevel, DataType.Byte, () => {
920
- return 255;
921
- });
858
+ const nodeId = makeNodeId(id);
922
859
 
923
- bindStandardScalar(VariableIds.Server_Auditing, DataType.Boolean, () => {
924
- return this.isAuditing;
925
- });
860
+ // make sur the provided function returns a valid value for the variant type
861
+ // This test may not be exhaustive but it will detect obvious mistakes.
926
862
 
927
- // eslint-disable-next-line @typescript-eslint/no-this-alias
928
- const engine = this;
929
- const makeNotReadableIfEnabledFlagIsFalse = (variable: UAVariable) => {
930
- const originalIsReadable = variable.isReadable;
931
- variable.isUserReadable = checkReadableFlag;
932
- function checkReadableFlag(this: UAVariable, context: SessionContext): boolean {
933
- const isEnabled = engine.serverDiagnosticsEnabled;
934
- return originalIsReadable.call(this, context) && isEnabled;
935
- }
936
- for (const c of variable.getAggregates()) {
937
- if (c.nodeClass === NodeClass.Variable) {
938
- makeNotReadableIfEnabledFlagIsFalse(c as UAVariable);
863
+ /* istanbul ignore next */
864
+ if (!isValidVariant(VariantArrayType.Scalar, dataType, func())) {
865
+ errorLog("func", func());
866
+ throw new Error("bindStandardScalar : func doesn't provide an value of type " + DataType[dataType]);
939
867
  }
940
- }
941
- };
942
-
943
- const bindServerDiagnostics = () => {
944
- bindStandardScalar(
945
- VariableIds.Server_ServerDiagnostics_EnabledFlag,
946
- DataType.Boolean,
947
- () => {
948
- return this.serverDiagnosticsEnabled;
949
- },
950
- (newFlag: boolean) => {
951
- this.serverDiagnosticsEnabled = newFlag;
952
- }
953
- );
954
- const nodeId = makeNodeId(VariableIds.Server_ServerDiagnostics_ServerDiagnosticsSummary);
955
- const serverDiagnosticsSummaryNode = addressSpace.findNode(
956
- nodeId
957
- ) as UAServerDiagnosticsSummary<ServerDiagnosticsSummaryDataType>;
958
-
959
- if (serverDiagnosticsSummaryNode) {
960
- serverDiagnosticsSummaryNode.bindExtensionObject(this.serverDiagnosticsSummary);
961
- this.serverDiagnosticsSummary = serverDiagnosticsSummaryNode.$extensionObject;
962
- makeNotReadableIfEnabledFlagIsFalse(serverDiagnosticsSummaryNode);
963
- }
964
- };
965
868
 
966
- const bindServerStatus = () => {
967
- const serverStatusNode = addressSpace.findNode(
968
- makeNodeId(VariableIds.Server_ServerStatus)
969
- ) as UAServerStatus<DTServerStatus>;
869
+ return bindVariableIfPresent(nodeId, {
870
+ get() {
871
+ return new Variant({
872
+ arrayType: VariantArrayType.Scalar,
873
+ dataType,
874
+ value: func()
875
+ });
876
+ },
877
+ set: setter_func2
878
+ });
879
+ };
970
880
 
971
- if (!serverStatusNode) {
972
- return;
973
- }
974
- if (serverStatusNode) {
975
- serverStatusNode.bindExtensionObject(this._serverStatus);
976
- serverStatusNode.minimumSamplingInterval = 1000;
977
- }
881
+ const bindStandardArray = (id: number, variantDataType: DataType, dataType: any, func: () => any[]) => {
882
+ assert(typeof func === "function");
883
+ assert(variantDataType !== null); // check invalid dataType
884
+
885
+ const nodeId = makeNodeId(id);
886
+
887
+ // make sur the provided function returns a valid value for the variant type
888
+ // This test may not be exhaustive but it will detect obvious mistakes.
889
+ assert(isValidVariant(VariantArrayType.Array, variantDataType, func()));
890
+
891
+ bindVariableIfPresent(nodeId, {
892
+ get() {
893
+ const value = func();
894
+ assert(Array.isArray(value));
895
+ return new Variant({
896
+ arrayType: VariantArrayType.Array,
897
+ dataType: variantDataType,
898
+ value
899
+ });
900
+ },
901
+ set: null // read only
902
+ });
903
+ };
978
904
 
979
- const currentTimeNode = addressSpace.findNode(
980
- makeNodeId(VariableIds.Server_ServerStatus_CurrentTime)
981
- ) as UAVariable;
905
+ bindStandardScalar(VariableIds.Server_EstimatedReturnTime, DataType.DateTime, () => getMinOPCUADate());
982
906
 
983
- if (currentTimeNode) {
984
- currentTimeNode.minimumSamplingInterval = 1000;
985
- }
986
- const secondsTillShutdown = addressSpace.findNode(
987
- makeNodeId(VariableIds.Server_ServerStatus_SecondsTillShutdown)
988
- ) as UAVariable;
907
+ // TimeZoneDataType
908
+ const timeZoneDataType = addressSpace.findDataType(resolveNodeId(DataTypeIds.TimeZoneDataType))!;
989
909
 
990
- if (secondsTillShutdown) {
991
- secondsTillShutdown.minimumSamplingInterval = 1000;
992
- }
910
+ const timeZone = new TimeZoneDataType({
911
+ daylightSavingInOffset: /* boolean*/ false,
912
+ offset: /* int16 */ 0
913
+ });
914
+ bindStandardScalar(VariableIds.Server_LocalTime, DataType.ExtensionObject, () => {
915
+ return timeZone;
916
+ });
993
917
 
994
- assert(serverStatusNode.$extensionObject);
918
+ bindStandardScalar(VariableIds.Server_ServiceLevel, DataType.Byte, () => {
919
+ return 255;
920
+ });
995
921
 
996
- serverStatusNode.$extensionObject = new Proxy(serverStatusNode.$extensionObject, {
997
- get(target, prop) {
998
- if (prop === "currentTime") {
999
- serverStatusNode.currentTime.touchValue();
1000
- return new Date();
1001
- } else if (prop === "secondsTillShutdown") {
1002
- serverStatusNode.secondsTillShutdown.touchValue();
1003
- return engine.secondsTillShutdown();
922
+ bindStandardScalar(VariableIds.Server_Auditing, DataType.Boolean, () => {
923
+ return this.isAuditing;
924
+ });
925
+
926
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
927
+ const engine = this;
928
+ const makeNotReadableIfEnabledFlagIsFalse = (variable: UAVariable) => {
929
+ const originalIsReadable = variable.isReadable;
930
+ variable.isUserReadable = checkReadableFlag;
931
+ function checkReadableFlag(this: UAVariable, context: SessionContext): boolean {
932
+ const isEnabled = engine.serverDiagnosticsEnabled;
933
+ return originalIsReadable.call(this, context) && isEnabled;
934
+ }
935
+ for (const c of variable.getAggregates()) {
936
+ if (c.nodeClass === NodeClass.Variable) {
937
+ makeNotReadableIfEnabledFlagIsFalse(c as UAVariable);
1004
938
  }
1005
- return (target as any)[prop];
1006
939
  }
1007
- });
1008
- this._serverStatus = serverStatusNode.$extensionObject;
1009
- };
1010
-
1011
- const bindServerCapabilities = () => {
1012
- bindStandardArray(
1013
- VariableIds.Server_ServerCapabilities_ServerProfileArray,
1014
- DataType.String,
1015
- DataType.String,
1016
- () => {
1017
- return this.serverCapabilities.serverProfileArray;
940
+ };
941
+
942
+ const bindServerDiagnostics = () => {
943
+ bindStandardScalar(
944
+ VariableIds.Server_ServerDiagnostics_EnabledFlag,
945
+ DataType.Boolean,
946
+ () => {
947
+ return this.serverDiagnosticsEnabled;
948
+ },
949
+ (newFlag: boolean) => {
950
+ this.serverDiagnosticsEnabled = newFlag;
951
+ }
952
+ );
953
+ const nodeId = makeNodeId(VariableIds.Server_ServerDiagnostics_ServerDiagnosticsSummary);
954
+ const serverDiagnosticsSummaryNode = addressSpace.findNode(
955
+ nodeId
956
+ ) as UAServerDiagnosticsSummary<ServerDiagnosticsSummaryDataType>;
957
+
958
+ if (serverDiagnosticsSummaryNode) {
959
+ serverDiagnosticsSummaryNode.bindExtensionObject(this.serverDiagnosticsSummary);
960
+ this.serverDiagnosticsSummary = serverDiagnosticsSummaryNode.$extensionObject;
961
+ makeNotReadableIfEnabledFlagIsFalse(serverDiagnosticsSummaryNode);
1018
962
  }
1019
- );
963
+ };
1020
964
 
1021
- bindStandardArray(VariableIds.Server_ServerCapabilities_LocaleIdArray, DataType.String, "LocaleId", () => {
1022
- return this.serverCapabilities.localeIdArray;
1023
- });
965
+ const bindServerStatus = () => {
966
+ const serverStatusNode = addressSpace.findNode(
967
+ makeNodeId(VariableIds.Server_ServerStatus)
968
+ ) as UAServerStatus<DTServerStatus>;
1024
969
 
1025
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MinSupportedSampleRate, DataType.Double, () => {
1026
- return Math.max(this.serverCapabilities.minSupportedSampleRate, defaultServerCapabilities.minSupportedSampleRate);
1027
- });
970
+ if (!serverStatusNode) {
971
+ return;
972
+ }
973
+ if (serverStatusNode) {
974
+ serverStatusNode.bindExtensionObject(this._serverStatus);
975
+ serverStatusNode.minimumSamplingInterval = 1000;
976
+ }
1028
977
 
1029
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxBrowseContinuationPoints, DataType.UInt16, () => {
1030
- return this.serverCapabilities.maxBrowseContinuationPoints;
1031
- });
978
+ const currentTimeNode = addressSpace.findNode(
979
+ makeNodeId(VariableIds.Server_ServerStatus_CurrentTime)
980
+ ) as UAVariable;
1032
981
 
1033
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxQueryContinuationPoints, DataType.UInt16, () => {
1034
- return this.serverCapabilities.maxQueryContinuationPoints;
1035
- });
982
+ if (currentTimeNode) {
983
+ currentTimeNode.minimumSamplingInterval = 1000;
984
+ }
985
+ const secondsTillShutdown = addressSpace.findNode(
986
+ makeNodeId(VariableIds.Server_ServerStatus_SecondsTillShutdown)
987
+ ) as UAVariable;
1036
988
 
1037
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxHistoryContinuationPoints, DataType.UInt16, () => {
1038
- return this.serverCapabilities.maxHistoryContinuationPoints;
1039
- });
989
+ if (secondsTillShutdown) {
990
+ secondsTillShutdown.minimumSamplingInterval = 1000;
991
+ }
1040
992
 
1041
- // new in 1.05
1042
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSessions, DataType.UInt32, () => {
1043
- return this.serverCapabilities.maxSessions;
1044
- });
1045
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSubscriptions, DataType.UInt32, () => {
1046
- return this.serverCapabilities.maxSubscriptions;
1047
- });
1048
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxMonitoredItems, DataType.UInt32, () => {
1049
- return this.serverCapabilities.maxMonitoredItems;
1050
- });
1051
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSubscriptionsPerSession, DataType.UInt32, () => {
1052
- return this.serverCapabilities.maxSubscriptionsPerSession;
1053
- });
1054
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSelectClauseParameters, DataType.UInt32, () => {
1055
- return this.serverCapabilities.maxSelectClauseParameters;
1056
- });
1057
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxWhereClauseParameters, DataType.UInt32, () => {
1058
- return this.serverCapabilities.maxWhereClauseParameters;
1059
- });
1060
- //bindStandardArray(VariableIds.Server_ServerCapabilities_ConformanceUnits, DataType.QualifiedName, () => {
1061
- // return this.serverCapabilities.conformanceUnits;
1062
- //});
1063
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxMonitoredItemsPerSubscription, DataType.UInt32, () => {
1064
- return this.serverCapabilities.maxMonitoredItemsPerSubscription;
1065
- });
993
+ assert(serverStatusNode.$extensionObject);
994
+
995
+ serverStatusNode.$extensionObject = new Proxy(serverStatusNode.$extensionObject, {
996
+ get(target, prop) {
997
+ if (prop === "currentTime") {
998
+ serverStatusNode.currentTime.touchValue();
999
+ return new Date();
1000
+ } else if (prop === "secondsTillShutdown") {
1001
+ serverStatusNode.secondsTillShutdown.touchValue();
1002
+ return engine.secondsTillShutdown();
1003
+ }
1004
+ return (target as any)[prop];
1005
+ }
1006
+ });
1007
+ this._serverStatus = serverStatusNode.$extensionObject;
1008
+ };
1066
1009
 
1067
- // added by DI : Server-specific period of time in milliseconds until the Server will revoke a lock.
1068
- // TODO bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxInactiveLockTime,
1069
- // TODO DataType.UInt16, function () {
1070
- // TODO return self.serverCapabilities.maxInactiveLockTime;
1071
- // TODO });
1072
-
1073
- bindStandardArray(
1074
- VariableIds.Server_ServerCapabilities_SoftwareCertificates,
1075
- DataType.ExtensionObject,
1076
- "SoftwareCertificates",
1077
- () => {
1078
- return this.serverCapabilities.softwareCertificates;
1079
- }
1080
- );
1010
+ const bindServerCapabilities = () => {
1011
+ bindStandardArray(
1012
+ VariableIds.Server_ServerCapabilities_ServerProfileArray,
1013
+ DataType.String,
1014
+ DataType.String,
1015
+ () => {
1016
+ return this.serverCapabilities.serverProfileArray;
1017
+ }
1018
+ );
1081
1019
 
1082
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxArrayLength, DataType.UInt32, () => {
1083
- return Math.min(this.serverCapabilities.maxArrayLength, Variant.maxArrayLength);
1084
- });
1020
+ bindStandardArray(VariableIds.Server_ServerCapabilities_LocaleIdArray, DataType.String, "LocaleId", () => {
1021
+ return this.serverCapabilities.localeIdArray;
1022
+ });
1085
1023
 
1086
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxStringLength, DataType.UInt32, () => {
1087
- return Math.min(this.serverCapabilities.maxStringLength, BinaryStream.maxStringLength);
1088
- });
1024
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MinSupportedSampleRate, DataType.Double, () => {
1025
+ return Math.max(
1026
+ this.serverCapabilities.minSupportedSampleRate,
1027
+ defaultServerCapabilities.minSupportedSampleRate
1028
+ );
1029
+ });
1089
1030
 
1090
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxByteStringLength, DataType.UInt32, () => {
1091
- return Math.min(this.serverCapabilities.maxByteStringLength, BinaryStream.maxByteStringLength);
1092
- });
1031
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxBrowseContinuationPoints, DataType.UInt16, () => {
1032
+ return this.serverCapabilities.maxBrowseContinuationPoints;
1033
+ });
1093
1034
 
1094
- bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxMonitoredItemsQueueSize, DataType.UInt32, () => {
1095
- return Math.max(1, this.serverCapabilities.maxMonitoredItemsQueueSize);
1096
- });
1035
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxQueryContinuationPoints, DataType.UInt16, () => {
1036
+ return this.serverCapabilities.maxQueryContinuationPoints;
1037
+ });
1097
1038
 
1098
- const bindOperationLimits = (operationLimits: ServerOperationLimits) => {
1099
- assert(operationLimits !== null && typeof operationLimits === "object");
1039
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxHistoryContinuationPoints, DataType.UInt16, () => {
1040
+ return this.serverCapabilities.maxHistoryContinuationPoints;
1041
+ });
1100
1042
 
1101
- const keys = Object.keys(operationLimits);
1043
+ // new in 1.05
1044
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSessions, DataType.UInt32, () => {
1045
+ return this.serverCapabilities.maxSessions;
1046
+ });
1047
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSubscriptions, DataType.UInt32, () => {
1048
+ return this.serverCapabilities.maxSubscriptions;
1049
+ });
1050
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxMonitoredItems, DataType.UInt32, () => {
1051
+ return this.serverCapabilities.maxMonitoredItems;
1052
+ });
1053
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSubscriptionsPerSession, DataType.UInt32, () => {
1054
+ return this.serverCapabilities.maxSubscriptionsPerSession;
1055
+ });
1056
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxSelectClauseParameters, DataType.UInt32, () => {
1057
+ return this.serverCapabilities.maxSelectClauseParameters;
1058
+ });
1059
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxWhereClauseParameters, DataType.UInt32, () => {
1060
+ return this.serverCapabilities.maxWhereClauseParameters;
1061
+ });
1062
+ //bindStandardArray(VariableIds.Server_ServerCapabilities_ConformanceUnits, DataType.QualifiedName, () => {
1063
+ // return this.serverCapabilities.conformanceUnits;
1064
+ //});
1065
+ bindStandardScalar(
1066
+ VariableIds.Server_ServerCapabilities_MaxMonitoredItemsPerSubscription,
1067
+ DataType.UInt32,
1068
+ () => {
1069
+ return this.serverCapabilities.maxMonitoredItemsPerSubscription;
1070
+ }
1071
+ );
1072
+
1073
+ // added by DI : Server-specific period of time in milliseconds until the Server will revoke a lock.
1074
+ // TODO bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxInactiveLockTime,
1075
+ // TODO DataType.UInt16, function () {
1076
+ // TODO return self.serverCapabilities.maxInactiveLockTime;
1077
+ // TODO });
1078
+
1079
+ bindStandardArray(
1080
+ VariableIds.Server_ServerCapabilities_SoftwareCertificates,
1081
+ DataType.ExtensionObject,
1082
+ "SoftwareCertificates",
1083
+ () => {
1084
+ return this.serverCapabilities.softwareCertificates;
1085
+ }
1086
+ );
1102
1087
 
1103
- keys.forEach((key: string) => {
1104
- const uid = "Server_ServerCapabilities_OperationLimits_" + upperCaseFirst(key);
1105
- const nodeId = makeNodeId((VariableIds as any)[uid]);
1106
- assert(!nodeId.isEmpty());
1088
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxArrayLength, DataType.UInt32, () => {
1089
+ return Math.min(this.serverCapabilities.maxArrayLength, Variant.maxArrayLength);
1090
+ });
1107
1091
 
1108
- bindStandardScalar((VariableIds as any)[uid], DataType.UInt32, () => {
1109
- return (operationLimits as any)[key];
1110
- });
1092
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxStringLength, DataType.UInt32, () => {
1093
+ return Math.min(this.serverCapabilities.maxStringLength, BinaryStream.maxStringLength);
1111
1094
  });
1112
- };
1113
1095
 
1114
- bindOperationLimits(this.serverCapabilities.operationLimits);
1115
-
1116
- // i=2399 [ProgramStateMachineType_ProgramDiagnostics];
1117
- function fix_ProgramStateMachineType_ProgramDiagnostics() {
1118
- const nodeId = coerceNodeId("i=2399"); // ProgramStateMachineType_ProgramDiagnostics
1119
- const variable = addressSpace.findNode(nodeId) as UAVariable;
1120
- if (variable) {
1121
- (variable as any).$extensionObject = new ProgramDiagnosticDataType({});
1122
- // variable.setValueFromSource({
1123
- // dataType: DataType.ExtensionObject,
1124
- // // value: new ProgramDiagnostic2DataType()
1125
- // value: new ProgramDiagnosticDataType({})
1126
- // });
1096
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxByteStringLength, DataType.UInt32, () => {
1097
+ return Math.min(this.serverCapabilities.maxByteStringLength, BinaryStream.maxByteStringLength);
1098
+ });
1099
+
1100
+ bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxMonitoredItemsQueueSize, DataType.UInt32, () => {
1101
+ return Math.max(1, this.serverCapabilities.maxMonitoredItemsQueueSize);
1102
+ });
1103
+
1104
+ const bindOperationLimits = (operationLimits: ServerOperationLimits) => {
1105
+ assert(operationLimits !== null && typeof operationLimits === "object");
1106
+
1107
+ const keys = Object.keys(operationLimits);
1108
+
1109
+ keys.forEach((key: string) => {
1110
+ const uid = "Server_ServerCapabilities_OperationLimits_" + upperCaseFirst(key);
1111
+ const nodeId = makeNodeId((VariableIds as any)[uid]);
1112
+ assert(!nodeId.isEmpty());
1113
+
1114
+ bindStandardScalar((VariableIds as any)[uid], DataType.UInt32, () => {
1115
+ return (operationLimits as any)[key];
1116
+ });
1117
+ });
1118
+ };
1119
+
1120
+ bindOperationLimits(this.serverCapabilities.operationLimits);
1121
+
1122
+ // i=2399 [ProgramStateMachineType_ProgramDiagnostics];
1123
+ function fix_ProgramStateMachineType_ProgramDiagnostics() {
1124
+ const nodeId = coerceNodeId("i=2399"); // ProgramStateMachineType_ProgramDiagnostics
1125
+ const variable = addressSpace.findNode(nodeId) as UAVariable;
1126
+ if (variable) {
1127
+ (variable as any).$extensionObject = new ProgramDiagnosticDataType({});
1128
+ // variable.setValueFromSource({
1129
+ // dataType: DataType.ExtensionObject,
1130
+ // // value: new ProgramDiagnostic2DataType()
1131
+ // value: new ProgramDiagnosticDataType({})
1132
+ // });
1133
+ }
1127
1134
  }
1128
- }
1129
- fix_ProgramStateMachineType_ProgramDiagnostics();
1130
- };
1135
+ fix_ProgramStateMachineType_ProgramDiagnostics();
1136
+ };
1131
1137
 
1132
- const bindHistoryServerCapabilities = () => {
1133
- bindStandardScalar(VariableIds.HistoryServerCapabilities_MaxReturnDataValues, DataType.UInt32, () => {
1134
- return this.historyServerCapabilities.maxReturnDataValues;
1135
- });
1138
+ const bindHistoryServerCapabilities = () => {
1139
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_MaxReturnDataValues, DataType.UInt32, () => {
1140
+ return this.historyServerCapabilities.maxReturnDataValues;
1141
+ });
1136
1142
 
1137
- bindStandardScalar(VariableIds.HistoryServerCapabilities_MaxReturnEventValues, DataType.UInt32, () => {
1138
- return this.historyServerCapabilities.maxReturnEventValues;
1139
- });
1143
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_MaxReturnEventValues, DataType.UInt32, () => {
1144
+ return this.historyServerCapabilities.maxReturnEventValues;
1145
+ });
1140
1146
 
1141
- bindStandardScalar(VariableIds.HistoryServerCapabilities_AccessHistoryDataCapability, DataType.Boolean, () => {
1142
- return this.historyServerCapabilities.accessHistoryDataCapability;
1143
- });
1144
- bindStandardScalar(VariableIds.HistoryServerCapabilities_AccessHistoryEventsCapability, DataType.Boolean, () => {
1145
- return this.historyServerCapabilities.accessHistoryEventsCapability;
1146
- });
1147
- bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertDataCapability, DataType.Boolean, () => {
1148
- return this.historyServerCapabilities.insertDataCapability;
1149
- });
1150
- bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceDataCapability, DataType.Boolean, () => {
1151
- return this.historyServerCapabilities.replaceDataCapability;
1152
- });
1153
- bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateDataCapability, DataType.Boolean, () => {
1154
- return this.historyServerCapabilities.updateDataCapability;
1155
- });
1147
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_AccessHistoryDataCapability, DataType.Boolean, () => {
1148
+ return this.historyServerCapabilities.accessHistoryDataCapability;
1149
+ });
1150
+ bindStandardScalar(
1151
+ VariableIds.HistoryServerCapabilities_AccessHistoryEventsCapability,
1152
+ DataType.Boolean,
1153
+ () => {
1154
+ return this.historyServerCapabilities.accessHistoryEventsCapability;
1155
+ }
1156
+ );
1157
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertDataCapability, DataType.Boolean, () => {
1158
+ return this.historyServerCapabilities.insertDataCapability;
1159
+ });
1160
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceDataCapability, DataType.Boolean, () => {
1161
+ return this.historyServerCapabilities.replaceDataCapability;
1162
+ });
1163
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateDataCapability, DataType.Boolean, () => {
1164
+ return this.historyServerCapabilities.updateDataCapability;
1165
+ });
1156
1166
 
1157
- bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertEventCapability, DataType.Boolean, () => {
1158
- return this.historyServerCapabilities.insertEventCapability;
1159
- });
1167
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertEventCapability, DataType.Boolean, () => {
1168
+ return this.historyServerCapabilities.insertEventCapability;
1169
+ });
1160
1170
 
1161
- bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceEventCapability, DataType.Boolean, () => {
1162
- return this.historyServerCapabilities.replaceEventCapability;
1163
- });
1171
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceEventCapability, DataType.Boolean, () => {
1172
+ return this.historyServerCapabilities.replaceEventCapability;
1173
+ });
1164
1174
 
1165
- bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateEventCapability, DataType.Boolean, () => {
1166
- return this.historyServerCapabilities.updateEventCapability;
1167
- });
1175
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateEventCapability, DataType.Boolean, () => {
1176
+ return this.historyServerCapabilities.updateEventCapability;
1177
+ });
1168
1178
 
1169
- bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteEventCapability, DataType.Boolean, () => {
1170
- return this.historyServerCapabilities.deleteEventCapability;
1171
- });
1179
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteEventCapability, DataType.Boolean, () => {
1180
+ return this.historyServerCapabilities.deleteEventCapability;
1181
+ });
1172
1182
 
1173
- bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteRawCapability, DataType.Boolean, () => {
1174
- return this.historyServerCapabilities.deleteRawCapability;
1175
- });
1183
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteRawCapability, DataType.Boolean, () => {
1184
+ return this.historyServerCapabilities.deleteRawCapability;
1185
+ });
1176
1186
 
1177
- bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteAtTimeCapability, DataType.Boolean, () => {
1178
- return this.historyServerCapabilities.deleteAtTimeCapability;
1179
- });
1187
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteAtTimeCapability, DataType.Boolean, () => {
1188
+ return this.historyServerCapabilities.deleteAtTimeCapability;
1189
+ });
1180
1190
 
1181
- bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertAnnotationCapability, DataType.Boolean, () => {
1182
- return this.historyServerCapabilities.insertAnnotationCapability;
1183
- });
1184
- };
1191
+ bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertAnnotationCapability, DataType.Boolean, () => {
1192
+ return this.historyServerCapabilities.insertAnnotationCapability;
1193
+ });
1194
+ };
1185
1195
 
1186
- type Getter<T> = () => T;
1187
- function r<T>(a: undefined | T | Getter<T>, defaultValue: T): T {
1188
- if (a === undefined) return defaultValue;
1189
- if (typeof a === "function") {
1190
- return (a as any)();
1196
+ type Getter<T> = () => T;
1197
+ function r<T>(a: undefined | T | Getter<T>, defaultValue: T): T {
1198
+ if (a === undefined) return defaultValue;
1199
+ if (typeof a === "function") {
1200
+ return (a as any)();
1201
+ }
1202
+ return a;
1191
1203
  }
1192
- return a;
1193
- }
1194
- const bindServerConfigurationBasic = () => {
1195
- bindStandardArray(VariableIds.ServerConfiguration_ServerCapabilities, DataType.String, DataType.String, () =>
1196
- r(this.serverConfiguration.serverCapabilities, ["NA"])
1197
- );
1198
- bindStandardScalar(VariableIds.ServerConfiguration_ApplicationType, DataType.Int32, () =>
1199
- r(this.serverConfiguration.applicationType, ApplicationType.Server)
1200
- );
1201
- bindStandardScalar(VariableIds.ServerConfiguration_ApplicationUri, DataType.String, () =>
1202
- r(this.serverConfiguration.applicationUri, "")
1203
- );
1204
- bindStandardScalar(VariableIds.ServerConfiguration_ProductUri, DataType.String, () =>
1205
- r(this.serverConfiguration.productUri, "")
1206
- );
1207
- bindStandardScalar(VariableIds.ServerConfiguration_HasSecureElement, DataType.Boolean, () =>
1208
- r(this.serverConfiguration.hasSecureElement, false)
1209
- );
1210
- bindStandardScalar(VariableIds.ServerConfiguration_MulticastDnsEnabled, DataType.Boolean, () =>
1211
- r(this.serverConfiguration.multicastDnsEnabled, false)
1212
- );
1213
- bindStandardArray(
1214
- VariableIds.ServerConfiguration_SupportedPrivateKeyFormats,
1215
- DataType.String,
1216
- DataType.String,
1217
- () => r(this.serverConfiguration.supportedPrivateKeyFormat, ["PEM"])
1218
- );
1219
- };
1204
+ const bindServerConfigurationBasic = () => {
1205
+ bindStandardArray(VariableIds.ServerConfiguration_ServerCapabilities, DataType.String, DataType.String, () =>
1206
+ r(this.serverConfiguration.serverCapabilities, ["NA"])
1207
+ );
1208
+ bindStandardScalar(VariableIds.ServerConfiguration_ApplicationType, DataType.Int32, () =>
1209
+ r(this.serverConfiguration.applicationType, ApplicationType.Server)
1210
+ );
1211
+ bindStandardScalar(VariableIds.ServerConfiguration_ApplicationUri, DataType.String, () =>
1212
+ r(this.serverConfiguration.applicationUri, "")
1213
+ );
1214
+ bindStandardScalar(VariableIds.ServerConfiguration_ProductUri, DataType.String, () =>
1215
+ r(this.serverConfiguration.productUri, "")
1216
+ );
1217
+ bindStandardScalar(VariableIds.ServerConfiguration_HasSecureElement, DataType.Boolean, () =>
1218
+ r(this.serverConfiguration.hasSecureElement, false)
1219
+ );
1220
+ bindStandardScalar(VariableIds.ServerConfiguration_MulticastDnsEnabled, DataType.Boolean, () =>
1221
+ r(this.serverConfiguration.multicastDnsEnabled, false)
1222
+ );
1223
+ bindStandardArray(
1224
+ VariableIds.ServerConfiguration_SupportedPrivateKeyFormats,
1225
+ DataType.String,
1226
+ DataType.String,
1227
+ () => r(this.serverConfiguration.supportedPrivateKeyFormat, ["PEM"])
1228
+ );
1229
+ };
1220
1230
 
1221
- bindServerDiagnostics();
1231
+ bindServerDiagnostics();
1222
1232
 
1223
- bindServerStatus();
1233
+ bindServerStatus();
1224
1234
 
1225
- bindServerCapabilities();
1235
+ bindServerCapabilities();
1226
1236
 
1227
- bindServerConfigurationBasic();
1237
+ bindServerConfigurationBasic();
1228
1238
 
1229
- bindHistoryServerCapabilities();
1239
+ bindHistoryServerCapabilities();
1230
1240
 
1231
- const bindExtraStuff = () => {
1232
- // mainly for compliance
1233
- /*
1241
+ const bindExtraStuff = () => {
1242
+ // mainly for compliance
1243
+ /*
1234
1244
  // The version number for the data type description. i=104
1235
1245
  bindStandardScalar(VariableIds.DataTypeDescriptionType_DataTypeVersion, DataType.String, () => {
1236
1246
  return "0";
@@ -1266,99 +1276,106 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
1266
1276
  });
1267
1277
  }
1268
1278
  */
1269
- };
1279
+ };
1270
1280
 
1271
- bindExtraStuff();
1281
+ bindExtraStuff();
1272
1282
 
1273
- this.__internal_bindMethod(makeNodeId(MethodIds.Server_GetMonitoredItems), getMonitoredItemsId.bind(this));
1274
- this.__internal_bindMethod(makeNodeId(MethodIds.Server_SetSubscriptionDurable), setSubscriptionDurable.bind(this));
1275
- this.__internal_bindMethod(makeNodeId(MethodIds.Server_ResendData), resendData.bind(this));
1276
- this.__internal_bindMethod(makeNodeId(MethodIds.Server_RequestServerStateChange), requestServerStateChange.bind(this));
1283
+ this.__internal_bindMethod(makeNodeId(MethodIds.Server_GetMonitoredItems), getMonitoredItemsId.bind(this));
1284
+ this.__internal_bindMethod(makeNodeId(MethodIds.Server_SetSubscriptionDurable), setSubscriptionDurable.bind(this));
1285
+ this.__internal_bindMethod(makeNodeId(MethodIds.Server_ResendData), resendData.bind(this));
1286
+ this.__internal_bindMethod(
1287
+ makeNodeId(MethodIds.Server_RequestServerStateChange),
1288
+ requestServerStateChange.bind(this)
1289
+ );
1277
1290
 
1278
- // fix getMonitoredItems.outputArguments arrayDimensions
1279
- const fixGetMonitoredItemArgs = () => {
1280
- const objects = this.addressSpace!.rootFolder?.objects;
1281
- if (!objects || !objects.server || !objects.server.getMonitoredItems) {
1282
- return;
1283
- }
1284
- const outputArguments = objects.server.getMonitoredItems.outputArguments!;
1285
- const dataValue = outputArguments.readValue();
1286
- assert(dataValue.value.value[0].arrayDimensions.length === 1 && dataValue.value.value[0].arrayDimensions[0] === 0);
1287
- assert(dataValue.value.value[1].arrayDimensions.length === 1 && dataValue.value.value[1].arrayDimensions[0] === 0);
1288
- };
1289
- fixGetMonitoredItemArgs();
1290
-
1291
- const prepareServerDiagnostics = () => {
1292
- const addressSpace1 = this.addressSpace!;
1293
-
1294
- if (!addressSpace1.rootFolder.objects) {
1295
- return;
1296
- }
1297
- const server = addressSpace1.rootFolder.objects.server;
1291
+ // fix getMonitoredItems.outputArguments arrayDimensions
1292
+ const fixGetMonitoredItemArgs = () => {
1293
+ const objects = this.addressSpace!.rootFolder?.objects;
1294
+ if (!objects || !objects.server || !objects.server.getMonitoredItems) {
1295
+ return;
1296
+ }
1297
+ const outputArguments = objects.server.getMonitoredItems.outputArguments!;
1298
+ const dataValue = outputArguments.readValue();
1299
+ assert(
1300
+ dataValue.value.value[0].arrayDimensions.length === 1 && dataValue.value.value[0].arrayDimensions[0] === 0
1301
+ );
1302
+ assert(
1303
+ dataValue.value.value[1].arrayDimensions.length === 1 && dataValue.value.value[1].arrayDimensions[0] === 0
1304
+ );
1305
+ };
1306
+ fixGetMonitoredItemArgs();
1298
1307
 
1299
- if (!server) {
1300
- return;
1301
- }
1308
+ const prepareServerDiagnostics = () => {
1309
+ const addressSpace1 = this.addressSpace!;
1302
1310
 
1303
- // create SessionsDiagnosticsSummary
1304
- const serverDiagnosticsNode = server.getComponentByName("ServerDiagnostics") as UAServerDiagnostics;
1305
- if (!serverDiagnosticsNode) {
1306
- return;
1307
- }
1308
- if (true) {
1309
- // set serverDiagnosticsNode enabledFlag writeable for admin user only
1310
- // TO DO ...
1311
- serverDiagnosticsNode.enabledFlag.userAccessLevel = makeAccessLevelFlag("CurrentRead");
1312
- serverDiagnosticsNode.enabledFlag.accessLevel = makeAccessLevelFlag("CurrentRead");
1313
- }
1311
+ if (!addressSpace1.rootFolder.objects) {
1312
+ return;
1313
+ }
1314
+ const server = addressSpace1.rootFolder.objects.server;
1314
1315
 
1315
- // A Server may not expose the SamplingIntervalDiagnosticsArray if it does not use fixed sampling rates.
1316
- // because we are not using fixed sampling rate, we need to remove the optional SamplingIntervalDiagnosticsArray
1317
- // component
1318
- const samplingIntervalDiagnosticsArray = serverDiagnosticsNode.getComponentByName(
1319
- "SamplingIntervalDiagnosticsArray"
1320
- );
1321
- if (samplingIntervalDiagnosticsArray) {
1322
- addressSpace.deleteNode(samplingIntervalDiagnosticsArray);
1323
- const s = serverDiagnosticsNode.getComponents();
1324
- }
1316
+ if (!server) {
1317
+ return;
1318
+ }
1325
1319
 
1326
- const subscriptionDiagnosticsArrayNode = serverDiagnosticsNode.getComponentByName(
1327
- "SubscriptionDiagnosticsArray"
1328
- )! as UADynamicVariableArray<SessionDiagnosticsDataType>;
1329
- assert(subscriptionDiagnosticsArrayNode.nodeClass === NodeClass.Variable);
1330
- bindExtObjArrayNode(subscriptionDiagnosticsArrayNode, "SubscriptionDiagnosticsType", "subscriptionId");
1331
-
1332
- makeNotReadableIfEnabledFlagIsFalse(subscriptionDiagnosticsArrayNode);
1333
-
1334
- const sessionsDiagnosticsSummary = serverDiagnosticsNode.getComponentByName("SessionsDiagnosticsSummary")!;
1335
-
1336
- const sessionDiagnosticsArray = sessionsDiagnosticsSummary.getComponentByName(
1337
- "SessionDiagnosticsArray"
1338
- )! as UADynamicVariableArray<SessionDiagnosticsDataType>;
1339
- assert(sessionDiagnosticsArray.nodeClass === NodeClass.Variable);
1340
-
1341
- bindExtObjArrayNode(sessionDiagnosticsArray, "SessionDiagnosticsVariableType", "sessionId");
1342
-
1343
- const varType = addressSpace.findVariableType("SessionSecurityDiagnosticsType");
1344
- if (!varType) {
1345
- debugLog("Warning cannot find SessionSecurityDiagnosticsType variable Type");
1346
- } else {
1347
- const sessionSecurityDiagnosticsArray = sessionsDiagnosticsSummary.getComponentByName(
1348
- "SessionSecurityDiagnosticsArray"
1349
- )! as UADynamicVariableArray<SessionSecurityDiagnosticsDataType>;
1350
- assert(sessionSecurityDiagnosticsArray.nodeClass === NodeClass.Variable);
1351
- bindExtObjArrayNode(sessionSecurityDiagnosticsArray, "SessionSecurityDiagnosticsType", "sessionId");
1352
- ensureObjectIsSecure(sessionSecurityDiagnosticsArray);
1353
- }
1354
- };
1320
+ // create SessionsDiagnosticsSummary
1321
+ const serverDiagnosticsNode = server.getComponentByName("ServerDiagnostics") as UAServerDiagnostics;
1322
+ if (!serverDiagnosticsNode) {
1323
+ return;
1324
+ }
1325
+ if (true) {
1326
+ // set serverDiagnosticsNode enabledFlag writeable for admin user only
1327
+ // TO DO ...
1328
+ serverDiagnosticsNode.enabledFlag.userAccessLevel = makeAccessLevelFlag("CurrentRead");
1329
+ serverDiagnosticsNode.enabledFlag.accessLevel = makeAccessLevelFlag("CurrentRead");
1330
+ }
1355
1331
 
1356
- prepareServerDiagnostics();
1332
+ // A Server may not expose the SamplingIntervalDiagnosticsArray if it does not use fixed sampling rates.
1333
+ // because we are not using fixed sampling rate, we need to remove the optional SamplingIntervalDiagnosticsArray
1334
+ // component
1335
+ const samplingIntervalDiagnosticsArray = serverDiagnosticsNode.getComponentByName(
1336
+ "SamplingIntervalDiagnosticsArray"
1337
+ );
1338
+ if (samplingIntervalDiagnosticsArray) {
1339
+ addressSpace.deleteNode(samplingIntervalDiagnosticsArray);
1340
+ const s = serverDiagnosticsNode.getComponents();
1341
+ }
1357
1342
 
1358
- this._internalState = "initialized";
1359
- this.setServerState(ServerState.Running);
1360
- setImmediate(() => callback());
1361
- });
1343
+ const subscriptionDiagnosticsArrayNode = serverDiagnosticsNode.getComponentByName(
1344
+ "SubscriptionDiagnosticsArray"
1345
+ )! as UADynamicVariableArray<SessionDiagnosticsDataType>;
1346
+ assert(subscriptionDiagnosticsArrayNode.nodeClass === NodeClass.Variable);
1347
+ bindExtObjArrayNode(subscriptionDiagnosticsArrayNode, "SubscriptionDiagnosticsType", "subscriptionId");
1348
+
1349
+ makeNotReadableIfEnabledFlagIsFalse(subscriptionDiagnosticsArrayNode);
1350
+
1351
+ const sessionsDiagnosticsSummary = serverDiagnosticsNode.getComponentByName("SessionsDiagnosticsSummary")!;
1352
+
1353
+ const sessionDiagnosticsArray = sessionsDiagnosticsSummary.getComponentByName(
1354
+ "SessionDiagnosticsArray"
1355
+ )! as UADynamicVariableArray<SessionDiagnosticsDataType>;
1356
+ assert(sessionDiagnosticsArray.nodeClass === NodeClass.Variable);
1357
+
1358
+ bindExtObjArrayNode(sessionDiagnosticsArray, "SessionDiagnosticsVariableType", "sessionId");
1359
+
1360
+ const varType = addressSpace.findVariableType("SessionSecurityDiagnosticsType");
1361
+ if (!varType) {
1362
+ debugLog("Warning cannot find SessionSecurityDiagnosticsType variable Type");
1363
+ } else {
1364
+ const sessionSecurityDiagnosticsArray = sessionsDiagnosticsSummary.getComponentByName(
1365
+ "SessionSecurityDiagnosticsArray"
1366
+ )! as UADynamicVariableArray<SessionSecurityDiagnosticsDataType>;
1367
+ assert(sessionSecurityDiagnosticsArray.nodeClass === NodeClass.Variable);
1368
+ bindExtObjArrayNode(sessionSecurityDiagnosticsArray, "SessionSecurityDiagnosticsType", "sessionId");
1369
+ ensureObjectIsSecure(sessionSecurityDiagnosticsArray);
1370
+ }
1371
+ };
1372
+
1373
+ prepareServerDiagnostics();
1374
+
1375
+ this._internalState = "initialized";
1376
+ this.setServerState(ServerState.Running);
1377
+ setImmediate(() => callback());
1378
+ });
1362
1379
  }
1363
1380
 
1364
1381
  public async browseWithAutomaticExpansion(
@@ -1425,12 +1442,6 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
1425
1442
 
1426
1443
  /**
1427
1444
  * create a new server session object.
1428
- * @class ServerEngine
1429
- * @method createSession
1430
- * @param [options] {Object}
1431
- * @param [options.sessionTimeout = 1000] {Number} sessionTimeout
1432
- * @param [options.clientDescription] {ApplicationDescription}
1433
- * @return {ServerSession}
1434
1445
  */
1435
1446
  public createSession(options?: CreateSessionOption): ServerSession {
1436
1447
  options = options || {};
@@ -1506,7 +1517,6 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
1506
1517
  }
1507
1518
 
1508
1519
  /**
1509
- * @method closeSession
1510
1520
  * @param authenticationToken
1511
1521
  * @param deleteSubscriptions {Boolean} : true if session's subscription shall be deleted
1512
1522
  * @param {String} [reason = "CloseSession"] the reason for closing the session (
@@ -1601,7 +1611,6 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
1601
1611
  }
1602
1612
 
1603
1613
  /**
1604
- * @method transferSubscription
1605
1614
  * @param session {ServerSession} - the new session that will own the subscription
1606
1615
  * @param subscriptionId {IntegerId} - the subscription Id to transfer
1607
1616
  * @param sendInitialValues {Boolean} - true if initial values will be resent.
@@ -1679,7 +1688,6 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
1679
1688
  /**
1680
1689
  * retrieve a session by its authenticationToken.
1681
1690
  *
1682
- * @method getSession
1683
1691
  * @param authenticationToken
1684
1692
  * @param activeOnly
1685
1693
  * @return {ServerSession}
@@ -1715,21 +1723,21 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
1715
1723
  *
1716
1724
  * performs a call to ```asyncRefresh``` on all variable nodes that provide an async refresh func.
1717
1725
  *
1718
- * @method refreshValues
1719
1726
  * @param nodesToRefresh {Array<ReadValueId|HistoryReadValueId>} an array containing the node to consider
1720
1727
  * Each element of the array shall be of the form { nodeId: <xxx>, attributeIds: <value> }.
1721
1728
  * @param maxAge {number} the maximum age of the value to be read, in milliseconds.
1722
1729
  * @param callback
1723
- * @param callback.err {Error}
1724
- * @param callback.dataValue {DataValue} an array containing value read
1725
- * The array length matches the number of nodeIds that are candidate for an async refresh (i.e: nodes that
1726
- * are of type Variable with asyncRefresh func }
1727
1730
  *
1728
- * @async
1729
1731
  */
1730
1732
  public refreshValues(
1731
1733
  nodesToRefresh: ReadValueId[] | HistoryReadValueId[],
1732
1734
  maxAge: number,
1735
+ /**
1736
+ * @param err
1737
+ * @param dataValues an array containing value read
1738
+ * The array length matches the number of nodeIds that are candidate for an
1739
+ * async refresh (i.e: nodes that are of type Variable with asyncRefresh func }
1740
+ */
1733
1741
  callback: (err: Error | null, dataValues?: DataValue[]) => void
1734
1742
  ): void {
1735
1743
  const referenceTime = getCurrentClock();
@@ -1880,8 +1888,8 @@ export class ServerEngine extends EventEmitter implements IAddressSpaceAccessor
1880
1888
  } else {
1881
1889
  warningLog(
1882
1890
  chalk.yellow("WARNING: cannot bind a method with id ") +
1883
- chalk.cyan(nodeId.toString()) +
1884
- chalk.yellow(". please check your nodeset.xml file or add this node programmatically")
1891
+ chalk.cyan(nodeId.toString()) +
1892
+ chalk.yellow(". please check your nodeset.xml file or add this node programmatically")
1885
1893
  );
1886
1894
  warningLog(traceFromThisProjectOnly());
1887
1895
  }