Parent Directory
|
Revision Log
|
Patch
--- trunk/libThermoControl/Configuration.cs 2013/11/13 03:08:55 25 +++ trunk/libThermoControl/Configuration.cs 2014/02/12 03:28:37 29 @@ -17,16 +17,25 @@ public static int CurrentTemp { get { return ReadTemp(); } set { WriteTemp(value); } } - public static int ExternalTemp { get { return GetExternalTemp(); } } + public static int GetTemperatureAdjustment() + { + int e_temp = Configuration.ExternalTemp; + int d_temp = Configuration.CurrentTemp; + int scale = 5; + int s = (d_temp - e_temp) / scale; + int offset = 4; + int t = (d_temp + s) - offset; + return t; + } - public static readonly string WEATHER_URL = ""; // 60 - public static readonly string THERMISTAT_DEVICE = ""; // 60 + public static readonly string WEATHER_URL = "http://www.accuweather.com/en/us/chattanooga-tn/37421/current-weather/331086"; // 60 + public static readonly string THERMISTAT_DEVICE = "AC_THERMOSTAT"; // 60 public static readonly int MIN_TEMP = 0; // 60 public static readonly int MAX_TEMP = 0; // 90 public static readonly int DEFAULT_TEMP = 0; // 70 - public static readonly string DEFAULT_MODE = ""; // cool - public static readonly string DEFAULT_FAN_SPEED = ""; // auto_fan + public static readonly string DEFAULT_MODE = "cool"; // cool + public static readonly string DEFAULT_FAN_SPEED = "auto_fan"; // auto_fan [Conditional("CONFIG_UNITTEST")] public static void UnitTest() @@ -55,13 +64,30 @@ var list = o.ToList(); if (list.Count == 0) { - Console.WriteLine("Name: '{0}' Default: '{1}' Configured: '{1}'", field.Name, field.GetValue(null).ToString()); + var f = field.GetValue(null).ToString(); + if (string.IsNullOrEmpty(f)) + { + throw new ArgumentNullException("f", string.Format("Error - Field: {0} is null or an empty string", field.Name)); + } + else + { + Console.WriteLine("Name: '{0}' Default: '{1}' Configured: '{1}'", field.Name, f); + } } else { var t = xdoc.Root.Elements(field.Name).ToList().FirstOrDefault().Value; - Console.WriteLine("Name: '{0}' Default: '{1}' Configured: '{2}'", field.Name, field.GetValue(null).ToString(), t); - field.SetValue(null, Convert.ChangeType(t,field.FieldType)); + if (string.IsNullOrEmpty(t)) + { + t = field.GetValue(null).ToString(); + Console.WriteLine("Name: '{0}' Default: '{1}' Configured: '{2}'", field.Name, t, t); + field.SetValue(null, Convert.ChangeType(t, field.FieldType)); + } + else + { + Console.WriteLine("Name: '{0}' Default: '{1}' Configured: '{2}'", field.Name, field.GetValue(null).ToString(), t); + field.SetValue(null, Convert.ChangeType(t, field.FieldType)); + } } } @@ -128,7 +154,7 @@ int k = Convert.ToInt32(t.Tag); temp = k; } - catch (Exception ex) + catch (Exception) { temp = 0; }
ViewVC Help | |
Powered by ViewVC 1.1.22 |