Beispiel #1
0
        static void Main(string[] args)
        {
            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Select compression mechanism");
            Console.WriteLine("1:   Pump");
            Console.WriteLine("2:   Lace");
            Console.WriteLine("ESC: Terminate application");

            ICompressionCtrl compressionControl = null;

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.D1)
                {
                    Pump pump = new Pump();
                    compressionControl = new PumpCompressionCtrl(pump);
                }
                if (consoleKeyInfo.Key == ConsoleKey.D2)
                {
                    Lace lace = new Lace();
                    compressionControl = new LaceCompressionCtrl(lace);
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape &&
                     consoleKeyInfo.Key != ConsoleKey.D1 &&
                     consoleKeyInfo.Key != ConsoleKey.D2);

            if (consoleKeyInfo.Key != ConsoleKey.Escape)
            {
                SimulatedPressureSensor pressureSensor     = new SimulatedPressureSensor(PRESSURE_WHEN_RELAXED);
                StockingController      stockingController = new StockingController(compressionControl, pressureSensor, PRESSURE_WHEN_COMPRESSED, PRESSURE_WHEN_RELAXED);
                ConsoleInput            consoleInput       = new ConsoleInput(pressureSensor);

                StockingInputHandler stockingInputHandler = new StockingInputHandler(stockingController);
                consoleInput.SetInputHandler(stockingInputHandler);

                CompressionProgressIndicator compressionProgressIndicator = new CompressionProgressIndicator();
                compressionProgressIndicator.AddCompressionRunningIndicator(new LED("Green"));
                compressionProgressIndicator.AddDecompressionRunningIndicator(new LED("Red"));
                VibratingDevice vibratingDevice = new VibratingDevice();
                compressionProgressIndicator.AddCompressionRunningIndicator(vibratingDevice);
                compressionProgressIndicator.AddDecompressionRunningIndicator(vibratingDevice);

                stockingController.SetCompressionProgressListener(compressionProgressIndicator);

                consoleInput.WaitForUserInput();
            }
        }
        static void Main(string[] args)
        {
            IPump  Pump_      = new Pump();
            ITimer Timer_     = new Timer();
            IPump  Pump_Lace  = new Lace();
            ITimer Timer_lace = new LaceTimer();

            IFeatures GreenLED = new LED("Green");
            IFeatures RedLED   = new LED("Red");
            IFeatures VDevice  = new VibratingDevice();

            var compressionStockingstocking      = new StockingCtrl(new CompressionCtrl(Pump_, Timer_, GreenLED, RedLED, VDevice));
            var compressionStockingstocking_Lace = new StockingCtrl(new CompressionCtrl(Pump_Lace, Timer_lace, GreenLED, RedLED, VDevice));

            ConsoleKeyInfo consoleKeyInfo;



            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("P:   Pump");
            Console.WriteLine("L:   Lace");
            Console.WriteLine("ESC: Terminate application");

            StockingCtrl Pumpy = compressionStockingstocking;

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.P)
                {
                    Pumpy = compressionStockingstocking;
                }
                if (consoleKeyInfo.Key == ConsoleKey.L)
                {
                    Pumpy = compressionStockingstocking_Lace;
                }
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    Pumpy.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    Pumpy.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }