using System;
using System.Collections.Generic;
using log4net;
namespace TBF.BenchControl.Elde.Pump
{
public class Pump : Generic.IComponent, GenericDevices.IPump, GenericDevices.IValve
{
///
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
///
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
public override string ToString()
{
return string.Format("Pump(name={0}, bit={1})", Name, bitPosition);
}
public static void ResetStaticProperties() { }
private readonly PumpCfg pumpCfg;
public Generic.IComponentCfg Cfg { get { return pumpCfg; } }
public string Name { get { return pumpCfg.Name; } }
public GenericDevices.IValve CoupledTo { get { return null; } }
public bool Invert { get { return false; } }
public int LagOpening { get { return 0; } }
public int LagClosing { get { return 0; } }
readonly ControlBoardDev controlBoard;
readonly int bitPosition; /// 0 .. 63
public readonly ulong Mask; /// derived from bitPosition in the constructor
public Pump(PumpCfg cfg, IList components)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.pumpCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
this.bitPosition = cfg.BitPosition;
this.Mask = (((ulong)1) << bitPosition);
log.Debug(this.ToString());
}
public bool State
{
get { return (controlBoard.Route & Mask) != 0; }
}
}
}