本文整理匯總了TypeScript中node-opcua-data-model.makeNodeClassMask函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript makeNodeClassMask函數的具體用法?TypeScript makeNodeClassMask怎麽用?TypeScript makeNodeClassMask使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了makeNodeClassMask函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("should browse multiple nodes ", async () => {
const nodeToBrowse = /*BrowseDescription*/ {
browseDirection: BrowseDirection.Forward,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Object"),
nodeId: "i=84",
referenceTypeId: null,
resultMask: makeResultMask("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
};
const browseResults = await session.browse([nodeToBrowse, nodeToBrowse]);
browseResults.should.be.instanceOf(Array);
browseResults[0].constructor.name.should.eql("BrowseResult");
browseResults[0].references!.length.should.eql(3);
browseResults[0].references![0].browseName.toString().should.eql("Objects");
browseResults[0].references![1].browseName.toString().should.eql("Types");
browseResults[0].references![2].browseName.toString().should.eql("Views");
browseResults[1].constructor.name.should.eql("BrowseResult");
browseResults[1].references!.length.should.eql(3);
browseResults[1].references![0].browseName.toString().should.eql("Objects");
browseResults[1].references![1].browseName.toString().should.eql("Types");
browseResults[1].references![2].browseName.toString().should.eql("Views");
});
示例2: makeNodeClassMask
const nodesToBrowse2 = references.map((ref: ReferenceDescription) => {
return {
browseDirection: BrowseDirection.Inverse,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Object | Variable"),
nodeId: ref.nodeId,
referenceTypeId: resolveNodeId("HasDescription"),
resultMask: makeResultMask("NodeId | ReferenceType | BrowseName | NodeClass | TypeDefinition")
};
});
示例3: extractNamespaceDataType
export async function extractNamespaceDataType(
session: IBasicSession,
dataTypeManager: ExtraDataTypeManager
) {
// read namespace array
const dataValueNamespaceArray = await session.read({
attributeId: AttributeIds.Value,
nodeId: resolveNodeId("Server_NamespaceArray")
});
if (dataValueNamespaceArray.statusCode === StatusCodes.Good) {
dataTypeManager.setNamespaceArray(dataValueNamespaceArray.value.value as string[]);
}
// DatType/OPCBinary => i=93 [OPCBinarySchema_TypeSystem]
const opcBinaryNodeId = resolveNodeId("OPCBinarySchema_TypeSystem");
const nodeToBrowse = {
browseDirection: BrowseDirection.Forward,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Variable"),
nodeId: opcBinaryNodeId,
referenceTypeId: resolveNodeId("HasComponent"),
resultMask: makeResultMask("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
};
const result = await session.browse(nodeToBrowse);
// filter nodes that have the expected namespace Index
const references = result.references!.filter(
(e: ReferenceDescription) => e.nodeId.namespace !== 0);
/* istanbul ignore next */
if (references.length === 0) {
return;
}
for (const ref of references) {
const typeDictionary = await extractSchema(session, ref.nodeId);
await exploreDataTypeDefinition(session, ref.nodeId, typeDictionary, dataTypeManager.namespaceArray);
dataTypeManager.registerTypeDictionary(ref.nodeId, typeDictionary);
}
}
示例4: it
it("should return 1 refs for browseNode on Server (BrowseDirection.Forward) and NodeClass set to Method", () => {
const mask = makeNodeClassMask("Method");
const server = rootFolder.objects.server;
server.browseName.toString().should.equal("Server");
const references = server.browseNode({
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeClassMask: mask, // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
referenceTypeId: "HierarchicalReferences",
resultMask: 0x3F
});
const browseNames = references.map((r) => r.browseName.name);
references.length.should.equal(1);
const expectedBrowseNames = ["GetMonitoredItems"];
_.intersection(browseNames, expectedBrowseNames).length.should.eql(expectedBrowseNames.length);
});
示例5: exploreDataTypeDefinition
export async function exploreDataTypeDefinition(
session: IBasicSession,
dataTypeDictionaryTypeNode: NodeId,
typeDictionary: TypeDictionary,
namespaces: string[]
) {
const nodeToBrowse = {
browseDirection: BrowseDirection.Forward,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Variable"),
nodeId: dataTypeDictionaryTypeNode,
referenceTypeId: resolveNodeId("HasComponent"),
resultMask: makeResultMask("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
};
const result = await session.browse(nodeToBrowse);
const references = result.references || [];
/* istanbul ignore next */
if (references.length === 0) {
return;
}
// request the Definition of each not
const nodesToBrowse2 = references.map((ref: ReferenceDescription) => {
return {
browseDirection: BrowseDirection.Inverse,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Object | Variable"),
nodeId: ref.nodeId,
referenceTypeId: resolveNodeId("HasDescription"),
resultMask: makeResultMask("NodeId | ReferenceType | BrowseName | NodeClass | TypeDefinition")
};
});
const results2 = await session.browse(nodesToBrowse2);
const binaryEncodingNodeIds = results2.map((br: BrowseResult) => {
const defaultBin = br.references!.filter((r: ReferenceDescription) => r.browseName.toString() === "Default Binary");
/* istanbul ignore next */
if (defaultBin.length < 1) {
return ExpandedNodeId;
}
return ExpandedNodeId.fromNodeId(defaultBin[0].nodeId, namespaces[defaultBin[0].nodeId.namespace]);
});
const tuples = _.zip(references, binaryEncodingNodeIds);
for (const [ref, defaultBinary] of tuples) {
const name = ref.browseName!.name!.toString();
const constructor = getOrCreateConstructor(name, typeDictionary, defaultBinary);
/* istanbul ignore next */
if (doDebug) {
try {
const testObject = new constructor();
debugLog(testObject.toString());
} catch (err) {
debugLog(err.message);
}
}
}
}
示例6: getDataTypeDefinition
export async function getDataTypeDefinition(session: IBasicSession, dataTypeNodeId: NodeId): Promise<void> {
// DataType
// | 1
// | n
// +- HasEncoding-> "Default Binary"
// |
// +-- HasDescription -> "MyItemType"
// +- ComponentOf -> Schema
//
// Note that in 1.04 compliant server, DataType definition might be available
// in a DataTypeDefinition attributes of the DataType object
// However this is a brand new aspect of the specification and is not widely implemented
// it is also optional
// It will takes time for old opcua server to be refurbished and we may have to
// keep the current method to access type definition from embedded xsd.
//
const nodeToBrowse1 = {
browseDirection: BrowseDirection.Forward,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Object"),
nodeId: dataTypeNodeId,
referenceTypeId: resolveNodeId("HasEncoding"),
resultMask: makeResultMask("NodeId | ReferenceType | BrowseName | NodeClass | TypeDefinition")
};
const result1 = await session.browse(nodeToBrowse1);
assert(result1.references && result1.references.length === 1);
const encodingReference = result1.references![0]!;
assert(encodingReference.browseName.toString() === "Default Binary");
// Xx console.log("Has Encoding ", encodingReference.browseName.toString(), encodingReference.nodeId.toString());
const nodeToBrowse2 = {
browseDirection: BrowseDirection.Forward,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Variable"),
nodeId: encodingReference.nodeId,
referenceTypeId: resolveNodeId("HasDescription"),
resultMask: makeResultMask("NodeId | ReferenceType | BrowseName | NodeClass | TypeDefinition")
};
const result2 = await session.browse(nodeToBrowse2);
assert(result2.references && result2.references.length === 1);
const definitionRef = result2.references![0]!;
// xx console.log("HasDefinition ", definitionRef.browseName.toString(), definitionRef.nodeId.toString());
const nameDataValue = await session.read({
attributeId: AttributeIds.Value,
nodeId: definitionRef.nodeId
});
const name = nameDataValue.value.value as string;
// xx console.log("name ", name);
// find parent node to access the xsd File
const nodeToBrowse3 = {
browseDirection: BrowseDirection.Inverse,
includeSubtypes: false,
nodeClassMask: makeNodeClassMask("Variable"),
nodeId: definitionRef.nodeId,
referenceTypeId: resolveNodeId("HasComponent"),
resultMask: makeResultMask("NodeId | ReferenceType | BrowseName | NodeClass | TypeDefinition")
};
const result3 = await session.browse(nodeToBrowse3);
assert(result3.references && result3.references.length === 1);
const schemaNode = result3.references![0]!.nodeId;
const typeDictionary = await extractSchema(session, schemaNode);
return (typeDictionary.structuredTypes as any)[name];
}
示例7: readUAStructure
export function readUAStructure(
proxyManager: UAProxyManager,
obj: any,
callback: ErrorCallback
) {
const session = proxyManager.session;
// 0 Object
// 1 Variable
// 2 Method
const nodeId = obj.nodeId;
const nodesToBrowse = [
// Components (except Methods)
{
// BrowseDescription
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeClassMask: makeNodeClassMask("Object | Variable"), // we don't want Method here
nodeId,
referenceTypeId: makeRefId("HasComponent"),
resultMask,
},
// Properties
{
// BrowseDescription
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
// nodeClassMask: makeNodeClassMask("Variable"),
nodeId,
referenceTypeId: makeRefId("HasProperty"),
resultMask
},
// Methods
{
// BrowseDescription
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeClassMask: makeNodeClassMask("Method"),
nodeId,
referenceTypeId: makeRefId("HasComponent"),
resultMask
},
// TypeDefinition
{
// BrowseDescription
browseDirection: BrowseDirection.Both,
includeSubtypes: true,
nodeId,
referenceTypeId: makeRefId("HasTypeDefinition"),
resultMask
},
// FromState
{
// BrowseDescription
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeId,
referenceTypeId: makeRefId("FromState"),
resultMask
},
// ToState
{
// BrowseDescription
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeId,
referenceTypeId: makeRefId("ToState"),
resultMask
},
// (for folders ) Organizes
{
// BrowseDescription
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeId,
referenceTypeId: makeRefId("Organizes"),
resultMask
}
];
session.browse(nodesToBrowse, (err: Error | null, browseResults?: BrowseResult[]) => {
function t(references: ReferenceDescription[]) {
return references.map((r: ReferenceDescription) => r.browseName.name + " " + r.nodeId.toString());
}
browseResults = browseResults || [];
// istanbul ignore next
if (err) {
return callback(err);
}
// xx console.log("Components", t(results[0].references));
// xx console.log("Properties", t(results[1].references));
// xx console.log("Methods", t(results[2].references));
async.parallel([
//.........這裏部分代碼省略.........