示例#1
0
        public override void SaveHeatersAndActiveProfile(List <Heater> heaters, string profileName)
        {
            Heaters       h       = m_data.LoadHeaters();
            List <Heater> changed = new List <Heater>();

            foreach (Heater heater in heaters)
            {
                if (!h.GetHeaters().Contains(heater))
                {
                    changed.Add(heater);
                }
            }

            foreach (Heater heater in changed)
            {
                if (heater.Id.Equals(Heaters.StartId))
                {
                    heater.Id = Heaters.NextId();
                    h.AddHeater(heater);
                    continue;
                }
                h.Replace(heater);
            }

            m_data.SaveHeaters(h);
            SaveProfileAsActive(h, profileName);
            List <Schedule> schedules = m_data.LoadSchedules();
        }
示例#2
0
 public override Heaters FindHeaters()
 {
     m_heaters = m_data.LoadHeaters();
     if (m_heaters.GetHeaters().Count < 8)
     {
         // add new heater in starting configuration
         m_heaters.AddIfDoesntExist(new Heater("aa", "", ""));
     }
     return(m_heaters);
 }
示例#3
0
        public virtual void SetReturnDateAndProfile(DateTime date, Profile profile)
        {
            Heaters         h         = m_data.LoadHeaters();
            List <Schedule> schedules = m_data.LoadSchedules();

            m_wifiDevices.SendAlternativeSchedules(h.GetHeaters(), schedules);

            // sends invalid temperature -- alternative schedule is used
            m_wifiDevices.SendReturnDateAndTemperature(date, 0);
        }
示例#4
0
        /// <summary>
        /// Saves profile to file, replaces profile with same name.
        /// </summary>
        /// <param name="heaters">Heaters in profile.</param>
        /// <param name="name">Profile name.</param>
        protected void SaveProfile(Heaters heaters, string name)
        {
            Profile profile = new Profile(name);

            foreach (Heater h in heaters.GetHeaters())
            {
                profile.Add(h.Id, h.Schedule);
            }

            SaveProfile(profile);
        }
示例#5
0
        /// <summary>
        /// Checks heaters on wifi.
        /// Creates new device, if one doesnt exist.
        /// </summary>
        /// <returns>Found heaters</returns>
        public virtual Heaters FindHeaters()
        {
            Heaters heaters = m_data.LoadHeaters();

            Dictionary <IPAddress, String> found = m_wifiDevices.FindHeaters();

            foreach (String s in found.Values)
            {
                heaters.AddIfDoesntExist(new Heater(s, "", ""));
            }

            return(heaters);
        }
示例#6
0
        public override Dictionary <String, double> GetTemperature()
        {
            Dictionary <String, double> res = new Dictionary <string, double>();
            Random random = new Random();

            m_heaters = m_data.LoadHeaters();

            foreach (Heater h in m_heaters.GetHeaters())
            {
                res.Add(h.Name, 18 + random.NextDouble() * 5);
            }

            return(res);
        }
示例#7
0
        public override void SaveNewHeatersAndNonactiveProfile(List <Heater> heaters, string profileName)
        {
            Heaters       h         = m_data.LoadHeaters();
            List <Heater> newHeater = new List <Heater>();

            foreach (Heater heater in heaters)
            {
                if (heater.Id.Equals(Heaters.StartId))
                {
                    heater.Id = Heaters.NextId();
                    h.AddHeater(heater);
                    newHeater.Add(heater);
                }
            }

            m_data.SaveHeaters(h);
            SaveProfile(h, profileName);
            List <Schedule> schedules = m_data.LoadSchedules();
        }
示例#8
0
        /// <summary>
        /// Changes new heaters id and saves schedule.
        /// </summary>
        /// <param name="heaters"></param>
        /// <param name="profileName"></param>
        public virtual void SaveNewHeatersAndNonactiveProfile(List <Heater> heaters, string profileName)
        {
            Heaters       h         = m_data.LoadHeaters();
            List <Heater> newHeater = new List <Heater>();

            foreach (Heater heater in heaters)
            {
                if (heater.Id.Equals(Heaters.StartId))
                {
                    heater.Id = Heaters.NextId();
                    h.AddHeater(heater);
                    newHeater.Add(heater);
                    m_wifiDevices.ChangeIdfromStartId(Heaters.LastId);
                }
            }

            m_data.SaveHeaters(h);
            SaveProfile(h, profileName);
            List <Schedule> schedules = m_data.LoadSchedules();

            m_wifiDevices.SendSchedules(newHeater, schedules);
        }
示例#9
0
 public SimulatedController()
 {
     m_heaters = new Heaters();
     m_data    = new Data();
 }