static void Main(string[] args)
        {
            IStocking        stocking                    = new Stocking();
            ICompressionCtrl compressionCtrl             = new PumpCompressionCtrl(stocking);
            IBtnHandler      compressionStockingstocking = new StockingCtrl(compressionCtrl);
            ConsoleKeyInfo   consoleKeyInfo;

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

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionStockingstocking.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionStockingstocking.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
Esempio n. 2
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();
            }
        }