예제 #1
0
        public void SkyinforVideoServer()
        {
            //显示视频转码路数
            CrossThreadOperationControl CrossDele_VideoCount = delegate()
            {
                Mainform.form1.textBoxVideo.Text = StaticData.g_dtCamera.Rows.Count + "路";
            };

            Mainform.form1.textBoxVideo.Invoke(CrossDele_VideoCount);
            List <string> rtspList = new List <string>();
            List <string> idList   = new List <string>();

            //遍历一下所有的摄像头rtsp流,传入rtsp流地址,通道号,就能实现转换了
            for (int i = 0; i < StaticData.g_dtCamera.Rows.Count; i++)
            {
                rtspList.Add(StaticData.g_dtCamera.Rows[i]["RTSP地址"].ToString());
                idList.Add(StaticData.g_dtCamera.Rows[i]["通道号"].ToString());
            }
            try
            {
                skyinforVideoShare(rtspList.ToArray(), idList.ToArray(), StaticData.g_dtCamera.Rows.Count);
            }
            catch (Exception)
            {
                //自己写的代码,肯定有异常,先不管了。。。测试能用了再说
                StaticUtils.ShowEventMsg("SkyinforHikvision.class-SkyinforVideoServer : SkyinforVideoServer出现异常!!\n");
                return;
            }
        }
        //事件信息增加
        public void ShowEventMsg(string msg)
        {
            CrossThreadOperationControl CrossDele = delegate()
            {
                Mainform.form1.kText_EventInfo.AppendText(msg);
            };

            Mainform.form1.kText_EventInfo.Invoke(CrossDele);
        }
        private void CrossThreadPictureBox()
        {
            CrossThreadOperationControl CrossDele = delegate()
            {
                m_picturebox = Mainform.form1.kPictureBox;
            };

            Mainform.form1.kPictureBox.Invoke(CrossDele);
        }
예제 #4
0
        private void setFormBcolor(Color color)
        {
            CrossThreadOperationControl CrossDelete = delegate()
            {
                this.BackColor = color;
            };

            this.Invoke(CrossDelete);
        }
예제 #5
0
        private void setLabelText(String sre_text)
        {
            CrossThreadOperationControl CrossDelete = delegate()
            {
                label1.Text = sre_text;
            };

            label1.Invoke(CrossDelete);
        }
 public override void PreviewFun(int userID, int channel)
 {
     CrossThreadPictureBox();
     if (userID < 0)
     {
         MessageBox.Show("该设备初始化登录失败!");
     }
     if (g_lRealHandle < 0)
     {
         // m_ptrRealHandle = m_picturebox.Handle;
         CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO(); //定义预览参数
         lpPreviewInfo.hPlayWnd        = m_picturebox.Handle;                               //预览窗口句柄绑定
         lpPreviewInfo.lChannel        = channel + 32;                                      //要预览的设备通道号
         lpPreviewInfo.dwStreamType    = 0;                                                 //码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
         lpPreviewInfo.dwLinkMode      = 0;                                                 //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
         lpPreviewInfo.bBlocked        = true;                                              //0- 非阻塞取流,1- 阻塞取流
         lpPreviewInfo.dwDisplayBufNum = 15;                                                //播放库显示缓冲区最大帧数
         IntPtr pUser = IntPtr.Zero;                                                        //用户数据
         lpPreviewInfo.hPlayWnd = IntPtr.Zero;                                              //预览窗口 live view window
         RealData      = new CHCNetSDK.REALDATACALLBACK(RealDataCallBack);                  //预览实时流回调函数 real-time stream callback function
         g_lRealHandle = CHCNetSDK.NET_DVR_RealPlay_V40(userID, ref lpPreviewInfo, RealData, pUser);
         if (g_lRealHandle < 0)
         {
             iLastErr = CHCNetSDK.NET_DVR_GetLastError();
             MessageBox.Show("预览失败,输出错误号: " + iLastErr); //预览失败,输出错误号
             return;
         }
         else
         {
             CrossThreadOperationControl CrossDeleBtn = delegate()
             {
                 Mainform.form1.kButtonView.Text = "停止预览";
             };
             Mainform.form1.kPictureBox.Invoke(CrossDeleBtn);
         }
     }
     else
     {
         //停止预览 Stop live view
         if (!CHCNetSDK.NET_DVR_StopRealPlay(g_lRealHandle))
         {
             iLastErr = CHCNetSDK.NET_DVR_GetLastError();
             MessageBox.Show("NET_DVR_StopRealPlay failed, error code= " + iLastErr);
             return;
         }
         m_picturebox.Invalidate();//刷新窗口
         m_picturebox.Refresh();
         g_lRealHandle = -1;
         StaticData.g_CameraSelectChannel = -1;
         CrossThreadOperationControl CrossDeleBtn = delegate()
         {
             Mainform.form1.kButtonView.Text = "预览";
         };
         Mainform.form1.kPictureBox.Invoke(CrossDeleBtn);
     }
 }
        //命令信息 高亮输出
        public static void ShowCMDMsg(string msg)
        {
            CrossThreadOperationControl CrossDele = delegate()
            {
                Mainform.form1.kText_Cmd.AppendText(msg);
                Mainform.form1.kText_Cmd.AppendText(Environment.NewLine);
            };

            Mainform.form1.kText_Cmd.Invoke(CrossDele);
        }
