Пример #1
0
 /// <summary>
 /// This method initializes the different classes and data
 /// </summary>
 private void InitializesClassesData()
 {
     ServoMotor.GetInstance().Lock();
     RFIDReader.GetInstance();
     DisplayLoad();
     ListOfCards.GetInstance().CardsList = SDCard.GetInstance().LoadCards();
     if (ListOfCards.GetInstance().CardsList == null)
     {
         ListOfCards.GetInstance().CardsList = new ArrayList();
     }
     RestoreInitialState();
 }
Пример #2
0
        public static void Main()
        {
            Debug.Print(Resources.GetString(Resources.StringResources.String1));

            AnalogInput joystick_y = new AnalogInput(FEZSpider.Socket9.AnalogInput4); //Initialise l'axe Y par rapport à l'orientation de mon joystick

            _reader.IdReceived          += _reader_IdReceived;
            _reader.MalformedIdReceived += _reader_MalformedIdReceived;

            ListOfCards.GetInstance().AddCardToList("Badge", "U1 2D 34 56 FC");
            ListOfCards.GetInstance().AddCardToList("Badge", "U9 65 B2 3C F5");
            ListOfCards.GetInstance().AddCardToList("Badge", "U1 2D 34 56 FC");
            ListOfCards.GetInstance().AddCardToList("Badge", "U9 65 B2 3C F5");
            ListOfCards.GetInstance().AddCardToList("Badge", "U1 2D 34 56 FC");
            ListOfCards.GetInstance().AddCardToList("Badge", "U9 65 B2 3C F5");
            ListOfCards.GetInstance().AddCardToList("Marty", "U1 2D 34 56 FC");
            ListOfCards.GetInstance().AddCardToList("Professeur", "U9 65 B2 3C F5");

            //SDCardSerializer.GetInstance().SerializecCardsToSDCard(ListOfCards.GetInstance().CardsList);
            //SDCardSerializer.GetInstance().showDirectory();
            //RFIDReader.GetInstance();
            ServoMotor.GetInstance();

            while (true)
            {
                Debug.Print(joystick_y.Read().ToString());
                if (joystick_y.Read() == 1)
                {
                    ServoMotor.GetInstance().Unlock();
                }
                else if (joystick_y.Read() == 0)
                {
                    ServoMotor.GetInstance().Lock();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// When no menu is selected
        /// </summary>
        private void InitialState()
        {
            switch (_scanCardState)
            {
            case SCAN_CARD_STATE.waitRFID:
                if (RFIDReader.GetInstance().IsBadgeScan)
                {
                    _scanCardState = SCAN_CARD_STATE.RFIDDetected;
                }
                break;

            case SCAN_CARD_STATE.RFIDDetected:
                if (_servoState == SERVO_STATE.close)     // If the servo is lock
                {
                    bool isValid = ListOfCards.GetInstance().FindCardInlist(RFIDReader.GetInstance().CurrentUid);
                    if (isValid)
                    {
                        _scanCardState = SCAN_CARD_STATE.RFIDValid;
                    }
                    else
                    {
                        _scanCardState = SCAN_CARD_STATE.RFIDInvalid;
                    }
                }
                else
                {
                    _scanCardState = SCAN_CARD_STATE.RFIDInvalid;
                }
                break;

            case SCAN_CARD_STATE.RFIDValid:
                _servoState    = SERVO_STATE.open;
                _scanCardState = SCAN_CARD_STATE.waitRFID;
                DeleteCurrentBadgescan();
                break;

            case SCAN_CARD_STATE.RFIDInvalid:
                _servoState    = SERVO_STATE.close;
                _scanCardState = SCAN_CARD_STATE.waitRFID;
                DeleteCurrentBadgescan();
                break;

            default:
                _scanCardState = SCAN_CARD_STATE.waitRFID;
                break;
            }

            switch (_servoState)
            {
            case SERVO_STATE.open:
                ServoMotor.GetInstance().Unlock();
                _secuTimer.Start();
                break;

            case SERVO_STATE.close:
                ServoMotor.GetInstance().Lock();
                _secuTimer.Stop();
                break;

            default:
                _servoState = SERVO_STATE.close;
                break;
            }

            if (_joystickX.Read() > JOYSTICK_DOWN_LEFT) // If the joystick is down
            {
                _menu++;
                if (_menu > 4)
                {
                    _menu = 0;
                }
                DisplayMainMenu(_menu);                     // It is not removed from the test to prevent the lcd flashing
                Thread.Sleep(100);                          // Wait 0.1 second to prevent the menu from scrolling too fast
            }
            else if (_joystickX.Read() < JOYSTICK_UP_RIGHT) // The joystick is up
            {
                _menu--;
                if (_menu < 0)
                {
                    _menu = 4;
                }
                DisplayMainMenu(_menu); // It is not removed from the test to prevent the lcd flashing
                Thread.Sleep(100);      // Wait 0.1 second to prevent the menu from scrolling too fast
            }
        }