Q2 correction clean-up, etc.
This commit is contained in:
parent
8f27d1a448
commit
3da6fcfe73
@ -47,6 +47,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
return RfidCommands.SetTestMode($"COM{iHead.RfidComPortNr}") ? "OK" : "Error Set Test Mode";
|
||||
}
|
||||
|
||||
#if IPERL
|
||||
internal static string TurnOffRadio(IperlHead iHead)
|
||||
{
|
||||
try
|
||||
@ -97,5 +98,6 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
}
|
||||
return $"Error COM{iHead.RfidComPortNr}";
|
||||
}
|
||||
#endif /// IPERL
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,6 +341,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
activityLabel.Text = Strings.Optical_heads;
|
||||
ShuffleTextBoxes(ProcessData.WMsCount, ProcessData.LineSize);
|
||||
|
||||
#if IPERL
|
||||
ContextMenu cm = new ContextMenu();
|
||||
cm.MenuItems.Add(NewMenuItem("Read PCB Number" , "ReadPCB"));
|
||||
cm.MenuItems.Add(NewMenuItem("Enter Test Mode" , "StartTestMode"));
|
||||
@ -353,6 +354,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
cm.MenuItems.Add(NewMenuItem("Open sealing", "OpenSealing"));
|
||||
}
|
||||
this.ContextMenu = cm;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -2060,27 +2062,6 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
return CommErr.None; /// No Q2 correction when doing conditional update and WM passed
|
||||
}
|
||||
|
||||
if (q2adjResult.Error < -50 || +50 < q2adjResult.Error ||
|
||||
(q2adjResult2 != null && (q2adjResult2.Error < -50 || +50 < q2adjResult2.Error)))
|
||||
{
|
||||
resultStr = string.Format("Measurement error => no Q2 correction");
|
||||
|
||||
/// At least one of Q2 errors is out of range for Q2 correction
|
||||
log.WarnFormat("OoR => anyhow Q2 correction was done: Pos={0}, PCB#={1}, ***Q2_RL err={2}%***, ***Q2_LR err={3}%***",
|
||||
ihead.Name,
|
||||
ihead.SerialNr,
|
||||
q2adjResult.Error.ToString("F2"),
|
||||
q2adjResult2 != null ? q2adjResult2.Error.ToString("F2") : string.Empty);
|
||||
|
||||
rfidDataLogger.InfoFormat("{0}({1}): Q2 error ({2},{3}) is out of range => Failed",
|
||||
ihead.Name,
|
||||
ihead.SerialNr,
|
||||
q2adjResult.Error.ToString("F2"),
|
||||
q2adjResult2 != null ? q2adjResult2.Error.ToString("F2") : string.Empty);
|
||||
|
||||
return CommErr.Q2OutOfRange;
|
||||
}
|
||||
|
||||
double errLimitLo = test.ErrLimLo + test.Uncertainty;
|
||||
double errLimitHi = test.ErrLimHi - test.Uncertainty;
|
||||
|
||||
@ -2100,7 +2081,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Do not forget to modify iPerlCommunicationSeq.MakeQ2CorrectedFrom(...)
|
||||
///
|
||||
double errorTarget = (q3error * q2adjResult.Error < 0) ? (0.1 * q2adjResult.Error) : (-0.1 * q2adjResult.Error);
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, errorTarget, q2adjTestData.Qfrom, q2adjResult.Q2CorrRL));
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom, errorTarget));
|
||||
}
|
||||
else if (q2CorrType == Q2CorrType.Dewa ||
|
||||
q2CorrType == Q2CorrType.Dewa_incl_05 ||
|
||||
@ -2112,7 +2093,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Do not forget to modify iPerlCommunicationSeq.MakeQ2CorrectedFrom(...)
|
||||
///
|
||||
double errorTarget = (q3error * q2adjResult.Error < 0) ? (0.1 * q2adjResult.Error) : (-0.1 * q2adjResult.Error);
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, errorTarget, q2adjTestData.Qfrom, q2adjResult.Q2CorrLR));
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrLR, q2adjTestData.Qfrom, errorTarget));
|
||||
}
|
||||
else if (q2CorrType == Q2CorrType.RL ||
|
||||
q2CorrType == Q2CorrType.RL_incl_05 ||
|
||||
@ -2129,7 +2110,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
return CommErr.None;
|
||||
}
|
||||
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, 0, q2adjTestData.Qfrom, q2adjResult.Q2CorrRL));
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom));
|
||||
}
|
||||
else if (q2CorrType == Q2CorrType.LR ||
|
||||
q2CorrType == Q2CorrType.LR_incl_05 ||
|
||||
@ -2146,7 +2127,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
return CommErr.None;
|
||||
}
|
||||
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, 0, q2adjTestData.Qfrom, q2adjResult.Q2CorrLR));
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrLR, q2adjTestData.Qfrom));
|
||||
}
|
||||
else if (q2CorrType == Q2CorrType.Update || q2CorrType == Q2CorrType.ConditionalUpdate)
|
||||
{
|
||||
@ -2155,8 +2136,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Assuming the 2nd Q2 tests are done afterwards
|
||||
/// MakeQ2CorrectedFrom(...) is not used
|
||||
///
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, 0, q2adjTestData.Qfrom, q2adjResult.Q2CorrRL));
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult2, 0, q2adjTestData2.Qfrom, q2adjResult2.Q2CorrLR));
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom));
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult2, q2adjResult2.Q2CorrLR, q2adjTestData2.Qfrom));
|
||||
}
|
||||
else if (q2CorrType == Q2CorrType.Greece || q2CorrType == Q2CorrType.Greece_incl_05 || q2CorrType == Q2CorrType.UpdateBothQ2FactorsTestLRDir)
|
||||
{
|
||||
@ -2169,7 +2150,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
return CommErr.None;
|
||||
}
|
||||
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, 0, q2adjTestData.Qfrom, q2adjResult.Q2CorrLR));
|
||||
q2CorrLR = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrLR, q2adjTestData.Qfrom));
|
||||
q2CorrRL = q2CorrLR;
|
||||
}
|
||||
else if (q2CorrType == Q2CorrType.UpdateBothQ2FactorsTestRLDir)
|
||||
@ -2178,7 +2159,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Another strange process
|
||||
///
|
||||
double errorTarget = (q3error * q2adjResult.Error < 0) ? (0.1 * q2adjResult.Error) : (-0.1 * q2adjResult.Error);
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, errorTarget, q2adjTestData.Qfrom, q2adjResult.Q2CorrRL));
|
||||
q2CorrRL = Convert.ToInt32(ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjResult.Q2CorrRL, q2adjTestData.Qfrom, errorTarget));
|
||||
q2CorrLR = q2CorrRL;
|
||||
}
|
||||
|
||||
@ -2250,7 +2231,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
(q2adjResult.Error < errLimitLo || errLimitHi < q2adjResult.Error ||
|
||||
(q2adjResult2 != null && (q2adjResult2.Error < errLimitLo || errLimitHi < q2adjResult2.Error))))
|
||||
{
|
||||
resultStr = resultStr + " (OoR)";
|
||||
resultStr += " (OoR)";
|
||||
|
||||
/// At least one of Q2 errors is out of range for Q2 correction
|
||||
log.WarnFormat("OoR => anyhow Q2 correction was done: Pos={0}, PCB#={1}, ***Q2_RL err={2}%***, ***Q2_LR err={3}%***, [Lo={4}%, Hi={5}%]",
|
||||
@ -2798,6 +2779,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
UiBridge.Bridge.OnTestCompleted(this, new UiBridge.TestCompletedEventArgs(string.Empty, null));
|
||||
}
|
||||
|
||||
#if IPERL
|
||||
private MenuItem NewMenuItem(string text, string tag)
|
||||
{
|
||||
MenuItem menuItem = new MenuItem { Text = text, Tag = tag };
|
||||
@ -2847,6 +2829,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
Application.DoEvents(); // Refresh UI
|
||||
}
|
||||
}
|
||||
#endif /// IPERL
|
||||
|
||||
#region Check boxes edit mode support
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
|
||||
/// Get 'wmType' from IperlHead procedure parameters
|
||||
int wmType = 0;
|
||||
#if IPERL
|
||||
foreach (var wm in ProcessData.BatchRslts.Batch.WaterMeters)
|
||||
{
|
||||
if (wm != null && !wm.Disabled && wm.WMTypeId() > 0)
|
||||
@ -80,6 +81,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cfg.UseWebService)
|
||||
{
|
||||
|
||||
@ -213,7 +213,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
/// <param name="nominalFlow">Nominal flow in m3/h</param>
|
||||
/// <param name="currentFactor">0 or the current Q2 correction factor when updating the factor</param>
|
||||
/// <returns>Calculated Q2 correction factor</returns>
|
||||
public double CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt currentQ2Result, double errorTarget, double nominalFlow, int currentFactor = 0)
|
||||
public double CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt currentQ2Result, int currentFactor, double nominalFlow, double errorTarget = 0)
|
||||
{
|
||||
double nominalTestFlowLph = Units.ConvertTo(Unit.lph, nominalFlow);
|
||||
double volumeRefShiftedToTarget = currentQ2Result.VolumeRef * (1.0 + errorTarget / 100.0);
|
||||
@ -226,12 +226,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
double F = D / (nominalTestFlowLph * 10.0); /// Error corrected with 8 Raw Units per minute [%]
|
||||
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
|
||||
|
||||
double q2CorrectionFactor = Convert.ToDouble(currentFactor)
|
||||
- (q2adjErrorShiftedToTarget / G) * (volumeRefShiftedToTarget / currentQ2Result.VolumeMeter);
|
||||
|
||||
///// Do not change the factor for an invalid measurement (q2adjResult.VolumeMeter == 0)
|
||||
//double q2CorrectionFactor = (Math.Abs(q2adjResult.VolumeMeter) <= float.Epsilon) ? Convert.ToDouble(currentFactor) :
|
||||
// Convert.ToDouble(currentFactor) - (q2adjResult.Error / G) * (q2adjResult.VolumeRef / q2adjResult.VolumeMeter);
|
||||
/// Do not change the factor for an invalid measurement (q2adjResult.VolumeMeter == 0)
|
||||
double q2CorrectionFactor = (Math.Abs(currentQ2Result.VolumeMeter) <= float.Epsilon) ? Convert.ToDouble(currentFactor) :
|
||||
Convert.ToDouble(currentFactor) - (q2adjErrorShiftedToTarget / G) * (volumeRefShiftedToTarget / currentQ2Result.VolumeMeter);
|
||||
|
||||
log.WarnFormat("CalculateQ2CorrectionFactor() : Pos={0}, PCB#={1}, Error={2}%, Target={3}%, Current factor={4} New factor={5}",
|
||||
Name,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user