diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs index 837e4b041..fcba8d801 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs @@ -14,7 +14,7 @@ namespace TBF.BenchControl.Elde.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}, PID={3})", regulValve.Name, finalReqFlowLo, finalReqFlowHi, pidCoef); } const int CoaxValveNr = 7; /// Coax. valve has number 7 @@ -25,17 +25,17 @@ namespace TBF.BenchControl.Elde.RegulValve readonly Elde.RegulValve.RegulValve regulValve; readonly int regulValveNr; readonly int flowMeterNr; - readonly float reqFlowLo; - readonly float reqFlowHi; - readonly float reqFlowAve; + readonly float finalReqFlowLo; + readonly float finalReqFlowHi; + readonly float reqFlowAve; readonly float pidCoef; readonly int timeout; readonly bool leaveMeasurementRunning; readonly bool reTryCommands; readonly float nominalFlow; - - /// + + /// /// Internal states of this operation /// enum OpState @@ -56,6 +56,8 @@ namespace TBF.BenchControl.Elde.RegulValve } OpState opState; + float currentReqFlowLo; + float currentReqFlowHi; float targetPositionLo; float targetPositionHi; @@ -103,10 +105,10 @@ namespace TBF.BenchControl.Elde.RegulValve nominalFlow = flowMeter.NominalFlow; - this.reqFlowLo = (3.0f * requiredFlowLo + requiredFlowHi) / 4.0f; - this.reqFlowHi = (3.0f * requiredFlowHi + requiredFlowLo) / 4.0f; - this.reqFlowAve = (reqFlowLo + reqFlowHi) / 2.0f; - this.pidCoef = pidCoef; + this.finalReqFlowLo = requiredFlowLo; + this.finalReqFlowHi = requiredFlowHi; + this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2.0f; + this.pidCoef = pidCoef; this.measuredFlow = measuredFlow; this.reTryCommands = reTryCmds; @@ -173,19 +175,36 @@ namespace TBF.BenchControl.Elde.RegulValve /// Start this operation public void Start() { + double flowMtrFreq = controlBoard.ReferenceFreq; + currentReqFlowLo = reqFlowAve; + currentReqFlowHi = reqFlowAve; + /// + if (flowMtrFreq != 0) + { + double flow = flowMtrFreq * nominalFlow / 2000.0; + if (measuredFlow != null) measuredFlow.Val = flow; + if (flow >= reqFlowAve) currentReqFlowLo = finalReqFlowLo; + if (flow <= reqFlowAve) currentReqFlowHi = finalReqFlowHi; + } + else + { + currentReqFlowLo = finalReqFlowLo; /// Unexpected case when flowMtrFreq==0 + currentReqFlowHi = finalReqFlowHi; + } + flowWithinBoundsTime = 0; if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi)) { log.InfoFormat("SetFlowOp:Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi, targetPositionLo, targetPositionHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi); opState = OpState.ValveMoveToPosition1; } else { log.InfoFormat("SetFlowOp:Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); opState = OpState.ValveMoveToFlow1; } @@ -214,6 +233,8 @@ namespace TBF.BenchControl.Elde.RegulValve if (flowMtrFreq != 0) { if (measuredFlow != null) measuredFlow.Val = flow; + if (flow >= reqFlowAve) currentReqFlowLo = finalReqFlowLo; + if (flow <= reqFlowAve) currentReqFlowHi = finalReqFlowHi; } log.InfoFormat("SetFlowOp:Run() rv#={0} pos={1}% freq={2} flow={3} opState={4}", @@ -227,14 +248,14 @@ namespace TBF.BenchControl.Elde.RegulValve if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi)) { log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi, targetPositionLo, targetPositionHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi); opState = OpState.ValveMoveToPosition1; } else { log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); opState = OpState.ValveMoveToFlow1; } @@ -335,16 +356,16 @@ namespace TBF.BenchControl.Elde.RegulValve /// /// Done once, issues an appropriate ValveMove(...) command /// - if (reqFlowLo >= reqFlowHi || reqFlowLo > nominalFlow || reqFlowHi <= 0) + if (currentReqFlowLo >= currentReqFlowHi || currentReqFlowLo > nominalFlow || currentReqFlowHi <= 0) { return Event.OpArgumentError; } log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); - float freqLo = 2000.0f * reqFlowLo / nominalFlow; - float freqHi = 2000.0f * reqFlowHi / nominalFlow; + float freqLo = 2000.0f * currentReqFlowLo / nominalFlow; + float freqHi = 2000.0f * currentReqFlowHi / nominalFlow; controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency, new float[2] { freqLo, freqHi }, regulValve.StableTime); @@ -375,8 +396,8 @@ namespace TBF.BenchControl.Elde.RegulValve else if (regulValveNr == CoaxValveNr && ((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0) { /// Done once, issues an appropriate ValveMove(...) command - float freqLo = 2000.0f * reqFlowLo / nominalFlow; - float freqHi = 2000.0f * reqFlowHi / nominalFlow; + float freqLo = 2000.0f * currentReqFlowLo / nominalFlow; + float freqHi = 2000.0f * currentReqFlowHi / nominalFlow; controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency, new float[2] { (freqLo + freqHi) / 2.0f, (freqLo + freqHi) / 2.0f }, regulValve.StableTime); @@ -390,8 +411,8 @@ namespace TBF.BenchControl.Elde.RegulValve else if (regulValveNr < 6 && controlBoard.RegulValveState(regulValveNr) != RegulValveState.PwOrFreqRegul) { /// Done once, issues an appropriate ValveMove(...) command - float freqLo = 2000.0f * reqFlowLo / nominalFlow; - float freqHi = 2000.0f * reqFlowHi / nominalFlow; + float freqLo = 2000.0f * currentReqFlowLo / nominalFlow; + float freqHi = 2000.0f * currentReqFlowHi / nominalFlow; controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency, new float[2] { freqLo, freqHi }, regulValve.StableTime); @@ -413,7 +434,7 @@ namespace TBF.BenchControl.Elde.RegulValve /// /// Repeated untill the required flow is reached /// - if ((reqFlowLo <= flow) && (flow <= reqFlowHi)) + if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi)) { if (flowWithinBoundsTime++ >= regulValve.FlowStableSec) { @@ -436,14 +457,14 @@ namespace TBF.BenchControl.Elde.RegulValve } } - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, reqFlowLo, reqFlowHi); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, currentReqFlowLo, currentReqFlowHi); opState = OpState.FlowReached; return Event.FlowReached; } else { - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, FLOW_OK_TIMER={3}s)", flow, reqFlowLo, reqFlowHi, flowWithinBoundsTime); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, FLOW_OK_TIMER={3}s)", flow, currentReqFlowLo, currentReqFlowHi, flowWithinBoundsTime); return Event.None; } } @@ -453,14 +474,14 @@ namespace TBF.BenchControl.Elde.RegulValve } else { - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2})", flow, reqFlowLo, reqFlowHi); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2})", flow, currentReqFlowLo, currentReqFlowHi); flowWithinBoundsTime = 0; return Event.None; } } else /// opState == OpState.FlowReached { - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, reqFlowLo, reqFlowHi); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, currentReqFlowLo, currentReqFlowHi); return Event.FlowReached; } } diff --git a/TestBenchFramework/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs index a3a18b9cf..8b2fceb85 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs @@ -14,7 +14,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax 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}, PID={3})", regulValve.Name, finalReqFlowLo, finalReqFlowHi, pidCoef); } const int CoaxValveNr = 7; /// Coax. valve has number 7 @@ -25,8 +25,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax readonly Elde.RegulValve.RegulValve regulValve; readonly int regulValveNr; readonly int flowMeterNr; - readonly float reqFlowLo; - readonly float reqFlowHi; + readonly float finalReqFlowLo; + readonly float finalReqFlowHi; readonly float reqFlowAve; readonly float pidCoef; readonly int timeout; @@ -56,7 +56,9 @@ namespace TBF.BenchControl.Elde.RegulValveCoax } OpState opState; - float targetPositionLo; + float currentReqFlowLo; + float currentReqFlowHi; + float targetPositionLo; float targetPositionHi; int expireTime; @@ -103,10 +105,10 @@ namespace TBF.BenchControl.Elde.RegulValveCoax nominalFlow = flowMeter.NominalFlow; - this.reqFlowLo = (3.0f * requiredFlowLo + requiredFlowHi) / 4.0f; - this.reqFlowHi = (3.0f * requiredFlowHi + requiredFlowLo) / 4.0f; - this.reqFlowAve = (reqFlowLo + reqFlowHi) / 2.0f; - this.pidCoef = pidCoef; + this.finalReqFlowLo = requiredFlowLo; + this.finalReqFlowHi = requiredFlowHi; + this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2.0f; + this.pidCoef = pidCoef; this.measuredFlow = measuredFlow; this.reTryCommands = reTryCmds; @@ -173,19 +175,36 @@ namespace TBF.BenchControl.Elde.RegulValveCoax /// Start this operation public void Start() { + double flowMtrFreq = controlBoard.ReferenceFreq; + currentReqFlowLo = reqFlowAve; + currentReqFlowHi = reqFlowAve; + /// + if (flowMtrFreq != 0) + { + double flow = flowMtrFreq * nominalFlow / 2000.0; + if (measuredFlow != null) measuredFlow.Val = flow; + if (flow >= reqFlowAve) currentReqFlowLo = finalReqFlowLo; + if (flow <= reqFlowAve) currentReqFlowHi = finalReqFlowHi; + } + else + { + currentReqFlowLo = finalReqFlowLo; /// Unexpected case when flowMtrFreq==0 + currentReqFlowHi = finalReqFlowHi; + } + flowWithinBoundsTime = 0; if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi)) { log.InfoFormat("SetFlowOp:Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi, targetPositionLo, targetPositionHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi); opState = OpState.ValveMoveToPosition1; } else { log.InfoFormat("SetFlowOp:Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); opState = OpState.ValveMoveToFlow1; } @@ -214,6 +233,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax if (flowMtrFreq != 0) { if (measuredFlow != null) measuredFlow.Val = flow; + if (flow >= reqFlowAve) currentReqFlowLo = finalReqFlowLo; + if (flow <= reqFlowAve) currentReqFlowHi = finalReqFlowHi; } log.InfoFormat("SetFlowOp:Run() rv#={0} pos={1}% freq={2} flow={3} opState={4}", @@ -227,14 +248,14 @@ namespace TBF.BenchControl.Elde.RegulValveCoax if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi)) { log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi, targetPositionLo, targetPositionHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi); opState = OpState.ValveMoveToPosition1; } else { log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); opState = OpState.ValveMoveToFlow1; } @@ -335,16 +356,16 @@ namespace TBF.BenchControl.Elde.RegulValveCoax /// /// Done once, issues an appropriate ValveMove(...) command /// - if (reqFlowLo >= reqFlowHi || reqFlowLo > nominalFlow || reqFlowHi <= 0) + if (currentReqFlowLo >= currentReqFlowHi || currentReqFlowLo > nominalFlow || currentReqFlowHi <= 0) { return Event.OpArgumentError; } log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); - float freqLo = 2000.0f * reqFlowLo / nominalFlow; - float freqHi = 2000.0f * reqFlowHi / nominalFlow; + float freqLo = 2000.0f * currentReqFlowLo / nominalFlow; + float freqHi = 2000.0f * currentReqFlowHi / nominalFlow; controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency, new float[2] { freqLo, freqHi }, regulValve.StableTime); @@ -375,8 +396,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax else if (regulValveNr == CoaxValveNr && ((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0) { /// Done once, issues an appropriate ValveMove(...) command - float freqLo = 2000.0f * reqFlowLo / nominalFlow; - float freqHi = 2000.0f * reqFlowHi / nominalFlow; + float freqLo = 2000.0f * currentReqFlowLo / nominalFlow; + float freqHi = 2000.0f * currentReqFlowHi / nominalFlow; controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency, new float[2] { (freqLo + freqHi) / 2.0f, (freqLo + freqHi) / 2.0f }, regulValve.StableTime); @@ -390,8 +411,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax else if (regulValveNr < 6 && controlBoard.RegulValveState(regulValveNr) != RegulValveState.PwOrFreqRegul) { /// Done once, issues an appropriate ValveMove(...) command - float freqLo = 2000.0f * reqFlowLo / nominalFlow; - float freqHi = 2000.0f * reqFlowHi / nominalFlow; + float freqLo = 2000.0f * currentReqFlowLo / nominalFlow; + float freqHi = 2000.0f * currentReqFlowHi / nominalFlow; controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency, new float[2] { freqLo, freqHi }, regulValve.StableTime); @@ -413,7 +434,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax /// /// Repeated untill the required flow is reached /// - if ((reqFlowLo <= flow) && (flow <= reqFlowHi)) + if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi)) { if (flowWithinBoundsTime++ >= regulValve.FlowStableSec) { @@ -436,14 +457,14 @@ namespace TBF.BenchControl.Elde.RegulValveCoax } } - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, reqFlowLo, reqFlowHi); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, currentReqFlowLo, currentReqFlowHi); opState = OpState.FlowReached; return Event.FlowReached; } else { - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, FLOW_OK_TIMER={3}s)", flow, reqFlowLo, reqFlowHi, flowWithinBoundsTime); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, FLOW_OK_TIMER={3}s)", flow, currentReqFlowLo, currentReqFlowHi, flowWithinBoundsTime); return Event.None; } } @@ -453,14 +474,14 @@ namespace TBF.BenchControl.Elde.RegulValveCoax } else { - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2})", flow, reqFlowLo, reqFlowHi); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2})", flow, currentReqFlowLo, currentReqFlowHi); flowWithinBoundsTime = 0; return Event.None; } } else /// opState == OpState.FlowReached { - log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, reqFlowLo, reqFlowHi); + log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, currentReqFlowLo, currentReqFlowHi); return Event.FlowReached; } } diff --git a/TestBenchFramework/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs index d7e7d9a0b..346e87146 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs @@ -14,7 +14,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem 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}, PID={3})", regulValve.Name, finalReqFlowLo, finalReqFlowHi, pidCoef); } /// Set by the constructor @@ -26,8 +26,8 @@ namespace TBF.BenchControl.Elde.RegulValveTandem readonly float fixedPctLo; readonly float fixedPctHi; readonly int flowMeterNr; - readonly float reqFlowLo; - readonly float reqFlowHi; + readonly float finalReqFlowLo; + readonly float finalReqFlowHi; readonly float reqFlowAve; readonly float pidCoef; readonly int timeout; @@ -49,7 +49,9 @@ namespace TBF.BenchControl.Elde.RegulValveTandem } OpState opState; - float targetPositionLo; + float currentReqFlowLo; + float currentReqFlowHi; + float targetPositionLo; float targetPositionHi; int expireTime; @@ -106,9 +108,9 @@ namespace TBF.BenchControl.Elde.RegulValveTandem nominalFlow = flowMeter.NominalFlow; - this.reqFlowLo = (3.0f * requiredFlowLo + requiredFlowHi) / 4.0f; - this.reqFlowHi = (3.0f * requiredFlowHi + requiredFlowLo) / 4.0f; - this.reqFlowAve = (reqFlowLo + reqFlowHi) / 2.0f; + this.finalReqFlowLo = requiredFlowLo; + this.finalReqFlowHi = requiredFlowHi; + this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2.0f; this.pidCoef = pidCoef; this.measuredFlow = measuredFlow; @@ -175,19 +177,36 @@ namespace TBF.BenchControl.Elde.RegulValveTandem /// Start this operation public void Start() { + double flowMtrFreq = controlBoard.ReferenceFreq; + currentReqFlowLo = reqFlowAve; + currentReqFlowHi = reqFlowAve; + /// + if (flowMtrFreq != 0) + { + double flow = flowMtrFreq * nominalFlow / 2000.0; + if (measuredFlow != null) measuredFlow.Val = flow; + if (flow >= reqFlowAve) currentReqFlowLo = finalReqFlowLo; + if (flow <= reqFlowAve) currentReqFlowHi = finalReqFlowHi; + } + else + { + currentReqFlowLo = finalReqFlowLo; /// Unexpected case when flowMtrFreq==0 + currentReqFlowHi = finalReqFlowHi; + } + flowWithinBoundsTime = 0; if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi)) { log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi, targetPositionLo, targetPositionHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi); opState = OpState.IssueSetPositionCommand; } else { log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); opState = OpState.IssueSetPositionCommand_FixedRV; } @@ -214,7 +233,12 @@ namespace TBF.BenchControl.Elde.RegulValveTandem double flowMtrFreq = controlBoard.ReferenceFreq; double flow = flowMtrFreq * nominalFlow / 2000.0; - if (measuredFlow != null) measuredFlow.Val = flow; + if (flowMtrFreq != 0) + { + if (measuredFlow != null) measuredFlow.Val = flow; + if (flow >= reqFlowAve) currentReqFlowLo = finalReqFlowLo; + if (flow <= reqFlowAve) currentReqFlowHi = finalReqFlowHi; + } log.InfoFormat("Run(): rv#={0} pos={1}% freq={2} flow={3} opState={4}", regulValveNr, rvPosition.ToString("F1"), flowMtrFreq, flow, opState); @@ -270,16 +294,16 @@ namespace TBF.BenchControl.Elde.RegulValveTandem /// /// Done once, issues an appropriate ValveMove(...) command /// - if (reqFlowLo >= reqFlowHi || reqFlowLo > nominalFlow || reqFlowHi <= 0) + if (currentReqFlowLo >= currentReqFlowHi || currentReqFlowLo > nominalFlow || currentReqFlowHi <= 0) { return Event.OpArgumentError; } log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", - regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); + regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi); - float freqLo = 2000.0f * reqFlowLo / nominalFlow; - float freqHi = 2000.0f * reqFlowHi / nominalFlow; + float freqLo = 2000.0f * currentReqFlowLo / nominalFlow; + float freqHi = 2000.0f * currentReqFlowHi / nominalFlow; controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency, new float[2] { freqLo, freqHi }, regulValve.StableTime); @@ -292,7 +316,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem /// /// Repeated untill the required flow is reached /// - if ((reqFlowLo <= flow) && (flow <= reqFlowHi)) + if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi)) { if (flowWithinBoundsTime++ >= regulValve.FlowStableSec) { diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 24fb7f865..729806d7a 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.17.708.1")] -[assembly: AssemblyFileVersion("2.17.708.1")] +[assembly: AssemblyVersion("2.17.709.1")] +[assembly: AssemblyFileVersion("2.17.709.1")]