- all components, componentCfg-s and parameter providers use base classes - less boilerplate code, simpler access to test/procedure parameters from code - CreateTestParams(test), CreateProcedureParams(procedure) methods added - TestBenchSim class is made static, it is not inheritted by any device anymore
77 lines
2.9 KiB
C#
77 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Elde.FlowMeterTwins
|
|
{
|
|
public class FlowMeter : ComponentBase, GenericDevices.IFlowMeter
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter));
|
|
public override string ToString() { return string.Format("FlowMeterTwins({0})", Cfg.ToString(1)); }
|
|
|
|
readonly FlowMeterCfg flowMeterCfg;
|
|
|
|
public int Idx1 { get { return 0; } }
|
|
|
|
public readonly ControlBoardDev ControlBoard;
|
|
public readonly TBF.BenchControl.Elde.FlowMeter.FlowMeter FlowMeter1;
|
|
public readonly TBF.BenchControl.Elde.FlowMeter.FlowMeter FlowMeter2;
|
|
|
|
public float NominalFlow { get { return flowMeterCfg.NominalFlow; } }
|
|
|
|
/// The nominal flowed of a pair of flow meters is reached at 4000Hz
|
|
public float LtrPerPulse { get { return flowMeterCfg.NominalFlow / 14400.0f; } }
|
|
|
|
/// Calculates the average of values of two flowmeters. Assumes the flow is divided evenly.
|
|
public float LtrPerPulseCorrected(float flow)
|
|
{
|
|
float flow2 = flow / 2;
|
|
return (FlowMeter1.LtrPerPulseCorrected(flow2) + FlowMeter2.LtrPerPulseCorrected(flow2)) / 2;
|
|
}
|
|
|
|
|
|
public FlowMeter(FlowMeterCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
flowMeterCfg = cfg;
|
|
|
|
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
|
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
|
|
|
FlowMeter1 = (TBF.BenchControl.Elde.FlowMeter.FlowMeter)TbfComponents.FindComponent(flowMeterCfg.FlowMeter1, components);
|
|
if (FlowMeter1 == null) throw new Exception("Cannot find FlowMeter1 component");
|
|
|
|
FlowMeter2 = (TBF.BenchControl.Elde.FlowMeter.FlowMeter)TbfComponents.FindComponent(flowMeterCfg.FlowMeter2, components);
|
|
if (FlowMeter2 == null) throw new Exception("Cannot find FlowMeter2 component");
|
|
|
|
ControlBoard.EtCalib[Idx1] = flowMeterCfg.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);
|
|
}
|
|
}
|
|
}
|