84 lines
2.6 KiB
C#
84 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Elde.RegisterReader
|
|
{
|
|
public class RegisterReader : ComponentBase, GenericDevices.IRegisterReader
|
|
{
|
|
/// <summary>
|
|
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
|
|
/// Warn: Start measurement when busy is true
|
|
/// </summary>
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(RegisterReader));
|
|
public override string ToString()
|
|
{
|
|
return string.Format("Register({0},{1})", Name, Position);
|
|
}
|
|
|
|
public static void ResetStaticProperties() { }
|
|
|
|
RegisterReaderCfg registerReaderCfg;
|
|
|
|
public float PulsesPerLtr
|
|
{
|
|
get
|
|
{
|
|
return (ProcedureParams is RRProcedureParams) ? (ProcedureParams as RRProcedureParams).PulsesPerLtr : 0;
|
|
}
|
|
}
|
|
|
|
public readonly ControlBoardDev ControlBoard;
|
|
|
|
public readonly int Position; /// 1 .. inf
|
|
|
|
public RegisterReader(RegisterReaderCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
if (cfg == null) throw new ArgumentNullException("cfg");
|
|
this.registerReaderCfg = cfg;
|
|
|
|
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
|
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
|
|
|
Position = cfg.Position;
|
|
|
|
/// Prepare data for SendCalibData() control board component method
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Events: Event.ReadRegisterDone, Event.Error
|
|
/// </summary>
|
|
/// <param name="pulses">Reference to a variable for the water meter pulses</param>
|
|
/// <returns>ReadWaterMeter instance reference casted to IOperaton</returns>
|
|
public IOperation ReadRegisterOp(ref IntBox pulses)
|
|
{
|
|
return new ReadRegisterOp(this, ref pulses);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Events: Event.ReadRegisterDone, Event.Error
|
|
/// </summary>
|
|
/// <param name="pulses">Reference to a variable for the water meter pulses</param>
|
|
/// <param name="pulses">Reference to a variable for the related reference flowmeter pulses</param>
|
|
/// <returns>Reference to operation object instance</returns>
|
|
public IOperation ReadRegisterOp(ref IntBox pulses, ref IntBox refPulses)
|
|
{
|
|
return new ReadRegisterOp(this, ref pulses, ref refPulses);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Events: ReadReferenceDone, Error
|
|
/// </summary>
|
|
/// <param name="pulses">Reference to a variable for the water meter pulses</param>
|
|
/// <returns>Reference to operation object instance</returns>
|
|
public IOperation ReadReferenceForRegisterOp(ref IntBox pulses, ref IntBox refPulses)
|
|
{
|
|
return new ReadReferenceForRegisterOp(this, ref pulses);
|
|
}
|
|
}
|
|
}
|