temperature calibration results implemented.
note! the results are from laa production web requested.
This commit is contained in:
+140
-11
@@ -31,6 +31,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = 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();
|
||||
@@ -67,7 +68,17 @@ 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.tabPage4 = new System.Windows.Forms.TabPage();
|
||||
this.resultsTab = 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();
|
||||
this.Avg_T = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Avg_TOF = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Selected = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.resultsMenu = new System.Windows.Forms.MenuStrip();
|
||||
this.loadPcbToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.updateViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveSelectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.timer3 = new System.Windows.Forms.Timer(this.components);
|
||||
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.automaticCalibrationTabControl.SuspendLayout();
|
||||
@@ -77,6 +88,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudRef)).BeginInit();
|
||||
this.AutomaticCalibrationTab.SuspendLayout();
|
||||
this.automaticControlsPanel.SuspendLayout();
|
||||
this.resultsTab.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.aggregationsGridView)).BeginInit();
|
||||
this.resultsMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// timer1
|
||||
@@ -94,7 +108,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
this.automaticCalibrationTabControl.Controls.Add(this.tabPage2);
|
||||
this.automaticCalibrationTabControl.Controls.Add(this.tabPage3);
|
||||
this.automaticCalibrationTabControl.Controls.Add(this.AutomaticCalibrationTab);
|
||||
this.automaticCalibrationTabControl.Controls.Add(this.tabPage4);
|
||||
this.automaticCalibrationTabControl.Controls.Add(this.resultsTab);
|
||||
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);
|
||||
@@ -498,15 +512,115 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
this.label1.Text = "Messgerät (COM port)";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
|
||||
//
|
||||
// tabPage4
|
||||
// resultsTab
|
||||
//
|
||||
this.tabPage4.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage4.Size = new System.Drawing.Size(1217, 647);
|
||||
this.tabPage4.TabIndex = 4;
|
||||
this.tabPage4.Text = "tabPage4";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
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;
|
||||
//
|
||||
// aggregationsGridView
|
||||
//
|
||||
this.aggregationsGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.aggregationsGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.aggregationsGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.aggregationsGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.aggregationsGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.aggregationsGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.PcbId,
|
||||
this.Avg_Nr,
|
||||
this.Avg_T,
|
||||
this.Avg_TOF,
|
||||
this.Selected});
|
||||
this.aggregationsGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.aggregationsGridView.Location = new System.Drawing.Point(0, 24);
|
||||
this.aggregationsGridView.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.aggregationsGridView.Name = "aggregationsGridView";
|
||||
this.aggregationsGridView.Size = new System.Drawing.Size(1217, 623);
|
||||
this.aggregationsGridView.TabIndex = 0;
|
||||
//
|
||||
// PcbId
|
||||
//
|
||||
this.PcbId.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.PcbId.HeaderText = "PcbId";
|
||||
this.PcbId.Name = "PcbId";
|
||||
this.PcbId.ReadOnly = true;
|
||||
//
|
||||
// Avg_Nr
|
||||
//
|
||||
this.Avg_Nr.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Avg_Nr.HeaderText = "Avg Nr";
|
||||
this.Avg_Nr.Name = "Avg_Nr";
|
||||
this.Avg_Nr.ReadOnly = true;
|
||||
//
|
||||
// Avg_T
|
||||
//
|
||||
this.Avg_T.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Avg_T.HeaderText = "Avg °C";
|
||||
this.Avg_T.Name = "Avg_T";
|
||||
this.Avg_T.ReadOnly = true;
|
||||
//
|
||||
// Avg_TOF
|
||||
//
|
||||
this.Avg_TOF.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Avg_TOF.HeaderText = "Avg TOF";
|
||||
this.Avg_TOF.Name = "Avg_TOF";
|
||||
this.Avg_TOF.ReadOnly = true;
|
||||
//
|
||||
// Selected
|
||||
//
|
||||
this.Selected.FalseValue = "false";
|
||||
this.Selected.HeaderText = "Selected";
|
||||
this.Selected.IndeterminateValue = "false";
|
||||
this.Selected.Name = "Selected";
|
||||
this.Selected.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.Selected.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
|
||||
this.Selected.TrueValue = "true";
|
||||
//
|
||||
// resultsMenu
|
||||
//
|
||||
this.resultsMenu.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.resultsMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.loadPcbToolStripMenuItem,
|
||||
this.updateViewToolStripMenuItem,
|
||||
this.saveSelectedToolStripMenuItem});
|
||||
this.resultsMenu.Location = new System.Drawing.Point(0, 0);
|
||||
this.resultsMenu.Name = "resultsMenu";
|
||||
this.resultsMenu.Size = new System.Drawing.Size(1217, 24);
|
||||
this.resultsMenu.TabIndex = 1;
|
||||
this.resultsMenu.Text = "menuStrip1";
|
||||
//
|
||||
// loadPcbToolStripMenuItem
|
||||
//
|
||||
this.loadPcbToolStripMenuItem.Name = "loadPcbToolStripMenuItem";
|
||||
this.loadPcbToolStripMenuItem.Size = new System.Drawing.Size(68, 20);
|
||||
this.loadPcbToolStripMenuItem.Text = "Load pcb";
|
||||
//
|
||||
// updateViewToolStripMenuItem
|
||||
//
|
||||
this.updateViewToolStripMenuItem.Name = "updateViewToolStripMenuItem";
|
||||
this.updateViewToolStripMenuItem.Size = new System.Drawing.Size(84, 20);
|
||||
this.updateViewToolStripMenuItem.Text = "Update view";
|
||||
this.updateViewToolStripMenuItem.Click += new System.EventHandler(this.UpdateViewToolStripMenuItem_Click);
|
||||
//
|
||||
// saveSelectedToolStripMenuItem
|
||||
//
|
||||
this.saveSelectedToolStripMenuItem.Name = "saveSelectedToolStripMenuItem";
|
||||
this.saveSelectedToolStripMenuItem.Size = new System.Drawing.Size(89, 20);
|
||||
this.saveSelectedToolStripMenuItem.Text = "Save selected";
|
||||
this.saveSelectedToolStripMenuItem.Click += new System.EventHandler(this.SaveSelectedToolStripMenuItem_Click);
|
||||
//
|
||||
// timer3
|
||||
//
|
||||
@@ -543,6 +657,11 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
this.AutomaticCalibrationTab.ResumeLayout(false);
|
||||
this.automaticControlsPanel.ResumeLayout(false);
|
||||
this.automaticControlsPanel.PerformLayout();
|
||||
this.resultsTab.ResumeLayout(false);
|
||||
this.resultsTab.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.aggregationsGridView)).EndInit();
|
||||
this.resultsMenu.ResumeLayout(false);
|
||||
this.resultsMenu.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -587,6 +706,16 @@ 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 tabPage4;
|
||||
private System.Windows.Forms.TabPage resultsTab;
|
||||
private System.Windows.Forms.DataGridView aggregationsGridView;
|
||||
private System.Windows.Forms.MenuStrip resultsMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem updateViewToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveSelectedToolStripMenuItem;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn PcbId;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Avg_Nr;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Avg_T;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Avg_TOF;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn Selected;
|
||||
private System.Windows.Forms.ToolStripMenuItem loadPcbToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
@@ -39,6 +40,8 @@
|
||||
private Boolean lutIsMissing;
|
||||
private List<RefTempRange> reftempRangeReq;
|
||||
private List<CordonelTempLut> cordonelTempLut;
|
||||
private AutomaticTemperatureCalibration automaticCalibration;
|
||||
private bool automatic = false;
|
||||
|
||||
public FrmTempMeter()
|
||||
{
|
||||
@@ -554,6 +557,18 @@
|
||||
|
||||
private void InitializeContent()
|
||||
{
|
||||
this.automaticCalibration = new AutomaticTemperatureCalibration(null, this);
|
||||
|
||||
foreach (var pcbText in this.automaticCalibration.AvailablePcbs())
|
||||
{
|
||||
var dropdownPcbId = new ToolStripMenuItem(pcbText);
|
||||
dropdownPcbId.Click += DropdownPcbId_Click;
|
||||
|
||||
this.loadPcbToolStripMenuItem.DropDownItems.Add(dropdownPcbId);
|
||||
}
|
||||
|
||||
this.aggregationsGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.WhiteSmoke;
|
||||
|
||||
this.mainMenuStrip.Padding = new Padding(5);
|
||||
|
||||
var menuFont = this.mainMenuStrip.Font;
|
||||
@@ -721,9 +736,6 @@
|
||||
this.stopAutomaticBtn.Enabled = false;
|
||||
}
|
||||
|
||||
private bool automatic = false;
|
||||
private AutomaticTemperatureCalibration automaticCalibration;
|
||||
|
||||
private void StartAutomaticBtn_Clicked(object sender, EventArgs args)
|
||||
{
|
||||
if (this.currentGenesis is null)
|
||||
@@ -741,7 +753,7 @@
|
||||
this.automatic = true;
|
||||
this.start = DateTimeOffset.Now;
|
||||
|
||||
var pcbid = this.currentGenesis?.PcbId ?? "*********";
|
||||
var pcbid = this.currentGenesis?.PcbId;
|
||||
this.automaticCalibration = new AutomaticTemperatureCalibration(pcbid, this);
|
||||
|
||||
this.automaticCalibration.StartMessuring();
|
||||
@@ -786,18 +798,6 @@
|
||||
}));
|
||||
}
|
||||
|
||||
private void SaveMessurement(double currentT, double meterTOF, DateTime timestamp)
|
||||
{
|
||||
// var pcbid = this.currentGenesis?.PcbId ?? "000000000";
|
||||
// var temperature = currentT.ToString().Substring(0, 2);
|
||||
|
||||
// TODO: LocalWebRequest.PostRequestAsync(
|
||||
// $"http://10.49.40.25/MeterProcessState/api/TempFlange/AddLut?PcbId={pcbid}&RefTempC={temperature}&AvgTof={meterTOF}&dt={timestamp}");
|
||||
// File.AppendAllLines("_temp_luts.txt", new[] { $"{pcbid}\t{temperature:F2}\t{meterTOF}\t{timestamp}" });
|
||||
|
||||
// File.AppendAllText($"./messuremensts/{pcbid}.txt", $"{pcbid}\t{currentT:F2}\t{meterTOF:F16}\t{timestamp}{Environment.NewLine}");
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
@@ -860,5 +860,122 @@
|
||||
|
||||
Appsettings.SaveSettings();
|
||||
}
|
||||
|
||||
private Messurement[] aggregations;
|
||||
private string selectedPcb;
|
||||
|
||||
private void DropdownPcbId_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)
|
||||
{
|
||||
this.selectedPcb = menuItem.Text;
|
||||
}
|
||||
|
||||
this.LoadAggregations(this.selectedPcb);
|
||||
}
|
||||
|
||||
private void UpdateViewToolStripMenuItem_Click(Object sender, EventArgs e)
|
||||
=> this.LoadAggregations(this.selectedPcb);
|
||||
|
||||
private void LoadAggregations(string pcb)
|
||||
=> this.BeginInvoke(new Action(() =>
|
||||
{
|
||||
this.aggregations = this.automaticCalibration
|
||||
.AggregationsFor(pcb)
|
||||
.ToArray();
|
||||
|
||||
var rowsCount = this.aggregations.Length;
|
||||
|
||||
this.aggregationsGridView.Rows.Clear();
|
||||
|
||||
if (rowsCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.aggregationsGridView.Rows.Add(rowsCount);
|
||||
|
||||
for (int i = 0; i < rowsCount; i++)
|
||||
{
|
||||
var aggregation = this.aggregations[i];
|
||||
var currentRow = this.aggregationsGridView.Rows[i];
|
||||
|
||||
currentRow.Cells[0].Value = aggregation.PcbId;
|
||||
currentRow.Cells[1].Value = aggregation.Id;
|
||||
currentRow.Cells[2].Value = aggregation.AvgT;
|
||||
currentRow.Cells[3].Value = aggregation.AvgTOF;
|
||||
currentRow.Cells[4].Value = aggregation.Selected;
|
||||
currentRow.Cells[4].Tag = aggregation.PcbId;
|
||||
currentRow.Cells[4].ValueType = typeof(bool);
|
||||
|
||||
if (aggregation.Selected)
|
||||
{
|
||||
currentRow.DefaultCellStyle.BackColor = Color.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
|
||||
this.aggregationsGridView.CellContentClick += AggregationsGridView_CurrentCellChanged;
|
||||
}));
|
||||
|
||||
private void AggregationsGridView_CurrentCellChanged(Object sender, EventArgs e)
|
||||
{
|
||||
this.BeginInvoke(new Action(() =>
|
||||
{
|
||||
this.aggregationsGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
|
||||
|
||||
var rows = this.aggregationsGridView.Rows;
|
||||
var rowsCount = this.aggregationsGridView.Rows.Count;
|
||||
|
||||
for (int i = 0; i < rowsCount; i++)
|
||||
{
|
||||
var row = rows[i];
|
||||
var cell = row.Cells[4];
|
||||
|
||||
if (cell.Tag is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
row.DefaultCellStyle.BackColor = Color.White;
|
||||
|
||||
if (bool.TryParse($"{cell.Value}", out bool value) && value)
|
||||
{
|
||||
row.DefaultCellStyle.BackColor = Color.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void SaveSelectedToolStripMenuItem_Click(Object sender, EventArgs e)
|
||||
{
|
||||
this.aggregationsGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
|
||||
|
||||
var rows = this.aggregationsGridView.Rows;
|
||||
var rowsCount = this.aggregationsGridView.Rows.Count;
|
||||
|
||||
for (int i = 0; i < rowsCount; i++)
|
||||
{
|
||||
var cell = rows[i].Cells[4];
|
||||
|
||||
if (cell.Tag is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bool.TryParse($"{cell.Value}", out bool value))
|
||||
{
|
||||
this.aggregations[i].Selected = value;
|
||||
}
|
||||
}
|
||||
|
||||
this.automaticCalibration?.UpdateAggregations(this.aggregations.Where(x => x.Selected));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,27 @@
|
||||
<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="resultsMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>413, 17</value>
|
||||
</metadata>
|
||||
<metadata name="PcbId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Avg_Nr.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Avg_T.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Avg_TOF.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Selected.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</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="timer3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>191, 17</value>
|
||||
</metadata>
|
||||
|
||||
@@ -8,18 +8,19 @@
|
||||
|
||||
using CommonCore.Configuration;
|
||||
using Logic.SoftwareAccessHelper;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
/// <summary>
|
||||
/// Holds information over current software and logged in user.
|
||||
/// </summary>
|
||||
internal static class Software
|
||||
{
|
||||
private static String bearer;
|
||||
private static String Bearer;
|
||||
private static IEnumerable<SoftwareFunctions> softwareFunctions = Array.Empty<SoftwareFunctions>();
|
||||
|
||||
public static String UserName;
|
||||
|
||||
private static Boolean HasUser => !string.IsNullOrWhiteSpace(bearer);
|
||||
private static Boolean HasUser => !string.IsNullOrWhiteSpace(Bearer);
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
@@ -51,7 +52,7 @@
|
||||
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Login/AD",
|
||||
json: model);
|
||||
|
||||
bearer = authenticationResponse.Content;
|
||||
Bearer = authenticationResponse.Content;
|
||||
softwareFunctions = GetFunctions();
|
||||
UserName = "Options";
|
||||
|
||||
@@ -83,7 +84,7 @@
|
||||
BuildV = SoftwareVersion.Current.BuildV,
|
||||
});
|
||||
|
||||
bearer = authenticationResponse.Content;
|
||||
Bearer = authenticationResponse.Content;
|
||||
softwareFunctions = GetFunctions();
|
||||
UserName = "Options";
|
||||
|
||||
@@ -95,7 +96,7 @@
|
||||
.GetRequest(
|
||||
timeoutMs: 1200,
|
||||
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Personalization/Login",
|
||||
header: new Dictionary<String, String> { { "Authorization", $"Bearer {bearer}" } })
|
||||
header: new Dictionary<String, String> { { "Authorization", $"Bearer {Bearer}" } })
|
||||
.Trim('"');
|
||||
}
|
||||
catch (Exception )
|
||||
@@ -114,7 +115,7 @@
|
||||
|
||||
public static IEnumerable<SoftwareFunctions> GetFunctions()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(bearer))
|
||||
if (string.IsNullOrWhiteSpace(Bearer))
|
||||
{
|
||||
return Array.Empty<SoftwareFunctions>();
|
||||
}
|
||||
@@ -124,7 +125,7 @@
|
||||
var functionsResponse = LocalWebRequest.GetRequest(
|
||||
timeoutMs: 1200,
|
||||
url: $"{ServiceUrls.LaaProductionAPI}/LaaProductionWeb/API/Personalization/Software/Access",
|
||||
header: new Dictionary<String, String> { { "Authorization", $"Bearer {bearer}" } });
|
||||
header: new Dictionary<String, String> { { "Authorization", $"Bearer {Bearer}" } });
|
||||
|
||||
return JsonConvert
|
||||
.DeserializeObject<IEnumerable<String>>(functionsResponse)
|
||||
@@ -145,10 +146,13 @@
|
||||
public static void Logout()
|
||||
{
|
||||
UserName = "Options";
|
||||
bearer = default(String);
|
||||
Bearer = default(String);
|
||||
softwareFunctions = Array.Empty<SoftwareFunctions>();
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public static AuthenticationHeaderValue AuthorizationHeader
|
||||
=> new AuthenticationHeaderValue(nameof(Bearer), Bearer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
namespace Xylem.Common.Ui.GenesisToolBox.Infrastructure
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
|
||||
using SystemThreadingThread = System.Threading.Thread;
|
||||
|
||||
@@ -97,8 +103,13 @@
|
||||
{
|
||||
this.pcbId = pcbId;
|
||||
this.tempMeterForm = genesisMeter;
|
||||
this.messurementsFile = this.GetOrCreateMessurementsFile(this.pcbId);
|
||||
this.aggregationsFile = this.GetOrCreateAggregationsFile(this.pcbId);
|
||||
|
||||
if (int.TryParse($"{this.pcbId}", out int pcb))
|
||||
{
|
||||
this.messurementsFile = this.GetOrCreateMessurementsFile(this.pcbId);
|
||||
this.aggregationsFile = this.GetOrCreateAggregationsFile(this.pcbId);
|
||||
}
|
||||
|
||||
this.temperatureSource = new TemperatureSource();
|
||||
this.en = new CultureInfo("en-US");
|
||||
this.de = new CultureInfo("de-DE");
|
||||
@@ -239,6 +250,11 @@
|
||||
{
|
||||
var tParsed = double.TryParse(tString, ANY, this.en, out currentT) || double.TryParse(tString, ANY, this.de, out currentT);
|
||||
var tofParsed = double.TryParse(tofString, ANY, this.en, out currentTOF) || double.TryParse(tofString, ANY, this.de, out currentTOF);
|
||||
|
||||
if (!tParsed || !tofParsed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -250,6 +266,249 @@
|
||||
|
||||
File.AppendAllLines(this.aggregationsFile, new[] { messurements.ToString() });
|
||||
}
|
||||
|
||||
internal IEnumerable<Messurement> AggregationsFor(string pcb)
|
||||
{
|
||||
var aggregations = new List<Messurement>();
|
||||
var aggregationsFile = $"{WORKING_DIR}\\{pcb}{AGGREGATIONS_FILE}";
|
||||
|
||||
var existingAggregations = this.GetAggregations(pcb);
|
||||
var aggregationsLines = new List<string>();
|
||||
|
||||
if (File.Exists(aggregationsFile))
|
||||
{
|
||||
aggregationsLines = File
|
||||
.ReadAllLines(aggregationsFile)
|
||||
.Skip(1)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
if (aggregationsLines.Count <= 0)
|
||||
{
|
||||
aggregations = existingAggregations.ToList();
|
||||
aggregations.ForEach(x => x.Selected = true);
|
||||
}
|
||||
|
||||
foreach (var line in aggregationsLines)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var tokens = line.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (tokens.Length != 10)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var pcbString = tokens[0] ?? string.Empty;
|
||||
var avgTString = tokens[3] ?? string.Empty;
|
||||
var avgTOFString = tokens[4] ?? 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;
|
||||
}
|
||||
|
||||
aggregations.Add(new Messurement
|
||||
{
|
||||
PcbId = pcbId,
|
||||
AvgT = avgT,
|
||||
AvgTOF = avgTOF,
|
||||
Selected = existingAggregations.Any(x => x.AvgT == avgT)
|
||||
});
|
||||
}
|
||||
|
||||
return aggregations
|
||||
.OrderBy(x => x.PcbId)
|
||||
.ThenBy(x => x.AvgT)
|
||||
.ThenBy(x => x.AvgTOF)
|
||||
.Select((messurement, index) =>
|
||||
{
|
||||
messurement.Id = index + 1;
|
||||
|
||||
return messurement;
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
internal IEnumerable<Messurement> GetAggregations(string pcb)
|
||||
{
|
||||
var aggregations = Array.Empty<Messurement>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
using (var httpRequestMessage = new HttpRequestMessage())
|
||||
{
|
||||
httpRequestMessage.Method = HttpMethod.Get;
|
||||
httpRequestMessage.Headers.Authorization = Software.AuthorizationHeader;
|
||||
httpRequestMessage.RequestUri = new Uri($"http://localhost:52822/LaaProductionWeb/API/Production/TempMeter/{pcb}");
|
||||
|
||||
using (var httpResponseMessage = httpClient.SendAsync(httpRequestMessage).Result)
|
||||
{
|
||||
if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var content = httpResponseMessage
|
||||
.Content
|
||||
.ReadAsStringAsync()
|
||||
.Result;
|
||||
|
||||
aggregations = JsonConvert.DeserializeObject<Messurement[]>($"{content}");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"HTTP! {(int)httpResponseMessage.StatusCode} - {httpResponseMessage.ReasonPhrase}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show($"Failed! {e.Message}");
|
||||
}
|
||||
|
||||
return aggregations;
|
||||
}
|
||||
|
||||
internal async void UpdateAggregations(IEnumerable<Messurement> messurements)
|
||||
{
|
||||
var message = "Succeeded!";
|
||||
|
||||
try
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
using (var httpRequestMessage = new HttpRequestMessage())
|
||||
{
|
||||
httpRequestMessage.Method = HttpMethod.Post;
|
||||
httpRequestMessage.Headers.Authorization = Software.AuthorizationHeader;
|
||||
httpRequestMessage.RequestUri = new Uri("http://localhost:52822/LaaProductionWeb/API/Production/TempMeter/Update");
|
||||
httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(messurements));
|
||||
httpRequestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
|
||||
using (var httpResponseMessage = await httpClient.SendAsync(httpRequestMessage))
|
||||
{
|
||||
if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var added = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
|
||||
message = $"Succeeded! {added} records added.";
|
||||
}
|
||||
else if (httpResponseMessage.StatusCode == HttpStatusCode.NotModified)
|
||||
{
|
||||
message = $"Failed! No messurements to add.";
|
||||
}
|
||||
else if (httpResponseMessage.StatusCode == HttpStatusCode.Conflict)
|
||||
{
|
||||
message = $"Failed! More than 1 pcb's sent.";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = $"HTTP! {(int)httpResponseMessage.StatusCode} - {httpResponseMessage.ReasonPhrase}.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
message = $"Failed! {e.Message}";
|
||||
}
|
||||
|
||||
MessageBox.Show(message);
|
||||
}
|
||||
|
||||
internal IEnumerable<string> AvailablePcbs()
|
||||
{
|
||||
var existingPcbs = this.GetAllPcbs();
|
||||
var localPcbs = Directory
|
||||
.CreateDirectory(WORKING_DIR)
|
||||
.GetFiles("*_aggregations.txt")
|
||||
.Select(x => x.Name
|
||||
.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.FirstOrDefault());
|
||||
|
||||
return existingPcbs
|
||||
.Union(localPcbs)
|
||||
.OrderBy(x => x)
|
||||
.ToHashSet();
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetAllPcbs()
|
||||
{
|
||||
var pcbs = Array.Empty<string>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
using (var httpRequestMessage = new HttpRequestMessage())
|
||||
{
|
||||
httpRequestMessage.Method = HttpMethod.Get;
|
||||
httpRequestMessage.Headers.Authorization = Software.AuthorizationHeader;
|
||||
httpRequestMessage.RequestUri = new Uri($"http://localhost:52822/LaaProductionWeb/API/Production/TempMeter/Pcbs");
|
||||
|
||||
using (var httpResponseMessage = httpClient.SendAsync(httpRequestMessage)
|
||||
.ConfigureAwait(true)
|
||||
.GetAwaiter()
|
||||
.GetResult())
|
||||
{
|
||||
if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var content = httpResponseMessage
|
||||
.Content
|
||||
.ReadAsStringAsync()
|
||||
.ConfigureAwait(true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
pcbs = JsonConvert
|
||||
.DeserializeObject<int[]>($"{content}")
|
||||
?.Select(x => x.ToString())
|
||||
?.ToArray()
|
||||
?? pcbs;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"HTTP! {(int)httpResponseMessage.StatusCode} - {httpResponseMessage.ReasonPhrase}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show($"Failed! {e.Message}");
|
||||
}
|
||||
|
||||
return pcbs;
|
||||
}
|
||||
}
|
||||
|
||||
class Messurement
|
||||
{
|
||||
public int PcbId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public double AvgT { get; set; }
|
||||
|
||||
public double AvgTOF { get; set; }
|
||||
|
||||
public bool Selected { get; set; }
|
||||
}
|
||||
|
||||
class Messurements
|
||||
|
||||
Reference in New Issue
Block a user