예제 #8
0
        private String getCombobox2Text()
        {
            String combo_str = "";
            CrossThreadOperationControl CrossDelete = delegate()
            {
                combo_str = comboBox2.Text;
            };

            comboBox2.Invoke(CrossDelete);
            return(combo_str);
        }
        private void StartListen()
        {
            Socket clientSocket = default(Socket);
            string strClientIP;

            while (true)
            {
                try
                {
                    clientSocket = m_listener.Accept();//这个方法返回一个通信套接字,并用这个套接字进行通信,错误时返回-1并设置全局错误变量
                }
                catch (Exception e)
                {
                    StaticUtils.ShowEventMsg("MgJsonCtrl.class-StartListen : 监听Json出现异常!");
                    Console.WriteLine(e);
                }
                Byte[] bytesForm = new byte[1024 * 1024];
                if (clientSocket != null && clientSocket.Connected)
                {
                    try
                    {
                        int length = clientSocket.Receive(bytesForm);
                        clientSocket.Send(PackHandShakeData(GetSecKeyAccept(bytesForm, length)));
                        strClientIP = clientSocket.RemoteEndPoint.ToString(); //得到客户端IP
                                                                              //      Console.WriteLine(strClientIP );
                        if (m_listClient.ContainsKey(strClientIP))
                        {
                            m_listClient[strClientIP] = clientSocket;
                        }
                        else
                        {
                            m_listClient.Add(strClientIP, clientSocket);
                            CrossThreadOperationControl CrossDele = delegate()
                            {
                                Mainform.form1.listViewIPClient.Items.Add(strClientIP);
                            };
                            Mainform.form1.listViewIPClient.Invoke(CrossDele);
                        }
                        //创建一个通信线程
                        ParameterizedThreadStart pts = new ParameterizedThreadStart(recv);
                        Thread thread = new Thread(pts);
                        thread.IsBackground = true;
                        thread.Start(clientSocket);
                        dictThread.Add(clientSocket.RemoteEndPoint.ToString(), thread);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        StaticUtils.ShowEventMsg("MgJsonCtrl.class-StartListen : 监听Json出现异常!\n");
                    }
                }
            }
        }
