• 大小: 14KB
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: 其他
  • 标签: 读取  解析  

资源简介

简洁明了,可以为相关人员提供一个解析文件的思路,没有复杂的代码,比较容易理解

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.Regularexpressions;
using TPCANHandle = System.Byte;
using System.IO;
using System.Threading;
using System.Collections;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private class MessageStatus
        {
            private TPCANMsg m_Msg;
            private TPCANTimestamp m_TimeStamp;
            private int m_index;
            public MessageStatus(TPCANMsg canMsg TPCANTimestamp canTimeStamp int listindex)
            {
                m_Msg = canMsg;
                m_TimeStamp = canTimeStamp;
                m_index = listindex;
            }
            public TPCANMsg CANMsg
            {
                get { return CANMsg; }
            }
            public TPCANTimestamp TimeStamp
            {
                get { return m_TimeStamp; }
            }
            public string TypeString
            {
                get { return GetMsgTypeString(); }
            }
            public string IdString
            {
                get { return GetIdString(); }
            }
            public string DataString
            {
                get { return GetDataString(); }
            }
            private string GetDataString()
            {
                string strTemp;

                strTemp = ““;

                if ((m_Msg.MSGTYPE & TPCANMessageType.PCAN_MESSAGE_RTR) == TPCANMessageType.PCAN_MESSAGE_RTR)
                    return “Remote Request“;
                else
                    for (int i = 0; i < m_Msg.LEN; i++)
                        strTemp += string.Format(“{0:X2} “ m_Msg.DATA[i]);

                return strTemp;
            }
            private string GetMsgTypeString()
            {
                string strTemp;

                if ((m_Msg.MSGTYPE & TPCANMessageType.PCAN_MESSAGE_EXTENDED) == TPCANMessageType.PCAN_MESSAGE_EXTENDED)
                    strTemp = “EXTENDED“;
                else
                    strTemp = “STANDARD“;

                if ((m_Msg.MSGTYPE & TPCANMessageType.PCAN_MESSAGE_RTR) == TPCANMessageType.PCAN_MESSAGE_RTR)
                    strTemp += “/RTR“;

                return strTemp;
            }
            private string GetIdString()
            {
                // We format the ID of the message and show it
                //
                if ((m_Msg.MSGTYPE & TPCANMessageType.PCAN_MESSAGE_EXTENDED) == TPCANMessageType.PCAN_MESSAGE_EXTENDED)
                    return string.Format(“{0:X8}h“ m_Msg.ID);
                else
                    return string.Format(“{0:X3}h“ m_Msg.ID);
            }
        }
        public TPCANHandle m_PcanHandle;
        public TPCANBaudrate m_Baudrate;
        public TPCANType m_HwType;
        public b

评论

共有 条评论