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.
- package/dist/addressSpace_accessor.js +1 -1
- package/dist/addressSpace_accessor.js.map +1 -1
- package/dist/base_server.d.ts +0 -11
- package/dist/base_server.js +0 -11
- package/dist/base_server.js.map +1 -1
- package/dist/filter/extract_event_fields.d.ts +1 -1
- package/dist/filter/extract_event_fields.js +1 -1
- package/dist/monitored_item.d.ts +2 -6
- package/dist/monitored_item.js +2 -6
- package/dist/monitored_item.js.map +1 -1
- package/dist/opcua_server.d.ts +2 -19
- package/dist/opcua_server.js +2 -17
- package/dist/opcua_server.js.map +1 -1
- package/dist/register_server_manager.d.ts +0 -4
- package/dist/register_server_manager.js +0 -4
- package/dist/register_server_manager.js.map +1 -1
- package/dist/server_end_point.d.ts +0 -16
- package/dist/server_end_point.js +0 -16
- package/dist/server_end_point.js.map +1 -1
- package/dist/server_engine.d.ts +8 -24
- package/dist/server_engine.js +43 -57
- package/dist/server_engine.js.map +1 -1
- package/dist/server_publish_engine.d.ts +0 -1
- package/dist/server_publish_engine.js +0 -1
- package/dist/server_publish_engine.js.map +1 -1
- package/dist/server_session.d.ts +0 -6
- package/dist/server_session.js +1 -7
- package/dist/server_session.js.map +1 -1
- package/dist/server_subscription.d.ts +2 -1
- package/dist/server_subscription.js +2 -1
- package/dist/server_subscription.js.map +1 -1
- package/package.json +43 -43
- package/source/addressSpace_accessor.ts +2 -2
- package/source/base_server.ts +0 -11
- package/source/filter/extract_event_fields.ts +1 -1
- package/source/monitored_item.ts +2 -6
- package/source/opcua_server.ts +2 -25
- package/source/register_server_manager.ts +0 -4
- package/source/server_end_point.ts +0 -16
- package/source/server_engine.ts +508 -500
- package/source/server_publish_engine.ts +0 -1
- package/source/server_session.ts +2 -8
- package/source/server_subscription.ts +2 -1
package/source/server_engine.ts
CHANGED
|
@@ -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,
|
|
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)
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
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
|
-
|
|
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
|
-
|
|
821
|
-
|
|
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
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
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
|
-
|
|
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.
|
|
874
|
-
dataType,
|
|
875
|
-
value:
|
|
797
|
+
arrayType: VariantArrayType.Array,
|
|
798
|
+
dataType: DataType.String,
|
|
799
|
+
value: addressSpace.getNamespaceArray().map((x) => x.namespaceUri)
|
|
876
800
|
});
|
|
877
801
|
},
|
|
878
|
-
set:
|
|
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
|
-
|
|
889
|
-
|
|
890
|
-
|
|
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(
|
|
814
|
+
bindVariableIfPresent(server_ServerArray_Id, {
|
|
893
815
|
get() {
|
|
894
|
-
|
|
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
|
-
|
|
909
|
-
|
|
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
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
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
|
-
|
|
920
|
-
return 255;
|
|
921
|
-
});
|
|
858
|
+
const nodeId = makeNodeId(id);
|
|
922
859
|
|
|
923
|
-
|
|
924
|
-
|
|
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
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
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
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
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
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
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
|
-
|
|
980
|
-
makeNodeId(VariableIds.Server_ServerStatus_CurrentTime)
|
|
981
|
-
) as UAVariable;
|
|
905
|
+
bindStandardScalar(VariableIds.Server_EstimatedReturnTime, DataType.DateTime, () => getMinOPCUADate());
|
|
982
906
|
|
|
983
|
-
|
|
984
|
-
|
|
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
|
-
|
|
991
|
-
|
|
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
|
-
|
|
918
|
+
bindStandardScalar(VariableIds.Server_ServiceLevel, DataType.Byte, () => {
|
|
919
|
+
return 255;
|
|
920
|
+
});
|
|
995
921
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
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
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
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
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
965
|
+
const bindServerStatus = () => {
|
|
966
|
+
const serverStatusNode = addressSpace.findNode(
|
|
967
|
+
makeNodeId(VariableIds.Server_ServerStatus)
|
|
968
|
+
) as UAServerStatus<DTServerStatus>;
|
|
1024
969
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
970
|
+
if (!serverStatusNode) {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
if (serverStatusNode) {
|
|
974
|
+
serverStatusNode.bindExtensionObject(this._serverStatus);
|
|
975
|
+
serverStatusNode.minimumSamplingInterval = 1000;
|
|
976
|
+
}
|
|
1028
977
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
978
|
+
const currentTimeNode = addressSpace.findNode(
|
|
979
|
+
makeNodeId(VariableIds.Server_ServerStatus_CurrentTime)
|
|
980
|
+
) as UAVariable;
|
|
1032
981
|
|
|
1033
|
-
|
|
1034
|
-
|
|
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
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
989
|
+
if (secondsTillShutdown) {
|
|
990
|
+
secondsTillShutdown.minimumSamplingInterval = 1000;
|
|
991
|
+
}
|
|
1040
992
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
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
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
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
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1020
|
+
bindStandardArray(VariableIds.Server_ServerCapabilities_LocaleIdArray, DataType.String, "LocaleId", () => {
|
|
1021
|
+
return this.serverCapabilities.localeIdArray;
|
|
1022
|
+
});
|
|
1085
1023
|
|
|
1086
|
-
|
|
1087
|
-
|
|
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
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1031
|
+
bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxBrowseContinuationPoints, DataType.UInt16, () => {
|
|
1032
|
+
return this.serverCapabilities.maxBrowseContinuationPoints;
|
|
1033
|
+
});
|
|
1093
1034
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1035
|
+
bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxQueryContinuationPoints, DataType.UInt16, () => {
|
|
1036
|
+
return this.serverCapabilities.maxQueryContinuationPoints;
|
|
1037
|
+
});
|
|
1097
1038
|
|
|
1098
|
-
|
|
1099
|
-
|
|
1039
|
+
bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxHistoryContinuationPoints, DataType.UInt16, () => {
|
|
1040
|
+
return this.serverCapabilities.maxHistoryContinuationPoints;
|
|
1041
|
+
});
|
|
1100
1042
|
|
|
1101
|
-
|
|
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
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
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
|
-
|
|
1109
|
-
|
|
1110
|
-
});
|
|
1092
|
+
bindStandardScalar(VariableIds.Server_ServerCapabilities_MaxStringLength, DataType.UInt32, () => {
|
|
1093
|
+
return Math.min(this.serverCapabilities.maxStringLength, BinaryStream.maxStringLength);
|
|
1111
1094
|
});
|
|
1112
|
-
};
|
|
1113
1095
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
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
|
-
|
|
1130
|
-
};
|
|
1135
|
+
fix_ProgramStateMachineType_ProgramDiagnostics();
|
|
1136
|
+
};
|
|
1131
1137
|
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1138
|
+
const bindHistoryServerCapabilities = () => {
|
|
1139
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_MaxReturnDataValues, DataType.UInt32, () => {
|
|
1140
|
+
return this.historyServerCapabilities.maxReturnDataValues;
|
|
1141
|
+
});
|
|
1136
1142
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1143
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_MaxReturnEventValues, DataType.UInt32, () => {
|
|
1144
|
+
return this.historyServerCapabilities.maxReturnEventValues;
|
|
1145
|
+
});
|
|
1140
1146
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
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
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1167
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertEventCapability, DataType.Boolean, () => {
|
|
1168
|
+
return this.historyServerCapabilities.insertEventCapability;
|
|
1169
|
+
});
|
|
1160
1170
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1171
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceEventCapability, DataType.Boolean, () => {
|
|
1172
|
+
return this.historyServerCapabilities.replaceEventCapability;
|
|
1173
|
+
});
|
|
1164
1174
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1175
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateEventCapability, DataType.Boolean, () => {
|
|
1176
|
+
return this.historyServerCapabilities.updateEventCapability;
|
|
1177
|
+
});
|
|
1168
1178
|
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1179
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteEventCapability, DataType.Boolean, () => {
|
|
1180
|
+
return this.historyServerCapabilities.deleteEventCapability;
|
|
1181
|
+
});
|
|
1172
1182
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1183
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteRawCapability, DataType.Boolean, () => {
|
|
1184
|
+
return this.historyServerCapabilities.deleteRawCapability;
|
|
1185
|
+
});
|
|
1176
1186
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1187
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteAtTimeCapability, DataType.Boolean, () => {
|
|
1188
|
+
return this.historyServerCapabilities.deleteAtTimeCapability;
|
|
1189
|
+
});
|
|
1180
1190
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1191
|
+
bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertAnnotationCapability, DataType.Boolean, () => {
|
|
1192
|
+
return this.historyServerCapabilities.insertAnnotationCapability;
|
|
1193
|
+
});
|
|
1194
|
+
};
|
|
1185
1195
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
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
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
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
|
-
|
|
1231
|
+
bindServerDiagnostics();
|
|
1222
1232
|
|
|
1223
|
-
|
|
1233
|
+
bindServerStatus();
|
|
1224
1234
|
|
|
1225
|
-
|
|
1235
|
+
bindServerCapabilities();
|
|
1226
1236
|
|
|
1227
|
-
|
|
1237
|
+
bindServerConfigurationBasic();
|
|
1228
1238
|
|
|
1229
|
-
|
|
1239
|
+
bindHistoryServerCapabilities();
|
|
1230
1240
|
|
|
1231
|
-
|
|
1232
|
-
|
|
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
|
-
|
|
1281
|
+
bindExtraStuff();
|
|
1272
1282
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
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
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
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
|
-
|
|
1300
|
-
|
|
1301
|
-
}
|
|
1308
|
+
const prepareServerDiagnostics = () => {
|
|
1309
|
+
const addressSpace1 = this.addressSpace!;
|
|
1302
1310
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
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
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
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
|
-
|
|
1327
|
-
"
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
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
|
-
|
|
1884
|
-
|
|
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
|
}
|