예제 #10
0
        public CameraListUpdate(DataTable dt)
        {
            CrossThreadOperationControl CrossDele = delegate()
            {
                Mainform.form1.kdtGrid_CameraList.DataSource = dt;
                //for (int k = 0; k < dt.Columns.Count; k++)
                //{
                //    Mainform.form1.kdtGrid_CameraList.Columns[k].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;//自适应下表单
                //}
            };

            Mainform.form1.kdtGrid_CameraList.Invoke(CrossDele);
        }
        /// <summary>
        /// 接收数据
        /// </summary>
        /// <param name="socketclientpara"></param>
        public void recv(object socketclientpara)
        {
            Socket socketClient = socketclientpara as Socket;

            myJson = new MyJsonCtrl();
            while (true)
            {
                //创建一个内存缓冲区,其大小为1024*1024字节  即1M
                byte[] arrServerRecMsg = new byte[1024 * 1024];
                //将接收到的信息存入到内存缓冲区,并返回其字节数组的长度
                try
                {
                    int length = socketClient.Receive(arrServerRecMsg);
                    //处理收到的数据
                    string strSRecMsg = AnalyticData(arrServerRecMsg, length);
                    //   Console.WriteLine(strSRecMsg);

                    ///
                    ///zzt重要,这里是解析每个web客户端发过来命令的地方
                    ///
                    string strReturn = myJson.ReceiceJson(strSRecMsg);
                    SendMessage(socketClient, strReturn);
                    //  Console.WriteLine(strReturn);
                }
                catch (SocketException ex)
                {
                    StaticUtils.ShowEventMsg("MgJsonCtrl.class-recv : 接收数据出现异常!\n");
                    Console.WriteLine("异常抛出" + ex + ",RemoteEnd=" + socketClient.RemoteEndPoint.ToString());
                    //从通信套接字集合中删除被中断连接的通信套接字
                    m_listClient.Remove(socketClient.RemoteEndPoint.ToString());//删除异常的端口和IP
                    Thread stopThread = dictThread[socketClient.RemoteEndPoint.ToString()];
                    //从通信线程中删除被中断的连接通信线程对象
                    dictThread.Remove(socketClient.RemoteEndPoint.ToString());//删除异常的线程
                    CrossThreadOperationControl CrossDele = delegate()
                    {
                        for (int j = 0; j < Mainform.form1.listViewIPClient.Items.Count; j++)
                        {
                            if (Mainform.form1.listViewIPClient.Items[j].Text.Equals(socketClient.RemoteEndPoint.ToString()))
                            {
                                Mainform.form1.listViewIPClient.Items.Remove(Mainform.form1.listViewIPClient.Items[j]);
                                j--;
                            }
                        }
                    };
                    Mainform.form1.listViewIPClient.Invoke(CrossDele);
                    stopThread.Abort();
                    return;
                }
            }
        }
예제 #12
0
        private void BackgroundProcess()
        {
            //将代理实例化为一个匿名代理
            CrossThreadOperationControl CrossDelete = delegate()
            {
                int i = 1;
                while (i < 5)
                {
                    listBox1.Items.Add("Item" + i.ToString());
                    i++;
                }
                label1.Text = "我在新线程里访问这个label";
                listBox1.Items.Add(label1.Text);
            };

            listBox1.Invoke(CrossDelete);
        }
예제 #13
0
        public HikvisionPTZControl()
        {
            CrossThreadOperationControl CrossDeleBtn = delegate()
            {
                Mainform.form1.kcomboBoxPTZ.SelectedIndex = 3;
                if (HikvisionPreviewFun.g_lRealHandle > -1)
                {
                    Mainform.form1.kcheckBox_isPreviewON.Checked = true;
                }
                else
                {
                    Mainform.form1.kcheckBox_isPreviewON.Checked = false;
                }
            };

            Mainform.form1.kPictureBox.Invoke(CrossDeleBtn);
        }
예제 #14
0
 private void PingCheck()
 {
     while (true)
     {
         int prepare = 0;
         int ready   = 0;
         int connect = 0;
         foreach (Device dev in DeviceManger.deviceList)
         {
             if (dev.PingOK == 1)
             {
                 prepare++;
             }
             else if (dev.PingOK == 2)
             {
                 ready++;
             }
             if (dev.ConnectionState == 0)
             {
                 connect++;
             }
         }
         CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
         {
             if (connect > 0)
             {
                 CSAMForm.PingText.Text = "已连接";
             }
             else if (ready > 0)
             {
                 CSAMForm.PingText.Text = "待连接";
             }
             else if (prepare > 0)
             {
                 CSAMForm.PingText.Text = "准备中";
             }
             else if (prepare == 0 && ready == 0)
             {
                 CSAMForm.PingText.Text = "未就绪";
             }
         };
         CSAMForm.Invoke(CrossThreadInfoRefresh);
     }
 }
