(1) Range of flow extended to 125%, (2) RequredFlowLo/Hi etc. float -> double, ver. 2.18.1192

This commit is contained in:
Milan Hanajik
2019-04-15 08:15:47 +02:00
parent 556290abf6
commit f8671ac516
16 changed files with 172 additions and 171 deletions
@@ -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;