Uni.XyzStartStopTest[WithDiv]Op, etc., AdjustmentSeq and all FlyingStartXyzSeq completed, ver. 3.1.1630

This commit is contained in:
Milan Hanajik
2021-03-14 21:28:41 +01:00
parent 6e1b02ebd5
commit 7af4e9465c
49 changed files with 1201 additions and 1164 deletions
+13 -14
View File
@@ -6,12 +6,11 @@ using System.Collections.Generic;
using log4net;
using SchematicDrawing;
using TBF.Rig.ControlBoard.Uni;
using TBF.Rig.Generic;
using TBF.Boxes;
namespace TBF.Rig.Uni.RegValve
{
public class RegValve : ComponentBase, IDevice, GenericDevices.IRegValve, IDrawingItCmpntWithSetpoint
public class RegValve : ComponentBase, Generic.IDevice, GenericDevices.IRegValve, IDrawingItCmpntWithSetpoint
{
private static readonly ILog log = LogManager.GetLogger(typeof(RegValve));
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(-1)); }
@@ -23,7 +22,7 @@ namespace TBF.Rig.Uni.RegValve
IDictionary<double, double> dict;
public IDictionary<double, double> Dict { get { return dict; } }
readonly UniCB uniCB;
public readonly UniCB UniCB;
readonly int adcChannel;
public ValveCategory Category { get { return regValveCfg.Category; } }
@@ -43,7 +42,7 @@ namespace TBF.Rig.Uni.RegValve
{
int denominator = DacValueOpen - DacValueClosed;
if (denominator == 0) denominator = 1;
return 100.0 * Convert.ToDouble(uniCB.AnalogInput(adcChannel) - DacValueClosed) / Convert.ToDouble(denominator);
return 100.0 * Convert.ToDouble(UniCB.AnalogInput(adcChannel) - DacValueClosed) / Convert.ToDouble(denominator);
}
}
///
@@ -73,7 +72,7 @@ namespace TBF.Rig.Uni.RegValve
/// <param name="time">Time in seconds, positive value opens the reg. valve</param>
public void IncrementalMovement(bool isFromUI, double time)
{
uniCB.RegVlvIncrMove(isFromUI, Idx1, time);
UniCB.RegVlvIncrMove(isFromUI, Idx1, time);
}
/// <summary>
@@ -83,7 +82,7 @@ namespace TBF.Rig.Uni.RegValve
/// <param name="position">Reg. valve position (0 .. 1.0)</param>
public void MoveToPosition(bool isFromUI, double positionLo, double positionHi = -1)
{
uniCB.RegVlvMoveToPos(isFromUI, Idx1, positionLo, positionHi);
UniCB.RegVlvMoveToPos(isFromUI, Idx1, positionLo, positionHi);
}
@@ -120,7 +119,7 @@ namespace TBF.Rig.Uni.RegValve
}
else if (args.Command == CfgChangeCmd.GetAdc1 || args.Command == CfgChangeCmd.GetAdc2)
{
short adcValue = uniCB.AnalogInput(adcChannel);
short adcValue = UniCB.AnalogInput(adcChannel);
RegValveCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, Idx1, adcValue));
}
}
@@ -140,8 +139,8 @@ namespace TBF.Rig.Uni.RegValve
regValveCfg = cfg as RegValveCfg;
adcChannel = regValveCfg.Idx1 - 1;
this.uniCB = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB;
if (this.uniCB == null) throw new Exception(string.Format("Cannot find {0} (a parent of {1})", cfg.ParentName, Name));
this.UniCB = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB;
if (this.UniCB == null) throw new Exception(string.Format("Cannot find {0} (a parent of {1})", cfg.ParentName, Name));
this.dict = new Dictionary<double, double>();
@@ -155,7 +154,7 @@ namespace TBF.Rig.Uni.RegValve
public void Initialize() { }
public void RunDeviceBefore()
{
Int16 adcValue = uniCB.AnalogInput(adcChannel);
Int16 adcValue = UniCB.AnalogInput(adcChannel);
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, Idx1, adcValue));
}
public void RunDeviceAfter() { }
@@ -176,7 +175,7 @@ namespace TBF.Rig.Uni.RegValve
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow, int timeout)
{
return new SetFlowOp(uniCB, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout);
return new SetFlowOp(UniCB, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout);
}
/// <summary>
@@ -192,7 +191,7 @@ namespace TBF.Rig.Uni.RegValve
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
DoubleBox measuredFlow, int timeout, float filterConstant)
{
return new SetFlowOp(uniCB, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout, true);
return new SetFlowOp(UniCB, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout, true);
}
/// <summary>
@@ -204,12 +203,12 @@ namespace TBF.Rig.Uni.RegValve
/// <returns>SetPositionOp instance</returns>
public IOperation SetRegulValvePositionOp(double pctLo, double pctHi, int timeoutMs)
{
return new SetRegValvePositionOp(uniCB, this, pctLo, pctHi, timeoutMs);
return new SetRegValvePositionOp(UniCB, this, pctLo, pctHi, timeoutMs);
}
public IOperation ChangeRegulValvePositionOp(double timePulseSec)
{
return new ChangeRegulValvePositionOp(uniCB, this, timePulseSec);
return new ChangeRegulValvePositionOp(UniCB, this, timePulseSec);
}
}
}
+14 -17
View File
@@ -28,7 +28,6 @@ namespace TBF.Rig.Uni.RegValve
readonly int timeout;
readonly bool leaveMeasurementRunning;
readonly double nominalFlow;
readonly double maximalFlow;
///
@@ -66,14 +65,14 @@ namespace TBF.Rig.Uni.RegValve
/// <param name="uniCB">Control board device</param>
/// <param name="regulValve">Regulation valve component</param>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="targetFlowLo">Lower limit of the flow to be achieved in [m3/h]</param>
/// <param name="targetFlowHi">Upper limit of the flow to be achieved in [m3/h]</param>
/// <param name="qFrom">Lower limit of the flow to be achieved in [m3/h]</param>
/// <param name="qTo">Upper limit of the flow to be achieved in [m3/h]</param>
/// <param name="pidCoef">PID coefficient (float)</param>
/// <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(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi,
DoubleBox flowBox, int timeout, bool leaveMeasurementRunning)
public SetFlowOp(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double qFrom, double qTo, DoubleBox flowBox,
int timeout, bool leaveMeasurementRunning)
{
this.uniCB = uniCB;
if (this.uniCB == null) throw new ArgumentNullException("cBoard is null or not Uni");
@@ -84,12 +83,11 @@ namespace TBF.Rig.Uni.RegValve
this.flowMeter = flowMeter;
if (this.flowMeter == null) throw new ArgumentNullException("flowMeter");
nominalFlow = flowMeter.NominalFlow;
maximalFlow = nominalFlow * 1.25;
maximalFlow = flowMeter.NominalFlow * 1.25;
this.targetFlowAve = (targetFlowLo + targetFlowHi) / 2;
this.shrinkedTgtFlowLo = (0.7 * targetFlowLo) + (0.3 * this.targetFlowAve); /// Move the lower limit 15% of the range up
this.shrinkedTgtFlowHi = (0.7 * targetFlowHi) + (0.3 * this.targetFlowAve); /// Move the upper limit 15% of the range down
this.targetFlowAve = (qFrom + qTo) / 2;
this.shrinkedTgtFlowLo = (0.7 * qFrom) + (0.3 * this.targetFlowAve); /// Move the lower limit 15% of the range up
this.shrinkedTgtFlowHi = (0.7 * qTo) + (0.3 * this.targetFlowAve); /// Move the upper limit 15% of the range down
this.flowBox = flowBox;
if (this.flowBox == null) throw new ArgumentNullException("flowBox");
@@ -105,9 +103,8 @@ namespace TBF.Rig.Uni.RegValve
/// Set required water flow - Do not leave the measurement running.
/// Events: FlowSet
/// </summary>
public SetFlowOp(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi,
DoubleBox flowbox, int timeout)
: this(uniCB, regValve, flowMeter, targetFlowLo, targetFlowHi, flowbox, timeout, false)
public SetFlowOp(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double qFrom, double qTo, DoubleBox flowbox, int timeout)
: this(uniCB, regValve, flowMeter, qFrom, qTo, flowbox, timeout, false)
{
}
@@ -115,9 +112,8 @@ namespace TBF.Rig.Uni.RegValve
/// Set required water flow - No timeout.
/// Events: FlowSet
/// </summary>
public SetFlowOp(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi,
DoubleBox flowbox)
: this(uniCB, regValve, flowMeter, targetFlowLo, targetFlowHi, flowbox, int.MaxValue, false)
public SetFlowOp(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double qFrom, double qTo, DoubleBox flowbox)
: this(uniCB, regValve, flowMeter, qFrom, qTo, flowbox, int.MaxValue, false)
{
}
@@ -203,7 +199,8 @@ namespace TBF.Rig.Uni.RegValve
return Event.OpArgumentError;
}
uniCB.SetFlow(false, regV.Idx1, 2000 * currentReqFlowLo / nominalFlow, 2000 * currentReqFlowHi / nominalFlow);
uniCB.SetFlow(false, regV.Idx1, 2000 * currentReqFlowLo / flowMeter.NominalFlow,
2000 * currentReqFlowHi / flowMeter.NominalFlow);
log.InfoFormat("Run(): rv#={0} TARGET: flowLo={1} flowHi={2}", regV.Idx1, currentReqFlowLo, currentReqFlowHi);
+5 -5
View File
@@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.ControlBoard.Uni;
using TBF.Rig.Generic;
using TBF.Boxes;
@@ -13,14 +13,14 @@ namespace TBF.Rig.Uni.RegValveTandem
public class RegValveTandem : ComponentBase, GenericDevices.IRegValve
{
private static readonly ILog log = LogManager.GetLogger(typeof(RegValveTandem));
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(1)); }
public override string ToString() { return string.Format("RegValveTandem({0})", Cfg.ToString(-1)); }
public readonly RegValveTandemCfg RegulValveTandemCfg;
IDictionary<double, double> dict;
public IDictionary<double, double> Dict { get { return dict; } }
CBoard controlBoard { get { return regValve.ControlBoard; } }
UniCB uniCB { get { return regValve.UniCB; } }
public ValveCategory Category { get { return RegulValveTandemCfg.Category; } }
readonly TBF.Rig.Uni.RegValve.RegValve regValve;
@@ -75,7 +75,7 @@ namespace TBF.Rig.Uni.RegValveTandem
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow, int timeout)
{
return new SetFlowOp(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi,
return new SetFlowOp(uniCB, regValve, fixedRV, fixedPctLo, fixedPctHi,
flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout);
}
@@ -92,7 +92,7 @@ namespace TBF.Rig.Uni.RegValveTandem
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
DoubleBox measuredFlow, int timeout, float filterConstant)
{
return new SetFlowOp(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi,
return new SetFlowOp(uniCB, regValve, fixedRV, fixedPctLo, fixedPctHi,
flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout, true);
}
@@ -40,7 +40,7 @@ namespace TBF.Rig.Uni.RegValveTandem
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.RegulValve.RegulValveFactory)
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Uni.RegValve.Factory)
{
regulValveNameComboBox.Items.Add(cmpnt.Name);
fixedRVNameComboBox.Items.Add(cmpnt.Name);
+30 -39
View File
@@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.ControlBoard.Uni;
using TBF.Rig.GenericDevices;
using TBF.Boxes;
@@ -19,9 +19,9 @@ namespace TBF.Rig.Uni.RegValveTandem
}
/// Set by the constructor
readonly CBoard controlBoard;
readonly TBF.Rig.Uni.RegValve.RegValve regValve;
readonly TBF.Rig.Uni.RegValve.RegValve fixedRV;
readonly UniCB uniCB;
readonly RegValve.RegValve regValve;
readonly RegValve.RegValve fixedRV;
readonly double fixedPctLo;
readonly double fixedPctHi;
readonly int flowMeterNr;
@@ -74,18 +74,18 @@ namespace TBF.Rig.Uni.RegValveTandem
/// <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(CBoard controlBoard, IRegValve regV, IRegValve fxdRV, float fxdPctLo, float fxdPctHi,
public SetFlowOp(TBF.Rig.ControlBoard.IControlBoard cb, IRegValve regV, IRegValve fxdRV, float fxdPctLo, float fxdPctHi,
IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow,
int timeout, bool leaveMeasurementRunning)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
this.uniCB = cb as UniCB;
if (uniCB == null) throw new ArgumentNullException("ctrlBoard is not Uni");
regValve = regV as TBF.Rig.Uni.RegValve.RegValve;
if (regValve == null) throw new ArgumentNullException("regValve is null or not Elde");
if (regValve == null) throw new ArgumentNullException("regValve is null or not Uni");
fixedRV = fxdRV as TBF.Rig.Uni.RegValve.RegValve;
if (fixedRV == null) throw new ArgumentNullException("regValve is null or not Elde");
if (fixedRV == null) throw new ArgumentNullException("regValve is null or not Uni");
this.fixedPctLo = fxdPctLo;
this.fixedPctHi = fxdPctHi;
@@ -93,18 +93,20 @@ namespace TBF.Rig.Uni.RegValveTandem
if (flowMeter is Uni.FlowMeter.FlowMeter)
{
this.flowMeterNr = (flowMeter as Uni.FlowMeter.FlowMeter).Idx1;
this.nominalFlow = flowMeter.NominalFlow;
}
else if (flowMeter is Elde.FlowMeterTwins.FlowMeter)
{
this.flowMeterNr = 0;
this.nominalFlow = flowMeter.NominalFlow;
}
else
{
throw new ArgumentNullException("flowMeter is null or not Elde");
throw new ArgumentNullException("flowMeter is null or not Uni");
}
nominalFlow = flowMeter.NominalFlow;
maximalFlow = nominalFlow * 1.25;
maximalFlow = flowMeter.NominalFlow * 1.25;
this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2;
this.finalReqFlowLo = (0.7 * requiredFlowLo) + (0.3 * this.reqFlowAve); /// Move the lower limit 15% of the range up
@@ -122,9 +124,9 @@ namespace TBF.Rig.Uni.RegValveTandem
/// Set required water flow - Do not leave the measurement running.
/// Events: FlowSet
/// </summary>
public SetFlowOp(CBoard controlBoard, IRegValve regValve, IRegValve fixedRV, float fixedPctLo, float fixedPctHi,
public SetFlowOp(UniCB uniCB, IRegValve regValve, IRegValve fixedRV, float fixedPctLo, float fixedPctHi,
IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow, int timeout)
: this(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout, false)
: this(uniCB, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout, false)
{
}
@@ -132,9 +134,9 @@ namespace TBF.Rig.Uni.RegValveTandem
/// Set required water flow - No timeout.
/// Events: FlowSet
/// </summary>
public SetFlowOp(CBoard controlBoard, IRegValve regValve, IRegValve fixedRV, float fixedPctLo, float fixedPctHi,
public SetFlowOp(UniCB uniCB, IRegValve regValve, IRegValve fixedRV, float fixedPctLo, float fixedPctHi,
IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow)
: this(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, int.MaxValue, false)
: this(uniCB, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, int.MaxValue, false)
{
}
@@ -174,7 +176,7 @@ namespace TBF.Rig.Uni.RegValveTandem
/// <summary>Start this operation</summary>
public void Start()
{
double flowMtrFreq = controlBoard.RefFrequency;
double flowMtrFreq = uniCB.RefFrequency;
currentReqFlowLo = reqFlowAve;
currentReqFlowHi = reqFlowAve;
///
@@ -211,10 +213,8 @@ namespace TBF.Rig.Uni.RegValveTandem
expireTime = StateMachine.Time + timeout;
if (expireTime < 0) expireTime = int.MaxValue;
ControlBoard.Legacy.TestMethods tm = 0;
StopDevs sd = 0;
// '_regulValve.RegulValveTandemCfg.PidCoef' replaced by a casted operation parameter 'pidCoef'
controlBoard.SendCommand(Command.Start, flowMeterNr, int.MaxValue, int.MaxValue, tm, sd);
/// Start flow measurement
uniCB.MeasureFlow(false, flowMeterNr);
}
/// <summary>Run this operation</summary>
@@ -223,9 +223,9 @@ namespace TBF.Rig.Uni.RegValveTandem
/// </returns>
public Event Run()
{
float rvPosition = controlBoard.RValvePosition(regValve.Idx1);
float fixedRVPosition = controlBoard.RValvePosition(fixedRV.Idx1);
double flowMtrFreq = controlBoard.RefFrequency;
double rvPosition = regValve.Position;
double fixedRVPosition = fixedRV.Position;
double flowMtrFreq = uniCB.RefFrequency;
double flow = flowMtrFreq * nominalFlow / 2000.0;
if (flowMtrFreq != 0)
@@ -243,9 +243,7 @@ namespace TBF.Rig.Uni.RegValveTandem
///
/// Done once, issues an appropriate ValveMove(...) command
///
controlBoard.ValveMove(regValve.Idx1, RegulValveMode.TargetPosition,
new double[2] { targetPositionLo, targetPositionHi },
regValve.StableTime);
uniCB.RegVlvMoveToPos(false, regValve.Idx1, targetPositionLo, targetPositionHi);
opState = OpState.SettingPosition;
return Event.None;
@@ -266,9 +264,7 @@ namespace TBF.Rig.Uni.RegValveTandem
///
/// Done once, issues an appropriate ValveMove(...) command
///
controlBoard.ValveMove(fixedRV.Idx1, RegulValveMode.TargetPosition,
new double[2] { fixedPctLo, fixedPctHi },
regValve.StableTime);
uniCB.RegVlvMoveToPos(false, fixedRV.Idx1, fixedPctLo, fixedPctHi);
opState = OpState.SettingPosition_FixedRV;
return Event.None;
@@ -299,9 +295,7 @@ namespace TBF.Rig.Uni.RegValveTandem
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
controlBoard.ValveMove(regValve.Idx1, RegulValveMode.TargetFrequency,
new double[2] { freqLo, freqHi },
regValve.StableTime);
uniCB.SetFlow(false, regValve.Idx1, freqLo, freqHi);
opState = OpState.SettingFlow;
return Event.None;
@@ -359,15 +353,12 @@ namespace TBF.Rig.Uni.RegValveTandem
/// <summary>Start this operation</summary>
public void Stop()
{
opState = OpState.Idle;
{
opState = OpState.Idle;
if (leaveMeasurementRunning) return;
/// Stop measurement
ControlBoard.Legacy.TestMethods tm = 0;
StopDevs sd = StopDevs.RegValveRegulation;
controlBoard.SendCommand(Command.Stop, flowMeterNr, 50000, 50000, tm, sd);
uniCB.Stop(false); /// Stop measurement
}
}
}