From 6dcd40c640f0cc8d49ba6954cde53c51187c12bc Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 23 Nov 2022 07:59:05 +0100 Subject: [PATCH] Profiles: Method added, imp./exp. fixed, Procedures: Selection by profile, Create from profile button, etc, ver. 3.5.1992 --- Config/Entities/PTest.cs | 30 ++- Config/Entities/Profile.cs | 5 +- Config/FluentCommon.cs | 2 +- Config/Mappings/PTestMap.cs | 1 + TBF/Properties/AssemblyInfo.cs | 4 +- TBF/Resources/Strings.Designer.cs | 18 ++ TBF/Resources/Strings.resx | 6 + TBF/Rig/TbfComponents.cs | 16 ++ TBF/TBF.csproj | 1 + TBF/UI/Bench/TestProfiles/TestProfileDlg.cs | 32 ++- TBF/UI/Bench/TestProfiles/TestProfileDlg.resx | 9 +- TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs | 3 +- TBF/UI/Procedures/Formulas.cs | 154 ++++++++++++ TBF/UI/Procedures/ProcedureDlg.cs | 51 ++-- TBF/UI/Procedures/ProcedureDlg.resx | 40 ++- TBF/UI/Procedures/ProceduresCtrl.Designer.cs | 47 +++- TBF/UI/Procedures/ProceduresCtrl.cs | 227 +++++++++--------- TBF/UI/Procedures/ProceduresDlg.cs | 22 +- .../TestWizard/TestProfileSelection.cs | 225 +++++++++++++---- .../TestProfileSelection.designer.cs | 39 +-- 20 files changed, 667 insertions(+), 265 deletions(-) create mode 100644 TBF/UI/Procedures/Formulas.cs diff --git a/Config/Entities/PTest.cs b/Config/Entities/PTest.cs index 513fdd201..5ed77e68f 100644 --- a/Config/Entities/PTest.cs +++ b/Config/Entities/PTest.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2022 Sensus Slovensko a.s. /// using System; using System.Globalization; @@ -27,6 +27,7 @@ namespace Config.Entities public virtual double PressLimHi { get; set; } /// [bar] max. water pressure public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal public virtual bool Evaluate { get; set; } + public virtual string Method { get; set; } /// Test method (component name) public virtual sbyte E1 { get; set; } /// public virtual sbyte E2 { get; set; } /// @@ -81,6 +82,7 @@ namespace Config.Entities PressLimHi = 16.0; /// [bar] Publish = (sbyte)Common.Publish.Always; Evaluate = true; + Method = string.Empty; E1 = (sbyte)ErrorFlagsMode.On; E2 = (sbyte)ErrorFlagsMode.On; @@ -140,6 +142,7 @@ namespace Config.Entities result.PressLimHi = PressLimHi; result.Publish = Publish; result.Evaluate = Evaluate; + result.Method = Method; result.E1 = E1; result.E2 = E2; @@ -193,6 +196,7 @@ namespace Config.Entities output.WriteLine(PressLimHi.ToString(ci)); output.WriteLine(Publish.ToString()); output.WriteLine(Evaluate.ToString()); + output.WriteLine(Method); output.WriteLine(E1.ToString()); output.WriteLine(E2.ToString()); @@ -247,10 +251,29 @@ namespace Config.Entities tst.ErrLimHi = double.Parse(input.ReadLine(), ci); tst.TempLimLo = double.Parse(input.ReadLine(), ci); tst.TempLimHi = double.Parse(input.ReadLine(), ci); - tst.Publish = sbyte.Parse(input.ReadLine()); + tst.PressLimLo = double.Parse(input.ReadLine(), ci); + tst.PressLimHi = double.Parse(input.ReadLine(), ci); + tst.Publish = sbyte.Parse(input.ReadLine(), ci); tst.Evaluate = bool.Parse(input.ReadLine()); + tst.Method = input.ReadLine(); - /// TODO (E1 .. E21) + tst.E1 = sbyte.Parse(input.ReadLine(), ci); + tst.E2 = sbyte.Parse(input.ReadLine(), ci); + tst.E3 = sbyte.Parse(input.ReadLine(), ci); + tst.E4 = sbyte.Parse(input.ReadLine(), ci); + tst.E5 = sbyte.Parse(input.ReadLine(), ci); + tst.E6 = sbyte.Parse(input.ReadLine(), ci); + tst.E7 = sbyte.Parse(input.ReadLine(), ci); + tst.E8 = sbyte.Parse(input.ReadLine(), ci); + tst.E9 = sbyte.Parse(input.ReadLine(), ci); + tst.E10 = sbyte.Parse(input.ReadLine(), ci); + tst.E11 = sbyte.Parse(input.ReadLine(), ci); + tst.E12 = sbyte.Parse(input.ReadLine(), ci); + tst.E13 = sbyte.Parse(input.ReadLine(), ci); + tst.E14 = sbyte.Parse(input.ReadLine(), ci); + tst.E15 = sbyte.Parse(input.ReadLine(), ci); + tst.E16 = sbyte.Parse(input.ReadLine(), ci); + tst.E21 = sbyte.Parse(input.ReadLine(), ci); tst.Delta_Q_pct = double.Parse(input.ReadLine(), ci); tst.Delta_T = double.Parse(input.ReadLine(), ci); @@ -293,6 +316,7 @@ namespace Config.Entities ln = inp.ReadLine(); if (ln != PressLimHi.ToString(ci)) { diff.AppendFormat(fmt, "Pressure_max", PressLimHi.ToString(ci), ln); }; ln = inp.ReadLine(); if (ln != Publish.ToString()) { diff.AppendFormat(fmt, "Publish", Publish.ToString(), ln); }; ln = inp.ReadLine(); if (ln != Evaluate.ToString()) { diff.AppendFormat(fmt, "Evaluate", Evaluate.ToString(), ln); }; + ln = inp.ReadLine(); if (ln != Method) { diff.AppendFormat(fmt, "Method", Method, ln); }; ln = inp.ReadLine(); if (ln != E1.ToString()) { diff.AppendFormat(fmt, "E1", E1.ToString(), ln); }; ln = inp.ReadLine(); if (ln != E2.ToString()) { diff.AppendFormat(fmt, "E2", E2.ToString(), ln); }; diff --git a/Config/Entities/Profile.cs b/Config/Entities/Profile.cs index cc7839886..7770e7cce 100644 --- a/Config/Entities/Profile.cs +++ b/Config/Entities/Profile.cs @@ -78,6 +78,8 @@ namespace Config.Entities output.WriteLine(CreationTime.ToString(CultureInfo.InvariantCulture)); output.WriteLine(LastChgUser); output.WriteLine(LastChgTime.ToString(CultureInfo.InvariantCulture)); + output.WriteLine(((sbyte)ProfileType).ToString()); + output.WriteLine(((sbyte)ErrorLimitType).ToString()); foreach (var test in Tests) { test.Export(output); } output.WriteLine(); @@ -96,7 +98,8 @@ namespace Config.Entities result.CreationTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture); result.LastChgUser = input.ReadLine(); result.LastChgTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture); - string line = input.ReadLine(); + result.ProfileType = (ProfileType)sbyte.Parse(input.ReadLine()); + result.ErrorLimitType = (ErrorLimitType)sbyte.Parse(input.ReadLine()); while (true) { diff --git a/Config/FluentCommon.cs b/Config/FluentCommon.cs index 9336ab5a3..cf82d2799 100644 --- a/Config/FluentCommon.cs +++ b/Config/FluentCommon.cs @@ -128,7 +128,7 @@ namespace Config case GID.Administrators: #if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL case GID.TraceabilityManagement: -#elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_END +#elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_50 || WARSAW_END case GID.MetrologicalAuthority: case GID.WaterMeterAuthority: #endif diff --git a/Config/Mappings/PTestMap.cs b/Config/Mappings/PTestMap.cs index 3cf5f1386..3210b9f64 100644 --- a/Config/Mappings/PTestMap.cs +++ b/Config/Mappings/PTestMap.cs @@ -24,6 +24,7 @@ namespace Config.Mappings Map(x => x.PressLimHi); Map(x => x.Publish); Map(x => x.Evaluate); + Map(x => x.Method); Map(x => x.E1); Map(x => x.E2); Map(x => x.E3); diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 623d060f9..026ee9119 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.4.1981.0")] -[assembly: AssemblyFileVersion("3.4.1981.0")] +[assembly: AssemblyVersion("3.5.1992.0")] +[assembly: AssemblyFileVersion("3.5.1992.0")] diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index e1604b293..18d1f3bb6 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -357,6 +357,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to any profile. + /// + internal static string any_profile { + get { + return ResourceManager.GetString("any_profile", resourceCulture); + } + } + /// /// Looks up a localized string similar to Approval. /// @@ -3372,6 +3381,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to no profile. + /// + internal static string no_profile { + get { + return ResourceManager.GetString("no_profile", resourceCulture); + } + } + /// /// Looks up a localized string similar to No results to print. /// diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 4bf3a736d..54e645405 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -2389,4 +2389,10 @@ Wait until + + any profile + + + no profile + \ No newline at end of file diff --git a/TBF/Rig/TbfComponents.cs b/TBF/Rig/TbfComponents.cs index 573b93092..711f68070 100644 --- a/TBF/Rig/TbfComponents.cs +++ b/TBF/Rig/TbfComponents.cs @@ -242,6 +242,22 @@ namespace TBF.Rig public static string CurrentlyLoadedComponentName; + /// + /// Load component entities from the database and convert them to TBF components + /// derived from IComponent with mutual references. + /// + /// NHibernate DB session + /// A list of TBF Components + public static IList LoadComponentsFromDB(NHibernate.ISession session) + { + /// Load the list of components from the database + var cmptnEntities = session.QueryOver() + .OrderBy(x => x.ItemNr).Asc + .List(); + + return LoadComponentsFromDB(cmptnEntities); + } + /// /// Load component entities from the database and convert them to TBF components /// derived from IComponent with mutual references. diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 291479f1d..8b68e742b 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -2262,6 +2262,7 @@ MainWnd.cs + Form diff --git a/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs b/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs index 6e4d6c20d..ef31efd13 100644 --- a/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs +++ b/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs @@ -1,15 +1,21 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2022 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Windows.Forms; using log4net; using Common; using Common.Forms; using Config.Entities; +using TBF.Rig.Generic; +using TBF.Rig.GenericDevices; using TBF.Resources; using TBF.UI.Shared; +using TBF.Rig.Output; +using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead; namespace TBF.UI.Bench.TestProfiles { @@ -33,6 +39,7 @@ namespace TBF.UI.Bench.TestProfiles /// Auxiliary public lists used also by user controls in tab pages public IList TbfComponents; + public IList TestMethods; bool unlocked; @@ -54,6 +61,18 @@ namespace TBF.UI.Bench.TestProfiles this.usedNames = usedNames; this.openUnlocked = openUnlocked; + TestMethods = new List(); + using (NHibernate.ISession session = TBF.DB.CreateSession(DBKind.Config)) + { + /// Prepare a list of components and a list of test methods + TbfComponents = Rig.TbfComponents.LoadComponentsFromDB(session); + + if (TbfComponents != null) + foreach (var c in TbfComponents) + if (c is ITestMethod) + TestMethods.Add(c as ITestMethod); + } + /// SharedDlgButtons configuration sharedButtons.ParentForm = parentForm; sharedButtons.RequiredGroupMembership = new GID[] { GID.MetrologicalAuthority }; @@ -218,6 +237,7 @@ namespace TBF.UI.Bench.TestProfiles PressLimHi, Publish, Evaluate, + Method, ColumnsCount } @@ -236,6 +256,7 @@ namespace TBF.UI.Bench.TestProfiles lv.Columns.Add(new ColumnHeader { Text = Strings.Press_lim_hi_chdr, Width = 80 }); lv.Columns.Add(new ColumnHeader { Text = Strings.Publish, Width = 80 }); lv.Columns.Add(new ColumnHeader { Text = Strings.Evaluate, Width = 80 }); + lv.Columns.Add(new ColumnHeader { Text = Strings.Method_chdr, Width = 200 }); ComboBox publishCBox = new ComboBox(); /// control for Publish for (Publish pb = 0; pb < Publish.Count; pb++) @@ -247,6 +268,9 @@ namespace TBF.UI.Bench.TestProfiles yesNoCBox.Items.Add(Strings.yes); yesNoCBox.Items.Add(Strings.no); + ComboBox methodCBox = new ComboBox(); + foreach (var m in TestMethods) methodCBox.Items.Add(m.Name); + metrologyEditors = new Control[] { new TextBox(), /// Name @@ -261,6 +285,7 @@ namespace TBF.UI.Bench.TestProfiles new TextBox(), /// Press.Lim. + publishCBox, /// Publish yesNoCBox, /// Evaluate + methodCBox, /// Test method }; foreach (var ctrl in metrologyEditors) @@ -306,6 +331,7 @@ namespace TBF.UI.Bench.TestProfiles lvi.SubItems.Add(pTest.PressLimHi.ToString()); lvi.SubItems.Add(((Publish)pTest.Publish).ToDescription()); lvi.SubItems.Add(pTest.Evaluate ? Strings.yes : Strings.no); + lvi.SubItems.Add((pTest.Method != null) ? pTest.Method : string.Empty); metrologyListViewEx.Items.Add(lvi); } @@ -359,6 +385,8 @@ namespace TBF.UI.Bench.TestProfiles break; } } + + entity.Method = lvi.SubItems[(int)MtrlgyClmn.Method].Text; } catch (Exception exc) { @@ -448,7 +476,7 @@ namespace TBF.UI.Bench.TestProfiles } /// Combo boxes - if ((e.SubItem == (int)MtrlgyClmn.Publish) || (e.SubItem == (int)MtrlgyClmn.Evaluate)) + if ((e.SubItem == (int)MtrlgyClmn.Publish) || (e.SubItem == (int)MtrlgyClmn.Evaluate) || (e.SubItem == (int)MtrlgyClmn.Method)) { if (!(metrologyEditors[e.SubItem] as ComboBox).Items.Contains(e.DisplayText)) { diff --git a/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx b/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx index 159701f68..daf4087e4 100644 --- a/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx +++ b/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx @@ -733,10 +733,10 @@ Fill - 3, 3 + 0, 0 - 917, 360 + 923, 366 0 @@ -756,9 +756,6 @@ 4, 34 - - 3, 3, 3, 3 - 923, 366 @@ -928,7 +925,7 @@ sharedButtons - TBF.UI.Shared.SharedButtons, TBF, Version=3.2.1913.0, Culture=neutral, PublicKeyToken=null + TBF.UI.Shared.SharedButtons, TBF, Version=3.4.1981.0, Culture=neutral, PublicKeyToken=null mainSplitContainer.Panel2 diff --git a/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs b/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs index 72e02656b..a045fd0fc 100644 --- a/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs +++ b/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Windows.Forms; using log4net; using Common; +using Common.Forms; using TBF.Resources; using TBF.UI.Shared; @@ -181,7 +182,7 @@ namespace TBF.UI.Bench.TestProfiles /// void SelectedIndexChanged(object sender, EventArgs e) { - Common.Forms.ListViewEx listViewEx = sender as Common.Forms.ListViewEx; + var listViewEx = sender as ListViewEx; if (listViewEx.SelectedItems.Count != 1) { /// No item selected diff --git a/TBF/UI/Procedures/Formulas.cs b/TBF/UI/Procedures/Formulas.cs new file mode 100644 index 000000000..e23f1ecbc --- /dev/null +++ b/TBF/UI/Procedures/Formulas.cs @@ -0,0 +1,154 @@ + +using Common; + +namespace TBF.UI.Procedures +{ + public static class Formulas + { + public static double GetTargetQ(Config.Entities.PTest ptest, double qN, double qpQiRatio, string metroClass, Medium medium) + { + if (ptest.Name.ToLower().Contains("q4") || ptest.Name.ToLower().Contains("qmax")) + { + return Formulas.GetQ4Qmax(qN, metroClass, medium, ptest.CoefQto); + } + else if (ptest.Name.ToLower().Contains("q3") || ptest.Name.ToLower().Contains("qn") || ptest.Name.ToLower().Equals("qp")) + { + return qN; + } + else if (ptest.Name.ToLower().Contains("q2") || ptest.Name.ToLower().Contains("qt")) + { + return Formulas.GetQ2Qt(qN, metroClass, medium, ptest.CoefQto); + } + else if (ptest.Name.ToLower().Contains("q1") || ptest.Name.ToLower().Contains("qmin")) + { + return Formulas.GetQ1Qmin(qN, metroClass, medium, ptest.CoefQto); + } + else if (ptest.Name.ToLower().Contains("0,1qp") || ptest.Name.ToLower().Contains("0.1qp")) + { + return 0.1 * qN; + } + else if (ptest.Name.ToLower().Contains("qi")) + { + return qN / qpQiRatio; + } + else + { + return qN; /// Manual flow selection: CoefQfrom and CoefQto are used to calculate Qfrom and Qto from Qn + } + } + + /// + /// Get either Q1 or Qmin flow for a given Qn and metrological class + /// + /// Nominal flow in m3/h + /// Metrological class ("A" ,"B", "C" or "R#") + /// NotSpecified, ColdWater or HotWater + /// Default flow when metrologic does not match pattern + /// Q1 or Qmin flow in m3/h + public static double GetQ1Qmin(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0) + { + if (string.IsNullOrEmpty(metroClass)) return Qdflt; + + int metroClassRatio; + if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0)) + { + return Qn / (double)metroClassRatio; + } + else + { + if (medium == Medium.HotWater) + { + switch (metroClass) + { + case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn); + case "B": return (Qn < 15) ? (0.02 * Qn) : (0.04 * Qn); + case "C": return (Qn < 15) ? (0.01 * Qn) : (0.02 * Qn); + case "D": return (Qn < 15) ? (0.01 * Qn) : Qdflt; + default: break; + } + } + else + { + switch (metroClass) + { + case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn); + case "B": return (Qn < 15) ? (0.02 * Qn) : (0.03 * Qn); + case "C": return (Qn < 15) ? (0.01 * Qn) : (0.006 * Qn); + default: break; + } + } + } + + return Qdflt; + } + + /// + /// Get either Q2 or Qt flow for a given Qn and metrological class + /// + /// Nominal flow in m3/h + /// Metrological class ("A" ,"B", "C" or "R#") + /// NotSpecified, ColdWater or HotWater + /// Default flow when metrologic does not match pattern + /// Q2 or Qt flow in m3/h + public static double GetQ2Qt(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0) + { + if (string.IsNullOrEmpty(metroClass)) return Qdflt; + + int metroClassRatio; + if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0)) + { + return 1.6 * Qn / (double)metroClassRatio; + } + + if (medium == Medium.HotWater) + { + switch (metroClass) + { + case "A": return (Qn < 15) ? (0.1 * Qn) : (0.2 * Qn); + case "B": return (Qn < 15) ? (0.08 * Qn) : (0.15 * Qn); + case "C": return (Qn < 15) ? (0.06 * Qn) : (0.1 * Qn); + case "D": return (Qn < 15) ? (0.015 * Qn) : Qdflt; + default: break; + } + } + else + { + switch (metroClass) + { + case "A": return (Qn < 15) ? (0.1 * Qn) : (0.3 * Qn); + case "B": return (Qn < 15) ? (0.08 * Qn) : (0.2 * Qn); + case "C": return (Qn < 15) ? (0.015 * Qn) : (0.015 * Qn); + default: break; + } + } + + return Qdflt; + } + + /// + /// Get either Q4 or Qmax flow for a given Qn and metrological class + /// + /// Nominal flow in m3/h + /// Metrological class ("A" ,"B", "C" or "R#") + /// NotSpecified, ColdWater or HotWater + /// Default flow when metrologic does not match pattern + /// Q4 or Qmax flow in m3/h + public static double GetQ4Qmax(double Qn, string metroClass, Medium medium = Medium.ColdWater, double Qdflt = 0) + { + if (string.IsNullOrEmpty(metroClass)) return Qdflt; + + switch (metroClass[0]) + { + case 'A': + case 'B': + case 'C': + case 'D': + return 2 * Qn; + case 'R': + return 1.25 * Qn; + default: + return Qdflt; + } + } + } +} diff --git a/TBF/UI/Procedures/ProcedureDlg.cs b/TBF/UI/Procedures/ProcedureDlg.cs index 2b5be25fe..f2678a327 100644 --- a/TBF/UI/Procedures/ProcedureDlg.cs +++ b/TBF/UI/Procedures/ProcedureDlg.cs @@ -1,6 +1,10 @@ /// /// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// +#if KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_50 || WARSAW_END +#define SHOW_Q_TG +#endif + using System; using System.Collections.Generic; using System.Linq; @@ -84,7 +88,7 @@ namespace TBF.UI.Procedures /// SharedDlgButtons configuration sharedButtons.ParentForm = parentForm; -#if KEMPNO_50 || KRAKOW_50 +#if KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_50 || WARSAW_END sharedButtons.RequiredGroupMembership = procedure.Protected ? new GID[] { GID.WaterMeterAuthority } : new GID[] { GID.TestingSpecialists, GID.WaterMeterAuthority }; #else @@ -328,11 +332,10 @@ namespace TBF.UI.Procedures IList other = new List(); foreach (var cmpnt in TbfComponents) { - if (cmpnt is TBF.Rig.Output.DB.SensusOracle.Database) other.Add(cmpnt); - if (cmpnt is TBF.Rig.TestMethods.S640Communication.S640Start) other.Add(cmpnt); - if (cmpnt is TBF.Rig.TestMethods.S640Communication.S640End) other.Add(cmpnt); - if (cmpnt is TBF.Rig.Modbus.TempControl.Easytherm.TControl) other.Add(cmpnt); - if (cmpnt is TBF.Rig.Modbus.TempControl.Novus.TControl) other.Add(cmpnt); + if (!(cmpnt is IRegReader) && !(cmpnt is IWaterMeter) && cmpnt.Cfg.CreateProcParamsProvider() != null) + { + other.Add(cmpnt); + } } if (other.Count > 0) @@ -356,7 +359,7 @@ namespace TBF.UI.Procedures LoadUISettings(); /// Enable/disable/show/hide controls in General tab -#if KEMPNO_50 || KRAKOW_50 +#if KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_50 || WARSAW_END altProcNameLabel.Visible = true; altProcNameTextBox.Visible = true; //altProcPeriodLabel.Visible = true; @@ -777,7 +780,7 @@ namespace TBF.UI.Procedures { Name, Part, -#if TEST_PROFILES +#if SHOW_Q_TG Qtg, #endif Qfrom, @@ -799,7 +802,7 @@ namespace TBF.UI.Procedures ListViewEx lv = metrology1ListViewEx; lv.Columns.Add(new ColumnHeader { Text = Strings.Test_chdr, Width = 70 }); lv.Columns.Add(new ColumnHeader { Text = Strings.Part, Width = 40 }); -#if TEST_PROFILES +#if SHOW_Q_TG lv.Columns.Add(new ColumnHeader { Text = Strings.Q_tg, Width = 80 }); #endif lv.Columns.Add(new ColumnHeader { Text = Strings.Q_from, Width = 80 }); @@ -819,7 +822,7 @@ namespace TBF.UI.Procedures var flowUnitBox = new ComboBox(); var volUnitBox = new ComboBox(); - for (Common.Unit u = 0; u < Common.Unit.Count; u++) + for (Unit u = 0; u < Unit.Count; u++) { if (Units.IsFlow(u)) flowUnitBox.Items.Add(u.ToDescription()); if (Units.IsVolume(u)) volUnitBox.Items.Add(u.ToDescription()); @@ -829,7 +832,7 @@ namespace TBF.UI.Procedures { new TextBox(), /// Name new TextBox(), /// Part -#if TEST_PROFILES +#if SHOW_Q_TG new TextBox(), /// Qtg #endif new TextBox(), /// Qfrom @@ -874,7 +877,7 @@ namespace TBF.UI.Procedures ListViewItem lvi = new ListViewItem(test.Name); /// Name lvi.Tag = test; lvi.SubItems.Add((test.Part == 0) ? "-" : test.Part.ToString()); /// Part -#if TEST_PROFILES +#if SHOW_Q_TG lvi.SubItems.Add(Units.ConvertTo(test.FlowUnit, test.Qtg).ToString()); /// Q_tg (target flow) #endif lvi.SubItems.Add(Units.ConvertTo(test.FlowUnit, test.Qfrom).ToString()); /// Q_from @@ -917,7 +920,7 @@ namespace TBF.UI.Procedures int itmp; float tmp; double dtmp; -#if TEST_PROFILES +#if SHOW_Q_TG if (test.QtgTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Qtg].Text, out dtmp)) test.Qtg = (float)Units.ConvertFrom(test.FlowUnit, dtmp); #endif @@ -949,7 +952,7 @@ namespace TBF.UI.Procedures { MtrlgyClmn column = (MtrlgyClmn)e.SubItem; -#if TEST_PROFILES +#if SHOW_Q_TG if (e.SubItem == (int)MtrlgyClmn.Qtg) return; #endif /// Unit change is allowed when locked @@ -972,7 +975,7 @@ namespace TBF.UI.Procedures void metrology1ListViewEx_SubItemRightClicked(object sender, SubItemEventArgs e) { -#if TEST_PROFILES +#if SHOW_Q_TG if (e.SubItem == (int)MtrlgyClmn.Qtg) return; #endif if (!unlocked || e.SubItem >= (int)MtrlgyClmn.ColumnsCount) return; @@ -1027,7 +1030,7 @@ namespace TBF.UI.Procedures if (int.TryParse(e.DisplayText, out dummy) && Data.IsGoodPartNr(dummy)) return; /// OK break; -#if TEST_PROFILES +#if SHOW_Q_TG case MtrlgyClmn.Qtg: if (Utils.TryParseUFloat(e.DisplayText, out fdummy)) { @@ -1163,7 +1166,7 @@ namespace TBF.UI.Procedures ix = (int)MtrlgyClmn.Qto; flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text)); item.SubItems[ix].Text = Units.ConvertTo(newUnit, test.QtoTextChngd ? flowM3ph : test.Qto).ToString(); -#if TEST_PROFILES +#if SHOW_Q_TG ix = (int)MtrlgyClmn.Qtg; flowM3ph = Units.ConvertFrom(oriUnit, Utils.ParseUDouble(item.SubItems[ix].Text)); item.SubItems[ix].Text = Units.ConvertTo(newUnit, test.QtgTextChngd ? flowM3ph : test.Qtg).ToString(); @@ -1238,7 +1241,7 @@ namespace TBF.UI.Procedures } ComboBox tempUnitBox = new ComboBox(); - for (Common.Unit u = 0; u < Common.Unit.Count; u++) + for (Unit u = 0; u < Unit.Count; u++) { if (Units.IsTemperature(u)) tempUnitBox.Items.Add(u.ToDescription()); } @@ -2382,7 +2385,8 @@ namespace TBF.UI.Procedures if (notUsed) break; } - /// Find possible selector values + /// Find possible selector values. + /// Empty string or null (which is permitted) is not part of list 'selectorValues' IList selectorValues = new List(); foreach (var fp in feedingPaths) { @@ -2496,7 +2500,8 @@ namespace TBF.UI.Procedures double Qaver = (test.Qfrom + test.Qto) / 2.0; foreach (var path in feedingPaths) { - if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && (string.IsNullOrEmpty(selector) || path.Selector == selector)) + if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && + (string.IsNullOrEmpty(selector) || string.IsNullOrEmpty(path.Selector) || path.Selector == selector)) { test.FeedingPath = path.Name; break; @@ -2504,7 +2509,8 @@ namespace TBF.UI.Procedures } foreach (var path in benchPaths) { - if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && (string.IsNullOrEmpty(selector) || path.Selector == selector)) + if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && + (string.IsNullOrEmpty(selector) || string.IsNullOrEmpty(path.Selector) || path.Selector == selector)) { test.BenchPath = path.Name; break; @@ -2512,7 +2518,8 @@ namespace TBF.UI.Procedures } foreach (var path in outputPaths) { - if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && (string.IsNullOrEmpty(selector) || path.Selector == selector)) + if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && + (string.IsNullOrEmpty(selector) || string.IsNullOrEmpty(path.Selector) || path.Selector == selector)) { test.OutputPath = path.Name; break; diff --git a/TBF/UI/Procedures/ProcedureDlg.resx b/TBF/UI/Procedures/ProcedureDlg.resx index 32b92b58a..097a87fd3 100644 --- a/TBF/UI/Procedures/ProcedureDlg.resx +++ b/TBF/UI/Procedures/ProcedureDlg.resx @@ -1903,10 +1903,10 @@ Fill - 3, 3 + 0, 0 - 917, 427 + 923, 433 0 @@ -1915,7 +1915,7 @@ historyListViewEx - Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null + Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null historyTabPage @@ -1926,9 +1926,6 @@ 4, 34 - - 3, 3, 3, 3 - 923, 433 @@ -1954,10 +1951,10 @@ Fill - 3, 3 + 0, 0 - 917, 427 + 923, 433 0 @@ -1966,7 +1963,7 @@ metrology1ListViewEx - Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null + Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null metrology1TabPage @@ -1977,9 +1974,6 @@ 4, 34 - - 3, 3, 3, 3 - 923, 433 @@ -2005,10 +1999,10 @@ Fill - 3, 3 + 0, 0 - 917, 427 + 923, 433 0 @@ -2017,7 +2011,7 @@ metrology2ListViewEx - Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null + Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null metrology2TabPage @@ -2028,9 +2022,6 @@ 4, 34 - - 3, 3, 3, 3 - 923, 433 @@ -2056,10 +2047,10 @@ Fill - 3, 3 + 0, 0 - 917, 427 + 923, 433 0 @@ -2068,7 +2059,7 @@ processListViewEx - Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null + Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null processTabPage @@ -2079,9 +2070,6 @@ 4, 34 - - 3, 3, 3, 3 - 923, 433 @@ -2119,7 +2107,7 @@ parametersListViewEx - Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null + Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null parametersTabPage @@ -2203,7 +2191,7 @@ sharedButtons - TBF.UI.Shared.SharedButtons, TBF, Version=3.1.1685.0, Culture=neutral, PublicKeyToken=null + TBF.UI.Shared.SharedButtons, TBF, Version=3.4.1981.0, Culture=neutral, PublicKeyToken=null mainSplitContainer.Panel2 diff --git a/TBF/UI/Procedures/ProceduresCtrl.Designer.cs b/TBF/UI/Procedures/ProceduresCtrl.Designer.cs index e4b90a639..ea2dfbba4 100644 --- a/TBF/UI/Procedures/ProceduresCtrl.Designer.cs +++ b/TBF/UI/Procedures/ProceduresCtrl.Designer.cs @@ -38,6 +38,8 @@ this.q3ComboBox = new System.Windows.Forms.ComboBox(); this.dnComboBox = new System.Windows.Forms.ComboBox(); this.listViewEx = new Common.Forms.ListViewEx(); + this.profileLabel = new System.Windows.Forms.Label(); + this.profileComboBox = new System.Windows.Forms.ComboBox(); ((System.ComponentModel.ISupportInitialize)(this.filtersSplitContainer)).BeginInit(); this.filtersSplitContainer.Panel1.SuspendLayout(); this.filtersSplitContainer.Panel2.SuspendLayout(); @@ -54,6 +56,8 @@ // // filtersSplitContainer.Panel1 // + this.filtersSplitContainer.Panel1.Controls.Add(this.profileLabel); + this.filtersSplitContainer.Panel1.Controls.Add(this.profileComboBox); this.filtersSplitContainer.Panel1.Controls.Add(this.producerLabel); this.filtersSplitContainer.Panel1.Controls.Add(this.mclassLabel); this.filtersSplitContainer.Panel1.Controls.Add(this.q3Label); @@ -66,14 +70,14 @@ // filtersSplitContainer.Panel2 // this.filtersSplitContainer.Panel2.Controls.Add(this.listViewEx); - this.filtersSplitContainer.Size = new System.Drawing.Size(600, 400); + this.filtersSplitContainer.Size = new System.Drawing.Size(800, 400); this.filtersSplitContainer.SplitterDistance = 40; this.filtersSplitContainer.TabIndex = 2; // // producerLabel // this.producerLabel.AutoSize = true; - this.producerLabel.Location = new System.Drawing.Point(381, 15); + this.producerLabel.Location = new System.Drawing.Point(581, 15); this.producerLabel.Name = "producerLabel"; this.producerLabel.Size = new System.Drawing.Size(50, 13); this.producerLabel.TabIndex = 7; @@ -82,7 +86,7 @@ // mclassLabel // this.mclassLabel.AutoSize = true; - this.mclassLabel.Location = new System.Drawing.Point(257, 15); + this.mclassLabel.Location = new System.Drawing.Point(457, 15); this.mclassLabel.Name = "mclassLabel"; this.mclassLabel.Size = new System.Drawing.Size(32, 13); this.mclassLabel.TabIndex = 6; @@ -91,7 +95,7 @@ // q3Label // this.q3Label.AutoSize = true; - this.q3Label.Location = new System.Drawing.Point(125, 15); + this.q3Label.Location = new System.Drawing.Point(325, 15); this.q3Label.Name = "q3Label"; this.q3Label.Size = new System.Drawing.Size(40, 13); this.q3Label.TabIndex = 5; @@ -100,7 +104,7 @@ // dnLabel // this.dnLabel.AutoSize = true; - this.dnLabel.Location = new System.Drawing.Point(12, 15); + this.dnLabel.Location = new System.Drawing.Point(212, 15); this.dnLabel.Name = "dnLabel"; this.dnLabel.Size = new System.Drawing.Size(23, 13); this.dnLabel.TabIndex = 4; @@ -109,7 +113,7 @@ // producerComboBox // this.producerComboBox.FormattingEnabled = true; - this.producerComboBox.Location = new System.Drawing.Point(437, 12); + this.producerComboBox.Location = new System.Drawing.Point(637, 12); this.producerComboBox.Name = "producerComboBox"; this.producerComboBox.Size = new System.Drawing.Size(133, 21); this.producerComboBox.TabIndex = 3; @@ -119,7 +123,7 @@ // mclassComboBox // this.mclassComboBox.FormattingEnabled = true; - this.mclassComboBox.Location = new System.Drawing.Point(295, 12); + this.mclassComboBox.Location = new System.Drawing.Point(495, 12); this.mclassComboBox.Name = "mclassComboBox"; this.mclassComboBox.Size = new System.Drawing.Size(72, 21); this.mclassComboBox.TabIndex = 2; @@ -129,7 +133,7 @@ // q3ComboBox // this.q3ComboBox.FormattingEnabled = true; - this.q3ComboBox.Location = new System.Drawing.Point(171, 12); + this.q3ComboBox.Location = new System.Drawing.Point(371, 12); this.q3ComboBox.Name = "q3ComboBox"; this.q3ComboBox.Size = new System.Drawing.Size(72, 21); this.q3ComboBox.TabIndex = 1; @@ -139,7 +143,7 @@ // dnComboBox // this.dnComboBox.FormattingEnabled = true; - this.dnComboBox.Location = new System.Drawing.Point(41, 12); + this.dnComboBox.Location = new System.Drawing.Point(241, 12); this.dnComboBox.Name = "dnComboBox"; this.dnComboBox.Size = new System.Drawing.Size(72, 21); this.dnComboBox.TabIndex = 0; @@ -155,7 +159,7 @@ this.listViewEx.GridLines = true; this.listViewEx.Location = new System.Drawing.Point(0, 0); this.listViewEx.Name = "listViewEx"; - this.listViewEx.Size = new System.Drawing.Size(600, 356); + this.listViewEx.Size = new System.Drawing.Size(800, 356); this.listViewEx.TabIndex = 0; this.listViewEx.UseCompatibleStateImageBehavior = false; this.listViewEx.View = System.Windows.Forms.View.Details; @@ -163,13 +167,32 @@ this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged); this.listViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewEx_MouseDoubleClick); // + // profileLabel + // + this.profileLabel.AutoSize = true; + this.profileLabel.Location = new System.Drawing.Point(12, 15); + this.profileLabel.Name = "profileLabel"; + this.profileLabel.Size = new System.Drawing.Size(36, 13); + this.profileLabel.TabIndex = 9; + this.profileLabel.Text = "Profile"; + // + // profileComboBox + // + this.profileComboBox.FormattingEnabled = true; + this.profileComboBox.Location = new System.Drawing.Point(68, 12); + this.profileComboBox.Name = "profileComboBox"; + this.profileComboBox.Size = new System.Drawing.Size(133, 21); + this.profileComboBox.TabIndex = 8; + this.profileComboBox.SelectedIndexChanged += new System.EventHandler(this.profileComboBox_SelectedIndexChanged); + this.profileComboBox.TextChanged += new System.EventHandler(this.profileComboBox_TextChanged); + // // ProceduresCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.filtersSplitContainer); this.Name = "ProceduresCtrl"; - this.Size = new System.Drawing.Size(600, 400); + this.Size = new System.Drawing.Size(800, 400); this.filtersSplitContainer.Panel1.ResumeLayout(false); this.filtersSplitContainer.Panel1.PerformLayout(); this.filtersSplitContainer.Panel2.ResumeLayout(false); @@ -191,5 +214,7 @@ private System.Windows.Forms.ComboBox q3ComboBox; private System.Windows.Forms.ComboBox dnComboBox; private Common.Forms.ListViewEx listViewEx; + private System.Windows.Forms.Label profileLabel; + private System.Windows.Forms.ComboBox profileComboBox; } } diff --git a/TBF/UI/Procedures/ProceduresCtrl.cs b/TBF/UI/Procedures/ProceduresCtrl.cs index 670bd4e19..2c8008b5f 100644 --- a/TBF/UI/Procedures/ProceduresCtrl.cs +++ b/TBF/UI/Procedures/ProceduresCtrl.cs @@ -42,7 +42,7 @@ namespace TBF.UI.Procedures public bool Unlocked { get { return unlocked; } } /// read only bool unlocked; - + string selectedProfile; float selectedDN; float selectedQ3; string selectedMClass; @@ -77,21 +77,37 @@ namespace TBF.UI.Procedures errorFlagsCmpnt = null; ToBeRemovedProcedures = new List(); - dnComboBox.Text = Strings.any; - dnComboBox.Items.Add(Strings.any); + /// Profile + selectedProfile = null; + ComboBox cb = profileComboBox; + cb.Items.Add(Strings.any); + cb.Items.Add(Strings.no_profile); + cb.Items.Add(Strings.any_profile); + cb.Text = cb.Items[0].ToString(); + + /// DN selectedDN = 0; + cb = dnComboBox; + cb.Items.Add(Strings.any); + cb.Text = cb.Items[0].ToString(); - q3ComboBox.Text = Strings.any; - q3ComboBox.Items.Add(Strings.any); + /// Q3 / Qn selectedQ3 = 0; + cb = q3ComboBox; + cb.Items.Add(Strings.any); + cb.Text = cb.Items[0].ToString(); - mclassComboBox.Text = Strings.any; - mclassComboBox.Items.Add(Strings.any); + /// Metrological class selectedMClass = null; + cb = mclassComboBox; + cb.Items.Add(Strings.any); + cb.Text = cb.Items[0].ToString(); - producerComboBox.Text = Strings.any; - producerComboBox.Items.Add(Strings.any); + /// Producer selectedProducer = null; + cb = producerComboBox; + cb.Items.Add(Strings.any); + cb.Text = cb.Items[0].ToString(); moreContent = MoreContent.Description; } @@ -145,7 +161,7 @@ namespace TBF.UI.Procedures bool ReloadProcedures() { - bool isFirstTime = AllProcedures == null; + bool isFirstTime = (AllProcedures == null); try { @@ -183,6 +199,10 @@ namespace TBF.UI.Procedures if (isFirstTime) { + if (!string.IsNullOrEmpty(proc.AltProcName) && !profileComboBox.Items.Contains(proc.AltProcName)) + { + profileComboBox.Items.Add(proc.AltProcName); + } if (!dnComboBox.Items.Contains(wmParams.DN.ToString())) dnComboBox.Items.Add(wmParams.DN.ToString()); if (!q3ComboBox.Items.Contains(wmParams.Qn.ToString())) q3ComboBox.Items.Add(wmParams.Qn.ToString()); if (!mclassComboBox.Items.Contains(wmParams.MetrologicalClass)) mclassComboBox.Items.Add(wmParams.MetrologicalClass); @@ -219,10 +239,14 @@ namespace TBF.UI.Procedures { foreach (var proc in AllProcedures) { - if ((selectedDN == 0 || selectedDN == proc.DN) && + if ((selectedProfile == null || + (selectedProfile == Strings.no_profile && string.IsNullOrEmpty(proc.AltProcName)) || + (selectedProfile == Strings.any_profile && !string.IsNullOrEmpty(proc.AltProcName)) || + selectedProfile == proc.AltProcName) && + (selectedDN == 0 || selectedDN == proc.DN) && (selectedQ3 == 0 || selectedQ3 == proc.Qn) && - ((selectedMClass == null) || (selectedMClass == proc.MClass)) && - ((selectedProducer == null) || (selectedProducer == proc.Producer))) + (selectedMClass == null || selectedMClass == proc.MClass) && + (selectedProducer == null || selectedProducer == proc.Producer)) { Procedures.Add(proc); } @@ -331,7 +355,9 @@ namespace TBF.UI.Procedures catch (Exception exc) { transaction.Rollback(); - log.ErrorFormat("Exception when saving Procedure '{0}' : {1}", newProcedure.Name, exc.Message); + log.ErrorFormat("Could not save procedure '{0}':", newProcedure.Name); + log.ErrorFormat("Exception: {0}", exc.Message); + if (exc.InnerException != null) log.ErrorFormat("InnerException: {0}", exc.InnerException.Message); } } } @@ -566,8 +592,10 @@ namespace TBF.UI.Procedures } catch (Exception exc) { - log.ErrorFormat("Exception when saving Procedure '{0}' : {1}", modifiedProcedure.Name, exc.Message); - transaction.Rollback(); + log.ErrorFormat("Could not save procedure '{0}':", modifiedProcedure.Name); + log.ErrorFormat("Exception: {0}", exc.Message); + if (exc.InnerException != null) log.ErrorFormat("InnerException: {0}", exc.InnerException.Message); + transaction.Rollback(); } } session.Flush(); @@ -694,10 +722,18 @@ namespace TBF.UI.Procedures public void CreateFromProfile() { IList profiles; + IList fPaths; + IList bPaths; + IList oPaths; try { - profiles = session.QueryOver().List(); + profiles = session.QueryOver() + .OrderBy(x => x.ItemNr).Asc + .List(); + fPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + bPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + oPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); } catch (Exception) { @@ -706,7 +742,7 @@ namespace TBF.UI.Procedures return; } - TestWizard.TestProfileSelection dlg = new TestWizard.TestProfileSelection(profiles); + TestWizard.TestProfileSelection dlg = new TestWizard.TestProfileSelection(profiles, fPaths, bPaths, oPaths); if (dlg.ShowDialog() != DialogResult.OK) return; /// Find an unused procedure name @@ -740,10 +776,10 @@ namespace TBF.UI.Procedures if (wmParams != null) { wmParams.NewQnames = (pt == ProfileType.Q3R); - wmParams.Qmax = (float)((pt == ProfileType.Manual) ? 0 : Common.Utils.GetQ4Qmax(dlg.Qn, dlg.MetroClass, medium)); + wmParams.Qmax = (float)((pt == ProfileType.Manual) ? 0 : Formulas.GetQ4Qmax(dlg.Qn, dlg.MetroClass, medium)); wmParams.Qn = (float)dlg.Qn; - wmParams.Qt = (float)((pt == ProfileType.Manual) ? 0 : (pt == ProfileType.QpQi) ? (0.1 * dlg.Qn) : Common.Utils.GetQ2Qt(dlg.Qn, dlg.MetroClass, medium)); - wmParams.Qmin = (float)((pt == ProfileType.Manual) ? 0 : (pt == ProfileType.QpQi) ? dlg.Qn / dlg.QpQiRatio : Common.Utils.GetQ1Qmin(dlg.Qn, dlg.MetroClass, medium)); + wmParams.Qt = (float)((pt == ProfileType.Manual) ? 0 : (pt == ProfileType.QpQi) ? (0.1 * dlg.Qn) : Formulas.GetQ2Qt(dlg.Qn, dlg.MetroClass, medium)); + wmParams.Qmin = (float)((pt == ProfileType.Manual) ? 0 : (pt == ProfileType.QpQi) ? dlg.Qn / dlg.QpQiRatio : Formulas.GetQ1Qmin(dlg.Qn, dlg.MetroClass, medium)); wmParams.MetrologicalClass = dlg.MetroClass; wmParams.WaterTemp = medium; } @@ -752,63 +788,10 @@ namespace TBF.UI.Procedures } } - - int itemNr = 0; - foreach (var ptest in dlg.SelectedProfile.Tests) + for (int i = 0; i < dlg.SelectedTests.Count; i++ ) { - double Qtg; - if (ptest.Name.Contains("Q4") || ptest.Name.Contains("Qmax")) - { - Qtg = Common.Utils.GetQ4Qmax(dlg.Qn, dlg.MetroClass, medium, ptest.CoefQto); - } - else if (ptest.Name.Contains("Q3") || ptest.Name.Contains("Qn") || ptest.Name.Equals("qp")) - { - Qtg = dlg.Qn; - } - else if (ptest.Name.Contains("Q2") || ptest.Name.Contains("Qt")) - { - Qtg = Common.Utils.GetQ2Qt(dlg.Qn, dlg.MetroClass, medium, ptest.CoefQto); - } - else if (ptest.Name.Contains("Q1") || ptest.Name.Contains("Qmin")) - { - Qtg = Common.Utils.GetQ1Qmin(dlg.Qn, dlg.MetroClass, medium, ptest.CoefQto); - } - else if (ptest.Name.Contains("0,1qp") || ptest.Name.Contains("0.1qp")) - { - Qtg = 0.1 * dlg.Qn; - } - else if (ptest.Name.Contains("qi")) - { - Qtg = dlg.Qn / dlg.QpQiRatio; - } - else - { - Qtg = dlg.Qn; /// Manual flow selection: CoefQfrom and CoefQto are used to calculate Qfrom and Qto from Qn - } - - Test test = new Test(ptest.Name, itemNr++, newProcedure); - test.Part = ptest.Part; - test.Profile = (pt == ProfileType.QpQi) ? TestProfile.ProtectedHeatMeter : TestProfile.Protected; - test.Qtg = (float)Qtg; - test.Qfrom = (float)(Qtg * ptest.CoefQfrom); - test.Qto = (float)(Qtg * ptest.CoefQto); - test.TempLimLo = (float)ptest.TempLimLo; - test.TempLimHi = (float)ptest.TempLimHi; - test.Publish = ptest.Publish; - test.DoEvaluate = ptest.Evaluate; - - if (pt != ProfileType.QpQi) - { - test.ErrLimLo = (float)ptest.ErrLimLo; - test.ErrLimHi = (float)ptest.ErrLimHi; - } - else - { - int metroClass; - if (int.TryParse(dlg.MetroClass, out metroClass)) test.ErrLimLo = (float)metroClass; - test.ErrLimHi = -(float)dlg.Qn; - } - + Test test = dlg.SelectedTests[i]; + test.Procedure = newProcedure; newProcedure.Tests.Add(test); if (errorFlagsCmpnt != null) @@ -818,39 +801,38 @@ namespace TBF.UI.Procedures TBF.Rig.Various.ErrorFlags.TestParams eFlagParams = errorFlagsParams as TBF.Rig.Various.ErrorFlags.TestParams; if (eFlagParams != null) { - eFlagParams.E1 = ptest.E1; - eFlagParams.E2 = ptest.E2; - eFlagParams.E3 = ptest.E3; - eFlagParams.E4 = ptest.E4; - eFlagParams.E5 = ptest.E5; - eFlagParams.E6 = ptest.E6; - eFlagParams.E7 = ptest.E7; - eFlagParams.E8 = ptest.E8; - eFlagParams.E9 = ptest.E9; - eFlagParams.E10 = ptest.E10; - eFlagParams.E11 = ptest.E11; - eFlagParams.E12 = ptest.E12; - eFlagParams.E13 = ptest.E13; - eFlagParams.E14 = ptest.E14; - eFlagParams.E15 = ptest.E15; - eFlagParams.E16 = ptest.E16; - eFlagParams.E21 = ptest.E21; - - eFlagParams.Delta_Q_pct = ptest.Delta_Q_pct; - eFlagParams.Delta_T = ptest.Delta_T; - eFlagParams.Delta_Tup_Tdn = ptest.Delta_Tup_Tdn; - eFlagParams.TestTime_min = ptest.TestTime_min; - eFlagParams.TestTime_max = ptest.TestTime_max; - eFlagParams.AmbTemp_min = ptest.AmbTemp_min; - eFlagParams.AmbTemp_max = ptest.AmbTemp_max; - eFlagParams.Pressure_min = ptest.PressLimLo; - eFlagParams.Pressure_max = ptest.PressLimHi; - eFlagParams.Coef_E9 = ptest.Coef_E9; - eFlagParams.Coef_E10 = ptest.Coef_E10; - eFlagParams.Coef_E11 = ptest.Coef_E11; - eFlagParams.Coef_E12 = ptest.Coef_E12; - eFlagParams.Offset_E9 = ptest.Offset_E9; - eFlagParams.Offset_E12 = ptest.Offset_E12; + eFlagParams.E1 = dlg.SelectedProfile.Tests[i].E1; + eFlagParams.E2 = dlg.SelectedProfile.Tests[i].E2; + eFlagParams.E3 = dlg.SelectedProfile.Tests[i].E3; + eFlagParams.E4 = dlg.SelectedProfile.Tests[i].E4; + eFlagParams.E5 = dlg.SelectedProfile.Tests[i].E5; + eFlagParams.E6 = dlg.SelectedProfile.Tests[i].E6; + eFlagParams.E7 = dlg.SelectedProfile.Tests[i].E7; + eFlagParams.E8 = dlg.SelectedProfile.Tests[i].E8; + eFlagParams.E9 = dlg.SelectedProfile.Tests[i].E9; + eFlagParams.E10 = dlg.SelectedProfile.Tests[i].E10; + eFlagParams.E11 = dlg.SelectedProfile.Tests[i].E11; + eFlagParams.E12 = dlg.SelectedProfile.Tests[i].E12; + eFlagParams.E13 = dlg.SelectedProfile.Tests[i].E13; + eFlagParams.E14 = dlg.SelectedProfile.Tests[i].E14; + eFlagParams.E15 = dlg.SelectedProfile.Tests[i].E15; + eFlagParams.E16 = dlg.SelectedProfile.Tests[i].E16; + eFlagParams.E21 = dlg.SelectedProfile.Tests[i].E21; + eFlagParams.Delta_Q_pct = dlg.SelectedProfile.Tests[i].Delta_Q_pct; + eFlagParams.Delta_T = dlg.SelectedProfile.Tests[i].Delta_T; + eFlagParams.Delta_Tup_Tdn = dlg.SelectedProfile.Tests[i].Delta_Tup_Tdn; + eFlagParams.TestTime_min = dlg.SelectedProfile.Tests[i].TestTime_min; + eFlagParams.TestTime_max = dlg.SelectedProfile.Tests[i].TestTime_max; + eFlagParams.AmbTemp_min = dlg.SelectedProfile.Tests[i].AmbTemp_min; + eFlagParams.AmbTemp_max = dlg.SelectedProfile.Tests[i].AmbTemp_max; + eFlagParams.Pressure_min = dlg.SelectedProfile.Tests[i].PressLimLo; + eFlagParams.Pressure_max = dlg.SelectedProfile.Tests[i].PressLimHi; + eFlagParams.Coef_E9 = dlg.SelectedProfile.Tests[i].Coef_E9; + eFlagParams.Coef_E10 = dlg.SelectedProfile.Tests[i].Coef_E10; + eFlagParams.Coef_E11 = dlg.SelectedProfile.Tests[i].Coef_E11; + eFlagParams.Coef_E12 = dlg.SelectedProfile.Tests[i].Coef_E12; + eFlagParams.Offset_E9 = dlg.SelectedProfile.Tests[i].Offset_E9; + eFlagParams.Offset_E12 = dlg.SelectedProfile.Tests[i].Offset_E12; } errorFlagsParamsOfCreatedTests.Add(errorFlagsParams); @@ -895,7 +877,9 @@ namespace TBF.UI.Procedures catch (Exception exc) { transaction.Rollback(); - log.ErrorFormat("Exception when saving Procedure '{0}' : {1}", newProcedure.Name, exc.Message); + log.ErrorFormat("Could not save procedure '{0}':", newProcedure.Name); + log.ErrorFormat("Exception: {0}", exc.Message); + if (exc.InnerException != null) log.ErrorFormat("InnerException: {0}", exc.InnerException.Message); } } } @@ -927,6 +911,17 @@ namespace TBF.UI.Procedures return usedNames; } + private void profileComboBox_SelectedIndexChanged(object sender, EventArgs e) { UpdateSelectedProfile(); } + private void profileComboBox_TextChanged(object sender, EventArgs e) { UpdateSelectedProfile(); } + /// + void UpdateSelectedProfile() + { + //selectedProfile = ... TODO + selectedProfile = (profileComboBox.Text != Strings.any) ? profileComboBox.Text : null; + RedrawAll(); + listViewEx_SelectedIndexChanged(null, null); + } + private void dnComboBox_SelectedIndexChanged(object sender, EventArgs e) { UpdateSelectedDN(); } private void dnComboBox_TextChanged(object sender, EventArgs e) { UpdateSelectedDN(); } /// @@ -971,7 +966,7 @@ namespace TBF.UI.Procedures private void listViewEx_SelectedIndexChanged(object sender, EventArgs e) { - bool isFilterAny = (selectedDN == 0) && (selectedQ3 == 0) && (selectedMClass == null) && (selectedProducer == null); + bool isFilterAny = (selectedProfile == null) && (selectedDN == 0) && (selectedQ3 == 0) && (selectedMClass == null) && (selectedProducer == null); if (parent != null) parent.SelectedIndexChanged(listViewEx, isFilterAny); } @@ -986,6 +981,7 @@ namespace TBF.UI.Procedures Tests, Writers, Printers, + Profile, #if ORACLE_DB Oracle, #endif @@ -1015,6 +1011,9 @@ namespace TBF.UI.Procedures case MoreContent.Printers: listViewEx.Columns[(int)Column.More].Text = "Printers"; break; + case MoreContent.Profile: + listViewEx.Columns[(int)Column.More].Text = "Profile"; + break; #if ORACLE_DB case MoreContent.Oracle: listViewEx.Columns[(int)Column.More].Text = "Oracle"; @@ -1081,6 +1080,10 @@ namespace TBF.UI.Procedures foreach (var p in printers) { sb.Append(p); sb.Append(" "); } } break; + + case MoreContent.Profile: + return string.IsNullOrEmpty(procedure.AltProcName) ? string.Empty : procedure.AltProcName; + #if ORACLE_DB case MoreContent.Oracle: if (!string.IsNullOrEmpty(procedure.ResultsWriter) && procedure.ResultsWriter.Contains("Sensus-Oracle-DB")) diff --git a/TBF/UI/Procedures/ProceduresDlg.cs b/TBF/UI/Procedures/ProceduresDlg.cs index 1d6206577..b40fe4748 100644 --- a/TBF/UI/Procedures/ProceduresDlg.cs +++ b/TBF/UI/Procedures/ProceduresDlg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2020 Sensus Slovensko a.s. +/// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// using System; using System.Windows.Forms; @@ -28,7 +28,6 @@ namespace TBF.UI.Procedures sharedButtons.ParentForm = this; sharedButtons.RequiredGroupMembership = new GID[] { GID.TestingSpecialists, GID.Metrologists }; -#if TEST_PROFILES sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down | SharedButtons.Buttons.Edit | SharedButtons.Buttons.Copy | @@ -36,13 +35,12 @@ namespace TBF.UI.Procedures SharedButtons.Buttons.Compare |SharedButtons.Buttons.Custom1; sharedButtons.Custom1Caption = string.Format("Create from{0}test profiles", Environment.NewLine); sharedButtons.Custom1Clicked += custom1Button_Click; -#else - sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove | - SharedButtons.Buttons.Up | SharedButtons.Buttons.Down | - SharedButtons.Buttons.Edit | SharedButtons.Buttons.Copy | - SharedButtons.Buttons.Export | SharedButtons.Buttons.Import | - SharedButtons.Buttons.Compare; -#endif + + //sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove | + // SharedButtons.Buttons.Up | SharedButtons.Buttons.Down | + // SharedButtons.Buttons.Edit | SharedButtons.Buttons.Copy | + // SharedButtons.Buttons.Export | SharedButtons.Buttons.Import | + // SharedButtons.Buttons.Compare; sharedButtons.Unlocked += Unlocked; sharedButtons.OKClicked += okButton_Click; @@ -84,10 +82,8 @@ namespace TBF.UI.Procedures } /// - /// "OK" button and Windows 'x' buttom functions similarly r + /// "OK" button and Windows 'x' buttom functions similarly /// - /// - /// private void okButton_Click(object sender, EventArgs e) { ProceduresDlg_FormClosed(sender, null); @@ -191,7 +187,7 @@ namespace TBF.UI.Procedures /// public void SelectedIndexChanged(ListView sender, bool isFilterAny) { - Common.Forms.ListViewEx listViewEx = sender as Common.Forms.ListViewEx; + var listViewEx = sender as Common.Forms.ListViewEx; if (listViewEx.SelectedItems.Count != 1) { /// No item selected diff --git a/TBF/UI/Procedures/TestWizard/TestProfileSelection.cs b/TBF/UI/Procedures/TestWizard/TestProfileSelection.cs index 2300bb180..0fff3959c 100644 --- a/TBF/UI/Procedures/TestWizard/TestProfileSelection.cs +++ b/TBF/UI/Procedures/TestWizard/TestProfileSelection.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2022 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -7,6 +7,7 @@ using System.Text; using System.Windows.Forms; using log4net; using Common; +using Common.Forms; using Config.Entities; using TBF.Rig.GenericDevices; using TBF.Resources; @@ -17,26 +18,66 @@ namespace TBF.UI.Procedures.TestWizard { static readonly ILog log = LogManager.GetLogger(typeof(TestProfileSelection)); + const int NameColumn = 0; + const int SelectorColumn = 5; + const string EmptySelector = "---"; + IList profiles; + IList fPaths; + IList bPaths; + IList oPaths; public Profile SelectedProfile; + public IList SelectedTests; public double Qn; public string MetroClass; public double QpQiRatio; - public TestProfileSelection(IList profiles) + IList selectorVals; /// Empty string or null (which is permitted) is not part of this list + TextBox testNameTextBox; + ComboBox selectorComboBox; + + public TestProfileSelection(IList profiles, + IList fPaths, + IList bPaths, + IList oPaths) { this.profiles = profiles; + this.fPaths = fPaths; + this.bPaths = bPaths; + this.oPaths = oPaths; InitializeComponent(); - listView.Columns.Add(Strings.Name, 70); - listView.Columns.Add(Strings.Part, 40); - listView.Columns.Add(string.Format("{0} [m3/h]", Strings.Q_tg), 80); - listView.Columns.Add(string.Format("{0} [m3/h]", Strings.Q_from), 80); - listView.Columns.Add(string.Format("{0} [m3/h]", Strings.Q_to), 70); - listView.Columns.Add(Strings.Err_limit_neg_pct_chdr, 80); - listView.Columns.Add(Strings.Err_limit_pos_pct_chdr, 80); + /// Find possible selector values + selectorVals = new List(); + foreach (var p in fPaths) if (!string.IsNullOrEmpty(p.Selector) && !selectorVals.Contains(p.Selector)) selectorVals.Add(p.Selector); + foreach (var p in bPaths) if (!string.IsNullOrEmpty(p.Selector) && !selectorVals.Contains(p.Selector)) selectorVals.Add(p.Selector); + foreach (var p in oPaths) if (!string.IsNullOrEmpty(p.Selector) && !selectorVals.Contains(p.Selector)) selectorVals.Add(p.Selector); + + testNameTextBox = new TextBox(); + testNameTextBox.Visible = false; + this.Controls.Add(testNameTextBox); + + selectorComboBox = new ComboBox(); + selectorComboBox.Visible = false; + selectorComboBox.Items.Add(EmptySelector); + foreach (var s in selectorVals) selectorComboBox.Items.Add(s); + this.Controls.Add(selectorComboBox); + + /// ListViewEx-es configuration + listViewEx.Columns.Add(Strings.Name, 70); + listViewEx.Columns.Add(Strings.Part, 40); + listViewEx.Columns.Add(string.Format("{0} [m3/h]", Strings.Q_tg), 80); + listViewEx.Columns.Add(string.Format("{0} [m3/h]", Strings.Q_from), 80); + listViewEx.Columns.Add(string.Format("{0} [m3/h]", Strings.Q_to), 70); + listViewEx.Columns.Add("Selector"); + listViewEx.Columns.Add(Strings.Err_limit_neg_pct_chdr, 80); + listViewEx.Columns.Add(Strings.Err_limit_pos_pct_chdr, 80); + listViewEx.Columns.Add(Strings.Method_chdr, 150); + + listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked); + listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing); if (profiles != null) { @@ -45,6 +86,7 @@ namespace TBF.UI.Procedures.TestWizard foreach (var s in new string[] { "10", "25", "50", "100", "250" }) qpQiRatioComboBox.Items.Add(s); + SelectedTests = new List(); nextButton.Enabled = false; } @@ -119,73 +161,76 @@ namespace TBF.UI.Procedures.TestWizard void RedrawPTests(Profile profile) { - listView.Items.Clear(); + SelectedTests.Clear(); + listViewEx.Items.Clear(); if (profile == null) return; try { + int itemNr = 0; foreach (var ptest in profile.Tests) { Medium medium = (profile.ProfileType == ProfileType.QnClassHotWater) ? Medium.HotWater : Medium.ColdWater; - double Qtg; - if (ptest.Name.Contains("Q4") || ptest.Name.Contains("Qmax")) + double Qtg = TBF.UI.Procedures.Formulas.GetTargetQ(ptest, Qn, QpQiRatio, MetroClass, medium); + + Test test = new Test(ptest.Name, itemNr++, null); /// Procedure reference to be added later + test.Part = ptest.Part; + test.Profile = (profile.ProfileType == ProfileType.QpQi) ? TestProfile.ProtectedHeatMeter : TestProfile.Protected; + test.Qtg = Convert.ToSingle(Qtg); + test.Qfrom = Convert.ToSingle(Qtg * ptest.CoefQfrom); + test.Qto = Convert.ToSingle(Qtg * ptest.CoefQto); + test.TempLimLo = Convert.ToSingle(ptest.TempLimLo); + test.TempLimHi = Convert.ToSingle(ptest.TempLimHi); + test.Publish = ptest.Publish; + test.DoEvaluate = ptest.Evaluate; + test.Method = (ptest.Method != null) ? ptest.Method : string.Empty; + + if (profile.ProfileType != ProfileType.QpQi) { - Qtg = Common.Utils.GetQ4Qmax(Qn, MetroClass, medium, ptest.CoefQto); - } - else if (ptest.Name.Contains("Q3") || ptest.Name.Contains("Qn") || ptest.Name.Equals("qp")) - { - Qtg = Qn; - } - else if (ptest.Name.Contains("Q2") || ptest.Name.Contains("Qt")) - { - Qtg = Common.Utils.GetQ2Qt(Qn, MetroClass, medium, ptest.CoefQto); - } - else if (ptest.Name.Contains("Q1") || ptest.Name.Contains("Qmin")) - { - Qtg = Common.Utils.GetQ1Qmin(Qn, MetroClass, medium, ptest.CoefQto); - } - else if (ptest.Name.Contains("0,1qp") || ptest.Name.Contains("0.1qp")) - { - Qtg = 0.1 * Qn; - } - else if (ptest.Name.Contains("qi")) - { - Qtg = Qn / QpQiRatio; + test.ErrLimLo = Convert.ToSingle(ptest.ErrLimLo); + test.ErrLimHi = Convert.ToSingle(ptest.ErrLimHi); } else { - Qtg = Qn; /// Manual flow selection: CoefQfrom and CoefQto are used to calculate Qfrom and Qto from Qn + int metroClass; + if (int.TryParse(MetroClass, out metroClass)) + { + test.ErrLimLo = Convert.ToSingle(metroClass); + } + test.ErrLimHi = -Convert.ToSingle(Qn); } - double Qfrom = Qtg * ptest.CoefQfrom; - double Qto = Qtg * ptest.CoefQto; - ListViewItem lvi; if (profile.ProfileType != ProfileType.QpQi) { lvi = new ListViewItem(new string[] { ptest.Name, (ptest.Part > 0) ? ptest.Part.ToString() : "-", Qtg.ToString(), - Qfrom.ToString(), - Qto.ToString(), + test.Qfrom.ToString(), + test.Qto.ToString(), + EmptySelector, ptest.ErrLimLo.ToString(), - ptest.ErrLimHi.ToString() }); + ptest.ErrLimHi.ToString(), + ptest.Method != null ? ptest.Method : string.Empty }); } else { lvi = new ListViewItem(new string[] { ptest.Name, (ptest.Part > 0) ? ptest.Part.ToString() : "-", Qtg.ToString(), - Qfrom.ToString(), - Qto.ToString(), + test.Qfrom.ToString(), + test.Qto.ToString(), + EmptySelector, Strings.calculated, - Strings.calculated }); + Strings.calculated, + ptest.Method != null ? ptest.Method : string.Empty }); } - lvi.Tag = ptest; - listView.Items.Add(lvi); + lvi.Tag = test; + listViewEx.Items.Add(lvi); + SelectedTests.Add(test); } } catch (Exception) @@ -232,7 +277,8 @@ namespace TBF.UI.Procedures.TestWizard } } - private void qnComboBox_SelectedIndexChanged(object sender, EventArgs e) + + private void qnTextBox_TextChanged(object sender, EventArgs e) { if (IsFormValid()) { @@ -335,10 +381,97 @@ namespace TBF.UI.Procedures.TestWizard return IsProfileValid() && IsQnValid() && IsMetroClassValid() && IsQpQiRatioValid(); } + private void listViewEx_SubItemClicked(object sender, SubItemEventArgs e) + { + if (e.SubItem == NameColumn) + { + listViewEx.StartEditing(testNameTextBox, e.Item, e.SubItem); + } + else if (e.SubItem == SelectorColumn) + { + listViewEx.StartEditing(selectorComboBox, e.Item, e.SubItem); + } + } + + private void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) + { + Test test = e.Item.Tag as Test; + + if (e.SubItem == NameColumn) + { + foreach (var item in listViewEx.Items) + { + var lvi = item as ListViewItem; + if (lvi != null && lvi != e.Item && (lvi.Tag is Test) && (lvi.Tag as Test).Name == e.DisplayText) + { + /// Test name was not unique, revert to the original one + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + return; + } + } + + /// OK + test.Name = e.DisplayText; + } + else if (e.SubItem == SelectorColumn) + { + if (!selectorComboBox.Items.Contains(e.DisplayText)) + { + /// Test name was not unique, revert to the original one + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + return; + } + + + } + } + private void nextButton_Click(object sender, EventArgs e) { if (IsFormValid()) { + foreach (var item in listViewEx.Items) + { + var lvi = item as ListViewItem; + string selector = (lvi.SubItems[SelectorColumn].Text == EmptySelector) ? string.Empty : lvi.SubItems[SelectorColumn].Text; + Test test = lvi.Tag as Test; + + if (test != null) + { + /// Depending on the chosen Q select the paths + double Qaver = (test.Qfrom + test.Qto) / 2.0; + foreach (var path in fPaths) + { + if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && + (string.IsNullOrEmpty(selector) || string.IsNullOrEmpty(path.Selector) || path.Selector == selector)) + { + test.FeedingPath = path.Name; + break; + } + } + foreach (var path in bPaths) + { + if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && + (string.IsNullOrEmpty(selector) || string.IsNullOrEmpty(path.Selector) || path.Selector == selector)) + { + test.BenchPath = path.Name; + break; + } + } + foreach (var path in oPaths) + { + if ((path.Qfrom <= Qaver) && (Qaver <= path.Qto) && + (string.IsNullOrEmpty(selector) || string.IsNullOrEmpty(path.Selector) || path.Selector == selector)) + { + test.OutputPath = path.Name; + break; + } + } + } + } + DialogResult = DialogResult.OK; Close(); } diff --git a/TBF/UI/Procedures/TestWizard/TestProfileSelection.designer.cs b/TBF/UI/Procedures/TestWizard/TestProfileSelection.designer.cs index 881cb9468..cedca9105 100644 --- a/TBF/UI/Procedures/TestWizard/TestProfileSelection.designer.cs +++ b/TBF/UI/Procedures/TestWizard/TestProfileSelection.designer.cs @@ -40,13 +40,13 @@ namespace TBF.UI.Procedures.TestWizard this.profileDescriptionLabel = new System.Windows.Forms.Label(); this.profileComboBox = new System.Windows.Forms.ComboBox(); this.qnGroupBox = new System.Windows.Forms.GroupBox(); + this.qnTextBox = new System.Windows.Forms.TextBox(); this.qnLabel = new System.Windows.Forms.Label(); this.metroClassGroupBox = new System.Windows.Forms.GroupBox(); this.metroClassComboBox = new System.Windows.Forms.ComboBox(); - this.listView = new System.Windows.Forms.ListView(); + this.listViewEx = new Common.Forms.ListViewEx(); this.cancelButton = new System.Windows.Forms.Button(); this.nextButton = new System.Windows.Forms.Button(); - this.qnTextBox = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit(); this.horizSplitContainer.Panel1.SuspendLayout(); this.horizSplitContainer.Panel2.SuspendLayout(); @@ -99,7 +99,7 @@ namespace TBF.UI.Procedures.TestWizard // // horizSplitContainer2.Panel2 // - this.horizSplitContainer2.Panel2.Controls.Add(this.listView); + this.horizSplitContainer2.Panel2.Controls.Add(this.listViewEx); this.horizSplitContainer2.Size = new System.Drawing.Size(850, 283); this.horizSplitContainer2.SplitterDistance = 115; this.horizSplitContainer2.TabIndex = 0; @@ -174,6 +174,14 @@ namespace TBF.UI.Procedures.TestWizard this.qnGroupBox.TabStop = false; this.qnGroupBox.Text = "2. Nominal flow"; // + // qnTextBox + // + this.qnTextBox.Location = new System.Drawing.Point(50, 22); + this.qnTextBox.Name = "qnTextBox"; + this.qnTextBox.Size = new System.Drawing.Size(82, 20); + this.qnTextBox.TabIndex = 11; + this.qnTextBox.TextChanged += new System.EventHandler(this.qnTextBox_TextChanged); + // // qnLabel // this.qnLabel.AutoSize = true; @@ -204,14 +212,14 @@ namespace TBF.UI.Procedures.TestWizard // // listView // - this.listView.Dock = System.Windows.Forms.DockStyle.Fill; - this.listView.GridLines = true; - this.listView.Location = new System.Drawing.Point(0, 0); - this.listView.Name = "listView"; - this.listView.Size = new System.Drawing.Size(850, 164); - this.listView.TabIndex = 0; - this.listView.UseCompatibleStateImageBehavior = false; - this.listView.View = System.Windows.Forms.View.Details; + this.listViewEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewEx.GridLines = true; + this.listViewEx.Location = new System.Drawing.Point(0, 0); + this.listViewEx.Name = "listView"; + this.listViewEx.Size = new System.Drawing.Size(850, 164); + this.listViewEx.TabIndex = 0; + this.listViewEx.UseCompatibleStateImageBehavior = false; + this.listViewEx.View = System.Windows.Forms.View.Details; // // cancelButton // @@ -235,13 +243,6 @@ namespace TBF.UI.Procedures.TestWizard this.nextButton.UseVisualStyleBackColor = true; this.nextButton.Click += new System.EventHandler(this.nextButton_Click); // - // qnTextBox - // - this.qnTextBox.Location = new System.Drawing.Point(50, 22); - this.qnTextBox.Name = "qnTextBox"; - this.qnTextBox.Size = new System.Drawing.Size(82, 20); - this.qnTextBox.TabIndex = 11; - // // TestProfileSelection // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -282,7 +283,7 @@ namespace TBF.UI.Procedures.TestWizard private System.Windows.Forms.GroupBox metroClassGroupBox; private System.Windows.Forms.GroupBox profileGroupBox; private System.Windows.Forms.ComboBox metroClassComboBox; - private System.Windows.Forms.ListView listView; + private Common.Forms.ListViewEx listViewEx; private System.Windows.Forms.Label profileDescriptionLabel; private System.Windows.Forms.Label profileTypeLabel; private System.Windows.Forms.GroupBox qpQiRatioGroupBox;