示例#1
0
文件: CMTS.cs 项目: tayeumi/HFC
        public void PHY_Card_all(out string[] List, DevExpress.XtraSplashScreen.SplashScreenManager Wait,out List<string> list1)
        {
            List = null;
            list1 = null;
            string t = "";

            if (tcpClient.Connected)
            {
                string strCMD = "sh cable modem phy\r\n";

                ASCIIEncoding encoder = new ASCIIEncoding();
                byte[] buffer = encoder.GetBytes(strCMD);
                NetworkStream clientStream = tcpClient.GetStream();
                clientStream.Write(buffer, 0, buffer.Length);
                Thread.Sleep(100);
                //Application.DoEvents();
                byte[] message = new byte[8192 * 30];

                do
                {
                    Thread.Sleep(20);
                } while (!clientStream.DataAvailable);

                if (clientStream.CanRead && clientStream.DataAvailable)
                {
                    //blocks until a client sends a message
                    try
                    {
                        //clientStream.Read(message, 0, (int)8192 * 30);
                       // Thread.Sleep(_Theard);
                        //t = encoder.GetString(message);
                        int bytesRead;
                        string result = "";
                        while (true)
                        {
                            try
                            {
                                bytesRead = 0;
                                //buffer = encoder.GetBytes(" ");
                                //clientStream.Write(buffer, 0, buffer.Length);
                                //Thread.Sleep(20);
                                bytesRead = clientStream.Read(message, 0, 8192 * 30);
                                if (bytesRead == 0)
                                {
                                    break;
                                }
                                t = encoder.GetString(message, 0, bytesRead);
                                t = t.Trim();
                                result += t;
                                if (t.EndsWith("--More--"))
                                {
                                    buffer = encoder.GetBytes(" ");
                                    clientStream.Write(buffer, 0, buffer.Length);
                                    Thread.Sleep(50);
                                   // Application.DoEvents();
                                    Class.App.Wait++;
                                }
                                if (t.EndsWith("MOT:7A#"))
                                {
                                    break;
                                }
                                if (Wait != null)
                                {
                                    if (Wait.IsSplashFormVisible)
                                    {
                                        Regex r2 = new Regex(@" (\d+)/(.*)L0 ");
                                        Match m2 = r2.Match(t);
                                        string location = "";
                                        if (m2.Success)
                                        {
                                            location = m2.Value.Trim();
                                        }
                                        Wait.SetWaitFormDescription("Đang tải PHY ( " + location + " )");
                                        Thread.Sleep(2);
                                    }
                                }
                            }
                            catch
                            {
                              //  MessageBox.Show(ex.Message);
                                break;
                            }
                        }

                      // List<string> list = new List<string>();
                        result = result.Replace("TDMA", "TDMA \n");
                        result = result.Replace("\r--More--\b\b\b\b\b\b\b\b\b", "");
                        result = result.Replace("\r", "");
                        List = result.Split('\n');

                        list1 = new List<string>();
                        //for (int i = 0; i < List.Length; i++)
                        //{

                        //    List[i] = List[i].ToString().Replace("\r--More-- \b\b\b\b\b\b\b\b\b", "");
                        //    List[i] = List[i].ToString().Replace("\r", "");
                        //    List[i] = List[i].ToString().Replace("--More--\b\b\b\b\b\b\b\b\b", "");

                        //    if (List[i].ToString().Trim().EndsWith("TDMA"))
                        //    {
                        //        if(List[i].ToString().Trim().Length>20)
                        //        {
                        //            string txt = List[i];
                        //            //txt = txt.Substring(txt.IndexOf("TDMA")+4);
                        //            list1.Add(txt);
                        //        }
                        //    }
                        //}
                        //TextWriter sw = new StreamWriter(@"Temp.txt", true);
                        //sw.WriteLine(result);
                        //sw.Close();
                    }
                    catch { }

                }

            }
        }
示例#2
0
文件: CMTS.cs 项目: tayeumi/HFC
        public void Remote_Card_all(out string[] List, DevExpress.XtraSplashScreen.SplashScreenManager Wait)
        {
            List = null;

            string t = "";

            if (tcpClient.Connected)
            {
                string strCMD = "sh cable modem remote\r\n";

                ASCIIEncoding encoder = new ASCIIEncoding();
                byte[] buffer = encoder.GetBytes(strCMD);
                NetworkStream clientStream = tcpClient.GetStream();
                clientStream.Write(buffer, 0, buffer.Length);
                Thread.Sleep(100);
               // Application.DoEvents();
                byte[] message = new byte[8192 * 30];

                do
                {
                    Thread.Sleep(20);
                } while (!clientStream.DataAvailable);

                if (clientStream.CanRead && clientStream.DataAvailable)
                {
                    //blocks until a client sends a message
                    try
                    {
                       // clientStream.Read(message, 0, (int)8192 * 30);
                       // Thread.Sleep(_Theard);
                      //  t = encoder.GetString(message);
                        int bytesRead;
                        string result = "";
                            while (true)
                            {
                                try
                                {
                                    bytesRead = 0;
                                    //buffer = encoder.GetBytes(" ");
                                    //clientStream.Write(buffer, 0, buffer.Length);
                                    //Thread.Sleep(20);
                                    bytesRead = clientStream.Read(message, 0, 8192 * 30);
                                    if (bytesRead == 0)
                                    {
                                        break;
                                    }
                                    t = encoder.GetString(message, 0, bytesRead);
                                    t=t.Trim();
                                    result += t;
                                    if (t.EndsWith("--More--"))
                                    {
                                        buffer = encoder.GetBytes(" ");
                                        clientStream.Write(buffer, 0, buffer.Length);
                                        Thread.Sleep(10);
                                       // Application.DoEvents();
                                    }
                                    if(t.EndsWith("MOT:7A#"))
                                    {
                                        break;
                                    }
                                    //
                                    if (Wait != null)
                                    {
                                        if (Wait.IsSplashFormVisible)
                                        {
                                            Regex r2 = new Regex(@"(\d+)/(.*)L0 ");
                                            Match m2 = r2.Match(t);
                                            string location="";
                                            if (m2.Success)
                                            {
                                               location = m2.Value.Trim();
                                            }
                                            Wait.SetWaitFormDescription("Đang tải Remote ( " + location+" )");
                                        }
                                    }
                                }
                                catch
                                {
                                    break;
                                }
                            }
                        result = result.Replace("line", "line \n");
                        List = result.Split('\n');
                        for (int i = 0; i < List.Length; i++)
                        {
                            List[i] = List[i].ToString().Replace("\r--More-- \b\b\b\b\b\b\b\b\b", "");
                            List[i] = List[i].ToString().Replace("\r", "");
                        }

                    }
                    catch { }

                }

            }
        }