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


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

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


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

示例1: _send_chunk

    private _send_chunk(callback: ErrorCallback | undefined, messageChunk: Buffer | null) {

        if (messageChunk) {
            this.transport.write(messageChunk);
        } else {
            if (doPerfMonitoring) {
                // record tick 3 : transaction completed.
                this._tick3 = get_clock_tick();
            }

            if (callback) {
                setImmediate(callback);
            }

            if (doPerfMonitoring) {
                this._record_transaction_statistics();

                /* istanbul ignore next */
                if (doDebug) {
                    // dump some statistics about transaction ( time and sizes )
                    _dump_transaction_statistics(this.last_transaction_stats);
                }
            }
            this.emit("transaction_done");
        }
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:26,代碼來源:server_secure_channel_layer.ts

示例2: _on_common_message

    private _on_common_message(request: Request, msgType: string, requestId: number, channelId: number) {

        /* istanbul ignore next */
        if (doTraceMessages) {
            dump_request(request, requestId, channelId);
        }

        if (this.messageBuilder.sequenceHeader === null) {
            throw new Error("Internal Error");
        }

        requestId = this.messageBuilder.sequenceHeader.requestId;

        const message: Message = {
            channel: this,
            request,
            requestId
        };

        if (msgType === "CLO" && request.schema.name === "CloseSecureChannelRequest") {
            this.close();
        } else if (msgType === "OPN" && request.schema.name === "OpenSecureChannelRequest") {
            // intercept client request to renew security Token
            this._handle_OpenSecureChannelRequest(message, (/* err?: Error*/) => {
            });
        } else {
            if (request.schema.name === "CloseSecureChannelRequest") {
                console.log("WARNING : RECEIVED a CloseSecureChannelRequest with MSGTYPE=" + msgType);
                this.close();
            } else {
                if (doPerfMonitoring) {
                    // record tick 1 : after message has been received, before message processing
                    this._tick1 = get_clock_tick();
                }

                if (this.securityToken && channelId !== this.securityToken.channelId) {
                    // response = new ServiceFault({responseHeader: {serviceResult: certificate_status}});
                    debugLog("Invalid channelId detected =", channelId, " <> ", this.securityToken.channelId);
                    return this.send_error_and_abort(
                      StatusCodes.BadCommunicationError,
                      "Invalid Channel Id specified " + this.securityToken.channelId,
                      message, () => {

                      });
                }

                /**
                 * notify the observer that a OPCUA message has been received.
                 * It is up to one observer to call send_response or send_error_and_abort to complete
                 * the transaction.
                 *
                 * @event message
                 * @param message
                 */
                this.emit("message", message);
            }
        }
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:58,代碼來源:server_secure_channel_layer.ts

示例3: createDiagnostic

        function createDiagnostic(index: number) {
            const t5 = utils.get_clock_tick();
            const sessionObject = namespace.addObject({
                browseName: "Session" + index,
                organizedBy: addressSpace.rootFolder.objects
            });

            // the extension object
            const t6 = utils.get_clock_tick();
            const _sessionDiagnostics = addressSpace.constructExtensionObject(sessionDiagnosticsDataType);
            const t7 = utils.get_clock_tick();
            const sessionDiagnostics = sessionDiagnosticsVariableType.instantiate({
                browseName: {name: "SessionDiagnostics", namespaceIndex: 0},
                componentOf: sessionObject,
                value: new Variant({ dataType: DataType.ExtensionObject, value: _sessionDiagnostics })
            });
            const t8 = utils.get_clock_tick();
            // xx debugLog(" t8-t7",t8-t7);

            objs.push(sessionObject);
        }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:21,代碼來源:test_address_space_construct_extension_object.ts

示例4: get_clock_tick

        this._packetAssembler.on("newMessage", (info, data) => {

            if (doPerfMonitoring) {
                // record tick 0: when the first data is received
                this._tick0 = get_clock_tick();
            }
            /**
             *
             * notify the observers that a new message is being built
             * @event start_chunk
             * @param info
             * @param data
             */
            this.emit("start_chunk", info, data);
        });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:15,代碼來源:message_builder_base.ts

示例5: _feed_messageChunk

    private _feed_messageChunk(chunk: Buffer) {
        assert(chunk);
        const messageHeader = readMessageHeader(new BinaryStream(chunk));
        /**
         * notify the observers that new message chunk has been received
         * @event chunk
         * @param messageChunk the raw message chunk
         */
        this.emit("chunk", chunk);

        if (messageHeader.isFinal === "F") {

            // last message
            this._append(chunk);
            if (this._hasReceivedError) {
                return false;
            }

            const fullMessageBody: Buffer = this.blocks.length === 1 ? this.blocks[0] : Buffer.concat(this.blocks);

            if (doPerfMonitoring) {
                // record tick 1: when a complete message has been received ( all chunks assembled)
                this._tick1 = get_clock_tick();
            }
            /**
             * notify the observers that a full message has been received
             * @event full_message_body
             * @param full_message_body the full message body made of all concatenated chunks.
             */
            this.emit("full_message_body", fullMessageBody);

            this._decodeMessageBody(fullMessageBody);

            // be ready for next block
            this._init_new();
            return true;

        } else if (messageHeader.isFinal === "A") {
            return this._report_error("received and Abort Message");

        } else if (messageHeader.isFinal === "C") {
            return this._append(chunk);
        }
        return false;
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:45,代碼來源:message_builder_base.ts

示例6: send_response

    /**
     * @method send_response
     * @async
     * @param msgType
     * @param response
     * @param message
     * @param callback
     */
    public send_response(
      msgType: string,
      response: Response,
      message: Message,
      callback?: ErrorCallback
    ): void {

        const request = message.request;
        const requestId = message.requestId;

        if (this.aborted) {
            debugLog("channel has been terminated , cannot send responses");
            return callback && callback(new Error("Aborted"));
        }

        // istanbul ignore next
        if (doDebug) {
            assert(response.schema);
            assert(request.schema);
            assert(requestId > 0);
            // verify that response for a given requestId is only sent once.
            if (!this.__verifId) {
                this.__verifId = {};
            }
            assert(!this.__verifId[requestId], " response for requestId has already been sent !! - Internal Error");
            this.__verifId[requestId] = requestId;
        }

        if (doPerfMonitoring) {
            // record tick : send response received.
            this._tick2 = get_clock_tick();
        }

        assert(this.securityToken);

        let options = {
            channelId: this.securityToken.channelId,
            chunkSize: this.transport.receiveBufferSize,
            requestId,
            tokenId: this.securityToken.tokenId
        };

        const securityOptions =
          msgType === "OPN" ? this._get_security_options_for_OPN() : this._get_security_options_for_MSG();
        options = _.extend(options, securityOptions);

        response.responseHeader.requestHandle = request.requestHeader.requestHandle;

        /* istanbul ignore next */
        if (0 && doDebug) {
            console.log(" options ", options);
            analyze_object_binary_encoding(response as any as BaseUAObject);
        }

        /* istanbul ignore next */
        if (doTraceMessages) {
            console.log(
              chalk.cyan.bold("xxxx   >>>> ---------------------------------------- "),
              chalk.green.bold(response.schema.name),
              requestId
            );
            console.log(response.toString());
            console.log(chalk.cyan.bold("xxxx   >>>> ----------------------------------------|\n"));
        }

        if (this._on_response) {
            this._on_response(msgType, response, message);
        }

        this._transactionsCount += 1;
        this.messageChunker.chunkSecureMessage(
          msgType,
          options as ChunkMessageOptions,
          response as any as BaseUAObject,
          (messageChunk: Buffer | null) => {
              return this._send_chunk(callback, messageChunk);
          });
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:86,代碼來源:server_secure_channel_layer.ts

示例7: get_clock_tick

 .on("start_chunk", () => {
     if (doPerfMonitoring) {
         // record tick 0: when the first chunk is received
         this._tick0 = get_clock_tick();
     }
 });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:6,代碼來源:server_secure_channel_layer.ts


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