(1) Range of flow extended to 125%, (2) RequredFlowLo/Hi etc. float -> double, ver. 2.18.1192
This commit is contained in:
parent
556290abf6
commit
f8671ac516
@ -23,8 +23,8 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
public float Position { get { return 50.0f; } }
|
||||
|
||||
|
||||
IDictionary<float, float> dict;
|
||||
public IDictionary<float, float> Dict { get { return dict; } }
|
||||
IDictionary<double, float> dict;
|
||||
public IDictionary<double, float> Dict { get { return dict; } }
|
||||
|
||||
|
||||
public RegulValve()
|
||||
@ -35,7 +35,7 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
: base(cfg)
|
||||
{
|
||||
RegulValveCfg = cfg as RegulValveCfg;
|
||||
dict = new Dictionary<float, float>();
|
||||
dict = new Dictionary<double, float>();
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
@ -57,7 +57,7 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
{
|
||||
return new SetFlowOp(this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout);
|
||||
@ -73,7 +73,7 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
|
||||
{
|
||||
return new SetFlowOp(this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, true);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2017-2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -14,7 +14,7 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(SetFlowOp));
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("SetFlowOp({0}, Qfrom={1}, Qto={2}, PID={3})", regulValve.Name, reqFlowLo, reqFlowHi, pidCoef);
|
||||
return string.Format("SetFlowOp({0}, Qfrom={1}, Qto={2})", regulValve.Name, reqFlowLo, reqFlowHi);
|
||||
}
|
||||
|
||||
const int CoaxValveNr = 7; /// Coax. valve has number 7
|
||||
@ -22,23 +22,17 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
|
||||
/// Set by the constructor
|
||||
readonly RegulValve regulValve;
|
||||
readonly int flowMeterNr;
|
||||
readonly float reqFlowLo;
|
||||
readonly float reqFlowHi;
|
||||
readonly float reqFlowAve;
|
||||
readonly float pidCoef;
|
||||
readonly double reqFlowLo;
|
||||
readonly double reqFlowHi;
|
||||
readonly double reqFlowAve;
|
||||
readonly int timeout;
|
||||
readonly bool leaveMeasurementRunning;
|
||||
readonly bool reTryCommands;
|
||||
|
||||
readonly float nominalFlow;
|
||||
|
||||
float targetPositionLo;
|
||||
float targetPositionHi;
|
||||
readonly double nominalFlow;
|
||||
readonly double maximalFlow;
|
||||
|
||||
int expireTime;
|
||||
DoubleBox measuredFlow;
|
||||
int flowWithinBoundsTime;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -53,17 +47,18 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
/// <param name="timeout">Timeout for the flow setting in [s]</param>
|
||||
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
|
||||
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
|
||||
public SetFlowOp(IRegulValve regulValve, IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
public SetFlowOp(IRegulValve regulValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout, bool leaveMeasurementRunning)
|
||||
{
|
||||
this.regulValve = regulValve as RegulValve;
|
||||
if (this.regulValve == null) throw new ArgumentNullException("regValve is null or not Dummy.RegulValve");
|
||||
|
||||
nominalFlow = (float)flowMeter.NominalFlow;
|
||||
nominalFlow = flowMeter.NominalFlow;
|
||||
maximalFlow = nominalFlow * 1.25;
|
||||
|
||||
this.reqFlowLo = requiredFlowLo;
|
||||
this.reqFlowHi = requiredFlowHi;
|
||||
this.reqFlowAve = (reqFlowLo + reqFlowHi) / 2.0f;
|
||||
this.reqFlowAve = (reqFlowLo + reqFlowHi) / 2.0;
|
||||
this.measuredFlow = measuredFlow;
|
||||
|
||||
this.timeout = timeout;
|
||||
@ -77,7 +72,7 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
/// Set required water flow - Do not leave the measurement running.
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(IRegulValve regValve, IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
public SetFlowOp(IRegulValve regValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
: this(regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, false)
|
||||
{
|
||||
@ -87,7 +82,7 @@ namespace TBF.BenchControl.Dummy.RegulValve
|
||||
/// Set required water flow - No timeout.
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(IRegulValve regValve, IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
public SetFlowOp(IRegulValve regValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow)
|
||||
: this(regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, int.MaxValue, false)
|
||||
{
|
||||
|
||||
@ -41,7 +41,6 @@ namespace TBF.BenchControl.Elde
|
||||
/// prsNr0 = 0 .. nrPressureMeters-1 (zero based)
|
||||
///
|
||||
public StatusP StatusP { get { return controlCom.StatusP; } }
|
||||
public double ReferenceFreq { get { return controlCom.ReferenceFreq; } } /// In [Hz] 0..2500, nom.=2000
|
||||
public int EtPulses(int wmNr1) { return controlCom.EtPulses(wmNr1); }
|
||||
public int EtPulsesK { get { return controlCom.EtPulsesK; } }
|
||||
public UInt16 WMeterPulses(int wmNr1) { return controlCom.WMeterPulses(wmNr1); }
|
||||
@ -56,13 +55,14 @@ namespace TBF.BenchControl.Elde
|
||||
public float ImpulseTime(int wmNr1) { return controlCom.ImpulseTime(wmNr1); }
|
||||
public uint FmState { get { return controlCom.FmState; } }
|
||||
public uint BeginState(int wmNr0) { return controlCom.BeginState(wmNr0); }
|
||||
public double ReferenceFlow { get { return controlCom.ReferenceFlow; } }
|
||||
public double ReferenceFreq { get { return controlCom.ReferenceFreq; } } /// In [Hz] 0..2500, nom.=2000
|
||||
public double ReferenceFlow { get { return controlCom.ReferenceFlow; } }
|
||||
public float RValvePosition(int rvNr1) { return controlCom.RValvePosition(rvNr1); }
|
||||
public float DivSamples(int time, int divIx0) { return controlCom.DivSamples(time, divIx0); } /// Time unit is 2 ms
|
||||
public float DivSamples(int time, int divIx0) { return controlCom.DivSamples(time, divIx0); } /// Time unit is 2 ms
|
||||
public int ScopeSamples(int i, int j, int k) { return controlCom.ScopeSamples(i, j, k); }
|
||||
public ulong DigitalInputs { get { return controlCom.DigitalInputs; } }
|
||||
public float AnalogInput(int adcNr0) { return controlCom.AnalogInput(adcNr0); }
|
||||
public uint AnalogInputRaw(int adcNr0, int bank) { return controlCom.AnalogInputRaw(adcNr0, bank); } /// adcNr0: 0=RV1, 1=RV2,... bank: 0=RV, 1=Temp
|
||||
public uint AnalogInputRaw(int adcNr0, int bank) { return controlCom.AnalogInputRaw(adcNr0, bank); } /// adcNr0: 0=RV1, 1=RV2,... bank: 0=RV, 1=Temp
|
||||
public float ReferenceVolume { get { return controlCom.TotalRefVolume; } }
|
||||
public float VyslExt(int wmNr0, int what) { return controlCom.VyslExt(wmNr0, what); }
|
||||
public uint[] CyclePar { get { return controlCom.CyclePar; } set { controlCom.CyclePar = value; } }
|
||||
@ -596,7 +596,7 @@ namespace TBF.BenchControl.Elde
|
||||
/// <param name="refPulses">Number of reference pulses to complete the test</param>
|
||||
/// <returns>Created operation</returns>
|
||||
public IOperation StartMeasurementOp(OutputPath outputPath, TestMethods method,
|
||||
float requiredFlowLo, float requiredFlowHi,
|
||||
double requiredFlowLo, double requiredFlowHi,
|
||||
int refPulses, int[] filterConstants)
|
||||
{
|
||||
if (controlBoardCfg.DebugLevel == DebugMode.Simulate)
|
||||
@ -619,7 +619,7 @@ namespace TBF.BenchControl.Elde
|
||||
/// <param name="refPulses">Number of reference pulses to complete the test</param>
|
||||
/// <returns>Created operation</returns>
|
||||
public IOperation StartProlongedMeasurementOp(OutputPath outputPath, TestMethods method,
|
||||
float requiredFlowLo, float requiredFlowHi,
|
||||
double requiredFlowLo, double requiredFlowHi,
|
||||
int totalRefPulses, int massRefPulses, int[] filters)
|
||||
{
|
||||
if (controlBoardCfg.DebugLevel == DebugMode.Simulate)
|
||||
|
||||
@ -17,8 +17,8 @@ namespace TBF.BenchControl.Elde
|
||||
StatusP statusP;
|
||||
public StatusP StatusP { get { return statusP; } }
|
||||
|
||||
float referenceFreq = 650.0f;
|
||||
public float ReferenceFreq { get { return referenceFreq; } }
|
||||
double referenceFreq = 650.0;
|
||||
public double ReferenceFreq { get { return referenceFreq; } }
|
||||
|
||||
int[] etPulses = new int[Config.Data.WMsCount + 1];
|
||||
public int EtPulses(int wmNr1)
|
||||
@ -28,8 +28,8 @@ namespace TBF.BenchControl.Elde
|
||||
|
||||
public int EtPulsesK { get { return 1; } }
|
||||
|
||||
float[] errFactor = new float[Config.Data.WMsCount + 1]; /// Internal
|
||||
float[] wMeterPulsesF = new float[Config.Data.WMsCount + 1]; /// Internal
|
||||
double[] errFactor = new double[Config.Data.WMsCount + 1]; /// Internal
|
||||
double[] wMeterPulsesF = new double[Config.Data.WMsCount + 1]; /// Internal
|
||||
|
||||
UInt16[] wMeterPulses = new UInt16[Config.Data.WMsCount + 1]; /// Rounded from wMeterPulsesF
|
||||
public UInt16 WMeterPulses(int wmNr1)
|
||||
@ -61,8 +61,8 @@ namespace TBF.BenchControl.Elde
|
||||
public uint FmState { get { return 0; } }
|
||||
public uint BeginState(int wmNr0) { return 0; }
|
||||
|
||||
float referenceFlow;
|
||||
public float ReferenceFlow { get { return referenceFlow; } }
|
||||
double referenceFlow;
|
||||
public double ReferenceFlow { get { return referenceFlow; } }
|
||||
|
||||
public float RValvePosition(int rvNr1) { return 0; }
|
||||
public float DivSamples(int ms, int divIx0) { return 0; }
|
||||
@ -303,7 +303,7 @@ namespace TBF.BenchControl.Elde
|
||||
//if (referenceFreq < valveValue[0]) referenceFreq += ((float)rand.Next(20) + 10.0f) / 2.0f;
|
||||
//else if (referenceFreq > valveValue[1]) referenceFreq -= ((float)rand.Next(20) + 10.0f) / 2.0f;
|
||||
//else referenceFreq += ((float)rand.Next(10) - 5.0f) / 2.0f;
|
||||
referenceFreq = TestBenchSim.GetSimFlow() * 2000.0f / Qnom;
|
||||
referenceFreq = TestBenchSim.GetSimFlow() * 2000.0 / Qnom;
|
||||
if (referenceFreq < 0) referenceFreq = 0;
|
||||
if (referenceFreq > 2500) referenceFreq = 2500;
|
||||
break;
|
||||
@ -312,12 +312,12 @@ namespace TBF.BenchControl.Elde
|
||||
break;
|
||||
}
|
||||
|
||||
referenceFlow = referenceFreq / 2000;
|
||||
referenceFlow = referenceFreq / 2000.0;
|
||||
|
||||
bool stopTest = false;
|
||||
if (cmd == Command.Start)
|
||||
{
|
||||
float pwFactor = 1.0f;
|
||||
double pwFactor = 1.0;
|
||||
|
||||
/// Increment reference flow meters
|
||||
for (int i = 0; i <= Config.Data.WMsCount; i++)
|
||||
@ -325,14 +325,14 @@ namespace TBF.BenchControl.Elde
|
||||
etPulses[i] += (int)referenceFreq;
|
||||
if (etPulses[i] > totalRefPulses)
|
||||
{
|
||||
pwFactor = 1.0f - (float)(etPulses[i] - totalRefPulses) / referenceFreq;
|
||||
pwFactor = 1.0 - (etPulses[i] - totalRefPulses) / referenceFreq;
|
||||
etPulses[i] = totalRefPulses;
|
||||
stopTest = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Increment water meters
|
||||
float flowLtrPerSec = TestBenchSim.GetSimFlow() / 1800.0f;
|
||||
double flowLtrPerSec = TestBenchSim.GetSimFlow() / 1800.0;
|
||||
for (int i = 1; i <= Config.Data.WMsCount; i++)
|
||||
{
|
||||
float wmPulsesPerLiter = 0;
|
||||
|
||||
@ -30,7 +30,7 @@ namespace TBF.BenchControl.Elde
|
||||
/// otherwise
|
||||
/// referenceFreq[0] = I2 or I3 or I4
|
||||
/// </summary>
|
||||
public float ReferenceFreq { get { return 1000.0f * ctrlBrdComponent.referenceFreq[0]; } } /// In [Hz] 0..2500, nom.=2000
|
||||
public double ReferenceFreq { get { return 1000.0 * ctrlBrdComponent.referenceFreq[0]; } } /// In [Hz] 0..2500, nom.=2000
|
||||
#endif
|
||||
|
||||
public int EtPulses(int wmNr1) { return (int)ctrlBrdComponent.etPulses[wmNr1]; }
|
||||
@ -87,7 +87,7 @@ namespace TBF.BenchControl.Elde
|
||||
public uint FmState { get { return ctrlBrdComponent.fMState[0]; } } /// TODO: index
|
||||
#endif
|
||||
public uint BeginState(int wmNr0) { return ctrlBrdComponent.beginSt[wmNr0]; }
|
||||
public float ReferenceFlow { get { return ctrlBrdComponent.referenceFlow; } }
|
||||
public double ReferenceFlow { get { return (double)ctrlBrdComponent.referenceFlow; } }
|
||||
public float RValvePosition(int rvNr1)
|
||||
{
|
||||
//return ctrlBrdComponent.RValvePosition[rvNr1 - 1];
|
||||
|
||||
@ -9,7 +9,6 @@ namespace TBF.BenchControl.Elde
|
||||
interface IControlCom
|
||||
{
|
||||
StatusP StatusP { get; }
|
||||
float ReferenceFreq { get; }
|
||||
int EtPulses(int wmNr1);
|
||||
int EtPulsesK { get; }
|
||||
UInt16 WMeterPulses(int wmNr1);
|
||||
@ -24,7 +23,8 @@ namespace TBF.BenchControl.Elde
|
||||
float ImpulseTime(int WMNr1);
|
||||
uint FmState { get; }
|
||||
uint BeginState(int wmNr0);
|
||||
float ReferenceFlow { get; }
|
||||
double ReferenceFreq { get; }
|
||||
double ReferenceFlow { get; }
|
||||
float RValvePosition(int rvNr1);
|
||||
float DivSamples(int time, int divIx0); /// time unit is 2 ms
|
||||
int ScopeSamples(int i, int j, int k);
|
||||
|
||||
@ -17,8 +17,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
|
||||
public readonly RegulValveCfg RegulValveCfg;
|
||||
|
||||
IDictionary<float, float> dict;
|
||||
public IDictionary<float, float> Dict { get { return dict; } }
|
||||
IDictionary<double, float> dict;
|
||||
public IDictionary<double, float> Dict { get { return dict; } }
|
||||
|
||||
public readonly ControlBoardDev ControlBoard;
|
||||
|
||||
@ -95,7 +95,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
this.dict = new Dictionary<float, float>();
|
||||
this.dict = new Dictionary<double, float>();
|
||||
|
||||
#if GENESIS
|
||||
adcChannel = (Idx1 < 6) ? (Idx1 - 1) : (Idx1 - 2);
|
||||
@ -154,7 +154,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
{
|
||||
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, RegulValveCfg.ReTryCommands, timeout);
|
||||
}
|
||||
@ -169,7 +169,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
|
||||
{
|
||||
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, RegulValveCfg.ReTryCommands, timeout, true);
|
||||
}
|
||||
|
||||
@ -22,15 +22,16 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
readonly Elde.RegulValve.RegulValve regulValve;
|
||||
readonly int regulValveNr;
|
||||
readonly IFlowMeter flowMeter;
|
||||
readonly float requiredFlowLo;
|
||||
readonly float requiredFlowHi;
|
||||
readonly float reqFlowAve;
|
||||
readonly double requiredFlowLo;
|
||||
readonly double requiredFlowHi;
|
||||
readonly double reqFlowAve;
|
||||
readonly float pidCoef;
|
||||
readonly int timeout;
|
||||
readonly bool leaveMeasurementRunning;
|
||||
readonly bool reTryCommands;
|
||||
|
||||
readonly float nominalFlow;
|
||||
readonly double nominalFlow;
|
||||
readonly double maximalFlow;
|
||||
|
||||
///
|
||||
/// Internal states of this operation
|
||||
@ -53,8 +54,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
}
|
||||
OpState opState;
|
||||
|
||||
float currentReqFlowLo;
|
||||
float currentReqFlowHi;
|
||||
double currentReqFlowLo;
|
||||
double currentReqFlowHi;
|
||||
float targetPositionLo;
|
||||
float targetPositionHi;
|
||||
|
||||
@ -78,7 +79,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
|
||||
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regulValve, IFlowMeter flowMeter,
|
||||
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox flowBox,
|
||||
double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox flowBox,
|
||||
bool reTryCmds, int timeout, bool leaveMeasurementRunning)
|
||||
{
|
||||
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
|
||||
@ -91,11 +92,12 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
if (flowMeter == null) throw new ArgumentNullException("flowMeter");
|
||||
this.flowMeter = flowMeter;
|
||||
|
||||
nominalFlow = (float)flowMeter.NominalFlow;
|
||||
nominalFlow = flowMeter.NominalFlow;
|
||||
maximalFlow = nominalFlow * 1.25;
|
||||
|
||||
this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2.0f;
|
||||
this.requiredFlowLo = (0.7F * requiredFlowLo) + (0.3F * this.reqFlowAve); /// Move the lower limit 15% of the range up
|
||||
this.requiredFlowHi = (0.7F * requiredFlowHi) + (0.3F * this.reqFlowAve); /// Move the upper limit 15% of the range down
|
||||
this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2;
|
||||
this.requiredFlowLo = (0.7 * requiredFlowLo) + (0.3 * this.reqFlowAve); /// Move the lower limit 15% of the range up
|
||||
this.requiredFlowHi = (0.7 * requiredFlowHi) + (0.3 * this.reqFlowAve); /// Move the upper limit 15% of the range down
|
||||
this.pidCoef = pidCoef;
|
||||
|
||||
if (flowBox == null) throw new ArgumentNullException("flowBox");
|
||||
@ -115,7 +117,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter,
|
||||
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox flowbox, bool reTryCmds, int timeout)
|
||||
double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox flowbox, bool reTryCmds, int timeout)
|
||||
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, flowbox, reTryCmds, timeout, false)
|
||||
{
|
||||
}
|
||||
@ -125,8 +127,8 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter,
|
||||
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox flowbox, bool reTryCmds)
|
||||
: this(controlBoard, regValve, flowMeter, requiredFlowLo, pidCoef, requiredFlowHi, flowbox, reTryCmds, int.MaxValue, false)
|
||||
double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox flowbox, bool reTryCmds)
|
||||
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, flowbox, reTryCmds, int.MaxValue, false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -137,7 +139,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// <param name="positionLo">Target valve position low limit (output)</param>
|
||||
/// <param name="positionHi">Target valve position high limit (output)</param>
|
||||
/// <returns>true when positions for the target flow are stored in the memory, otherwise return false</returns>
|
||||
bool FetchTargetPosition(float avgReqFlow, out float positionLo, out float positionHi)
|
||||
bool FetchTargetPosition(double avgReqFlow, out float positionLo, out float positionHi)
|
||||
{
|
||||
float targetPosition;
|
||||
if (regulValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
|
||||
@ -154,11 +156,11 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
}
|
||||
}
|
||||
|
||||
void StoreTargetPosition(float avgReqFlow, float actPosition)
|
||||
void StoreTargetPosition(double avgReqFlow, float actPosition)
|
||||
{
|
||||
if (!regulValve.Dict.ContainsKey(reqFlowAve))
|
||||
{
|
||||
regulValve.Dict.Add(new KeyValuePair<float, float>(avgReqFlow, actPosition));
|
||||
regulValve.Dict.Add(new KeyValuePair<double, float>(avgReqFlow, actPosition));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -328,7 +330,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
///
|
||||
/// Done once, issues an appropriate ValveMove(...) command
|
||||
///
|
||||
if (currentReqFlowLo >= currentReqFlowHi || currentReqFlowLo > nominalFlow || currentReqFlowHi <= 0)
|
||||
if ((currentReqFlowLo >= currentReqFlowHi) || (currentReqFlowLo > maximalFlow) || (currentReqFlowHi <= 0))
|
||||
{
|
||||
return Event.OpArgumentError;
|
||||
}
|
||||
@ -336,10 +338,10 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
|
||||
regulValveNr, flowMeter.Idx1, currentReqFlowLo, currentReqFlowHi);
|
||||
|
||||
float freqLo = 2000.0f * currentReqFlowLo / nominalFlow;
|
||||
float freqHi = 2000.0f * currentReqFlowHi / nominalFlow;
|
||||
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
|
||||
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
|
||||
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
|
||||
new float[2] { freqLo, freqHi },
|
||||
new float[2] { (float)freqLo, (float)freqHi },
|
||||
regulValve.StableTime);
|
||||
|
||||
opState = OpState.ValveMoveToFlow3;
|
||||
@ -368,10 +370,10 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
else if (controlBoard.RegulValveState(regulValveNr) != RegulValveState.PwOrFreqRegul)
|
||||
{
|
||||
/// Done once, issues an appropriate ValveMove(...) command
|
||||
float freqLo = 2000.0f * currentReqFlowLo / nominalFlow;
|
||||
float freqHi = 2000.0f * currentReqFlowHi / nominalFlow;
|
||||
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
|
||||
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
|
||||
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
|
||||
new float[2] { freqLo, freqHi },
|
||||
new float[2] { (float)freqLo, (float)freqHi },
|
||||
regulValve.StableTime);
|
||||
|
||||
log.InfoFormat("SetFlowOp: ValveMove({0}, Frequency, {1}, {2}, {3})",
|
||||
|
||||
@ -16,8 +16,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
|
||||
public readonly RegulValveCfg RegulValveCfg;
|
||||
|
||||
IDictionary<float, float> dict;
|
||||
public IDictionary<float, float> Dict { get { return dict; } }
|
||||
IDictionary<double, float> dict;
|
||||
public IDictionary<double, float> Dict { get { return dict; } }
|
||||
|
||||
public readonly ControlBoardDev ControlBoard;
|
||||
|
||||
@ -43,7 +43,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
this.dict = new Dictionary<float, float>();
|
||||
this.dict = new Dictionary<double, float>();
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
@ -60,7 +60,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
{
|
||||
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, RegulValveCfg.ReTryCommands, timeout);
|
||||
}
|
||||
@ -75,7 +75,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
|
||||
{
|
||||
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, RegulValveCfg.ReTryCommands, timeout, true);
|
||||
}
|
||||
|
||||
@ -22,15 +22,16 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
readonly Elde.RegulValveCoax.RegulValve regulValve;
|
||||
readonly int regulValveNr;
|
||||
readonly int flowMeterNr;
|
||||
readonly float finalReqFlowLo;
|
||||
readonly float finalReqFlowHi;
|
||||
readonly float reqFlowAve;
|
||||
readonly double finalReqFlowLo;
|
||||
readonly double finalReqFlowHi;
|
||||
readonly double reqFlowAve;
|
||||
readonly float pidCoef;
|
||||
readonly int timeout;
|
||||
readonly bool leaveMeasurementRunning;
|
||||
readonly bool reTryCommands;
|
||||
|
||||
readonly float nominalFlow;
|
||||
readonly double nominalFlow;
|
||||
readonly double maximalFlow;
|
||||
|
||||
///
|
||||
/// Internal states of this operation
|
||||
@ -53,8 +54,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
}
|
||||
OpState opState;
|
||||
|
||||
float currentReqFlowLo;
|
||||
float currentReqFlowHi;
|
||||
double currentReqFlowLo;
|
||||
double currentReqFlowHi;
|
||||
float targetPositionLo;
|
||||
float targetPositionHi;
|
||||
|
||||
@ -77,7 +78,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
|
||||
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve _regulValve, IFlowMeter flowMeter,
|
||||
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow,
|
||||
double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow,
|
||||
bool reTryCmds, int timeout, bool leaveMeasurementRunning)
|
||||
{
|
||||
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
|
||||
@ -100,11 +101,12 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
throw new ArgumentNullException("flowMeter is null or not Elde");
|
||||
}
|
||||
|
||||
nominalFlow = (float)flowMeter.NominalFlow;
|
||||
nominalFlow = flowMeter.NominalFlow;
|
||||
maximalFlow = nominalFlow * 1.25;
|
||||
|
||||
this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2;
|
||||
this.finalReqFlowLo = (0.7F * requiredFlowLo) + (0.3F * this.reqFlowAve); /// Move the lower limit 15% of the range up
|
||||
this.finalReqFlowHi = (0.7F * requiredFlowHi) + (0.3F * this.reqFlowAve); /// Move the upper limit 15% of the range down
|
||||
this.finalReqFlowLo = (0.7 * requiredFlowLo) + (0.3 * this.reqFlowAve); /// Move the lower limit 15% of the range up
|
||||
this.finalReqFlowHi = (0.7 * requiredFlowHi) + (0.3 * this.reqFlowAve); /// Move the upper limit 15% of the range down
|
||||
this.pidCoef = pidCoef;
|
||||
this.measuredFlow = measuredFlow;
|
||||
this.reTryCommands = reTryCmds;
|
||||
@ -121,7 +123,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter,
|
||||
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, bool reTryCmds, int timeout)
|
||||
double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow, bool reTryCmds, int timeout)
|
||||
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, reTryCmds, timeout, false)
|
||||
{
|
||||
}
|
||||
@ -131,8 +133,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter,
|
||||
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, bool reTryCmds)
|
||||
: this(controlBoard, regValve, flowMeter, requiredFlowLo, pidCoef, requiredFlowHi, measuredFlow, reTryCmds, int.MaxValue, false)
|
||||
double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow, bool reTryCmds)
|
||||
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, reTryCmds, int.MaxValue, false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -143,7 +145,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
/// <param name="positionLo">Target valve position low limit (output)</param>
|
||||
/// <param name="positionHi">Target valve position high limit (output)</param>
|
||||
/// <returns>true when positions for the target flow are stored in the memory, otherwise return false</returns>
|
||||
bool FetchTargetPosition(float avgReqFlow, out float positionLo, out float positionHi)
|
||||
bool FetchTargetPosition(double avgReqFlow, out float positionLo, out float positionHi)
|
||||
{
|
||||
float targetPosition;
|
||||
if (regulValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
|
||||
@ -160,11 +162,11 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
}
|
||||
}
|
||||
|
||||
void StoreTargetPosition(float avgReqFlow, float actPosition)
|
||||
void StoreTargetPosition(double avgReqFlow, float actPosition)
|
||||
{
|
||||
if (!regulValve.Dict.ContainsKey(reqFlowAve))
|
||||
{
|
||||
regulValve.Dict.Add(new KeyValuePair<float, float>(avgReqFlow, actPosition));
|
||||
regulValve.Dict.Add(new KeyValuePair<double, float>(avgReqFlow, actPosition));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -349,16 +351,16 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
///
|
||||
/// Done once, issues an appropriate ValveMove(...) command
|
||||
///
|
||||
if (currentReqFlowLo >= currentReqFlowHi || currentReqFlowLo > nominalFlow || currentReqFlowHi <= 0)
|
||||
if ((currentReqFlowLo >= currentReqFlowHi) || (currentReqFlowLo > maximalFlow) || (currentReqFlowHi <= 0))
|
||||
{
|
||||
log.DebugFormat(" return Event.OpArgumentError");
|
||||
return Event.OpArgumentError;
|
||||
}
|
||||
|
||||
float freqLo = 2000.0f * currentReqFlowLo / nominalFlow;
|
||||
float freqHi = 2000.0f * currentReqFlowHi / nominalFlow;
|
||||
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
|
||||
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
|
||||
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
|
||||
new float[2] { (freqLo + freqHi) / 2, (freqLo + freqHi) / 2 },
|
||||
new float[2] { (float)((freqLo + freqHi) / 2), (float)((freqLo + freqHi) / 2) },
|
||||
regulValve.StableTime);
|
||||
log.WarnFormat(" Run() ValveMove({0}, Freq., {1}, {2}, {3}) flowMtr#={4} TARGET: flowLo={5} flowHi={6}",
|
||||
regulValveNr, (freqLo + freqHi) / 2, (freqLo + freqHi) / 2,
|
||||
@ -387,10 +389,10 @@ namespace TBF.BenchControl.Elde.RegulValveCoax
|
||||
if (((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0)
|
||||
{
|
||||
/// Done once, issues an appropriate ValveMove(...) command
|
||||
float freqLo = 2000.0f * currentReqFlowLo / nominalFlow;
|
||||
float freqHi = 2000.0f * currentReqFlowHi / nominalFlow;
|
||||
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
|
||||
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
|
||||
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
|
||||
new float[2] { (freqLo + freqHi) / 2, (freqLo + freqHi) / 2 },
|
||||
new float[2] { (float)((freqLo + freqHi) / 2), (float)((freqLo + freqHi) / 2) },
|
||||
regulValve.StableTime);
|
||||
|
||||
log.WarnFormat(" Run() ValveMove({0}, Frequency, {1}, {2}, {3}) flowMtr#={4} TARGET: flowLo={5} flowHi={6}",
|
||||
|
||||
@ -16,8 +16,8 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
|
||||
public readonly RegulValveTandemCfg RegulValveTandemCfg;
|
||||
|
||||
IDictionary<float, float> dict;
|
||||
public IDictionary<float, float> Dict { get { return dict; } }
|
||||
IDictionary<double, float> dict;
|
||||
public IDictionary<double, float> Dict { get { return dict; } }
|
||||
|
||||
ControlBoardDev controlBoard { get { return regulValve.ControlBoard; } }
|
||||
public ValveCategory Category { get { return RegulValveTandemCfg.Category; } }
|
||||
@ -56,7 +56,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
fixedPctLo = Math.Max(0.0f, RegulValveTandemCfg.FixedRVPosition - 3.0f);
|
||||
fixedPctHi = Math.Min(100.0f, RegulValveTandemCfg.FixedRVPosition + 3.0f);
|
||||
|
||||
this.dict = new Dictionary<float, float>();
|
||||
this.dict = new Dictionary<double, float>();
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
@ -72,7 +72,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
{
|
||||
return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi,
|
||||
@ -89,7 +89,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
|
||||
{
|
||||
return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi,
|
||||
|
||||
@ -26,14 +26,15 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
readonly float fixedPctLo;
|
||||
readonly float fixedPctHi;
|
||||
readonly int flowMeterNr;
|
||||
readonly float finalReqFlowLo;
|
||||
readonly float finalReqFlowHi;
|
||||
readonly float reqFlowAve;
|
||||
readonly double finalReqFlowLo;
|
||||
readonly double finalReqFlowHi;
|
||||
readonly double reqFlowAve;
|
||||
readonly float pidCoef;
|
||||
readonly int timeout;
|
||||
readonly bool leaveMeasurementRunning;
|
||||
|
||||
readonly float nominalFlow;
|
||||
readonly double nominalFlow;
|
||||
readonly double maximalFlow;
|
||||
|
||||
/// Process values
|
||||
enum OpState
|
||||
@ -49,8 +50,8 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
}
|
||||
OpState opState;
|
||||
|
||||
float currentReqFlowLo;
|
||||
float currentReqFlowHi;
|
||||
double currentReqFlowLo;
|
||||
double currentReqFlowHi;
|
||||
float targetPositionLo;
|
||||
float targetPositionHi;
|
||||
|
||||
@ -76,7 +77,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
|
||||
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regV, IRegulValve fxdRV, float fxdPctLo, float fxdPctHi,
|
||||
IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow,
|
||||
IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow,
|
||||
int timeout, bool leaveMeasurementRunning)
|
||||
{
|
||||
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
|
||||
@ -106,11 +107,12 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
throw new ArgumentNullException("flowMeter is null or not Elde");
|
||||
}
|
||||
|
||||
nominalFlow = (float)flowMeter.NominalFlow;
|
||||
nominalFlow = flowMeter.NominalFlow;
|
||||
maximalFlow = nominalFlow * 1.25;
|
||||
|
||||
this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2.0f;
|
||||
this.finalReqFlowLo = (0.7F * requiredFlowLo) + (0.3F * this.reqFlowAve); /// Move the lower limit 15% of the range up
|
||||
this.finalReqFlowHi = (0.7F * requiredFlowHi) + (0.3F * this.reqFlowAve); /// Move the upper limit 15% of the range down
|
||||
this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2;
|
||||
this.finalReqFlowLo = (0.7 * requiredFlowLo) + (0.3 * this.reqFlowAve); /// Move the lower limit 15% of the range up
|
||||
this.finalReqFlowHi = (0.7 * requiredFlowHi) + (0.3 * this.reqFlowAve); /// Move the upper limit 15% of the range down
|
||||
this.pidCoef = pidCoef;
|
||||
this.measuredFlow = measuredFlow;
|
||||
|
||||
@ -126,7 +128,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IRegulValve fixedRV, float fixedPctLo, float fixedPctHi,
|
||||
IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
|
||||
: this(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, false)
|
||||
{
|
||||
}
|
||||
@ -136,8 +138,8 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
/// Events: FlowSet
|
||||
/// </summary>
|
||||
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IRegulValve fixedRV, float fixedPctLo, float fixedPctHi,
|
||||
IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow)
|
||||
: this(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, pidCoef, requiredFlowHi, measuredFlow, int.MaxValue, false)
|
||||
IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef, DoubleBox measuredFlow)
|
||||
: this(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, int.MaxValue, false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -148,7 +150,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
/// <param name="positionLo">Target valve position low limit (output)</param>
|
||||
/// <param name="positionHi">Target valve position high limit (output)</param>
|
||||
/// <returns>true when positions for the target flow are stored in the memory, otherwise return false</returns>
|
||||
bool FetchTargetPosition(float avgReqFlow, out float positionLo, out float positionHi)
|
||||
bool FetchTargetPosition(double avgReqFlow, out float positionLo, out float positionHi)
|
||||
{
|
||||
float targetPosition;
|
||||
if (regulValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
|
||||
@ -165,11 +167,11 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
}
|
||||
}
|
||||
|
||||
void StoreTargetPosition(float avgReqFlow, float actPosition)
|
||||
void StoreTargetPosition(double avgReqFlow, float actPosition)
|
||||
{
|
||||
if (!regulValve.Dict.ContainsKey(reqFlowAve))
|
||||
{
|
||||
regulValve.Dict.Add(new KeyValuePair<float, float>(avgReqFlow, actPosition));
|
||||
regulValve.Dict.Add(new KeyValuePair<double, float>(avgReqFlow, actPosition));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -294,7 +296,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
///
|
||||
/// Done once, issues an appropriate ValveMove(...) command
|
||||
///
|
||||
if (currentReqFlowLo >= currentReqFlowHi || currentReqFlowLo > nominalFlow || currentReqFlowHi <= 0)
|
||||
if ((currentReqFlowLo >= currentReqFlowHi) || (currentReqFlowLo > maximalFlow) || (currentReqFlowHi <= 0))
|
||||
{
|
||||
return Event.OpArgumentError;
|
||||
}
|
||||
@ -302,10 +304,10 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
|
||||
log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
|
||||
regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi);
|
||||
|
||||
float freqLo = 2000.0f * currentReqFlowLo / nominalFlow;
|
||||
float freqHi = 2000.0f * currentReqFlowHi / nominalFlow;
|
||||
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
|
||||
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
|
||||
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
|
||||
new float[2] { freqLo, freqHi },
|
||||
new float[2] { (float)freqLo, (float)freqHi },
|
||||
regulValve.StableTime);
|
||||
|
||||
opState = OpState.SettingFlow;
|
||||
|
||||
@ -18,9 +18,10 @@ namespace TBF.BenchControl.Elde
|
||||
readonly int regulValveNr;
|
||||
readonly int regulValveStableTime;
|
||||
readonly int flowMeterNr;
|
||||
readonly float nominalFlow;
|
||||
readonly float reqFlowLo;
|
||||
readonly float reqFlowHi;
|
||||
readonly double nominalFlow;
|
||||
readonly double maximalFlow;
|
||||
readonly double reqFlowLo;
|
||||
readonly double reqFlowHi;
|
||||
readonly float pidCoef;
|
||||
readonly int totalRefPulses; /// Number of reference pulses for a complete test
|
||||
readonly int massRefPulses; /// Number of reference pulses for mass collection
|
||||
@ -28,8 +29,6 @@ namespace TBF.BenchControl.Elde
|
||||
readonly int[] filters;
|
||||
readonly int diverterNr;
|
||||
|
||||
bool started = false;
|
||||
|
||||
///
|
||||
/// Internal states of this operation
|
||||
///
|
||||
@ -54,7 +53,7 @@ namespace TBF.BenchControl.Elde
|
||||
/// <param name="totalRefPulses">Test duration in number of reference flowmeter pulses</param>
|
||||
/// <param name="filterConstant">Specifies filter for watermeter pulses</param>
|
||||
public StartMeasurementOp(ControlBoardDev controlBoard, OutputPath outputPath, TestMethods method,
|
||||
float requiredFlowLo, float requiredFlowHi,
|
||||
double requiredFlowLo, double requiredFlowHi,
|
||||
int refPulses, int[] filters)
|
||||
: this(controlBoard, outputPath, method, requiredFlowLo, requiredFlowHi, refPulses, refPulses, filters)
|
||||
{
|
||||
@ -70,7 +69,7 @@ namespace TBF.BenchControl.Elde
|
||||
/// <param name="refPulses">Test duration in number of reference flowmeter pulses</param>
|
||||
/// <param name="filterConstant">Specifies filter for watermeter pulses</param>
|
||||
public StartMeasurementOp(ControlBoardDev controlBoard, OutputPath outputPath, TestMethods method,
|
||||
float requiredFlowLo, float requiredFlowHi,
|
||||
double requiredFlowLo, double requiredFlowHi,
|
||||
int totalRefPulses, int massRefPulses, int[] filters)
|
||||
{
|
||||
if (controlBoard == null) throw new ArgumentNullException("controlBoardDev");
|
||||
@ -102,7 +101,8 @@ namespace TBF.BenchControl.Elde
|
||||
diverterNr = (outputPath.Diverter as Elde.Diverter.Diverter).DiverterNr;
|
||||
}
|
||||
|
||||
nominalFlow = (float)outputPath.FlowMeter.NominalFlow;
|
||||
nominalFlow = outputPath.FlowMeter.NominalFlow;
|
||||
maximalFlow = 1.25 * nominalFlow;
|
||||
|
||||
this.reqFlowLo = requiredFlowLo;
|
||||
this.reqFlowHi = requiredFlowHi;
|
||||
@ -179,7 +179,7 @@ namespace TBF.BenchControl.Elde
|
||||
///
|
||||
/// Done once, issues an appropriate ValveMove(...) command
|
||||
///
|
||||
if (reqFlowLo >= reqFlowHi || reqFlowLo > nominalFlow || reqFlowHi <= 0)
|
||||
if ((reqFlowLo >= reqFlowHi) || (reqFlowLo > maximalFlow) || (reqFlowHi <= 0))
|
||||
{
|
||||
return Event.OpArgumentError;
|
||||
}
|
||||
@ -187,18 +187,18 @@ namespace TBF.BenchControl.Elde
|
||||
log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
|
||||
regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi);
|
||||
|
||||
float freqLo = 2000.0f * reqFlowLo / nominalFlow;
|
||||
float freqHi = 2000.0f * reqFlowHi / nominalFlow;
|
||||
double freqLo = 2000.0 * reqFlowLo / nominalFlow;
|
||||
double freqHi = 2000.0 * reqFlowHi / nominalFlow;
|
||||
if (regulValve.IsCoax)
|
||||
{
|
||||
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
|
||||
new float[2] { (freqLo + freqHi) / 2, (freqLo + freqHi) / 2 },
|
||||
new float[2] { (float)((freqLo + freqHi) / 2), (float)((freqLo + freqHi) / 2) },
|
||||
regulValveStableTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
|
||||
new float[2] { freqLo, freqHi },
|
||||
new float[2] { (float)freqLo, (float)freqHi },
|
||||
regulValveStableTime);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -28,7 +28,7 @@ namespace TBF.BenchControl.GenericDevices
|
||||
/// <summary>
|
||||
/// Dictionary for position re-use
|
||||
/// </summary>
|
||||
IDictionary<float, float> Dict { get; }
|
||||
IDictionary<double, float> Dict { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Operation to set the water flow within tolerances
|
||||
@ -40,8 +40,8 @@ namespace TBF.BenchControl.GenericDevices
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
IOperation SetFlowOp(IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout);
|
||||
IOperation SetFlowOp(IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef,
|
||||
DoubleBox measuredFlow, int timeout);
|
||||
|
||||
/// <summary>
|
||||
/// Operation to set the water flow within tolerances. Leave the measurement running.
|
||||
@ -54,8 +54,8 @@ namespace TBF.BenchControl.GenericDevices
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <param name="filter">Passed to SendCommand() as argument filterContant</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
IOperation SetFlowAndMeasureOp(IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
|
||||
float pidCoef, DoubleBox measuredFlow, int timeout, float filter);
|
||||
IOperation SetFlowAndMeasureOp(IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, float pidCoef,
|
||||
DoubleBox measuredFlow, int timeout, float filter);
|
||||
|
||||
/// <summary>
|
||||
/// Operation to set the regulation valve to a required position
|
||||
|
||||
@ -18,18 +18,18 @@ namespace TBF.BenchControl
|
||||
///
|
||||
/// Incremented in RunDevice() depending on diverters and valves
|
||||
///
|
||||
public static float Mass1sim; /// Volume in [ltr] or mass in [kg] in the tank1 on the balance1, filled by the diverter1
|
||||
public static float Mass2sim; /// Volume in [ltr] or mass in [kg] in the tank2 on the balance2, filled by the diverter2
|
||||
public static double Mass1sim; /// Volume in [ltr] or mass in [kg] in the tank1 on the balance1, filled by the diverter1
|
||||
public static double Mass2sim; /// Volume in [ltr] or mass in [kg] in the tank2 on the balance2, filled by the diverter2
|
||||
|
||||
///
|
||||
/// Set by regulation valves
|
||||
///
|
||||
public static float Flow1sim; /// flow in [m3/h] through RV1
|
||||
public static float Flow2sim; /// flow in [m3/h] through RV2
|
||||
public static float Flow3sim; /// flow in [m3/h] through RV3
|
||||
public static float Flow4sim; /// flow in [m3/h] through RV4
|
||||
public static float Flow5sim; /// flow in [m3/h] through RV5
|
||||
public static float Flow6sim; /// flow in [m3/h] through RV5
|
||||
public static double Flow1sim; /// flow in [m3/h] through RV1
|
||||
public static double Flow2sim; /// flow in [m3/h] through RV2
|
||||
public static double Flow3sim; /// flow in [m3/h] through RV3
|
||||
public static double Flow4sim; /// flow in [m3/h] through RV4
|
||||
public static double Flow5sim; /// flow in [m3/h] through RV5
|
||||
public static double Flow6sim; /// flow in [m3/h] through RV5
|
||||
|
||||
///
|
||||
/// Valves and diverters
|
||||
@ -44,14 +44,14 @@ namespace TBF.BenchControl
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Mass1sim = 0.0f; /// Initialize tanks
|
||||
Mass2sim = 0.0f;
|
||||
Flow1sim = 0.0f; /// Initialize regulation valves
|
||||
Flow2sim = 0.0f;
|
||||
Flow3sim = 0.0f;
|
||||
Flow4sim = 0.0f;
|
||||
Flow5sim = 0.0f;
|
||||
Flow6sim = 0.0f;
|
||||
Mass1sim = 0; /// Initialize tanks
|
||||
Mass2sim = 0;
|
||||
Flow1sim = 0; /// Initialize regulation valves
|
||||
Flow2sim = 0;
|
||||
Flow3sim = 0;
|
||||
Flow4sim = 0;
|
||||
Flow5sim = 0;
|
||||
Flow6sim = 0;
|
||||
SimRoute = 0; /// Initialize other valves
|
||||
Div1sim = false;
|
||||
Div2sim = false;
|
||||
@ -497,7 +497,7 @@ namespace TBF.BenchControl
|
||||
{
|
||||
TestBenchSim.regulValveNo = regulValveNo;
|
||||
TestBenchSim.refFlowmtrNo = refFlowmtrNo;
|
||||
float time = 1.0f;
|
||||
double time = 1.0;
|
||||
|
||||
#if DN100
|
||||
if (Div1sim && (SimRoute & Path1) == Path1) Mass1sim += DiffKg(Flow1sim, time);
|
||||
@ -564,10 +564,10 @@ namespace TBF.BenchControl
|
||||
if (Div2sim && (SimRoute & Path2) == Path2) Mass2sim += DiffKg(Flow2sim, time);
|
||||
#endif
|
||||
|
||||
if ((SimRoute & EmptyValve1) == EmptyValve1) Mass1sim -= DiffKg(100.0f, time);
|
||||
if ((SimRoute & EmptyValve1) == EmptyValve1) Mass1sim -= DiffKg(100.0, time);
|
||||
if (Mass1sim < 0) Mass1sim = 0;
|
||||
|
||||
if ((SimRoute & EmptyValve2) == EmptyValve2) Mass2sim -= DiffKg(10.0f, time);
|
||||
if ((SimRoute & EmptyValve2) == EmptyValve2) Mass2sim -= DiffKg(10.0, time);
|
||||
if (Mass2sim < 0) Mass2sim = 0;
|
||||
|
||||
UiBridge.Bridge.OnLog(null, string.Format("I{1}/RV{2}: q1={3}, q2={4}, q3={5}, q4={6}, q5={7}, D123={8}{9}{10}, m1={11}, m2={12}, S={13}\r\n",
|
||||
@ -594,9 +594,9 @@ namespace TBF.BenchControl
|
||||
/// <param name="flowM3H">Flow in [m3/h]</param>
|
||||
/// <param name="timeSec">Time period in [s]</param>
|
||||
/// <returns>Mass change in [kg]</returns>
|
||||
static float DiffKg(float flowM3H, float timeSec)
|
||||
static double DiffKg(double flowM3H, double timeSec)
|
||||
{
|
||||
return timeSec * flowM3H / 3.6f;
|
||||
return timeSec * flowM3H / 3.6;
|
||||
}
|
||||
|
||||
|
||||
@ -605,7 +605,7 @@ namespace TBF.BenchControl
|
||||
/// </summary>
|
||||
/// <param name="balanceNr">0-based balance number</param>
|
||||
/// <returns>Simulated mass reading [kg]</returns>
|
||||
public static float GetSimMass(int balanceNr)
|
||||
public static double GetSimMass(int balanceNr)
|
||||
{
|
||||
if (balanceNr == 0) return Mass1sim;
|
||||
else if (balanceNr == 1) return Mass2sim;
|
||||
@ -751,7 +751,7 @@ namespace TBF.BenchControl
|
||||
/// Get the simulated flow in [m3/h].
|
||||
/// </summary>
|
||||
/// <returns>Simulated flow [m3/h]</returns>
|
||||
public static float GetSimFlow()
|
||||
public static double GetSimFlow()
|
||||
{
|
||||
switch (refFlowmtrNo)
|
||||
{
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1191.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1191.0")]
|
||||
[assembly: AssemblyVersion("2.18.1192.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1192.0")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user