Пример #1
0
        // Eksempel på event handler for eventet "RFID Detected" fra tilstandsdiagrammet for klassen
        private void RfidDetectedHandler(object sender, RfidDetectedEventArgs arg)
        {
            switch (_state)
            {
            case LadeskabState.Available:
                // Check for ladeforbindelse
                if (_chargeControl.IsConnected())
                {
                    _door.LockDoor();
                    _chargeControl.StartCharge();
                    _oldId = arg.Id;

                    _log.logWrite(1, _oldId);
                    _display.CloseDoorMsg();

                    _state = LadeskabState.Locked;
                }
                else
                {
                    _display.CloseDoorErrorMsg();
                }

                break;

            case LadeskabState.DoorOpen:
                // Ignore
                break;

            case LadeskabState.Locked:
                // Check for correct ID
                if (arg.Id == _oldId)
                {
                    _chargeControl.StopCharge();
                    _door.UnlockDoor();

                    _log.logWrite(2, _oldId);
                    _display.UnlockDoorMsg();

                    _state = LadeskabState.Available;
                }
                else
                {
                    _display.UnlockDoorErrorMsg();
                }

                break;
            }
        }