iPerlCommunication, etc: A correct calibration factor is written to iPerl.
This commit is contained in:
parent
3647740d4a
commit
440199b3bc
@ -456,6 +456,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
WaterMeters.iPerl.WaterMeter iPerl = (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter);
|
||||
tstRslt.Meters[i].VolumeMeter = (float)(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
|
||||
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV * (float)(iPerl.TimestampSecEnd - iPerl.TimestampSecStart) / tstRslt.Time;
|
||||
iPerl.VolumeLtrRef = (double)tstRslt.Meters[i].VolumeRef;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -805,11 +805,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
UInt16 factor = wm.CalibrationFactor; /// Original calibration factor
|
||||
|
||||
/// Write the calculated calibration factor
|
||||
UInt16 newCalFactor = wm.CalculatedCalibrationFactor;
|
||||
byte[] data = new byte[2] { (byte)(newCalFactor & 0x00FF), (byte)((newCalFactor >> 8) & 0x00FF) };
|
||||
UInt16 newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor);
|
||||
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.Calibration, 2, 2, data, CommTimeout)) { error = CommErr.None; break; }
|
||||
|
||||
@ -89,11 +89,23 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
|
||||
public ushort CalibrationFactor { get { return CalibrationStruct.Calibration; } }
|
||||
|
||||
public ushort CalculatedCalibrationFactor
|
||||
public UInt16 CalculateNewCalibFactor(UInt16 originalCalibrationFactor)
|
||||
{
|
||||
get
|
||||
double volumeMeter = VolumeLtrEnd - VolumeLtrStart;
|
||||
if (volumeMeter > 1E-2)
|
||||
{
|
||||
return (UInt16)((double)CalibrationStruct.Calibration + 0.5); /// TODO: real calculation
|
||||
UInt16 newFactor = (UInt16)((double)originalCalibrationFactor * VolumeLtrRef / volumeMeter + 0.5);
|
||||
log.InfoFormat("CalculateNewCalibFactor: orig={0} new={1} V_1={2} V_2={3} Vdiff={4} Vref={5}",
|
||||
originalCalibrationFactor, newFactor,
|
||||
VolumeLtrStart.ToString("F3"), VolumeLtrEnd.ToString("F3"), volumeMeter.ToString("F3"),
|
||||
VolumeLtrRef.ToString("F3"));
|
||||
return newFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.ErrorFormat("CalculateNewCalibFactor: orig={0} new={0} (unchanged!) Vdiff={1}",
|
||||
originalCalibrationFactor, volumeMeter.ToString("F3"));
|
||||
return originalCalibrationFactor; /// Too small volume in the denominator -> no correction at all
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,10 +120,11 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
private double volumeLtr; ///
|
||||
private double volumeLtr0;
|
||||
|
||||
public double VolumeLtrStart;
|
||||
public double VolumeLtrEnd;
|
||||
double volumeLtrEnd1;
|
||||
double volumeLtrEnd2;
|
||||
public double VolumeLtrStart; /// Test start volume for metrology
|
||||
public double VolumeLtrEnd; /// Test end volume for metrology
|
||||
public double VolumeLtrRef; /// Reference volume or metrology
|
||||
double volumeLtrEnd1; /// auxiliary buffer1 to keep the end volume before test stops
|
||||
double volumeLtrEnd2; /// auxiliary buffer2 to keep the end volume before test stops
|
||||
|
||||
///
|
||||
/// Timestamp from the opto telegram
|
||||
|
||||
Loading…
Reference in New Issue
Block a user