private List<AirConditioner> Filter(List<ObjectId> selBls)
 {
     List<AirConditioner> airConds = new List<AirConditioner>();
     foreach (var idBlRef in selBls)
     {
         using (var blRef = idBlRef.Open( OpenMode.ForRead, false, true)as BlockReference)
         {
             var blName = blRef.GetEffectiveName();
             if (blName.Equals("АР_Корзина_Кондиционера", StringComparison.OrdinalIgnoreCase) )
             {
                 var airCond = new AirConditioner(blRef);
                 airConds.Add(airCond);
                 if (!string.IsNullOrEmpty(airCond.Error))
                 {
                     Inspector.AddError($"Ошибки в блоке кондиционера - {airCond.Error}", blRef, System.Drawing.SystemIcons.Warning);
                 }
             }
         }
     }
     if (airConds.Count==0)
     {
         throw new Exception("Не найдены блоки кондиционеров 'АР_Корзина_Кондиционера'");
     }
     return airConds;
 }
Пример #2
0
        private static void TuneCar(Car car)
        {
            ITuning air = new AirConditioner(car);

            air.AddTuning();
            ITuning alarm = new AlarmSystem(car);

            alarm.AddTuning();
            ITuning park = new Parctronic(car);

            park.AddTuning();
        }
Пример #3
0
 public ShoppingCart FillCartWithAirConditioner(string airConditionerId, AirConditioner airConditioner,
                                                User currentUser, string userId, decimal?newPriceAirConditioner)
 {
     return(new ShoppingCart
     {
         AirConditionerId = airConditionerId,
         AirConditioner = airConditioner,
         User = currentUser,
         UserId = userId,
         TotalPrice = newPriceAirConditioner,
     });
 }
        static void Main(string[] args)
        {
            AirConditioner
            .InitializeFactories()
            .ExecuteCreation(Actions.Warming, 22.5)
            .Operate();

            AirConditioner
            .InitializeFactories()
            .ExecuteCreation(Actions.Cooling, 5.0)
            .Operate();
        }
        private AirConditionerDto GenerateAirCondDtoFromModel(AirConditioner airConditioner)
        {
            var propertyInfos = airConditioner.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(prop => prop.IsDefined(typeof(OrderAttribute)));

            propertyInfos = propertyInfos.OrderBy(info => info.GetCustomAttribute <OrderAttribute>().Order);
            object[]          props      = propertyInfos.Select(info => info.GetValue(airConditioner)).ToArray();
            Type              airConType = Type.GetType("ACTester.ViewModels." + airConditioner.GetType().Name + "Dto");
            ConstructorInfo   ctorInfo   = airConType.GetConstructors(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault();
            AirConditionerDto air        = (AirConditionerDto)ctorInfo.Invoke(props);

            return(air);
        }
        /// <summary>
        /// Searches for an air conditioner by model and manufacturer.
        /// </summary>
        /// <param name="model">The model of the searched air conditioner.</param>
        /// <param name="manufacturer">The manufacturer name of the searched air conditioner.</param>
        /// <returns>Returns information about the found air conditioner, otherwise throws an exception.</returns>
        /// <exception cref="NonExistantEntryException"></exception>
        private string FindAirConditioner(string model, string manufacturer)
        {
            AirConditioner airConditioner = this.airConditionalTesterSystemEngine.Database.GetAirConditioner(manufacturer, model);

            if (airConditioner == null)
            {
                throw new NonExistantEntryException(Constants.NonExistingEntryMessage);
            }

            string message = airConditioner.ToString();

            return(message);
        }
        private void comboBoxACMODE_DropDownClosed(object sender, object e)
        {
            if (comboBoxACMode.SelectedItem != null)
            {
                String acmodestr = comboBoxACMode.SelectedItem as String;

                //textBlock1.Text = acmodestr;
                BitmapImage bmp       = new BitmapImage();
                String      ACmodeStr = comboBoxACMode.SelectedItem as String;
                String      picstr;

                if (ACmodeStr == COOL)
                {
                    picstr = "ac_mode_cool.png";
                    Task.Factory.StartNew(() =>
                    {
                        AirConditioner.setACMode(AirConditioner.AC_MODE.COLD);
                    });
                }
                else if (ACmodeStr == WARM)
                {
                    picstr = "ac_mode_hot.png";
                    Task.Factory.StartNew(() =>
                    {
                        AirConditioner.setACMode(AirConditioner.AC_MODE.WARM);
                    });
                }
                else if (ACmodeStr == VENTILATE)
                {
                    picstr = "ac_mode_ventilate.png";
                    Task.Factory.StartNew(() =>
                    {
                        AirConditioner.setACMode(AirConditioner.AC_MODE.VENTILATION);
                    });
                }
                else
                {
                    picstr = "ac_mode_dehydrate.png";
                    Task.Factory.StartNew(() =>
                    {
                        AirConditioner.setACMode(AirConditioner.AC_MODE.DEHYDRATION);
                    });
                }

                bmp.UriSource      = new Uri("ms-appx:///Assets/" + picstr, UriKind.RelativeOrAbsolute);
                Img_ACMode.Source  = bmp;
                Img_ACMode.Stretch = Stretch.Fill;

                changeACONOFFIMAGE(true);
            }
        }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.AddOrGet <LoopingSounds>();
        AirConditioner airConditioner = go.AddOrGet <AirConditioner>();

        airConditioner.temperatureDelta    = -14f;
        airConditioner.maxEnvironmentDelta = -50f;
        Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);

        storage.showInUI = true;
        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType     = ConduitType.Gas;
        conduitConsumer.consumptionRate = 1f;
    }
 public void ThreadProcUpDownAC(bool isReadyDown)
 {
     if (isReadyDown == true)
     {
         AirConditioner.downTemperature();
     }
     else
     {
         AirConditioner.upTemperature();
     }
     context.Post((s) =>
     {
         //可以在此访问UI线程中的对象,因为代理本身是在UI线程的上下文中执行的
         atmosphereData.SetTemperature = AirConditioner.temperature.ToString();
     }, null);
 }
