Positions of reg. valves are defined in output path

This commit is contained in:
Milan Hanajik
2020-12-02 15:45:59 +01:00
parent d4ac2453b8
commit 6da5bd92ec
7 changed files with 220 additions and 83 deletions
+15 -2
View File
@@ -34,6 +34,7 @@ namespace TBF.UI.Bench.Paths
public IList<BenchControl.Generic.IComponent> TbfComponents;
public IList<IValve> Valves;
public IList<IRegulValve> FeedingRegulValves;
public IList<IRegulValve> OutputRegulValves;
public ISession Session; /// One common DB session passed also to the controls inside tab pages
public IList<Procedure> Procedures;
public IList<Test> Tests;
@@ -78,12 +79,24 @@ namespace TBF.UI.Bench.Paths
/// Find all feeding regulation valves
FeedingRegulValves = new List<IRegulValve>();
OutputRegulValves = new List<IRegulValve>();
foreach (var cmpnt in TbfComponents)
{
IRegulValve regValve = cmpnt as IRegulValve;
if (regValve != null && (regValve.Category == TBF.BenchControl.ValveCategory.Feeding || regValve.Category == TBF.BenchControl.ValveCategory.All))
if (regValve != null)
{
FeedingRegulValves.Add(regValve);
switch (regValve.Category)
{
case TBF.BenchControl.ValveCategory.Feeding:
FeedingRegulValves.Add(regValve);
break;
case TBF.BenchControl.ValveCategory.Output:
OutputRegulValves.Add(regValve);
break;
case TBF.BenchControl.ValveCategory.All:
OutputRegulValves.Add(regValve);
break;
}
}
}
+80 -12
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2017 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -12,6 +12,7 @@ using TBF.BenchControl;
using TBF.BenchControl.GenericDevices;
using TBF.Resources;
using TBF.UI.Shared;
using System.Text;
namespace TBF.UI.Bench.Paths
{
@@ -45,6 +46,9 @@ namespace TBF.UI.Bench.Paths
}
readonly int fixedColumnsCount = (int)Column.FixedColumnsCount;
int valvescount;
int regulValvesCount;
PathsDlg parent;
Control parentControl;
Control[] editors;
@@ -90,15 +94,26 @@ namespace TBF.UI.Bench.Paths
Columns.Add(string.Format("{0} 3", Strings.StartValve), (ls.OutputColumnCount > 14) ? ls.OutputColumnWidths[14] : 80 * parent.Dpi / Constants.Dpi100pct);
Columns.Add(string.Format("Inv.SV3"), (ls.OutputColumnCount > 15) ? ls.OutputColumnWidths[15] : 80 * parent.Dpi / Constants.Dpi100pct);
Columns.Add(string.Format("Lag SV3"), (ls.OutputColumnCount > 16) ? ls.OutputColumnWidths[16] : 80 * parent.Dpi / Constants.Dpi100pct);
valvescount = 0;
regulValvesCount = 0;
int clmn = (int)Column.FixedColumnsCount;
///
foreach (var vlv in parent.Valves)
{
if (vlv.Category == ValveCategory.All || vlv.Category == ValveCategory.Output)
{
Columns.Add(vlv.Cfg.Name, (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
clmn++;
valvescount++;
}
}
foreach (var rvlv in parent.OutputRegulValves)
{
Columns.Add(rvlv.Cfg.Name + " [%]", (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 55 * parent.Dpi / Constants.Dpi100pct);
clmn++;
regulValvesCount++;
}
/// Prepare fixed columns combo boxes
ComboBox flowMeterComboBox = new ComboBox();
@@ -143,7 +158,7 @@ namespace TBF.UI.Bench.Paths
}
}
editors = new Control[fixedColumnsCount + 64];
editors = new Control[fixedColumnsCount + valvescount + regulValvesCount];
///
editors[(int)Column.Name] = new TextBox(); /// Name
editors[(int)Column.Qfrom] = new TextBox(); /// Q_from
@@ -163,7 +178,7 @@ namespace TBF.UI.Bench.Paths
editors[(int)Column.InvertSV3] = invertSV3ComboBox;
editors[(int)Column.LagSV3] = lagSV3TextBox;
/// Prepare valve combo-boxes (max. 64 valves)
for (int i = 0; i < 64; i++)
for (int i = 0; i < valvescount; i++)
{
ComboBox cb = new ComboBox();
cb.Items.Add("---");
@@ -171,7 +186,19 @@ namespace TBF.UI.Bench.Paths
cb.Items.Add(Strings.close);
editors[fixedColumnsCount + i] = cb;
}
///
/// Prepare regul. valve combo-boxes
for (int i = 0; i < regulValvesCount; i++)
{
ComboBox cb = new ComboBox();
cb.Items.Add("---");
cb.Items.Add("0");
cb.Items.Add("25");
cb.Items.Add("50");
cb.Items.Add("75");
cb.Items.Add("100");
editors[fixedColumnsCount + valvescount + i] = cb;
}
///
for (int i = 0; i < editors.Length; i++)
{
editors[i].Visible = false;
@@ -221,10 +248,14 @@ namespace TBF.UI.Bench.Paths
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
{
if (e.SubItem >= fixedColumnsCount)
if (e.SubItem >= fixedColumnsCount && e.SubItem < fixedColumnsCount + valvescount)
{
e.Item.SubItems[e.SubItem].BackColor = e.DisplayText == Strings.open ? Color.LightGray : Color.White;
}
else if (e.SubItem >= fixedColumnsCount + valvescount)
{
e.Item.SubItems[e.SubItem].BackColor = (e.DisplayText != "0" && e.DisplayText != "---") ? Color.LightGray : Color.White;
}
}
public override void DrawOne(object myItem)
@@ -256,26 +287,43 @@ namespace TBF.UI.Bench.Paths
foreach (var valve in parent.Valves)
{
int subItemNr = lvi.SubItems.Count;
if (valve.Category == ValveCategory.All || valve.Category == ValveCategory.Output)
{
if (path.ValvesOpen != null && path.ValvesOpen.Contains(valve))
{
lvi.SubItems.Add(Strings.open);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Color.LightGray;
lvi.SubItems[subItemNr].BackColor = Color.LightGray;
}
else if (path.ValvesClose != null && path.ValvesClose.Contains(valve))
{
lvi.SubItems.Add(Strings.close);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Color.White;
lvi.SubItems[subItemNr].BackColor = Color.White;
}
else
{
lvi.SubItems.Add("---");
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Color.White;
lvi.SubItems[subItemNr].BackColor = Color.White;
}
}
}
for (int i = 0; i < parent.OutputRegulValves.Count; i++ )
{
int subItemNr = lvi.SubItems.Count;
if (i < path.RegulValvesPct.Length && 0 <= path.RegulValvesPct[i] && path.RegulValvesPct[i] <= 100)
{
float rvPos = path.RegulValvesPct[i];
lvi.SubItems.Add(rvPos.ToString());
lvi.SubItems[subItemNr].BackColor = (rvPos == 0) ? Color.White : Color.LightGray;
}
else
{
lvi.SubItems.Add("---");
lvi.SubItems[subItemNr].BackColor = Color.White;
}
}
lvi.Tag = entity;
Items.Add(lvi);
@@ -322,26 +370,46 @@ namespace TBF.UI.Bench.Paths
string valvesOpen = string.Empty;
string valvesClose = string.Empty;
int k = 0;
for (int j = 0; j < parent.Valves.Count; j++)
foreach (var valve in parent.Valves)
{
if (parent.Valves[j].Category == ValveCategory.All || parent.Valves[j].Category == ValveCategory.Output)
if (valve.Category == ValveCategory.All || valve.Category == ValveCategory.Output)
{
string text = lvi.SubItems[fixedColumnsCount + k].Text;
if (text.Equals(Strings.open))
{
if (valvesOpen != string.Empty) valvesOpen += ";";
valvesOpen += parent.Valves[j].Cfg.Name;
valvesOpen += valve.Cfg.Name;
}
if (text.Equals(Strings.close))
{
if (valvesClose != string.Empty) valvesClose += ";";
valvesClose += parent.Valves[j].Cfg.Name;
valvesClose += valve.Cfg.Name;
}
k++;
}
}
entity.ValvesOpen = valvesOpen;
entity.ValvesClose = valvesClose;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < regulValvesCount; i++)
{
float pct;
string text = lvi.SubItems[fixedColumnsCount + valvescount + i].Text;
if (Utils.TryParseUFloat(text, out pct) && pct >= 0 && pct <= 100.0f)
{
sb.Append(pct.ToString());
}
else
{
sb.Append("-1");
}
if (i != regulValvesCount - 1)
{
sb.Append(";");
}
}
entity.RegulValvesPct = sb.ToString();
}
public void AddOne()