• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript underscore.isFinite函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中underscore.isFinite函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isFinite函数的具体用法?TypeScript isFinite怎么用?TypeScript isFinite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isFinite函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: _validateSequenceNumber

    private _validateSequenceNumber(sequenceNumber: number) {

        // checking that sequenceNumber is increasing
        assert(_.isFinite(this._previousSequenceNumber));
        assert(_.isFinite(sequenceNumber) && sequenceNumber >= 0);

        let expectedSequenceNumber;
        if (this._previousSequenceNumber !== -1) {

            expectedSequenceNumber = this._previousSequenceNumber + 1;

            if (expectedSequenceNumber !== sequenceNumber) {
                const errMessage = "Invalid Sequence Number found ( expected " + expectedSequenceNumber + ", got " + sequenceNumber + ")";

                /* istanbul ignore next */
                debugLog(chalk.red.bold(errMessage));
                /**
                 * notify the observers that a message with an invalid sequence number has been received.
                 * @event invalid_sequence_number
                 * @param  expected sequence Number
                 * @param  actual sequence Number
                 */
                this.emit("invalid_sequence_number", expectedSequenceNumber, sequenceNumber);
            }
            // todo : handle the case where sequenceNumber wraps back to < 1024
        }
        /* istanbul ignore next */
        if (doDebug) {
            debugLog(chalk.yellow.bold(" Sequence Number = "), sequenceNumber);
        }
        this._previousSequenceNumber = sequenceNumber;
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:32,代码来源:message_builder.ts


示例2: _differenceScalar

function _differenceScalar(
  value1: NumberType,
  value2: NumberType,
  dataType: DataType,
  absoluteDeadband: number
): boolean {

    let diff;
    if (dataType === DataType.UInt64 || dataType === DataType.Int64) {
        if (!(value1 instanceof Array && value2 instanceof Array)) {
            throw new Error("Invalid");
        }
        const h1 = value1[0]; // high
        const h2 = value2[0];
        if (h1 !== h2) {
            diff = (h1 - h2) * 4294967295;
            if (Math.abs(diff) > absoluteDeadband) {
                return true;
            }
        }
        diff = value1[1] - value2[1];
        assert(_.isNumber(diff) && _.isFinite(diff));
        return Math.abs(diff) > absoluteDeadband;
    }
    if (!(typeof value1 === "number" && typeof value2 === "number")) {
        throw new Error("Invalid");
    }
    diff = value2 - value1;
    assert(_.isNumber(diff) && _.isFinite(diff));

    return Math.abs(diff) > absoluteDeadband;

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


示例3: difference

function difference(v1: Variant, v2: Variant, absoluteDeadBand: number): boolean {

    assert(_.isFinite(absoluteDeadBand));

    if (v1.arrayType === VariantArrayType.Array) {

        if (v1.dataType !== v2.dataType) {
            return true;
        }
        if (v1.value.length !== v2.value.length) {
            return true;
        }

        const n = v1.value.length;
        let i = 0;
        for (i = 0; i < n; i++) {
            if (_differenceScalar(v1.value[i], v2.value[i], v1.dataType, absoluteDeadBand)) {
                return true;
            }
        }
        return false;

    } else {
        assert(v1.arrayType === VariantArrayType.Scalar);
        assert(v1.dataType === v2.dataType);
        return _differenceScalar(v1.value, v2.value, v1.dataType, absoluteDeadBand);
    }
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:28,代码来源:deadband_checker.ts


示例4: _setStateBasedOnInputValue

    public _setStateBasedOnInputValue(value: number) {

        assert(_.isFinite(value));
        let isActive = false;

        let state = null;

        const oldState = this.limitState.getCurrentState();

        if (this.highHighLimit && this.getHighHighLimit() < value) {
            state = "HighHigh";
            isActive = true;
        } else if (this.highLimit && this.getHighLimit() < value) {
            state = "High";
            isActive = true;
        } else if (this.lowLowLimit && this.getLowLowLimit() > value) {
            state = "LowLow";
            isActive = true;
        } else if (this.lowLimit && this.getLowLimit() > value) {
            state = "Low";
            isActive = true;
        }

        if (state !== oldState) {
            this._signalNewCondition(state, isActive, value);
        }
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:27,代码来源:ua_exclusive_limit_alarm.ts


示例5: _send_HELLO_request

    private _send_HELLO_request() {

        if (doDebug) {
            debugLog("entering _send_HELLO_request");
        }

        assert(this._socket);
        assert(_.isFinite(this.protocolVersion));
        assert(this.endpointUrl.length > 0, " expecting a valid endpoint url");

        // Write a message to the socket as soon as the client is connected,
        // the server will receive it as message from the client
        const request = new HelloMessage({

            endpointUrl: this.endpointUrl,
            maxChunkCount: 0,                 // 0 - no limits
            maxMessageSize: 0,                // 0 - no limits

            protocolVersion: this.protocolVersion,
            receiveBufferSize: 1024 * 64 * 10,
            sendBufferSize: 1024 * 64 * 10   // 8192 min,
        });

        const messageChunk = packTcpMessage("HEL", request);
        this._write_chunk(messageChunk);
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:26,代码来源:client_tcp_transport.ts


示例6: _setStateBasedOnInputValue

 public _setStateBasedOnInputValue(value: number) {
     const setpointValue = this.getSetpointValue();
     if (setpointValue === null) {
         throw new Error("Cannot access setpoint Value");
     }
     assert(_.isFinite(setpointValue), "expecting a valid setpoint value");
     // call base class implementation
     super._setStateBasedOnInputValue(value - setpointValue);
 }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:9,代码来源:ua_non_exclusive_deviation_alarm.ts


示例7: setValue

    public setValue(value: string | number): void {

        if (typeof (value) === "string") {
            const index = this.getIndex(value);
            assert(index >= 0, " invalid multi state value provided");
            return this.setValue(index);
        }
        assert(_.isFinite(value));
        return this.setValueFromSource(new Variant({ dataType: DataType.UInt32, value }));
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:10,代码来源:ua_multistate_discrete.ts


示例8: _timedShelve_method

function _timedShelve_method(
  inputArguments: VariantLike[],
  context: SessionContext,
  callback: any
) {
    assert(inputArguments.length === 1);

    const shelvingState = context.object as ShelvingStateMachine;

    if (shelvingState.getCurrentState() !== "Unshelved") {
        return callback(null, {
            statusCode: StatusCodes.BadConditionAlreadyShelved
        });
    }
    // checking duration ...
    const alarmNode = shelvingState.parent;

    // istanbul ignore next
    if (!(alarmNode instanceof UAAlarmConditionBase)) {
        return callback(null, {
            statusCode: StatusCodes.BadNodeIdInvalid
        });
    }
    const maxTimeShelved = alarmNode.getMaxTimeShelved();
    assert(_.isFinite(maxTimeShelved));

    assert(inputArguments[0].dataType === DataType.Double); // Duration
    assert(inputArguments[0] instanceof Variant);

    // xx console.log("inputArguments",inputArguments[0].toString());

    const proposedDuration = inputArguments[0].value; // as double (milliseconds)
    if (proposedDuration > maxTimeShelved) {
        return callback(null, {
            statusCode: StatusCodes.BadShelvingTimeOutOfRange
        });
    }

    if (proposedDuration < 0) {
        return callback(null, {
            statusCode: StatusCodes.BadShelvingTimeOutOfRange
        });
    }

    _clear_timer_if_any(shelvingState);
    shelvingState.setState("TimedShelved");
    _start_timer_for_automatic_unshelve(shelvingState, proposedDuration);

    return callback(null, {
        statusCode: StatusCodes.Good
    });

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


示例9: writeUInt32

 /**
  * write a single 32 bit unsigned integer to the stream.
  *
  * @param  value the value to write
  */
 public writeUInt32(value: number): void {
     if (performCheck) {assert(this.buffer.length >= this.length + 4, "not enough space in buffer"); }
     if (performCheck) {assert(isFinite(value)); }
     if (performCheck) {assert(value >= 0 && value <= MAXUINT32); }
     this.buffer.writeUInt32LE(value, this.length);
     this.length += 4;
     /*
       assert(this.buffer[this.length - 4] === value % 256);
       assert(this.buffer[this.length - 3] === (value >>> 8) % 256);
       assert(this.buffer[this.length - 2] === (value >>> 16) % 256);
       assert(this.buffer[this.length - 1] === (value >>> 24) % 256);
       */
 }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:18,代码来源:binaryStream.ts


示例10: _setStateBasedOnInputValue

    protected _setStateBasedOnInputValue(value: number): void {

        assert(_.isFinite(value), "expecting a valid value here");

        const alarm = this;

        let isActive = false;

        const states: any = {
            highHigh: alarm.highHighState ? alarm.highHighState.getValue() : "unset",

            high: alarm.highState ? alarm.highState.getValue() : "unset",

            low: alarm.lowState ? alarm.lowState.getValue() : "unset",

            lowLow: alarm.lowLowState ? alarm.lowLowState.getValue() : "unset"
        };

        let count = 0;

        function ___p(
          stateName: string,
          func_value: () => boolean
        ) {
            if (states[stateName] !== "unset") {
                const val = func_value();
                isActive = isActive || val;
                if (states[stateName] !== val) {
                    states[stateName] = val;
                    count += 1;
                }
            }
        }

        ___p("highHigh", () => {
            return alarm.getHighHighLimit() < value;
        });
        ___p("high", () => {
            return alarm.getHighLimit() < value;
        });
        ___p("low", () => {
            return alarm.getLowLimit() > value;
        });
        ___p("lowLow", () => {
            return alarm.getLowLowLimit() > value;
        });

        if (count > 0) {
            alarm._signalNewCondition(states, isActive, value);
        }
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:51,代码来源:ua_non_exclusive_limit_alarm.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript underscore.isFunction函数代码示例发布时间:2022-05-25
下一篇:
TypeScript underscore.isEqual函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap