Profiles: Method added, imp./exp. fixed, Procedures: Selection by profile, Create from profile button, etc, ver. 3.5.1992

This commit is contained in:
Milan Hanajik 2022-11-23 07:59:05 +01:00
parent b54de856af
commit 6dcd40c640
20 changed files with 667 additions and 265 deletions

View File

@ -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); };

View File

@ -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)
{

View File

@ -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

View File

@ -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);

View File

@ -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")]

View File

@ -357,6 +357,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to any profile.
/// </summary>
internal static string any_profile {
get {
return ResourceManager.GetString("any_profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Approval.
/// </summary>
@ -3372,6 +3381,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to no profile.
/// </summary>
internal static string no_profile {
get {
return ResourceManager.GetString("no_profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No results to print.
/// </summary>

View File

@ -2389,4 +2389,10 @@
<data name="Wait_until" xml:space="preserve">
<value>Wait until</value>
</data>
<data name="any_profile" xml:space="preserve">
<value>any profile</value>
</data>
<data name="no_profile" xml:space="preserve">
<value>no profile</value>
</data>
</root>

View File

@ -242,6 +242,22 @@ namespace TBF.Rig
public static string CurrentlyLoadedComponentName;
/// <summary>
/// Load component entities from the database and convert them to TBF components
/// derived from IComponent with mutual references.
/// </summary>
/// <param name="session">NHibernate DB session</param>
/// <returns>A list of TBF Components</returns>
public static IList<IComponent> LoadComponentsFromDB(NHibernate.ISession session)
{
/// Load the list of components from the database
var cmptnEntities = session.QueryOver<Config.Entities.Component>()
.OrderBy(x => x.ItemNr).Asc
.List();
return LoadComponentsFromDB(cmptnEntities);
}
/// <summary>
/// Load component entities from the database and convert them to TBF components
/// derived from IComponent with mutual references.

View File

@ -2262,6 +2262,7 @@
<DependentUpon>MainWnd.cs</DependentUpon>
</Compile>
<Compile Include="UI\ProcedureInfo.cs" />
<Compile Include="UI\Procedures\Formulas.cs" />
<Compile Include="UI\Procedures\IProcParamsCtrl.cs" />
<Compile Include="UI\Procedures\ProcedureDlg.cs">
<SubType>Form</SubType>

View File

@ -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<Rig.Generic.IComponent> TbfComponents;
public IList<ITestMethod> TestMethods;
bool unlocked;
@ -54,6 +61,18 @@ namespace TBF.UI.Bench.TestProfiles
this.usedNames = usedNames;
this.openUnlocked = openUnlocked;
TestMethods = new List<ITestMethod>();
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))
{

View File

@ -733,10 +733,10 @@
<value>Fill</value>
</data>
<data name="metrologyListViewEx.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>0, 0</value>
</data>
<data name="metrologyListViewEx.Size" type="System.Drawing.Size, System.Drawing">
<value>917, 360</value>
<value>923, 366</value>
</data>
<data name="metrologyListViewEx.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -756,9 +756,6 @@
<data name="metrologyTabPage.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 34</value>
</data>
<data name="metrologyTabPage.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="metrologyTabPage.Size" type="System.Drawing.Size, System.Drawing">
<value>923, 366</value>
</data>
@ -928,7 +925,7 @@
<value>sharedButtons</value>
</data>
<data name="&gt;&gt;sharedButtons.Type" xml:space="preserve">
<value>TBF.UI.Shared.SharedButtons, TBF, Version=3.2.1913.0, Culture=neutral, PublicKeyToken=null</value>
<value>TBF.UI.Shared.SharedButtons, TBF, Version=3.4.1981.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;sharedButtons.Parent" xml:space="preserve">
<value>mainSplitContainer.Panel2</value>

View File

@ -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
/// <param name="listViewEx"></param>
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

View File

@ -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
}
}
/// <summary>
/// Get either Q1 or Qmin flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q1 or Qmin flow in m3/h</returns>
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;
}
/// <summary>
/// Get either Q2 or Qt flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q2 or Qt flow in m3/h</returns>
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;
}
/// <summary>
/// Get either Q4 or Qmax flow for a given Qn and metrological class
/// </summary>
/// <param name="Qn">Nominal flow in m3/h</param>
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
/// <returns>Q4 or Qmax flow in m3/h</returns>
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;
}
}
}
}

View File

@ -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<IComponent> other = new List<IComponent>();
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<string> selectorValues = new List<string>();
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;

View File

