Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should bind an xml-preloaded Extension Object Variable : ServerStatus ", function (done) {
// in this test, we verify that we can easily bind the Server_ServerStatus object
// the process shall automatically bind variables and substructures recursively
var VariableIds = require("node-opcua-constants").VariableIds;
var makeNodeId = require("node-opcua-nodeid").makeNodeId;
var serverStatus = addressSpace.findNode(makeNodeId(VariableIds.Server_ServerStatus));
serverStatus.browseName.toString().should.eql("ServerStatus");
// before bindExtensionObject is called, startTime property exists but is not bound
serverStatus.should.have.property("startTime");
serverStatus.startTime.readValue().value.dataType.should.eql(DataType.Null);
serverStatus.readValue().value.dataType.should.eql(DataType.Null);
//Xx value.startTime.should.eql(DataType.Null);
//xx debugLog("serverStatus.startTime =",serverStatus.startTime.readValue().value.toString());
serverStatus.bindExtensionObject();
/* global describe,it,before*/
const should = require("should");
const assert = require("node-opcua-assert").assert;
const DataType = require("node-opcua-variant").DataType;
const NodeClass = require("node-opcua-data-model").NodeClass;
const resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
const ObjectTypeIds = require("node-opcua-constants").ObjectTypeIds;
const VariableTypeIds = require("node-opcua-constants").VariableTypeIds;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const ObjectIds = require("node-opcua-constants").ObjectIds;
const DataTypeIds = require("node-opcua-constants").DataTypeIds;
const Reference = require("..").Reference;
function dumpReferencesHierarchy(addressSpace) {
function _dump(referenceType,level) {
console.log(level,referenceType.browseName.toString(),"(",referenceType.getAllSubtypes().map(x=>x.browseName.toString()).join(" ").green,")");
const subTypes = referenceType.findReferencesExAsObject("HasSubtype");
for(let subType of subTypes) {
_dump(subType," "+ level);
/* global describe,it,before*/
const should = require("should");
const assert = require("node-opcua-assert").assert;
const DataType = require("node-opcua-variant").DataType;
const NodeClass = require("node-opcua-data-model").NodeClass;
const resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
const ObjectTypeIds = require("node-opcua-constants").ObjectTypeIds;
const VariableTypeIds = require("node-opcua-constants").VariableTypeIds;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const ObjectIds = require("node-opcua-constants").ObjectIds;
const DataTypeIds = require("node-opcua-constants").DataTypeIds;
const Reference = require("..").Reference;
function dumpReferencesHierarchy(addressSpace) {
function _dump(referenceType,level) {
console.log(level,referenceType.browseName.toString(),"(",referenceType.getAllSubtypes().map(x=>x.browseName.toString()).join(" ").green,")");
const subTypes = referenceType.findReferencesExAsObject("HasSubtype");
for(let subType of subTypes) {
_dump(subType," "+ level);
it("should bind an xml-preloaded Extension Object Variable : ServerStatus ", function (done) {
// in this test, we verify that we can easily bind the Server_ServerStatus object
// the process shall automatically bind variables and substructures recursively
var VariableIds = require("node-opcua-constants").VariableIds;
var makeNodeId = require("node-opcua-nodeid").makeNodeId;
var serverStatus = addressSpace.findNode(makeNodeId(VariableIds.Server_ServerStatus));
serverStatus.browseName.toString().should.eql("ServerStatus");
// before bindExtensionObject is called, startTime property exists but is not bound
serverStatus.should.have.property("startTime");
serverStatus.startTime.readValue().value.dataType.should.eql(DataType.Null);
serverStatus.readValue().value.dataType.should.eql(DataType.Null);
//Xx value.startTime.should.eql(DataType.Null);
//xx debugLog("serverStatus.startTime =",serverStatus.startTime.readValue().value.toString());
serverStatus.bindExtensionObject();
serverStatus.readValue().value.value.startTime.toISOString().should.eql("1601-01-01T00:00:00.000Z");
serverStatus.startTime.readValue().value.value.toISOString().should.eql("1601-01-01T00:00:00.000Z");
/* global describe,it,before*/
const should = require("should");
const assert = require("node-opcua-assert").assert;
const DataType = require("node-opcua-variant").DataType;
const NodeClass = require("node-opcua-data-model").NodeClass;
const resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
const ObjectTypeIds = require("node-opcua-constants").ObjectTypeIds;
const VariableTypeIds = require("node-opcua-constants").VariableTypeIds;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const ObjectIds = require("node-opcua-constants").ObjectIds;
const DataTypeIds = require("node-opcua-constants").DataTypeIds;
const Reference = require("..").Reference;
function dumpReferencesHierarchy(addressSpace) {
function _dump(referenceType,level) {
console.log(level,referenceType.browseName.toString(),"(",referenceType.getAllSubtypes().map(x=>x.browseName.toString()).join(" ").green,")");
const subTypes = referenceType.findReferencesExAsObject("HasSubtype");
nodeClass: NodeClass.Object,
nodeId: resolveNodeId(ObjectIds.ModellingRule_Mandatory),
}) as any as UAObject;
// add the root folder
{
const rootFolder = namespace0._createNode({
browseName: "RootFolder",
nodeClass: NodeClass.Object,
nodeId: resolveNodeId(ObjectIds.RootFolder)
}) as any as UAObject;
{
const objectsFolder = namespace0.addObject({
browseName: "Objects",
nodeId: resolveNodeId(ObjectIds.ObjectsFolder),
organizedBy: rootFolder
});
assert(rootFolder.getFolderElementByName("Objects")!
.browseName.toString() === "Objects");
}
{
const dataTypeFolder = namespace0.addObject({
browseName: "DataType",
nodeId: resolveNodeId(ObjectIds.DataTypesFolder),
organizedBy: rootFolder
});
{
const doubleDataType = namespace0._createNode({
browseName: "Double",
isAbstract: true
});
// add the root folder
{
const rootFolder = namespace0._createNode({
browseName: "RootFolder",
nodeId: resolveNodeId(ObjectIds.RootFolder),
nodeClass: NodeClass.Object
});
{
const objectsFolder = namespace0.addObject({
browseName: "Objects",
nodeId: resolveNodeId(ObjectIds.ObjectsFolder),
organizedBy: rootFolder
});
rootFolder.getFolderElementByName("Objects").browseName.toString().should.eql("Objects");
}
{
const dataTypeFolder = namespace0.addObject({
browseName: "DataType",
nodeId: resolveNodeId(ObjectIds.DataTypesFolder),
organizedBy: rootFolder
});
{
const doubleDataType = namespace0._createNode({
browseName: "Double",
nodeId: resolveNodeId(DataTypeIds.Double),
const now = Date.now();
const session = this;
console.log(" name..................... ", session.name);
console.log(" sessionId................ ", session.sessionId.toString());
console.log(" authenticationToken...... ", session.authenticationToken.toString());
console.log(" timeout.................. ", session.timeout , "ms");
console.log(" serverNonce.............. ", session.serverNonce.toString("hex"));
console.log(" serverCertificate........ ", session.serverCertificate.toString("base64"));
console.log(" serverSignature.......... ", session.serverSignature);
console.log(" lastRequestSentTime...... ", new Date(session.lastRequestSentTime).toISOString(), now - session.lastRequestSentTime);
console.log(" lastResponseReceivedTime. ", new Date(session.lastResponseReceivedTime).toISOString(), now - session.lastResponseReceivedTime);
};
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const resultMask = makeResultMask("ReferenceType");
function __findBasicDataType(session, dataTypeId, callback) {
assert(dataTypeId instanceof NodeId);
if (dataTypeId.value <= 25) {
// we have a well-known DataType
const dataType = DataType.get(dataTypeId.value);
callback(null, dataType);
} else {
// let's browse for the SuperType of this object
const nodeToBrowse = new browse_service.BrowseDescription({
referenceTypeId: makeNodeId(ReferenceTypeIds.HasSubtype),
function bindExtraStuff() {
// mainly for compliance
// The version number for the data type description. i=104
bindStandardScalar(VariableIds.DataTypeDescriptionType_DataTypeVersion,
DataType.UInt16, () => {
return 0.0;
});
const nrt = addressSpace.findDataType(resolveNodeId(DataTypeIds.NamingRuleType))!;
// xx console.log(nrt.toString());
if (nrt) {
const namingRuleType = (nrt as any)._getDefinition().nameIndex; // getEnumeration("NamingRuleType");
// i=111
bindStandardScalar(VariableIds.ModellingRuleType_NamingRule,
DataType.UInt16, () => {
return 0;
});
// i=112
bindStandardScalar(VariableIds.ModellingRule_Mandatory_NamingRule,
module.exports.NumericRange = require("node-opcua-numeric-range").NumericRange;
module.exports.AccessLevelFlag = require("node-opcua-data-model").AccessLevelFlag;
module.exports.makeAccessLevel = require("node-opcua-data-model").makeAccessLevel;
module.exports.LocalizedText = require("node-opcua-data-model").LocalizedText;
module.exports.coerceLocalizedText = require("node-opcua-data-model").coerceLocalizedText;
module.exports.QualifiedName = require("node-opcua-data-model").QualifiedName;
module.exports.coerceQualifyName = require("node-opcua-data-model").coerceQualifyName;
module.exports.NodeClass = require("node-opcua-data-model").NodeClass;
module.exports.NodeClassMask = require("node-opcua-data-model").NodeClassMask;
module.exports.AttributeIds = require("node-opcua-data-model").AttributeIds;
module.exports.AttributeNameById = require("node-opcua-data-model").AttributeNameById;
module.exports.BrowseDirection = require("node-opcua-data-model").BrowseDirection;
module.exports.VariableTypeIds = require("node-opcua-constants").VariableTypeIds;
module.exports.VariableIds = require("node-opcua-constants").VariableIds;
module.exports.MethodIds = require("node-opcua-constants").MethodIds;
module.exports.ObjectIds = require("node-opcua-constants").ObjectIds;
module.exports.ObjectTypeIds = require("node-opcua-constants").ObjectTypeIds;
module.exports.ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
module.exports.DataTypeIds = require("node-opcua-constants").DataTypeIds;
// DA
module.exports.standardUnits = require("node-opcua-data-access").standardUnits;
module.exports.makeEUInformation = require("node-opcua-data-access").makeEUInformation;
module.exports.Range = require("node-opcua-data-access").Range;
//
module.exports.get_fully_qualified_domain_name = require("node-opcua-hostname").get_fully_qualified_domain_name;
module.exports.makeApplicationUrn = require("node-opcua-common").makeApplicationUrn;
// services