Ejemplo n.º 1
0
        private void LogTemperatureChange(int locationId, Thermostat current, Thermostat previous)
        {
            ThermostatMonitorLib.Thermostat thermostat = ThermostatMonitorLib.Thermostat.LoadThermostat(locationId, current.IpAddress);
            double precision = System.Math.Round(new TimeSpan(DateTime.Now.Ticks - previous.CheckinTime.Ticks).TotalMinutes, 0);

            if (precision > 100)
            {
                precision = -1;
            }
            ThermostatMonitorLib.Temperature.LogTemperature(thermostat.Id, current.Temperature, (short)precision);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            key         = Request["k"];
            action      = Request["a"];
            mode        = Request["m"];
            duration    = Convert.ToInt32(Request["d"]);
            precision   = Convert.ToInt16(Request["p"]);
            temperature = (int)Convert.ToDouble(Request["t"]);

            if (key != null && key != "")
            {
                thermostat = ThermostatMonitorLib.Thermostat.LoadByKeyName(key);
            }
            if (action == "location")
            {
                ReturnLocation();
            }
            else
            {
                if (thermostat != null)
                {
                    switch (action)
                    {
                    case "cycle":
                        LogCycle();
                        break;

                    case "temp":
                        LogTemperatureChange();
                        break;

                    case "conditions":
                        LogConditions();
                        break;

                    case "stats":
                        RedirectToStats();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void LogStateChange(int locationId, Thermostat current, Thermostat previous)
        {
            ThermostatMonitorLib.Thermostat thermostat = ThermostatMonitorLib.Thermostat.LoadThermostat(locationId, current.IpAddress);
            double precision = System.Math.Round(new TimeSpan(DateTime.Now.Ticks - previous.CheckinTime.Ticks).TotalMinutes, 0);

            if (precision > 100)
            {
                precision = -1;
            }

            ThermostatMonitorLib.Cycle.EndOpenCycle(thermostat.Id, (short)precision);
            if (current.State != "Off")
            {
                ThermostatMonitorLib.Cycle.StartCycle(thermostat.Id, current.State, (short)precision);
            }
            else
            {
                ThermostatMonitorLib.Snapshots.Generate(thermostat.Id);
            }
        }
Ejemplo n.º 4
0
        public static void CleanCache()
        {
            DateTime minTime = DateTime.Now.AddMinutes(-10);

            String[] keys = new String[Cache.Keys.Count];

            Cache.Keys.CopyTo(keys, 0);

            foreach (string key in keys)
            {
                Thermostat t = (Thermostat)Cache[key];
                if (t.CheckinTime < minTime)
                {
                    if (t.State != "Off")
                    {
                        string[] parts      = key.Split('_');
                        int      locationId = Convert.ToInt32(parts[0]);
                        ThermostatMonitorLib.Thermostat thermostat = ThermostatMonitorLib.Thermostat.LoadThermostat(locationId, t.IpAddress);
                        ThermostatMonitorLib.Cycle.EndOpenCycle(thermostat.Id, (short)-1);
                    }
                    Cache.Remove(key);
                }
            }
        }