Exemplo n.º 1
0
        private void reconnect()
        {
            Thread.Sleep(20000);   //检测线程启动延时
            while (!form1.IsClose)
            {
                for (int i = 0; i < form1.Xtreaderlist.Count; i++)  //  XReaderInitList是所有已注册的reader
                {
                    XtiveReaderInitClass CurInitR = form1.Xtreaderlist[i];
                    RFIDInterface        CurR     = CurInitR.reader;

                    //Test
                    //bool flag = CurR.Check();
                    //System.Console.WriteLine(CurR.ip + " " + CurR.Check() + CurR.ReConnectCount);
                    //if (!CurR.Check() && CurR.ReConnectCount < CurInitR.errCountOfLoadTagData)
                    //if (!flag)

                    if (!CurR.Check())
                    {
                        if (CurR.ReConnectCount <= CurInitR.errCountOfLoadTagData || reconnectCntSet.Contains(CurR.ReConnectCount))
                        {
                            Thread tipThread = new Thread(new ParameterizedThreadStart(reconnectTips));
                            tipThread.IsBackground = true;
                            tipThread.Start(CurR);

                            CurR.ReConnect(CurR.ip);
                        }
                        else if (!(bool)AlertState[CurR.ip])
                        {
                            Thread connectThread = new Thread(new ParameterizedThreadStart(reconnectWait));
                            connectThread.IsBackground = true;
                            //connectThread.Priority = ThreadPriority.Lowest;
                            connectThread.Start(CurR);

                            CurR.ReConnectCount++;
                        }
                        else
                        {
                            CurR.ReConnectCount++;
                        }
                    }
                }
                Thread.Sleep(15000); //检测频率15s
            }
        }
Exemplo n.º 2
0
        private void reconnectWait(object obj)
        {  /*
            * 弹出对话框,提示用户读写器断线,并等待用户响应,重连或返回  2014.2.24
            */
            RFIDInterface rfidreader = obj as RFIDInterface;

            AlertState[rfidreader.ip] = true;

            MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            DialogResult      dr         = MessageBox.Show(rfidreader.ip + "掉线或断电,请重新连接或上电重启,完成后按\"确定\"按钮重连", "断线重连", messButton);

            log.Info(rfidreader.ip + "掉线或断电");
            //System.Console.WriteLine("Wait");
            if (dr == DialogResult.OK)
            {
                rfidreader.ReConnect(rfidreader.ip);
            }
            //System.Console.WriteLine("Reconnect");

            AlertState[rfidreader.ip] = false;
            rfidreader.ReConnectCount = 0;
        }