@ -1903,10 +1903,10 @@
<value>Fill</value>
</data>
<data name="historyListViewEx.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>0, 0</value>
</data>
<data name="historyListViewEx.Size" type="System.Drawing.Size, System.Drawing">
<value>917, 427</value>
<value>923, 433</value>
</data>
<data name="historyListViewEx.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -1915,7 +1915,7 @@
<value>historyListViewEx</value>
</data>
<data name="&gt;&gt;historyListViewEx.Type" xml:space="preserve">
<value>Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null</value>
<value>Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;historyListViewEx.Parent" xml:space="preserve">
<value>historyTabPage</value>
@ -1926,9 +1926,6 @@
<data name="historyTabPage.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 34</value>
</data>
<data name="historyTabPage.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="historyTabPage.Size" type="System.Drawing.Size, System.Drawing">
<value>923, 433</value>
</data>
@ -1954,10 +1951,10 @@
<value>Fill</value>
</data>
<data name="metrology1ListViewEx.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>0, 0</value>
</data>
<data name="metrology1ListViewEx.Size" type="System.Drawing.Size, System.Drawing">
<value>917, 427</value>
<value>923, 433</value>
</data>
<data name="metrology1ListViewEx.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -1966,7 +1963,7 @@
<value>metrology1ListViewEx</value>
</data>
<data name="&gt;&gt;metrology1ListViewEx.Type" xml:space="preserve">
<value>Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null</value>
<value>Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;metrology1ListViewEx.Parent" xml:space="preserve">
<value>metrology1TabPage</value>
@ -1977,9 +1974,6 @@
<data name="metrology1TabPage.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 34</value>
</data>
<data name="metrology1TabPage.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="metrology1TabPage.Size" type="System.Drawing.Size, System.Drawing">
<value>923, 433</value>
</data>
@ -2005,10 +1999,10 @@
<value>Fill</value>
</data>
<data name="metrology2ListViewEx.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>0, 0</value>
</data>
<data name="metrology2ListViewEx.Size" type="System.Drawing.Size, System.Drawing">
<value>917, 427</value>
<value>923, 433</value>
</data>
<data name="metrology2ListViewEx.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -2017,7 +2011,7 @@
<value>metrology2ListViewEx</value>
</data>
<data name="&gt;&gt;metrology2ListViewEx.Type" xml:space="preserve">
<value>Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null</value>
<value>Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;metrology2ListViewEx.Parent" xml:space="preserve">
<value>metrology2TabPage</value>
@ -2028,9 +2022,6 @@
<data name="metrology2TabPage.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 34</value>
</data>
<data name="metrology2TabPage.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="metrology2TabPage.Size" type="System.Drawing.Size, System.Drawing">
<value>923, 433</value>
</data>
@ -2056,10 +2047,10 @@
<value>Fill</value>
</data>
<data name="processListViewEx.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>0, 0</value>
</data>
<data name="processListViewEx.Size" type="System.Drawing.Size, System.Drawing">
<value>917, 427</value>
<value>923, 433</value>
</data>
<data name="processListViewEx.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -2068,7 +2059,7 @@
<value>processListViewEx</value>
</data>
<data name="&gt;&gt;processListViewEx.Type" xml:space="preserve">
<value>Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null</value>
<value>Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;processListViewEx.Parent" xml:space="preserve">
<value>processTabPage</value>
@ -2079,9 +2070,6 @@
<data name="processTabPage.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 34</value>
</data>
<data name="processTabPage.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="processTabPage.Size" type="System.Drawing.Size, System.Drawing">
<value>923, 433</value>
</data>
@ -2119,7 +2107,7 @@
<value>parametersListViewEx</value>
</data>
<data name="&gt;&gt;parametersListViewEx.Type" xml:space="preserve">
<value>Common.Forms.ListViewEx, Results, Version=3.1.1464.0, Culture=neutral, PublicKeyToken=null</value>
<value>Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;parametersListViewEx.Parent" xml:space="preserve">
<value>parametersTabPage</value>
@ -2203,7 +2191,7 @@
<value>sharedButtons</value>
</data>
<data name="&gt;&gt;sharedButtons.Type" xml:space="preserve">
<value>TBF.UI.Shared.SharedButtons, TBF, Version=3.1.1685.0, Culture=neutral, PublicKeyToken=null</value>
<value>TBF.UI.Shared.SharedButtons, TBF, Version=3.4.1981.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;sharedButtons.Parent" xml:space="preserve">
<value>mainSplitContainer.Panel2</value>

View File

@ -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;
}
}

View File

@ -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<Procedure>();
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<Profile> profiles;
IList<FeedingPath> fPaths;
IList<BenchPath> bPaths;
IList<OutputPath> oPaths;
try
{
profiles = session.QueryOver<Profile>().List();
profiles = session.QueryOver<Profile>()
.OrderBy(x => x.ItemNr).Asc
.List();
fPaths = session.QueryOver<FeedingPath>().OrderBy(x => x.ItemNr).Asc.List();
bPaths = session.QueryOver<BenchPath>().OrderBy(x => x.ItemNr).Asc.List();
oPaths = session.QueryOver<OutputPath>().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"))

View File

@ -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
}
/// <summary>
/// "OK" button and Windows 'x' buttom functions similarly r
/// "OK" button and Windows 'x' buttom functions similarly
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void okButton_Click(object sender, EventArgs e)
{
ProceduresDlg_FormClosed(sender, null);
@ -191,7 +187,7 @@ namespace TBF.UI.Procedures
/// <param name="listViewEx"></param>
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

View File

@ -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<Profile> profiles;
IList<FeedingPath> fPaths;
IList<BenchPath> bPaths;
IList<OutputPath> oPaths;
public Profile SelectedProfile;
public IList<Test> SelectedTests;
public double Qn;
public string MetroClass;
public double QpQiRatio;
public TestProfileSelection(IList<Profile> profiles)
IList<string> selectorVals; /// Empty string or null (which is permitted) is not part of this list
TextBox testNameTextBox;
ComboBox selectorComboBox;
public TestProfileSelection(IList<Profile> profiles,
IList<FeedingPath> fPaths,
IList<BenchPath> bPaths,
IList<OutputPath> 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<string>();
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<Test>();
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();
}

View File

@ -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;