Пример #1
0
        public void GetData()
        {
            String msg = "";

            Thread.Sleep(500);


            int i = 0;

            msg = usb.ReadData();


            if (msg.Contains("sys_power_flg")) // || msg.Contains( "onu_info.rx_lenth")
            {
                Action <int> action = (data) =>
                {
                    int    start0    = msg.IndexOf("mcu_temperate");
                    int    length0   = " = 36.71".Length;
                    String tmpValue0 = msg.Substring(start0 + 15, length0).Trim();

                    int    start1    = msg.IndexOf("battary_volatge ");
                    int    length1   = " = 4.30".Length;
                    String tmpValue1 = msg.Substring(start1 + 17, length1).Trim();

                    int    start2    = msg.IndexOf("fan_speed_test");
                    int    length2   = " = 0  ".Length;
                    String tmpValue2 = msg.Substring(start2 + 16, length2).Trim();

                    // ReceivedTextBox.Text += msg + "\r\n";


                    lbl_mcu_temperate.Text   = "mcu_temperate:" + tmpValue0;
                    lbl_battary_volatge.Text = "battary_volatge:" + tmpValue1;
                    lbl_fan_speed.Text       = "fan_speed:" + tmpValue2;


                    String responseoutput = String.Empty;
                    responseoutput = msg;
                    //save info log
                    StreamWriter file = new StreamWriter("usblog.txt", true);
                    file.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff") + "        " + responseoutput);
                    file.Close();

                    //graph list
                    string amount = string.Empty;
                    if (!string.IsNullOrEmpty(tmpValue0) && (Regex.IsMatch(tmpValue0, @"^[1-9]\d*|0$"))) // || Regex.IsMatch(tmpValue0, @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$")
                    {
                        amount = Convert.ToDecimal(tmpValue0).ToString("F2");
                    }
                    else
                    {
                        amount = "0.00";
                    }


                    //string amount = string.Empty;
                    //amount = tmpValue0.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
                    temperature_y1.Add(float.Parse(amount));
                    ReceivedTextBox.Text += amount + "\r\n";
                };
                Invoke(action, i);
                i++;

                //  }
                Thread.Sleep(1000);
                //    }
            }
            //else
            //{
            //    try
            //    {

            //        vertest_again();
            //    }
            //    catch {
            //        MessageBox.Show("123123");
            //    }

            //}
        }
Пример #2
0
        // Random rand = new Random();

        public void GetData_foh100_state()
        {
            String msg = "";

            Thread.Sleep(100);


            int i = 0;

            msg = usb.ReadData();


            if (msg.Contains("sys_power_flg")) // || msg.Contains( "onu_info.rx_lenth")
            {
                Action <int> action = (data) =>
                {
                    int    start0    = msg.IndexOf("mcu_temperate");
                    int    length0   = " = 36.71".Length;
                    String tmpValue0 = msg.Substring(start0 + 15, length0 - 1).Trim();

                    int    start1    = msg.IndexOf("battary_volatge ");
                    int    length1   = " = 4.30".Length;
                    String tmpValue1 = msg.Substring(start1 + 17, length1).Trim();

                    int    start2    = msg.IndexOf("fan_speed_test");
                    int    length2   = " = 0  ".Length;
                    String tmpValue2 = msg.Substring(start2 + 16, length2 - 2).Trim();

                    // ReceivedTextBox.Text += msg + "\r\n";



                    //温度计显示
                    userControl1_temperature.CurValue = float.Parse(tmpValue0);
                    userControl1_temperature.Refresh();

                    //最大温度值:
                    if (float.Parse(tb_temperature_max.Text) < float.Parse(tmpValue0))
                    {
                        tb_temperature_max.Text = tmpValue0;
                    }



                    String responseoutput = String.Empty;
                    responseoutput = msg;
                    //save info log
                    StreamWriter file = new StreamWriter("fohlog.txt", true);
                    file.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff") + "        " + responseoutput);
                    file.Close();

                    //graph list
                    //string amount = string.Empty;
                    //if (!string.IsNullOrEmpty(tmpValue0) && (Regex.IsMatch(tmpValue0, @"^[1-9]\d*|0$"))) // || Regex.IsMatch(tmpValue0, @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$")
                    //{
                    //    amount = Convert.ToDecimal(tmpValue0).ToString();

                    //}
                    //else
                    //{
                    //    amount = "0.00";
                    //}


                    //string amount = string.Empty;
                    //amount = tmpValue0.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");

                    y1.Add(float.Parse(tmpValue0));

                    //让文本框获取焦点
                    this.ReceivedTextBox.Focus();
                    //设置光标的位置到文本尾
                    this.ReceivedTextBox.Select(this.ReceivedTextBox.TextLength, 0);
                    //滚动到控件光标处
                    this.ReceivedTextBox.ScrollToCaret();
                    ReceivedTextBox.Text += "temperature: " + float.Parse(tmpValue0) + "\r\n" + "battary_volatge: " + tmpValue1 + "\r\n" + "fan_speed: " + tmpValue2 + "\r\n";
                    x1.Add(timerDrawI);

                    // y1.Add(float.Parse(tb_mcu_temperate.Text));
                    timerDrawI++;
                    LGraphTest.f_Refresh();

                    lbl_send_count.Text = "采样计数: " + sendCount++.ToString();
                };
                Invoke(action, i);
                i++;

                //  }
                Thread.Sleep(200);
                //    }
            }
        }
Пример #3
0
        public void GetData()
        {
            String msg = "";

            Thread.Sleep(500);


            int i = 0;

            msg = usb.ReadData();


            if (msg.Contains("V"))
            {
                Action <int> action = (data) =>
                {
                    int    start0    = msg.IndexOf("V");
                    int    length0   = "V1.3.6".Length;
                    String tmpValue0 = msg.Substring(start0, length0).Trim();

                    int    start1    = msg.IndexOf("PAM3001.ver:");
                    int    length1   = "V2.2_1905220".Length;
                    String tmpValue1 = msg.Substring(start1 + 13, length1).Trim();

                    int    start2    = msg.IndexOf("PAM3001.fpga: ");
                    int    length2   = "19042400    ".Length;
                    String tmpValue2 = msg.Substring(start2 + 13, length2).Trim();

                    // ReceivedTextBox.Text += msg;


                    tBx_EpSoftware.Text = tmpValue1;
                    tBx_VOA.Text        = tmpValue0;
                    tBx_EpFPGA.Text     = tmpValue2;

                    String responseoutput = String.Empty;
                    responseoutput = msg;
                    //save info log
                    StreamWriter file = new StreamWriter("log.txt", true);
                    file.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff") + "        " + responseoutput);
                    file.Close();
                };
                Invoke(action, i);
                i++;
                //  }
                Thread.Sleep(1000);
                //    }
            }
            //else
            //{
            //    try
            //    {

            //        vertest_again();
            //    }
            //    catch {
            //        MessageBox.Show("123123");
            //    }

            //}
        }