When using 'Create from Profile' the generated tests can be renamed, order of profilesin ComboBox.

This commit is contained in:
Milan Hanajik 2022-06-28 15:07:26 +02:00
parent 1f12464218
commit b3df3307a0
3 changed files with 145 additions and 99 deletions

View File

@ -694,7 +694,9 @@ namespace TBF.UI.Procedures
try
{
profiles = session.QueryOver<Profile>().List();
profiles = session.QueryOver<Profile>()
.OrderBy(x => x.ItemNr).Asc
.List();
}
catch (Exception)
{
@ -750,35 +752,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 = Formulas.GetTargetQ(ptest, dlg.Qn, dlg.QpQiRatio, dlg.MetroClass, medium);
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)
@ -788,39 +765,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);

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;
@ -20,23 +21,34 @@ namespace TBF.UI.Procedures.TestWizard
IList<Profile> profiles;
public Profile SelectedProfile;
public IList<Test> SelectedTests;
public double Qn;
public string MetroClass;
public double QpQiRatio;
TextBox testNameTextBox;
public TestProfileSelection(IList<Profile> profiles)
{
this.profiles = profiles;
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);
testNameTextBox = new TextBox();
testNameTextBox.Visible = false;
this.Controls.Add(testNameTextBox);
/// 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(Strings.Err_limit_neg_pct_chdr, 80);
listViewEx.Columns.Add(Strings.Err_limit_pos_pct_chdr, 80);
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
if (profiles != null)
{
@ -45,6 +57,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,19 +132,45 @@ 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 = TBF.UI.Procedures.Formulas.GetTargetQ(ptest, Qn, QpQiRatio, MetroClass, medium);
double Qfrom = Qtg * ptest.CoefQfrom;
double Qto = Qtg * ptest.CoefQto;
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;
if (profile.ProfileType != ProfileType.QpQi)
{
test.ErrLimLo = Convert.ToSingle(ptest.ErrLimLo);
test.ErrLimHi = Convert.ToSingle(ptest.ErrLimHi);
}
else
{
int metroClass;
if (int.TryParse(MetroClass, out metroClass))
{
test.ErrLimLo = Convert.ToSingle(metroClass);
}
test.ErrLimHi = -Convert.ToSingle(Qn);
}
ListViewItem lvi;
if (profile.ProfileType != ProfileType.QpQi)
@ -139,8 +178,8 @@ namespace TBF.UI.Procedures.TestWizard
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(),
ptest.ErrLimLo.ToString(),
ptest.ErrLimHi.ToString() });
}
@ -149,14 +188,15 @@ namespace TBF.UI.Procedures.TestWizard
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(),
Strings.calculated,
Strings.calculated });
}
lvi.Tag = ptest;
listView.Items.Add(lvi);
lvi.Tag = test;
listViewEx.Items.Add(lvi);
SelectedTests.Add(test);
}
}
catch (Exception)
@ -203,7 +243,8 @@ namespace TBF.UI.Procedures.TestWizard
}
}
private void qnComboBox_SelectedIndexChanged(object sender, EventArgs e)
private void qnTextBox_TextChanged(object sender, EventArgs e)
{
if (IsFormValid())
{
@ -306,6 +347,34 @@ namespace TBF.UI.Procedures.TestWizard
return IsProfileValid() && IsQnValid() && IsMetroClassValid() && IsQpQiRatioValid();
}
private void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
{
if (e.SubItem != 0) return;
listViewEx.StartEditing(testNameTextBox, e.Item, e.SubItem);
}
private void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
{
Test test = e.Item.Tag as Test;
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;
return;
}
private void nextButton_Click(object sender, EventArgs e)
{
if (IsFormValid())

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;