This commit is contained in:
Roland Drabesch
2023-03-06 15:13:26 +01:00
24 changed files with 707 additions and 219 deletions
@@ -1,11 +1,11 @@
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Threading;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus;
using Xylem.Common.Logic.SoftwareAccessHelper;
namespace ProductionUiCordonel.ProductionProcesses.Actions
@@ -108,9 +108,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Progress = 50;
var nowSeconds = Meter.ReadRegister("POWERMON_TotalUsedSeconds");
var nowCharge = Meter.ReadRegister("POWERMON_TotalUsedCharge", 8);
if (nowCharge == null)
var genesisStatus = new GenesisStatus();
// this calculates all life time values
if (!GenesisStatusHandler.BuildLifeTimeInformation(Meter, genesisStatus))
{
UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send,
@@ -122,26 +123,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Meter.WriteLog("Batterie nicht lesbar");
break;
}
var nowChargeV = BitConverter.ToUInt64(nowCharge.ToArray(), 0);
var nowSecondsV = BitConverter.ToUInt32(nowSeconds.ToArray(), 0);
//// Time Span in h in mAhr In % with one battery is 100%
////(((total used change difference / (Time span / 3600) ) / 3600000) / 19000)*100
// ReSharper disable once UnusedVariable used for debug purposes
var loadAtH = nowChargeV / ((Double)nowSecondsV / 3600) / 3600000 / (19000 * 2) * 100;
var totalUsed = (Double)nowChargeV / 1000000 / 3.6 / (19000 * 2) * 100;
//lastFrame
Meter.WriteLog($"totalUsed at EOL {totalUsed}");
if (totalUsed > 10)
Meter.WriteLog($"totalUsed at EOL {genesisStatus.DrainedBatteryLoadPercent:F2}");
if (genesisStatus.DrainedBatteryLoadPercent > 10.0)
{
currentProcessState = ProductionProcessState.Error;
UserControl.lblText.Content = "Batterie über 15% entladen";
Meter.WriteLog("Batterie über 15% entladen");
UserControl.lblText.Content = "Batterie über 10% entladen";
Meter.WriteLog("Batterie über 10% entladen");
}
if (currentProcessState != ProductionProcessState.Error)
@@ -149,7 +139,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
currentProcessState = ProductionProcessState.Done;
return;
}
retriesRemaining = retriesRemaining - 1;
retriesRemaining -= 1;
currentProcessState = ProductionProcessState.Error;
}
@@ -157,10 +147,8 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
Meter.WriteLog($"{ex}");
currentProcessState = ProductionProcessState.Error;
retriesRemaining = retriesRemaining - 1;
retriesRemaining -= 1;
}
}
currentProcessState = ProductionProcessState.Error;
}