当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript node-opcua-data-model.makeResultMask函数代码示例

本文整理汇总了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");
    });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:27,代码来源:test_pseudo_session.ts

示例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")
     };
 });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:10,代码来源:client_dynamic_extension_object.ts

示例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);
    }

}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:43,代码来源:client_dynamic_extension_object.ts

示例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);
            }
        }
    }
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:63,代码来源:client_dynamic_extension_object.ts

示例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];
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:69,代码来源:client_dynamic_extension_object.ts

示例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 });
        });
    });
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:87,代码来源:basic_session_interface.ts

示例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
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:object_explorer.ts


注:本文中的node-opcua-data-model.makeResultMask函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。