Example #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();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            IPump            myPump            = new Pump();
            ITightner        myTightner        = new Tightner();
            ICompressionCtrl myCompressionCtrl = new LaceCompressionCtrl(myTightner);

            INotificationDevice myGreenLed     = new LedGreen();
            INotificationDevice myReDevice     = new LedRed();
            INotificationDevice myVibrator     = new Vibrator();
            INotification       myNotification = new Notification(myGreenLed, myReDevice, myVibrator);

            IButtonHandler           myStockingCtrl = new StockingCtrl(myCompressionCtrl, myNotification);
            ICompressionEventHandler myEventHandler = new StockingCtrl(myCompressionCtrl, myNotification);

            myCompressionCtrl.AddNotificationCenter(myEventHandler);

            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)
                {
                    myStockingCtrl.StartButtonPushed();
                }

                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    myStockingCtrl.StopButtonPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }