Пример #1
0
        private void LogState()
        {
            IBoiler      boiler = _repo.Retrieve();
            BoilerStatus bs     = new BoilerStatus(boiler);

            bs.LoggedDate = DateTime.Now;
            _logger.Save(bs);
        }
Пример #2
0
        public IBoiler Save(IBoiler boiler)
        {
            elementPin.State   = boiler.IsElementOn.AsGPIOState();
            pumpPin.State      = boiler.IsPumpOn.AsGPIOState();
            _boiler.TargetTemp = boiler.TargetTemp;
            _boiler.TempOffset = boiler.TempOffset;

            return(this.Retrieve());
        }
Пример #3
0
        public MockRepository()
        {
            _boiler = new Boiler();
            _boiler.ActualTemp = 10;
            _boiler.TargetTemp = 20;

            _saveCalledCount = 0;
            _retrieveCalledCount = 0;

            _lastRecorded = DateTime.Now;
        }
Пример #4
0
        public MockRepository()
        {
            _boiler            = new Boiler();
            _boiler.ActualTemp = 10;
            _boiler.TargetTemp = 20;

            _saveCalledCount     = 0;
            _retrieveCalledCount = 0;

            _lastRecorded = DateTime.Now;
        }
Пример #5
0
        public BoilerStatus(IBoiler boiler)
        {
            IsElementOn= boiler.IsElementOn;
            IsPumpOn = boiler.IsPumpOn;
            IsBurstOn = boiler.IsBurstOn;
            IsAuto = boiler.IsAuto;
            TargetTemp = boiler.TargetTemp;
            TempOffset = boiler.TempOffset;
            ActualTemp = boiler.ActualTemp;

            BurstTime = boiler.BurstTime;
            BurstInterval = boiler.BurstInterval;
        }
Пример #6
0
        public BoilerStatus(IBoiler boiler)
        {
            IsElementOn = boiler.IsElementOn;
            IsPumpOn    = boiler.IsPumpOn;
            IsBurstOn   = boiler.IsBurstOn;
            IsAuto      = boiler.IsAuto;
            TargetTemp  = boiler.TargetTemp;
            TempOffset  = boiler.TempOffset;
            ActualTemp  = boiler.ActualTemp;

            BurstTime     = boiler.BurstTime;
            BurstInterval = boiler.BurstInterval;
        }
Пример #7
0
        public BoilerMonitor(IBoilerRepository repo, ITimerAdapter timer, IBoilerStatusRepository logger)
        {
            _repo   = repo;
            _logger = logger;

            lastOff = DateTime.Now.AddHours(-1);

            IBoiler b = logger.Retrieve().ToBoiler();

            _repo.Save(b);

            timer.Initialize(MonitorState);
        }
Пример #8
0
        private void MonitorState(object source)
        {
            IBoiler boiler = _repo.Retrieve();

            DateTime n = DateTime.Now;

            boiler.DisableOnHighTemp();
            boiler.EnableOnLowTemp(n);
            boiler.BurstCycleOff(n);
            boiler.BurstCycleOn(n);

            _repo.Save(boiler);

            LogState();
        }
Пример #9
0
        public IBoiler Save(IBoiler boiler)
        {
            _saveCalledCount++;

            _boiler = boiler;

            // fudge to make the gauge move tick.
            decimal diffInSeconds = (decimal)((DateTime.Now - _lastRecorded).TotalSeconds);
            boiler.ActualTemp = Math.Round(boiler.ActualTemp + (diffInSeconds * (boiler.IsElementOn == false ? -1 : 1)),2);

            if (boiler.ActualTemp > 100) boiler.ActualTemp = 100;
            if (boiler.ActualTemp < 0) boiler.ActualTemp = 0;
            _lastRecorded = DateTime.Now;

            return this.Retrieve();
        }
Пример #10
0
        public IBoiler Save(IBoiler boiler)
        {
            _saveCalledCount++;

            _boiler = boiler;

            // fudge to make the gauge move tick.
            decimal diffInSeconds = (decimal)((DateTime.Now - _lastRecorded).TotalSeconds);

            boiler.ActualTemp = Math.Round(boiler.ActualTemp + (diffInSeconds * (boiler.IsElementOn == false ? -1 : 1)), 2);

            if (boiler.ActualTemp > 100)
            {
                boiler.ActualTemp = 100;
            }
            if (boiler.ActualTemp < 0)
            {
                boiler.ActualTemp = 0;
            }
            _lastRecorded = DateTime.Now;

            return(this.Retrieve());
        }
Пример #11
0
 public Boiler(IBoiler hardware)
 {
     this._hardware = hardware;
 }
Пример #12
0
 public EspressoMaker(IBeanGrinder beanGrinder, IBoiler waterBoiler, IPortaFilter portaFilter)
 {
     _beanGrinder = beanGrinder;
     _waterBoiler = waterBoiler;
     _portaFilter = portaFilter;
 }