tbf/TestBenchFramework/BenchControl/Elde/Pump/Pump.cs
Milan Hanajik 94de991bf6 Everything works OK after serious changes:
- 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
2015-01-02 12:51:27 +01:00

49 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using log4net;
namespace TBF.BenchControl.Elde.Pump
{
public class Pump : ComponentBase, GenericDevices.IPump, GenericDevices.IValve
{
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
public override string ToString() { return string.Format("Pump({0})", Cfg.ToString(1)); }
readonly PumpCfg pumpCfg;
public int Delay { get { return pumpCfg.Delay; } }
public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding
public GenericDevices.IValve CoupledTo { get { return null; } }
public bool InvertCouple { 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<Generic.IComponent> components)
: base(cfg)
{
pumpCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
bitPosition = pumpCfg.BitPosition;
Mask = (((ulong)1) << pumpCfg.BitPosition);
log.Debug(this.ToString());
}
public bool State
{
get { return (controlBoard.Route & Mask) != 0; }
}
}
}