diff --git a/Common/LaaProduction/Programm.cs b/Common/LaaProduction/Programm.cs
index 4565bdb7..415e70c3 100644
--- a/Common/LaaProduction/Programm.cs
+++ b/Common/LaaProduction/Programm.cs
@@ -1,7 +1,5 @@
namespace LaaProduction
{
- using Newtonsoft.Json;
-
class Programm
{
static void Main()
diff --git a/Common/Ui/GenesisToolBox/FrmTempMeter.cs b/Common/Ui/GenesisToolBox/FrmTempMeter.cs
index 0f1cd44e..2e261a6b 100644
--- a/Common/Ui/GenesisToolBox/FrmTempMeter.cs
+++ b/Common/Ui/GenesisToolBox/FrmTempMeter.cs
@@ -646,8 +646,6 @@
this.btnAddLut.Enabled = false;
this.nudRef.Visible = false;
this.btnRefreshLut.Enabled = false;
- //this.startAutomaticBtn.Enabled = false;
- //this.stopAutomaticBtn.Enabled = false;
break;
case ProgrammState.Connected:
this.btnStartRecord.Enabled = true;
@@ -655,8 +653,6 @@
this.btnAddLut.Enabled = false;
this.nudRef.Visible = false;
this.btnRefreshLut.Enabled = true;
- //this.startAutomaticBtn.Enabled = true;
- //this.stopAutomaticBtn.Enabled = false;
break;
case ProgrammState.RecordRuning:
this.btnStartRecord.Enabled = false;
@@ -664,8 +660,6 @@
this.btnAddLut.Enabled = false;
this.nudRef.Visible = false;
this.btnRefreshLut.Enabled = true;
- //this.startAutomaticBtn.Enabled = false;
- //this.stopAutomaticBtn.Enabled = true;
break;
case ProgrammState.RecordStoped:
this.btnStartRecord.Enabled = true;
@@ -673,8 +667,6 @@
this.btnAddLut.Enabled = true;
this.nudRef.Visible = true;
this.btnRefreshLut.Enabled = true;
- //this.startAutomaticBtn.Enabled = true;
- //this.stopAutomaticBtn.Enabled = false;
break;
default:
break;
@@ -718,12 +710,14 @@
{
if (this.currentGenesis is null)
{
+ MessageBox.Show(this, "Water meter not connected!", "Start aborted", MessageBoxButtons.OK);
+
return;
}
this.automatic = true;
this.start = DateTimeOffset.Now;
- this.messurementsFile = $"messurements.txt";
+ this.messurementsFile = $"_messurements.txt";
this.currentGenesis.StartRecordData();
this.currentGenesis.WriteRegister(Register.Genesisflow.SampleRate, (byte)16, checkRegister: true);
@@ -756,10 +750,12 @@
this.MergeToAutoFile();
this.automaticCalibration.StopMessuring();
+
this.currentGenesis.WriteRegister(Register.Genesisflow.SampleRate, (byte)0, checkRegister: true);
this.currentGenesis.WriteRegister("GENESISFLOW_MaxValidDeltaToF", 4294967295, checkRegister: true);
this.currentGenesis.WriteRegister("GENESISFLOW_MaxValidToF", 4294967295, checkRegister: true);
this.currentGenesis.WriteRegister("GENESISFLOW_MinValidToF", (uint)0, checkRegister: true);
+
this.SetEnabled(ProgrammState.RecordStoped);
this.startAutomaticBtn.Enabled = true;
@@ -783,6 +779,15 @@
{
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;
@@ -801,12 +806,37 @@
private void SaveMessurement(double meterTOF, double temperature, DateTime timestamp)
{
var pcbid = this.currentGenesis?.PcbId ?? "000000000";
+
+ File.AppendAllLines("_temp_luts.txt", new[] { $"{pcbid}\t{temperature:F2}\t{meterTOF}\t{timestamp}" });
- File.AppendAllLines(this.messurementsFile, new[] { $"{pcbid}\t{temperature}\t{meterTOF}\t{timestamp}" });
- // Note: the MeterProcessState should be also updated.
- // To the endpoint was added new property: dt <=> Timestamp -> this is the timestamp provided from the automatic temperature calibration.
- File.AppendAllLines("temp_luts.txt", new[] { $"{pcbid}\t{temperature}\t{meterTOF}\t{timestamp}" });
- // LocalWebRequest.PostRequestAsync($"http://10.49.40.25/MeterProcessState/api/TempFlange/AddLut?PcbId={pcbid}&RefTempC={temperature}&AvgTof={meterTOF}&dt={timestamp}");
+ // TODO: LocalWebRequest.PostRequestAsync(
+ // $"http://10.49.40.25/MeterProcessState/api/TempFlange/AddLut?PcbId={pcbid}&RefTempC={temperature}&AvgTof={meterTOF}&dt={timestamp}");
+ }
+
+ protected override void OnClosed(EventArgs e)
+ {
+ base.OnClosed(e);
+
+ this.automatic = false;
+
+ if (this.automaticCalibration != null)
+ {
+ this.automaticCalibration.TemperatureMesured -= this.SaveMessurement;
+ this.automaticCalibration.InfoMessage -= message => this.AddMessage(message, Color.Black);
+ this.automaticCalibration.ErrorMessage -= message => this.AddMessage(message, Color.Red);
+ this.automaticCalibration.WarningMessage -= message => this.AddMessage(message, Color.Orange);
+
+ this.automaticCalibration.StopMessuring();
+ }
+
+ try
+ {
+ this.MergeToAutoFile();
+ }
+ catch (Exception)
+ {
+ // TODO:
+ }
}
}
}
diff --git a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj
index 961867ac..0b6465d5 100644
--- a/Common/Ui/GenesisToolBox/GenesisToolBox.csproj
+++ b/Common/Ui/GenesisToolBox/GenesisToolBox.csproj
@@ -761,6 +761,9 @@
true
+
+
+