PumpTandem component added (to be completed), fixes in component config edit controls
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.Elde.PumpTandem
|
||||
{
|
||||
public class Pump : ComponentBase, GenericDevices.IPumpFM, IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
|
||||
public override string ToString() { return string.Format("PumpTandem({0})", Cfg.ToString(1)); }
|
||||
|
||||
readonly PumpCfg pumpCfg;
|
||||
|
||||
readonly GenericDevices.IPump pump1;
|
||||
readonly GenericDevices.IPump pump2;
|
||||
|
||||
public bool State { get { return pump1.State || pump2.State; } }
|
||||
public int Delay { get { return Math.Max(pump1.Delay, pump2.Delay); } }
|
||||
public float Power { get { return pumpCfg.TestParams.Power; } }
|
||||
|
||||
public Pump(PumpCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
pumpCfg = cfg;
|
||||
|
||||
pump1 = (GenericDevices.IPump)TbfComponents.FindComponent(cfg.Pump1, components);
|
||||
if (pump1 == null) throw new Exception("Cannot find component Pump 1");
|
||||
|
||||
pump2 = (GenericDevices.IPump)TbfComponents.FindComponent(cfg.Pump2, components);
|
||||
if (pump2 == null) throw new Exception("Cannot find component Pump 2");
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
public void TurnOnDfltPower()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void TurnOn(float powerArg)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void TurnOff()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The currently running operation.
|
||||
/// </summary>
|
||||
public enum CurrentOp
|
||||
{
|
||||
None,
|
||||
TurnOnDfltPower,
|
||||
TurnOn,
|
||||
TurnOff,
|
||||
}
|
||||
///
|
||||
CurrentOp currentOp;
|
||||
|
||||
float powerForOp;
|
||||
|
||||
/// <summary>
|
||||
/// Turn the pump frequency inverter on.
|
||||
/// </summary>
|
||||
public IOperation TurnOnDfltPowerOp()
|
||||
{
|
||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||
currentOp = CurrentOp.TurnOnDfltPower;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turn the pump frequency inverter on.
|
||||
/// </summary>
|
||||
public IOperation TurnOnOp(float powerArg)
|
||||
{
|
||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||
currentOp = CurrentOp.TurnOn;
|
||||
powerForOp = powerArg;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turn the pump frequency inverter on.
|
||||
/// </summary>
|
||||
public IOperation TurnOffOp()
|
||||
{
|
||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||
currentOp = CurrentOp.TurnOff;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>Start the operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
switch (currentOp)
|
||||
{
|
||||
case CurrentOp.TurnOnDfltPower:
|
||||
TurnOnDfltPower();
|
||||
return;
|
||||
case CurrentOp.TurnOn:
|
||||
TurnOn(powerForOp);
|
||||
return;
|
||||
case CurrentOp.TurnOff:
|
||||
default:
|
||||
TurnOff();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run the operation</summary>
|
||||
public Event Run()
|
||||
{
|
||||
return Event.TurnPumpOnOffDone;
|
||||
}
|
||||
|
||||
/// <summary>Stop the operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
currentOp = CurrentOp.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user