public TemperatureView(ITemperatureController controller)
        {
            List <TemperatureScale> temperatureScales = new List <TemperatureScale>
            {
                new TemperatureScale {
                    Description = "Кельвины", Name = "Kelvin"
                },
                new TemperatureScale {
                    Description = "Фаренгейты", Name = "Fahrenheit"
                },
                new TemperatureScale {
                    Description = "Цельсии", Name = "Celsius"
                },
            };

            this.controller = controller;
            InitializeComponent();

            KeyPreview = true;

            temperatureScaleFrom.DataSource    = new List <TemperatureScale>(temperatureScales);
            temperatureScaleFrom.DisplayMember = "Description";
            temperatureScaleFrom.ValueMember   = "Name";
            temperatureScaleFrom.SelectedIndex = 2;

            temperatureScaleTo.DataSource    = new List <TemperatureScale>(temperatureScales);
            temperatureScaleTo.DisplayMember = "Description";
            temperatureScaleTo.ValueMember   = "Name";
            temperatureScaleTo.SelectedIndex = 0;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FuzzyLogicEntry" /> class.
        /// </summary>
        /// <param name="controller">The controller.</param>
        public FuzzyLogicEntry(ITemperatureController controller)
        {
            this.controller = controller;
            LinguisticVariable tempInside = new LinguisticVariable("TemperatureInside");

            tempInside.MembershipFunctionCollection.Add(new MembershipFunction("Cold", -10, -10, 15, 19));
            tempInside.MembershipFunctionCollection.Add(new MembershipFunction("Normal", 15, 22, 22, 26));
            tempInside.MembershipFunctionCollection.Add(new MembershipFunction("Warm", 22, 26, 125, 125));

            LinguisticVariable tempOutside = new LinguisticVariable("TemperatureOutside");

            tempOutside.MembershipFunctionCollection.Add(new MembershipFunction("Cold", -20, -20, 10, 16));
            tempOutside.MembershipFunctionCollection.Add(new MembershipFunction("Normal", 13, 21, 21, 27));
            tempOutside.MembershipFunctionCollection.Add(new MembershipFunction("Warm", 20, 26, 125, 125));

            LinguisticVariable heating = new LinguisticVariable("PerformHeat");

            heating.MembershipFunctionCollection.Add(new MembershipFunction("none", 0, 0, 16, 33));
            heating.MembershipFunctionCollection.Add(new MembershipFunction("one", 25, 50, 50, 66));
            heating.MembershipFunctionCollection.Add(new MembershipFunction("both", 45, 75, 100, 100));

            engine.LinguisticVariableCollection.Add(tempInside);
            engine.LinguisticVariableCollection.Add(tempOutside);
            engine.LinguisticVariableCollection.Add(heating);
            engine.Consequent = "PerformHeat";

            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Cold) AND (TemperatureOutside IS Cold) THEN PerformHeat IS both"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Cold) AND (TemperatureOutside IS Normal) THEN PerformHeat IS one"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Cold) AND (TemperatureOutside IS Warm) THEN PerformHeat IS none"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Normal) AND (TemperatureOutside IS Cold) THEN PerformHeat IS one"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Normal) AND (TemperatureOutside IS Normal) THEN PerformHeat IS none"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Normal) AND (TemperatureOutside IS Warm) THEN PerformHeat IS none"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Warm) AND (TemperatureOutside IS Cold) THEN PerformHeat IS none"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Warm) AND (TemperatureOutside IS Normal) THEN PerformHeat IS none"));
            engine.FuzzyRuleCollection.Add(new FuzzyRule("IF (TemperatureInside IS Warm) AND (TemperatureOutside IS Warm) THEN PerformHeat IS none"));
        }
 public DeviceManager(ITemperatureController temperatureController, IEnumerable<IExternalDevice> devices)
 {
     this.temperatureController = temperatureController;
     AddExternalDevices(devices);
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            ISession hive = new Session("YOUR_LOGIN", "YOUR_PASSWORD");

            hive.Login();

            ITemperatureController temp = hive.TemperatureController;

            //show inside temp, outside temp and weather
            var currentTemp = temp.Current();

            Console.WriteLine(currentTemp.inside.now);
            Console.WriteLine(currentTemp.outside.now);
            Console.WriteLine(currentTemp.outside.weather);

            //set temperature to 20 degrees celcius
            temp.Set(20);

            //get temperature history for today
            var temphistory = temp.History(HistoryPeriod.today);

            foreach (var historyItem in temphistory.data)
            {
                Console.WriteLine($"{historyItem.date} = {historyItem.temperature}");
            }

            //get temperature history for Jan 2016
            temphistory = temp.History(HistoryPeriod.thisMonth, 2016, 1);

            //get temperature schedule and show temp of first schedule on Sunday
            var schedule = temp.Schedule();

            Console.WriteLine(schedule.days.sunday.First().temperature);

            //show current control mode, example manual, off, override
            var controlInfo = temp.ControlInfo();

            Console.WriteLine(controlInfo.control);

            //switch heating off
            temp.SetControl(ControlMode.OFF);

            //switch back to schedule
            temp.SetControl(ControlMode.SCHEDULE);

            //turn on boost
            temp.SetControl(ControlMode.BOOST);


            IDeviceController devices = hive.DeviceController;

            //output number of devices and info about them - this will include thermostat, hub etc
            var deviceInfo = devices.Details();

            Console.WriteLine(deviceInfo.Count());
            foreach (var device in deviceInfo)
            {
                Console.WriteLine($"Device {device.name} ID is {device.id} and is a {device.type}");
            }

            //show device events
            var history = devices.EventHistory();

            foreach (var @event in history.events)
            {
                Console.WriteLine(@event.time);
                Console.WriteLine(@event.type);
            }

            //get history with limit of 10
            devices.EventHistory(10);

            //show hub details
            var hub = devices.HubDetails();

            Console.WriteLine(hub.name);
            Console.WriteLine(hub.ip);
            Console.WriteLine(hub.macAddress);
            Console.WriteLine(hub.upTime);



            hive.Logout();
        }