Changes in TBF.Rig.Uni.RegValve(s), TBF.Rig.CB.Uni.Action.RegVlvMoveToPos, etc.
This commit is contained in:
@@ -55,10 +55,20 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
/// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move a regulation valve to specfied position
|
||||
/// </summary>
|
||||
/// <param name="rvId">Reg. valve ID</param>
|
||||
/// <param name="position">Reg. valve position (0 .. 1.0)</param>
|
||||
public void MoveToPosition(bool isFromUI, double posPct)
|
||||
{
|
||||
/// Converison assuming: 0..100 % ~ 4..20 mA , 0..20 mA ~ 0..1023
|
||||
int targetAdcVal = Math.Max(0, Math.Min(1023, Convert.ToInt32(Math.Round(8.19 * posPct + 204.0))));
|
||||
uniCB.RegVlvMoveToPos(isFromUI, Idx1, targetAdcVal);
|
||||
}
|
||||
|
||||
public RegValve()
|
||||
{
|
||||
}
|
||||
|
||||
public RegValve() { }
|
||||
|
||||
public RegValve(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
@@ -67,13 +77,13 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
|
||||
uniCB = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB;
|
||||
if (uniCB == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
this.dict = new Dictionary<double, double>();
|
||||
|
||||
log.FatalFormat("{0} initialized: {1}", Name, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(SetRegValvePositionOp));
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("SetRegValvePositionOp({0},{1},{2})", regValve.Name, posLoPct, posHiPct);
|
||||
return string.Format("SetRegValvePositionOp({0},{1},{2})", regV.Name, posLoPct, posHiPct);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -31,7 +31,7 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
|
||||
/// Set by the constructor
|
||||
readonly UniCB uniCB;
|
||||
readonly RegValve regValve;
|
||||
readonly RegValve regV;
|
||||
readonly double posLoPct;
|
||||
readonly double posHiPct;
|
||||
readonly int timeout;
|
||||
@@ -52,11 +52,11 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
|
||||
public SetRegValvePositionOp(UniCB uniCB, RegValve regV, double posLoPct, double posHiPct, int timeout)
|
||||
{
|
||||
if (uniCB == null) throw new ArgumentNullException("ctrlBoard");
|
||||
this.uniCB = uniCB;
|
||||
if (this.uniCB == null) throw new ArgumentNullException("ctrlBoard");
|
||||
|
||||
this.regValve = regV as RegValve;
|
||||
if (regV == null) throw new ArgumentNullException("regValve is null or not Elde");
|
||||
this.regV = regV;
|
||||
if (this.regV == null) throw new ArgumentNullException("regValve is null or not Elde");
|
||||
|
||||
this.posLoPct = posLoPct;
|
||||
this.posHiPct = posHiPct;
|
||||
@@ -79,7 +79,7 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
{
|
||||
positionReached = false;
|
||||
expireTime = StateMachine.Time + timeout;
|
||||
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regValve.Idx1, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
|
||||
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regV.Idx1, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
|
||||
opState = OpState.MoveToPosition;
|
||||
}
|
||||
|
||||
@@ -98,15 +98,15 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
return Event.OpArgumentError;
|
||||
}
|
||||
|
||||
uniCB.RegVlvMoveToPos(false, regValve.Idx1, posLoPct, posHiPct);
|
||||
regV.MoveToPosition(false, posLoPct);
|
||||
opState = OpState.CheckState;
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
if (positionReached) return Event.PositionReached;
|
||||
|
||||
double positionPct = regValve.Position;
|
||||
log.WarnFormat("Run(): RV#={0}, actPos={1}%", regValve.Idx1, positionPct.ToString("F1"));
|
||||
double positionPct = regV.Position;
|
||||
log.WarnFormat("Run(): RV#={0}, actPos={1}%", regV.Idx1, positionPct.ToString("F1"));
|
||||
|
||||
if (opState == OpState.CheckState)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ namespace TBF.Rig.Uni.RegValveAnalog
|
||||
positionReached = true;
|
||||
return Event.PositionReached;
|
||||
}
|
||||
else if (regValve.Idx1 < 6
|
||||
else if (regV.Idx1 < 6
|
||||
/// && uniCB.RegulValveState(regValve.Idx1) != RegulValveState.DacValueRegul // TODO: Reimplement
|
||||
)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user