2Hz correction related changes: iPerlCommunication: 'Reset 2Hz correction', 'Write 2Hz correction' + OraDB changes.
This commit is contained in:
parent
a22b4de1b6
commit
4b1a684d69
@ -25,8 +25,11 @@ namespace Results.Entities
|
||||
public virtual double CalibFactor { get; set; } /// iPerl calibration factor used during the test - Not mapped to DB !!!
|
||||
public virtual double Q2ErrWOCorrection { get; set; }
|
||||
public virtual bool Q2CorrectionDone { get; set; } /// true = iPerl Q2 correction was done
|
||||
public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test - Not mapped to DB !!!
|
||||
public virtual int Q2CorrFlowRight { get; set; } /// 1 = right to left
|
||||
public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test
|
||||
public virtual int Q2CorrFlowRight { get; set; } /// 1 = right to left
|
||||
public virtual double Diff2Hz8Hz { get; set; }
|
||||
public virtual bool Hz2CorrectionDone { get; set; } /// true = iPerl Q2 correction was done - Not mapped to DB !!!
|
||||
public virtual int Hz2Correction { get; set; } /// iPerl Q2 correction used during the test - Not mapped to DB !!!
|
||||
#endif
|
||||
public virtual WaterMeterData WaterMeterData { get; set; }
|
||||
public virtual Batch Batch { get; set; }
|
||||
|
||||
@ -934,9 +934,9 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
parm = new OracleParameter("VT_Fernum", OracleDbType.Varchar2); parm.Value = wm.SerialNr; cmd.Parameters.Add(parm); ///:1
|
||||
parm = new OracleParameter("Pruefindex", OracleDbType.Int32); parm.Value = max_Pruefindex; cmd.Parameters.Add(parm); ///:2
|
||||
parm = new OracleParameter("ANBID", OracleDbType.Int32); parm.Value = Anbid_StaraTura; cmd.Parameters.Add(parm); ///:3
|
||||
parm = new OracleParameter("WITHCORRECTION2HZ", OracleDbType.Int32); parm.Value = 0; cmd.Parameters.Add(parm); ///:4
|
||||
parm = new OracleParameter("CORRECTION2HZ", OracleDbType.Double); parm.Value = 0; cmd.Parameters.Add(parm); ///:5
|
||||
parm = new OracleParameter("DIFF2HZ8HZ", OracleDbType.Double); parm.Value = 0; cmd.Parameters.Add(parm); ///:6
|
||||
parm = new OracleParameter("WITHCORRECTION2HZ", OracleDbType.Int32); parm.Value = wm.Hz2CorrectionDone ? 1 : 0; cmd.Parameters.Add(parm); ///:4
|
||||
parm = new OracleParameter("CORRECTION2HZ", OracleDbType.Double); parm.Value = wm.Hz2Correction; cmd.Parameters.Add(parm); ///:5
|
||||
parm = new OracleParameter("DIFF2HZ8HZ", OracleDbType.Double); parm.Value = wm.Diff2Hz8Hz; cmd.Parameters.Add(parm); ///:6
|
||||
parm = new OracleParameter("WITHQ2CORRECTION", OracleDbType.Int32); parm.Value = wm.Q2CorrectionDone ? 1 : 0; cmd.Parameters.Add(parm); ///:7
|
||||
parm = new OracleParameter("ERRQ2", OracleDbType.Double); parm.Value = q2ErrWOCorrection; cmd.Parameters.Add(parm); ///:8
|
||||
parm = new OracleParameter("Q2CORRECTIONFLOWRIGHT", OracleDbType.Int32);parm.Value = wm.Q2CorrFlowRight;/*1=right to left*/ cmd.Parameters.Add(parm); ///:9
|
||||
|
||||
@ -241,7 +241,11 @@ namespace TBF.BenchControl.DataEntry.iPerl
|
||||
wm.CalibFactor = iPerl.CalibrationFactor;
|
||||
wm.Q2ErrWOCorrection = iPerl.Q2ErrorWOCorrection;
|
||||
wm.Q2CorrectionDone = iPerl.Q2CorrectionDone;
|
||||
wm.Q2Correction = iPerl.CurrentQ2Correction;
|
||||
wm.Q2Correction = iPerl.Q2CorrectionFactor;
|
||||
wm.Diff2Hz8Hz = iPerl.Diff2Hz8Hz;
|
||||
wm.Hz2CorrectionDone = iPerl.Hz2CorrectionDone;
|
||||
wm.Hz2Correction = iPerl.Hz2CorrectionFactor;
|
||||
|
||||
if (iPerl.CalibrationStruct == null)
|
||||
{
|
||||
wm.Q2CorrFlowRight = 0;
|
||||
|
||||
@ -297,14 +297,15 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
|
||||
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
|
||||
#if IPERLST
|
||||
meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
|
||||
meterRslt.WaterMeter.Q2Correction = iPerl.CurrentQ2Correction;
|
||||
meterRslt.WaterMeter.Q2Correction = iPerl.Q2CorrectionFactor;
|
||||
#endif
|
||||
iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
|
||||
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
|
||||
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
|
||||
iPerl.LastTestResult = meterRslt; /// Save this test result
|
||||
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
|
||||
}
|
||||
else
|
||||
{
|
||||
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
|
||||
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
|
||||
meterRslt.VolumeStart = 0;
|
||||
meterRslt.VolumeEnd = 0;
|
||||
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
|
||||
|
||||
@ -462,14 +462,15 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
|
||||
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
|
||||
#if IPERLST
|
||||
meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
|
||||
meterRslt.WaterMeter.Q2Correction = iPerl.CurrentQ2Correction;
|
||||
meterRslt.WaterMeter.Q2Correction = iPerl.Q2CorrectionFactor;
|
||||
#endif
|
||||
iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
|
||||
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
|
||||
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
|
||||
iPerl.LastTestResult = meterRslt; /// Save this test result
|
||||
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
|
||||
}
|
||||
else
|
||||
{
|
||||
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
|
||||
meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky
|
||||
meterRslt.VolumeStart = 0; /// liter
|
||||
meterRslt.VolumeEnd = 0; /// liter
|
||||
meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter
|
||||
|
||||
@ -239,6 +239,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
const string WriteCalibrationFactorStr = "Write calibration factor";
|
||||
const string ResetQ2CorrectionStr = "Reset Q2 correction";
|
||||
const string WriteQ2CorrectionStr = "Write Q2 correction";
|
||||
const string Reset2HzCorrectionStr = "Reset 2Hz correction";
|
||||
const string Write2HzCorrectionStr = "Write 2Hz correction";
|
||||
|
||||
|
||||
DateTime startTime;
|
||||
@ -644,6 +646,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
else if (activity.ToLower().Contains(WriteCalibrationFactorStr.ToLower())) error = WriteCalibrationFactor(wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(ResetQ2CorrectionStr.ToLower())) error = ResetQ2Correction(wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(WriteQ2CorrectionStr.ToLower())) error = WriteQ2Correction(wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(Reset2HzCorrectionStr.ToLower())) error = Reset2HzCorrection(wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(Write2HzCorrectionStr.ToLower())) error = Write2HzCorrection(wm, ref resultStr);
|
||||
else
|
||||
{
|
||||
error = CommErr.None;
|
||||
@ -1019,9 +1023,17 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Verification disabled on 16.02.2016
|
||||
///
|
||||
#if false
|
||||
/// Verify the correction factors
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
@ -1036,11 +1048,81 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
error = CommErr.None;
|
||||
resultStr = "Q2 correction factors reset to 0";
|
||||
wm.CurrentQ2Correction = 0;
|
||||
wm.Q2CorrectionFactor = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
resultStr = "Q2 corrections reset to 0";
|
||||
wm.Q2CorrectionFactor = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(wm); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reset 2Hz correction factor in the memory to 0.
|
||||
/// </summary>
|
||||
/// <param name="wm">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr Reset2HzCorrection(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (wm.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
/// Write zero Q2 correction
|
||||
byte[] wrData = new byte[1] { 0 };
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Verification disabled on 16.02.2016
|
||||
///
|
||||
#if false
|
||||
/// Verify the correction factors
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
error = CommErr.Verify;
|
||||
|
||||
/// Read calibration
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, 1, out rdData, cfg.CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == 0) && (rdData[1] == 0))
|
||||
{
|
||||
error = CommErr.None;
|
||||
resultStr = "2Hz correction reset to 0";
|
||||
wm.Q2CorrectionFactor = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
resultStr = "2Hz correction reset to 0";
|
||||
wm.Hz2CorrectionFactor = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(wm); /// Close RFID port
|
||||
|
||||
@ -1059,11 +1141,15 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
if (wm.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
/// Write Q2 corrections
|
||||
double q2CorrectionFactor = wm.Q2CorrectionFactor();
|
||||
wm.Q2ErrorWOCorrection = wm.LastTestResult.Error;
|
||||
wm.Q2CorrectionDone = false;
|
||||
|
||||
double q2CorrectionFactor;
|
||||
bool wmOK = wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2CorrectionFactor);
|
||||
|
||||
if (q2CorrectionFactor == 0)
|
||||
{
|
||||
resultStr = string.Format("Q2 factors = 0 (writing bypassed)");
|
||||
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
|
||||
return CommErr.None;
|
||||
}
|
||||
|
||||
@ -1077,12 +1163,20 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
///
|
||||
/// Verification disabled on 16.02.2016
|
||||
///
|
||||
#if false
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
error = CommErr.Verify;
|
||||
error = CommErr.Verify;
|
||||
|
||||
/// Read calibration
|
||||
byte[] rdData = null;
|
||||
@ -1091,14 +1185,24 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == q2CorrRFlow) && (rdData[1] == q2CorrLFlow))
|
||||
{
|
||||
error = CommErr.None;
|
||||
error = CommErr.None;
|
||||
resultStr = string.Format("Q2 factors: R-flow={0}, L-flow={1}", (SByte)q2CorrRFlow, (SByte)q2CorrLFlow);
|
||||
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
|
||||
wm.CurrentQ2Correction = q2CorrectionFactor;
|
||||
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
|
||||
wm.Q2CorrectionDone = true;
|
||||
wm.Q2CorrectionFactor = q2CorrectionFactor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
resultStr = string.Format("Q2 correction: R-flow={0}, L-flow={1}", (SByte)q2CorrRFlow, (SByte)q2CorrLFlow);
|
||||
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
|
||||
wm.Q2CorrectionDone = true;
|
||||
wm.Q2CorrectionFactor = q2CorrectionFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(wm); /// Close RFID port
|
||||
|
||||
@ -1116,11 +1220,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
if (wm.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
/// Write Q2 corrections
|
||||
double hz2CorrectionFactor = wm.Hz2CorrectionFactor();
|
||||
/// Calculate the correction
|
||||
wm.Hz2CorrectionDone = false;
|
||||
int hz2CorrectionFactor;
|
||||
bool wmOK = wm.Calculate2HzCorrectionFactor(wm.LastTestResult2, wm.LastTestResult, out wm.Diff2Hz8Hz, out hz2CorrectionFactor);
|
||||
|
||||
if (hz2CorrectionFactor == 0)
|
||||
{
|
||||
resultStr = string.Format("2Hz factors = 0 (writing bypassed)");
|
||||
resultStr = string.Format("2Hz correction = 0 (writing bypassed)");
|
||||
return CommErr.None;
|
||||
}
|
||||
|
||||
@ -1128,14 +1235,22 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
Byte hz2CorrectionByte = (byte)((int)Math.Round(hz2CorrectionFactor) & 0x000000FF);
|
||||
Byte hz2CorrectionByte = (byte)(hz2CorrectionFactor & 0x000000FF);
|
||||
byte[] wrData = new byte[1] { hz2CorrectionByte };
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, 1, wrData, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Verification disabled on 16.02.2016
|
||||
///
|
||||
#if false
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
error = CommErr.Verify;
|
||||
@ -1150,11 +1265,20 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
error = CommErr.None;
|
||||
resultStr = string.Format("2Hz factor = {0}", (SByte)hz2CorrectionByte);
|
||||
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
|
||||
wm.Current2HzCorrection = hz2CorrectionFactor;
|
||||
wm.Hz2CorrectionFactor = hz2CorrectionFactor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
resultStr = string.Format("2Hz correction = {0}", (SByte)hz2CorrectionByte);
|
||||
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
|
||||
wm.Hz2CorrectionDone = true;
|
||||
wm.Hz2CorrectionFactor = hz2CorrectionFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(wm); /// Close RFID port
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this);
|
||||
|
||||
const string Q2correctedFromCmd = "q2 corrected from ";
|
||||
const string Hz2correctedFromCmd = "2Hz corrected from ";
|
||||
|
||||
if (testParams.Activity.ToLower().Contains(Q2correctedFromCmd))
|
||||
{
|
||||
@ -66,7 +67,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
string fromTestName = testParams.Activity.Substring(Q2correctedFromCmd.Length);
|
||||
|
||||
MakeCorrectedFrom(test.Name, fromTestName);
|
||||
MakeQ2CorrectedFrom(test.Name, fromTestName);
|
||||
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.Completed));
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
|
||||
@ -76,6 +77,33 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
rList.Add(Event.Done);
|
||||
return rList;
|
||||
}
|
||||
//else if (testParams.Activity.ToLower().Contains(Hz2correctedFromCmd))
|
||||
//{
|
||||
// TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 60, 0, 0, 0 });
|
||||
// Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.JustStarted));
|
||||
// Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.FlowSetting));
|
||||
|
||||
// string fromTestsNames = testParams.Activity.Substring(Hz2correctedFromCmd.Length);
|
||||
// string[] fromTestsArr = fromTestsNames.Split(new char[] { ' ' });
|
||||
// if (fromTestsArr.Length == 2)
|
||||
// {
|
||||
// //MakeCorrectedFrom(test.Name, fromTestsArr[0], fromTestsArr[1]);
|
||||
|
||||
// Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.Completed));
|
||||
// Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0)));
|
||||
// allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
|
||||
|
||||
// IList<Event> rList = new List<Event>(1);
|
||||
// rList.Add(Event.Done);
|
||||
// return rList;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// IList<Event> rList = new List<Event>(1);
|
||||
// rList.Add(Event.Done);
|
||||
// return rList;
|
||||
// }
|
||||
//}
|
||||
else if (testParams.Activity.ToLower().Contains("simulate "))
|
||||
{
|
||||
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 60, 0, 0, 0 } );
|
||||
@ -171,7 +199,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="oriTestRslt">Q2Adj test result</param>
|
||||
/// <returns>Virtual Q2 test result</returns>
|
||||
/// <remarks>Assuming this test does not have multiple parts (part = 0)</remarks>
|
||||
void MakeCorrectedFrom(string testName, string oriTestName)
|
||||
void MakeQ2CorrectedFrom(string testName, string oriTestName)
|
||||
{
|
||||
Results.Entities.TestRslt oriTestRslt = ProcessData.BatchRslts.GetTestRslt(oriTestName, 0);
|
||||
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0);
|
||||
|
||||
@ -113,11 +113,14 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
|
||||
public double Q2ErrorWOCorrection;
|
||||
public bool Q2CorrectionDone;
|
||||
public double CurrentQ2Correction;
|
||||
public double Q2CorrectionFactor;
|
||||
|
||||
public double Current2HzCorrection;
|
||||
public double Diff2Hz8Hz;
|
||||
public bool Hz2CorrectionDone;
|
||||
public int Hz2CorrectionFactor;
|
||||
|
||||
/// <summary> Result of the last test used to calculate Q2 correction factors, etc </summary>
|
||||
public Results.Entities.MeterTestRslt LastTestResult2;
|
||||
public Results.Entities.MeterTestRslt LastTestResult;
|
||||
public double NominalTestFlow; /// liter per hour
|
||||
|
||||
@ -176,48 +179,55 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
/// Q2 correction factor calculated from the last test (Q2).
|
||||
/// This factors should be used only for R800 meters.
|
||||
/// </summary>
|
||||
/// <returns>Q2 correction factor</returns>
|
||||
public double Q2CorrectionFactor()
|
||||
/// <param name="q2TestResult">Test result from which to calculate the factor</param>
|
||||
/// <param name="q2CorrectionFactor">The calculated Q2 correction factor</param>
|
||||
/// <returns>true = OK, false = failed</returns>
|
||||
public bool CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt q2TestResult, out double q2CorrectionFactor)
|
||||
{
|
||||
Q2ErrorWOCorrection = LastTestResult.Error;
|
||||
q2CorrectionFactor = 0;
|
||||
|
||||
if (Math.Abs(LastTestResult.Error) <= 0.5)
|
||||
if (q2TestResult == null)
|
||||
{
|
||||
return false; /// Q2 test result is missing ==> water meter failed
|
||||
}
|
||||
|
||||
if (Math.Abs(q2TestResult.Error) <= 0.5)
|
||||
{
|
||||
Q2CorrectionDone = false;
|
||||
return 0; /// No Q2 correction if error < +/-0.5 %
|
||||
return true; /// error < +/-0.5 % ==> no Q2 correction
|
||||
}
|
||||
|
||||
double A = 16.0 / ScalingFactor(); /// Raw units per ml: DN15=16, DN20=8, DN25=4, DN32=2, DN40=1
|
||||
const double B = 8.0; /// Raw units per minute, 8
|
||||
const double C = B * 60.0; /// Raw units per hour, 480
|
||||
double D = C / A; /// ml correction per hour
|
||||
double F = D / (NominalTestFlow * 10.0); /// Error corrected with 8 Raw Units per minute [%]
|
||||
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
|
||||
double A = 16.0 / ScalingFactor(); /// Raw units per ml: DN15=16, DN20=8, DN25=4, DN32=2, DN40=1
|
||||
const double B = 8.0; /// Raw units per minute, 8
|
||||
const double C = B * 60.0; /// Raw units per hour, 480
|
||||
double D = C / A; /// ml correction per hour
|
||||
double F = D / (NominalTestFlow * 10.0); /// Error corrected with 8 Raw Units per minute [%]
|
||||
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
|
||||
|
||||
double errLimitLo = LastTestResult.ErrLimLo() + LastTestResult.Uncertainty();
|
||||
double errLimitHi = LastTestResult.ErrLimHi() - LastTestResult.Uncertainty();
|
||||
double errLimitLo = q2TestResult.ErrLimLo() + q2TestResult.Uncertainty();
|
||||
double errLimitHi = q2TestResult.ErrLimHi() - q2TestResult.Uncertainty();
|
||||
|
||||
if (LastTestResult.Error < errLimitLo) return 0; /// No Q2 correction if error too large -> WM failed
|
||||
if (LastTestResult.Error > errLimitHi) return 0; /// No Q2 correction if error too large -> WM failed
|
||||
if ((q2TestResult.Error < errLimitLo) || (q2TestResult.Error > errLimitHi))
|
||||
{
|
||||
return false; /// Q2 error too large ==> water meter failed
|
||||
}
|
||||
|
||||
double volumeMeterErrLimLo = LastTestResult.VolumeRef * (100.0 + errLimitLo) / 100.0;
|
||||
double volumeMeterErrLimHi = LastTestResult.VolumeRef * (100.0 + errLimitHi) / 100.0;
|
||||
double volumeMeterErrLimLo = q2TestResult.VolumeRef * (100.0 + errLimitLo) / 100.0;
|
||||
double volumeMeterErrLimHi = q2TestResult.VolumeRef * (100.0 + errLimitHi) / 100.0;
|
||||
|
||||
double corrFactorHi = (-1) * (errLimitLo / G) * (LastTestResult.VolumeRef / volumeMeterErrLimLo); /// > 0
|
||||
double corrFactorLo = (-1) * (errLimitHi / G) * (LastTestResult.VolumeRef / volumeMeterErrLimHi); /// < 0
|
||||
double corrFactorHi = (-1) * (errLimitLo / G) * (q2TestResult.VolumeRef / volumeMeterErrLimLo); /// > 0
|
||||
double corrFactorLo = (-1) * (errLimitHi / G) * (q2TestResult.VolumeRef / volumeMeterErrLimHi); /// < 0
|
||||
|
||||
double corrFactor = (-1) * (LastTestResult.Error / G) * (LastTestResult.VolumeRef / LastTestResult.VolumeMeter);
|
||||
double origCalulatedCorrFactor = corrFactor;
|
||||
q2CorrectionFactor = (-1) * (q2TestResult.Error / G) * (q2TestResult.VolumeRef / q2TestResult.VolumeMeter);
|
||||
|
||||
log.WarnFormat("Q2 correction: {0}, corrFactor={4}, error={3}% [Lo={1}%, Hi={2}%]",
|
||||
log.WarnFormat("Q2 correction: Pos={0}, PCB#={1}, corrFactor={2}, error={3}% [Lo={4}%, Hi={5}%]",
|
||||
Name,
|
||||
SerialNr,
|
||||
q2CorrectionFactor.ToString("F1"),
|
||||
q2TestResult.Error.ToString("F2"),
|
||||
errLimitLo.ToString("F1"),
|
||||
errLimitHi.ToString("F1"),
|
||||
LastTestResult.Error.ToString("F2"),
|
||||
corrFactor.ToString("F1"));
|
||||
errLimitHi.ToString("F1"));
|
||||
|
||||
Q2CorrectionDone = true;
|
||||
return corrFactor;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -225,50 +235,39 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
/// 2 Hz correction factor calculated from two Q3 tests - done at 2Hz and at 8Hz.
|
||||
/// This factors should be used only for DN32 and DN40 meters.
|
||||
/// </summary>
|
||||
/// <returns>2 Hz correction factor</returns>
|
||||
public double Hz2CorrectionFactor()
|
||||
/// <param name="resultAt2Hz">Test result @2Hz from which to calculate the factor</param>
|
||||
/// <param name="resultAt8Hz">Test result @8Hz from which to calculate the factor</param>
|
||||
/// <param name="hz2CorrectionFactor">The calculated Q2 correction factor</param>
|
||||
/// <returns>true = OK, false = failed</returns>
|
||||
public bool Calculate2HzCorrectionFactor(Results.Entities.MeterTestRslt resultAt2Hz,
|
||||
Results.Entities.MeterTestRslt resultAt8Hz,
|
||||
out double diff2Hz8Hz, out int hz2CorrectionFactor)
|
||||
{
|
||||
Q2ErrorWOCorrection = LastTestResult.Error;
|
||||
hz2CorrectionFactor = 0;
|
||||
diff2Hz8Hz = 0;
|
||||
|
||||
if (Math.Abs(LastTestResult.Error) <= 0.5)
|
||||
if ((resultAt2Hz == null) || (resultAt8Hz == null))
|
||||
{
|
||||
Q2CorrectionDone = false;
|
||||
return 0; /// No Q2 correction if error < +/-0.5 %
|
||||
return false; /// Test result @2Hz and/or @8Hz is missing ==> water meter failed
|
||||
}
|
||||
|
||||
double A = 16.0 / ScalingFactor(); /// Raw units per ml: DN15=16, DN20=8, DN25=4, DN32=2, DN40=1
|
||||
const double B = 8.0; /// Raw units per minute, 8
|
||||
const double C = B * 60.0; /// Raw units per hour, 480
|
||||
double D = C / A; /// ml correction per hour
|
||||
double F = D / (NominalTestFlow * 10.0); /// Error corrected with 8 Raw Units per minute [%]
|
||||
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
|
||||
diff2Hz8Hz = resultAt2Hz.Error - resultAt8Hz.Error;
|
||||
|
||||
double errLimitLo = LastTestResult.ErrLimLo() + LastTestResult.Uncertainty();
|
||||
double errLimitHi = LastTestResult.ErrLimHi() - LastTestResult.Uncertainty();
|
||||
if (Math.Abs(diff2Hz8Hz) > 2.5) return false; /// Difference of errors > 2.5 % ==> water meter failed
|
||||
|
||||
if (LastTestResult.Error < errLimitLo) return 0; /// No Q2 correction if error too large -> WM failed
|
||||
if (LastTestResult.Error > errLimitHi) return 0; /// No Q2 correction if error too large -> WM failed
|
||||
hz2CorrectionFactor = -1 * (int)Math.Round(10 * diff2Hz8Hz);
|
||||
|
||||
double volumeMeterErrLimLo = LastTestResult.VolumeRef * (100.0 + errLimitLo) / 100.0;
|
||||
double volumeMeterErrLimHi = LastTestResult.VolumeRef * (100.0 + errLimitHi) / 100.0;
|
||||
|
||||
double corrFactorHi = (-1) * (errLimitLo / G) * (LastTestResult.VolumeRef / volumeMeterErrLimLo); /// > 0
|
||||
double corrFactorLo = (-1) * (errLimitHi / G) * (LastTestResult.VolumeRef / volumeMeterErrLimHi); /// < 0
|
||||
|
||||
double corrFactor = (-1) * (LastTestResult.Error / G) * (LastTestResult.VolumeRef / LastTestResult.VolumeMeter);
|
||||
double origCalulatedCorrFactor = corrFactor;
|
||||
|
||||
log.WarnFormat("Q2 correction: {0}, corrFactor={4}, error={3}% [Lo={1}%, Hi={2}%]",
|
||||
log.WarnFormat("2Hz correction: Pos={0}, PCB#={1}, corrFactor={2}, erro@2Hz={3}%, erro@8Hz={4}%",
|
||||
Name,
|
||||
errLimitLo.ToString("F1"),
|
||||
errLimitHi.ToString("F1"),
|
||||
LastTestResult.Error.ToString("F2"),
|
||||
corrFactor.ToString("F1"));
|
||||
SerialNr,
|
||||
hz2CorrectionFactor,
|
||||
resultAt2Hz.Error.ToString("F2"),
|
||||
resultAt8Hz.Error.ToString("F2"));
|
||||
|
||||
Q2CorrectionDone = true;
|
||||
return corrFactor;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Name set by the test, to be used as a part of the opto-data log file name </summary>
|
||||
public string TestName;
|
||||
|
||||
@ -368,7 +367,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
OriginalCalibFactor = 0;
|
||||
Q2ErrorWOCorrection = 0;
|
||||
Q2CorrectionDone = false;
|
||||
CurrentQ2Correction = 0;
|
||||
Q2CorrectionFactor = 0;
|
||||
|
||||
optoDataCount = 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user