2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2019-01-25 11:52:05 +00:00
|
|
|
|
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
2019-01-25 11:52:05 +00:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.IO;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
namespace Config.Entities
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
public class TransitionStep : IHasItemNr, IHasValves
|
|
|
|
|
|
{
|
|
|
|
|
|
public virtual int Id { get; protected set; }
|
2015-05-22 08:29:56 +00:00
|
|
|
|
public virtual int ItemNr { get; set; } /// Order of the preparation step
|
|
|
|
|
|
public virtual int Duration { get; set; } /// Duration in seconds
|
|
|
|
|
|
public virtual string Message { get; set; } /// Message
|
2017-02-11 21:27:18 +00:00
|
|
|
|
public virtual string EndCondition { get; set; } /// Condition when transition step is finished (next to the duration)
|
2015-05-22 08:29:56 +00:00
|
|
|
|
public virtual string ValvesOpen { get; set; } /// List of valves to be opened
|
|
|
|
|
|
public virtual string ValvesClose { get; set; } /// List of valves to be closed
|
|
|
|
|
|
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
|
|
|
|
|
|
public virtual string PumpWithFMPcts { get; set; } /// Power of FM controlled pumps in % separated by ';'
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
public virtual TransitionSequence TransitionSequence { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// ------------- Additional stuff not mapped into the database -------------
|
|
|
|
|
|
|
|
|
|
|
|
public TransitionStep()
|
|
|
|
|
|
{
|
2017-02-11 21:27:18 +00:00
|
|
|
|
Duration = 5; /// sec.
|
|
|
|
|
|
EndCondition = "None";
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TransitionStep(int itemNr, TransitionSequence sequence)
|
|
|
|
|
|
: this()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemNr = itemNr;
|
|
|
|
|
|
TransitionSequence = sequence;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual TransitionStep Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
TransitionStep result = new TransitionStep(ItemNr, TransitionSequence);
|
|
|
|
|
|
result.Duration = Duration;
|
2015-01-11 08:06:54 +00:00
|
|
|
|
result.Message = Message;
|
2015-05-22 08:29:56 +00:00
|
|
|
|
result.EndCondition = EndCondition;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
result.ValvesOpen = ValvesOpen;
|
|
|
|
|
|
result.ValvesClose = ValvesClose;
|
|
|
|
|
|
result.RegulValvesPct = RegulValvesPct;
|
2014-09-07 15:01:30 +00:00
|
|
|
|
result.PumpWithFMPcts = PumpWithFMPcts;
|
|
|
|
|
|
return result;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual string ToString(string indent)
|
|
|
|
|
|
{
|
|
|
|
|
|
string result = "";
|
|
|
|
|
|
result += indent + "ItemNr = " + ItemNr.ToString() + ", ";
|
|
|
|
|
|
result += indent + "Duration = " + Duration.ToString() + ", ";
|
2015-01-11 08:06:54 +00:00
|
|
|
|
result += indent + "Message = " + Message + ", ";
|
2017-02-11 21:27:18 +00:00
|
|
|
|
result += indent + "EndCondition = " + EndCondition + ", ";
|
2016-02-07 21:27:32 +00:00
|
|
|
|
result += indent + "ValvesOpen = " + ValvesOpen + ", ";
|
|
|
|
|
|
result += indent + "ValvesClose = " + ValvesClose + ", ";
|
|
|
|
|
|
result += indent + "RegulValvesPct = " + RegulValvesPct + ", ";
|
|
|
|
|
|
result += indent + "PumpsWithFMPct = " + PumpWithFMPcts + Environment.NewLine;
|
2014-09-07 15:01:30 +00:00
|
|
|
|
return result;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2019-01-25 11:52:05 +00:00
|
|
|
|
|
|
|
|
|
|
public virtual void Export(StreamWriter output)
|
|
|
|
|
|
{
|
|
|
|
|
|
CultureInfo ci = CultureInfo.InvariantCulture;
|
|
|
|
|
|
|
|
|
|
|
|
output.WriteLine(ItemNr.ToString(ci));
|
|
|
|
|
|
output.WriteLine(Duration.ToString(ci));
|
|
|
|
|
|
output.WriteLine(Message);
|
|
|
|
|
|
output.WriteLine(EndCondition);
|
|
|
|
|
|
output.WriteLine(ValvesOpen);
|
|
|
|
|
|
output.WriteLine(ValvesClose);
|
|
|
|
|
|
output.WriteLine(RegulValvesPct);
|
|
|
|
|
|
output.WriteLine(PumpWithFMPcts);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static TransitionStep Import(StreamReader input, TransitionSequence newSequence)
|
|
|
|
|
|
{
|
|
|
|
|
|
string firstLine = input.ReadLine();
|
|
|
|
|
|
if (string.IsNullOrEmpty(firstLine))
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CultureInfo ci = CultureInfo.InvariantCulture;
|
|
|
|
|
|
int itemNr = int.Parse(firstLine, ci);
|
|
|
|
|
|
TransitionStep tst = new TransitionStep(itemNr, newSequence);
|
|
|
|
|
|
|
|
|
|
|
|
tst.Duration = int.Parse(input.ReadLine(), ci);
|
|
|
|
|
|
tst.Message = input.ReadLine();
|
|
|
|
|
|
tst.EndCondition = input.ReadLine();
|
|
|
|
|
|
tst.ValvesOpen = input.ReadLine();
|
|
|
|
|
|
tst.ValvesClose = input.ReadLine();
|
|
|
|
|
|
tst.RegulValvesPct = input.ReadLine();
|
|
|
|
|
|
tst.PumpWithFMPcts = input.ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
return tst;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual string Compare(StreamReader inp)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Text.StringBuilder diff = new System.Text.StringBuilder();
|
|
|
|
|
|
string fmt = string.Format("Step {0} : ", ItemNr) + "{0} = {1}\r\n (in the file {2})\r\n";
|
|
|
|
|
|
string ln;
|
|
|
|
|
|
CultureInfo ci = CultureInfo.InvariantCulture;
|
|
|
|
|
|
|
|
|
|
|
|
string firstLine = inp.ReadLine();
|
|
|
|
|
|
if (string.IsNullOrEmpty(firstLine)) return string.Format("TransitionStep {0} is missing in the compared file\r\n", ItemNr);
|
|
|
|
|
|
|
|
|
|
|
|
if (ItemNr.ToString() != firstLine) { diff.AppendFormat(fmt, "ItemNr", ItemNr, firstLine); };
|
|
|
|
|
|
ln = inp.ReadLine(); if (ln != Duration.ToString(ci)) { diff.AppendFormat(fmt, "Duration", Duration.ToString(ci), ln); };
|
|
|
|
|
|
ln = inp.ReadLine(); if (ln != Message) { diff.AppendFormat(fmt, "Message", Message, ln); };
|
|
|
|
|
|
ln = inp.ReadLine(); if (ln != EndCondition) { diff.AppendFormat(fmt, "EndCondition", EndCondition, ln); };
|
|
|
|
|
|
ln = inp.ReadLine(); if (ln != ValvesOpen) { diff.AppendFormat(fmt, "ValvesOpen", ValvesOpen, ln); };
|
|
|
|
|
|
ln = inp.ReadLine(); if (ln != ValvesClose) { diff.AppendFormat(fmt, "ValvesClose", ValvesClose, ln); };
|
|
|
|
|
|
ln = inp.ReadLine(); if (ln != RegulValvesPct) { diff.AppendFormat(fmt, "RegulValvesPct", RegulValvesPct, ln); };
|
|
|
|
|
|
ln = inp.ReadLine(); if (ln != PumpWithFMPcts) { diff.AppendFormat(fmt, "PumpWithFMPcts", PumpWithFMPcts, ln); };
|
|
|
|
|
|
|
|
|
|
|
|
return diff.ToString();
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|