diff --git a/Common/TempFlansh/TempFlansh.csproj b/Common/TempFlansh/TempFlansh.csproj
index 2bfaa8dc..82fb0385 100644
--- a/Common/TempFlansh/TempFlansh.csproj
+++ b/Common/TempFlansh/TempFlansh.csproj
@@ -13,7 +13,7 @@
true
true
false
- L:\TiloW\TempMeter\publish\
+ C:\Users\SZLATEV\Desktop\TempFlansh\
true
Disk
false
@@ -23,7 +23,7 @@
false
false
true
- 1
+ 2
1.0.0.%2a
false
true
diff --git a/Common/Ui/GenesisToolBox/FrmTempMeter.cs b/Common/Ui/GenesisToolBox/FrmTempMeter.cs
index cb2c6916..46f0fdfd 100644
--- a/Common/Ui/GenesisToolBox/FrmTempMeter.cs
+++ b/Common/Ui/GenesisToolBox/FrmTempMeter.cs
@@ -779,24 +779,7 @@
{
this.automaticContentBox.BeginInvoke(new Action(() =>
{
- if (this.automaticContentBox.Lines.Length > 50)
- {
- this.automaticContentBox.Lines = this.automaticContentBox
- .Lines
- .Skip(1)
- .Take(50)
- .ToArray();
- }
-
this.automaticContentBox.AppendText(message);
-
- var length = message.Length;
- var start = this.automaticContentBox.Text.Length - length;
-
- this.automaticContentBox.Select(start, length);
-
- this.automaticContentBox.SelectionColor = color;
-
this.automaticContentBox.AppendText(Environment.NewLine);
}));
@@ -808,11 +791,11 @@
var pcbid = this.currentGenesis?.PcbId ?? "000000000";
var temperature = currentT.ToString().Substring(0, 2);
- File.AppendAllText($"./messuremensts/{pcbid}_{temperature}.txt", $"{pcbid}\t{currentT:F2}\t{meterTOF:F16}\t{timestamp}{Environment.NewLine}");
-
- // File.AppendAllLines("_temp_luts.txt", new[] { $"{pcbid}\t{temperature:F2}\t{meterTOF}\t{timestamp}" });
// 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)
diff --git a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj
index 15bc130b..5f36ddf9 100644
--- a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj
+++ b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj
@@ -14,7 +14,7 @@
true
false
- L:\Stoyan\temperature_calibration\
+ C:\Users\SZLATEV\Desktop\GenesisToolBox\
false
Disk
false
@@ -24,7 +24,7 @@
false
false
true
- 3
+ 5
1.0.0.%2a
false
true
diff --git a/Common/Ui/GenesisToolBox/Infrastructure/TempMeterModels.cs b/Common/Ui/GenesisToolBox/Infrastructure/TempMeterModels.cs
index 071ff723..2f2bac64 100644
--- a/Common/Ui/GenesisToolBox/Infrastructure/TempMeterModels.cs
+++ b/Common/Ui/GenesisToolBox/Infrastructure/TempMeterModels.cs
@@ -28,42 +28,10 @@
public class RefTempRange
{
public Double Min { get; set; }
+
public Double Max { get; set; }
}
- public class LutTemp
- {
- public int PcbId { get; set; }
-
- public int FromTempC { get; set; }
-
- public int ToTempC { get; set; }
-
- public double? AvgRefTempC { get; set; }
-
- public ICollection ListOfRecordedTofs { get; set; } = new List();
-
- public double? AvgTofs { get; set; }
- }
-
- internal enum ProgrammState
- {
- Start,
- Connected,
- RecordRuning,
- RecordStoped,
- RecodCalculated,
- }
-
- internal struct Messurement
- {
- public double T { get; set; }
-
- public double TOF { get; set; }
-
- public DateTime DTS { get; set; }
- }
-
class TemperatureSource : IDisposable
{
private readonly NamedPipeClientStream pipeStream;
@@ -127,6 +95,7 @@
private readonly Timer timer;
private readonly Func sourceTOF;
private readonly TemperatureSource temperature;
+ private readonly string messurementsLog;
private ICollection timesOfFliights;
private ICollection temperatures;
@@ -139,6 +108,7 @@
public AutomaticTemperatureCalibration(Func sourceTOF)
{
this.sourceTOF = sourceTOF;
+ this.messurementsLog = $"_{nameof(this.messurementsLog)}.txt";
this.temperature = new TemperatureSource();
this.timesOfFliights = new List();
this.temperatures = new List();
@@ -149,15 +119,6 @@
public event Action ErrorMessage;
public event Action WarningMessage;
public event Action TemperatureMesured;
-
- private void Messure(object sender, ElapsedEventArgs args)
- {
- var timestamp = args.SignalTime;
- var currentTOF = this.sourceTOF?.Invoke() ?? default(double);
- _ = this.temperature.TryGetTemperature(out var currentT);
-
- this.TemperatureMesured?.Invoke(currentT, currentTOF, timestamp);
- }
public void StartMessuring()
{
@@ -165,19 +126,21 @@
Appsettings.Refresh();
- this.waiting = true;
- this.temperatureChecks = 0;
-
- this.timer.Interval = Appsettings.MessurementStep;
- // this.timer.Elapsed += this.CheckTemperature;
- this.timer.Elapsed += this.Messure;
+ this.timer.Interval = Appsettings.TemperatureCheckInMs;
+ this.timer.Elapsed += this.CheckTemperature;
+ this.timer.Elapsed -= this.Messure;
this.timer.AutoReset = true;
this.timer.Enabled = true;
this.timer.Start();
- //this.InfoMessage?.Invoke(string.Empty);
- //this.InfoMessage?.Invoke($"\t Nr\tPrevious\tCurrent\tDifference");
+ this.waiting = true;
+ this.temperatureChecks = 0;
+
+ File.AppendAllText(this.messurementsLog, $"[{DateTime.Now}]\tTemperature messurements started{Environment.NewLine}");
+
+ this.InfoMessage?.Invoke(string.Empty);
+ this.InfoMessage?.Invoke($"\t Nr\tPrevious\tCurrent\tDifference");
}
public void StopMessuring()
@@ -186,143 +149,152 @@
this.timer?.Stop();
this.timer?.Dispose();
this.temperature?.Dispose();
+
+ File.AppendAllText(this.messurementsLog, $"[{DateTime.Now}]\tTemperature messurements stopped{Environment.NewLine}");
}
- //private void CheckTemperature(object sender, ElapsedEventArgs args)
- //{
- // this.temperatureChecks++;
+ private void CheckTemperature(object sender, ElapsedEventArgs args)
+ {
+ if (this.temperature.TryGetTemperature(out var currentT))
+ {
+ var differenceT = Math.Abs(this.previousT - currentT);
- // if (this.temperature.TryGetTemperature(out var currentT))
- // {
- // var differenceT = Math.Abs(this.previousT - currentT);
+ if (this.waiting)
+ {
- // this.InfoMessage?.Invoke($"\t{this.temperatureChecks,3}\t{this.previousT,8:F2}\t{currentT,7:F2}\t{differenceT,10:F2}");
+ File.AppendAllText(this.messurementsLog, $"[{DateTime.Now}]\t{this.temperatureChecks}\t{currentT:0.00}°C\t{this.previousT:0.00}°C\t{differenceT:0.00}°C{Environment.NewLine}");
- // if (this.waiting)
- // {
- // if (differenceT >= Appsettings.TemperatureCheckInC)
- // {
- // this.waiting = false;
- // this.previousT = currentT;
- // }
+ if (differenceT >= Appsettings.TemperatureCheckInC)
+ {
+ this.waiting = false;
+ this.previousT = currentT;
+ this.temperatureChecks++;
+ }
+ else
+ {
+ this.temperatureChecks = 0;
+ }
+ }
+ else
+ {
+ if (differenceT <= Appsettings.TemperatureCheckInC)
+ {
+ this.temperatureChecks++;
- // this.temperatureChecks = 0;
- // }
- // else
- // {
- // if (differenceT <= Appsettings.TemperatureCheckInC)
- // {
- // if (this.temperatureChecks >= Appsettings.TemperatureChecksCount)
- // {
- // this.timer.Stop();
+ if (this.temperatureChecks >= Appsettings.TemperatureChecksCount)
+ {
+ this.previousT = currentT;
- // this.waiting = true;
- // this.messurementsN = 0;
- // this.messurementsCount = Appsettings.MessurementDauerInMs / Appsettings.MessurementStep;
+ this.timer.Stop();
+
+ this.messurementsCount = Appsettings.MessurementDauerInMs / Appsettings.MessurementStep;
- // this.timer.Interval = Appsettings.MessurementStep;
- // this.timer.Elapsed -= this.CheckTemperature;
- // this.timer.Elapsed += this.Messure;
- // this.timer.AutoReset = true;
- // this.timer.Enabled = true;
+ this.timer.Interval = Appsettings.MessurementStep;
+ this.timer.Elapsed -= this.CheckTemperature;
+ this.timer.Elapsed += this.Messure;
+ this.timer.AutoReset = true;
+ this.timer.Enabled = true;
- // this.timer.Start();
+ this.timer.Start();
- // this.InfoMessage?.Invoke(string.Empty);
- // this.InfoMessage?.Invoke($"\t Nr\tTimestamp\t TOF\tTemperature");
- // }
- // }
- // else
- // {
- // this.waiting = true;
- // this.previousT = currentT;
- // this.temperatureChecks = 0;
- // }
- // }
- // }
- // else
- // {
- // this.temperatureChecks = 0;
+ this.InfoMessage?.Invoke(string.Empty);
+ this.InfoMessage?.Invoke($"\t Nr\tTimestamp\t TOF\tTemperature");
+ }
+ }
+ else
+ {
+ this.waiting = true;
+ }
- // this.InfoMessage?.Invoke($"\t 0\t{this.previousT,8:F2}\t.......\t..........");
- // }
- //}
+ File.AppendAllText(this.messurementsLog, $"[{DateTime.Now}]\t{this.temperatureChecks}\t{currentT:0.00}°C\t{this.previousT:0.00}°C\t{differenceT:0.00}°C{Environment.NewLine}");
+ }
+ }
+ else
+ {
+ this.temperatureChecks = 0;
- //private void Messure(object sender, ElapsedEventArgs args)
- //{
- // if (!this.temperature.TryGetTemperature(out var currentT))
- // {
- // this.WarningMessage?.Invoke("\t ... temperature could not be read.");
- // this.StartMessuring();
+ this.InfoMessage?.Invoke($"\t 0\t{this.previousT,8:F2}\t.......\t..........");
+ File.AppendAllText(this.messurementsLog, $"[{DateTime.Now}]\tInvalid temperature messured{Environment.NewLine}");
+ }
+ }
- // return;
- // }
+ private void Messure(object sender, ElapsedEventArgs args)
+ {
+ if (!this.temperature.TryGetTemperature(out var currentT))
+ {
+ this.WarningMessage?.Invoke("\t ... temperature could not be read.");
+ this.StartMessuring();
- // var differenceT = Math.Abs(this.previousT - currentT);
+ return;
+ }
+
+ var differenceT = Math.Abs(this.previousT - currentT);
+ var currentTOF = this.sourceTOF?.Invoke() ?? 0;
- // if (differenceT > Appsettings.MessurementToleranceInC)
- // {
- // if (this.messurementsN >= this.messurementsCount / 2)
- // {
- // this.NotifyTemperatureMessured(args.SignalTime);
- // this.InfoMessage?.Invoke("\t ... messurement saved, start looking new temperature change!");
- // }
- // else
- // {
- // this.ErrorMessage?.Invoke("\t ... not enough messurements!");
- // }
+ File.AppendAllText(this.messurementsLog, $"[{DateTime.Now}]\t{this.messurementsN}\t{currentT:0.00}\t{this.previousT:0.00}\t{differenceT:0.00}\t{currentTOF:0.0000000000}{Environment.NewLine}");
- // this.ErrorMessage?.Invoke($"\t ... temperature difference '{differenceT:F2}' is not in the tolerance span!");
- // this.StartMessuring();
+ if (differenceT > Appsettings.MessurementToleranceInC)
+ {
+ if (this.messurementsN >= this.messurementsCount / 2)
+ {
+ this.NotifyTemperatureMessured(args.SignalTime);
+ this.InfoMessage?.Invoke("\t ... messurement saved, start looking new temperature change!");
+ }
+ else
+ {
+ this.ErrorMessage?.Invoke("\t ... not enough messurements!");
+ }
- // return;
- // }
+ this.ErrorMessage?.Invoke($"\t ... temperature difference '{differenceT:F2}' is not in the tolerance span!");
+ this.StartMessuring();
- // var currentTOF = this.sourceTOF?.Invoke() ?? 0;
- // var minTOF = currentTOF;
- // var maxTOF = currentTOF;
+ return;
+ }
+
+ var minTOF = currentTOF;
+ var maxTOF = currentTOF;
- // if (this.timesOfFliights.Any())
- // {
- // var tolerance = Appsettings.MessurementTOFTolerance / 100;
- // minTOF = this.timesOfFliights.Min() * (1.00 - tolerance);
- // maxTOF = this.timesOfFliights.Max() * (1.00 + tolerance);
- // }
+ if (this.timesOfFliights.Any())
+ {
+ var tolerance = Appsettings.MessurementTOFTolerance / 100;
+ minTOF = this.timesOfFliights.Min() * (1.00 - tolerance);
+ maxTOF = this.timesOfFliights.Max() * (1.00 + tolerance);
+ }
- // if (currentTOF < minTOF || currentTOF > maxTOF)
- // {
- // if (this.messurementsN >= this.messurementsCount / 2)
- // {
- // this.NotifyTemperatureMessured(args.SignalTime);
- // this.WarningMessage?.Invoke("\t ... messurement saved, start looking new temperature change!");
- // }
- // else
- // {
- // this.ErrorMessage?.Invoke("\t ... not enough messurements!");
- // }
+ if (currentTOF < minTOF || currentTOF > maxTOF)
+ {
+ if (this.messurementsN >= this.messurementsCount / 2)
+ {
+ this.NotifyTemperatureMessured(args.SignalTime);
+ this.WarningMessage?.Invoke("\t ... messurement saved, start looking new temperature change!");
+ }
+ else
+ {
+ this.ErrorMessage?.Invoke("\t ... not enough messurements!");
+ }
- // this.ErrorMessage?.Invoke($"\t ... TOF is not in a tolerance span - {minTOF} <= {currentTOF} <= {maxTOF}!");
- // this.StartMessuring();
+ this.ErrorMessage?.Invoke($"\t ... TOF is not in a tolerance span - {minTOF} <= {currentTOF} <= {maxTOF}!");
+ this.StartMessuring();
- // return;
- // }
+ return;
+ }
- // this.temperatures.Add(currentT);
- // this.timesOfFliights.Add(currentTOF);
+ this.temperatures.Add(currentT);
+ this.timesOfFliights.Add(currentTOF);
- // this.InfoMessage?.Invoke($"\t{this.messurementsN,4}\t {args.SignalTime,8:hh:mm:ss}\t{currentTOF,17:F15}\t {currentT,5:F2}");
+ this.InfoMessage?.Invoke($"\t{this.messurementsN,4}\t {args.SignalTime,8:hh:mm:ss}\t{currentTOF,17:F15}\t {currentT,5:F2}");
- // if (this.messurementsN >= this.messurementsCount)
- // {
- // this.NotifyTemperatureMessured(args.SignalTime);
- // this.InfoMessage?.Invoke("\t ... messurement done!");
- // this.StartMessuring();
+ if (this.messurementsN >= this.messurementsCount)
+ {
+ this.NotifyTemperatureMessured(args.SignalTime);
+ this.InfoMessage?.Invoke("\t ... messurement done!");
+ this.StartMessuring();
- // return;
- // }
+ return;
+ }
- // this.messurementsN++;
- //}
+ this.messurementsN++;
+ }
private void NotifyTemperatureMessured(DateTime timestamp)
{
diff --git a/Common/Ui/GenesisToolBox/Ui - Verknüpfung.lnk b/Common/Ui/GenesisToolBox/Ui - Verknüpfung.lnk
deleted file mode 100644
index 14eaefa8..00000000
Binary files a/Common/Ui/GenesisToolBox/Ui - Verknüpfung.lnk and /dev/null differ