Masses are stored in double variables everywhere.

This commit is contained in:
Milan Hanajik
2016-10-07 14:06:54 +02:00
parent 9f2e8407a0
commit 4160420844
26 changed files with 104 additions and 111 deletions
@@ -255,7 +255,7 @@ namespace TBF.BenchControl.Elde
ControlComponent_Torino2015.UserControl1 ctrlBrdComponent,
#endif
ulong valvesToInvert,
float[] tankCapacities)
double[] tankCapacities)
{
this.valvesToInvert = valvesToInvert;
this.benchModelRoute = valvesToInvert;
@@ -67,7 +67,7 @@ namespace TBF.BenchControl.Elde
public uint AnalogInputRaw(int adcNr0, int bank) { return 0; } /// bank0=RV, bank1=Temp
public float TotalRefVolume { get { return 0; } }
public float VyslExt(int wmNr0, int what) { return 0; }
public void SetWeight(int pos, float mass) { return; } /// not available in sim. mode
public void SetWeight(int pos, double mass) { return; } /// not available in sim. mode
///
/// Private initialization data updated by contructors of children components
@@ -65,9 +65,9 @@ namespace TBF.BenchControl.Elde
public float MassRefVolume { get { return ctrlBrdComponent.ReferenceVolume; } }
#endif
public float VyslExt(int wmNr0, int what) { return ctrlBrdComponent.VyslExt[wmNr0, what]; }
public void SetWeight(int pos, float mass)
public void SetWeight(int pos, double mass)
{
ctrlBrdComponent.Weight[pos] = mass;
ctrlBrdComponent.Weight[pos] = (float)mass;
log.DebugFormat("SetWeight(pos={0}, mass={1}", pos, mass);
}
@@ -30,7 +30,7 @@ namespace TBF.BenchControl.Elde
uint AnalogInputRaw(int adcNr0, int bank);
float TotalRefVolume { get; }
float VyslExt(int wmNr0, int what);
void SetWeight(int pos, float mass);
void SetWeight(int pos, double mass);
/// <summary>
/// Sends calibration and configuration data to the control board.
@@ -20,12 +20,12 @@ namespace TBF.BenchControl.GenericDevices
/// <summary>
/// Balance water tank capacity in kg or ltr
/// </summary>
float Capacity { get; }
double Capacity { get; }
/// <summary>
/// Returns true if tank s empty, mass is less then some threshold
/// </summary>
bool IsEmpty(float mass);
bool IsEmpty(double mass);
/// <summary>
/// Returns true if tank s empty, the last measured mass is less then some threshold
@@ -56,14 +56,14 @@ namespace TBF.BenchControl.GenericDevices
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp instance reference casted to IOperaton</returns>
IOperation TaringOp(ref FloatBox tara);
IOperation TaringOp(ref DoubleBox tara);
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="result">Reference to a variable for the measured mass in kg</param>
/// <returns>ReadMassOp instance reference casted to IOperaton</returns>
IOperation ReadMassOp(ref FloatBox mass);
IOperation ReadMassOp(ref DoubleBox mass);
/// <summary>
/// Events: BalanceDone, Error
@@ -73,6 +73,6 @@ namespace TBF.BenchControl.GenericDevices
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
/// <returns>ReadMassAverageOp instance reference casted to IOperaton</returns>
IOperation ReadStableMassOp(ref FloatBox mass, int readingsCount, float maxSpread, bool method);
IOperation ReadStableMassOp(ref DoubleBox mass, int readingsCount, double maxSpread, bool method);
}
}
@@ -1,6 +1,5 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajik
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@@ -42,7 +41,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
}
public static int BalancesCount { get { return nextBalanceIdx; } }
public static BalanceDev[] Balances;
public static float[] Masses;
public static double[] Masses;
///
protected int balanceNr; /// 0-based balance number
@@ -51,15 +50,15 @@ namespace TBF.BenchControl.MettlerToledo.Multi
public int BalanceNr { get { return balanceNr; } }
public int IdNr { get { return balanceCfg.IdNr; } }
public float Capacity { get { return balanceCfg.Capacity; } }
public float Resolution { get { return balanceCfg.Resolution; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public double Resolution { get { return balanceCfg.Resolution; } }
public int EmptyTimeSec { get { return balanceCfg.EmptyTimeSec; } }
/// Buoyancy
public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } }
public float BuoyancyPress { get { return balanceCfg.BuoyancyPress; } }
public float BuoyancyHumi { get { return balanceCfg.BuoyancyHumi; } }
public float WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
public double WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
/// <summary>The state of the mass measurement</summary>
@@ -67,7 +66,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
protected static MsrmntState msrmntState;
/// <summary>The mass after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public float Mass { get { return Masses[balanceNr]; } }
public double Mass { get { return Masses[balanceNr]; } }
/// <summary>The time stamp after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public int MsrmntTimeStamp { get { return msrmntTimeStamp; } }
@@ -90,7 +89,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
if (balanceCfg.IdNr == 1) balance1Cfg = balanceCfg;
balanceNr = nextBalanceIdx++;
Masses = new float[nextBalanceIdx]; /// (re)initialize the static array of masses of all balances
Masses = new double[nextBalanceIdx]; /// (re)initialize the static array of masses of all balances
///
if (Balances == null || Balances.Length < nextBalanceIdx)
{
@@ -126,7 +125,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
return (Mass <= balanceCfg.Empty);
}
public bool IsEmpty(float mass)
public bool IsEmpty(double mass)
{
return (mass <= balanceCfg.Empty);
}
@@ -240,8 +239,8 @@ namespace TBF.BenchControl.MettlerToledo.Multi
weightStr = weightStr.Substring(1, weightStr.Length - 1);
}
float weight = 0;
if (Utils.TryParseSFloat(weightStr, out weight))
double weight = 0;
if (Utils.TryParseSDouble(weightStr, out weight))
{
Masses[balanceIdNr - 1] = weight * Balances[balanceIdNr - 1].Resolution;
log.InfoFormat("Balance({0}) Valid response=\"{1}<cr>\", Mass = {2}kg", balanceIdNr, received, Masses[balanceIdNr - 1]);
@@ -279,7 +278,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp instance reference casted to IOperaton</returns>
public IOperation TaringOp(ref FloatBox tara)
public IOperation TaringOp(ref DoubleBox tara)
{
return new TaringOp(this, ref tara);
}
@@ -289,7 +288,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// </summary>
/// <param name="result">Reference to a variable for the measured mass in kg</param>
/// <returns>ReadMassOp instance reference casted to IOperaton</returns>
public IOperation ReadMassOp(ref FloatBox mass)
public IOperation ReadMassOp(ref DoubleBox mass)
{
return new ReadMassOp(this, ref mass);
}
@@ -302,7 +301,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
/// <returns>ReadMassAverageOp instance reference casted to IOperaton</returns>
public IOperation ReadStableMassOp(ref FloatBox mass, int readingsCount, float maxSpread, bool method)
public IOperation ReadStableMassOp(ref DoubleBox mass, int readingsCount, double maxSpread, bool method)
{
return new ReadStableMassOp(this, ref mass, readingsCount, maxSpread, method);
}
@@ -1,6 +1,5 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajik
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System;
using log4net;
@@ -18,7 +17,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// Set by the constructor
BalanceDev balanceDev;
FloatBox result;
DoubleBox result;
/// <summary>
/// Events: BalanceDone, Error
@@ -26,7 +25,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// <param name="balanceDev">Balance device instance</param>
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
/// <param name="result">Reference to the measured mass in kg</param>
public ReadMassOp(BalanceDev balanceDev, ref FloatBox result)
public ReadMassOp(BalanceDev balanceDev, ref DoubleBox result)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
@@ -1,6 +1,5 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajik
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System;
using log4net;
@@ -17,15 +16,15 @@ namespace TBF.BenchControl.MettlerToledo.Multi
public override string ToString() { return string.Format("ReadStableMassOp(.,{0},.)", totalReadingsCount); }
/// Operation specific
float[] massReadings;
double[] massReadings;
int currentReadingsCount;
/// Set by the constructor
BalanceDev balanceDev;
int totalReadingsCount;
float maxSpread; /// Maximum spread of measurements in kg (otherwise the measurement continues)
double maxSpread; /// Maximum spread of measurements in kg (otherwise the measurement continues)
bool method; /// false = slow (precise), true = fast (immediate)
FloatBox result;
DoubleBox result;
bool started;
@@ -37,7 +36,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// <param name="readingsCount">Required mass readings count (>= 3)</param>
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
public ReadStableMassOp(BalanceDev balanceDev, ref FloatBox result, int readingsCount, float maxSpread, bool method)
public ReadStableMassOp(BalanceDev balanceDev, ref DoubleBox result, int readingsCount, double maxSpread, bool method)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
@@ -67,7 +66,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
{
started = false;
currentReadingsCount = 0;
massReadings = new float[totalReadingsCount];
massReadings = new double[totalReadingsCount];
started = BalanceDev.GetImmediateMassMeasurement(balanceDev.IdNr, balanceDev.Name);
}
@@ -92,7 +91,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
#if true /// OLD_WAY_OF_MASS_CALCULATION
/// Exclude min. and max. value, calculate average
Array.Sort(massReadings);
float calcMass = 0;
double calcMass = 0;
for (int i = 1; i < totalReadingsCount - 1; i++)
{
calcMass += massReadings[i];
@@ -102,9 +101,9 @@ namespace TBF.BenchControl.MettlerToledo.Multi
result.Val = calcMass;
return Event.BalanceDone; /// Mass has just been calculated
#else
float minimum = float.MaxValue;
float maximum = float.MinValue;
foreach (float val in massReadings)
double minimum = double.MaxValue;
double maximum = double.MinValue;
foreach (double val in massReadings)
{
if (val < minimum) minimum = val;
if (val > maximum) maximum = val;
@@ -112,7 +111,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
if ((maximum - minimum) <= maxSpread)
{
float calcMass = 0;
double calcMass = 0;
for (int i = 0; i < totalReadingsCount; i++)
{
calcMass += massReadings[i];
@@ -1,6 +1,5 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajik
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System;
using log4net;
@@ -17,14 +16,14 @@ namespace TBF.BenchControl.MettlerToledo.Multi
/// Set by the constructor
BalanceDev balanceDev;
FloatBox tara;
DoubleBox tara;
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="balanceDev">Balance device instance</param>
/// <param name="result">Reference to variable for 'tara' in kg</param>
public TaringOp(BalanceDev balanceDev, ref FloatBox tara)
public TaringOp(BalanceDev balanceDev, ref DoubleBox tara)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
@@ -41,7 +41,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
}
public static int BalancesCount { get { return nextBalanceIdx; } }
public static BalanceDev[] Balances;
public static float[] Masses;
public static double[] Masses;
///
protected int balanceNr; /// 0-based balance number
@@ -49,14 +49,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
protected StringBuilder stringBuilder;
public int BalanceNr { get { return balanceNr; } }
public float Capacity { get { return balanceCfg.Capacity; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public int EmptyTimeSec { get { return balanceCfg.EmptyTimeSec; } }
/// Buoyancy
public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } }
public float BuoyancyPress { get { return balanceCfg.BuoyancyPress; } }
public float BuoyancyHumi { get { return balanceCfg.BuoyancyHumi; } }
public float WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
public double WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
/// <summary>The state of the mass measurement</summary>
@@ -64,8 +64,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard
protected MsrmntState msrmntState;
/// <summary>The mass after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public float Mass { get { return mass; } }
protected float mass;
public double Mass { get { return mass; } }
protected double mass;
/// <summary>The time stamp after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public int MsrmntTimeStamp { get { return msrmntTimeStamp; } }
@@ -88,7 +88,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
balanceCfg = cfg as BalanceCfg;
balanceNr = nextBalanceIdx++;
Masses = new float[nextBalanceIdx]; /// (re)initialize the static array of masses of all balances
Masses = new double[nextBalanceIdx]; /// (re)initialize the static array of masses of all balances
///
if (Balances == null || Balances.Length < nextBalanceIdx)
{
@@ -121,7 +121,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
return (this.mass <= balanceCfg.Empty);
}
public bool IsEmpty(float mass)
public bool IsEmpty(double mass)
{
return (mass <= balanceCfg.Empty);
}
@@ -321,7 +321,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("S")) /// Stable mass: field[1] = <mass> field[2] = "kg"
{
if (fields.Length == 3 &&
float.TryParse(fields[1],
double.TryParse(fields[1],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -333,7 +333,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
}
else if (fields.Length == 4 && (fields[1].Equals("S") || fields[1].Equals("D")) &&
float.TryParse(fields[2],
double.TryParse(fields[2],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -355,14 +355,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
{
msrmntState = MsrmntState.Failed;
log.WarnFormat("{0} Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
bool b = float.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
bool b = double.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
}
}
else if (fields[0].Equals("SD")) /// Dynamic mass: field[1] = <mass> field[2] = "kg"
{
if (fields.Length >= 3 &&
float.TryParse(fields[1],
double.TryParse(fields[1],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -384,14 +384,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
{
msrmntState = MsrmntState.Failed;
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
bool b = float.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
bool b = double.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
}
}
else if (fields[0].Equals("TB")) /// Taring
{
if (fields.Length >= 3 &&
float.TryParse(fields[1],
double.TryParse(fields[1],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -410,7 +410,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("T")) /// Taring
{
if (fields.Length >= 4 && fields[1].Equals("S") &&
float.TryParse(fields[2],
double.TryParse(fields[2],
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
CultureInfo.InvariantCulture,
out mass))
@@ -450,7 +450,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp instance reference casted to IOperaton</returns>
public IOperation TaringOp(ref FloatBox tara)
public IOperation TaringOp(ref DoubleBox tara)
{
return new TaringOp(this, ref tara);
}
@@ -460,7 +460,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// </summary>
/// <param name="result">Reference to a variable for the measured mass in kg</param>
/// <returns>ReadMassOp instance reference casted to IOperaton</returns>
public IOperation ReadMassOp(ref FloatBox mass)
public IOperation ReadMassOp(ref DoubleBox mass)
{
return new ReadMassOp(this, ref mass);
}
@@ -473,7 +473,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
/// <returns>ReadMassAverageOp instance reference casted to IOperaton</returns>
public IOperation ReadStableMassOp(ref FloatBox mass, int readingsCount, float maxSpread, bool method)
public IOperation ReadStableMassOp(ref DoubleBox mass, int readingsCount, double maxSpread, bool method)
{
return new ReadStableMassOp(this, ref mass, readingsCount, maxSpread, method);
}
@@ -145,7 +145,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("S")) /// Stable (field[1] == "S") or dynamic (field[1] == "D") mass measurement
{
if (fields.Length == 4 && (fields[1].Equals("S") || fields[1].Equals("D")) &&
float.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
CultureInfo.InvariantCulture, out mass))
{
if (fields[3].Equals("g")) mass /= 1000.0f;
@@ -189,7 +189,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("T")) /// Taring
{
if (fields.Length == 4 && fields[1].Equals("S") &&
float.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
CultureInfo.InvariantCulture, out mass))
{
if (fields[3].Equals("g")) mass /= 1000.0f;
@@ -121,7 +121,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("S")) /// Stable (field[1] == "S") or dynamic (field[1] == "D") mass measurement
{
if (fields.Length == 4 && fields[1].Equals("S") &&
float.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
CultureInfo.InvariantCulture, out mass))
{
if (fields[3].Equals("g")) mass /= 1000.0f;
@@ -132,7 +132,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
}
else if (fields.Length == 4 && fields[1].Equals("D") &&
float.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
CultureInfo.InvariantCulture, out mass))
{
if (fields[3].Equals("g")) mass /= 1000.0f;
@@ -176,7 +176,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
else if (fields[0].Equals("T")) /// Taring
{
if (fields.Length == 4 && fields[1].Equals("S") &&
float.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
CultureInfo.InvariantCulture, out mass))
{
if (fields[3].Equals("g")) mass /= 1000.0f;
@@ -1,6 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Author: Milan Hanajik
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using log4net;
@@ -17,7 +16,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// Set by the constructor
BalanceDev balanceDev;
FloatBox result;
DoubleBox result;
/// <summary>
/// Events: BalanceDone, Error
@@ -25,7 +24,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <param name="balanceDev">Balance device instance</param>
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
/// <param name="result">Reference to the measured mass in kg</param>
public ReadMassOp(BalanceDev balanceDev, ref FloatBox result)
public ReadMassOp(BalanceDev balanceDev, ref DoubleBox result)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
@@ -1,6 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Author: Milan Hanajik
///
using System;
using log4net;
@@ -17,15 +16,15 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public override string ToString() { return string.Format("ReadStableMassOp(.,{0},.)", totalReadingsCount); }
/// Operation specific
float[] massReadings;
double[] massReadings;
int currentReadingsCount;
/// Set by the constructor
BalanceDev balanceDev;
int totalReadingsCount;
float maxSpread; /// Maximum spread of measurements in kg (otherwise the measurement continues)
double maxSpread; /// Maximum spread of measurements in kg (otherwise the measurement continues)
bool method; /// false = slow (precise), true = fast (immediate)
FloatBox result;
DoubleBox result;
/// <summary>
/// Events: BalanceDone, Error
@@ -35,7 +34,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <param name="readingsCount">Required mass readings count (>= 3)</param>
/// <param name="maxSpread">Maximum spread of measurements in kg (otherwise the measurement continues)</param>
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
public ReadStableMassOp(BalanceDev balanceDev, ref FloatBox result, int readingsCount, float maxSpread, bool method)
public ReadStableMassOp(BalanceDev balanceDev, ref DoubleBox result, int readingsCount, double maxSpread, bool method)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
@@ -63,7 +62,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public void Start()
{
currentReadingsCount = 0;
massReadings = new float[totalReadingsCount];
massReadings = new double[totalReadingsCount];
if (method)
balanceDev.GetImmediateMassMeasurement();
@@ -92,7 +91,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
#if true /// OLD_WAY_OF_MASS_CALCULATION
/// Exclude min. and max. value, calculate average
Array.Sort(massReadings);
float calcMass = 0;
double calcMass = 0;
for (int i = 1; i < totalReadingsCount - 1; i++)
{
calcMass += massReadings[i];
@@ -102,9 +101,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
result.Val = calcMass;
return Event.BalanceDone; /// Mass has just been calculated
#else
float minimum = float.MaxValue;
float maximum = float.MinValue;
foreach (float val in massReadings)
double minimum = double.MaxValue;
double maximum = double.MinValue;
foreach (double val in massReadings)
{
if (val < minimum) minimum = val;
if (val > maximum) maximum = val;
@@ -112,7 +111,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
if ((maximum - minimum) <= maxSpread)
{
float calcMass = 0;
double calcMass = 0;
for (int i = 0; i < totalReadingsCount; i++)
{
calcMass += massReadings[i];
@@ -1,6 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Author: Milan Hanajik
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using log4net;
@@ -17,14 +16,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// Set by the constructor
BalanceDev balanceDev;
FloatBox tara;
DoubleBox tara;
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="balanceDev">Balance device instance</param>
/// <param name="result">Reference to variable for 'tara' in kg</param>
public TaringOp(BalanceDev balanceDev, ref FloatBox tara)
public TaringOp(BalanceDev balanceDev, ref DoubleBox tara)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
@@ -198,7 +198,7 @@ namespace TBF.BenchControl.Sequences
//--------------------------------------------------------------------------------------------
State taraAll = State.Create("MainSeq : Reset all balances").AddOperation(checkUiOp);
FloatBox tara = new FloatBox(0);
DoubleBox tara = new DoubleBox(0);
if (StateMachine.Balance1 != null) taraAll.AddOperation(StateMachine.Balance1.TaringOp(ref tara));
if (StateMachine.Balance2 != null) taraAll.AddOperation(StateMachine.Balance2.TaringOp(ref tara));
if (StateMachine.Balance3 != null) taraAll.AddOperation(StateMachine.Balance3.TaringOp(ref tara));
@@ -1016,9 +1016,9 @@ namespace TBF.BenchControl.Sequences
bool emptying3 = false;
/// Measured masses to control emptying
FloatBox mass1 = new FloatBox();
FloatBox mass2 = new FloatBox();
FloatBox mass3 = new FloatBox();
DoubleBox mass1 = new DoubleBox();
DoubleBox mass2 = new DoubleBox();
DoubleBox mass3 = new DoubleBox();
IList<Event> e;
Selection selection;
@@ -23,9 +23,12 @@ namespace TBF.BenchControl.Sequences
public static FloatBox RefFreq = new FloatBox() { Name = "RefFreq", Format = "F2" };
public static FloatBox RefFlow = new FloatBox() { Name = "RefFlow", Format = "F2" }; /// [m3/h]
public static FloatBox Mass = new FloatBox() { Name = "Mass", Format = "F3" }; /// [kg]
public static FloatBox StartMass = new FloatBox() { Name = "Start Mass", Format = "F3" }; /// [kg]
public static FloatBox EndMass = new FloatBox() { Name = "End Mass", Format = "F3" }; /// [kg]
public static DoubleBox Mass = new DoubleBox() { Name = "Mass", Format = "F3" }; /// [kg]
public static DoubleBox StartMass = new DoubleBox() { Name = "Start Mass", Format = "F3" }; /// [kg]
public static DoubleBox EndMass = new DoubleBox() { Name = "End Mass", Format = "F3" }; /// [kg]
public static DateTime TestStartTime;
public static DateTime TestEndTime;
/// Heat meters only
public static FloatBox TempRefWarm1 = new FloatBox() { Name = "T ref warm 1", Format = "F3" }; /// [°C]
@@ -33,9 +36,6 @@ namespace TBF.BenchControl.Sequences
public static FloatBox TempRefCold1 = new FloatBox() { Name = "T ref cold 1", Format = "F3" }; /// [°C]
public static FloatBox TempRefCold2 = new FloatBox() { Name = "T ref cold 2", Format = "F3" }; /// [°C]
public static DateTime TestStartTime;
public static DateTime TestEndTime;
public static Results.BatchResults BatchRslts;
public static IRegisterReader[] RegisterReaders;
@@ -248,7 +248,7 @@ namespace TBF.BenchControl
}
/// Create an array with tank capacities
float[] tankCapacities = new float[balances.Count];
double[] tankCapacities = new double[balances.Count];
for (int i = 0; i < tankCapacities.Length; i++) tankCapacities[i] = balances[i].Capacity;
/// Pre-initialize the control board (= buffer the arguments ctrlBrdComponent, tankCapacities)
@@ -101,7 +101,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
}
while (!e.Contains(Event.BalanceDone));
float estimatedEndMass = Mass.Val + test.Volume;
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto switching_flow_detection; /// Enough room in the tank -> skip emptying
@@ -126,7 +126,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
}
while (!e.Contains(Event.BalanceDone));
float estimatedEndMass = Mass.Val + test.Volume;
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
@@ -145,7 +145,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
}
while (!e.Contains(Event.BalanceDone));
float estimatedEndMass = Mass.Val + test.Volume;
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
@@ -84,7 +84,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
}
while (!e.Contains(Event.BalanceDone));
float estimatedEndMass = Mass.Val + test.Volume;
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass >= outPath.Balance.Capacity * Constants.TankFullFactor)
{
tankEmptyingInProgress = true;
@@ -123,7 +123,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
}
while (!e.Contains(Event.BalanceDone));
float estimatedEndMass = Mass.Val + test.Volume;
double estimatedEndMass = Mass.Val + test.Volume;
if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor)
{
goto set_flow; /// Enough room in the tank -> skip emptying
@@ -443,9 +443,9 @@ namespace TBF.Screens
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses;
refVolumeLabel.Text = refVolume.ToString("F2");
float massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
float volumeCtv = 1001.03f * massDiff / (float)TBF.BenchControl.Formulas.WaterDensityFromTemp(ProcessData.TempOut.Val);
double volumeCtv = 1001.03 * massDiff / TBF.BenchControl.Formulas.WaterDensityFromTemp(ProcessData.TempOut.Val);
volumeCtvLabel.Text = volumeCtv.ToString("F2");
double refError = TBF.BenchControl.Formulas.ErrorFromVolumes(refVolume, volumeCtv);
refErrorLabel.Text = refError.ToString("F3");
@@ -472,9 +472,9 @@ namespace TBF.Screens
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses;
refVolumeLabel.Text = refVolume.ToString("F2");
float massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
float volumeCtv = 1001.03f * massDiff / (float)TBF.BenchControl.Formulas.WaterDensityFromTemp(ProcessData.TempOut.Val);
double volumeCtv = 1001.03f * massDiff / (float)TBF.BenchControl.Formulas.WaterDensityFromTemp(ProcessData.TempOut.Val);
volumeCtvLabel.Text = volumeCtv.ToString("F2");
double refError = TBF.BenchControl.Formulas.ErrorFromVolumes(refVolume, volumeCtv);
refErrorLabel.Text = refError.ToString("F3");
@@ -477,9 +477,9 @@ namespace TBF.Screens
double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses;
refVolumeLabel.Text = refVolume.ToString("F2");
float massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
float volumeCtv = 1001.03f * massDiff / (float)TBF.BenchControl.Formulas.WaterDensityFromTemp(ProcessData.TempOut.Val);
double volumeCtv = 1001.03f * massDiff / (float)TBF.BenchControl.Formulas.WaterDensityFromTemp(ProcessData.TempOut.Val);
volumeCtvLabel.Text = volumeCtv.ToString("F2");
double refError = TBF.BenchControl.Formulas.ErrorFromVolumes(refVolume, volumeCtv);
refErrorLabel.Text = refError.ToString("F3");