Ejemplo n.º 1
0
        private void EventThreadProc()
        {
            while (!StoppingThread)
            {
                BadgeEvent.WaitOne();
                if (CancelOps)
                {
                    return;
                }
                Clock.Stop();

                WaitDoor = true;
                OpenDoor();
                Clock.Start();
                CptDoor = 10;
                DoorEventNormal.Reset();

                if (DoorEventNormal.WaitOne(10000, false))
                {
                    continue;                                        // next loop iteration
                }
                WaitDoor     = false;
                WaitDoor     = false;
                DisplayBadge = false;
                CloseDoor();
                CurrenRfidReader.NotifyRelock();
                Clock.Start();
            }
            if (ThreadEvent != null)
            {
                ThreadEvent.Set();
            }
        }
        private void EventThreadProc()
        {
            while (!StoppingThread)
            {
                LogToFile.LogMessageToFile("------Wait Badge ------");
                badgeset = false;
                while (!badgeset)
                {
                    if (CancelOps)
                    {
                        return;
                    }
                    NonBlockingSleep(1000);
                }

                //BadgeEvent.WaitOne();
                // if (CancelOps) return;
                LogToFile.LogMessageToFile("Event Badge received in thread");
                Clock.Stop();
                WaitDoor = true;
                StopScan();
                LogToFile.LogMessageToFile("Unlock door  in thread");
                OpenDoor();
                Clock.Start();
                CptDoor = 10;
                DoorEventNormal.Reset();
                LogToFile.LogMessageToFile("------Wait Door Close ------");
                if (DoorEventNormal.WaitOne(10000, false))
                {
                    LogToFile.LogMessageToFile("------Door Close event ----");
                    CloseDoor();
                    continue; // next loop iteration as the process will continue to classic door event
                }
                else
                {
                    LogToFile.LogMessageToFile("------Door Close timeout  ----");
                }
                if (LedThread != null)
                {
                    LedThread.Abort();
                    LedThread.Join(1000);
                    LedThread = null;
                }

                Thread.Sleep(500);

                WaitDoor     = false;
                DisplayBadge = false;
                //if ((CurrenRfidReader != null) && (CurrenRfidReader.IsConnected)) CurrenRfidReader.SetLightPower(300);
                CloseDoor();
                if (CurrenRfidReader != null)
                {
                    CurrenRfidReader.NotifyRelock();
                }

                Clock.Start();
            }
            if (ThreadEvent != null)
            {
                ThreadEvent.Set();
            }
        }