PumpTandem component added (to be completed), fixes in component config edit controls

This commit is contained in:
Milan Hanajik
2015-01-11 05:06:18 +01:00
parent 5a0c01688a
commit b79ae4b1aa
43 changed files with 748 additions and 79 deletions
@@ -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;
}
}
}