Exemplo n.º 1
0
 public static ClimateModel From(ClimateModel model)
 {
     return(new ClimateModel(
                model.DesiredTemperature,
                model.HvacOperatingMode,
                AtmosphericConditions.From(model.CurrentConditions)));
 }
Exemplo n.º 2
0
        protected void InitializePeripherals()
        {
            Console.WriteLine("UXController.InitializePeripherals");

            upButton   = new PushButton(IODeviceMap.Buttons.Device, IODeviceMap.Buttons.UpPin);
            downButton = new PushButton(IODeviceMap.Buttons.Device, IODeviceMap.Buttons.DownPin);
            modeButton = new PushButton(IODeviceMap.Buttons.Device, IODeviceMap.Buttons.ModePin);

            upButton.Clicked += (s, e) => {
                // TODO: do some checks here:
                //if(this._climateModel.DesiredTemperature + 1 < someMax) {
                Console.WriteLine("Up button");
                ClimateModel newClimate = ClimateModel.From(ThermApp.ModelManager.Climate);
                newClimate.DesiredTemperature++;
                ThermApp.ModelManager.UpdateDesiredClimate(newClimate);
            };

            downButton.Clicked += (s, e) => {
                //if(this._climateModel.DesiredTemperature - 1 > someMin) {
                Console.WriteLine("Down button");
                ClimateModel newClimate = ClimateModel.From(ThermApp.ModelManager.Climate);
                newClimate.DesiredTemperature--;
                ThermApp.ModelManager.UpdateDesiredClimate(newClimate);
            };

            modeButton.Clicked += (s, e) => {
                Console.WriteLine("Mode button");
                ClimateModel newClimate = ClimateModel.From(ThermApp.ModelManager.Climate);
                // cycle to the next mode
                switch (newClimate.HvacOperatingMode)
                {
                case ClimateController.Mode.Auto:
                    newClimate.HvacOperatingMode = ClimateController.Mode.Cool;
                    break;

                case ClimateController.Mode.Cool:
                    newClimate.HvacOperatingMode = ClimateController.Mode.Heat;
                    break;

                case ClimateController.Mode.Heat:
                    newClimate.HvacOperatingMode = ClimateController.Mode.FanOnly;
                    break;

                case ClimateController.Mode.FanOnly:
                    newClimate.HvacOperatingMode = ClimateController.Mode.Off;
                    break;

                case ClimateController.Mode.Off:
                    newClimate.HvacOperatingMode = ClimateController.Mode.Auto;
                    break;
                }
                ThermApp.ModelManager.UpdateDesiredClimate(newClimate);
            };
        }
Exemplo n.º 3
0
        public ClimateController(
            //HvacController hvacController,
            //AnalogTemperature temperatureSensor
            )
        {
            _hvacController = new HvacController(
                ThermApp.Device.CreateDigitalOutputPort(IODeviceMap.HVac.HeaterPin),
                ThermApp.Device.CreateDigitalOutputPort(IODeviceMap.HVac.FanPin),
                ThermApp.Device.CreateDigitalOutputPort(IODeviceMap.HVac.AirConPin)
                );

            // when the climate model changes, make sure to update the HVAC
            // state
            ThermApp.ModelManager.Subscribe(new FilterableChangeObserver <ClimateModelChangeResult, ClimateModel>(
                                                h => {
                Console.WriteLine("ClimateController: Climate model changed, updating hvac.");
                _desiredClimateOperation = h.New;
                UpdateClimateIntent();
            }
                                                ));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Does a display update, if appropriate based on the new climate model
 /// passed in.
 /// </summary>
 /// <param name="model">The climate model that shuld be reflected on
 /// screen.</param>
 public void UpdateClimate(ClimateModel model)
 {
     climate = model;
     // update the screen
     Render();
 }
Exemplo n.º 5
0
 public ClimateModelResult(ClimateModel model)
 {
     Model = model;
 }