zoukankan      html  css  js  c++  java
  • 多功能嵌入式解码软件(3)

    多功能嵌入式解码软件(3)

    类库使用方法

    读取协议文件

     1 private void ButtonReadProtocol_Click(object sender, RoutedEventArgs e)
     2         {
     3             string[] txtRead = new string[2];
     4 
     5             txtRead = Selected_txt();
     6             if (txtRead == null)
     7                 return;
     8             TextBoxSettingLog.AppendText(txtRead[0] + "
    ");
     9             s.pro_Read = txtRead[1];
    10             c_f.Process_protocol_readed(s.pro_Read);
    11             if (c_f.protocolFresh == true)
    12                 TextBoxSettingLog.AppendText(c_f.frameMsg);
    13         }

    保存解码数据

     1 /// <summary>
     2         /// 2019-05-06
     3         /// </summary>
     4         private void SaveDecodeDat()
     5         {
     6             string strPath = Environment.CurrentDirectory;
     7             List<Class_frame._saveDecodeStruct> re = new List<Class_frame._saveDecodeStruct>();
     8             re = c_f.SaveDecodeDat(listSpRxdDat);
     9             for (int i = 0; i < re.Count; i++)
    10             {
    11                 byte id = re[i].function;
    12                 string str = re[i].str;
    13                 string strFile = strPath + "\DOC\" + DateTime.Now.ToString("yy-MM-dd-HH.mm.ss") + "dec" + Convert.ToString(id, 16) + ".txt";
    14                 if (re[0].str != null)
    15                     SaveString(str, strFile, FileMode.Create);
    16                 else
    17                     MessageBox.Show("null");
    18             }
    19         }

    实时解码数据

     1 /// <summary>
     2         /// 2019-05-07
     3         /// </summary>
     4         private void Decode_header_function_sum8()
     5         {
     6             Class_frame._decodeDatTimelyStruct re = new Class_frame._decodeDatTimelyStruct();
     7             int cnt = listSpRxdDat.Count();
     8 
     9             while (s.dec_lastCnt < cnt)
    10             {
    11                 re = c_f.DecodeTimely(listSpRxdDat[s.dec_lastCnt++]);
    12                 List<object> l = re.listRe;
    13                 byte id = re.function;
    14                 if (l != null)
    15                 {
    16                     byte ui8;
    17                     UInt16 ui16;
    18                     UInt32 ui32;
    19                     Int16 i16;
    20                     Int32 i32;
    21                     float f;
    22                     double d;
    23 
    24                     switch (id)
    25                     {
    26                         case 0xB1:
    27                             {
    28                                 ui8 = (byte)l[0];
    29                                 ui16 = (UInt16)l[1];
    30                                 ui32 = (UInt32)l[2];
    31                                 i16 = (Int16)l[3];
    32                                 i32 = (Int32)l[4];
    33                                 f = (float)l[5];
    34                                 d = (double)l[6];
    35                                 TextBoxRxd.AppendText("--------0xB1
    ");
    36                                 TextBoxRxd.AppendText(ui8.ToString() + " ");
    37                                 TextBoxRxd.AppendText(ui16.ToString() + " ");
    38                                 TextBoxRxd.AppendText(ui32.ToString() + " ");
    39                                 TextBoxRxd.AppendText(i16.ToString() + " ");
    40                                 TextBoxRxd.AppendText(i32.ToString() + " ");
    41                                 TextBoxRxd.AppendText(f.ToString() + " ");
    42                                 TextBoxRxd.AppendText(d.ToString() + " ");
    43                                 TextBoxRxd.AppendText("
    ");
    44                             }
    45                             break;
    46                         case 0xB2:
    47                             {
    48                                 ui8 = (byte)l[0];
    49                                 ui16 = (UInt16)l[1];
    50                                 ui32 = (UInt32)l[2];
    51                                 i16 = (Int16)l[3];
    52                                 i32 = (Int32)l[4];
    53                                 f = (float)l[5];
    54                                 d = (double)l[6];
    55                                 TextBoxRxd.AppendText("--------0xB2
    ");
    56                                 TextBoxRxd.AppendText(ui8.ToString() + " ");
    57                                 TextBoxRxd.AppendText(ui16.ToString() + " ");
    58                                 TextBoxRxd.AppendText(ui32.ToString() + " ");
    59                                 TextBoxRxd.AppendText(i16.ToString() + " ");
    60                                 TextBoxRxd.AppendText(i32.ToString() + " ");
    61                                 TextBoxRxd.AppendText(f.ToString() + " ");
    62                                 TextBoxRxd.AppendText(d.ToString() + " ");
    63                                 TextBoxRxd.AppendText("
    ");
    64                             }
    65                             break;
    66                         case 0xB3:
    67                             {
    68                                 ui8 = (byte)l[0];
    69                                 ui16 = (UInt16)l[1];
    70                                 ui32 = (UInt32)l[2];
    71                                 i16 = (Int16)l[3];
    72                                 i32 = (Int32)l[4];
    73                                 f = (float)l[5];
    74                                 d = (double)l[6];
    75                                 TextBoxRxd.AppendText("--------0xB3
    ");
    76                                 TextBoxRxd.AppendText(ui8.ToString() + " ");
    77                                 TextBoxRxd.AppendText(ui16.ToString() + " ");
    78                                 TextBoxRxd.AppendText(ui32.ToString() + " ");
    79                                 TextBoxRxd.AppendText(i16.ToString() + " ");
    80                                 TextBoxRxd.AppendText(i32.ToString() + " ");
    81                                 TextBoxRxd.AppendText(f.ToString() + " ");
    82                                 TextBoxRxd.AppendText(d.ToString() + " ");
    83                                 TextBoxRxd.AppendText("
    ");
    84                             }
    85                             break;
    86                         default:
    87                             TextBoxRxd.AppendText("frame id err
    ");
    88                             break;
    89                     }
    90                 }
    91             }
    92
  • 相关阅读:
    大象起舞:用PostgreSQL解海盗分金问题
    python 导入模块
    python socket 发送ESB报文
    python socket超时
    ISCC2018部分WriteUp
    查看SQL执行计划的方法及优劣
    jquery遮罩层
    IE9 JS不执行,打开F12就没问题了
    BigDecimal 01
    BigDecimal 01
  • 原文地址:https://www.cnblogs.com/xutopia/p/10874970.html
Copyright © 2011-2022 走看看