tbf/ResultsBrowser/Entities/FeedingPath.cs
2015-02-20 09:44:35 +01:00

70 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
namespace ResultsBrowser.Entities
{
public class FeedingPath : IHasItemNr, IHasValves
{
public virtual int Id { get; protected set; }
public virtual int ItemNr { get; set; }
public virtual string Name { get; set; }
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
public virtual float Qto { get; set; } /// Water flow in [m3/h]
public virtual string Pump { get; set; }
/// Valves
public virtual string ValvesOpen { get; set; }
public virtual string ValvesClose { get; set; }
/// ------------- Additional stuff not mapped into the database -------------
public FeedingPath()
{
}
public FeedingPath(string name, int itemNr)
: this()
{
Name = name;
ItemNr = itemNr;
}
public FeedingPath(BenchControl.FeedingPath path)
: this(path.Name, path.ItemNr)
{
Qfrom = path.Qfrom;
Qto = path.Qto;
Pump = (path.Pump != null) ? path.Pump.Cfg.Name : null;
string vOpen = string.Empty;
foreach (var valve in path.ValvesOpen)
{
if (vOpen != string.Empty) vOpen += ";";
vOpen += valve.Cfg.Name;
}
ValvesOpen = vOpen;
string vClose = string.Empty;
foreach (var valve in path.ValvesClose)
{
if (vClose != string.Empty) vClose += ";";
vClose += valve.Cfg.Name;
}
ValvesClose = vClose;
}
public virtual FeedingPath Clone(string name, int itemNr)
{
FeedingPath result = new FeedingPath(name, itemNr);
result.Qfrom = Qfrom;
result.Qto = Qto;
result.Pump = Pump;
result.ValvesOpen = ValvesOpen;
result.ValvesClose = ValvesClose;
return result;
}
}
}