Beispiel #1
0
        private void Display_Correct_Text(Byte[] Receive_Buffer)
        {
            //Total_TextBox.AppendText("Rx: ");
            //Total_TextBox.AppendText(BitConverter.ToString(Receive_Buffer).Replace("-", " "));
            //Total_TextBox.AppendText(Environment.NewLine);
            Correct_TextBox.AppendText("Tx: ");
            Correct_TextBox.AppendText(BitConverter.ToString(buffer).Replace("-", " "));
            Correct_TextBox.AppendText(Environment.NewLine);
            Correct_TextBox.AppendText("Rx: ");
            Correct_TextBox.AppendText(BitConverter.ToString(Receive_Buffer).Replace("-", " "));
            Correct_TextBox.AppendText(Environment.NewLine);

            DataRow dr = file.dt.NewRow();   //建立新的Rows

            dr["TX"]     = BitConverter.ToString(buffer).Replace("-", " ");
            dr["RX"]     = BitConverter.ToString(Receive_Buffer).Replace("-", " ");
            dr["RESULT"] = "TRUE";
            file.dt.Rows.Add(dr);

            file.SaveCsv(file.dt, file.GetFileName());

            Correct_Times++;
            Correct_Count_TextBox.Text = Correct_Times.ToString();
            Temp_Receive_Buffer        = new Byte[1024];
        }
Beispiel #2
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            Timeout_Count++;

            if (Timeout_Count == modbus.Modbus_Timeout)
            {
                if (buffer[modbus.Modbus_Id_Index] != 0)
                {
                    TimeOut_Error_Times++;
                    TimeOut_Count_TextBox.Text = TimeOut_Error_Times.ToString();
                    Error_TextBox.AppendText("Tx: ");
                    Error_TextBox.AppendText(BitConverter.ToString(buffer).Replace("-", " "));
                    Error_TextBox.AppendText(Environment.NewLine);

                    DataRow dr = file.dt.NewRow();   //建立新的Rows
                    dr["TX"]     = BitConverter.ToString(buffer).Replace("-", " ");
                    dr["RESULT"] = "FALSE";
                    file.dt.Rows.Add(dr);
                }
                else
                {
                    Correct_Times++;
                    Correct_Count_TextBox.Text = Correct_Times.ToString();

                    DataRow dr = file.dt.NewRow();   //建立新的Rows
                    dr["TX"]     = BitConverter.ToString(buffer).Replace("-", " ");
                    dr["RESULT"] = "TRUE";
                    file.dt.Rows.Add(dr);
                }

                file.SaveCsv(file.dt, file.GetFileName());
                Is_Need_Receive = false;

                Clear_Timer2_Parameter();
                //s.Stop();//開始計時

                //TimeOut_Count_TextBox.Text = ((s.ElapsedMilliseconds).ToString() + "毫秒");
                //s.Reset();
            }
        }