backwards messurements | update aggregated results in API

This commit is contained in:
Stoyan Zlatev
2023-10-09 15:13:10 +02:00
parent 716e78d5b5
commit 6370357f6f
10 changed files with 637 additions and 120 deletions
+263 -67
View File
@@ -31,7 +31,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.automaticCalibrationTabControl = new System.Windows.Forms.TabControl();
@@ -55,10 +57,13 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.btnStopRecord = new System.Windows.Forms.Button();
this.btnStartRecord = new System.Windows.Forms.Button();
this.txtCurrentTofs = new System.Windows.Forms.TextBox();
this.AutomaticCalibrationTab = new System.Windows.Forms.TabPage();
this.calibrationTab = new System.Windows.Forms.TabPage();
this.automaticContentBox = new System.Windows.Forms.RichTextBox();
this.autometicControlsSplitter = new System.Windows.Forms.Splitter();
this.automaticControlsPanel = new System.Windows.Forms.Panel();
this.backwardsStepMS = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.stopBackwardsBtn = new System.Windows.Forms.Button();
this.startBackwardBtn = new System.Windows.Forms.Button();
this.saveSettingsBtn = new System.Windows.Forms.Button();
this.messurementDauerMS = new System.Windows.Forms.TextBox();
@@ -69,7 +74,20 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.label2 = new System.Windows.Forms.Label();
this.GMHPort = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.resultsTab = new System.Windows.Forms.TabPage();
this.temperatureChecksTab = new System.Windows.Forms.TabPage();
this.temperatureChecksGridView = new System.Windows.Forms.DataGridView();
this.TemperatureCheck_Pcb = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_PrevC = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_NextC = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_CurrentC = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_CalcC = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_DiffC = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_PrevTOF = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_CurrentTOF = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TemperatureCheck_NextTOF = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.backwardsPcbs = new System.Windows.Forms.ToolStripMenuItem();
this.lutTab = new System.Windows.Forms.TabPage();
this.aggregationsGridView = new System.Windows.Forms.DataGridView();
this.PcbId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Avg_Nr = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -82,15 +100,17 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.saveSelectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
this.stopBackwardsBtn = new System.Windows.Forms.Button();
this.automaticCalibrationTabControl.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabPage3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudRef)).BeginInit();
this.AutomaticCalibrationTab.SuspendLayout();
this.calibrationTab.SuspendLayout();
this.automaticControlsPanel.SuspendLayout();
this.resultsTab.SuspendLayout();
this.temperatureChecksTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.temperatureChecksGridView)).BeginInit();
this.menuStrip1.SuspendLayout();
this.lutTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.aggregationsGridView)).BeginInit();
this.resultsMenu.SuspendLayout();
this.SuspendLayout();
@@ -109,8 +129,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.automaticCalibrationTabControl.Controls.Add(this.tabPage1);
this.automaticCalibrationTabControl.Controls.Add(this.tabPage2);
this.automaticCalibrationTabControl.Controls.Add(this.tabPage3);
this.automaticCalibrationTabControl.Controls.Add(this.AutomaticCalibrationTab);
this.automaticCalibrationTabControl.Controls.Add(this.resultsTab);
this.automaticCalibrationTabControl.Controls.Add(this.calibrationTab);
this.automaticCalibrationTabControl.Controls.Add(this.temperatureChecksTab);
this.automaticCalibrationTabControl.Controls.Add(this.lutTab);
this.automaticCalibrationTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.automaticCalibrationTabControl.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.automaticCalibrationTabControl.Location = new System.Drawing.Point(0, 24);
@@ -340,18 +361,18 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.txtCurrentTofs.Size = new System.Drawing.Size(380, 230);
this.txtCurrentTofs.TabIndex = 49;
//
// AutomaticCalibrationTab
// calibrationTab
//
this.AutomaticCalibrationTab.BackColor = System.Drawing.SystemColors.Window;
this.AutomaticCalibrationTab.Controls.Add(this.automaticContentBox);
this.AutomaticCalibrationTab.Controls.Add(this.autometicControlsSplitter);
this.AutomaticCalibrationTab.Controls.Add(this.automaticControlsPanel);
this.AutomaticCalibrationTab.Location = new System.Drawing.Point(4, 25);
this.AutomaticCalibrationTab.Margin = new System.Windows.Forms.Padding(0);
this.AutomaticCalibrationTab.Name = "AutomaticCalibrationTab";
this.AutomaticCalibrationTab.Size = new System.Drawing.Size(1217, 647);
this.AutomaticCalibrationTab.TabIndex = 3;
this.AutomaticCalibrationTab.Text = "Automatic Calibration";
this.calibrationTab.BackColor = System.Drawing.SystemColors.Window;
this.calibrationTab.Controls.Add(this.automaticContentBox);
this.calibrationTab.Controls.Add(this.autometicControlsSplitter);
this.calibrationTab.Controls.Add(this.automaticControlsPanel);
this.calibrationTab.Location = new System.Drawing.Point(4, 25);
this.calibrationTab.Margin = new System.Windows.Forms.Padding(0);
this.calibrationTab.Name = "calibrationTab";
this.calibrationTab.Size = new System.Drawing.Size(1217, 647);
this.calibrationTab.TabIndex = 3;
this.calibrationTab.Text = "Automatic Calibration";
//
// automaticContentBox
//
@@ -377,6 +398,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
// automaticControlsPanel
//
this.automaticControlsPanel.BackColor = System.Drawing.SystemColors.Menu;
this.automaticControlsPanel.Controls.Add(this.backwardsStepMS);
this.automaticControlsPanel.Controls.Add(this.label8);
this.automaticControlsPanel.Controls.Add(this.stopBackwardsBtn);
this.automaticControlsPanel.Controls.Add(this.startBackwardBtn);
this.automaticControlsPanel.Controls.Add(this.saveSettingsBtn);
@@ -395,12 +418,52 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.automaticControlsPanel.Size = new System.Drawing.Size(328, 647);
this.automaticControlsPanel.TabIndex = 0;
//
// backwardsStepMS
//
this.backwardsStepMS.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.backwardsStepMS.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.backwardsStepMS.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.backwardsStepMS.Location = new System.Drawing.Point(5, 166);
this.backwardsStepMS.Margin = new System.Windows.Forms.Padding(0);
this.backwardsStepMS.Name = "backwardsStepMS";
this.backwardsStepMS.Size = new System.Drawing.Size(318, 24);
this.backwardsStepMS.TabIndex = 20;
//
// label8
//
this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label8.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.label8.Location = new System.Drawing.Point(5, 149);
this.label8.Margin = new System.Windows.Forms.Padding(5);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(318, 18);
this.label8.TabIndex = 19;
this.label8.Text = "Backwards step (ms)";
this.label8.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// stopBackwardsBtn
//
this.stopBackwardsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stopBackwardsBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stopBackwardsBtn.Location = new System.Drawing.Point(5, 379);
this.stopBackwardsBtn.Margin = new System.Windows.Forms.Padding(5);
this.stopBackwardsBtn.Name = "stopBackwardsBtn";
this.stopBackwardsBtn.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5);
this.stopBackwardsBtn.Size = new System.Drawing.Size(318, 36);
this.stopBackwardsBtn.TabIndex = 18;
this.stopBackwardsBtn.Text = "Stop backwards";
this.stopBackwardsBtn.UseVisualStyleBackColor = true;
this.stopBackwardsBtn.Click += new System.EventHandler(this.StopBackwardsBtn_Click);
//
// startBackwardBtn
//
this.startBackwardBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.startBackwardBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.startBackwardBtn.Location = new System.Drawing.Point(5, 287);
this.startBackwardBtn.Location = new System.Drawing.Point(5, 333);
this.startBackwardBtn.Margin = new System.Windows.Forms.Padding(5);
this.startBackwardBtn.Name = "startBackwardBtn";
this.startBackwardBtn.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5);
@@ -415,7 +478,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.saveSettingsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.saveSettingsBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.saveSettingsBtn.Location = new System.Drawing.Point(5, 149);
this.saveSettingsBtn.Location = new System.Drawing.Point(5, 195);
this.saveSettingsBtn.Margin = new System.Windows.Forms.Padding(5);
this.saveSettingsBtn.Name = "saveSettingsBtn";
this.saveSettingsBtn.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5);
@@ -431,7 +494,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
| System.Windows.Forms.AnchorStyles.Right)));
this.messurementDauerMS.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.messurementDauerMS.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.messurementDauerMS.Location = new System.Drawing.Point(5, 114);
this.messurementDauerMS.Location = new System.Drawing.Point(5, 120);
this.messurementDauerMS.Margin = new System.Windows.Forms.Padding(0);
this.messurementDauerMS.Name = "messurementDauerMS";
this.messurementDauerMS.Size = new System.Drawing.Size(318, 24);
@@ -442,7 +505,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label3.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.label3.Location = new System.Drawing.Point(5, 97);
this.label3.Location = new System.Drawing.Point(5, 103);
this.label3.Margin = new System.Windows.Forms.Padding(5);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(318, 18);
@@ -455,7 +518,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.stopAutomaticBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stopAutomaticBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stopAutomaticBtn.Location = new System.Drawing.Point(5, 241);
this.stopAutomaticBtn.Location = new System.Drawing.Point(5, 287);
this.stopAutomaticBtn.Margin = new System.Windows.Forms.Padding(5);
this.stopAutomaticBtn.Name = "stopAutomaticBtn";
this.stopAutomaticBtn.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5);
@@ -470,7 +533,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.startAutomaticBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.startAutomaticBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.startAutomaticBtn.Location = new System.Drawing.Point(5, 195);
this.startAutomaticBtn.Location = new System.Drawing.Point(5, 241);
this.startAutomaticBtn.Margin = new System.Windows.Forms.Padding(5);
this.startAutomaticBtn.Name = "startAutomaticBtn";
this.startAutomaticBtn.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5);
@@ -486,7 +549,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
| System.Windows.Forms.AnchorStyles.Right)));
this.messurementStepMS.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.messurementStepMS.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.messurementStepMS.Location = new System.Drawing.Point(5, 68);
this.messurementStepMS.Location = new System.Drawing.Point(5, 74);
this.messurementStepMS.Margin = new System.Windows.Forms.Padding(0);
this.messurementStepMS.Name = "messurementStepMS";
this.messurementStepMS.Size = new System.Drawing.Size(318, 24);
@@ -497,7 +560,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.label2.Location = new System.Drawing.Point(5, 51);
this.label2.Location = new System.Drawing.Point(5, 57);
this.label2.Margin = new System.Windows.Forms.Padding(5);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(318, 18);
@@ -511,7 +574,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
| System.Windows.Forms.AnchorStyles.Right)));
this.GMHPort.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.GMHPort.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.GMHPort.Location = new System.Drawing.Point(5, 22);
this.GMHPort.Location = new System.Drawing.Point(5, 27);
this.GMHPort.Margin = new System.Windows.Forms.Padding(0);
this.GMHPort.MinimumSize = new System.Drawing.Size(2, 25);
this.GMHPort.Name = "GMHPort";
@@ -523,7 +586,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.label1.Location = new System.Drawing.Point(5, 5);
this.label1.Location = new System.Drawing.Point(5, 10);
this.label1.Margin = new System.Windows.Forms.Padding(5);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(318, 18);
@@ -531,31 +594,159 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.label1.Text = "Messgerät (COM port)";
this.label1.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// resultsTab
// temperatureChecksTab
//
this.resultsTab.Controls.Add(this.aggregationsGridView);
this.resultsTab.Controls.Add(this.resultsMenu);
this.resultsTab.Location = new System.Drawing.Point(4, 25);
this.resultsTab.Margin = new System.Windows.Forms.Padding(0);
this.resultsTab.Name = "resultsTab";
this.resultsTab.Size = new System.Drawing.Size(1217, 647);
this.resultsTab.TabIndex = 4;
this.resultsTab.Text = "Results";
this.resultsTab.UseVisualStyleBackColor = true;
this.temperatureChecksTab.Controls.Add(this.temperatureChecksGridView);
this.temperatureChecksTab.Controls.Add(this.menuStrip1);
this.temperatureChecksTab.Location = new System.Drawing.Point(4, 25);
this.temperatureChecksTab.Margin = new System.Windows.Forms.Padding(0);
this.temperatureChecksTab.Name = "temperatureChecksTab";
this.temperatureChecksTab.Size = new System.Drawing.Size(1217, 647);
this.temperatureChecksTab.TabIndex = 5;
this.temperatureChecksTab.Text = "Temperature check";
this.temperatureChecksTab.UseVisualStyleBackColor = true;
//
// temperatureChecksGridView
//
this.temperatureChecksGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
this.temperatureChecksGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.ButtonFace;
dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.temperatureChecksGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.temperatureChecksGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.TemperatureCheck_Pcb,
this.TemperatureCheck_PrevC,
this.TemperatureCheck_NextC,
this.TemperatureCheck_CurrentC,
this.TemperatureCheck_CalcC,
this.TemperatureCheck_DiffC,
this.TemperatureCheck_PrevTOF,
this.TemperatureCheck_CurrentTOF,
this.TemperatureCheck_NextTOF});
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.temperatureChecksGridView.DefaultCellStyle = dataGridViewCellStyle5;
this.temperatureChecksGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.temperatureChecksGridView.Location = new System.Drawing.Point(0, 24);
this.temperatureChecksGridView.Name = "temperatureChecksGridView";
this.temperatureChecksGridView.Size = new System.Drawing.Size(1217, 623);
this.temperatureChecksGridView.TabIndex = 1;
//
// TemperatureCheck_Pcb
//
this.TemperatureCheck_Pcb.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_Pcb.HeaderText = "Pcb Id";
this.TemperatureCheck_Pcb.Name = "TemperatureCheck_Pcb";
this.TemperatureCheck_Pcb.ReadOnly = true;
//
// TemperatureCheck_PrevC
//
this.TemperatureCheck_PrevC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_PrevC.HeaderText = "Prev °C";
this.TemperatureCheck_PrevC.Name = "TemperatureCheck_PrevC";
this.TemperatureCheck_PrevC.ReadOnly = true;
//
// TemperatureCheck_NextC
//
this.TemperatureCheck_NextC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_NextC.HeaderText = "Next °C";
this.TemperatureCheck_NextC.Name = "TemperatureCheck_NextC";
this.TemperatureCheck_NextC.ReadOnly = true;
//
// TemperatureCheck_CurrentC
//
this.TemperatureCheck_CurrentC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_CurrentC.HeaderText = "Actual °C";
this.TemperatureCheck_CurrentC.Name = "TemperatureCheck_CurrentC";
this.TemperatureCheck_CurrentC.ReadOnly = true;
//
// TemperatureCheck_CalcC
//
this.TemperatureCheck_CalcC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_CalcC.HeaderText = "Calc °C";
this.TemperatureCheck_CalcC.Name = "TemperatureCheck_CalcC";
this.TemperatureCheck_CalcC.ReadOnly = true;
//
// TemperatureCheck_DiffC
//
this.TemperatureCheck_DiffC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_DiffC.HeaderText = "°C diff.";
this.TemperatureCheck_DiffC.Name = "TemperatureCheck_DiffC";
this.TemperatureCheck_DiffC.ReadOnly = true;
//
// TemperatureCheck_PrevTOF
//
this.TemperatureCheck_PrevTOF.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_PrevTOF.HeaderText = "Prev TOF";
this.TemperatureCheck_PrevTOF.Name = "TemperatureCheck_PrevTOF";
this.TemperatureCheck_PrevTOF.ReadOnly = true;
//
// TemperatureCheck_CurrentTOF
//
this.TemperatureCheck_CurrentTOF.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_CurrentTOF.HeaderText = "Current TOF";
this.TemperatureCheck_CurrentTOF.Name = "TemperatureCheck_CurrentTOF";
this.TemperatureCheck_CurrentTOF.ReadOnly = true;
//
// TemperatureCheck_NextTOF
//
this.TemperatureCheck_NextTOF.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.TemperatureCheck_NextTOF.HeaderText = "Next TOF";
this.TemperatureCheck_NextTOF.Name = "TemperatureCheck_NextTOF";
this.TemperatureCheck_NextTOF.ReadOnly = true;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.backwardsPcbs});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1217, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// backwardsPcbs
//
this.backwardsPcbs.Name = "backwardsPcbs";
this.backwardsPcbs.Size = new System.Drawing.Size(73, 20);
this.backwardsPcbs.Text = "Select pcb";
this.backwardsPcbs.Click += new System.EventHandler(this.BackwardsPcb_Click);
//
// lutTab
//
this.lutTab.Controls.Add(this.aggregationsGridView);
this.lutTab.Controls.Add(this.resultsMenu);
this.lutTab.Location = new System.Drawing.Point(4, 25);
this.lutTab.Margin = new System.Windows.Forms.Padding(0);
this.lutTab.Name = "lutTab";
this.lutTab.Size = new System.Drawing.Size(1217, 647);
this.lutTab.TabIndex = 4;
this.lutTab.Text = "Temperature LUT";
this.lutTab.UseVisualStyleBackColor = true;
//
// aggregationsGridView
//
this.aggregationsGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.aggregationsGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
this.aggregationsGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.aggregationsGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.aggregationsGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6;
this.aggregationsGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.aggregationsGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.PcbId,
@@ -655,21 +846,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.mainMenuStrip.TabIndex = 57;
this.mainMenuStrip.Text = "menuStrip1";
//
// stopBackwardsBtn
//
this.stopBackwardsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stopBackwardsBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stopBackwardsBtn.Location = new System.Drawing.Point(5, 333);
this.stopBackwardsBtn.Margin = new System.Windows.Forms.Padding(5);
this.stopBackwardsBtn.Name = "stopBackwardsBtn";
this.stopBackwardsBtn.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5);
this.stopBackwardsBtn.Size = new System.Drawing.Size(318, 36);
this.stopBackwardsBtn.TabIndex = 18;
this.stopBackwardsBtn.Text = "Stop backwards";
this.stopBackwardsBtn.UseVisualStyleBackColor = true;
this.stopBackwardsBtn.Click += new System.EventHandler(this.stopBackwardsBtn_Click);
//
// FrmTempMeter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -688,11 +864,16 @@ namespace Xylem.Common.Ui.GenesisToolBox
this.tabPage3.ResumeLayout(false);
this.tabPage3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudRef)).EndInit();
this.AutomaticCalibrationTab.ResumeLayout(false);
this.calibrationTab.ResumeLayout(false);
this.automaticControlsPanel.ResumeLayout(false);
this.automaticControlsPanel.PerformLayout();
this.resultsTab.ResumeLayout(false);
this.resultsTab.PerformLayout();
this.temperatureChecksTab.ResumeLayout(false);
this.temperatureChecksTab.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.temperatureChecksGridView)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.lutTab.ResumeLayout(false);
this.lutTab.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.aggregationsGridView)).EndInit();
this.resultsMenu.ResumeLayout(false);
this.resultsMenu.PerformLayout();
@@ -725,7 +906,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
private System.Windows.Forms.Button btnStopRecord;
private System.Windows.Forms.Button btnStartRecord;
private System.Windows.Forms.TextBox txtCurrentTofs;
private System.Windows.Forms.TabPage AutomaticCalibrationTab;
private System.Windows.Forms.TabPage calibrationTab;
private System.Windows.Forms.Timer timer3;
private System.Windows.Forms.MenuStrip mainMenuStrip;
private System.Windows.Forms.RichTextBox automaticContentBox;
@@ -740,7 +921,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
private System.Windows.Forms.TextBox messurementDauerMS;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button saveSettingsBtn;
private System.Windows.Forms.TabPage resultsTab;
private System.Windows.Forms.TabPage lutTab;
private System.Windows.Forms.DataGridView aggregationsGridView;
private System.Windows.Forms.MenuStrip resultsMenu;
private System.Windows.Forms.ToolStripMenuItem updateViewToolStripMenuItem;
@@ -753,5 +934,20 @@ namespace Xylem.Common.Ui.GenesisToolBox
private System.Windows.Forms.ToolStripMenuItem loadPcbToolStripMenuItem;
private System.Windows.Forms.Button startBackwardBtn;
private System.Windows.Forms.Button stopBackwardsBtn;
private System.Windows.Forms.TabPage temperatureChecksTab;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem backwardsPcbs;
private System.Windows.Forms.DataGridView temperatureChecksGridView;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_Pcb;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_PrevC;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_NextC;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_CurrentC;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_CalcC;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_DiffC;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_PrevTOF;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_CurrentTOF;
private System.Windows.Forms.DataGridViewTextBoxColumn TemperatureCheck_NextTOF;
private System.Windows.Forms.TextBox backwardsStepMS;
private System.Windows.Forms.Label label8;
}
}
+102 -4
View File
@@ -559,7 +559,7 @@
{
this.automaticCalibration = new AutomaticTemperatureCalibration(null, this);
foreach (var pcbText in this.automaticCalibration.AvailablePcbs())
foreach (var pcbText in this.automaticCalibration.AvailableAggregationPcbs())
{
var dropdownPcbId = new ToolStripMenuItem(pcbText);
dropdownPcbId.Click += DropdownPcbId_Click;
@@ -567,6 +567,14 @@
this.loadPcbToolStripMenuItem.DropDownItems.Add(dropdownPcbId);
}
foreach (var pcbText in this.automaticCalibration.AvailableCheckPcbs())
{
var dropdownPcbId = new ToolStripMenuItem(pcbText);
dropdownPcbId.Click += this.BackwardsPcb_Click;
this.backwardsPcbs.DropDownItems.Add(dropdownPcbId);
}
this.aggregationsGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.WhiteSmoke;
this.mainMenuStrip.Padding = new Padding(5);
@@ -660,6 +668,7 @@
this.GMHPort.Text = Appsettings.GMHPort.ToString();
this.messurementStepMS.Text = Appsettings.MessurementStep.ToString();
this.messurementDauerMS.Text = Appsettings.MessurementDauer.ToString();
this.backwardsStepMS.Text = Appsettings.BackwardsStepMS.ToString();
};
this.SetEnabled(ProgrammState.Start);
@@ -734,6 +743,9 @@
this.startAutomaticBtn.Enabled = true;
this.stopAutomaticBtn.Enabled = false;
this.startBackwardBtn.Enabled = true;
this.stopBackwardsBtn.Enabled = false;
}
private void StartAutomaticBtn_Clicked(object sender, EventArgs args)
@@ -759,6 +771,7 @@
this.automaticCalibration.StartMessuring();
this.SetEnabled(ProgrammState.RecordRuning);
this.startBackwardBtn.Enabled = false;
this.startAutomaticBtn.Enabled = false;
this.stopAutomaticBtn.Enabled = true;
}
@@ -773,6 +786,7 @@
this.SetEnabled(ProgrammState.RecordStoped);
this.startBackwardBtn.Enabled = true;
this.startAutomaticBtn.Enabled = true;
this.stopAutomaticBtn.Enabled = false;
}
@@ -842,7 +856,7 @@
return tofs.Average();
}
return 0;
return 1;
}
protected override void OnFormClosed(FormClosedEventArgs e)
@@ -865,6 +879,11 @@
Appsettings.MessurementDauer = msDauer;
}
if (int.TryParse($"{this.backwardsStepMS.Text}", out int bwStep))
{
Appsettings.BackwardsStepMS = bwStep;
}
Appsettings.SaveSettings();
}
@@ -987,12 +1006,91 @@
private void StartBackwardBtn_Click(Object sender, EventArgs e)
{
if (this.currentGenesis is null)
{
MessageBox.Show(this, "Water meter not connected!", "Start aborted", MessageBoxButtons.OK);
return;
}
this.automaticCalibration = new AutomaticTemperatureCalibration(this.currentGenesis?.PcbId, this);
this.automaticCalibration.StartBackward();
this.SetEnabled(ProgrammState.RecordRuning);
this.startAutomaticBtn.Enabled = false;
this.startBackwardBtn.Enabled = false;
this.stopBackwardsBtn.Enabled = true;
}
private void stopBackwardsBtn_Click(Object sender, EventArgs e)
=> this.automaticCalibration.StopMessuring();
private void StopBackwardsBtn_Click(Object sender, EventArgs e)
{
this.automaticCalibration.StopMessuring();
this.SetEnabled(ProgrammState.RecordStoped);
this.startAutomaticBtn.Enabled = true;
this.startBackwardBtn.Enabled = true;
this.stopBackwardsBtn.Enabled = false;
}
private void BackwardsPcb_Click(Object sender, EventArgs e)
{
if (this.automaticCalibration is null)
{
this.automaticCalibration = new AutomaticTemperatureCalibration(null, this);
}
var pcb = string.Empty;
if (sender is ToolStripMenuItem menuItem)
{
pcb = menuItem.Text;
}
if (int.TryParse($"{pcb}", out int pcbId))
{
this.LoadTemperatureChecks(pcb);
}
}
private void LoadTemperatureChecks(string pcb)
=> this.BeginInvoke(new Action(() =>
{
this.aggregationsGridView.Rows.Clear();
var temperatureChecks = this.automaticCalibration
.TemperatureChecksFor(pcb)
.ToArray();
var rowsCount = temperatureChecks.Length;
if (rowsCount <= 0)
{
return;
}
this.temperatureChecksGridView.Rows.Add(rowsCount);
for (int i = 0; i < rowsCount; i++)
{
var temperatureCheck = temperatureChecks[i];
var currentRow = this.temperatureChecksGridView.Rows[i];
// Pcb Id
currentRow.Cells[0].Value = temperatureCheck.PcbId;
// Temperatures
currentRow.Cells[1].Value = $"{temperatureCheck.PrevT:00.00}";
currentRow.Cells[2].Value = $"{temperatureCheck.NextT:00.00}";
currentRow.Cells[3].Value = $"{temperatureCheck.CurrentT:00.00}";
currentRow.Cells[4].Value = $"{temperatureCheck.CalculatedT:00.00}";
currentRow.Cells[5].Value = $"{temperatureCheck.DiffT:00.00}";
// Times of flights
currentRow.Cells[6].Value = $"{temperatureCheck.PrevTOF:0.0000000000}";
currentRow.Cells[7].Value = $"{temperatureCheck.CurrentTOF:0.0000000000}";
currentRow.Cells[8].Value = $"{temperatureCheck.NextTOF:0.0000000000}";
}
this.aggregationsGridView.CellContentClick += AggregationsGridView_CurrentCellChanged;
}));
}
}
@@ -123,6 +123,42 @@
<metadata name="timer2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>104, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>531, 17</value>
</metadata>
<metadata name="resultsMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>413, 17</value>
</metadata>
<metadata name="TemperatureCheck_Pcb.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_PrevC.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_NextC.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_CurrentC.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_CalcC.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_DiffC.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_PrevTOF.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_CurrentTOF.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TemperatureCheck_NextTOF.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>531, 17</value>
</metadata>
<metadata name="PcbId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@@ -33,6 +33,12 @@
set => SetValue(value);
}
public static int BackwardsStepMS
{
get => GetInt32();
set => SetValue(value);
}
private static short GetInt16([CallerMemberName] string property = EMPTY)
{
var value = settings[property]?.Value?.ToString() ?? string.Empty;
@@ -66,7 +66,7 @@
{
var result = default(short);
var priority = default(short);
var temperature = default(double);
var temperature = double.MinValue;
var value = default(int);
unsafe
@@ -82,15 +82,18 @@
partial class AutomaticTemperatureCalibration
{
private const string BASE_ADDRESS = "http://sla12iis01.emea.sensus.net/LaaProductionWeb"; // "http://localhost:52822/LaaProductionWeb";
private const string WORKING_DIR = @".\temperature_calibrations";
private const string BASE_ADDRESS = "http://sla12iis01.emea.sensus.net/LaaProductionWeb";
// private const string BASE_ADDRESS = "http://localhost:52822/LaaProductionWeb";
private const string WORKING_DIR = @"temperature_calibrations";
private const string MESSUREMENTS_FILE = @"_messurements.txt";
private const string AGGREGATIONS_FILE = @"_aggregations.txt";
private const string BACKWARDS_FILE = @"_backwards.txt";
private const NumberStyles ANY = NumberStyles.Any;
private readonly string pcbId;
private readonly string messurementsFile;
private readonly string aggregationsFile;
private readonly string backwardsFile;
private readonly ITempMeterForm tempMeterForm;
private readonly CultureInfo en;
private readonly CultureInfo de;
@@ -107,8 +110,9 @@
if (int.TryParse($"{this.pcbId}", out int pcb))
{
this.messurementsFile = this.GetOrCreateMessurementsFile(this.pcbId);
this.aggregationsFile = this.GetOrCreateAggregationsFile(this.pcbId);
this.messurementsFile = this.GetOrCreateFile(this.pcbId, MESSUREMENTS_FILE);
this.aggregationsFile = this.GetOrCreateFile(this.pcbId, AGGREGATIONS_FILE);
this.backwardsFile = this.GetOrCreateFile(this.pcbId, BACKWARDS_FILE);
}
this.temperatureSource = new TemperatureSource();
@@ -179,9 +183,9 @@
{
this.tempMeterForm.BeginInvoke(new Action(() =>
{
var currentTOF = this.tempMeterForm.AvgTOF();
var currentT = this.temperatureSource.GetTemperature();
var messurement = $"[{args.SignalTime:yyyy-MM-dd hh:mm:ss}]\t{this.pcbId,9}\t{currentT,5:00.00}\t{currentTOF,14:0.000000000000}";
var messurement = !this.TryGetTOFandT(out double currentTOF, out double currentT)
? $"[{args.SignalTime:yyyy-MM-dd hh:mm:ss}]\t invalid record (TOF: {currentTOF} & T: {currentT})"
: $"[{args.SignalTime:yyyy-MM-dd hh:mm:ss}]\t{this.pcbId,9}\t{currentT,5:00.00}\t{currentTOF,14:0.000000000000}";
if (this.messuring)
{
@@ -192,26 +196,15 @@
}
}
private String GetOrCreateMessurementsFile(string pcbId)
private String GetOrCreateFile(string pcbId, string fileBase)
{
Directory.CreateDirectory(WORKING_DIR);
var filePath = $@"{WORKING_DIR}\{this.pcbId}{MESSUREMENTS_FILE}";
File.AppendAllText(filePath, Environment.NewLine);
return filePath;
}
private String GetOrCreateAggregationsFile(string pcbId)
{
Directory.CreateDirectory(WORKING_DIR);
var filePath = $@"{WORKING_DIR}\{this.pcbId}{AGGREGATIONS_FILE}";
var filePath = Path.Combine(".", WORKING_DIR, $"{pcbId}{fileBase}");
if (!File.Exists(filePath))
{
File.WriteAllLines(filePath, new[] { Messurements.Header });
File.WriteAllText(filePath, string.Empty);
}
return filePath;
@@ -273,7 +266,7 @@
var aggregations = new List<Messurement>();
var aggregationsFile = $"{WORKING_DIR}\\{pcb}{AGGREGATIONS_FILE}";
var existingAggregations = this.GetAggregations(pcb);
var existingAggregations = this.RequestAggregations(pcb);
var aggregationsLines = new List<string>();
if (File.Exists(aggregationsFile))
@@ -343,7 +336,7 @@
.ToList();
}
internal IEnumerable<Messurement> GetAggregations(string pcb)
internal IEnumerable<Messurement> RequestAggregations(string pcb)
{
var aggregations = Array.Empty<Messurement>();
@@ -432,12 +425,12 @@
MessageBox.Show(message);
}
internal IEnumerable<string> AvailablePcbs()
internal IEnumerable<string> AvailableAggregationPcbs()
{
var existingPcbs = this.GetAllPcbs();
var localPcbs = Directory
.CreateDirectory(WORKING_DIR)
.GetFiles("*_aggregations.txt")
.GetFiles($"*{AGGREGATIONS_FILE}")
.Select(x => x.Name
.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries)
.FirstOrDefault());
@@ -501,7 +494,7 @@
internal void StartBackward()
{
this.temperatureSource = new TemperatureSource();
this.shortTimer = new Timer(5000)
this.shortTimer = new Timer(Appsettings.BackwardsStepMS)
{
Enabled = true,
AutoReset = true
@@ -514,16 +507,173 @@
{
this.tempMeterForm.BeginInvoke(new Action(() =>
{
var currentTOF = this.tempMeterForm.AvgTOF();
var currentT = this.temperatureSource.GetTemperature();
var messurement = $"[{args.SignalTime:yyyy-MM-dd hh:mm:ss}]\t{this.pcbId,9}\t{currentT,5:00.00}\t{currentTOF,14:0.000000000000}";
var messurement = !this.TryGetTOFandT(out double currentTOF, out double currentT)
? $"[{args.SignalTime:yyyy-MM-dd hh:mm:ss}]\t invalid record (TOF: {currentTOF} & T: {currentT})"
: $"[{args.SignalTime:yyyy-MM-dd hh:mm:ss}]\t{this.pcbId,9}\t{currentT,5:00.00}\t{currentTOF,14:0.000000000000}";
this.tempMeterForm.AddMessage(messurement);
File.AppendAllLines(this.messurementsFile, new[] { messurement });
File.AppendAllLines(this.backwardsFile, new[] { messurement });
this.tempMeterForm.StartRecording();
}));
}
private bool TryGetTOFandT(out double actualTOF, out double actualT)
{
actualTOF = this.tempMeterForm.AvgTOF();
actualT = this.temperatureSource.GetTemperature();
if (actualTOF >= 1 || actualT <= double.MinValue)
{
return false;
}
return true;
}
internal IEnumerable<string> AvailableCheckPcbs()
=> Directory
.CreateDirectory(WORKING_DIR)
.GetFiles($"*{BACKWARDS_FILE}")
.Select(x => x.Name
.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries)
.FirstOrDefault())
.OrderBy(x => x)
.ToHashSet();
internal IEnumerable<InterpolationResult> TemperatureChecksFor(String pcb)
{
var backwardsFile = Path.Combine(".", WORKING_DIR, $"{pcb}{BACKWARDS_FILE}");
if (!File.Exists(backwardsFile))
{
return Array.Empty<InterpolationResult>();
}
var backwardsMessurements = new List<Messurement>();
foreach (var line in File.ReadAllLines(backwardsFile))
{
if (string.IsNullOrWhiteSpace(line))
{
continue;
}
var tokens = line.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length != 4)
{
continue;
}
var pcbString = tokens[1] ?? string.Empty;
var avgTString = tokens[2] ?? string.Empty;
var avgTOFString = tokens[3] ?? string.Empty;
var pcbId = default(int);
var avgT = default(double);
var avgTOF = default(double);
var pcbParsed = int.TryParse(pcbString, out pcbId);
var tParsed = double.TryParse(avgTString, ANY, this.en, out avgT) || double.TryParse(avgTString, ANY, this.de, out avgT);
var tofParsed = double.TryParse(avgTOFString, ANY, this.en, out avgTOF) || double.TryParse(avgTOFString, ANY, this.de, out avgTOF);
if (!pcbParsed || !tParsed || !tofParsed)
{
continue;
}
backwardsMessurements.Add(new Messurement
{
PcbId = pcbId,
AvgT = avgT,
AvgTOF = avgTOF
});
}
var localAggregations = this.AggregationsFor(pcb) ?? Array.Empty<Messurement>();
var temperatureLUT = localAggregations.OrderBy(x => x.AvgTOF).ToArray();
var temperatureChecks = new List<InterpolationResult>();
foreach (var check in backwardsMessurements)
{
var interpolatedResult = this.InterpolateTOF2T(check.AvgTOF, temperatureLUT);
interpolatedResult.PcbId = check.PcbId;
interpolatedResult.CurrentT = check.AvgT;
temperatureChecks.Add(interpolatedResult);
}
return temperatureChecks;
}
private InterpolationResult InterpolateTOF2T(double currentTOF, params Messurement[] temperatureLUT)
{
var interpolationResult = new InterpolationResult
{
CalculatedT = 1,
CurrentTOF = currentTOF
};
var length = temperatureLUT?.Length ?? 0;
var last = length - 1;
if (last <= 0 || temperatureLUT[0].AvgTOF > currentTOF || temperatureLUT[last].AvgTOF < currentTOF)
{
return interpolationResult;
}
var prevTOF = default(double);
var prevT = default(double);
var nextTOF = default(double);
var nextT = default(double);
for (int i = 1; i < length; i++)
{
if (temperatureLUT[i].AvgTOF >= currentTOF)
{
prevTOF = temperatureLUT[i - 1].AvgTOF;
prevT = temperatureLUT[i - 1].AvgT;
nextTOF = temperatureLUT[i].AvgTOF;
nextT = temperatureLUT[i].AvgT;
break;
}
}
var currentT = (nextT - prevT) / (nextTOF - prevTOF) * (currentTOF - prevTOF) + prevT;
interpolationResult.CalculatedT = currentT;
interpolationResult.PrevTOF = prevTOF;
interpolationResult.PrevT = prevT;
interpolationResult.NextTOF = nextTOF;
interpolationResult.NextT = nextT;
return interpolationResult;
}
}
class InterpolationResult
{
public int PcbId { get; set; }
public double PrevT { get; set; }
public double PrevTOF { get; set; }
public double CurrentT { get; set; }
public double CalculatedT { get; set; }
public double CurrentTOF { get; set; }
public double NextT { get; set; }
public double NextTOF { get; set; }
public double DiffT => Math.Abs(this.CurrentT - this.CalculatedT);
}
class Messurement