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