Files
tbf/TBF/Rig/BuiltIn/Pump/Pump.cs
T

54 lines
1.9 KiB
C#

///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using Dirichlet.Numerics;
using log4net;
using TBF.Rig.ControlBoard;
namespace TBF.Rig.BuiltIn.Pump
{
public class Pump : ComponentBase, GenericDevices.IPump, GenericDevices.IValve, SchematicDrawing.IDrawingItCmpnt
{
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly PumpCfg pumpCfg;
public SchematicDrawing.IDrawingItem DrawingItem { get { return pumpCfg as SchematicDrawing.IDrawingItem; } }
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; } }
public bool State { get { return (controlBoard.Route & Mask) != 0; } }
public double Power { get { return State ? 100.0 : 0; } }
readonly IControlBoard controlBoard;
readonly int bitPosition; /// 0 .. 127
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public Pump() { }
public Pump(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
pumpCfg = cfg as PumpCfg;
controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as IControlBoard;
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
bitPosition = pumpCfg.BitNr;
Mask = (((UInt128)1) << pumpCfg.BitNr);
log.Warn(this.ToString());
}
public override void Initialize() { }
}
}