tbf/TBF/BenchControl/BuiltIn/Valve/ValveCfg.cs

95 lines
3.5 KiB
C#

///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using System.Xml.Serialization;
using SchematicDrawing;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BuiltIn.Valve
{
public class ValveCfg : ComponentCfgBase, IChildComponentCfg, IRouteBasedDrawingItem
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ValveCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new ValveCfgCtrl(); }
///
/// Serialized parameters
///
public int BitNr { get; set; } /// Bit-position
public bool Inverted { get; set; } /// When true the valve function is inverted: 0 = open, 1 = closed
public ValveCategory Category; /// None, Feeding, Bench or Output
public int OpenCloseTime; /// Delay for SetValvesOp operations
///
public string CoupledToName; /// Name of the coupled valve or null
public bool InvertCouple; /// The coupled valve has inverted position
public int LagOpening; /// Delay (referred to the master valve) when opening this valve in [s]
public int LagClosing; /// Delay (referred to the master valve) when closing this valve in [s]
/// Negative values of delays mean an earlier function of the coupled valve.
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
[XmlIgnore]
public IList<GEdge> EdgesToSet { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
ValveCfg()
{
GNodes = new List<GNode>();
EdgesToSet = new List<GEdge>();
}
public ValveCfg(IComponentFactory factory)
: this()
{
Shape = Shape.Valve;
Sz = Sz.M;
Factory = factory;
Name = "V";
ParentName = "UniCB";
BitNr = 0;
Category = ValveCategory.None;
OpenCloseTime = 1;
Inverted = false;
CoupledToName = string.Empty;
InvertCouple = false;
LagOpening = 0;
LagClosing = 0;
}
public string ToString(int i)
{
return string.Format("{0}({1}) {2}[{3},{4}] bit={5} inv={6} delay={7}s cat={8} coupled to={9} inv.couple={10} lagO={11}s lagC={12}s",
Name,
string.IsNullOrEmpty(ParentName) ? "-" : ParentName,
Shape,
X,
Y,
BitNr,
Inverted ? "yes" : "no",
OpenCloseTime,
Category,
string.IsNullOrEmpty(CoupledToName) ? "-" : CoupledToName,
InvertCouple ? "yes" : "no",
LagOpening,
LagClosing);
}
}
}