Example #1
0
        //发送指令
        private string SendCommandAndGetResult()
        {
            //获取待发送指令
            string cmd = GetSendCommand();

            //预处理指令
            string ErrorMessage = "";
            string precmd       = PrepareCommand.DuelCommand(cmd, ref ErrorMessage);

            if (precmd == "")
            {
                if (ErrorMessage != "")
                {
                    richTextBox1.AppendText("\n" + ErrorMessage);
                }
                richTextBox1.AppendText("\n>");
                richTextBox1.SelectionStart = richTextBox1.TextLength;
            }
            else
            {
                string strResult = "";
                if (PublicClass.SendCommand(precmd, 1, ref strResult))
                {
                    //格式化返回结果(主要处理AVH返回)
                    strResult = PublicClass.FormatResult(precmd, strResult);

                    richTextBox1.AppendText("\n" + strResult + "\n>");
                    richTextBox1.SelectionStart = richTextBox1.TextLength;
                    //分析返回结果
                    PrepareCommand.AnalyseCommandResult(precmd, strResult);
                }
                else
                {
                    MessageBox.Show(strResult);
                }
            }

            return(cmd);
        }