예제 #15
0
        /// <summary>
        /// 获取软件占用资源信息--I/O--CPU--Memory
        /// </summary>
        public void GetProgramInfo()
        {
            //获取当前进程对象
            Process            cur            = Process.GetCurrentProcess();
            PerformanceCounter curpcp         = new PerformanceCounter("Process", "Working Set - Private", cur.ProcessName);
            PerformanceCounter curpc          = new PerformanceCounter("Process", "Working Set", cur.ProcessName);
            PerformanceCounter curtime        = new PerformanceCounter("Process", "% Processor Time", cur.ProcessName);
            PerformanceCounter ioReadcounter  = new PerformanceCounter("Process", "IO Read Bytes/sec", cur.ProcessName);
            PerformanceCounter ioWritecounter = new PerformanceCounter("Process", "IO Write Bytes/sec", cur.ProcessName);

            //上次记录CPU的时间
            TimeSpan prevCpuTime = TimeSpan.Zero;
            //Sleep的时间间隔
            int interval = 1000;
            PerformanceCounter totalcpu = new PerformanceCounter("Processor", "% Processor Time", "_Total");
            //  SystemInfo sys = new SystemInfo();
            const int KB_DIV = 1024;
            const int MB_DIV = 1024 * 1024;
            const int GB_DIV = 1024 * 1024 * 1024;

            while (true)
            {
                // Console.WriteLine("{0}:{1}  {2:N}MB CPU使用率:{3}%", cur.ProcessName, "私有工作集    ", curpcp.NextValue() / MB_DIV, curtime.NextValue() / Environment.ProcessorCount);
                //Console.WriteLine("读取硬盘:{0}----------写入硬盘:{1}", ioReadcounter.NextValue() , ioWritecounter.NextValue() / KB_DIV);

                Thread.Sleep(interval);
                CrossThreadOperationControl CrossDele_cpu = delegate()
                {
                    Mainform.form1.textBoxCPU.Text = Math.Round(curtime.NextValue() / Environment.ProcessorCount, 2) + "%";
                };
                Mainform.form1.textBoxCPU.Invoke(CrossDele_cpu);
                CrossThreadOperationControl CrossDele_memory = delegate()
                {
                    Mainform.form1.textBoxMemory.Text = Math.Round(curpcp.NextValue() / MB_DIV, 2) + "MB";
                };
                Mainform.form1.textBoxMemory.Invoke(CrossDele_memory);
                CrossThreadOperationControl CrossDele_io = delegate()
                {
                    Mainform.form1.textBoxIO.Text = "读取:" + Math.Round(ioReadcounter.NextValue(), 2) + "B/s  " + "写入:" + Math.Round(ioWritecounter.NextValue() / KB_DIV, 2) + "KB/s";
                };
                Mainform.form1.textBoxIO.Invoke(CrossDele_io);
            }
        }
예제 #16
0
        private void CellSearchBtnUnable()
        {
            CrossThreadOperationControl CrossThreadChange = delegate()
            {
                if (unableCount == 0)
                {
                    CSAMBtnStatus = CSAMForm.CellMonitorButton.Enabled;
                    CSAMForm.CellMonitorButton.Enabled     = false;
                    CSAMForm.AddToSearchListButton.Enabled = false;
                    CSAMForm.CellMonitorListView.Enabled   = false;
                }
                unableCount++;
                if (unableCount == 2)
                {
                    unableCount = 0;
                }
            };

            CSAMForm.Invoke(CrossThreadChange);
        }
예제 #17
0
        public void SkyinforVideoServer()
        {
            List <string> rtspList = new List <string>();
            List <string> idList   = new List <string>();
            int           k        = 0;

            //遍历一下所有的摄像头rtsp流,传入rtsp流地址,通道号,就能实现转换了,不是判断摄像头online,判断device_transcoding_flag,然后传入rtsp地址
            for (int i = 0; i < StaticData.g_dtCamera.Rows.Count; i++)
            {
                //  if (StaticData.g_dtCamera.Rows[i]["摄像头状态"].ToString()=="online")
                if (Convert.ToInt32(StaticData.g_dtCamera.Rows[i]["转码标识"]) == 1)
                {
                    rtspList.Add(StaticData.g_dtCamera.Rows[i]["RTSP地址"].ToString());
                    idList.Add(k.ToString());
                    k++;
                }
            }


            //显示视频转码路数
            CrossThreadOperationControl CrossDele_VideoCount = delegate()
            {
                Mainform.form1.textBoxVideo.Text = rtspList.Count + "路";
            };

            Mainform.form1.textBoxVideo.Invoke(CrossDele_VideoCount);
            try
            {
                skyinforVideoShare(rtspList.ToArray(), idList.ToArray(), rtspList.Count);//该处暂时写死了------------
            }
            catch (Exception)
            {
                //自己写的代码,肯定有异常,先不管了。。。测试能用了再说
                StaticUtils.ShowEventMsg("SkyinforVideoTransform.class-SkyinforVideoServer : 出现异常!!\n");
                return;
            }
        }
