Ejemplo n.º 1
0
        public void AddNewElement(UIElement uIElement)
        {
            uIElement.Id = _item_counter;
            UIElements.Add(uIElement);
            IDevice device = _deviceFactory.CreateDevice(uIElement.DeviceType, _item_counter);

            device.Position = uIElement.Position;
            switch (uIElement.DeviceType)
            {
            case DeviceType.Device:
                Device temp_device = (Device)device;
                switch (uIElement.Area)
                {
                case Area.AirTemperature:
                    temp_device.Command = _commandFactory.CreateAirTemperatureHeaterCommand();
                    break;

                case Area.WaterTemperature:
                    temp_device.Command = _commandFactory.CreateWaterTemperatureHeaterCommand();
                    break;

                case Area.Nutrient:
                    temp_device.Command = _commandFactory.CreateNutrientRegulatorCommand();
                    break;

                case Area.Acid:
                    temp_device.Command = _commandFactory.CreateAcidRegulatorCommand();
                    break;

                default:
                    throw new NotImplementedException();
                }
                Devices.Add(temp_device);
                break;

            case DeviceType.ActiveSensor:
                ActiveSensors.Add(device as ActiveSensor);
                break;

            case DeviceType.PasssiveSensor:
                PassiveSensors.Add(device as PassiveSensor);
                break;

            default:
                throw new NotImplementedException();
            }
            _item_counter++;
        }