Initial commit almost identical to SVN-repo rev.340
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
public class RegulValve : IComponent, GenericDevices.IRegulValve
|
||||
{
|
||||
/// <summary>
|
||||
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
|
||||
/// Warn: Start measurement when busy is true
|
||||
/// </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(RegulValve));
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("RegulationValve({0},{1})", Name, Position);
|
||||
}
|
||||
|
||||
public static void ResetStaticProperties() { }
|
||||
|
||||
public RegulValveCfg RegulValveCfg;
|
||||
public Generic.IComponentCfg Cfg { get { return RegulValveCfg; } }
|
||||
|
||||
public string Name { get { return Cfg.Name; } }
|
||||
|
||||
IDictionary<float, float> dict;
|
||||
public IDictionary<float, float> Dict { get { return dict; } }
|
||||
|
||||
readonly ControlBoardDev controlBoard;
|
||||
|
||||
public readonly int Position; /// 0..7
|
||||
public readonly int DacValueClosed; /// 0..1023
|
||||
public readonly int DacValueOpen; /// 0..1023
|
||||
|
||||
public RegulValve(RegulValveCfg cfg, IList<Generic.IComponent> components)
|
||||
{
|
||||
if (cfg == null) throw new ArgumentNullException("cfg");
|
||||
this.RegulValveCfg = cfg;
|
||||
|
||||
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
this.Position = cfg.Position;
|
||||
this.DacValueClosed = cfg.DacValueClosed;
|
||||
this.DacValueOpen = cfg.DacValueOpen;
|
||||
this.dict = new Dictionary<float, float>();
|
||||
|
||||
this.controlBoard.RegValveCalib[Position - 1, 0] = (uint)DacValueClosed;
|
||||
this.controlBoard.RegValveCalib[Position - 1, 1] = (uint)DacValueOpen;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation to set the water flow within tolerances
|
||||
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
|
||||
/// </summary>
|
||||
/// <param name="flowMeter">Flowmeter component</param>
|
||||
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
|
||||
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, FloatBox measuredFlow, int timeout)
|
||||
{
|
||||
return new SetFlowOp(controlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation to set the water flow within tolerances. Leave the measurement running.
|
||||
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
|
||||
/// </summary>
|
||||
/// <param name="flowMeter">Flowmeter component</param>
|
||||
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
|
||||
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
|
||||
/// <param name="measuredFlow">Measured flow [m3/h]</param>
|
||||
/// <param name="timeout">Timeout in [s]</param>
|
||||
/// <returns>SetFlowOp instance</returns>
|
||||
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, FloatBox measuredFlow, int timeout)
|
||||
{
|
||||
return new SetFlowOp(controlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation to set the regulation valve to a required position
|
||||
/// Events: Event.None
|
||||
/// </summary>
|
||||
/// <param name="flowLo">Lower limit of the required valve position in [%]</param>
|
||||
/// <param name="flowLo">Higher limit of the required valve position in [%]</param>
|
||||
/// <returns>SetPositionOp instance</returns>
|
||||
public IOperation SetRegulValvePositionOp(float pctLo, float pctHi, int timeoutMs)
|
||||
{
|
||||
return new SetRegulValvePositionOp(controlBoard, this, pctLo, pctHi, timeoutMs);
|
||||
}
|
||||
|
||||
public IOperation ChangeRegulValvePositionOp(float timePulseSec)
|
||||
{
|
||||
return new ChangeRegulValvePositionOp(controlBoard, this, timePulseSec);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user