TBF.UI.Bench.Paths controls support imperial units for flow.
This commit is contained in:
parent
a70491d236
commit
1b14954a6d
@ -1,8 +1,9 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -14,6 +15,7 @@ namespace Config.Entities
|
||||
public virtual string OriName { get; set; } /// Not mapped to database
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
|
||||
public virtual string Selector { get; set; }
|
||||
public virtual string TempMtrUp { get; set; }
|
||||
public virtual string TempMtrDown { get; set; }
|
||||
@ -26,6 +28,9 @@ namespace Config.Entities
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
public virtual bool QfromTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QtoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public BenchPath()
|
||||
@ -47,6 +52,7 @@ namespace Config.Entities
|
||||
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.FlowUnit = FlowUnit;
|
||||
result.Selector = Selector;
|
||||
result.TempMtrUp = TempMtrUp;
|
||||
result.TempMtrDown = TempMtrDown;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -14,6 +15,7 @@ namespace Config.Entities
|
||||
public virtual string OriName { get; set; } /// Not mapped to database
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
|
||||
public virtual string Selector { get; set; }
|
||||
public virtual string Pump { get; set; }
|
||||
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
|
||||
@ -22,6 +24,9 @@ namespace Config.Entities
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
public virtual bool QfromTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QtoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public FeedingPath()
|
||||
@ -43,13 +48,13 @@ namespace Config.Entities
|
||||
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.FlowUnit = FlowUnit;
|
||||
result.Selector = Selector;
|
||||
result.Pump = Pump;
|
||||
result.RegulValvesPct = RegulValvesPct;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -14,6 +15,7 @@ namespace Config.Entities
|
||||
public virtual string OriName { get; set; } /// Not mapped to database
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
|
||||
public virtual string Selector { get; set; }
|
||||
public virtual string RegulValve { get; set; }
|
||||
public virtual string FlowMeter { get; set; }
|
||||
@ -28,6 +30,9 @@ namespace Config.Entities
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
public virtual bool QfromTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QtoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public OutputPath()
|
||||
@ -50,6 +55,7 @@ namespace Config.Entities
|
||||
result.Name = Name;
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.FlowUnit = FlowUnit;
|
||||
result.Selector = Selector;
|
||||
result.RegulValve = RegulValve;
|
||||
result.FlowMeter = FlowMeter;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -7,7 +7,7 @@ using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
using Common;
|
||||
using Common.Forms;
|
||||
using TBF.Rig;
|
||||
using TBF.Rig.GenericDevices;
|
||||
@ -28,6 +28,7 @@ namespace TBF.UI.Bench.Paths
|
||||
Name,
|
||||
Qfrom,
|
||||
Qto,
|
||||
FlowUnit,
|
||||
Selector,
|
||||
Tup,
|
||||
Tdown,
|
||||
@ -59,7 +60,11 @@ namespace TBF.UI.Bench.Paths
|
||||
.OrderBy(x => x.ItemNr).Asc
|
||||
.List();
|
||||
|
||||
foreach (var path in MyItems) path.OriName = path.Name;
|
||||
foreach (var path in MyItems)
|
||||
{
|
||||
path.OriName = path.Name;
|
||||
path.FlowUnit = TBF.Rig.Sequences.ProcessData.FlowUnit;
|
||||
}
|
||||
|
||||
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||
SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
|
||||
@ -68,15 +73,16 @@ namespace TBF.UI.Bench.Paths
|
||||
/// ListViewEx columns
|
||||
TBF.LocalSettings ls = Program.LocalSettings;
|
||||
Columns.Add(Strings.Name, (ls.BenchColumnCount > 0) ? ls.BenchColumnWidths[0] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [m3/h]", Strings.Q_from), (ls.BenchColumnCount > 1) ? ls.BenchColumnWidths[1] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [m3/h]", Strings.Q_to), (ls.BenchColumnCount > 2) ? ls.BenchColumnWidths[2] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Selector", (ls.BenchColumnCount > 0) ? ls.BenchColumnWidths[0] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.T_in, (ls.BenchColumnCount > 3) ? ls.BenchColumnWidths[3] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.T_out, (ls.BenchColumnCount > 4) ? ls.BenchColumnWidths[4] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.P_in, (ls.BenchColumnCount > 5) ? ls.BenchColumnWidths[5] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.P_out, (ls.BenchColumnCount > 6) ? ls.BenchColumnWidths[6] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.P_delta, (ls.BenchColumnCount > 7) ? ls.BenchColumnWidths[7] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.StopBFValve_chdr, (ls.BenchColumnCount > 8) ? ls.BenchColumnWidths[8] : 70 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Q_from, (ls.BenchColumnCount > 1) ? ls.BenchColumnWidths[1] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Q_to, (ls.BenchColumnCount > 2) ? ls.BenchColumnWidths[2] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Unit", (ls.BenchColumnCount > 3) ? ls.BenchColumnWidths[3] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Selector", (ls.BenchColumnCount > 4) ? ls.BenchColumnWidths[4] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.T_in, (ls.BenchColumnCount > 5) ? ls.BenchColumnWidths[5] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.T_out, (ls.BenchColumnCount > 6) ? ls.BenchColumnWidths[6] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.P_in, (ls.BenchColumnCount > 7) ? ls.BenchColumnWidths[7] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.P_out, (ls.BenchColumnCount > 8) ? ls.BenchColumnWidths[8] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.P_delta, (ls.BenchColumnCount > 9) ? ls.BenchColumnWidths[9] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.StopBFValve_chdr, (ls.BenchColumnCount > 10) ? ls.BenchColumnWidths[10] : 70 * parent.Dpi / Constants.Dpi100pct);
|
||||
int clmn = (int)Column.FixedColumnsCount;
|
||||
foreach (var vlv in parent.Valves)
|
||||
{
|
||||
@ -87,6 +93,10 @@ namespace TBF.UI.Bench.Paths
|
||||
}
|
||||
}
|
||||
|
||||
/// Flow unit
|
||||
var flowUnitBox = new ComboBox();
|
||||
for (Unit u = 0; u < Unit.Count; u++) if (Units.IsFlow(u)) flowUnitBox.Items.Add(u.ToDescription());
|
||||
|
||||
/// Temperatures, pressures
|
||||
ComboBox tUpCBox = new ComboBox();
|
||||
ComboBox tDownCBox = new ComboBox();
|
||||
@ -119,6 +129,7 @@ namespace TBF.UI.Bench.Paths
|
||||
editors[(int)Column.Name] = new TextBox(); /// Name
|
||||
editors[(int)Column.Qfrom] = new TextBox(); /// Q_from
|
||||
editors[(int)Column.Qto] = new TextBox(); /// Q_to
|
||||
editors[(int)Column.FlowUnit] = flowUnitBox; /// Flow unit
|
||||
editors[(int)Column.Selector] = new TextBox(); /// Selector
|
||||
editors[(int)Column.Tup] = tUpCBox;
|
||||
editors[(int)Column.Tdown] = tDownCBox;
|
||||
@ -147,7 +158,8 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
|
||||
{
|
||||
if (!Unlocked || e.SubItem >= editors.Length) return;
|
||||
if (e.SubItem != (int)Column.FlowUnit && (!Unlocked || e.SubItem >= editors.Length)) return;
|
||||
|
||||
if ((e.Item.Tag is Config.Entities.IHasItemNr) &&
|
||||
((e.Item.Tag as Config.Entities.IHasItemNr).ItemNr < FixedRowsCount) &&
|
||||
(e.SubItem < fixedColumnsCount))
|
||||
@ -173,6 +185,8 @@ namespace TBF.UI.Bench.Paths
|
||||
{
|
||||
item.SubItems[columnNr].Text = value;
|
||||
item.SubItems[columnNr].BackColor = backColor;
|
||||
|
||||
if (columnNr == (int)Column.FlowUnit) UpdateFlow(item, Units.FromDescription(value));
|
||||
}
|
||||
else if (item == e.Item)
|
||||
{
|
||||
@ -185,10 +199,66 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
||||
{
|
||||
var entity = e.Item.Tag as Config.Entities.BenchPath;
|
||||
float fdummy;
|
||||
|
||||
if (e.SubItem >= fixedColumnsCount)
|
||||
{
|
||||
e.Item.SubItems[e.SubItem].BackColor = e.DisplayText == Strings.open ? Color.LightGray : Color.White;
|
||||
}
|
||||
else if (e.SubItem == (int)Column.Qfrom)
|
||||
{
|
||||
if (Utils.TryParseUFloat(e.DisplayText, out fdummy))
|
||||
{
|
||||
entity.QfromTextChngd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
else if (e.SubItem == (int)Column.Qto)
|
||||
{
|
||||
if (Utils.TryParseUFloat(e.DisplayText, out fdummy))
|
||||
{
|
||||
entity.QtoTextChngd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
else if (e.SubItem == (int)Column.FlowUnit)
|
||||
{
|
||||
Unit newUnit = Units.FromDescription(e.DisplayText);
|
||||
if (Units.IsFlow(newUnit))
|
||||
{
|
||||
UpdateFlow(e.Item, newUnit);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateFlow(ListViewItem item, Unit newUnit)
|
||||
{
|
||||
var entity = item.Tag as Config.Entities.BenchPath;
|
||||
if (entity == null || !Units.IsFlow(newUnit) || newUnit == entity.FlowUnit) return;
|
||||
Unit oriUnit = entity.FlowUnit;
|
||||
entity.FlowUnit = newUnit;
|
||||
|
||||
int ix = (int)Column.Qfrom;
|
||||
double flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text));
|
||||
item.SubItems[ix].Text = Units.ConvertTo(newUnit, entity.QfromTextChngd ? flowM3ph : entity.Qfrom).ToString();
|
||||
|
||||
ix = (int)Column.Qto;
|
||||
flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text));
|
||||
item.SubItems[ix].Text = Units.ConvertTo(newUnit, entity.QtoTextChngd ? flowM3ph : entity.Qto).ToString();
|
||||
}
|
||||
|
||||
public override void DrawOne(object myItem)
|
||||
@ -199,8 +269,9 @@ namespace TBF.UI.Bench.Paths
|
||||
ListViewItem lvi = new ListViewItem(entity.Name);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
|
||||
lvi.SubItems.Add(path.Qfrom.ToString());
|
||||
lvi.SubItems.Add(path.Qto.ToString());
|
||||
lvi.SubItems.Add(Units.ConvertTo(entity.FlowUnit, path.Qfrom).ToString()); /// Q_from
|
||||
lvi.SubItems.Add(Units.ConvertTo(entity.FlowUnit, path.Qto).ToString()); /// Q_to
|
||||
lvi.SubItems.Add(entity.FlowUnit.ToDescription());
|
||||
lvi.SubItems.Add(path.Selector);
|
||||
lvi.SubItems.Add(path.TempMtrUp != null ? path.TempMtrUp.Cfg.Name : "---");
|
||||
lvi.SubItems.Add(path.TempMtrDown != null ? path.TempMtrDown.Cfg.Name : "---");
|
||||
@ -244,11 +315,11 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
float Qfrom;
|
||||
bool allOk = Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qfrom].Text, out Qfrom);
|
||||
entity.Qfrom = Qfrom;
|
||||
entity.Qfrom = Units.ConvertFrom(entity.FlowUnit, Qfrom);
|
||||
|
||||
float Qto;
|
||||
allOk &= Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qto].Text, out Qto);
|
||||
entity.Qto = Qto;
|
||||
entity.Qto = Units.ConvertFrom(entity.FlowUnit, Qto);
|
||||
|
||||
entity.Selector = lvi.SubItems[(int)Column.Selector].Text;
|
||||
entity.TempMtrUp = lvi.SubItems[(int)Column.Tup].Text;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -7,8 +7,9 @@ using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using Common;
|
||||
using Common.Forms;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Resources;
|
||||
using TBF.UI.Shared;
|
||||
@ -27,6 +28,7 @@ namespace TBF.UI.Bench.Paths
|
||||
Name,
|
||||
Qfrom,
|
||||
Qto,
|
||||
FlowUnit,
|
||||
Selector,
|
||||
Pump,
|
||||
FixedColumnsCount,
|
||||
@ -55,7 +57,11 @@ namespace TBF.UI.Bench.Paths
|
||||
.OrderBy(x => x.ItemNr).Asc
|
||||
.List();
|
||||
|
||||
foreach (var path in MyItems) path.OriName = path.Name;
|
||||
foreach (var path in MyItems)
|
||||
{
|
||||
path.OriName = path.Name;
|
||||
path.FlowUnit = TBF.Rig.Sequences.ProcessData.FlowUnit;
|
||||
}
|
||||
|
||||
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||
SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
|
||||
@ -64,10 +70,11 @@ namespace TBF.UI.Bench.Paths
|
||||
/// ListViewEx columns
|
||||
TBF.LocalSettings ls = Program.LocalSettings;
|
||||
Columns.Add(Strings.Name, (ls.FeedingColumnCount > 0) ? ls.FeedingColumnWidths[0] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [m3/h]", Strings.Q_from), (ls.FeedingColumnCount > 1) ? ls.FeedingColumnWidths[1] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [m3/h]", Strings.Q_to), (ls.FeedingColumnCount > 2) ? ls.FeedingColumnWidths[2] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Selector", (ls.FeedingColumnCount > 0) ? ls.FeedingColumnWidths[0] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Pump, (ls.FeedingColumnCount > 3) ? ls.FeedingColumnWidths[3] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Q_from, (ls.FeedingColumnCount > 1) ? ls.FeedingColumnWidths[1] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Q_to, (ls.FeedingColumnCount > 2) ? ls.FeedingColumnWidths[2] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Unit", (ls.FeedingColumnCount > 3) ? ls.FeedingColumnWidths[3] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Selector", (ls.FeedingColumnCount > 4) ? ls.FeedingColumnWidths[4] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Pump, (ls.FeedingColumnCount > 5) ? ls.FeedingColumnWidths[5] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
int clmn = (int)Column.FixedColumnsCount;
|
||||
|
||||
foreach (var rv in parent.FeedingRegulValves)
|
||||
@ -87,6 +94,10 @@ namespace TBF.UI.Bench.Paths
|
||||
}
|
||||
valvesCount = clmn - (int)Column.FixedColumnsCount - regvCount;
|
||||
|
||||
/// Flow unit
|
||||
var flowUnitBox = new ComboBox();
|
||||
for (Unit u = 0; u < Unit.Count; u++) if (Units.IsFlow(u)) flowUnitBox.Items.Add(u.ToDescription());
|
||||
|
||||
/// Pump
|
||||
ComboBox pumpCBox = new ComboBox();
|
||||
pumpCBox.Items.Add("---");
|
||||
@ -100,6 +111,7 @@ namespace TBF.UI.Bench.Paths
|
||||
editors[(int)Column.Name] = new TextBox(); /// Name
|
||||
editors[(int)Column.Qfrom] = new TextBox(); /// Q_from
|
||||
editors[(int)Column.Qto] = new TextBox(); /// Q_to
|
||||
editors[(int)Column.FlowUnit] = flowUnitBox; /// Flow unit
|
||||
editors[(int)Column.Selector] = new TextBox(); /// Selector
|
||||
editors[(int)Column.Pump] = pumpCBox;
|
||||
for (int i = 0; i < regvCount; i++)
|
||||
@ -135,7 +147,8 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
|
||||
{
|
||||
if (!Unlocked || e.SubItem >= editors.Length) return;
|
||||
if (e.SubItem != (int)Column.FlowUnit && (!Unlocked || e.SubItem >= editors.Length)) return;
|
||||
|
||||
if ((e.Item.Tag is IHasItemNr) &&
|
||||
((e.Item.Tag as IHasItemNr).ItemNr < FixedRowsCount) &&
|
||||
(e.SubItem < fixedColumnsCount))
|
||||
@ -161,6 +174,8 @@ namespace TBF.UI.Bench.Paths
|
||||
{
|
||||
item.SubItems[columnNr].Text = value;
|
||||
item.SubItems[columnNr].BackColor = backColor;
|
||||
|
||||
if (columnNr == (int)Column.FlowUnit) UpdateFlow(item, Units.FromDescription(value));
|
||||
}
|
||||
else if (item == e.Item)
|
||||
{
|
||||
@ -173,10 +188,66 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
||||
{
|
||||
var entity = e.Item.Tag as Config.Entities.FeedingPath;
|
||||
float fdummy;
|
||||
|
||||
if (e.SubItem >= fixedColumnsCount + regvCount)
|
||||
{
|
||||
e.Item.SubItems[e.SubItem].BackColor = (e.DisplayText == Strings.open) ? Color.LightGray : Color.White;
|
||||
}
|
||||
else if (e.SubItem == (int)Column.Qfrom)
|
||||
{
|
||||
if (Utils.TryParseUFloat(e.DisplayText, out fdummy))
|
||||
{
|
||||
entity.QfromTextChngd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
else if (e.SubItem == (int)Column.Qto)
|
||||
{
|
||||
if (Utils.TryParseUFloat(e.DisplayText, out fdummy))
|
||||
{
|
||||
entity.QtoTextChngd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
else if (e.SubItem == (int)Column.FlowUnit)
|
||||
{
|
||||
Unit newUnit = Units.FromDescription(e.DisplayText);
|
||||
if (Units.IsFlow(newUnit))
|
||||
{
|
||||
UpdateFlow(e.Item, newUnit);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateFlow(ListViewItem item, Unit newUnit)
|
||||
{
|
||||
var entity = item.Tag as Config.Entities.FeedingPath;
|
||||
if (entity == null || !Units.IsFlow(newUnit) || newUnit == entity.FlowUnit) return;
|
||||
Unit oriUnit = entity.FlowUnit;
|
||||
entity.FlowUnit = newUnit;
|
||||
|
||||
int ix = (int)Column.Qfrom;
|
||||
double flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text));
|
||||
item.SubItems[ix].Text = Units.ConvertTo(newUnit, entity.QfromTextChngd ? flowM3ph : entity.Qfrom).ToString();
|
||||
|
||||
ix = (int)Column.Qto;
|
||||
flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text));
|
||||
item.SubItems[ix].Text = Units.ConvertTo(newUnit, entity.QtoTextChngd ? flowM3ph : entity.Qto).ToString();
|
||||
}
|
||||
|
||||
public override void DrawOne(object myItem)
|
||||
@ -187,8 +258,9 @@ namespace TBF.UI.Bench.Paths
|
||||
ListViewItem lvi = new ListViewItem(entity.Name);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
|
||||
lvi.SubItems.Add(path.Qfrom.ToString());
|
||||
lvi.SubItems.Add(path.Qto.ToString());
|
||||
lvi.SubItems.Add(Units.ConvertTo(entity.FlowUnit, path.Qfrom).ToString()); /// Q_from
|
||||
lvi.SubItems.Add(Units.ConvertTo(entity.FlowUnit, path.Qto).ToString()); /// Q_to
|
||||
lvi.SubItems.Add(entity.FlowUnit.ToDescription());
|
||||
lvi.SubItems.Add(path.Selector);
|
||||
lvi.SubItems.Add(path.Pump != null ? path.Pump.Cfg.Name : "---");
|
||||
|
||||
@ -234,11 +306,11 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
float Qfrom;
|
||||
bool allOk = Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qfrom].Text, out Qfrom);
|
||||
entity.Qfrom = Qfrom;
|
||||
entity.Qfrom = Units.ConvertFrom(entity.FlowUnit, Qfrom);
|
||||
|
||||
float Qto;
|
||||
allOk &= Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qto].Text, out Qto);
|
||||
entity.Qto = Qto;
|
||||
entity.Qto = Units.ConvertFrom(entity.FlowUnit, Qto);
|
||||
|
||||
entity.Selector = lvi.SubItems[(int)Column.Selector].Text;
|
||||
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using Common;
|
||||
using Common.Forms;
|
||||
using Config.Entities;
|
||||
using TBF.Rig;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Resources;
|
||||
using TBF.UI.Shared;
|
||||
using System.Text;
|
||||
|
||||
namespace TBF.UI.Bench.Paths
|
||||
{
|
||||
@ -28,6 +29,7 @@ namespace TBF.UI.Bench.Paths
|
||||
Name,
|
||||
Qfrom,
|
||||
Qto,
|
||||
FlowUnit,
|
||||
Selector,
|
||||
RefFlowmtr,
|
||||
RegulValve,
|
||||
@ -70,7 +72,11 @@ namespace TBF.UI.Bench.Paths
|
||||
.OrderBy(x => x.ItemNr).Asc
|
||||
.List();
|
||||
|
||||
foreach (var path in MyItems) path.OriName = path.Name;
|
||||
foreach (var path in MyItems)
|
||||
{
|
||||
path.OriName = path.Name;
|
||||
path.FlowUnit = TBF.Rig.Sequences.ProcessData.FlowUnit;
|
||||
}
|
||||
|
||||
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||
SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
|
||||
@ -79,23 +85,24 @@ namespace TBF.UI.Bench.Paths
|
||||
/// ListViewEx columns
|
||||
TBF.LocalSettings ls = Program.LocalSettings;
|
||||
Columns.Add(Strings.Name, (ls.OutputColumnCount > 0) ? ls.OutputColumnWidths[0] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [m3/h]", Strings.Q_from), (ls.OutputColumnCount > 1) ? ls.OutputColumnWidths[1] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [m3/h]", Strings.Q_to), (ls.OutputColumnCount > 2) ? ls.OutputColumnWidths[2] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Selector", (ls.OutputColumnCount > 0) ? ls.OutputColumnWidths[0] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Flowmeter, (ls.OutputColumnCount > 3) ? ls.OutputColumnWidths[3] : 85 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Reg_valve, (ls.OutputColumnCount > 4) ? ls.OutputColumnWidths[4] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.PID, (ls.OutputColumnCount > 5) ? ls.OutputColumnWidths[5] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Diverter, (ls.OutputColumnCount > 6) ? ls.OutputColumnWidths[6] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.T_div, (ls.OutputColumnCount > 7) ? ls.OutputColumnWidths[7] : 70 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Balance, (ls.OutputColumnCount > 8) ? ls.OutputColumnWidths[8] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} 1", Strings.StartValve), (ls.OutputColumnCount > 9) ? ls.OutputColumnWidths[9] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Inv. SV1"), (ls.OutputColumnCount > 10) ? ls.OutputColumnWidths[10] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} 2", Strings.StartValve), (ls.OutputColumnCount > 11) ? ls.OutputColumnWidths[11] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Inv.SV2"), (ls.OutputColumnCount > 12) ? ls.OutputColumnWidths[12] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Lag SV2"), (ls.OutputColumnCount > 13) ? ls.OutputColumnWidths[13] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
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);
|
||||
Columns.Add(Strings.Q_from, (ls.OutputColumnCount > 1) ? ls.OutputColumnWidths[1] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Q_to, (ls.OutputColumnCount > 2) ? ls.OutputColumnWidths[2] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Unit", (ls.OutputColumnCount > 3) ? ls.OutputColumnWidths[3] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add("Selector", (ls.OutputColumnCount > 4) ? ls.OutputColumnWidths[4] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Flowmeter, (ls.OutputColumnCount > 5) ? ls.OutputColumnWidths[5] : 85 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Reg_valve, (ls.OutputColumnCount > 6) ? ls.OutputColumnWidths[6] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.PID, (ls.OutputColumnCount > 7) ? ls.OutputColumnWidths[7] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Diverter, (ls.OutputColumnCount > 8) ? ls.OutputColumnWidths[8] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.T_div, (ls.OutputColumnCount > 9) ? ls.OutputColumnWidths[9] : 70 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(Strings.Balance, (ls.OutputColumnCount > 10) ? ls.OutputColumnWidths[10] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} 1", Strings.StartValve), (ls.OutputColumnCount > 11) ? ls.OutputColumnWidths[11] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Inv. SV1"), (ls.OutputColumnCount > 12) ? ls.OutputColumnWidths[12] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} 2", Strings.StartValve), (ls.OutputColumnCount > 13) ? ls.OutputColumnWidths[13] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Inv.SV2"), (ls.OutputColumnCount > 14) ? ls.OutputColumnWidths[14] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Lag SV2"), (ls.OutputColumnCount > 15) ? ls.OutputColumnWidths[15] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} 3", Strings.StartValve), (ls.OutputColumnCount > 16) ? ls.OutputColumnWidths[16] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Inv.SV3"), (ls.OutputColumnCount > 17) ? ls.OutputColumnWidths[17] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("Lag SV3"), (ls.OutputColumnCount > 18) ? ls.OutputColumnWidths[18] : 80 * parent.Dpi / Constants.Dpi100pct);
|
||||
|
||||
valvescount = 0;
|
||||
regulValvesCount = 0;
|
||||
@ -160,11 +167,16 @@ namespace TBF.UI.Bench.Paths
|
||||
}
|
||||
}
|
||||
|
||||
/// Flow unit
|
||||
var flowUnitBox = new ComboBox();
|
||||
for (Unit u = 0; u < Unit.Count; u++) if (Units.IsFlow(u)) flowUnitBox.Items.Add(u.ToDescription());
|
||||
|
||||
editors = new Control[fixedColumnsCount + valvescount + regulValvesCount];
|
||||
///
|
||||
editors[(int)Column.Name] = new TextBox(); /// Name
|
||||
editors[(int)Column.Qfrom] = new TextBox(); /// Q_from
|
||||
editors[(int)Column.Qto] = new TextBox(); /// Q_to
|
||||
editors[(int)Column.FlowUnit] = flowUnitBox; /// Flow unit
|
||||
editors[(int)Column.Selector] = new TextBox(); /// Selector
|
||||
editors[(int)Column.RefFlowmtr] = flowMeterComboBox;
|
||||
editors[(int)Column.RegulValve] = regulValveComboBox;
|
||||
@ -213,7 +225,8 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
|
||||
{
|
||||
if (!Unlocked || e.SubItem >= editors.Length) return;
|
||||
if (e.SubItem != (int)Column.FlowUnit && (!Unlocked || e.SubItem >= editors.Length)) return;
|
||||
|
||||
if ((e.Item.Tag is IHasItemNr) &&
|
||||
((e.Item.Tag as IHasItemNr).ItemNr < FixedRowsCount) &&
|
||||
(e.SubItem < fixedColumnsCount))
|
||||
@ -239,6 +252,8 @@ namespace TBF.UI.Bench.Paths
|
||||
{
|
||||
item.SubItems[columnNr].Text = value;
|
||||
item.SubItems[columnNr].BackColor = backColor;
|
||||
|
||||
if (columnNr == (int)Column.FlowUnit) UpdateFlow(item, Units.FromDescription(value));
|
||||
}
|
||||
else if (item == e.Item)
|
||||
{
|
||||
@ -251,6 +266,9 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
||||
{
|
||||
var entity = e.Item.Tag as Config.Entities.OutputPath;
|
||||
float fdummy;
|
||||
|
||||
if (e.SubItem >= fixedColumnsCount && e.SubItem < fixedColumnsCount + valvescount)
|
||||
{
|
||||
e.Item.SubItems[e.SubItem].BackColor = e.DisplayText == Strings.open ? Color.LightGray : Color.White;
|
||||
@ -259,6 +277,59 @@ namespace TBF.UI.Bench.Paths
|
||||
{
|
||||
e.Item.SubItems[e.SubItem].BackColor = (e.DisplayText != "0" && e.DisplayText != "---") ? Color.LightGray : Color.White;
|
||||
}
|
||||
else if (e.SubItem == (int)Column.Qfrom)
|
||||
{
|
||||
if (Utils.TryParseUFloat(e.DisplayText, out fdummy))
|
||||
{
|
||||
entity.QfromTextChngd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
else if (e.SubItem == (int)Column.Qto)
|
||||
{
|
||||
if (Utils.TryParseUFloat(e.DisplayText, out fdummy))
|
||||
{
|
||||
entity.QtoTextChngd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
else if (e.SubItem == (int)Column.FlowUnit)
|
||||
{
|
||||
Unit newUnit = Units.FromDescription(e.DisplayText);
|
||||
if (Units.IsFlow(newUnit))
|
||||
{
|
||||
UpdateFlow(e.Item, newUnit);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateFlow(ListViewItem item, Unit newUnit)
|
||||
{
|
||||
var entity = item.Tag as Config.Entities.OutputPath;
|
||||
if (entity == null || !Units.IsFlow(newUnit) || newUnit == entity.FlowUnit) return;
|
||||
Unit oriUnit = entity.FlowUnit;
|
||||
entity.FlowUnit = newUnit;
|
||||
|
||||
int ix = (int)Column.Qfrom;
|
||||
double flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text));
|
||||
item.SubItems[ix].Text = Units.ConvertTo(newUnit, entity.QfromTextChngd ? flowM3ph : entity.Qfrom).ToString();
|
||||
|
||||
ix = (int)Column.Qto;
|
||||
flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text));
|
||||
item.SubItems[ix].Text = Units.ConvertTo(newUnit, entity.QtoTextChngd ? flowM3ph : entity.Qto).ToString();
|
||||
}
|
||||
|
||||
public override void DrawOne(object myItem)
|
||||
@ -269,8 +340,9 @@ namespace TBF.UI.Bench.Paths
|
||||
ListViewItem lvi = new ListViewItem(entity.Name);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
|
||||
lvi.SubItems.Add(path.Qfrom.ToString());
|
||||
lvi.SubItems.Add(path.Qto.ToString());
|
||||
lvi.SubItems.Add(Units.ConvertTo(entity.FlowUnit, path.Qfrom).ToString()); /// Q_from
|
||||
lvi.SubItems.Add(Units.ConvertTo(entity.FlowUnit, path.Qto).ToString()); /// Q_to
|
||||
lvi.SubItems.Add(entity.FlowUnit.ToDescription());
|
||||
lvi.SubItems.Add(path.Selector);
|
||||
lvi.SubItems.Add((path.FlowMeter != null) ? path.FlowMeter.Cfg.Name : "---");
|
||||
lvi.SubItems.Add((path.RegulValve != null) ? path.RegulValve.Cfg.Name : "---");
|
||||
@ -341,11 +413,11 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
float Qfrom;
|
||||
bool allOk = Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qfrom].Text, out Qfrom);
|
||||
entity.Qfrom = Qfrom;
|
||||
entity.Qfrom = Units.ConvertFrom(entity.FlowUnit, Qfrom);
|
||||
|
||||
float Qto;
|
||||
allOk &= Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qto].Text, out Qto);
|
||||
entity.Qto = Qto;
|
||||
entity.Qto = Units.ConvertFrom(entity.FlowUnit, Qto);
|
||||
|
||||
entity.Selector = lvi.SubItems[(int)Column.Selector].Text;
|
||||
entity.FlowMeter = lvi.SubItems[(int)Column.RefFlowmtr].Text.Equals("---") ? null : lvi.SubItems[(int)Column.RefFlowmtr].Text;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user