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


TypeScript node-opcua-assert.assert函數代碼示例

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


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

示例1: resolveDataTypeName

function resolveDataTypeName(
  addressSpace: AddressSpacePrivate,
  dataType: string | NodeId
): QualifiedName {

    let dataTypeNode = null;
    // istanbul ignore next
    if (_.isString(dataType)) {
        dataTypeNode = addressSpace.findDataType(dataType);
    } else {
        assert(dataType instanceof NodeId);
        const o = addressSpace.findNode(dataType.toString());
        dataTypeNode = o ? o : null;
    }
    if (!dataTypeNode) {
        throw new Error("Cannot find dataTypeName " + dataType);
    }
    return dataTypeNode.browseName;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:19,代碼來源:nodeset_to_xml.ts

示例2: dumpReferencedNodesOld

function dumpReferencedNodesOld(
  xw: XmlWriter,
  node: BaseNode,
  forward: boolean
) {

    assert(_.isBoolean(forward));

    xw.visitedNode[_hash(node)] = 1;

    const nodesToVisit: any = {};
    visitUANode(node, nodesToVisit, forward);

    for (const el of nodesToVisit.elements) {
        if (!xw.visitedNode[_hash(el)]) {
            el.dumpXML(xw);
        }
    }
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:19,代碼來源:nodeset_to_xml.ts

示例3: _post_process_current_chunk

    private _post_process_current_chunk() {

        let extraEncryptionBytes = 0;
        // add padding bytes if needed
        if (this.plainBlockSize > 0) {

            // write padding ( if encryption )

            // let's calculate curLength = the length of the block to encrypt without padding yet
            // +---------------+---------------+-------------+---------+--------------+------------+
            // |SequenceHeader | data          | paddingByte | padding | extraPadding | signature  |
            // +---------------+---------------+-------------+---------+--------------+------------+
            let curLength = this.sequenceHeaderSize + this.cursor + this.signatureLength;
            if (this.plainBlockSize > 256) {
                curLength += 2; // account for extraPadding Byte Number;
            } else {
                curLength += 1;
            }
            // let's calculate the required number of padding bytes
            const n = (curLength % this.plainBlockSize);
            const nbPaddingByteTotal = (this.plainBlockSize - n) % this.plainBlockSize;

            this._write_padding_bytes(nbPaddingByteTotal);
            const adjustedLength = this.sequenceHeaderSize + this.cursor + this.signatureLength;

            assert(adjustedLength % this.plainBlockSize === 0);
            const nbBlock = adjustedLength / this.plainBlockSize;
            extraEncryptionBytes = nbBlock * (this.cipherBlockSize - this.plainBlockSize);
        }

        this.dataEnd = this.dataOffset + this.cursor;

        // calculate the expected length of the chunk, once encrypted if encryption apply
        const expectedLength = this.dataEnd + this.signatureLength + extraEncryptionBytes;

        this.pendingChunk = this.chunk!.slice(0, expectedLength);
        // note :
        //  - this.pending_chunk has the correct size but is not signed nor encrypted yet
        //    as we don't know what to write in the header yet
        //  - as a result,
        this.chunk = null;
        this.cursor = 0;
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:43,代碼來源:chunk_manager.ts

示例4: assert

        this.withSession(endpointUrl, (session: ClientSession, done: (err?: Error) => void) => {

            assert(_.isFunction(done));

            const subscription = new ClientSubscriptionImpl(session as ClientSessionImpl, subscriptionParameters);

            try {
                innerFunc(session, subscription, (err?: Error) => {

                    subscription.terminate((err1?: Error) => {
                        done(err1);
                    });
                });

            } catch (err) {
                debugLog(err);
                done(err);
            }
        }, callback);
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:19,代碼來源:opcua_client_impl.ts

示例5: _historyReadRawAsync

function _historyReadRawAsync(
  this: UAVariable,
  historyReadRawModifiedDetails: ReadRawModifiedDetails,
  maxNumberToExtract: number,
  isReversed: boolean,
  reverseDataValue: boolean,
  callback: Callback<DataValue[]>
) {

    assert(callback instanceof Function);
    const node = this;

    node.varHistorian!.extractDataValues(
      historyReadRawModifiedDetails,
      maxNumberToExtract,
      isReversed,
      reverseDataValue,
      callback);
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:19,代碼來源:address_space_historical_data_node.ts

示例6: getMiniAddressSpace

export function getMiniAddressSpace(...args: any[]): any {

    const callback = args[0] as (err: Error | null, addressSpace?: AddressSpace) => void;

    const addressSpace = AddressSpace.create();

    // register namespace 1 (our namespace);
    const serverNamespace = addressSpace.registerNamespace("http://MYNAMESPACE");
    assert(serverNamespace.index === 1);

    generateAddressSpace(addressSpace, get_mini_nodeset_filename(), (err?: Error) => {
        // istanbul ignore next
        if (err) {
            // tslint:disable:no-console
            console.log("err =", err);
        }
        callback(err || null, addressSpace);
    });
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:19,代碼來源:get_mini_address_space.ts

示例7: debugLog

        this._mockTransport.server.on("data", (data: Buffer) => {

            let reply = this._replies[this._counter];
            this._counter++;
            if (reply) {

                if (_.isFunction(reply)) {
                    reply = reply.call(this);
                    // console.log(" interpreting reply as a function" + reply);
                    if (!reply) {
                        return;
                    }
                }

                debugLog("\nFAKE SERVER RECEIVED");
                debugLog(hexDump(data));

                let replies = [];
                if (reply instanceof Buffer) {
                    replies.push(reply);
                } else {
                    replies = reply;
                }
                assert(replies.length >= 1, " expecting at least one reply " + JSON.stringify(reply));
                replies.forEach((reply1: any) => {
                    debugLog("\nFAKE SERVER SEND");
                    debugLog(chalk.red(hexDump(reply1)));
                    this._mockTransport.server.write(reply1);
                });

            } else {
                const msg = " MockServerTransport has no more packets to send to client to" +
                  " emulate server responses.... ";
                console.log(chalk.red.bold(msg));
                console.log(chalk.blue.bold(hexDump(data)));

                display_trace_from_this_projet_only();
                analyseExtensionObject(data, 0, 0, {});

                this.emit("done");
            }
        });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:42,代碼來源:mock_transport.ts

示例8: _acknowledge_branch

    public _acknowledge_branch(
      eventId: Buffer,
      comment: string | LocalizedTextLike | LocalizedText,
      branch: ConditionSnapshot,
      message: string
    ) {

        assert(typeof (message) === "string");

        const conditionNode = this;

        if (conditionNode.confirmedState) {
            // alarm has a confirmed state !
            // we should be waiting for confirmation now
            branch.setConfirmedState(false);
            branch.setRetain(true);
        } else {
            branch.setRetain(false);
        }

        const statusCode = _setAckedState(branch, true, eventId, comment);
        if (statusCode !== StatusCodes.Good) {
            return statusCode;
        }

        branch.setComment(comment);

        conditionNode.raiseNewBranchState(branch);

        // xx conditionNode._raiseAuditConditionCommentEvent("Method/Acknowledge",eventId,comment);
        conditionNode._raiseAuditConditionAcknowledgeEvent(branch);

        /**
         * @event acknowledged
         * @param  eventId   {Buffer|null}
         * @param  comment   {LocalizedText}
         * @param  branch    {ConditionSnapshot}
         * raised when the alarm branch has been acknowledged
         */
        conditionNode.emit("acknowledged", eventId, comment, branch);

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

示例9: setDeprecated

export function setDeprecated(constructor: Function, methodName: string, helpString: string): void {

    const oldMethod = constructor.prototype[methodName];

    assert(oldMethod instanceof Function,
      "expecting a valid " + methodName + "method on class " + constructor.constructor.name);

    let counter = 0;
    constructor.prototype[methodName] = function() {
        if (counter % 1000 === 0) {
            // tslint:disable:no-console
            console.log(chalk.green("Warning !"),
              chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated"));
            console.log("         ", helpString);
        }
        counter++;
        return oldMethod.apply(this, arguments);
    };

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

示例10: _start_one_time_message_receiver

    private _start_one_time_message_receiver() {
        assert(!this._timerId, "timer already started");

        // Setup timeout detection timer ....
        this._timerId = setTimeout(() => {
            this._timerId = null;
            this._fulfill_pending_promises(
              new Error(`Timeout in waiting for data on socket ( timeout was = ${this.timeout} ms)`));
        }, this.timeout);

        // also monitored
        if (this._socket) {
            // to do = intercept socket error as well
            this._on_error_during_one_time_message_receiver = (err?: Error) => {
                this._fulfill_pending_promises(
                  new Error(`ERROR in waiting for data on socket ( timeout was = ${this.timeout} ms)`));
            };
            this._socket.on("close", this._on_error_during_one_time_message_receiver);
        }
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:20,代碼來源:tcp_transport.ts


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