2Hz correction related changes: iPerlCommunication: 'Reset 2Hz correction', 'Write 2Hz correction' + OraDB changes.
This commit is contained in:
@@ -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
|
||||
|
||||
+5
-4
@@ -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
|
||||
|
||||
+141
-17
@@ -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
|
||||
|
||||
|
||||
+30
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user