tbf/TestBenchFramework/BenchControl/Elde/FlowMeter/FlowMeter.cs
2014-07-28 09:56:40 +02:00

74 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using log4net;
namespace TBF.BenchControl.Elde.FlowMeter
{
public class FlowMeter : Generic.IComponent, GenericDevices.IFlowMeter
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter));
public override string ToString()
{
return string.Format("FlowMeter({0},{1})", Name, Position);
}
public static void ResetStaticProperties() { }
FlowMeterCfg flowMeterCfg;
public Generic.IComponentCfg Cfg { get { return flowMeterCfg; } }
public string Name { get { return flowMeterCfg.Name; } }
public IList<Entities.MeasurementCorrection> Corrections { get { return flowMeterCfg.Corrections; } }
public readonly ControlBoardDev ControlBoard;
public readonly int Position; /// 1..4
readonly float nominalFlow;
public float NominalFlow { get { return nominalFlow; } }
public FlowMeter(FlowMeterCfg cfg, IList<Generic.IComponent> components)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.flowMeterCfg = cfg;
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
Position = cfg.Position;
nominalFlow = cfg.NominalFlow;
ControlBoard.EtCalib[Position] = NominalFlow;
/// Prepare data for SendCalibData() control board component method
log.Debug(this.ToString());
}
/// <summary>
/// Events: FlowDone, Error
/// </summary>
/// <param name="flow">Reference to a variable for the flow in Bar</param>
/// <returns>ReadFlowOp instance reference casted to IOperaton</returns>
public IOperation ReadFlowOp(ref FloatBox flow)
{
return new ReadFlowOp(this, ref flow);
}
/// <summary>
/// Events: flowDone, Error
/// </summary>
/// <param name="flow">Reference to a variable for the flow in Bar</param>
/// <param name="flowDone">Event returned when measurement done</param>
/// <returns>ReadFlowOp instance reference casted to IOperaton</returns>
public IOperation ReadFlowOp(ref FloatBox flow, Event flowDone)
{
return new ReadFlowOp(this, ref flow, flowDone);
}
}
}