Пример #10
0
        public string FindAllReportsByManufacturer(string manufacturer)
        {
            IList <Report> reports = AirConditioner.GetReportsByManufacturer(manufacturer);

            if (reports.Count == 0)
            {
                return(Constants.NoReports);
            }

            reports = reports.OrderBy(x => x.Mark).ToList();
            StringBuilder reportsPrint = new StringBuilder();

            reportsPrint.AppendLine($"Reports from {manufacturer}:");
            reportsPrint.Append(string.Join(Environment.NewLine, reports));
            return(reportsPrint.ToString());
        }
Пример #11
0
        public static void Test()
        {
            ChinaFactory   factory = new HaierFactory();
            AirConditioner ac1     = factory.CreateAircondition();
            Fridge         f1      = factory.CreateFridge();

            Console.WriteLine(ac1.Name);
            Console.WriteLine(f1.Name);

            ChinaFactory   greeFactory = new GreeFactory();
            AirConditioner ac2         = greeFactory.CreateAircondition();
            Fridge         f2          = greeFactory.CreateFridge();

            Console.WriteLine(ac2.Name);
            Console.WriteLine(f2.Name);
        }
Пример #12
0
        public StationViewModel()
        {
            light  = new Light();
            blinds = new Blinds();
            air    = new AirConditioner();

            Modules = new List <ITurnOnOffModule>();
            Modules.Add(light);
            Modules.Add(blinds);
            Modules.Add(air);


            term    = new Termomethre();
            humi    = new HumiditySensor();
            ligsens = new LightSensor();
            disp    = new Display();
        }
        public string TestAirConditioner(string manufacturer, string model)
        {
            AirConditioner airConditioner = this.GetAirConditionerByManufacturerAndModel(manufacturer, model);
            //AirConditionerDTO airConditionerDTO = this.GetAirConditionerDTOFromModel(airConditioner);
            AirConditionerDTO airConditionerDTO = Mapper.Map <AirConditionerDTO>(airConditioner);

            var mark = airConditionerDTO.Test() ? Mark.Passed : Mark.Failed;

            this.Database.ReportRepo.Add(
                new Report()
            {
                Manufacturer = manufacturer,
                Model        = model,
                Mark         = mark
            });
            this.Database.Save();
            return(string.Format(Constants.TestAirConditioner, model, manufacturer));
        }
Пример #14
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.AddOrGet <LoopingSounds>();
        AirConditioner airConditioner = go.AddOrGet <AirConditioner>();

        airConditioner.temperatureDelta    = -14f;
        airConditioner.maxEnvironmentDelta = -50f;
        airConditioner.isLiquidConditioner = true;
        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType     = ConduitType.Liquid;
        conduitConsumer.consumptionRate = 10f;
        Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);

        storage.showInUI   = true;
        storage.capacityKg = 2f * conduitConsumer.consumptionRate;
        storage.SetDefaultStoredItemModifiers(StoredItemModifiers);
    }
 public bool InsertAirConditioner(AirConditioner ACobj)
 {
     try
     {
         DataContext.AirConditioners.Add(ACobj);
         int result = DataContext.SaveChanges();
     }
     catch (DbUpdateException ex)
     {
         dc.PCErrorLoggers.Add(new PCErrorLogger()
         {
             ErrorDate    = DateTime.Now,
             ErrorMessage = ex.Message,
             ErrorSource  = ex.Source
         });
         dc.SaveChanges();
         throw new DbUpdateException("Please enter valid Foreign keys");
     }
     catch (System.FormatException fe)
     {
         dc.PCErrorLoggers.Add(new PCErrorLogger()
         {
             ErrorDate    = DateTime.Now,
             ErrorMessage = fe.Message,
             ErrorSource  = fe.Source
         });
         dc.SaveChanges();
         throw new System.FormatException();
     }
     catch (Exception q)
     {
         dc.PCErrorLoggers.Add(new PCErrorLogger()
         {
             ErrorDate    = DateTime.Now,
             ErrorMessage = q.Message,
             ErrorSource  = q.Source
         });
         dc.SaveChanges();
         throw new Exception("Incorrect Format");
     }
     return(true);
 }
