Example #1
0
 // Her mangler de andre trigger handlere
 public void DoorOpened(object sender, DoorEventArgs e)
 {
     doorOpen = e.OpenDoor;
     if (doorOpen)
     {
         _state = ChargingCabinetState.DoorOpen;
         Console.WriteLine("Døren er åbnet");
         _display.ConnectPhone();
     }
 }
Example #2
0
 public void DoorClosed(object sender, DoorEventArgs e)
 {
     doorOpen = e.OpenDoor;
     if (!doorOpen)
     {
         _state = ChargingCabinetState.Available;
         Console.WriteLine("Døren er lukket");
         _display.ReadRFID();
     }
 }
Example #3
0
        // Eksempel på event handler for eventet "RFID Detected" fra tilstandsdiagrammet for klassen
        public void RfidDetected(object sender, RFIDEventArgs e)
        {
            switch (_state)
            {
            case ChargingCabinetState.Available:
                // Check for ladeforbindelse
                if (_chargeControl.IsConnected())
                {
                    _door.LockDoor();
                    _oldId = e.RFID;

                    _logfile.WriteToLogLocked(_oldId);

                    _display.ChargingCabinetTaken();
                    _state = ChargingCabinetState.Locked;
                    _chargeControl.StartCharge();
                }
                else
                {
                    _display.ConnectionFail();
                }

                break;

            case ChargingCabinetState.DoorOpen:
            {
                _display.CloseDoor();
            }
            break;

            case ChargingCabinetState.Locked:
                // Check for correct ID
                if (e.RFID == _oldId)
                {
                    _chargeControl.StopCharge();
                    _door.UnlockDoor();

                    _logfile.WriteToLogUnlocked(_oldId);

                    _display.RemovePhone();
                    _state = ChargingCabinetState.Available;
                }
                else
                {
                    _display.RFIDFail();
                }

                break;
            }
        }