From 2b48cec0e0189c834995cddece0874b185e95495 Mon Sep 17 00:00:00 2001 From: NSFW Date: Sat, 7 Sep 2024 19:07:39 -0700 Subject: [PATCH] Needs testing. --- Apps/PcmHammer/PcmHammer.csproj | 4 +- Apps/PcmLibrary/Logging/LogColumn.cs | 5 +- Apps/PcmLibrary/Logging/LogProfileReader.cs | 7 +- Apps/PcmLibrary/Logging/LogProfileWriter.cs | 1 + Apps/PcmLibrary/Logging/Logger.cs | 4 +- Apps/PcmLibrary/Logging/ParameterDatabase.cs | 2 +- Apps/PcmLogger/MainForm.Designer.cs | 148 ++++++++++++------- Apps/PcmLogger/MainForm.LoggingThread.cs | 39 ++++- Apps/PcmLogger/MainForm.ParameterGrid.cs | 12 +- Apps/PcmLogger/MainForm.Zoom.cs | 67 +++++++++ Apps/PcmLogger/MainForm.resx | 21 +++ Apps/PcmLogger/Parameters.Math.xml | 2 +- Apps/PcmLogger/Parameters.Standard.xml | 86 +++++------ Apps/PcmLogger/PcmLogger.csproj | 7 +- Apps/Tests/LoggingTests.cs | 8 +- Apps/Tests/MathTests.cs | 8 +- 16 files changed, 297 insertions(+), 124 deletions(-) create mode 100644 Apps/PcmLogger/MainForm.Zoom.cs diff --git a/Apps/PcmHammer/PcmHammer.csproj b/Apps/PcmHammer/PcmHammer.csproj index 32c8a95e..e15ef326 100644 --- a/Apps/PcmHammer/PcmHammer.csproj +++ b/Apps/PcmHammer/PcmHammer.csproj @@ -36,7 +36,7 @@ TRACE;DEBUG prompt 4 - C:\Users\Jouko\AppData\Local\Temp\vsD06A.tmp\Debug\ + C:\Users\nate\AppData\Local\Temp\vsAB0C.tmp\Debug\ AnyCPU @@ -46,7 +46,7 @@ TRACE prompt 4 - C:\Users\Jouko\AppData\Local\Temp\vsD06A.tmp\Release\ + C:\Users\nate\AppData\Local\Temp\vsAB0C.tmp\Release\ 0411_256px.ico diff --git a/Apps/PcmLibrary/Logging/LogColumn.cs b/Apps/PcmLibrary/Logging/LogColumn.cs index d3070213..8927e8a5 100644 --- a/Apps/PcmLibrary/Logging/LogColumn.cs +++ b/Apps/PcmLibrary/Logging/LogColumn.cs @@ -20,13 +20,16 @@ public class LogColumn /// public Conversion Conversion { get; private set; } + public bool Zoom { get; private set; } + /// /// Constructor. /// - public LogColumn(Parameter parameter, Conversion conversion) + public LogColumn(Parameter parameter, Conversion conversion, bool zoom) { this.Parameter = parameter; this.Conversion = conversion; + this.Zoom = zoom; } /// diff --git a/Apps/PcmLibrary/Logging/LogProfileReader.cs b/Apps/PcmLibrary/Logging/LogProfileReader.cs index a580ee8f..6da14f83 100644 --- a/Apps/PcmLibrary/Logging/LogProfileReader.cs +++ b/Apps/PcmLibrary/Logging/LogProfileReader.cs @@ -59,12 +59,13 @@ private void LoadParameters(XDocument xml) where T : Parameter { string id = parameterElement.Attribute("id").Value; string units = parameterElement.Attribute("units").Value; - this.AddParameterToProfile(id, units); + bool zoom = parameterElement.Attribute("zoom").Value == "true"; + this.AddParameterToProfile(id, units, zoom); } } } - private void AddParameterToProfile(string id, string units) where T : Parameter + private void AddParameterToProfile(string id, string units, bool zoom) where T : Parameter { T parameter; if (!this.database.TryGetParameter(id, out parameter)) @@ -86,7 +87,7 @@ private void AddParameterToProfile(string id, string units) where T : Paramet throw new Exception(String.Format("Conversion {0} for parameter {1} not found when loading profile.", units, id)); } - LogColumn column = new LogColumn(parameter, conversion); + LogColumn column = new LogColumn(parameter, conversion, zoom); this.profile.AddColumn(column); } diff --git a/Apps/PcmLibrary/Logging/LogProfileWriter.cs b/Apps/PcmLibrary/Logging/LogProfileWriter.cs index f3c4aad0..1654891e 100644 --- a/Apps/PcmLibrary/Logging/LogProfileWriter.cs +++ b/Apps/PcmLibrary/Logging/LogProfileWriter.cs @@ -50,6 +50,7 @@ private static void WriteParameters(LogProfile profile, XElement top) where T XElement element = new XElement(parameterType); element.SetAttributeValue("id", column.Parameter.Id); element.SetAttributeValue("units", column.Conversion.Units); + element.SetAttributeValue("zoom", column.Zoom.ToString()); parameterListElement.Add(element); } } diff --git a/Apps/PcmLibrary/Logging/Logger.cs b/Apps/PcmLibrary/Logging/Logger.cs index 3d304a7d..d1e877cd 100644 --- a/Apps/PcmLibrary/Logging/Logger.cs +++ b/Apps/PcmLibrary/Logging/Logger.cs @@ -131,14 +131,14 @@ public static Logger Create( if (xColumn == null) { - xColumn = new LogColumn(mathParameter.XColumn.Parameter, mathParameter.XColumn.Conversion); + xColumn = new LogColumn(mathParameter.XColumn.Parameter, mathParameter.XColumn.Conversion, false); pcmColumns.Add(xColumn); } LogColumn yColumn = pcmColumns.Where(y => y.Parameter == mathParameter.YColumn.Parameter).FirstOrDefault(); if (yColumn == null) { - yColumn = new LogColumn(mathParameter.YColumn.Parameter, mathParameter.YColumn.Conversion); + yColumn = new LogColumn(mathParameter.YColumn.Parameter, mathParameter.YColumn.Conversion, false); pcmColumns.Add(yColumn); } diff --git a/Apps/PcmLibrary/Logging/ParameterDatabase.cs b/Apps/PcmLibrary/Logging/ParameterDatabase.cs index 8bd0dae9..076ee461 100644 --- a/Apps/PcmLibrary/Logging/ParameterDatabase.cs +++ b/Apps/PcmLibrary/Logging/ParameterDatabase.cs @@ -272,7 +272,7 @@ private LogColumn BuildLogColumnForMathParameter(string id, string units, string throw new Exception(String.Format("No conversion found for {0} in {1}", units, parameterName)); } - return new LogColumn(xParameter, xConversion); + return new LogColumn(xParameter, xConversion, false); } List GetConversions(XElement parameterElement) diff --git a/Apps/PcmLogger/MainForm.Designer.cs b/Apps/PcmLogger/MainForm.Designer.cs index 03890d1a..5ccc1249 100644 --- a/Apps/PcmLogger/MainForm.Designer.cs +++ b/Apps/PcmLogger/MainForm.Designer.cs @@ -51,9 +51,6 @@ private void InitializeComponent() this.parametersTab = new System.Windows.Forms.TabPage(); this.parameterSearch = new System.Windows.Forms.TextBox(); this.parameterGrid = new System.Windows.Forms.DataGridView(); - this.enabledColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.nameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.unitsColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.canTab = new System.Windows.Forms.TabPage(); this.canParameterGrid = new System.Windows.Forms.DataGridView(); this.canParameterNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -64,7 +61,12 @@ private void InitializeComponent() this.selectCanButton = new System.Windows.Forms.Button(); this.debugTab = new System.Windows.Forms.TabPage(); this.debugLog = new System.Windows.Forms.TextBox(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.logValues = new System.Windows.Forms.TextBox(); + this.enabledColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.Zoom = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.nameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.unitsColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -77,6 +79,9 @@ private void InitializeComponent() this.canTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.canParameterGrid)).BeginInit(); this.debugTab.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.SuspendLayout(); this.SuspendLayout(); // // loggerProgress @@ -88,7 +93,7 @@ private void InitializeComponent() this.loggerProgress.Margin = new System.Windows.Forms.Padding(4); this.loggerProgress.MarqueeAnimationSpeed = 0; this.loggerProgress.Name = "loggerProgress"; - this.loggerProgress.Size = new System.Drawing.Size(692, 58); + this.loggerProgress.Size = new System.Drawing.Size(791, 58); this.loggerProgress.Step = 0; this.loggerProgress.Style = System.Windows.Forms.ProgressBarStyle.Marquee; this.loggerProgress.TabIndex = 5; @@ -130,9 +135,9 @@ private void InitializeComponent() // // splitContainer1.Panel2 // - this.splitContainer1.Panel2.Controls.Add(this.logValues); - this.splitContainer1.Size = new System.Drawing.Size(1031, 543); - this.splitContainer1.SplitterDistance = 600; + this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); + this.splitContainer1.Size = new System.Drawing.Size(1130, 609); + this.splitContainer1.SplitterDistance = 577; this.splitContainer1.TabIndex = 9; // // tabs @@ -147,7 +152,7 @@ private void InitializeComponent() this.tabs.Margin = new System.Windows.Forms.Padding(4); this.tabs.Name = "tabs"; this.tabs.SelectedIndex = 0; - this.tabs.Size = new System.Drawing.Size(600, 543); + this.tabs.Size = new System.Drawing.Size(577, 609); this.tabs.TabIndex = 8; // // configurationTab @@ -161,7 +166,7 @@ private void InitializeComponent() this.configurationTab.Location = new System.Drawing.Point(4, 25); this.configurationTab.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.configurationTab.Name = "configurationTab"; - this.configurationTab.Size = new System.Drawing.Size(592, 514); + this.configurationTab.Size = new System.Drawing.Size(569, 580); this.configurationTab.TabIndex = 3; this.configurationTab.Text = "Configuration"; this.configurationTab.UseVisualStyleBackColor = true; @@ -173,7 +178,7 @@ private void InitializeComponent() this.disclaimer.Location = new System.Drawing.Point(5, 178); this.disclaimer.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.disclaimer.Name = "disclaimer"; - this.disclaimer.Size = new System.Drawing.Size(584, 172); + this.disclaimer.Size = new System.Drawing.Size(485, 172); this.disclaimer.TabIndex = 10; this.disclaimer.Text = resources.GetString("disclaimer.Text"); // @@ -184,7 +189,7 @@ private void InitializeComponent() this.logFilePath.Location = new System.Drawing.Point(153, 85); this.logFilePath.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.logFilePath.Name = "logFilePath"; - this.logFilePath.Size = new System.Drawing.Size(65, 17); + this.logFilePath.Size = new System.Drawing.Size(61, 16); this.logFilePath.TabIndex = 7; this.logFilePath.Text = "Directory"; // @@ -227,7 +232,7 @@ private void InitializeComponent() this.deviceDescription.Location = new System.Drawing.Point(300, 11); this.deviceDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.deviceDescription.Name = "deviceDescription"; - this.deviceDescription.Size = new System.Drawing.Size(114, 17); + this.deviceDescription.Size = new System.Drawing.Size(111, 16); this.deviceDescription.TabIndex = 1; this.deviceDescription.Text = "[selected device]"; // @@ -242,7 +247,7 @@ private void InitializeComponent() this.profilesTab.Location = new System.Drawing.Point(4, 25); this.profilesTab.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.profilesTab.Name = "profilesTab"; - this.profilesTab.Size = new System.Drawing.Size(592, 514); + this.profilesTab.Size = new System.Drawing.Size(569, 580); this.profilesTab.TabIndex = 4; this.profilesTab.Text = "Profiles"; this.profilesTab.UseVisualStyleBackColor = true; @@ -292,7 +297,7 @@ private void InitializeComponent() this.profileList.Location = new System.Drawing.Point(3, 39); this.profileList.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.profileList.Name = "profileList"; - this.profileList.Size = new System.Drawing.Size(583, 469); + this.profileList.Size = new System.Drawing.Size(642, 535); this.profileList.TabIndex = 2; this.profileList.SelectedIndexChanged += new System.EventHandler(this.profileList_SelectedIndexChanged); // @@ -325,7 +330,7 @@ private void InitializeComponent() this.parametersTab.Location = new System.Drawing.Point(4, 25); this.parametersTab.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.parametersTab.Name = "parametersTab"; - this.parametersTab.Size = new System.Drawing.Size(592, 514); + this.parametersTab.Size = new System.Drawing.Size(569, 580); this.parametersTab.TabIndex = 2; this.parametersTab.Text = "Parameters"; this.parametersTab.UseVisualStyleBackColor = true; @@ -337,7 +342,7 @@ private void InitializeComponent() this.parameterSearch.Location = new System.Drawing.Point(4, 4); this.parameterSearch.Margin = new System.Windows.Forms.Padding(4); this.parameterSearch.Name = "parameterSearch"; - this.parameterSearch.Size = new System.Drawing.Size(584, 22); + this.parameterSearch.Size = new System.Drawing.Size(561, 22); this.parameterSearch.TabIndex = 1; this.parameterSearch.TextChanged += new System.EventHandler(this.parameterSearch_TextChanged); this.parameterSearch.Enter += new System.EventHandler(this.parameterSearch_Enter); @@ -356,6 +361,7 @@ private void InitializeComponent() this.parameterGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.parameterGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.enabledColumn, + this.Zoom, this.nameColumn, this.unitsColumn}); this.parameterGrid.Location = new System.Drawing.Point(0, 34); @@ -368,38 +374,12 @@ private void InitializeComponent() this.parameterGrid.ShowCellErrors = false; this.parameterGrid.ShowEditingIcon = false; this.parameterGrid.ShowRowErrors = false; - this.parameterGrid.Size = new System.Drawing.Size(589, 478); + this.parameterGrid.Size = new System.Drawing.Size(565, 546); this.parameterGrid.TabIndex = 0; this.parameterGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.parameterGrid_CellContentClick); this.parameterGrid.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.parameterGrid_CellValueChanged); this.parameterGrid.CurrentCellDirtyStateChanged += new System.EventHandler(this.parameterGrid_CurrentCellDirtyStateChanged); // - // enabledColumn - // - this.enabledColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; - this.enabledColumn.FillWeight = 1F; - this.enabledColumn.HeaderText = "Enabled"; - this.enabledColumn.MinimumWidth = 50; - this.enabledColumn.Name = "enabledColumn"; - this.enabledColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - this.enabledColumn.Width = 89; - // - // nameColumn - // - this.nameColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.nameColumn.HeaderText = "Name"; - this.nameColumn.MinimumWidth = 100; - this.nameColumn.Name = "nameColumn"; - this.nameColumn.ReadOnly = true; - // - // unitsColumn - // - this.unitsColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; - this.unitsColumn.FillWeight = 1F; - this.unitsColumn.HeaderText = "Units"; - this.unitsColumn.MinimumWidth = 100; - this.unitsColumn.Name = "unitsColumn"; - // // canTab // this.canTab.Controls.Add(this.canParameterGrid); @@ -409,7 +389,7 @@ private void InitializeComponent() this.canTab.Controls.Add(this.selectCanButton); this.canTab.Location = new System.Drawing.Point(4, 25); this.canTab.Name = "canTab"; - this.canTab.Size = new System.Drawing.Size(592, 514); + this.canTab.Size = new System.Drawing.Size(569, 580); this.canTab.TabIndex = 5; this.canTab.Text = "CAN Bus"; this.canTab.UseVisualStyleBackColor = true; @@ -433,7 +413,7 @@ private void InitializeComponent() this.canParameterGrid.RowHeadersVisible = false; this.canParameterGrid.RowHeadersWidth = 51; this.canParameterGrid.RowTemplate.Height = 24; - this.canParameterGrid.Size = new System.Drawing.Size(586, 448); + this.canParameterGrid.Size = new System.Drawing.Size(645, 514); this.canParameterGrid.TabIndex = 17; this.canParameterGrid.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.canParameterGrid_CellValueChanged); this.canParameterGrid.CurrentCellDirtyStateChanged += new System.EventHandler(this.canParameterGrid_CurrentCellDirtyStateChanged); @@ -462,7 +442,7 @@ private void InitializeComponent() this.disableCanLogging.Checked = true; this.disableCanLogging.Location = new System.Drawing.Point(4, 30); this.disableCanLogging.Name = "disableCanLogging"; - this.disableCanLogging.Size = new System.Drawing.Size(163, 21); + this.disableCanLogging.Size = new System.Drawing.Size(158, 20); this.disableCanLogging.TabIndex = 16; this.disableCanLogging.TabStop = true; this.disableCanLogging.Text = "&Disable CAN Logging"; @@ -474,7 +454,7 @@ private void InitializeComponent() this.enableCanLogging.AutoSize = true; this.enableCanLogging.Location = new System.Drawing.Point(4, 4); this.enableCanLogging.Name = "enableCanLogging"; - this.enableCanLogging.Size = new System.Drawing.Size(160, 21); + this.enableCanLogging.Size = new System.Drawing.Size(154, 20); this.enableCanLogging.TabIndex = 15; this.enableCanLogging.Text = "&Enable CAN Logging"; this.enableCanLogging.UseVisualStyleBackColor = true; @@ -487,7 +467,7 @@ private void InitializeComponent() this.canDeviceDescription.Location = new System.Drawing.Point(373, 32); this.canDeviceDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.canDeviceDescription.Name = "canDeviceDescription"; - this.canDeviceDescription.Size = new System.Drawing.Size(114, 17); + this.canDeviceDescription.Size = new System.Drawing.Size(111, 16); this.canDeviceDescription.TabIndex = 14; this.canDeviceDescription.Text = "[selected device]"; // @@ -510,7 +490,7 @@ private void InitializeComponent() this.debugTab.Margin = new System.Windows.Forms.Padding(4); this.debugTab.Name = "debugTab"; this.debugTab.Padding = new System.Windows.Forms.Padding(4); - this.debugTab.Size = new System.Drawing.Size(592, 514); + this.debugTab.Size = new System.Drawing.Size(569, 580); this.debugTab.TabIndex = 1; this.debugTab.Text = "Debug"; this.debugTab.UseVisualStyleBackColor = true; @@ -524,9 +504,24 @@ private void InitializeComponent() this.debugLog.Name = "debugLog"; this.debugLog.ReadOnly = true; this.debugLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.debugLog.Size = new System.Drawing.Size(584, 506); + this.debugLog.Size = new System.Drawing.Size(561, 572); this.debugLog.TabIndex = 0; // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.logValues); + this.splitContainer2.Panel1MinSize = 200; + this.splitContainer2.Panel2MinSize = 200; + this.splitContainer2.Size = new System.Drawing.Size(549, 609); + this.splitContainer2.SplitterDistance = 250; + this.splitContainer2.TabIndex = 1; + // // logValues // this.logValues.Dock = System.Windows.Forms.DockStyle.Fill; @@ -535,14 +530,50 @@ private void InitializeComponent() this.logValues.Multiline = true; this.logValues.Name = "logValues"; this.logValues.ReadOnly = true; - this.logValues.Size = new System.Drawing.Size(427, 543); + this.logValues.Size = new System.Drawing.Size(250, 609); this.logValues.TabIndex = 0; // + // enabledColumn + // + this.enabledColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.enabledColumn.FillWeight = 1F; + this.enabledColumn.HeaderText = "Enable"; + this.enabledColumn.MinimumWidth = 70; + this.enabledColumn.Name = "enabledColumn"; + this.enabledColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.enabledColumn.Width = 79; + // + // Zoom + // + this.Zoom.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.Zoom.HeaderText = "Zoom"; + this.Zoom.MinimumWidth = 70; + this.Zoom.Name = "Zoom"; + this.Zoom.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Zoom.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.Zoom.Width = 71; + // + // nameColumn + // + this.nameColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.nameColumn.HeaderText = "Name"; + this.nameColumn.MinimumWidth = 200; + this.nameColumn.Name = "nameColumn"; + this.nameColumn.ReadOnly = true; + // + // unitsColumn + // + this.unitsColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.unitsColumn.FillWeight = 1F; + this.unitsColumn.HeaderText = "Units"; + this.unitsColumn.MinimumWidth = 100; + this.unitsColumn.Name = "unitsColumn"; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1033, 622); + this.ClientSize = new System.Drawing.Size(1132, 688); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.loggerProgress); this.Controls.Add(this.startStopSaving); @@ -553,7 +584,6 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.MainForm_Load); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.tabs.ResumeLayout(false); @@ -568,6 +598,10 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.canParameterGrid)).EndInit(); this.debugTab.ResumeLayout(false); this.debugTab.PerformLayout(); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); this.ResumeLayout(false); } @@ -591,9 +625,6 @@ private void InitializeComponent() private System.Windows.Forms.TabPage parametersTab; private System.Windows.Forms.TextBox parameterSearch; private System.Windows.Forms.DataGridView parameterGrid; - private System.Windows.Forms.DataGridViewCheckBoxColumn enabledColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn nameColumn; - private System.Windows.Forms.DataGridViewComboBoxColumn unitsColumn; private System.Windows.Forms.TextBox logValues; private System.Windows.Forms.TabPage profilesTab; private System.Windows.Forms.Button removeProfileButton; @@ -610,6 +641,11 @@ private void InitializeComponent() private System.Windows.Forms.Button setDirectory; private System.Windows.Forms.Label deviceDescription; private System.Windows.Forms.TabControl tabs; + private System.Windows.Forms.SplitContainer splitContainer2; + private System.Windows.Forms.DataGridViewCheckBoxColumn enabledColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn Zoom; + private System.Windows.Forms.DataGridViewTextBoxColumn nameColumn; + private System.Windows.Forms.DataGridViewComboBoxColumn unitsColumn; } } diff --git a/Apps/PcmLogger/MainForm.LoggingThread.cs b/Apps/PcmLogger/MainForm.LoggingThread.cs index 0a8b31b4..abdba3bc 100644 --- a/Apps/PcmLogger/MainForm.LoggingThread.cs +++ b/Apps/PcmLogger/MainForm.LoggingThread.cs @@ -11,6 +11,22 @@ namespace PcmHacking { + public class ZoomedParameter + { + public LogColumn LogColumn { get; private set; } + public string Value { get; private set; } + public string Name { get; private set; } + public string Units { get; private set; } + + public ZoomedParameter(LogColumn logColumn, string value, string name, string units) + { + LogColumn = logColumn; + Value = value; + Name = name; + Units = units; + } + } + partial class MainForm { private ConcurrentQueue>> logRowQueue = new ConcurrentQueue>>(); @@ -40,8 +56,10 @@ enum LogState /// Create a string that will look reasonable in the UI's main text box. /// TODO: Use a grid instead. /// - private string FormatValuesForTextBox(Logger logger, IEnumerable rowValues) + private Tuple> FormatValuesForTextBox(Logger logger, IEnumerable rowValues) { + List zoomedParameters = new List(); + StringBuilder builder = new StringBuilder(); IEnumerator rowValueEnumerator = rowValues.GetEnumerator(); foreach (ParameterGroup group in logger.DpidConfiguration.ParameterGroups) @@ -54,6 +72,16 @@ private string FormatValuesForTextBox(Logger logger, IEnumerable rowValu builder.Append(column.Conversion.Units); builder.Append('\t'); builder.AppendLine(column.Parameter.Name); + + if (column.Zoom) + { + zoomedParameters.Add( + new ZoomedParameter( + column, + rowValueEnumerator.Current, + column.Parameter.Name, + column.Conversion.Units)); + } } } @@ -80,7 +108,7 @@ private string FormatValuesForTextBox(Logger logger, IEnumerable rowValu builder.AppendLine((now - lastLogTime).TotalMilliseconds.ToString("0.00") + "\tms\tQuery time"); lastLogTime = now; - return builder.ToString(); + return new Tuple>(builder.ToString(), zoomedParameters); } private async Task RecreateLogger(ParameterDatabase parameterDatabase) @@ -377,12 +405,15 @@ private void LogFileWriterThread(object threadContext) row.Item2.WriteLine(row.Item3); } - string formattedValues = FormatValuesForTextBox(row.Item1, row.Item3); + Tuple> values = FormatValuesForTextBox( + row.Item1, // logger + row.Item3); // row values this.BeginInvoke((MethodInvoker) delegate () { - this.logValues.Text = formattedValues; + this.logValues.Text = values.Item1; + this.DrawZoomedParameters(values.Item2); }); } } diff --git a/Apps/PcmLogger/MainForm.ParameterGrid.cs b/Apps/PcmLogger/MainForm.ParameterGrid.cs index 71203681..972f5c75 100644 --- a/Apps/PcmLogger/MainForm.ParameterGrid.cs +++ b/Apps/PcmLogger/MainForm.ParameterGrid.cs @@ -65,6 +65,7 @@ private void UpdateGridFromProfile() foreach (DataGridViewRow row in this.parameterGrid.Rows) { row.Cells[0].Value = false; + row.Cells[1].Value = false; } foreach (LogColumn column in this.currentProfile.Columns) @@ -74,6 +75,10 @@ private void UpdateGridFromProfile() if (row != null) { row.Cells[0].Value = true; + if (column.Zoom) + { + row.Cells[1].Value = true; + } DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(row.Cells[2]); Conversion profileConversion = column.Conversion; @@ -126,6 +131,8 @@ private void LogProfileChanged() this.ResetProfile(); + this.ClearZoomPanel(); + this.CreateProfileFromGrid(); this.SetDirtyFlag(true); @@ -155,12 +162,14 @@ private void CreateProfileFromGrid() } } - LogColumn column = new LogColumn(parameter, conversion); + bool zoom = (bool)row.Cells[1].Value; + LogColumn column = new LogColumn(parameter, conversion, zoom); this.currentProfile.AddColumn(column); } } } + #region Parameter search private bool showSearchPrompt = true; private void ShowSearchPrompt() @@ -214,5 +223,6 @@ private void parameterSearch_TextChanged(object sender, EventArgs e) } } } + #endregion } } diff --git a/Apps/PcmLogger/MainForm.Zoom.cs b/Apps/PcmLogger/MainForm.Zoom.cs new file mode 100644 index 00000000..592c4eb7 --- /dev/null +++ b/Apps/PcmLogger/MainForm.Zoom.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PcmHacking +{ + public partial class MainForm + { + private static Brush textBrush = Brushes.White; + private static Font bigFont = new Font("Arial", 32); + private static Font littleFont = new Font("Arial", 16); + private const int margin = 5; + + public void ClearZoomPanel() + { + var canvas = this.splitContainer2.Panel2; + using (var graphics = canvas.CreateGraphics()) + { + graphics.FillRectangle(new SolidBrush(Color.Black), canvas.DisplayRectangle); + } + } + + public void DrawZoomedParameters(List list) + { + + var canvas = this.splitContainer2.Panel2; + using (var graphics = canvas.CreateGraphics()) + using (var buffer = BufferedGraphicsManager.Current.Allocate(graphics, canvas.DisplayRectangle)) + { + graphics.FillRectangle(new SolidBrush(Color.Black), canvas.DisplayRectangle); + var rowHeight = canvas.DisplayRectangle.Height / list.Count; + + for(int row = 0; row < list.Count; row++) + { + var centerX = canvas.DisplayRectangle.Width / 2; + var centerY = ((rowHeight) / 2) + row * rowHeight; + + StringFormat format = new StringFormat(); + + string valueString = list[row].Value; + SizeF valueSize = buffer.Graphics.MeasureString(valueString, bigFont); + float valueX = centerX - valueSize.Width / 2; + float valueY = centerY - valueSize.Height / 2; + buffer.Graphics.DrawString(valueString, bigFont, textBrush, valueX, valueY, format); + + string nameString = list[row].Name; + SizeF nameSize = buffer.Graphics.MeasureString(nameString, littleFont); + float nameX = centerX - nameSize.Width / 2; + float nameY = centerY - ((valueSize.Height / 2) + nameSize.Width / 2 + margin); + buffer.Graphics.DrawString(nameString, littleFont, textBrush, nameX, nameY, format); + + string unitsString = list[row].Units; + SizeF unitsSize = buffer.Graphics.MeasureString(unitsString, littleFont); + float unitsX = centerX - unitsSize.Width / 2; + float unitsY = centerY + (valueSize.Height / 2) + margin; + buffer.Graphics.DrawString(unitsString, littleFont, textBrush, unitsX, unitsY, format); + } + + buffer.Render(); + } + + } + } +} diff --git a/Apps/PcmLogger/MainForm.resx b/Apps/PcmLogger/MainForm.resx index 7ff8249d..7f8c2125 100644 --- a/Apps/PcmLogger/MainForm.resx +++ b/Apps/PcmLogger/MainForm.resx @@ -130,6 +130,9 @@ Thanks! True + + True + True @@ -142,4 +145,22 @@ Thanks! True + + True + + + True + + + True + + + True + + + True + + + True + \ No newline at end of file diff --git a/Apps/PcmLogger/Parameters.Math.xml b/Apps/PcmLogger/Parameters.Math.xml index 83d33a90..72c54a9c 100644 --- a/Apps/PcmLogger/Parameters.Math.xml +++ b/Apps/PcmLogger/Parameters.Math.xml @@ -8,7 +8,7 @@ xParameterConversion="g/s" yParameterId="EngineSpeed" yParameterConversion="RPM"> - + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - Form - + Form @@ -88,6 +86,9 @@ Form + + Form + diff --git a/Apps/Tests/LoggingTests.cs b/Apps/Tests/LoggingTests.cs index 80f3199b..d8e5a88e 100644 --- a/Apps/Tests/LoggingTests.cs +++ b/Apps/Tests/LoggingTests.cs @@ -27,10 +27,10 @@ public void DecodeDpid() Parameter signed16 = new RamParameter("U8", "signed 16-bit", "", "int16", false, conversions, GetAddress(0)); Parameter unsigned16 = new RamParameter("U16", "unsigned 16-bit", "", "uint16", false, conversions, GetAddress(0)); - LogColumn signed8Column = new LogColumn(signed8, conversion); - LogColumn unsigned8Column = new LogColumn(unsigned8, conversion); - LogColumn signed16Column = new LogColumn(signed16, conversion); - LogColumn unsigned16Column = new LogColumn(unsigned16, conversion); + LogColumn signed8Column = new LogColumn(signed8, conversion, false); + LogColumn unsigned8Column = new LogColumn(unsigned8, conversion, false); + LogColumn signed16Column = new LogColumn(signed16, conversion, false); + LogColumn unsigned16Column = new LogColumn(unsigned16, conversion, false); ParameterGroup group = new ParameterGroup(0); diff --git a/Apps/Tests/MathTests.cs b/Apps/Tests/MathTests.cs index 61634e89..6e60a857 100644 --- a/Apps/Tests/MathTests.cs +++ b/Apps/Tests/MathTests.cs @@ -16,13 +16,15 @@ public void MathValueTest() LogColumn rpm = new LogColumn( new PidParameter("EngSpeed", "Engine Speed", "", "uint16", false, new Conversion[] { rpmConversion }, 0x3456, new List()), - rpmConversion); + rpmConversion, + false); Conversion mafConversion = new Conversion("RPM", "x", "0"); LogColumn maf = new LogColumn( new PidParameter("MAF", "Mass Air Flow", "", "uint16", false, new Conversion[] { mafConversion }, 0x1234, new List()), - mafConversion); + mafConversion, + false); MathParameter load = new MathParameter( "id", @@ -32,7 +34,7 @@ public void MathValueTest() rpm, maf); - LogColumn mathColumn = new LogColumn(load, load.Conversions.First()); + LogColumn mathColumn = new LogColumn(load, load.Conversions.First(), false); DpidConfiguration profile = new DpidConfiguration(); profile.ParameterGroups.Add(new ParameterGroup(0xFE));