public Form_AutomatedAnalysis()
        {
            InitializeComponent();
            //
            usbCAN = new USBCAN(getRawPacket);
            udsCAN = new UDSBASEDCAN(usbCAN);

            chartCmp.Series.Clear();

            readUdsInstructions(Application.StartupPath + @"\OPTIONAL.txt");
            //test
            ANALYSISRESULT testResult = new ANALYSISRESULT();

            testResult.udsReq.description   = "[测试数据]大众途安发动机扭矩";
            testResult.udsReq.format        = 0;
            testResult.udsReq.expectedFrame = 0;
            testResult.udsReq.address       = 0x7E0;
            testResult.udsReq.serviceID     = 0x22;
            testResult.udsReq.parameterList.Add(0x10);
            testResult.udsReq.parameterList.Add(0x10);

            testResult.path = Application.StartupPath + @"\dataPacket\[测试数据]大众途安发动机扭矩.txt";
            analysisResults.Add(testResult);

            listBoxResult.Items.Add(testResult.udsReq.description);
        }
        private void buttonStart_Click(object sender, EventArgs e)
        {
            int pointCount = 0;

            try { pointCount = Convert.ToInt32(textBoxPointCount.Text); }
            catch (Exception) { MessageBox.Show("请指定收集点个数"); return; }

            int udsInterval = 0;

            try { udsInterval = Convert.ToInt32(textBoxUdsInterval.Text); }
            catch (Exception) { MessageBox.Show("请指定指令发送间隔"); return; }
            //
            richTextBoxLog.Text    = "";
            buttonEnd.Enabled      = true;
            buttonStart.Enabled    = false;
            groupBoxResult.Enabled = false;
            rawPacket.Clear();
            hasGetUds = false;
            DateTime prev;

            for (int reqIndex = 0; reqIndex < listRequests.Count; reqIndex++)
            {
                if (usbCAN.startDevice() == false)
                {
                    goto endProcess;
                }

                udsCAN.createService(listRequests[reqIndex]);
                for (int cnt = pointCount; cnt > 0;)
                {
                    for (int reTry = 0; reTry < 10 && wantTerminate == false; reTry++)
                    {
                        prev = DateTime.Now;
                        while ((DateTime.Now - prev).TotalMilliseconds < DELAY)
                        {
                            Application.DoEvents();
                        }

                        hasGetUds = false;
                        usbCAN.sendFame(1);

                        prev = DateTime.Now;
                        while (hasGetUds == false && (DateTime.Now - prev).TotalMilliseconds < 1200)
                        {
                            Application.DoEvents();
                        }
                        if (hasGetUds == false)
                        {
                            continue;
                        }

                        break;
                    }

                    if (wantTerminate)
                    {
                        goto endProcess;
                    }

                    if (hasGetUds == false)
                    {
                        richTextBoxLog.AppendText("超时,请检查设备\n");
                    }
                    else
                    {
                        cnt--;
                        richTextBoxLog.AppendText(listRequests[reqIndex].description + ":剩余点个数 " + cnt.ToString() + "\n");
                    }

                    prev = DateTime.Now;
                    while ((DateTime.Now - prev).TotalMilliseconds < udsInterval)
                    {
                        Application.DoEvents();
                    }
                }

                //保存文件
                if (usbCAN.shutDevice() == false)
                {
                    goto endProcess;
                }

                string   path = Application.StartupPath + @"\dataPacket\";
                TimeSpan ts   = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                path += listRequests[reqIndex].description + Convert.ToUInt64(ts.TotalSeconds).ToString();
                FileStream   file = new FileStream(path, FileMode.Create);
                StreamWriter sw   = new StreamWriter(file);

                string line;
                for (int i = 0; i < rawPacket.Count; i++)
                {
                    line  = rawPacket[i].ID.ToString("X2") + " ";
                    line += rawPacket[i].DataLen.ToString() + " ";
                    for (int d = 0; d < rawPacket[i].DataLen; d++)
                    {
                        line += rawPacket[i].Data[d].ToString("X2") + " ";
                    }

                    sw.WriteLine(line);
                }

                sw.Close();
                file.Close();

                ANALYSISRESULT result = new ANALYSISRESULT();
                result.udsReq = listRequests[reqIndex];
                result.path   = path;
                analysisResults.Add(result);
                listBoxResult.Items.Add(result.udsReq.description);
            }

endProcess:
            buttonEnd.Enabled      = false;
            buttonStart.Enabled    = true;
            groupBoxResult.Enabled = true;
            wantTerminate          = false;
        }