Пример #16
0
        /// <summary>
        /// 宏命令
        /// </summary>
        static void MacorCommand()
        {
            Console.WriteLine($"命令模式 -> 宏命令{Environment.NewLine}-------------------------------------------");

            Television     tv = new Television();                   //电视对象(命令接收者)
            AirConditioner ac = new AirConditioner();               //空调对象(命令接收者)

            TvOpenCommand tvOpenCommand = new TvOpenCommand(tv);    //电视开机命令
            AcOpenCommand acOpenCommand = new AcOpenCommand(ac);    //空调开机命令
            MacorCommand  macorCommand  = new MacorCommand();       //宏命令

            macorCommand.Commands.Add(tvOpenCommand);               //设置宏命令
            macorCommand.Commands.Add(acOpenCommand);               //设置宏命令

            Button button = new Button(macorCommand);               //创建宏按钮

            button.Click();                                         //执行命令

            Console.ReadKey();
        }
        public string TestAirConditioner(string manufacturer, string model)
        {
            AirConditioner    airConditioner = this.GetAirConditionerByManufacturerAndModel(manufacturer, model);
            AirConditionerDto air            = GenerateAirCondDtoFromModel(airConditioner);

            air.Model        = airConditioner.Model;
            air.Manufacturer = airConditioner.Manufacturer;

            var mark = air.Test() ? Mark.Passed : Mark.Failed;

            this.database.ReportsRepo.Add(new Report()
            {
                Manufacturer = manufacturer,
                Model        = model,
                Mark         = mark
            });

            this.database.Save();
            return(string.Format(Constants.TestAirConditioner, model, manufacturer));
        }
        /// <summary>
        /// Registers the stationary air conditioner with the parameters given.
        /// It adds the air conditioner to the enumeration of lists.
        /// </summary>
        /// <param name="manufacturer">Manufacturer name</param>
        /// <param name="model">Model name</param>
        /// <param name="energyEfficiencyRating">The Energy Efficiency Rating of the air conditioner.</param>
        /// <param name="powerUsage">The Power Usage of the air conditioner</param>
        /// <returns>Registered Air Conditioner with Manufacturer and Model names.</returns>
        public string RegisterStationaryAirConditioner(string manufacturer, string model, string energyEfficiencyRating, int powerUsage)
        {
            EnergyEfficiencyRating rating;

            try
            {
                rating = (EnergyEfficiencyRating)Enum.Parse(typeof(EnergyEfficiencyRating), energyEfficiencyRating);
            }
            catch (ArgumentException ex)
            {
                throw new ArgumentException(Constants.Incorrectrating, ex);
            }
            if (manufacturer.Length < Constants.ManufacturerMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Manufacturer", Constants.ManufacturerMinLength));
            }

            if (model.Length < Constants.ModelMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Model", Constants.ModelMinLength));
            }

            if (powerUsage <= 0)
            {
                throw new ArgumentException(string.Format(Constants.Nonpositive, "Power Usage"));
            }

            if (Controller.GetAirConditionersCount() != 0)
            {
                if (Controller.AirConditioners.Any(airCon => airCon.Manufacturer == manufacturer && airCon.Model == model))
                {
                    throw new DuplicateEntryException(Constants.Duplicate);
                }
            }

            AirConditioner airConditioner = new AirConditioner(manufacturer, model, rating, powerUsage);

            Controller.AirConditioners.Add(airConditioner);

            return(string.Format(Constants.Register, airConditioner.Model, airConditioner.Manufacturer));
        }
        public IActionResult Command([FromBody] AirConditioner airConditioner)
        {
            if (airConditioner == null)
            {
                return(BadRequest());
            }

            if (!db.AirConditioners.Any(x => x.Name == airConditioner.Name))
            {
                return(NotFound());
            }

            var resultAirConditioner = db.AirConditioners.FirstOrDefault(x => x.Name == airConditioner.Name);

            resultAirConditioner.Power       = airConditioner.Power;
            resultAirConditioner.Mode        = airConditioner.Mode;
            resultAirConditioner.Temperature = airConditioner.Temperature;

            db.Update(resultAirConditioner);
            db.SaveChanges();
            return(Ok(resultAirConditioner));
        }
 public bool DeleteAirConditioner(string pID)
 {
     try
     {
         AirConditioner oldAC = (from ac in DataContext.AirConditioners
                                 where ac.ProductID == pID
                                 select ac).First();
         DataContext.AirConditioners.Remove(oldAC);
         int result = DataContext.SaveChanges();
         if (result > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (DbUpdateException)
     {
         throw new DbUpdateException("Enter proper Primary key");
     }
 }
        public string TestAirConditioner(string manufacturer, string model)
        {
            if (Controller.GetReportsCount() != 0)
            {
                if (Controller.Reports.Any(rep => rep.Manufacturer == manufacturer && rep.Model == model))
                {
                    throw new DuplicateEntryException(Constants.Duplicate);
                }
            }

            if (Controller.GetAirConditionersCount() != 0)
            {
                if (Controller.AirConditioners.Any(airCon => airCon.Manufacturer == manufacturer && airCon.Model == model))
                {
                    AirConditioner airConditioner = Controller.GetAirConditioner(manufacturer, model);
                    var            mark           = airConditioner.Test();
                    Controller.Reports.Add(new Report(airConditioner.Manufacturer, airConditioner.Model, mark));
                    return(string.Format(Constants.Test, model, manufacturer));
                }
            }

            return(string.Format(Constants.Nonexist));
        }
Пример #22
0
        public void ACTester()
        {
            // Arrange
            ac = new AirConditioner();

            // Act
            bool   acOnInit     = ac.TurnedOn;
            float  tempInit     = ac.Temperature;
            string acInitString = ac.About();

            string acToggleOn  = ac.ToggleOn();
            string acOnAbout   = ac.About();
            string acToggleOff = ac.ToggleOn();

            ac.ToggleOn();

            string raiseTemp = ac.changeTemp(79f);
            string maxTemp   = ac.changeTemp(81f);
            string minTemp   = ac.changeTemp(59f);

            ac.ToggleOn();
            string failChangeTemp = ac.changeTemp(75f);

            // Assert
            Assert.AreEqual(false, acOnInit);
            Assert.AreEqual(78f, tempInit);
            Assert.AreEqual(ac.ToString() + " is currently off.", acInitString);

            Assert.AreEqual(ac.ToString() + " has been turned on!", acToggleOn);
            Assert.AreEqual(ac.ToString() + " is currently on, maintaining a temperature of " + 78 + " degrees.", acOnAbout);
            Assert.AreEqual(ac.ToString() + " has been turned off!", acToggleOff);

            Assert.AreEqual("Temperature changed to " + ac.Temperature + " degrees.", raiseTemp);
            Assert.AreEqual("Temperature changed to maximum: " + 80 + " degrees.", maxTemp);
            Assert.AreEqual("Temperature changed to mininum: " + 60 + " degrees.", minTemp);
            Assert.AreEqual(ac.ToString() + " is currently off. Cannot Change Temperature.", failChangeTemp);
        }
        public string RegisterPlaneAirConditioner(string manufacturer, string model, int volumeCoverage, int electricityUsed)
        {
            if (manufacturer.Length < Constants.ManufacturerMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Manufacturer", Constants.ManufacturerMinLength));
            }

            if (model.Length < Constants.ModelMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Model", Constants.ModelMinLength));
            }

            if (volumeCoverage <= 0)
            {
                throw new ArgumentException(string.Format(Constants.Nonpositive, "Volume Covered"));
            }

            if (electricityUsed <= 0)
            {
                throw new ArgumentException(string.Format(Constants.Nonpositive, "Electricity Used"));
            }

            if (Controller.GetAirConditionersCount() != 0)
            {
                if (Controller.AirConditioners.Any(airCon => airCon.Manufacturer == manufacturer && airCon.Model == model))
                {
                    throw new DuplicateEntryException(Constants.Duplicate);
                }
            }

            AirConditioner airConditioner = new AirConditioner(manufacturer, model, volumeCoverage, electricityUsed);

            Controller.AirConditioners.Add(airConditioner);

            return(string.Format(Constants.Register, airConditioner.Model, airConditioner.Manufacturer));
        }
Пример #24
0
        static void Main(string[] args)
        {
            Console.WriteLine("====== Alcohol Shop =====");
            Console.WriteLine();

            var pesho   = new Client("Pesho", "Petrov", 21);
            var gosho   = new Client("Gosho", "Goshov", 18);
            var mariika = new Client("Mariika", "Petrova", 25);
            var canko   = new Client("Canko", "Mitkov", 36);
            var mitko   = new Client("Mitko", "Mitkov", 52);
            var goshka  = new Client("Goshka", "Mitkova", 50);

            var firstClients = new List <Client>();

            firstClients.Add(pesho);
            firstClients.Add(gosho);
            firstClients.Add(mariika);

            var secondClients = new List <Client>();

            secondClients.Add(canko);
            secondClients.Add(mitko);
            secondClients.Add(goshka);

            var waitressPenka = new Waitress("Penka", "Penkova", 35);
            var waitressSuzi  = new Waitress("Suzi", "Avramova", 30);

            var waitresses = new List <Waitress>();

            waitresses.Add(waitressPenka);
            waitresses.Add(waitressSuzi);

            var table1 = new Table(3, firstClients, "Table 1");

            table1.Waitress = waitressPenka;
            Console.WriteLine($"Avanti's table 1 waitress is {table1.Waitress.FirstName}.");
            table1.GetClientsNames(table1.Name);
            Console.WriteLine();

            var table2 = new Table(3, secondClients, "Table 2");

            table2.Waitress = waitressSuzi;
            Console.WriteLine($"Avanti's table 2 waitress is {table2.Waitress.FirstName}.");
            table2.GetClientsNames(table2.Name);
            Console.WriteLine();

            var tables = new List <Table>();

            tables.Add(table1);
            tables.Add(table2);

            var fridgeSamsung = new Fridge("Fridge Samsung", 4, true);

            fridgeSamsung.PushButtonOn(fridgeSamsung.Name);
            fridgeSamsung.PushButtonOff(fridgeSamsung.Name);
            fridgeSamsung.PushButtonOn(fridgeSamsung.Name);
            fridgeSamsung.ChangeDegree(true, fridgeSamsung);
            Console.WriteLine();

            var alcoholShop = new AlcoholShop("Avanti", tables, waitresses, fridgeSamsung);
            var avantiLtd   = new Company("Avanti LTD");

            alcoholShop.Company = avantiLtd;
            Console.WriteLine("Alcohol shop company's name is " + alcoholShop.Company.Name + '.');
            Console.WriteLine();

            var adressAlcoholShop = new Address("Sofia", "Lincoln street");

            alcoholShop.Address = adressAlcoholShop;
            Console.WriteLine($"Alcohol shop's address is {alcoholShop.Address.City}, {alcoholShop.Address.Street}.");
            Console.WriteLine();

            var vodka   = new Alcohol("Vodka", 25);
            var whiskey = new Alcohol("Whiskey", 159);
            var beer    = new Alcohol("Beer", 2);
            var candy   = new Candy("Bonbon", 5);

            alcoholShop.AddGood(candy);
            alcoholShop.AddGood(vodka);
            alcoholShop.AddGood(whiskey);
            alcoholShop.AddGood(beer);

            Console.WriteLine($"In {alcoholShop.Name}'s income before ---> {alcoholShop.Income} lv. " +
                              $"Count: {alcoholShop.Goods.Count()}");

            alcoholShop.Sell(beer);

            Console.WriteLine($"In {alcoholShop.Name}'s income after ---> {alcoholShop.Income} lv. " +
                              $"Count: {alcoholShop.Goods.Count()}");
            Console.WriteLine();

            Console.WriteLine("====== Candy Shop =====");

            var sellerCandyShop = new Seller("Ani", "Petkova", 21);

            sellerCandyShop.Sallary = 750;

            var airConditionerDaikin = new AirConditioner("Air conditioner  Daikin", 23, false, "purple");

            var candyShop = new CandyShop(sellerCandyShop, airConditionerDaikin);

            Console.WriteLine();

            var candyLtd = new Company("Candy LTD");

            candyShop.Company = candyLtd;

            var addressCandyShop = new Address("Sofia", "Lublyana street");

            candyShop.Address = addressCandyShop;
            Console.WriteLine($"The address of {candyShop.Company.Name} is {candyShop.Address.City}, {candyShop.Address.Street}.");

            airConditionerDaikin.PushButtonOn(airConditionerDaikin.Name);
            airConditionerDaikin.PushButtonOff(airConditionerDaikin.Name);
            airConditionerDaikin.PushButtonOn(airConditionerDaikin.Name);
            airConditionerDaikin.ChangeDegree(false, airConditionerDaikin);
            Console.WriteLine();

            var chocolate      = new Candy("Chocolate", 1.8m);
            var candyBar       = new Candy("Candy bar", 1.5m);
            var sweet          = new Candy("Sweet", 2.5m);
            var expensiveSweet = new Candy("ExpensiveSweet", 25);

            candyShop.AddGood(chocolate);
            candyShop.AddGood(candy);
            candyShop.AddGood(candyBar);
            candyShop.AddGood(sweet);
            candyShop.AddGood(beer);
            candyShop.AddGood(expensiveSweet);

            Console.WriteLine($"In {candyShop.Company.Name}'s income before ---> {candyShop.Income} lv. " +
                              $"Count: {candyShop.Goods.Count()}");
            candyShop.Sell(chocolate);
            Console.WriteLine($"In {candyShop.Company.Name}'s income after ---> {candyShop.Income} lv. " +
                              $"Count: {candyShop.Goods.Count()}");
            Console.WriteLine();

            sellerCandyShop.GetBonus(candyShop);
            candyShop.Sell(expensiveSweet);
            sellerCandyShop.GetBonus(candyShop);
        }
Пример #25
0
 private static void TuneCar(Car car)
 {
     ITuning air = new AirConditioner(car);
     air.AddTuning();
     ITuning alarm = new AlarmSystem(car);
     alarm.AddTuning();
     ITuning park = new Parctronic(car);
     park.AddTuning();
 }
Пример #26
0
 internal static void RemoveAirConditioner(AirConditioner airConditioner)
 {
     AirConditioners.Remove(airConditioner);
 }
Пример #27
0
 internal static void AddAirConditioner(AirConditioner airConditioner)
 {
     AirConditioners.Add(airConditioner);
 }
        /// <summary>
        /// Registers the stationary air conditioner with the parameters given.
        /// It adds the air conditioner to the enumeration of lists.
        /// </summary>
        /// <param name="manufacturer">Manufacturer name</param>
        /// <param name="model">Model name</param>
        /// <param name="energyEfficiencyRating">The Energy Efficiency Rating of the air conditioner.</param>
        /// <param name="powerUsage">The Power Usage of the air conditioner</param>
        /// <returns>Registered Air Conditioner with Manufacturer and Model names.</returns>
        public string RegisterStationaryAirConditioner(string manufacturer, string model, string energyEfficiencyRating, int powerUsage)
        {
            EnergyEfficiencyRating rating;
            try
            {
                rating = (EnergyEfficiencyRating)Enum.Parse(typeof(EnergyEfficiencyRating), energyEfficiencyRating);
            }
            catch (ArgumentException ex)
            {
                throw new ArgumentException(Constants.Incorrectrating, ex);
            }
            if (manufacturer.Length < Constants.ManufacturerMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Manufacturer", Constants.ManufacturerMinLength));
            }

            if (model.Length < Constants.ModelMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Model", Constants.ModelMinLength));
            }

            if (powerUsage <= 0)
            {
                throw new ArgumentException(string.Format(Constants.Nonpositive, "Power Usage"));
            }

            if (Controller.GetAirConditionersCount() != 0)
            {
                if (Controller.AirConditioners.Any(airCon => airCon.Manufacturer == manufacturer && airCon.Model == model))
                {
                    throw new DuplicateEntryException(Constants.Duplicate);
                }
            }

            AirConditioner airConditioner = new AirConditioner(manufacturer, model, rating, powerUsage);
            Controller.AirConditioners.Add(airConditioner);

            return string.Format(Constants.Register, airConditioner.Model, airConditioner.Manufacturer);
        }
 public string RegisterStationaryAirConditioner(string manufacturer, string model, string energyEfficiencyRating, int powerUsage)
 {
     AirConditioner airConditioner = new AirConditioner(manufacturer, model, energyEfficiencyRating, powerUsage);
     MyStuff.AirConditioners.Add(airConditioner);
     throw new InvalidOperationException(string.Format(Constants.Register, airConditioner.Model, airConditioner.Manufacturer));
 }
Пример #30
0
        public async Task <IActionResult> Command(string version, string device)
        {
            AirConditionerCommand command;
            CancellationToken     cancellationToken = new CancellationToken();
            ActionResult          result;
            ContentResult         contentResult;
            string strCommandType;

            Logging.WriteDebugLog("DeviceController.Command() Client Start: {0}:{1}", HttpContext.Connection.RemoteIpAddress.ToString(), HttpContext.Connection.RemotePort.ToString());

            HttpContext.Response.Headers.Add("Access-Control-Allow-Headers", new Microsoft.Extensions.Primitives.StringValues("Accept, Content-Type, Authorization, Content-Length, X-Requested-With, X-Ninja-Token"));
            HttpContext.Response.Headers.Add("Access-Control-Allow-Methods", new Microsoft.Extensions.Primitives.StringValues("GET,PUT,POST,DELETE,OPTIONS"));
            HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", new Microsoft.Extensions.Primitives.StringValues("*"));

            AirConditioner.UpdateRequestTime();

            if (!await AirConditioner.EventCommand.WaitOneAsync(_iTimeout, cancellationToken))
            {
                return(new EmptyResult());
            }

            command = AirConditioner.GetCommand(out strCommandType);

            if (strCommandType != "4" & strCommandType != "5")
            {
                result = new EmptyResult();
            }
            else
            {
                contentResult = new ContentResult();

                contentResult.ContentType = "application/json";
                contentResult.StatusCode  = 200;

                if (strCommandType == "4")
                {
                    contentResult.Content = string.Format("{{\"DEVICE\":[{{\"G\":\"0\",\"V\":2,\"D\":4,\"DA\":{{\"amOn\":{0},\"tempTarget\":{1},\"fanSpeed\":{2},\"mode\":{3}}}}}]}}",
                                                          command.amOn ? "true" : "false",
                                                          command.tempTarget.ToString("F1"),
                                                          command.fanSpeed.ToString(),
                                                          command.mode.ToString()
                                                          );

                    Logging.WriteDebugLog("DeviceController.Command() Command: {0}", contentResult.Content);
                }
                else if (strCommandType == "5")
                {
                    contentResult.Content = string.Format("{{\"DEVICE\":[{{\"G\":\"0\",\"V\":2,\"D\":5,\"DA\":{{\"enabledZones\":[{0}]}}}}]}}",
                                                          command.enabledZones
                                                          );

                    Logging.WriteDebugLog("DeviceController.Command() Command: {0}", contentResult.Content);
                }

                result = contentResult;
            }

            Logging.WriteDebugLog("DeviceController.Command() Client End: {0}:{1}", HttpContext.Connection.RemoteIpAddress.ToString(), HttpContext.Connection.RemotePort.ToString());

            return(result);
        }
 internal static void RemoveAirConditioner(AirConditioner airConditioner)
 {
     AirConditioners.Remove(airConditioner);
 }
 internal static void AddAirConditioner(AirConditioner airConditioner)
 {
     AirConditioners.Add(airConditioner);
 }
 public AirConditionerOff(AirConditioner ac)
 {
     this.ac = ac;
 }
        public void RegisterStationaryAirConditioner(string manufacturer, string model, string energyEfficiencyRating, int powerUsage)
        {
            if (energyEfficiencyRating != "A" && energyEfficiencyRating != "B" && energyEfficiencyRating != "C"
                && energyEfficiencyRating != "D" && energyEfficiencyRating != "E")
            {
                throw new ArgumentException("Energy efficiency rating must be between \"A\" and \"E\".");
            }

            if (powerUsage <= 0)
            {
                throw new ArgumentException("Power Usage must be a positive integer.");
            }

            CheckIfModelAlreadyExists(manufacturer, model);

            AirConditioner airConditioner = new AirConditioner(manufacturer, model, energyEfficiencyRating, powerUsage);
            Data.AirConditioners.Add(airConditioner);
            this.writer.Print(
                string.Format(
                    "Air Conditioner model {0} from {1} registered successfully.",
                    airConditioner.Model,
                    airConditioner.Manufacturer));
        }
        public string RegisterPlaneAirConditioner(string manufacturer, string model, int volumeCoverage, int electricityUsed)
        {
            if (manufacturer.Length < Constants.ManufacturerMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Manufacturer", Constants.ManufacturerMinLength));
            }

            if (model.Length < Constants.ModelMinLength)
            {
                throw new ArgumentException(string.Format(Constants.IncorrectPropertyLength, "Model", Constants.ModelMinLength));
            }

            if (volumeCoverage <= 0)
            {
                throw new ArgumentException(string.Format(Constants.Nonpositive, "Volume Covered"));
            }

            if (electricityUsed <= 0)
            {
                throw new ArgumentException(string.Format(Constants.Nonpositive, "Electricity Used"));
            }

            if (Controller.GetAirConditionersCount() != 0)
            {
                if (Controller.AirConditioners.Any(airCon => airCon.Manufacturer == manufacturer && airCon.Model == model))
                {
                    throw new DuplicateEntryException(Constants.Duplicate);
                }
            }

            AirConditioner airConditioner = new AirConditioner(manufacturer, model, volumeCoverage, electricityUsed);
            Controller.AirConditioners.Add(airConditioner);

            return string.Format(Constants.Register, airConditioner.Model, airConditioner.Manufacturer);
        }
        /// <summary>
        /// Registering a new plane air conditioner
        /// </summary>
        /// <param name="manufacturer"> The name of the manufacture.</param>
        /// <param name="model"> The model of the air conditioner.</param>
        /// <param name="volumeCoverage"> Volume coverage of the air conditioner.</param>
        /// <param name="electricityUsed"> Electricity used of the air conditioner.</param>
        /// <returns>
        /// If success execution it returns a string with the manufacture and model name
        /// </returns>
        /// <seealso cref="ArgumentException(string)">
        /// Notice that the method return ArgumentException if the volume coverage or electricity used is less then 1
        /// </seealso>
        public void RegisterPlaneAirConditioner(string manufacturer, string model, int volumeCoverage, string electricityUsed)
        {
            if (volumeCoverage <= 0)
            {
                throw new ArgumentException("Volume Covered must be a positive integer.");
            }
            if (Convert.ToInt32(electricityUsed) <= 0)
            {
                throw new ArgumentException("Electricity Used must be a positive integer.");
            }
            CheckIfModelAlreadyExists(manufacturer, model);

            AirConditioner airConditioner = new AirConditioner(manufacturer, model, volumeCoverage, electricityUsed);
            Data.AirConditioners.Add(airConditioner);
            this.writer.Print(string.Format("Air Conditioner model {0} from {1} registered successfully.", airConditioner.Model, airConditioner.Manufacturer));
        }
Пример #37
0
 public static void AddAirConditioner(AirConditioner airConditioner)
 {
     AirConditioners.Add(airConditioner);
 }
 public AirConditionerOn(AirConditioner ac)
 {
     this.ac = ac;
 }
Пример #39
0
 public static void RemoveAirConditioner(AirConditioner airConditioner)
 {
     AirConditioners.Remove(airConditioner);
 }
Пример #40
0
        public IActionResult Data(string version, string device)
        {
            AirConditionerData          data = new AirConditionerData();
            AirConditionerDataHeader    header;
            AirConditionerDataHeader6   header6;
            Dictionary <string, object> dDataField;
            DataResponse response = new DataResponse();
            StreamReader reader;
            string       strData;

            Newtonsoft.Json.Linq.JArray aZones, aZoneTemperatures;

            Logging.WriteDebugLog("DeviceController.Data() Client: {0}:{1}", HttpContext.Connection.RemoteIpAddress.ToString(), HttpContext.Connection.RemotePort.ToString());

            HttpContext.Response.Headers.Add("Access-Control-Allow-Headers", new Microsoft.Extensions.Primitives.StringValues("Accept, Content-Type, Authorization, Content-Length, X-Requested-With, X-Ninja-Token"));
            HttpContext.Response.Headers.Add("Access-Control-Allow-Methods", new Microsoft.Extensions.Primitives.StringValues("GET,PUT,POST,DELETE,OPTIONS"));
            HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", new Microsoft.Extensions.Primitives.StringValues("*"));

            reader  = new StreamReader(HttpContext.Request.Body);
            strData = reader.ReadToEnd();
            reader.Dispose();

            try
            {
                header = JsonConvert.DeserializeObject <AirConditionerDataHeader>(strData);
                switch (header.D)
                {
                case 6:
                    Logging.WriteDebugLog("DeviceController.Data() Data: {0}", strData);

                    header6 = JsonConvert.DeserializeObject <AirConditionerDataHeader6>(strData);

                    dDataField = header6.DA;

                    data.iCompressorActivity = int.Parse(dDataField["compressorActivity"].ToString());
                    data.strErrorCode        = dDataField["errorCode"].ToString();
                    data.iFanContinuous      = int.Parse(dDataField["fanIsCont"].ToString());
                    data.iFanSpeed           = int.Parse(dDataField["fanSpeed"].ToString());
                    data.bOn                = bool.Parse(dDataField["isOn"].ToString());
                    data.bESPOn             = bool.Parse(dDataField["isInESP_Mode"].ToString());
                    data.iMode              = int.Parse(dDataField["mode"].ToString());
                    data.dblRoomTemperature = double.Parse(dDataField["roomTemp_oC"].ToString());
                    data.dblSetTemperature  = double.Parse(dDataField["setPoint"].ToString());

                    aZones      = (Newtonsoft.Json.Linq.JArray)dDataField["enabledZones"];
                    data.bZone1 = (aZones[0].ToString() == "1");
                    data.bZone2 = (aZones[1].ToString() == "1");
                    data.bZone3 = (aZones[2].ToString() == "1");
                    data.bZone4 = (aZones[3].ToString() == "1");
                    data.bZone5 = (aZones[4].ToString() == "1");
                    data.bZone6 = (aZones[5].ToString() == "1");
                    data.bZone7 = (aZones[6].ToString() == "1");
                    data.bZone8 = (aZones[7].ToString() == "1");

                    aZoneTemperatures = (Newtonsoft.Json.Linq.JArray)dDataField["individualZoneTemperatures_oC"];
                    if (aZones[0].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[0].ToString(), out data.dblZone1Temperature);
                    }
                    if (aZones[1].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[1].ToString(), out data.dblZone2Temperature);
                    }
                    if (aZones[2].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[2].ToString(), out data.dblZone3Temperature);
                    }
                    if (aZones[3].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[3].ToString(), out data.dblZone4Temperature);
                    }
                    if (aZones[4].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[4].ToString(), out data.dblZone5Temperature);
                    }
                    if (aZones[5].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[5].ToString(), out data.dblZone6Temperature);
                    }
                    if (aZones[6].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[6].ToString(), out data.dblZone7Temperature);
                    }
                    if (aZones[7].ToString() != "null")
                    {
                        double.TryParse(aZoneTemperatures[7].ToString(), out data.dblZone8Temperature);
                    }

                    AirConditioner.PostData(data);

                    break;
                }
            }
            catch (Exception eException)
            {
                Logging.WriteDebugLogError("DeviceController.Data()", eException, "Unable to parse air conditioner data.");
            }

            response.result = 1;
            response.error  = null;
            response.id     = 0;

            if (Service.ForwardToOriginalWebService)
            {
                ForwardDataToOriginalWebService(strData);
            }

            return(new ObjectResult(response));
        }
