E15 and E16 implementation in progress.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
using Results.Entities;
|
||||
|
||||
@@ -14,8 +13,8 @@ namespace TBF.BenchControl.GenericDevices
|
||||
|
||||
int GetErrorFlags(TestRslt testRslt, bool getE9E10, bool getE11E12, int switchTimeStart, int switchTimeEnd);
|
||||
|
||||
int GetE15(IList<MeterTestRslt> meterTestRslts); /// Return value is either 0 (=OK) or 0x4000 (=E15), it should be OR-ed with error flags
|
||||
int GetE15(MeterTestRslt mtrQ3, MeterTestRslt mtrQ2, MeterTestRslt mtrQ1); /// Return value is either 0 (=OK) or 0x4000 (=E15), it should be OR-ed with error flags
|
||||
|
||||
int GetE16(IList<MeterTestRslt> meterTestRslts); /// Return value is either 0 (=OK) or 0x8000 (=E16), it should be OR-ed with error flags
|
||||
int GetE16(MeterTestRslt mtrQ3, MeterTestRslt mtrQ2, MeterTestRslt mtrQ1); /// Return value is either 0 (=OK) or 0x8000 (=E16), it should be OR-ed with error flags
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,8 @@ namespace TBF.BenchControl.Various.ErrorFlags
|
||||
{
|
||||
public class Errors : ComponentBase, GenericDevices.IErrorFlags
|
||||
{
|
||||
/// TODO: Implement support for sharing one camera by multiple ROI-s
|
||||
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Errors));
|
||||
public override string ToString()
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1));
|
||||
}
|
||||
@@ -116,20 +114,43 @@ namespace TBF.BenchControl.Various.ErrorFlags
|
||||
return ErrorFlags;
|
||||
}
|
||||
|
||||
public int GetE15(IList<MeterTestRslt> meterTestRslts)
|
||||
|
||||
MeterTestRslt GetMtrTstRsltFromNames(IList<MeterTestRslt> meterTestRslts, string testNames)
|
||||
{
|
||||
if (Mode == Config.Entities.ErrorFlagsMode.Off || !errorsCfg.TestParams.E15)
|
||||
if (string.IsNullOrEmpty(testNames)) return null;
|
||||
|
||||
string[] names = testNames.Split(new char[] { ';' });
|
||||
|
||||
foreach (var nm in names)
|
||||
{
|
||||
return 0;
|
||||
foreach (var mtr in meterTestRslts) if (mtr.Name() == nm) return mtr;
|
||||
}
|
||||
|
||||
MeterTestRslt mtrQ3 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q3Names);
|
||||
MeterTestRslt mtrQ2 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q2Names);
|
||||
MeterTestRslt mtrQ1 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q1Names);
|
||||
return null; /// No matching MeterTestRslt found
|
||||
}
|
||||
|
||||
if (mtrQ3 != null && mtrQ3.TestDone && (mtrQ3.Error > mtrQ3.ErrLimHi() / 2) &&
|
||||
mtrQ2 != null && mtrQ2.TestDone && (mtrQ2.Error > mtrQ2.ErrLimHi() / 2) &&
|
||||
mtrQ1 != null && mtrQ1.TestDone && (mtrQ1.Error > mtrQ1.ErrLimHi() / 2))
|
||||
/// <summary>
|
||||
/// Returns 'true' when all three test were found and all three are 'TestDone'
|
||||
/// </summary>
|
||||
/// <param name="meterTestRslts"></param>
|
||||
/// <param name="mtrQ3">mtrQ3 or null</param>
|
||||
/// <param name="mtrQ2">mtrQ2 or null</param>
|
||||
/// <param name="mtrQ1">mtrQ1 or null</param>
|
||||
/// <returns></returns>
|
||||
public bool GetSelectedMtrs(IList<MeterTestRslt> meterTestRslts, out MeterTestRslt mtrQ3, out MeterTestRslt mtrQ2, out MeterTestRslt mtrQ1)
|
||||
{
|
||||
mtrQ3 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q3Names);
|
||||
mtrQ2 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q2Names);
|
||||
mtrQ1 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q1Names);
|
||||
|
||||
return (mtrQ3 != null && mtrQ3.TestDone && mtrQ2 != null && mtrQ2.TestDone && mtrQ1 != null && mtrQ1.TestDone);
|
||||
}
|
||||
|
||||
public int GetE15(MeterTestRslt mtrQ3, MeterTestRslt mtrQ2, MeterTestRslt mtrQ1)
|
||||
{
|
||||
if ((mtrQ3.Error > mtrQ3.ErrLimHi() / 2) &&
|
||||
(mtrQ2.Error > mtrQ2.ErrLimHi() / 2) &&
|
||||
(mtrQ1.Error > mtrQ1.ErrLimHi() / 2))
|
||||
{
|
||||
return 0x4000;
|
||||
}
|
||||
@@ -139,20 +160,11 @@ namespace TBF.BenchControl.Various.ErrorFlags
|
||||
}
|
||||
}
|
||||
|
||||
public int GetE16(IList<MeterTestRslt> meterTestRslts)
|
||||
public int GetE16(MeterTestRslt mtrQ3, MeterTestRslt mtrQ2, MeterTestRslt mtrQ1)
|
||||
{
|
||||
if (Mode == Config.Entities.ErrorFlagsMode.Off || !errorsCfg.TestParams.E16)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MeterTestRslt mtrQ3 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q3Names);
|
||||
MeterTestRslt mtrQ2 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q2Names);
|
||||
MeterTestRslt mtrQ1 = GetMtrTstRsltFromNames(meterTestRslts, errorsCfg.Q1Names);
|
||||
|
||||
if (mtrQ3 != null && mtrQ3.TestDone && (mtrQ3.Error < mtrQ3.ErrLimLo() / 2) &&
|
||||
mtrQ2 != null && mtrQ2.TestDone && (mtrQ2.Error < mtrQ2.ErrLimLo() / 2) &&
|
||||
mtrQ1 != null && mtrQ1.TestDone && (mtrQ1.Error < mtrQ1.ErrLimLo() / 2))
|
||||
if ((mtrQ3.Error < mtrQ3.ErrLimLo() / 2) &&
|
||||
(mtrQ2.Error < mtrQ2.ErrLimLo() / 2) &&
|
||||
(mtrQ1.Error < mtrQ1.ErrLimLo() / 2))
|
||||
{
|
||||
return 0x8000;
|
||||
}
|
||||
@@ -162,18 +174,18 @@ namespace TBF.BenchControl.Various.ErrorFlags
|
||||
}
|
||||
}
|
||||
|
||||
MeterTestRslt GetMtrTstRsltFromNames(IList<MeterTestRslt> meterTestRslts, string testNames)
|
||||
public int GetErrorFlags(IList<MeterTestRslt> meterTestRslts)
|
||||
{
|
||||
if (string.IsNullOrEmpty(testNames)) return null;
|
||||
MeterTestRslt mtrQ3, mtrQ2, mtrQ1;
|
||||
int errorFlags = 0;
|
||||
|
||||
string[] names = testNames.Split(new char[] {';'});
|
||||
|
||||
foreach (var nm in names)
|
||||
if (GetSelectedMtrs(meterTestRslts, out mtrQ3, out mtrQ2, out mtrQ1))
|
||||
{
|
||||
foreach (var mtr in meterTestRslts) if (mtr.Name() == nm) return mtr;
|
||||
errorFlags |= GetE15(mtrQ3, mtrQ1, mtrQ1);
|
||||
errorFlags |= GetE16(mtrQ3, mtrQ1, mtrQ1);
|
||||
}
|
||||
|
||||
return null; /// No matching MeterTestRslt found
|
||||
|
||||
return errorFlags;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +203,7 @@ namespace TBF.BenchControl.Various.ErrorFlags
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
#region Configuration Change Handling
|
||||
|
||||
public static void OnCfgChange(object sender, CfgChangeArgs args)
|
||||
|
||||
Reference in New Issue
Block a user