예제 #18
0
 public void ACKHandler(object sender, AGIInterface.CustomDataEvtArg e)
 {
     if (this.InvokeRequired)
     {
         try
         {
             this.BeginInvoke(new Class1.DeviceSendACKToCellScan(ACKHandler), sender, e);
         }
         catch
         {
         }
     }
     else
     {
         if (Global.CurrentSender == CSAMForm.Name && e.deivceName == Global.GCurrentDevice)
         {
             //
             if (mutexRrace == 0 && CellSearchItemIndex != CSAMForm.CellSearchListView.Items.Count) //CellSearchItemIndex = 0;
             {
                 Thread.Sleep(1000);
                 CellSearchItemIndex++;
                 System.Diagnostics.Debug.WriteLine("CellSearchItemIndex: " + CellSearchItemIndex + ">>>>>>>>>>>>>>>>");
                 mutexRrace = 1;
                 CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
                 {
                     CSAMForm.CellIndexLabel.Text = CellSearchItemIndex.ToString();
                     if (CellSearchItemIndex != CSAMForm.CellSearchListView.Items.Count && isStop == false)
                     {
                         CSAMForm.CellSearchStart();
                     }
                 };
                 CSAMForm.Invoke(CrossThreadInfoRefresh);
             }
             if (CellSearchItemIndex == CSAMForm.CellSearchListView.Items.Count || isStop == true)
             {
                 CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
                 {
                     //Device temDevice = null;
                     //foreach (Device d in DeviceManger.deviceList)
                     //{
                     //    if (d.ConnectionState == 0)
                     //        temDevice = d;
                     //}
                     //DeviceManger DM = new DeviceManger();
                     //Thread RebootThread = new Thread(() => DM.RebootThreadFun(temDevice));
                     //RebootThread.Start();
                     CSAMForm.CellIndexLabel.Text = CellSearchItemIndex.ToString();
                     foreach (Device dev in DeviceManger.deviceList)
                     {
                         if (dev.SendRexAnt)
                         {
                             dev.SendRexAnt = false;
                         }
                     }
                     isStop = false;
                     CSAMForm.CellMonitorButton.Enabled = true;
                     CSAMForm.CellStopBtn.Enabled       = false;
                     Global.tempClass.CSAMStop();
                     CSAMRunning = false;
                     //Global.tempClass.FTSTMSIStop();
                 };
                 CSAMForm.Invoke(CrossThreadInfoRefresh);
             }
         }
     }
 }
예제 #19
0
        /// <summary>
        /// 用于更新UI中的在线数、掉线数、报警数等信息
        /// </summary>
        public void UpdateForm()
        {
            DataRow[] dtrCamera_Online     = null; //获取摄像头在线的行数
            DataRow[] dtrCamera_Offline    = null; //获取摄像头掉线的行数
            DataRow[] dtrBroadcast_Online  = null; //获取广播在线的行数
            DataRow[] dtrBroadcast_Offline = null; //获取广播离线的行数
            while (true)
            {
                Thread.Sleep(5000);
                try
                {
                    dtrCamera_Online  = StaticData.g_dtCamera.Select("摄像头状态='正常'"); //获取摄像头在线的行数
                    dtrCamera_Offline = StaticData.g_dtCamera.Select("摄像头状态='掉线'"); //获取摄像头掉线的行数
                }
                catch (Exception)
                {
                    StaticUtils.ShowEventMsg("Mainform.class-UpdateForm : 获取摄像头在线数据出现异常!!\n");
                }
                try
                {
                    dtrBroadcast_Online  = StaticData.g_dtBroadcastDevice.Select("连通='连通'");   //获取广播在线的行数
                    dtrBroadcast_Offline = StaticData.g_dtBroadcastDevice.Select("连通 <>'连通'"); //获取广播离线的行数
                }
                catch (Exception)
                {
                    StaticUtils.ShowEventMsg("Mainform.class-UpdateForm : 获取广播在线数据出现异常!!\n");
                }

                #region 跨线程更新UI界面

                if (dtrCamera_Online != null)
                {
                    CrossThreadOperationControl CrossDele_CamOnline = delegate()
                    {
                        Mainform.form1.textBoxCameraOnline.Text = dtrCamera_Online.Length.ToString();
                    };
                    Mainform.form1.textBoxCameraOnline.Invoke(CrossDele_CamOnline);
                    CrossThreadOperationControl CrossDele_CamOffline = delegate()
                    {
                        Mainform.form1.textBoxCameraOffline.Text = dtrCamera_Offline.Length.ToString();
                    };
                    Mainform.form1.textBoxCameraOffline.Invoke(CrossDele_CamOffline);
                    CrossThreadOperationControl CrossDele_AlarmNum = delegate()
                    {
                        Mainform.form1.textBoxCameraAlarm.Text = StaticData.g_inAlarmNum.ToString();
                    };
                    Mainform.form1.textBoxCameraAlarm.Invoke(CrossDele_AlarmNum);
                }

                if (dtrBroadcast_Online != null)
                {
                    CrossThreadOperationControl CrossDele_BroadOnline = delegate()
                    {
                        Mainform.form1.textBoxBroadcastOnline.Text = dtrBroadcast_Online.Length.ToString();
                    };
                    Mainform.form1.textBoxBroadcastOnline.Invoke(CrossDele_BroadOnline);
                    CrossThreadOperationControl CrossDele_BroadOffline = delegate()
                    {
                        Mainform.form1.textBoxBroadcastOffline.Text = dtrBroadcast_Offline.Length.ToString();
                    };
                    Mainform.form1.textBoxBroadcastOffline.Invoke(CrossDele_BroadOffline);
                }
                #endregion
            }
        }
