Exemplo n.º 1
0
        private void LogState()
        {
            IBoiler      boiler = _repo.Retrieve();
            BoilerStatus bs     = new BoilerStatus(boiler);

            bs.LoggedDate = DateTime.Now;
            _logger.Save(bs);
        }
Exemplo n.º 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());
        }
Exemplo n.º 3
0
        public MockRepository()
        {
            _boiler = new Boiler();
            _boiler.ActualTemp = 10;
            _boiler.TargetTemp = 20;

            _saveCalledCount = 0;
            _retrieveCalledCount = 0;

            _lastRecorded = DateTime.Now;
        }
Exemplo n.º 4
0
        public MockRepository()
        {
            _boiler            = new Boiler();
            _boiler.ActualTemp = 10;
            _boiler.TargetTemp = 20;

            _saveCalledCount     = 0;
            _retrieveCalledCount = 0;

            _lastRecorded = DateTime.Now;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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());
        }
Exemplo n.º 11
0
 public Boiler(IBoiler hardware)
 {
     this._hardware = hardware;
 }
Exemplo n.º 12
0
 public EspressoMaker(IBeanGrinder beanGrinder, IBoiler waterBoiler, IPortaFilter portaFilter)
 {
     _beanGrinder = beanGrinder;
     _waterBoiler = waterBoiler;
     _portaFilter = portaFilter;
 }