Beispiel #1
0
        static void Main(string[] args)
        {
            // Assemble your system here from all the classes
            Door                door                = new Door();
            RfidReader          rfidReader          = new RfidReader();
            LogFile             logfile             = new LogFile();
            Display             display             = new Display();
            UsbChargerSimulator usbChargerSimulator = new UsbChargerSimulator();
            ChargeControl       chargeControl       = new ChargeControl(display, usbChargerSimulator);
            StationControl      stationControl      = new StationControl(door, display, chargeControl, logfile, rfidReader);


            bool finish = false;

            do
            {
                string input;
                System.Console.WriteLine("Indtast E, O, C, R: ");
                input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    continue;
                }

                switch (input[0])
                {
                case 'E':
                    finish = true;
                    break;

                case 'O':
                    door.OnDoorOpen();
                    break;

                case 'C':
                    door.OnDoorClose();
                    break;

                case 'R':
                    System.Console.WriteLine("Indtast RFID id: ");
                    string idString = System.Console.ReadLine();
                    try
                    {
                        int id = Convert.ToInt32(idString);
                        rfidReader.OnRfidRead(id);
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("Invalid Input, prøv igen!");
                    }
                    ;
                    break;

                default:
                    break;
                }
            } while (!finish);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //_stationControl = new StationControl(_door, _display, _rfidReader, _usbChargerSimulator);
            Door                _door          = new Door();
            Display             _display       = new Display();
            UsbChargerSimulator _charger       = new UsbChargerSimulator();
            RfidReader          _rfidReader    = new RfidReader();
            ChargeControl       _chargeControl = new ChargeControl(_charger, _display);

            StationControl _control = new StationControl(_door, _display, _rfidReader, _chargeControl);

            bool finish = false;

            do
            {
                string input;
                System.Console.WriteLine("Indtast E, O, C, R: ");
                input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    continue;
                }

                switch (input[0])
                {
                case 'E':
                    finish = true;
                    break;

                case 'O':
                    _door.OnDoorOpen();
                    break;

                case 'C':
                    _door.OnDoorClosed();
                    break;

                case 'R':
                    System.Console.WriteLine("Indtast RFID id: ");
                    string idString = System.Console.ReadLine();

                    int id = Convert.ToInt32(idString);
                    _rfidReader.onRfidRead(id);
                    break;

                default:
                    break;
                }
            } while (!finish);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            DoorSimulator       door       = new DoorSimulator();
            RFIDreaderSimulator rfidReader = new RFIDreaderSimulator();
            Display             display    = new Display(new ConsoleWriteLine());
            UsbChargerSimulator USBCharger = new UsbChargerSimulator();
            ChargeControl       CC         = new ChargeControl(USBCharger, display);
            LogFile             logfile    = new LogFile();

            StationControl SC = new StationControl(CC, door, display, logfile, rfidReader);

            bool finish = false;

            do
            {
                string input;
                System.Console.WriteLine("Indtast E, O, C, R: ");
                input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    continue;
                }

                switch (input[0])
                {
                case 'E':
                    finish = true;
                    break;

                case 'O':
                    door.OnDoorOpen();
                    break;

                case 'C':
                    door.OnDoorClose();
                    break;

                case 'R':
                    System.Console.WriteLine("Indtast RFID id: ");
                    string idString = System.Console.ReadLine();

                    int id = Convert.ToInt32(idString);
                    rfidReader.OnRfidRead(id);
                    break;

                default:
                    break;
                }
            } while (!finish);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            IDoor          door           = new FakeDoor();
            IUsbCharger    usbCharger     = new UsbChargerSimulator();
            IDisplay       display        = new Display();
            IChargeControl chargeControl  = new ChargeControl(usbCharger, display);
            IRfidReader    riRfidReader   = new FakeRfidReader();
            StreamWriter   SW             = new StreamWriter("LogFile.txt", true);
            ILogFile       logFile        = new LogFile(SW);
            StationControl stationControl = new StationControl(door, chargeControl, riRfidReader, display, logFile);
            bool           finish         = false;

            do
            {
                System.Console.WriteLine("\n                                    Indtast E(xit), O(pen), C(Lose), R(eadKey), P(honeConnect), D(isconnectPhone): ");
                var input = Console.ReadKey().Key;
                switch (input)
                {
                case ConsoleKey.E:
                    finish = true;
                    break;

                case ConsoleKey.O:
                    door.DoorOpen = true;
                    break;

                case ConsoleKey.C:
                    door.DoorOpen = false;
                    break;

                case ConsoleKey.R:
                    System.Console.WriteLine("\n                                    Indtast RFID id: ");
                    string idString = System.Console.ReadLine();

                    int id = Convert.ToInt32(idString);
                    riRfidReader.ScanRFID(id);
                    break;

                case ConsoleKey.P:
                    if (stationControl.DoorState == true)
                    {
                        chargeControl.IsConnected = true;
                    }
                    else
                    {
                        System.Console.WriteLine("\n                                    Lågen er lukket, åben lågen før du tilslutter telefon");
                    }
                    break;

                case ConsoleKey.D:
                    if (stationControl.DoorState == true)
                    {
                        chargeControl.IsConnected = false;
                    }
                    else
                    {
                        System.Console.WriteLine("\n                                    Lågen er lukket, åben lågen før du frakobler telefon");
                    }
                    break;

                default:
                    break;
                }
            } while (!finish);
        }