Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"use strict";
const factories = require("node-opcua-factory");
const SequenceHeader_Schema = {
name: "SequenceHeader",
id: factories.next_available_id(),
fields: [
// A monotonically increasing sequence number assigned by the sender to each
// MessageChunk sent over the ClientSecureChannelLayer.
{ name: "sequenceNumber", fieldType: "UInt32" },
// An identifier assigned by the client to OPC UA request Message. All MessageChunks for
// the request and the associated response use the same identifier.
{ name: "requestId", fieldType: "UInt32" }
]
};
exports.SequenceHeader_Schema = SequenceHeader_Schema;
function getLocalizeText_EncodingByte(localizedText) {
let encoding_mask = 0;
if (localizedText.locale) {
encoding_mask += 1;
}
if (localizedText.text) {
encoding_mask += 2;
}
return encoding_mask;
}
// see Part 3 - $8.5 page 63
const LocalizedText_Schema = {
name: "LocalizedText",
id: factories.next_available_id(),
fields: [
{ name: "text", fieldType: "String", defaultValue : function () { return null; } },
{ name: "locale", fieldType: "LocaleId" }
],
// OPCUA Part 6 $ 5.2.2.14 : localizedText have a special encoding
encode: function (localizedText, stream) {
const encoding_mask = getLocalizeText_EncodingByte(localizedText);
ec.encodeByte(encoding_mask, stream);
if ((encoding_mask & 0x01) === 0x01) {
ec.encodeString(localizedText.locale, stream);
}
if ((encoding_mask & 0x02) === 0x02) {
ec.encodeString(localizedText.text, stream);
}
},
"use strict";
const factories = require("node-opcua-factory");
// see Part 3 $8.3 and Part 6 $5.2.213
const QualifiedName_Schema = {
name: "QualifiedName",
id: factories.next_available_id(),
fields: [
{ name: "namespaceIndex", fieldType: "UInt16", documentation: "The namespace index" },
{ name: "name", fieldType: "String", defaultValue: function () {
return null;
}, documentation: "The name" }
]
};
exports.QualifiedName_Schema = QualifiedName_Schema;
if (dataValue.sourcePicoseconds ? dataValue.sourcePicoseconds % 100000 : false) {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.SourcePicoseconds);
}
if (dataValue.serverTimestamp && dataValue.serverTimestamp !== "null") {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.ServerTimestamp);
}
if (dataValue.serverPicoseconds ? dataValue.serverPicoseconds % 100000 : false) {
encoding_mask = set_flag(encoding_mask,DataValueEncodingByte.ServerPicoseconds);
}
return encoding_mask;
}
// OPC-UA part 4 - $7.7
const DataValue_Schema = {
name: "DataValue",
id: factories.next_available_id(),
fields: [
{ name:"value", fieldType:"Variant" , defaultValue: null },
{ name:"statusCode", fieldType:"StatusCode", defaultValue: StatusCodes.Good },
{ name:"sourceTimestamp", fieldType:"DateTime" , defaultValue: null },
{ name:"sourcePicoseconds", fieldType:"UInt16" , defaultValue: 0 },
{ name:"serverTimestamp", fieldType:"DateTime" , defaultValue: null },
{ name:"serverPicoseconds", fieldType:"UInt16" , defaultValue: 0 }
],
encode: function( dataValue, stream) {
const encoding_mask = getDataValue_EncodingByte(dataValue);
assert(_.isFinite(encoding_mask) && encoding_mask>=0 && encoding_mask<= 0x3F);
// write encoding byte
"use strict";
const factories = require("node-opcua-factory");
const ErrorMessage_Schema = {
name: "ErrorMessage",
id: factories.next_available_id(),
fields: [
{
name: "Error",
fieldType: "UInt32",
documentation: "The numeric code for the error. This shall be one of the values listed in Table 40."
},
{
name: "Reason",
fieldType: "String",
documentation: "A more verbose description of the error.This string shall not be more than 4096 characters."
}
]
};
exports.ErrorMessage_Schema = ErrorMessage_Schema;
"use strict";
const factories = require("node-opcua-factory");
const AcknowledgeMessage_Schema = {
name: "AcknowledgeMessage",
id: factories.next_available_id(),
fields: [
{ name: "protocolVersion" , fieldType: "UInt32" , documentation: "The latest version of the OPC UA TCP protocol supported by the Server." },
{ name: "receiveBufferSize" , fieldType: "UInt32" },
{ name: "sendBufferSize" , fieldType: "UInt32" },
{ name: "maxMessageSize" , fieldType: "UInt32" , documentation: "The maximum size for any request message."},
{ name: "maxChunkCount" , fieldType: "UInt32" , documentation: "The maximum number of chunks in any request message." }
]
};
exports.AcknowledgeMessage_Schema = AcknowledgeMessage_Schema;
"use strict";
const factories = require("node-opcua-factory");
const NodeClass = require("node-opcua-data-model").NodeClass;
const resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
const ReferenceDescription_Schema = {
name: "ReferenceDescription",
documentation: "The description of a reference.",
id: factories.next_available_id(),
fields: [
{name: "referenceTypeId", fieldType: "NodeId", documentation: "The type of references."},
{name: "isForward", fieldType: "Boolean", documentation: "TRUE if the reference is a forward reference."},
{name: "nodeId", fieldType: "ExpandedNodeId", documentation: "The id of the target node."},
{name: "browseName", fieldType: "QualifiedName", documentation: "The browse name of the target node."},
{name: "displayName", fieldType: "LocalizedText", documentation: "The display name of the target node."},
{name: "nodeClass", fieldType: "NodeClass", defaultValue:NodeClass.Unspecified, documentation: "The node class of the target node."},
{name: "typeDefinition", fieldType: "ExpandedNodeId", documentation: "The type definition of the target node."}
]
};
exports.ReferenceDescription_Schema = ReferenceDescription_Schema;
"use strict";
const factories = require("node-opcua-factory");
const EventFieldList_Schema = {
id: factories.next_available_id(),
name: "EventFieldList",
fields: [
{name: "clientHandle", fieldType: "IntegerId", documentation: "Client-supplied handle for the MonitoredItem"},
{
name: "eventFields",
fieldType: "Variant",
isArray: true,
documentation: "List of selected Event fields. This shall be a one to one match with the fields selected in the EventFilter."
}
]
};
exports.EventFieldList_Schema = EventFieldList_Schema;
tracer.trace("member", "Variant", "...", cursor_before, stream.length, dataType.key);
tracer.trace("end_element", "", n1);
}
tracer.trace("end_array", "Variant", stream.length);
}
function decodeDimension(stream) {
return decodeGeneralArray(DataType.UInt32, stream);
}
function encodeDimension(dimensions, stream) {
return encodeGeneralArray(DataType.UInt32, stream, dimensions);
}
const Variant_Schema = {
name: "Variant",
id: factories.next_available_id(),
fields: [{
name: "dataType",
fieldType: "DataType",
defaultValue: DataType.Null,
documentation: "the variant type."
}, {
name: "arrayType",
fieldType: "VariantArrayType",
defaultValue: VariantArrayType.Scalar
}, {
name: "value",
fieldType: "Any",
defaultValue: null
}, {
name: "dimensions",
fieldType: "UInt32",
"use strict";
require("node-opcua-data-model");
require("node-opcua-service-endpoints");
const factories = require("node-opcua-factory");
const RegisteredServer_Schema = {
documentation:"The information required to register a server with a discovery server.",
name: "RegisteredServer",
id: factories.next_available_id(),
fields: [
{name:"serverUri", fieldType:"String", documentation:"The globally unique identifier for the server." },
{name:"productUri", fieldType:"String", documentation:"The globally unique identifier for the product." },
{name:"serverNames", isArray:true, fieldType:"LocalizedText", documentation:"The name of server in multiple lcoales." },
{name:"serverType", fieldType:"ApplicationType", documentation:"The type of server." },
{name:"gatewayServerUri", fieldType:"String" , documentation:"The globally unique identifier for the server that is acting as a gateway for the server." },
{name:"discoveryUrls", isArray:true, fieldType:"String" , documentation:"The URLs for the server's discovery endpoints." },
{name:"semaphoreFilePath", fieldType:"String" , documentation:"A path to a file that is deleted when the server is no longer accepting connections." },
{name:"isOnline", fieldType:"Boolean" , documentation:"If FALSE the server will save the registration information to a persistent datastore." }
]
};
exports.RegisteredServer_Schema = RegisteredServer_Schema;