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

TypeScript node-opcua-debug.hexDump函数代码示例

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

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



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

示例1: _dump_simple_value

    function _dump_simple_value(self: any, field: StructuredTypeField, data: any, value: any, fieldType: string) {

        let str = "";
        if (value instanceof Buffer) {
            const _hexDump = hexDump(value);
            data.lines.push(fieldNameF + " " + fieldTypeF);
            data.lines.push("BUFFER{" + _hexDump + "}");

        } else {

            if (field.isArray) {
                str = fieldNameF + " " + fieldTypeF + ": " + _arrayEllipsis(value);
            } else {
                if (fieldType === "IntegerId" || fieldType === "UInt32") {
                    value = "" + value + "               0x" + value.toString(16);
                } else if (fieldType === "DateTime" || fieldType === "UtcTime") {
                    value = (value && value.toISOString) ? value.toISOString() : value;
                } else if (typeof value === "object" && value !== null && value !== undefined) {
                    value = value.toString.apply(value, args);
                }
                str = fieldNameF + " " + fieldTypeF + ": "
                  + ((value === null || value === undefined) ? chalk.blue("null") : value.toString());
            }
            data.lines.push(str);
        }
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:26,代码来源:factories_baseobject.ts


示例2: messageHeaderToString

export function messageHeaderToString(messageChunk: Buffer): string {

    const stream = new BinaryStream(messageChunk);

    const messageHeader = readMessageHeader(stream);
    if (messageHeader.msgType === "ERR" || messageHeader.msgType === "HEL") {
        return messageHeader.msgType + " " + messageHeader.isFinal + " length   = " + messageHeader.length;
    }

    const securityHeader = chooseSecurityHeader(messageHeader.msgType);

    const sequenceHeader = new SequenceHeader();
    assert(stream.length === 8);

    const channelId = stream.readUInt32();
    securityHeader.decode(stream);
    sequenceHeader.decode(stream);

    const slice = messageChunk.slice(0, stream.length);

    return messageHeader.msgType + " " +
        messageHeader.isFinal +
        " length   = " + messageHeader.length +
        " channel  = " + channelId +
        " seqNum   = " + sequenceHeader.sequenceNumber +
        " req ID   = " + sequenceHeader.requestId +
        " security   = " + securityHeader.toString() +
        "\n\n" + hexDump(slice);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:29,代码来源:message_header_to_string.ts


示例3: switch

            trace: (operation: any, name: any, value: any, start: number, end: number, fieldType: string) => {

                const b = buffer.slice(start, end);
                let _hexDump = "";

                switch (operation) {

                    case "start":
                        padding += 2;
                        display(name.toString());
                        break;

                    case "end":
                        padding -= 2;
                        break;

                    case "start_array":
                        display("." + name + " (length = " + value + ") " + "[", hex_block(start, end, b));
                        padding += 2;
                        break;

                    case "end_array":
                        padding -= 2;
                        display("] // " + name);
                        break;

                    case "start_element":
                        display(" #" + value + " {");
                        padding += 2;
                        break;

                    case "end_element":
                        padding -= 2;
                        display(" } // # " + value);
                        break;

                    case "member":
                        display("." + name + " : " + fieldType);

                        _hexDump = "";
                        if (value instanceof Buffer) {
                            _hexDump = hexDump(value);
                            console.log(_hexDump);
                            value = "<BUFFER>";
                        }

                        if (value && value.encode) {
                            if (fieldType === "ExtensionObject") {
                                display_encodeable(value, buffer, start, end);
                            } else {
                                const str = value.toString() || "<empty>";
                                display(str);
                            }
                        } else {
                            display(" " + value, hex_block(start, end, b));
                        }
                        break;
                }
            },
开发者ID:node-opcua,项目名称:node-opcua,代码行数:59,代码来源:packet_analyzer.ts


示例4: toString

 public toString(): string {
     const str =
       "/* OpaqueStructure */ { \n" +
       "nodeId " + this.nodeId.toString() + "\n" +
       "buffer = \n" + hexDump(this.buffer) + "\n" +
       "}";
     return str;
 }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:8,代码来源:extension_object.ts


示例5: 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


示例6: _read_headers

    protected _read_headers(binaryStream: BinaryStream): boolean {

        super._read_headers(binaryStream);

        assert(binaryStream.length === 12);

        const msgType = this.messageHeader.msgType;

        if (msgType === "HEL" || msgType === "ACK") {

            this.securityPolicy = SecurityPolicy.None;
        } else if (msgType === "ERR") {

            // extract Error StatusCode and additional message
            binaryStream.length = 8;
            const errorCode = decodeStatusCode(binaryStream);
            const message = decodeString(binaryStream);

            /* istanbul ignore next */
            if (doDebug) {
                debugLog(chalk.red.bold(" ERROR RECEIVED FROM SENDER"), chalk.cyan(errorCode.toString()), message);
                debugLog(hexDump(binaryStream.buffer));
            }
            return true;

        } else {

            this.securityHeader = chooseSecurityHeader(msgType);
            this.securityHeader.decode(binaryStream);

            if (msgType === "OPN") {
                const asymmetricAlgorithmSecurityHeader = this.securityHeader as AsymmetricAlgorithmSecurityHeader;
                this.securityPolicy = fromURI(asymmetricAlgorithmSecurityHeader.securityPolicyUri);
                this.cryptoFactory = getCryptoFactory(this.securityPolicy);
            }

            if (!this._decrypt(binaryStream)) {
                return false;
            }

            this.sequenceHeader = new SequenceHeader();
            this.sequenceHeader.decode(binaryStream);

            /* istanbul ignore next */
            if (doDebug) {
                debugLog(" Sequence Header", this.sequenceHeader);
            }

            this._validateSequenceNumber(this.sequenceHeader.sequenceNumber);
        }
        return true;
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:52,代码来源:message_builder.ts


示例7: it

    it("Q3 should encode and decode a method call request", async () => {

        const objectId = makeNodeId(999990, 0);
        const methodId = makeNodeId(999992, 0);

        const obj = addressSpace.findNode(objectId)! as UAObject;
        obj.nodeClass.should.eql(NodeClass.Object);

        const method = obj.getMethodById(methodId)!;
        method.nodeClass.should.eql(NodeClass.Method);
        method.browseName.toString().should.eql("DoStuff");

        const inputArguments = method.getInputArguments();
        inputArguments.should.be.instanceOf(Array);

        const callRequest = new CallRequest({

            methodsToCall: [{
                inputArguments: [{
                    dataType: DataType.UInt32,
                    value: [0xAA, 0xAB, 0xAC]
                }],
                methodId,
                objectId
            }]
        });

        const size = callRequest.binaryStoreSize();

        const stream = new BinaryStream(size);

        callRequest.encode(stream);

        if (doDebug) {
            console.log(hexDump(stream.buffer));
        }

        // now decode
        const callRequest_reloaded = new CallRequest();
        stream.rewind();
        callRequest_reloaded.decode(stream);

    });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:43,代码来源:test_method_service.ts


示例8: analyze_object_binary_encoding

export function analyze_object_binary_encoding(obj: BaseUAObject) {

    assert(obj);

    const size = obj.binaryStoreSize();
    console.log("-------------------------------------------------");
    console.log(" size = ", size);
    const stream = new BinaryStream(size);
    obj.encode(stream);

    stream.rewind();
    console.log("-------------------------------------------------");
    if (stream.buffer.length < 256) {
        console.log(hexDump(stream.buffer));
        console.log("-------------------------------------------------");
    }

    const reloadedObject = new (obj.constructor as any)();
    analyzePacket(stream.buffer, reloadedObject, 0);

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


示例9: _safe_decode_message_body

    private _safe_decode_message_body(fullMessageBody: Buffer, objMessage: any, binaryStream: BinaryStream) {
        try {
            // de-serialize the object from the binary stream
            const options = this.objectFactory;
            objMessage.decode(binaryStream, options);
        } catch (err) {
            console.log(err);
            console.log(err.stack);
            console.log(hexDump(fullMessageBody));
            analyseExtensionObject(fullMessageBody, 0, 0);

            console.log(" ---------------- block");
            let i = 0;
            this.messageChunks.forEach((messageChunk) => {
                console.log(" ---------------- chunk i=", i++);
                console.log(hexDump(messageChunk));
            });
            return false;
        }
        return true;
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:21,代码来源:message_builder.ts


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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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