add revers mesuremnt to magflux

This commit is contained in:
Roland Drabesch
2023-06-29 09:36:13 +02:00
parent 37c5708f30
commit fde54896d9
19 changed files with 139 additions and 28 deletions
@@ -168,7 +168,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <summary>
/// the first measurement is ALWAYS a FlowTestRecord due to the underlying<see cref="GetAllMeasurementResults"/> routine logic.
/// </summary>
public MeasurementResults GetMainMeasurementResult(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false)
public MeasurementResults GetMainMeasurementResult(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false, MeasurementDirection dir = MeasurementDirection.TakeBoth)
{
if (!intermediateMeasurement && GetMeasurementState(0) != MeasurementStates.IsCompleted)
{
@@ -180,19 +180,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <summary>
/// The first measurement is ALWAYS a FlowTestRecord.
/// </summary>
public List<MeasurementResults> GetAllMeasurementResults(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false, Int32? channel = null)
public List<MeasurementResults> GetAllMeasurementResults(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false, Int32? channel = null, MeasurementDirection dir = MeasurementDirection.TakeBoth)
{
//
if (!intermediateMeasurement && GetMeasurementState(channel) != MeasurementStates.IsCompleted)
{
throw new ApplicationException("Measurement is not completed");
}
var mainMeasurement = _listOfIMeasurement.FirstOrDefault(m => m.GetType() == typeof(FlowTestRecord));
if (mainMeasurement == null)
{
throw new ApplicationException("Can not find an ongoing measurement");
}
mainMeasurement.FlowDirectionforCalculatingVol = dir;
var results = new List<MeasurementResults>();
var mainResult = intermediateMeasurement
? mainMeasurement.GetIntermediateMeasurementResult(refVolume, refTimeS)
@@ -864,18 +864,19 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
/// <inheritdoc />
public MeasurementResults GetMainMeasurementResult(Double? refVolume, Double? refTimeS,
Boolean intermediateMeasurement = false)
Boolean intermediateMeasurement = false, MeasurementDirection dir = MeasurementDirection.TakeBoth)
{
if (!intermediateMeasurement && GetMeasurementState(0) != MeasurementStates.IsCompleted)
{
throw new ApplicationException("Measurement is not completed");
}
return GetAllMeasurementResults(refVolume, refTimeS, intermediateMeasurement, 0).First();
return GetAllMeasurementResults(refVolume, refTimeS, intermediateMeasurement, 0,dir).First();
}
/// <inheritdoc />
///
public List<MeasurementResults> GetAllMeasurementResults(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false,
Int32? channel = null)
Int32? channel = null, MeasurementDirection dir = MeasurementDirection.TakeBoth)
{
if (!intermediateMeasurement && GetMeasurementState(channel) != MeasurementStates.IsCompleted)
{
@@ -169,14 +169,14 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
/// After a completed measurement , you can grab <see cref="MeasurementResults"/>
/// </summary>
/// <returns>Calculated results</returns>
MeasurementResults GetMainMeasurementResult(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false);
MeasurementResults GetMainMeasurementResult(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false, MeasurementDirection dir = MeasurementDirection.TakeBoth);
/// <summary>
/// The first measurement is ALWAYS a FlowTestRecord.
/// </summary>
List<MeasurementResults> GetAllMeasurementResults(Double? refVolume, Double? refTimeS,
Boolean intermediateMeasurement = false, Int32? channel = null);
Boolean intermediateMeasurement = false, Int32? channel = null, MeasurementDirection dir = MeasurementDirection.TakeBoth);
@@ -283,5 +283,6 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
/// Clear all object set up on runtime
/// </summary>
void DisposeMeter();
}
}
@@ -1 +1 @@
1a3d4919c9c702245832d925951f2b7cb72fc333
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
@@ -42,6 +42,9 @@ namespace Xylem.Common.Metrology.Measurements
/// </summary>
public IMeasurementRecord IntermediateRecord;
/// <inheritdoc />
public event EventHandler OnActionStateHasChanged;
@@ -116,6 +119,10 @@ namespace Xylem.Common.Metrology.Measurements
}
}
public MeasurementDirection FlowDirectionforCalculatingVol { get; set; } = MeasurementDirection.TakeBoth;
/// <summary>
///
/// </summary>
@@ -216,7 +223,7 @@ namespace Xylem.Common.Metrology.Measurements
throw new ApplicationException("Measurement records missing");
return new MeasurementResults(DutStartRecord, DutStopRecord, _accuDutOverflowVolumeCm,
_accuDutOverflowTimeS, refVolumeCm, refTimeS, _channel);
_accuDutOverflowTimeS, refVolumeCm, refTimeS, _channel, FlowDirectionforCalculatingVol);
}
private void CheckForOverFlowVolumeAndTime()
@@ -0,0 +1,12 @@
namespace Xylem.Common.Metrology.Measurements.Consts
{
public enum MeasurementDirection
{
TakeBoth,
TakeOnlyForward,
TakeOnlyBackward,
}
}
@@ -31,6 +31,12 @@ namespace Xylem.Common.Metrology.Measurements
/// </summary>
MeasurementStates MeasurementState { get; set; }
/// <summary>
/// Actual state of the measurement
/// </summary>
MeasurementDirection FlowDirectionforCalculatingVol { get; set; }
/// <summary>
/// Clear start, intermediate and end record and set action state to idle
/// </summary>
@@ -14,7 +14,13 @@ namespace Xylem.Common.Metrology.Measurements
/// Get volume of the record
/// </summary>
Double GetVolumeCm();
Double GetNegativeReserveVolumeCm();
Double GetForwardVolumeCm();
/// <summary>
/// Get time stamp of the record from meter
/// </summary>
@@ -116,5 +116,17 @@ namespace Xylem.Common.Metrology.Measurements
{
return MemberwiseClone();
}
public Double GetNegativeReserveVolumeCm()
{
return NegativeReverseVolumeCm;
}
public Double GetForwardVolumeCm()
{
return ForwardVolumeCm;
}
}
}
@@ -8,6 +8,7 @@ namespace Xylem.Common.Metrology.Measurements
/// </summary>
public struct MeasurementResults
{
/// <inheritdoc cref="MeasurementResultsStates"/>
public readonly MeasurementResultsStates State;
@@ -157,7 +158,7 @@ namespace Xylem.Common.Metrology.Measurements
/// <param name="requiredChannel">physical channel of measurement path (0 for main measurement)</param>
public MeasurementResults(IMeasurementRecord dutStartRecord, IMeasurementRecord dutStopRecord,
Double accuDutOverflowVolumeCm = 0.0, Double accuDutOverflowTimeS = 0.0, Double? refVolumeCm = null,
Double? refTimeS = null, Int32 requiredChannel = 0)
Double? refTimeS = null, Int32 requiredChannel = 0, MeasurementDirection takeDirections = MeasurementDirection.TakeBoth)
{
//backup input
DutStartRecord = dutStartRecord;
@@ -185,9 +186,26 @@ namespace Xylem.Common.Metrology.Measurements
State = MeasurementResultsStates.WrongChannel;
return;
}
//build the measured volume
DutVolumeCm = (DutStopRecord.GetVolumeCm() + accuDutOverflowVolumeCm) - DutStartRecord.GetVolumeCm();
switch (takeDirections)
{
case MeasurementDirection.TakeBoth:
//build the measured volume
DutVolumeCm = (DutStopRecord.GetVolumeCm() + accuDutOverflowVolumeCm) - DutStartRecord.GetVolumeCm();
break;
case MeasurementDirection.TakeOnlyForward:
//build the measured volume
DutVolumeCm = (DutStopRecord.GetForwardVolumeCm() + accuDutOverflowVolumeCm) - DutStartRecord.GetForwardVolumeCm();
break;
case MeasurementDirection.TakeOnlyBackward:
//build the measured volume
DutVolumeCm = (DutStopRecord.GetNegativeReserveVolumeCm() + accuDutOverflowVolumeCm) - DutStartRecord.GetNegativeReserveVolumeCm();
break;
default:
//build the measured volume
DutVolumeCm = (DutStopRecord.GetVolumeCm() + accuDutOverflowVolumeCm) - DutStartRecord.GetVolumeCm();
break;
}
//assume a correct measurement for static start/stop procedure, in case of flying start/stop
//this is going to be overwritten if REF time is set
CorrectedDutVolumeCm = DutVolumeCm;
@@ -176,6 +176,7 @@
</Compile>
<Compile Include="BaseMeasurement.cs" />
<Compile Include="CalibrationMeasurement.cs" />
<Compile Include="Consts\MeasurementDirection.cs" />
<Compile Include="Consts\MeasurementResultsStates.cs" />
<Compile Include="Consts\MeasurementStates.cs" />
<Compile Include="Consts\ProcessStates.cs" />
@@ -282,6 +282,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
funkadresse.AddRange((new Byte[] { 0xAC, 0x21, 0x65, 0x35 }).ToArray());
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_EncryptionKey", funkadresse.ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_RadioAddress", radioParams.RadioAddress, true, true));
if (radioParams.PowerLevel > 0 && radioParams.PowerLevelOption > 0 && radioParams.ImpedanceCodeNew > 0 && radioParams.ImpedanceCodeOption > 0)
@@ -1 +1 @@
f64d563def603c89cafafa61a3219ba97e1e344c
0d85a5b3a7561b41163c20e5dc7713bcd0d65555
@@ -16,6 +16,8 @@ namespace XylemCommonUiLegacyGenCtl.DataPackage
public decimal FlowAdjustmentTarget { get; set; }
public bool PreAdjustment { get; set; }
public bool FlowTesting { get; set; }
public Boolean FlowTestingOnlyForward { get; internal set; }
public Boolean FlowTestingOnlyRevers { get; internal set; }
}
public class MeterTestResults
@@ -51,6 +51,8 @@ namespace XylemCommonUiLegacyGenCtl.DataPackage
sb.AppendLine($"FlowAdjustment={item.FlowAdjustment}");
sb.AppendLine($"FlowAdjustmentTarget={item.FlowAdjustmentTarget}");
sb.AppendLine($"meterType={item.meterType}");
sb.AppendLine($"FlowTestingOnlyForward={item.FlowTestingOnlyForward}");
sb.AppendLine($"FlowTestingOnlyRevers={item.FlowTestingOnlyRevers}");
}
@@ -182,11 +182,13 @@ namespace XylemCommonUiLegacyGenCtl
/// <param name="doubleRefTime">Time in S how long the messuremnt on the ref was running</param>
/// <returns></returns>
Results GetResults(int Slot, int Chnnl, double refVol, double doubleRefTime);
/// <summary>
/// write a log entry from the caller (test bench) to the current meters log file
/// </summary>
/// <param name="slot">Slot for identify the meter</param>
/// <param name="message"></param>
///
void LogMeter(int slot, string message);
/// <summary>
+1 -1
View File
@@ -38,7 +38,7 @@ namespace XylemCommonUiLegacyGenCtl
void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting);
void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting, bool MagFlux, bool Cordonel, bool ReversFlow);
string GetMeterSerialNr(int Slot);
bool GetFlowAdjustment(int Slot);
bool GetPreAdjustment(int Slot);
+22 -2
View File
@@ -174,10 +174,11 @@ namespace XylemCommonUiLegacyGenCtl
#region MeterStuff
public void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting)
public void SetMeterTestSettings(int Slot, string SerialNr, bool FlowAdjustment, double FlowAdjustmentTarget, bool PreAdjustment, bool FlowTesting, bool MagFlux, bool Cordonel,bool ReversFlow)
{
HanldWrongInputMeters(Slot);
@@ -199,7 +200,26 @@ namespace XylemCommonUiLegacyGenCtl
testSetup.meterTestSettings[Slot - 1].FlowAdjustmentTarget = Convert.ToDecimal(FlowAdjustmentTarget);
testSetup.meterTestSettings[Slot - 1].PreAdjustment = PreAdjustment;
testSetup.meterTestSettings[Slot - 1].FlowTesting = FlowTesting;
testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.MagFlux;
if (MagFlux)
{
testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.MagFlux;
}
if (Cordonel)
{
testSetup.meterTestSettings[Slot - 1].meterType = Xylem.Common.Hardware.WaterMeter.WaterMeterCore.MeterTypes.Cordonel;
}
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyForward = true;
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyRevers = false;
if (ReversFlow)
{
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyForward = false;
testSetup.meterTestSettings[Slot - 1].FlowTestingOnlyRevers = true;
}
}
+25 -8
View File
@@ -884,7 +884,6 @@ namespace XylemCommonUiLegacyGenCtl
{
if (TestSetupContainer == null)
{
MessageBox.Show("TestSetupContainer is null so add a new one");
TestSetupContainer = new TestSetupContainer();
TestSetupContainer.AllChanelsRequired = true;
TestSetupContainer.meterTestSettings = new MeterTestSettings[10];
@@ -893,7 +892,6 @@ namespace XylemCommonUiLegacyGenCtl
if (!TestSetupContainer.meterTestSettings.Any(f => f != null && f.Slot == slot))
{
MessageBox.Show($"TestSetupContainer has no entrys for Slot {slot}");
TestSetupContainer.meterTestSettings[slot] = new MeterTestSettings() { SerialNr = serialNumber, Slot = slot, FlowAdjustment = true, FlowTesting = true };
TestSetupContainer.meterTestResults[slot] = new MeterTestResults() { SerialNr = serialNumber, Slot = slot, meterType = MeterTypes.MagFlux, Results = new List<Xylem.Common.Hardware.WaterMeter.DataPackages.MeasurementRecords.FlowDeviations>() };
@@ -1021,7 +1019,7 @@ namespace XylemCommonUiLegacyGenCtl
sb.AppendLine($"Results: {result.SerialNr} on ep. {result.Slot}");
foreach (var flowDeviations in result.Results)
{
MessageBox.Show($"RefFlow {flowDeviations.MeasuredRefFlowQmPerH} (for {flowDeviations.RefTimeS} Seconds) vs DutFlow {flowDeviations.MeasuredDutFlowQmPerH} (for {flowDeviations.DutTimeS} Seconds)");
//MessageBox.Show($"RefFlow {flowDeviations.MeasuredRefFlowQmPerH} (for {flowDeviations.RefTimeS} Seconds) vs DutFlow {flowDeviations.MeasuredDutFlowQmPerH} (for {flowDeviations.DutTimeS} Seconds)");
sb.AppendLine($"RefFlow {flowDeviations.MeasuredRefFlowQmPerH} (for {flowDeviations.RefTimeS} Seconds) vs DutFlow {flowDeviations.MeasuredDutFlowQmPerH} (for {flowDeviations.DutTimeS} Seconds)");
}
//MessageBox.Show(sb.ToString());
@@ -1516,7 +1514,7 @@ namespace XylemCommonUiLegacyGenCtl
}
private MeasurementResults? GetMeasurementResult(Int32 Slot, Int32 Chnnl, Double refVolQm, Double refTimeS)
private MeasurementResults? GetMeasurementResult(Int32 Slot, Int32 Chnnl, Double refVolQm, Double refTimeS, MeasurementDirection dir = MeasurementDirection.TakeBoth)
{
try
{
@@ -1543,7 +1541,7 @@ namespace XylemCommonUiLegacyGenCtl
}
}
result = refTimeS == 0.0 ? meter.GetMainMeasurementResult(refVolQm, null) : meter.GetMainMeasurementResult(refVolQm, refTimeS);
result = refTimeS == 0.0 ? meter.GetMainMeasurementResult(refVolQm, null, dir: dir) : meter.GetMainMeasurementResult(refVolQm, refTimeS, dir: dir);
return result;
}
catch (Exception ex)
@@ -1559,7 +1557,26 @@ namespace XylemCommonUiLegacyGenCtl
try
{
//todo remove
var result = GetMeasurementResult(Slot, Chnnl, refVolQm, refTimeS);
MeasurementResults? result;
var t = MeasurementDirection.TakeBoth;
if (TestSetupContainer != null && TestSetupContainer.meterTestSettings != null && TestSetupContainer.meterTestSettings.Any(ts => ts.Slot == Slot))
{
var testset = TestSetupContainer.meterTestSettings.First(ts => ts.Slot == Slot);
if (testset.FlowTestingOnlyRevers)
{
t = MeasurementDirection.TakeOnlyBackward;
}
else if (testset.FlowTestingOnlyForward)
{
t = MeasurementDirection.TakeOnlyForward;
}
}
result = GetMeasurementResult(Slot, Chnnl, refVolQm, refTimeS,t);
if (!result.HasValue)
{
_logger.Warn($"No Result found for GetResults(Slot={Slot},Chnnl={Chnnl},refVolQm={refVolQm},refTimeS={refTimeS})");
@@ -1595,14 +1612,14 @@ namespace XylemCommonUiLegacyGenCtl
if (TestSetupContainer.meterTestResults == null)
{
MessageBox.Show("meterTestResults emtpty on getresults");
// MessageBox.Show("meterTestResults emtpty on getresults");
var countMeters = TestSetupContainer.meterTestSettings?.Count() ?? 10;
TestSetupContainer.meterTestResults = new MeterTestResults[countMeters];
}
if (!TestSetupContainer.meterTestResults.Any(f => f != null && f.Slot == Slot))
{
MessageBox.Show("meterTestResults not found on getresults");
// MessageBox.Show("meterTestResults not found on getresults");
TestSetupContainer.meterTestResults[Slot - 1].Results = new List<Xylem.Common.Hardware.WaterMeter.DataPackages.MeasurementRecords.FlowDeviations>();
}