예제 #20
0
        private void PingTarget(object dev)
        {
            try
            {
                string devName  = "";
                string tempName = "";
                Device device   = null;
                device = (Device)dev;
                string      ip      = "";
                Ping        p       = new Ping();
                PingOptions options = new PingOptions();
                string      data    = "TestData";
                byte[]      buffer  = Encoding.ASCII.GetBytes(data);
                int         timeout = 1000;
                PingReply   reply;
                DateTime    startTime = System.DateTime.Now;
                DateTime    lastTime  = System.DateTime.Now;
                TimeSpan    spanTime;
                CrossThreadOperationControl CrossThreadGetInfo = delegate()
                {
                    device.PingOK = 0;
                };
                CSAMForm.Invoke(CrossThreadGetInfo);

                if (device == null)
                {
                    return;
                }
                while (true)
                {
                    CrossThreadOperationControl CrossThreadGetName = delegate()
                    {
                    };
                    CSAMForm.Invoke(CrossThreadGetName);
                    ip = device.IpAddress;
                    options.DontFragment = true;
                    //if (IsDisposed || !this.IsHandleCreated) return;
                    reply = p.Send(ip, timeout, buffer, options);
                    if (reply.Status != IPStatus.Success)
                    {
                        if (device.PingOK == 0)
                        {
                            CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
                            {
                            };
                            CSAMForm.Invoke(CrossThreadInfoRefresh);
                        }
                        else if (device.PingOK == 3)
                        {
                            lastTime = System.DateTime.Now;
                            spanTime = lastTime - startTime;
                            if (spanTime.Seconds >= 10)
                            {
                                CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
                                {
                                };
                                CSAMForm.Invoke(CrossThreadInfoRefresh);
                                device.PingOK = 0;
                            }
                        }
                        else if (device.PingOK == 1 || device.PingOK == 2)
                        {
                            startTime     = System.DateTime.Now;
                            device.PingOK = 3;
                        }
                    }
                    else if (reply.Status == IPStatus.Success)
                    {
                        if (device.PingOK == 0 || device.PingOK == 3)
                        {
                            startTime     = System.DateTime.Now;
                            device.PingOK = 1;
                            CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
                            {
                            };
                            CSAMForm.Invoke(CrossThreadInfoRefresh);
                        }
                        else if (device.PingOK == 1)
                        {
                            lastTime = System.DateTime.Now;
                            spanTime = lastTime - startTime;
                            if (spanTime.Seconds >= 30)
                            {
                                CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
                                {
                                };
                                CSAMForm.Invoke(CrossThreadInfoRefresh);
                                device.PingOK = 2;
                            }
                        }
                        else if (device.PingOK == 2)
                        {
                            CrossThreadOperationControl CrossThreadInfoRefresh = delegate()
                            {
                            };
                            CSAMForm.Invoke(CrossThreadInfoRefresh);
                        }
                    }
                    Thread.Sleep(CellSearchAndMonitorUnions.PingTime);
                }
            }
            catch { }
        }