Ejemplo n.º 1
0
        public void UpdateSensorValues(string[] rawValues)
        {
            if (rawValues == null || rawValues.Length == 0)
            {
                throw new Exception("Incomming data is incomplete");
            }

            Slider.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.SliderOrder]));
            LightSensor.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.LightSensorOrder]));
            Temperature.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.TemperatureOrder]));
            Microphone.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.MicrophoneOrder]));

            JoystickSwitch.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickSwitchOrder]));
            JoystickButton.UpdateValue(rawValues[SensorValuesOrderTable.JoystickButtonOrder] != "1");

            AccelerometerX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerXOrder]));
            AccelerometerY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerYOrder]));
            AccelerometerZ.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerZOrder]));

            ButtonDown.UpdateValue(rawValues[SensorValuesOrderTable.ButtonDownOrder] != "1");
            ButtonLeft.UpdateValue(rawValues[SensorValuesOrderTable.ButtonLeftOrder] != "1");
            ButtonUp.UpdateValue(rawValues[SensorValuesOrderTable.ButtonUpOrder] != "1");
            ButtonRight.UpdateValue(rawValues[SensorValuesOrderTable.ButtonRightOrder] != "1");

            JoystickX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickXOrder]));
            JoystickY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickYOrder]));

            LedRed.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedRedOrder]));
            LedGreen.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedGreenOrder]));
            LedBlue.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedBlueOrder]));
        }
Ejemplo n.º 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);
        }