當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript node-opcua-nodeid.sameNodeId函數代碼示例

本文整理匯總了TypeScript中node-opcua-nodeid.sameNodeId函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript sameNodeId函數的具體用法?TypeScript sameNodeId怎麽用?TypeScript sameNodeId使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sameNodeId函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: assert

function _slow_isSupertypeOf<T extends UAType>(
  this: T,
  Class: typeof BaseNode,
  baseType: T
): boolean {

    assert(this instanceof Class);
    assert(baseType instanceof Class, " Object must have same type");
    assert(this.addressSpace);

    if (sameNodeId(this.nodeId, baseType.nodeId)) {
        return true;
    }
    const references = this.allReferences();

    const subTypes = references.filter(_filterSubType);
    assert(subTypes.length <= 1, "should have zero or one subtype no more");

    for (const subType1 of subTypes) {
        const subTypeId = subType1.nodeId;
        const subTypeNode = this.addressSpace.findNode(subTypeId) as any as T;
        // istanbul ignore next
        if (!subTypeNode) {
            throw new Error("Cannot find object with nodeId " + subTypeId.toString());
        }
        if (sameNodeId(subTypeNode.nodeId, baseType.nodeId)) {
            return true;
        } else {
            if (_slow_isSupertypeOf.call(subTypeNode, Class, baseType)) {
                return true;
            }
        }
    }
    return false;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:35,代碼來源:tool_isSupertypeOf.ts

示例2: _add_backward_reference

    // TODO : shall we care about overloading the remove_backward_reference method ?
    // some TrueSubState and FalseSubState relationship may be added later
    // so we need a mechanism to keep adding the "value_changed" event handle on subStates that
    // will be defined later.
    // install change detection on sub State
    // this is useful to change the effective transitionTime
    // EffectiveTransitionTime specifies the time when the current state or one of its sub states was entered.
    // If, for example, a LevelAlarm is active and – while active – switches several times between High and
    // HighHigh, then the TransitionTime stays at the point in time where the Alarm became active whereas the
    // EffectiveTransitionTime changes with each shift of a sub state.
    protected _add_backward_reference(reference: Reference): void {

        const self = this;

        super._add_backward_reference(reference);

        if (reference.isForward &&
          (sameNodeId(reference.referenceType, hasTrueSubState_ReferenceTypeNodeId) ||
            sameNodeId(reference.referenceType, hasFalseSubState_ReferenceTypeNodeId))) {

            const addressSpace = self.addressSpace;
            // add event handle
            const subState = addressSpace.findNode(reference.nodeId) as UAVariable;
            subState.on("value_changed", _updateEffectiveTransitionTime.bind(null, self, subState));
        }
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:26,代碼來源:ua_two_state_variable.ts

示例3: extractEventField

/**
 *
 * @method extractEventField
 * extract a eventField from a event node, matching the given selectClause
 * @param eventData
 * @param selectClause
 */
function extractEventField(eventData: any, selectClause: SimpleAttributeOperand): Variant {

    assert_valid_event_data(eventData);
    assert(selectClause instanceof SimpleAttributeOperand);

    selectClause.browsePath = selectClause.browsePath || [];

    if (selectClause.browsePath.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {

        // "ns=0;i=2782" => ConditionType
        // "ns=0;i=2041" => BaseEventType
        if (selectClause.typeDefinitionId.toString() !== "ns=0;i=2782") {
            // not ConditionType
            // tslint:disable-next-line:no-console
            console.warn("this case is not handled yet : selectClause.typeDefinitionId = " + selectClause.typeDefinitionId.toString());
            const eventSource1 = eventData.$eventDataSource;
            return new Variant({ dataType: DataType.NodeId, value: eventSource1.nodeId });
        }
        const conditionTypeNodeId = resolveNodeId("ConditionType");
        assert(sameNodeId(selectClause.typeDefinitionId, conditionTypeNodeId));

        const eventSource = eventData.$eventDataSource;
        const eventSourceTypeDefinition = eventSource.typeDefinitionObj;
        if (!eventSourceTypeDefinition) {
            // eventSource is a EventType class
            return new Variant();
        }
        const addressSpace = eventSource.addressSpace;
        const conditionType = addressSpace.findObjectType(conditionTypeNodeId);

        if (!eventSourceTypeDefinition.isSupertypeOf(conditionType)) {
            return new Variant();
        }
        // Yeh : our EventType is a Condition Type !
        return new Variant({ dataType: DataType.NodeId, value: eventSource.nodeId });
    }

    const handle = eventData.resolveSelectClause(selectClause);

    if (handle !== null) {
        const value = eventData.readValue(handle, selectClause);
        assert(value instanceof Variant);
        return value;

    } else {

        // Part 4 - 7.17.3
        // A null value is returned in the corresponding event field in the Publish response if the selected
        // field is not part of the Event or an error was returned in the selectClauseResults of the EventFilterResult.
        // return new Variant({dataType: DataType.StatusCode, value: browsePathResult.statusCode});
        return new Variant();
    }
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:60,代碼來源:tools_event_filter.ts

示例4: is_valid_reference

function is_valid_reference(ref: Reference): boolean {

    const hasRequestedProperties = ref.hasOwnProperty("referenceType") &&
        ref.hasOwnProperty("nodeId") &&
        !utils.isNullOrUndefined(ref.isForward);

    if (!hasRequestedProperties) {
        return false;
    }
    assert(ref.referenceType instanceof NodeId);
    assert(!ref.node || sameNodeId(ref.node.nodeId, ref.nodeId));
    // xx assert(!ref.referenceTypeName || typeof ref.referenceTypeName === "string");
    // xx // referenceType shall no be a nodeId string (this could happen by mistake)
    // xx assert(!isNodeIdString(ref.referenceType));
    return true;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:16,代碼來源:reference.ts

示例5: _filterSubType

function _filterSubType(reference: UAReference) {
    return (sameNodeId(reference.referenceType, HasSubTypeNodeId)
      && !reference.isForward);
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:4,代碼來源:tool_isSupertypeOf.ts

示例6: sameNodeId

 refs = refs.filter((ref: UAReference) => {
     return sameNodeId(ref.nodeId, normalizedReference.nodeId);
 });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:3,代碼來源:assertHasMatchingReference.ts


注:本文中的node-opcua-nodeid.sameNodeId函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。