Added a configurable logging interval.
1.1 --- a/GUI/MainForm.Designer.cs Sun Aug 18 21:44:08 2013 +0000
1.2 +++ b/GUI/MainForm.Designer.cs Sun Aug 25 19:13:35 2013 +0000
1.3 @@ -88,6 +88,7 @@
1.4 this.webMenuItem = new System.Windows.Forms.MenuItem();
1.5 this.runWebServerMenuItem = new System.Windows.Forms.MenuItem();
1.6 this.serverPortMenuItem = new System.Windows.Forms.MenuItem();
1.7 + this.logSensorsMenuItem = new System.Windows.Forms.MenuItem();
1.8 this.helpMenuItem = new System.Windows.Forms.MenuItem();
1.9 this.aboutMenuItem = new System.Windows.Forms.MenuItem();
1.10 this.treeContextMenu = new System.Windows.Forms.ContextMenu();
1.11 @@ -95,7 +96,21 @@
1.12 this.timer = new System.Windows.Forms.Timer(this.components);
1.13 this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
1.14 this.treeView = new Aga.Controls.Tree.TreeViewAdv();
1.15 - this.logSensorsMenuItem = new System.Windows.Forms.MenuItem();
1.16 + this.logSeparatorMenuItem = new System.Windows.Forms.MenuItem();
1.17 + this.loggingIntervalMenuItem = new System.Windows.Forms.MenuItem();
1.18 + this.log1sMenuItem = new System.Windows.Forms.MenuItem();
1.19 + this.log5sMenuItem = new System.Windows.Forms.MenuItem();
1.20 + this.log10sMenuItem = new System.Windows.Forms.MenuItem();
1.21 + this.log30sMenuItem = new System.Windows.Forms.MenuItem();
1.22 + this.log1minMenuItem = new System.Windows.Forms.MenuItem();
1.23 + this.log5minMenuItem = new System.Windows.Forms.MenuItem();
1.24 + this.log10minMenuItem = new System.Windows.Forms.MenuItem();
1.25 + this.log30minMenuItem = new System.Windows.Forms.MenuItem();
1.26 + this.log2sMenuItem = new System.Windows.Forms.MenuItem();
1.27 + this.log2minMenuItem = new System.Windows.Forms.MenuItem();
1.28 + this.log1hMenuItem = new System.Windows.Forms.MenuItem();
1.29 + this.log2hMenuItem = new System.Windows.Forms.MenuItem();
1.30 + this.log6hMenuItem = new System.Windows.Forms.MenuItem();
1.31 this.splitContainer.Panel1.SuspendLayout();
1.32 this.splitContainer.SuspendLayout();
1.33 this.SuspendLayout();
1.34 @@ -355,9 +370,11 @@
1.35 this.separatorMenuItem,
1.36 this.temperatureUnitsMenuItem,
1.37 this.plotLocationMenuItem,
1.38 + this.logSeparatorMenuItem,
1.39 + this.logSensorsMenuItem,
1.40 + this.loggingIntervalMenuItem,
1.41 this.webMenuItemSeparator,
1.42 - this.webMenuItem,
1.43 - this.logSensorsMenuItem});
1.44 + this.webMenuItem});
1.45 this.optionsMenuItem.Text = "Options";
1.46 //
1.47 // startMinMenuItem
1.48 @@ -436,12 +453,12 @@
1.49 //
1.50 // webMenuItemSeparator
1.51 //
1.52 - this.webMenuItemSeparator.Index = 7;
1.53 + this.webMenuItemSeparator.Index = 10;
1.54 this.webMenuItemSeparator.Text = "-";
1.55 //
1.56 // webMenuItem
1.57 //
1.58 - this.webMenuItem.Index = 8;
1.59 + this.webMenuItem.Index = 11;
1.60 this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
1.61 this.runWebServerMenuItem,
1.62 this.serverPortMenuItem});
1.63 @@ -458,6 +475,11 @@
1.64 this.serverPortMenuItem.Text = "Port";
1.65 this.serverPortMenuItem.Click += new System.EventHandler(this.serverPortMenuItem_Click);
1.66 //
1.67 + // logSensorsMenuItem
1.68 + //
1.69 + this.logSensorsMenuItem.Index = 8;
1.70 + this.logSensorsMenuItem.Text = "Log Sensors";
1.71 + //
1.72 // helpMenuItem
1.73 //
1.74 this.helpMenuItem.Index = 3;
1.75 @@ -539,10 +561,107 @@
1.76 this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove);
1.77 this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseUp);
1.78 //
1.79 - // logSensorsMenuItem
1.80 + // logSeparatorMenuItem
1.81 //
1.82 - this.logSensorsMenuItem.Index = 9;
1.83 - this.logSensorsMenuItem.Text = "Log Sensors";
1.84 + this.logSeparatorMenuItem.Index = 7;
1.85 + this.logSeparatorMenuItem.Text = "-";
1.86 + //
1.87 + // loggingIntervalMenuItem
1.88 + //
1.89 + this.loggingIntervalMenuItem.Index = 9;
1.90 + this.loggingIntervalMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
1.91 + this.log1sMenuItem,
1.92 + this.log2sMenuItem,
1.93 + this.log5sMenuItem,
1.94 + this.log10sMenuItem,
1.95 + this.log30sMenuItem,
1.96 + this.log1minMenuItem,
1.97 + this.log2minMenuItem,
1.98 + this.log5minMenuItem,
1.99 + this.log10minMenuItem,
1.100 + this.log30minMenuItem,
1.101 + this.log1hMenuItem,
1.102 + this.log2hMenuItem,
1.103 + this.log6hMenuItem});
1.104 + this.loggingIntervalMenuItem.Text = "Logging Interval";
1.105 + //
1.106 + // log1sMenuItem
1.107 + //
1.108 + this.log1sMenuItem.Index = 0;
1.109 + this.log1sMenuItem.RadioCheck = true;
1.110 + this.log1sMenuItem.Text = "1s";
1.111 + //
1.112 + // log5sMenuItem
1.113 + //
1.114 + this.log5sMenuItem.Index = 2;
1.115 + this.log5sMenuItem.RadioCheck = true;
1.116 + this.log5sMenuItem.Text = "5s";
1.117 + //
1.118 + // log10sMenuItem
1.119 + //
1.120 + this.log10sMenuItem.Index = 3;
1.121 + this.log10sMenuItem.RadioCheck = true;
1.122 + this.log10sMenuItem.Text = "10s";
1.123 + //
1.124 + // log30sMenuItem
1.125 + //
1.126 + this.log30sMenuItem.Index = 4;
1.127 + this.log30sMenuItem.RadioCheck = true;
1.128 + this.log30sMenuItem.Text = "30s";
1.129 + //
1.130 + // log1minMenuItem
1.131 + //
1.132 + this.log1minMenuItem.Index = 5;
1.133 + this.log1minMenuItem.RadioCheck = true;
1.134 + this.log1minMenuItem.Text = "1min";
1.135 + //
1.136 + // log5minMenuItem
1.137 + //
1.138 + this.log5minMenuItem.Index = 7;
1.139 + this.log5minMenuItem.RadioCheck = true;
1.140 + this.log5minMenuItem.Text = "5min";
1.141 + //
1.142 + // log10minMenuItem
1.143 + //
1.144 + this.log10minMenuItem.Index = 8;
1.145 + this.log10minMenuItem.RadioCheck = true;
1.146 + this.log10minMenuItem.Text = "10min";
1.147 + //
1.148 + // log30minMenuItem
1.149 + //
1.150 + this.log30minMenuItem.Index = 9;
1.151 + this.log30minMenuItem.RadioCheck = true;
1.152 + this.log30minMenuItem.Text = "30min";
1.153 + //
1.154 + // log2sMenuItem
1.155 + //
1.156 + this.log2sMenuItem.Index = 1;
1.157 + this.log2sMenuItem.RadioCheck = true;
1.158 + this.log2sMenuItem.Text = "2s";
1.159 + //
1.160 + // log2minMenuItem
1.161 + //
1.162 + this.log2minMenuItem.Index = 6;
1.163 + this.log2minMenuItem.RadioCheck = true;
1.164 + this.log2minMenuItem.Text = "2min";
1.165 + //
1.166 + // log1hMenuItem
1.167 + //
1.168 + this.log1hMenuItem.Index = 10;
1.169 + this.log1hMenuItem.RadioCheck = true;
1.170 + this.log1hMenuItem.Text = "1h";
1.171 + //
1.172 + // log2hMenuItem
1.173 + //
1.174 + this.log2hMenuItem.Index = 11;
1.175 + this.log2hMenuItem.RadioCheck = true;
1.176 + this.log2hMenuItem.Text = "2h";
1.177 + //
1.178 + // log6hMenuItem
1.179 + //
1.180 + this.log6hMenuItem.Index = 12;
1.181 + this.log6hMenuItem.RadioCheck = true;
1.182 + this.log6hMenuItem.Text = "6h";
1.183 //
1.184 // MainForm
1.185 //
1.186 @@ -628,6 +747,21 @@
1.187 private System.Windows.Forms.MenuItem fanControllerMenuItem;
1.188 private System.Windows.Forms.MenuItem ramMenuItem;
1.189 private System.Windows.Forms.MenuItem logSensorsMenuItem;
1.190 + private System.Windows.Forms.MenuItem logSeparatorMenuItem;
1.191 + private System.Windows.Forms.MenuItem loggingIntervalMenuItem;
1.192 + private System.Windows.Forms.MenuItem log1sMenuItem;
1.193 + private System.Windows.Forms.MenuItem log2sMenuItem;
1.194 + private System.Windows.Forms.MenuItem log5sMenuItem;
1.195 + private System.Windows.Forms.MenuItem log10sMenuItem;
1.196 + private System.Windows.Forms.MenuItem log30sMenuItem;
1.197 + private System.Windows.Forms.MenuItem log1minMenuItem;
1.198 + private System.Windows.Forms.MenuItem log2minMenuItem;
1.199 + private System.Windows.Forms.MenuItem log5minMenuItem;
1.200 + private System.Windows.Forms.MenuItem log10minMenuItem;
1.201 + private System.Windows.Forms.MenuItem log30minMenuItem;
1.202 + private System.Windows.Forms.MenuItem log1hMenuItem;
1.203 + private System.Windows.Forms.MenuItem log2hMenuItem;
1.204 + private System.Windows.Forms.MenuItem log6hMenuItem;
1.205 }
1.206 }
1.207
2.1 --- a/GUI/MainForm.cs Sun Aug 18 21:44:08 2013 +0000
2.2 +++ b/GUI/MainForm.cs Sun Aug 25 19:13:35 2013 +0000
2.3 @@ -67,6 +67,7 @@
2.4 private HttpServer server;
2.5
2.6 private UserOption logSensors;
2.7 + private UserRadioGroup loggingInterval;
2.8 private Logger logger;
2.9
2.10 private bool selectionDragging = false;
2.11 @@ -283,7 +284,31 @@
2.12 };
2.13
2.14 logSensors = new UserOption("logSensorsMenuItem", false, logSensorsMenuItem,
2.15 - settings);
2.16 + settings);
2.17 +
2.18 + loggingInterval = new UserRadioGroup("loggingInterval", 0,
2.19 + new[] { log1sMenuItem, log2sMenuItem, log5sMenuItem, log10sMenuItem,
2.20 + log30sMenuItem, log1minMenuItem, log2minMenuItem, log5minMenuItem,
2.21 + log10minMenuItem, log30minMenuItem, log1hMenuItem, log2hMenuItem,
2.22 + log6hMenuItem},
2.23 + settings);
2.24 + loggingInterval.Changed += (sender, e) => {
2.25 + switch (loggingInterval.Value) {
2.26 + case 0: logger.LoggingInterval = new TimeSpan(0, 0, 1); break;
2.27 + case 1: logger.LoggingInterval = new TimeSpan(0, 0, 2); break;
2.28 + case 2: logger.LoggingInterval = new TimeSpan(0, 0, 5); break;
2.29 + case 3: logger.LoggingInterval = new TimeSpan(0, 0, 10); break;
2.30 + case 4: logger.LoggingInterval = new TimeSpan(0, 0, 30); break;
2.31 + case 5: logger.LoggingInterval = new TimeSpan(0, 1, 0); break;
2.32 + case 6: logger.LoggingInterval = new TimeSpan(0, 2, 0); break;
2.33 + case 7: logger.LoggingInterval = new TimeSpan(0, 5, 0); break;
2.34 + case 8: logger.LoggingInterval = new TimeSpan(0, 10, 0); break;
2.35 + case 9: logger.LoggingInterval = new TimeSpan(0, 30, 0); break;
2.36 + case 10: logger.LoggingInterval = new TimeSpan(1, 0, 0); break;
2.37 + case 11: logger.LoggingInterval = new TimeSpan(2, 0, 0); break;
2.38 + case 12: logger.LoggingInterval = new TimeSpan(6, 0, 0); break;
2.39 + }
2.40 + };
2.41
2.42 InitializePlotForm();
2.43
3.1 --- a/Properties/AssemblyVersion.cs Sun Aug 18 21:44:08 2013 +0000
3.2 +++ b/Properties/AssemblyVersion.cs Sun Aug 25 19:13:35 2013 +0000
3.3 @@ -10,5 +10,5 @@
3.4
3.5 using System.Reflection;
3.6
3.7 -[assembly: AssemblyVersion("0.6.0.9")]
3.8 -[assembly: AssemblyInformationalVersion("0.6.0.9 Alpha")]
3.9 \ No newline at end of file
3.10 +[assembly: AssemblyVersion("0.6.0.10")]
3.11 +[assembly: AssemblyInformationalVersion("0.6.0.10 Alpha")]
3.12 \ No newline at end of file
4.1 --- a/Utilities/Logger.cs Sun Aug 18 21:44:08 2013 +0000
4.2 +++ b/Utilities/Logger.cs Sun Aug 25 19:13:35 2013 +0000
4.3 @@ -28,10 +28,12 @@
4.4 private string[] identifiers;
4.5 private ISensor[] sensors;
4.6
4.7 + private DateTime lastLoggedTime = DateTime.MinValue;
4.8 +
4.9 public Logger(IComputer computer) {
4.10 this.computer = computer;
4.11 this.computer.HardwareAdded += HardwareAdded;
4.12 - this.computer.HardwareRemoved += HardwareRemoved;
4.13 + this.computer.HardwareRemoved += HardwareRemoved;
4.14 }
4.15
4.16 private void HardwareRemoved(IHardware hardware) {
4.17 @@ -142,8 +144,14 @@
4.18 }
4.19 }
4.20
4.21 - public void Log() {
4.22 + public TimeSpan LoggingInterval { get; set; }
4.23 +
4.24 + public void Log() {
4.25 var now = DateTime.Now;
4.26 +
4.27 + if (lastLoggedTime + LoggingInterval - new TimeSpan(5000000) > now)
4.28 + return;
4.29 +
4.30 if (day != now.Date || !File.Exists(fileName)) {
4.31 day = now.Date;
4.32 fileName = GetFileName(day);
4.33 @@ -171,6 +179,8 @@
4.34 }
4.35 }
4.36 } catch (IOException) { }
4.37 +
4.38 + lastLoggedTime = now;
4.39 }
4.40 }
4.41 }