本文整理匯總了TypeScript中node-opcua-data-model.makeResultMask函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript makeResultMask函數的具體用法?TypeScript makeResultMask怎麽用?TypeScript makeResultMask使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了makeResultMask函數的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: 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);
}
}
}
}
示例5: 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];
}
示例6: getArgumentDefinitionHelper
export function getArgumentDefinitionHelper(
session: IBasicSession,
methodId: MethodId,
callback: ResponseCallback<ArgumentDefinition>
) {
const browseDescription = new BrowseDescription({
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeClassMask: 0, // makeNodeClassMask("Variable"),
nodeId: methodId,
referenceTypeId: resolveNodeId("HasProperty"),
resultMask: makeResultMask("BrowseName")
});
session.browse(browseDescription, (err: Error | null, browseResult?: BrowseResult) => {
/* istanbul ignore next */
if (err) {
return callback(err);
}
if (!browseResult) {
return callback(new Error("Invalid"));
}
browseResult.references = browseResult.references || [];
// xx console.log("xxxx results", util.inspect(results, {colors: true, depth: 10}));
const inputArgumentRefArray = browseResult.references.filter(
(r) => r.browseName.name === "InputArguments");
// note : InputArguments property is optional thus may be missing
const inputArgumentRef = (inputArgumentRefArray.length === 1) ? inputArgumentRefArray[0] : null;
const outputArgumentRefArray = browseResult.references.filter(
(r) => r.browseName.name === "OutputArguments");
// note : OutputArguments property is optional thus may be missing
const outputArgumentRef = (outputArgumentRefArray.length === 1) ? outputArgumentRefArray[0] : null;
let inputArguments: Variant[] = [];
let outputArguments: Variant[] = [];
const nodesToRead = [];
const actions: any[] = [];
if (inputArgumentRef) {
nodesToRead.push({
attributeId: AttributeIds.Value,
nodeId: inputArgumentRef.nodeId
});
actions.push((result: DataValue) => {
inputArguments = result.value.value;
});
}
if (outputArgumentRef) {
nodesToRead.push({
attributeId: AttributeIds.Value,
nodeId: outputArgumentRef.nodeId
});
actions.push((result: DataValue) => {
outputArguments = result.value.value;
});
}
if (nodesToRead.length === 0) {
return callback(null, { inputArguments, outputArguments });
}
// now read the variable
session.read(nodesToRead, (err1: Error | null, dataValues?: DataValue[]) => {
/* istanbul ignore next */
if (err1) {
return callback(err1);
}
if (!dataValues) {
return callback(new Error("Internal Error"));
}
dataValues.forEach((dataValue, index) => {
actions[index].call(null, dataValue);
});
callback(null, { inputArguments, outputArguments });
});
});
}
示例7: makeResultMask
import { ClientSession, DataValue } from "node-opcua-client";
import { BrowseResult } from "node-opcua-service-browse";
import { Callback } from "./common";
import { makeRefId } from "./proxy";
import { UAProxyManager } from "./proxy_manager";
import { ProxyVariable } from "./proxy_variable";
export interface ObjectExplorerOptions {
proxyManager: UAProxyManager;
name: string;
nodeId: NodeId;
parent: any;
}
const resultMask = makeResultMask("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition");
type ErrorCallback = (err?: Error) => void;
function convertNodeIdToDataType(dataTypeId: NodeId): DataType {
return (dataTypeId as any)._dataType as DataType;
}
/**
* @method convertNodeIdToDataTypeAsync
*
* @param session
* @param dataTypeId
* @param callback
* @param callback.err
* @param callback.dataType