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


TypeScript node-opcua-utils.isNullOrUndefined函數代碼示例

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


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

示例1: makeAccessLevelFlag

export function makeAccessLevelFlag(str: string | number | null): AccessLevelFlag {

    if (typeof str === "number") {
        const value = str as number;
        if (value === 0) { return AccessLevelFlag.None; }
        return value as AccessLevelFlag;
    }

    let accessFlag: AccessLevelFlag | null;

    if (str === "" || str === null) {
        accessFlag = AccessLevelFlag.None;
    } else {
        const flags = str.split(" | ");
        accessFlag = 0;
        for (const flag of flags) {
            accessFlag |= (AccessLevelFlag as any)[flag];
        }
    }

    if (utils.isNullOrUndefined(accessFlag)) {
        throw new Error("Invalid access flag specified '" + str + "' should be one of " + AccessLevelFlag.toString());
    }
    return accessFlag as AccessLevelFlag;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:25,代碼來源:access_level.ts

示例2: _updateAlarmState

    public _updateAlarmState(normalStateValue?: any, inputValue?: any) {

        const alarm = this;

        if (utils.isNullOrUndefined(normalStateValue) || utils.isNullOrUndefined(inputValue)) {
            this.activeState.setValue(false);
            return;
        }
        const isActive = !isEqual(normalStateValue, inputValue);

        if (isActive === alarm.activeState.getValue()) {
            // no change => ignore !
            return;
        }

        const stateName = isActive ? "Active" : "Inactive";
        // also raise the event
        alarm._signalNewCondition(stateName, isActive, "");

    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:20,代碼來源:ua_off_normal_alarm.ts

示例3:

        _.forEach(indexes.nameIndex, (defItem: any, key) => {

            xw.startElement("Field");
            xw.writeAttribute("Name", defItem.name);

            if (defItem.dataType && !defItem.dataType.isEmpty()) {
                // there is no dataType on enumeration
                const dataTypeStr = defItem.dataType.toString();
                xw.writeAttribute("DataType", dataTypeStr);
            }

            if (!utils.isNullOrUndefined(defItem.valueRank)) {
                xw.writeAttribute("ValueRank", defItem.valueRank);
            }
            if (!utils.isNullOrUndefined(defItem.value)) {
                xw.writeAttribute("Value", defItem.value);
            }
            if (defItem.description) {
                xw.startElement("Description");
                xw.text(defItem.description);
                xw.endElement();
            }
            xw.endElement();
        });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:24,代碼來源:nodeset_to_xml.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: constructor

    constructor(options?: OPCUAClientOptions) {

        options = options || {};
        super(options);

        // @property endpoint_must_exist {Boolean}
        // if set to true , create Session will only accept connection from server which endpoint_url has been reported
        // by GetEndpointsRequest.
        // By default, the client is strict.
        this.endpoint_must_exist = (isNullOrUndefined(options.endpoint_must_exist))
          ? true
          : !!options.endpoint_must_exist;

        this.requestedSessionTimeout = options.requestedSessionTimeout || 60000; // 1 minute

        this.___sessionName_counter = 0;
        this.userIdentityInfo = { type: UserTokenType.Anonymous };
        this.endpoint = undefined;
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:19,代碼來源:opcua_client_impl.ts

示例6: _arrayEllipsis

function _arrayEllipsis(value: any[] | null) {

    if (!value) {
        return "null []";
    } else {
        if (value.length === 0) {
            return "[ /* empty*/ ]";
        }
        assert(_.isArray(value));
        const v = [];
        const m = Math.min(_nbElements, value.length);
        for (let i = 0; i < m; i++) {
            let element = value[i];
            if (element instanceof Buffer) {
                element = hexDump(element, 32, 16);
            }
            v.push(!utils.isNullOrUndefined(element) ? element.toString() : null);
        }
        return "[ " + v.join(",") + (value.length > 10 ? " ... " : "") + "] (l=" + value.length + ")";
    }
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:21,代碼來源:factories_baseobject.ts


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