From 41604208448233d709ab64714c59227cf5c8a9d9 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 7 Oct 2016 14:06:54 +0200 Subject: [PATCH] Masses are stored in double variables everywhere. --- .../BenchControl/Elde/ControlBoardDev.cs | 2 +- .../BenchControl/Elde/ControlComSim.cs | 2 +- .../BenchControl/Elde/ControlComWrap.cs | 4 +-- .../BenchControl/Elde/IControlCom.cs | 2 +- .../BenchControl/GenericDevices/IBalance.cs | 10 +++--- .../MettlerToledo/Multi/BalanceDev.cs | 33 +++++++++--------- .../MettlerToledo/Multi/ReadMassOp.cs | 7 ++-- .../MettlerToledo/Multi/ReadStableMassOp.cs | 23 ++++++------- .../MettlerToledo/Multi/TaringOp.cs | 7 ++-- .../MettlerToledo/Standard/BalanceDev.cs | 34 +++++++++---------- .../MettlerToledo/Standard/BalanceNewDev.cs | 4 +-- .../MettlerToledo/Standard/BalanceOld.cs | 6 ++-- .../MettlerToledo/Standard/ReadMassOp.cs | 7 ++-- .../Standard/ReadStableMassOp.cs | 23 ++++++------- .../MettlerToledo/Standard/TaringOp.cs | 7 ++-- .../BenchControl/Sequences/MainSeq.cs | 8 ++--- .../BenchControl/Sequences/ProcessData.cs | 12 +++---- .../BenchControl/StateMachine.cs | 2 +- .../CombinedWithDetectionSeq.cs | 2 +- .../FixedStartAdvancedSeq.cs | 2 +- .../FixedStartMassCollectionSeq.cs | 2 +- .../FlyingStartMassCollectionSeq.cs | 2 +- .../ReferenceFlowmeterCalibrationSeq.cs | 2 +- .../Screens/ProcessTabPageCtrl24.cs | 4 +-- .../Screens/ProcessTabPageCtrl48.cs | 4 +-- .../Screens/ProcessTabPageCtrl6.cs | 4 +-- 26 files changed, 104 insertions(+), 111 deletions(-) diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs index b95d7d1fc..39211b176 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs @@ -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; diff --git a/TestBenchFramework/BenchControl/Elde/ControlComSim.cs b/TestBenchFramework/BenchControl/Elde/ControlComSim.cs index 4c1e8cb1d..b1ca57d2f 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlComSim.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlComSim.cs @@ -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 diff --git a/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs b/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs index 8c828097a..a6103fa80 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlComWrap.cs @@ -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); } diff --git a/TestBenchFramework/BenchControl/Elde/IControlCom.cs b/TestBenchFramework/BenchControl/Elde/IControlCom.cs index 48f46f855..7500dcc29 100644 --- a/TestBenchFramework/BenchControl/Elde/IControlCom.cs +++ b/TestBenchFramework/BenchControl/Elde/IControlCom.cs @@ -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); /// /// Sends calibration and configuration data to the control board. diff --git a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs b/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs index 64fde4d54..60e93cd6d 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs @@ -20,12 +20,12 @@ namespace TBF.BenchControl.GenericDevices /// /// Balance water tank capacity in kg or ltr /// - float Capacity { get; } + double Capacity { get; } /// /// Returns true if tank s empty, mass is less then some threshold /// - bool IsEmpty(float mass); + bool IsEmpty(double mass); /// /// Returns true if tank s empty, the last measured mass is less then some threshold @@ -56,14 +56,14 @@ namespace TBF.BenchControl.GenericDevices /// /// Reference to a variable for 'tara' in kg /// TaringOp instance reference casted to IOperaton - IOperation TaringOp(ref FloatBox tara); + IOperation TaringOp(ref DoubleBox tara); /// /// Events: BalanceDone, Error /// /// Reference to a variable for the measured mass in kg /// ReadMassOp instance reference casted to IOperaton - IOperation ReadMassOp(ref FloatBox mass); + IOperation ReadMassOp(ref DoubleBox mass); /// /// Events: BalanceDone, Error @@ -73,6 +73,6 @@ namespace TBF.BenchControl.GenericDevices /// Maximum spread of measurements in kg (otherwise the measurement continues) /// Method: false = slow (precise), true = fast (immediate) /// ReadMassAverageOp instance reference casted to IOperaton - IOperation ReadStableMassOp(ref FloatBox mass, int readingsCount, float maxSpread, bool method); + IOperation ReadStableMassOp(ref DoubleBox mass, int readingsCount, double maxSpread, bool method); } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs index a13252a3d..84fcf65b5 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs @@ -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,24 +41,24 @@ 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 protected static SerialPort serialPort; protected static StringBuilder stringBuilder; - 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 int EmptyTimeSec { get { return balanceCfg.EmptyTimeSec; } } + public int BalanceNr { get { return balanceNr; } } + public int IdNr { get { return balanceCfg.IdNr; } } + 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; } } /// The state of the mass measurement @@ -67,7 +66,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi protected static MsrmntState msrmntState; /// The mass after StartMassMeasurement() when MsrmntState == MsrmntState.Valid - public float Mass { get { return Masses[balanceNr]; } } + public double Mass { get { return Masses[balanceNr]; } } /// The time stamp after StartMassMeasurement() when MsrmntState == MsrmntState.Valid 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}\", Mass = {2}kg", balanceIdNr, received, Masses[balanceIdNr - 1]); @@ -279,7 +278,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi /// /// Reference to a variable for 'tara' in kg /// TaringOp instance reference casted to IOperaton - 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 /// /// Reference to a variable for the measured mass in kg /// ReadMassOp instance reference casted to IOperaton - 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 /// Maximum spread of measurements in kg (otherwise the measurement continues) /// Method: false = slow (precise), true = fast (immediate) /// ReadMassAverageOp instance reference casted to IOperaton - 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); } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadMassOp.cs b/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadMassOp.cs index f8560163f..154a8ff03 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadMassOp.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadMassOp.cs @@ -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; /// /// Events: BalanceDone, Error @@ -26,7 +25,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi /// Balance device instance /// Required mass readings count (>= 3) /// Reference to the measured mass in kg - public ReadMassOp(BalanceDev balanceDev, ref FloatBox result) + public ReadMassOp(BalanceDev balanceDev, ref DoubleBox result) { if (balanceDev == null) throw new ArgumentNullException("balanceDev"); this.balanceDev = balanceDev; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadStableMassOp.cs b/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadStableMassOp.cs index a8c06db0f..502c90aa3 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadStableMassOp.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Multi/ReadStableMassOp.cs @@ -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 /// Required mass readings count (>= 3) /// Maximum spread of measurements in kg (otherwise the measurement continues) /// Method: false = slow (precise), true = fast (immediate) - 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]; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Multi/TaringOp.cs b/TestBenchFramework/BenchControl/MettlerToledo/Multi/TaringOp.cs index 64f0aa1d8..d34d9443c 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Multi/TaringOp.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Multi/TaringOp.cs @@ -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; /// /// Events: BalanceDone, Error /// /// Balance device instance /// Reference to variable for 'tara' in kg - public TaringOp(BalanceDev balanceDev, ref FloatBox tara) + public TaringOp(BalanceDev balanceDev, ref DoubleBox tara) { if (balanceDev == null) throw new ArgumentNullException("balanceDev"); this.balanceDev = balanceDev; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs index 61c7b85ac..97fb795ca 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs @@ -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; } } /// The state of the mass measurement @@ -64,8 +64,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard protected MsrmntState msrmntState; /// The mass after StartMassMeasurement() when MsrmntState == MsrmntState.Valid - public float Mass { get { return mass; } } - protected float mass; + public double Mass { get { return mass; } } + protected double mass; /// The time stamp after StartMassMeasurement() when MsrmntState == MsrmntState.Valid 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] = 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}\", 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}\", 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] = 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}\", 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 /// /// Reference to a variable for 'tara' in kg /// TaringOp instance reference casted to IOperaton - 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 /// /// Reference to a variable for the measured mass in kg /// ReadMassOp instance reference casted to IOperaton - 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 /// Maximum spread of measurements in kg (otherwise the measurement continues) /// Method: false = slow (precise), true = fast (immediate) /// ReadMassAverageOp instance reference casted to IOperaton - 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); } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs index 4cdf2edbc..3bca12a13 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs @@ -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; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs index f208f82a6..8cecb8c26 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs @@ -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", "").Replace("\n", ""), 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; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadMassOp.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadMassOp.cs index 8048b592d..185e0893b 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadMassOp.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadMassOp.cs @@ -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; /// /// Events: BalanceDone, Error @@ -25,7 +24,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// Balance device instance /// Required mass readings count (>= 3) /// Reference to the measured mass in kg - public ReadMassOp(BalanceDev balanceDev, ref FloatBox result) + public ReadMassOp(BalanceDev balanceDev, ref DoubleBox result) { if (balanceDev == null) throw new ArgumentNullException("balanceDev"); this.balanceDev = balanceDev; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadStableMassOp.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadStableMassOp.cs index d05d9f582..8d3eb6dcd 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadStableMassOp.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/ReadStableMassOp.cs @@ -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; /// /// Events: BalanceDone, Error @@ -35,7 +34,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// Required mass readings count (>= 3) /// Maximum spread of measurements in kg (otherwise the measurement continues) /// Method: false = slow (precise), true = fast (immediate) - 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]; @@ -132,7 +131,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard currentReadingsCount--; } #endif - } + } } if (method) diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/TaringOp.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/TaringOp.cs index 6d89e3c9b..24e524463 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/TaringOp.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/TaringOp.cs @@ -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; /// /// Events: BalanceDone, Error /// /// Balance device instance /// Reference to variable for 'tara' in kg - public TaringOp(BalanceDev balanceDev, ref FloatBox tara) + public TaringOp(BalanceDev balanceDev, ref DoubleBox tara) { if (balanceDev == null) throw new ArgumentNullException("balanceDev"); this.balanceDev = balanceDev; diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 04612c2ed..5d68e15f5 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -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 e; Selection selection; diff --git a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs index 563dd3a1f..9abe85f2f 100644 --- a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs +++ b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs @@ -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; diff --git a/TestBenchFramework/BenchControl/StateMachine.cs b/TestBenchFramework/BenchControl/StateMachine.cs index 0165f1096..bd7bae701 100644 --- a/TestBenchFramework/BenchControl/StateMachine.cs +++ b/TestBenchFramework/BenchControl/StateMachine.cs @@ -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) diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 121bea0dc..695f978cc 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -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 diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index 16107522c..ad43833eb 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -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 diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index fab0a880c..5d155f8a5 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -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 diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 5ffee3946..200e6448b 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -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; diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs index b51998c36..e1c53a924 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs @@ -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 diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs index 5a24b0bdf..b108f2cb6 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs @@ -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"); diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs index a3e0b6af9..0cbd146af 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs @@ -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"); diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs index ac98f8abf..36619bb39 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs @@ -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");