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();
            }
        }
Ejemplo n.º 2
0
        protected override void myDevice_NotifyEvent(object sender, rfidReaderArgs args)
        {
            switch (args.RN_Value)
            {
            case rfidReaderArgs.ReaderNotify.RN_ScanStarted:
                //_listTagWithChannel = new Hashtable();
                _channelInScan = 1;
                Clock.Stop();
                break;

            case rfidReaderArgs.ReaderNotify.RN_ReaderFailToStartScan:
            case rfidReaderArgs.ReaderNotify.RN_ReaderScanTimeout:
                break;

            case rfidReaderArgs.ReaderNotify.RN_ScanCompleted:
            case rfidReaderArgs.ReaderNotify.RN_ErrorDuringScan:
                Thread.Sleep(2000);
                Clock.Start();
                break;

            case rfidReaderArgs.ReaderNotify.RN_Door_Closed:
                if (DoorEventNormal != null)
                {
                    DoorEventNormal.Set();
                }
                break;

            case rfidReaderArgs.ReaderNotify.RN_Door_Opened:
                Thread.Sleep(500);
                CloseDoor();
                break;

            case rfidReaderArgs.ReaderNotify.RN_ActiveChannnelChange:
                byte.TryParse(args.Message, out _channelInScan);
                break;

            case rfidReaderArgs.ReaderNotify.RN_TagAdded:
                //if (!_listTagWithChannel.ContainsKey(args.Message))
                //   _listTagWithChannel.Add(args.Message, _channelInScan);
                break;
            }
        }
        protected override void myDevice_NotifyEvent(object sender, rfidReaderArgs args)
        {
            switch (args.RN_Value)
            {
            case rfidReaderArgs.ReaderNotify.RN_ScanStarted:
                bDoorJustClosed = false;
                _channelInScan  = 1;
                // _listTagWithChannel = new Hashtable();
                // Clock.Stop();
                WriteLCDLine(1, " - IDENTIFICATION - ");
                WriteLCDLine(2, " ");
                break;

            case rfidReaderArgs.ReaderNotify.RN_ReaderFailToStartScan:
            case rfidReaderArgs.ReaderNotify.RN_ReaderScanTimeout:
                WriteLCDLine(1, " - IDENTIFICATION - ");
                WriteLCDLine(2, " ID failure ");
                break;

            case rfidReaderArgs.ReaderNotify.RN_ScanCompleted:
            case rfidReaderArgs.ReaderNotify.RN_ErrorDuringScan:
                string tmp = string.Format(" {0:D3} TAG(S) SCANNED", CurrenRfidReader.ReaderData.nbTagScan);
                WriteLCDLine(1, " - IDENTIFICATION - ");
                WriteLCDLine(2, tmp);

                Thread.Sleep(2000);
                Clock.Start();
                ClearLCD();
                break;

            case rfidReaderArgs.ReaderNotify.RN_Door_Closed:
                LogToFile.LogMessageToFile("door Close Medical cabinet");
                if (DoorEventNormal != null)
                {
                    DoorEventNormal.Set();
                }
                break;

            case rfidReaderArgs.ReaderNotify.RN_Door_Opened:

                LogToFile.LogMessageToFile("door Open Medical cabinet");
                if (LedThread != null)
                {
                    LogToFile.LogMessageToFile("Thred led - stop it in medical");
                    LedThread.Abort();
                    LedThread.Join(1000);
                    LedThread = null;
                }
                Thread.Sleep(3000);
                //if ((CurrenRfidReader != null) && (CurrenRfidReader.IsConnected)) CurrenRfidReader.SetLightPower(300);
                LogToFile.LogMessageToFile("Close door in medical");
                CloseDoor();
                WriteLCDLine(1, "  - INFORMATION - ");
                WriteLCDLine(2, " WAIT DOOR CLOSING");
                bDoorJustClosed = true;
                break;

            case rfidReaderArgs.ReaderNotify.RN_ActiveChannnelChange:
                byte.TryParse(args.Message, out _channelInScan);
                break;

            case rfidReaderArgs.ReaderNotify.RN_TagAdded:
                // if (!_listTagWithChannel.ContainsKey(args.Message))
                //    _listTagWithChannel.Add(args.Message, _channelInScan);
                break;
            }
        }
        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();
            }
        }