87 lines
3.0 KiB
C#
87 lines
3.0 KiB
C#
///
|
|
/// Copyright (c) 2017-2021 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using SchematicDrawing;
|
|
using TBF.Boxes;
|
|
using TBF.Rig.Sequences;
|
|
|
|
namespace TBF.Rig.Dummy.FlowMeter
|
|
{
|
|
public class FlowMeter : ComponentBase, GenericDevices.IFlowMeter, IDrawingItCmpntWithMeasuredVal
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter));
|
|
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
|
|
|
readonly FlowMeterCfg flowMeterCfg;
|
|
public double NominalFlow { get { return flowMeterCfg.NominalFlow; } }
|
|
public double NominalFreq { get { return 2000; } }
|
|
public double LtrPerPulse { get { return flowMeterCfg.NominalFlow / 7200.0f; } }
|
|
|
|
public IDrawingItem DrawingItem { get { return flowMeterCfg as IDrawingItem; } }
|
|
|
|
public double LtrPerPulseCorrected(double flow, float temperature)
|
|
{
|
|
return flow;
|
|
}
|
|
|
|
public int Idx1 { get { return 1; } }
|
|
|
|
public bool MsrmntAvailable { get { return ProcessData.Devices != null && ProcessData.Devices.FlowMeter == this && ReadFlow() > 0; } }
|
|
public string AltString { get { return string.Empty; } }
|
|
public double MeasuredVal
|
|
{
|
|
get { return (ProcessData.Devices != null && ProcessData.Devices.FlowMeter == this) ? ReadFlow() : 0; }
|
|
set { }
|
|
}
|
|
|
|
public string MsrdFormat { get { return flowMeterCfg.MsrdFormat; } }
|
|
public Common.Unit MsrdUnit { get { return flowMeterCfg.MsrdUnit; } }
|
|
public double MsrdValLimLo { get { return flowMeterCfg.MsrdValLimLo; } set { flowMeterCfg.MsrdValLimLo = value; } }
|
|
public double MsrdValLimHi { get { return flowMeterCfg.MsrdValLimHi; } set { flowMeterCfg.MsrdValLimHi = value; } }
|
|
|
|
|
|
public FlowMeter() { }
|
|
|
|
public FlowMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
flowMeterCfg = cfg as FlowMeterCfg;
|
|
log.Warn(this.ToString());
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
MsrdValLimLo = 0;
|
|
MsrdValLimHi = NominalFlow;
|
|
}
|
|
|
|
|
|
public double ReadFlow() { return ProcessData.FlowFromMassIncrease; }
|
|
public double ReadFrequency() { return ProcessData.FlowFromMassIncrease * 2000.0 / (double)NominalFlow; }
|
|
|
|
/// <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 DoubleBox 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 DoubleBox flow, Event flowDone)
|
|
{
|
|
return new ReadFlowOp(this, ref flow, flowDone);
|
|
}
|
|
}
|
|
}
|