Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
serverStatus.startTime.setValueFromSource({dataType: DataType.DateTime, value: new Date(Date.UTC(2100, 0, 1))});
serverStatus.readValue().value.value.startTime.toISOString().should.eql("2100-01-01T00:00:00.000Z");
serverStatus.startTime.readValue().value.value.toISOString().should.eql("2100-01-01T00:00:00.000Z");
//xx debugLog(serverStatus.readValue().value.toString());
serverStatus.readValue().value.value.buildInfo.productName = "productName1";
serverStatus.readValue().value.value.buildInfo.productName.should.eql("productName1");
serverStatus.buildInfo.productName.readValue().value.value.should.eql("productName1");
serverStatus.buildInfo.productName.setValueFromSource({dataType: DataType.String, value: "productName2"});
serverStatus.readValue().value.value.buildInfo.productName.should.eql("productName2");
serverStatus.buildInfo.productName.readValue().value.value.should.eql("productName2");
var async = require("async");
var StatusCodes = require("node-opcua-status-code").StatusCodes;
var write_service = require("node-opcua-service-write");
var WriteValue = write_service.WriteValue;
var makeAccessLevel = require("node-opcua-data-model").makeAccessLevel;
// now use WriteValue instead
// make sure value is writable
var rw = makeAccessLevel("CurrentRead | CurrentWrite");
serverStatus.buildInfo.productName.accessLevel = rw;
serverStatus.buildInfo.productName.userAccessLevel = rw;
serverStatus.buildInfo.accessLevel = rw;
serverStatus.buildInfo.userAccessLevel = rw;
serverStatus.accessLevel = rw;
serverStatus.userAccessLevel = rw;
const coerceLocalizedText = require("node-opcua-data-model").coerceLocalizedText;
const attributeNameById = require("node-opcua-data-model").attributeNameById;
const ResultMask = require("node-opcua-data-model").ResultMask;
const NodeClass = require("node-opcua-data-model").NodeClass;
const makeNodeClassMask = require("node-opcua-data-model").makeNodeClassMask;
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const BrowseDirection = require("node-opcua-data-model").BrowseDirection;
const AccessLevelFlag = require("node-opcua-data-model").AccessLevelFlag;
const ReferenceDescription = require("node-opcua-service-browse").ReferenceDescription;
const DataValue = require("node-opcua-data-value").DataValue;
const DataType = require("node-opcua-variant").DataType;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
exports.BrowseDirection = BrowseDirection;
const SessionContext = require("./session_context").SessionContext;
const Reference = require("./reference").Reference;
let ReferenceType = null;// will be defined after baseNode is defined
const doDebug = false;
function defaultBrowseFilterFunc(session) {
return true;
}
//---------------------------------------------------------------------------------------------------------------------
// Common
// ---------------------------------------------------------------------------------------------------------------------
module.exports.NodeId = require("node-opcua-nodeid").NodeId;
module.exports.resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
module.exports.makeNodeId = require("node-opcua-nodeid").makeNodeId;
module.exports.coerceNodeId = require("node-opcua-nodeid").coerceNodeId;
module.exports.sameNodeId = require("node-opcua-nodeid").sameNodeId;
module.exports.NodeIdType = require("node-opcua-nodeid").NodeIdType;
module.exports.ExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").ExpandedNodeId;
module.exports.makeExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").makeExpandedNodeId;
module.exports.coerceExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").coerceExpandedNodeId;
module.exports.StatusCodes = require("node-opcua-status-code").StatusCodes;
module.exports.Enum = require("node-opcua-enum");
module.exports.DataType = require("node-opcua-variant").DataType;
module.exports.Variant = require("node-opcua-variant").Variant;
module.exports.VariantArrayType = require("node-opcua-variant").VariantArrayType;
module.exports.buildVariantArray = require("node-opcua-variant").buildVariantArray;
module.exports.DataValue = require("node-opcua-data-value").DataValue;
module.exports.sameDataValue = require("node-opcua-data-value").sameDataValue;
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;
const assert = require("node-opcua-assert").assert;
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const BrowseDirection = require("node-opcua-data-model").BrowseDirection;
const QualifiedName = require("node-opcua-data-model").QualifiedName;
const LocalizedText = require("node-opcua-data-model").LocalizedText;
const NodeClass = require("node-opcua-data-model").NodeClass;
const BrowseDescription = require("node-opcua-service-browse").BrowseDescription;
const resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
const NodeId = require("node-opcua-nodeid").NodeId;
const sameNodeId = require("node-opcua-nodeid").sameNodeId;
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const browse_service = require("node-opcua-service-browse");
const lowerFirstLetter = require("node-opcua-utils").lowerFirstLetter;
const VariableIds = require("node-opcua-constants").VariableIds;
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
//
// some server do not expose the ReferenceType Node in their address space
// ReferenceType are defined by the OPCUA standard and can be prepopulated in the crawler.
// Pre-populating the ReferenceType node in the crawler will also reduce the network traffic.
//
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
"use strict";
const _ = require("underscore");
const subscription_service = require("node-opcua-service-subscription");
const assert = require("node-opcua-assert").assert;
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename);
const StatusCodes = require("node-opcua-status-code").StatusCodes;
//xx var debugLog = console.log;
/**
* A client side implementation to deal with publish service.
*
* The ClientSidePublishEngine encapsulates the mechanism to
* deal with a OPCUA Server and constantly sending PublishRequest
* The ClientSidePublishEngine also performs notification acknowledgements.
* Finally, ClientSidePublishEngine dispatch PublishResponse to the correct
* Subscription id callback
*
* @class ClientSidePublishEngine
* @constructor
* @param session {ClientSession} - the client session
*
const NodeClass = require("node-opcua-data-model").NodeClass;
const NodeId = require("node-opcua-nodeid").NodeId;
const coerceNodeId = require("node-opcua-nodeid").coerceNodeId;
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
const sameNodeId = require("node-opcua-nodeid").sameNodeId;
const DataValue = require("node-opcua-data-value").DataValue;
const Variant = require("node-opcua-variant").Variant;
const DataType = require("node-opcua-variant").DataType;
const VariantArrayType = require("node-opcua-variant").VariantArrayType;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const isNullOrUndefined = require("node-opcua-utils").isNullOrUndefined;
const BrowseDirection = require("node-opcua-data-model").BrowseDirection;
const SessionContext = require("./session_context").SessionContext;
const Reference = require("./reference").Reference;
const debug = require("node-opcua-debug");
const debugLog = debug.make_debugLog(__filename);
const doDebug = debug.checkDebugFlag(__filename);
"use strict";
/**
* @module opcua.client
*/
const util = require("util");
const _ = require("underscore");
const assert = require("node-opcua-assert").assert;
const crypto = require("crypto");
const async = require("async");
const chalk = require("chalk");
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const session_service = require("node-opcua-service-session");
const AnonymousIdentityToken = session_service.AnonymousIdentityToken;
const CreateSessionRequest = session_service.CreateSessionRequest;
const CreateSessionResponse = session_service.CreateSessionResponse;
const ActivateSessionRequest = session_service.ActivateSessionRequest;
const ActivateSessionResponse = session_service.ActivateSessionResponse;
const CloseSessionRequest = session_service.CloseSessionRequest;
const endpoints_service = require("node-opcua-service-endpoints");
const ApplicationDescription = endpoints_service.ApplicationDescription;
const ApplicationType = endpoints_service.ApplicationType;
const EndpointDescription = endpoints_service.EndpointDescription;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
* @module opcua.address_space
*/
const assert = require("node-opcua-assert").assert;
const _ = require("underscore");
const util = require("util");
const utils = require("node-opcua-utils");
const NodeClass = require("node-opcua-data-model").NodeClass;
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const DataValue = require("node-opcua-data-value").DataValue;
const DataType = require("node-opcua-variant").DataType;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const BaseNode = require("./base_node").BaseNode;
const SessionContext = require("./session_context").SessionContext;
/**
* @class UAObjectType
* @param options
* @constructor
*/
function UAObjectType(options) {
BaseNode.apply(this, arguments);
this.isAbstract = utils.isNullOrUndefined(options.isAbstract) ? false : options.isAbstract;
}
util.inherits(UAObjectType, BaseNode);
UAObjectType.prototype.nodeClass = NodeClass.ObjectType;
"use strict";
/**
* @module opcua.server
*/
const Dequeue = require("dequeue");
const subscription_service = require("node-opcua-service-subscription");
const DataChangeNotification = subscription_service.DataChangeNotification;
const EventNotificationList = subscription_service.EventNotificationList;
const NotificationMessage = subscription_service.NotificationMessage;
const StatusChangeNotification = subscription_service.StatusChangeNotification;
const MonitoringMode = subscription_service.MonitoringMode;
const NodeId = require("node-opcua-nodeid").NodeId;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const Enum = require("node-opcua-enum").Enum;
const assert = require("node-opcua-assert").assert;
const NodeClass = require("node-opcua-data-model").NodeClass;
const _ = require("underscore");
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const SequenceNumberGenerator = require("node-opcua-secure-channel").SequenceNumberGenerator;
const EventEmitter = require("events").EventEmitter;
const util = require("util");
const SessionContext = require("node-opcua-address-space").SessionContext;
const EventFilter = require("node-opcua-service-filter").EventFilter;
const DataChangeFilter = require("node-opcua-service-subscription").DataChangeFilter;
"use strict";
/*global: require Buffer*/
/**
* @module opcua.server
*/
const assert = require("node-opcua-assert").assert;
const async = require("async");
const util = require("util");
const fs = require("fs");
const _ = require("underscore");
const ApplicationType = require("node-opcua-service-endpoints").ApplicationType;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const SessionContext = require("node-opcua-address-space").SessionContext;
const fromURI = require("node-opcua-secure-channel").fromURI;
const SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const utils = require("node-opcua-utils");
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const forceGarbageCollectionOnSessionClose = false;
const ServerEngine = require("./server_engine").ServerEngine;
const browse_service = require("node-opcua-service-browse");
const read_service = require("node-opcua-service-read");
const write_service = require("node-opcua-service-write");