Пример #41
0
 public IActionResult AirConditioner(AirConditioner model) => Save(model);
Пример #42
0
 public static void TuneAir(Car car)
 {
     ITuning air = new AirConditioner(car);
     air.AddTuning();
 }
 /// <summary>
 /// Registers a new air conditioner with the specified manufacturer, model, volume covered and electricity used.
 /// </summary>
 /// <param name="manufacturer"></param>
 /// <param name="model"></param>
 /// <param name="volumeCoverage"></param>
 /// <param name="electricityUsed"></param>
 /// <returns></returns>
 public string RegisterPlaneAirConditioner(string manufacturer, string model, int volumeCoverage, string electricityUsed)
 {
     AirConditioner airConditioner = new AirConditioner(manufacturer, model, volumeCoverage, electricityUsed);
     MyStuff.AirConditioners.Add(airConditioner);
     throw new InvalidOperationException(
         string.Format(Constants.Test, airConditioner.Model, airConditioner.Manufacturer));
 }
Пример #44
0
 public AirConOff(AirConditioner airConditioner)
 {
     this.AirConditioner = airConditioner;
 }
 public string RegisterCarAirConditioner(string model, string manufacturer, int volumeCoverage)
 {
     AirConditioner airConditioner = new AirConditioner(manufacturer, model, volumeCoverage);
     MyStuff.AirConditioners.Add(airConditioner);
     throw new InvalidOperationException(
         string.Format(Constants.Register, airConditioner.Model, airConditioner.Manufacturer));
 }