diff --git a/TestBenchFramework/ProcedureDlg.cs b/TestBenchFramework/ProcedureDlg.cs index f6b2bef06..aaa7966b0 100644 --- a/TestBenchFramework/ProcedureDlg.cs +++ b/TestBenchFramework/ProcedureDlg.cs @@ -1690,6 +1690,7 @@ namespace TBF /// Add a test Test test = new Test(newName, listViewEx.Items.Count, LoadedProcedure); + TestWizard.RoiData roiData = new TestWizard.RoiData(); /// Run a create new test wizard TestWizard.MethodSelection methodDlg = new TestWizard.MethodSelection(true, false, test, TestMethods); @@ -1697,9 +1698,16 @@ namespace TBF TestWizard.VolumeAndErrorSelection volumeDlg = new TestWizard.VolumeAndErrorSelection(false, true, test); TestWizard.PressureSelection pressureDlg = new TestWizard.PressureSelection(false, true, test); TestWizard.HeatMetersSelection heatMetersDlg = new TestWizard.HeatMetersSelection(false, false, test); - //TestWizard.SensorsSelection sensorsDlg = new TestWizard.SensorsSelection(test); + TestWizard.Roi1 roi1Dlg = new TestWizard.Roi1(false, false, roiData); + TestWizard.Roi2 roi2Dlg = new TestWizard.Roi2(false, false, roiData); + TestWizard.Roi3 roi3Dlg = new TestWizard.Roi3(false, false, roiData); + roiData.Calculate(); + test.Qfrom = (float)(roiData.Q * 0.95); + test.Qto = (float)(roiData.Q * 1.05); + //test. methodLabel: + switch (methodDlg.ShowDialog()) { case DialogResult.Cancel: return; @@ -1719,6 +1727,27 @@ namespace TBF #if HEAT_METERS if (selectedMethod.CanTest(MetersKind.HeatMeter)) goto heat_meters_label; #endif + if (!(selectedMethod is BenchControl.TestMethods.RoiDetection.RoiDetection)) goto flowLabel; + + roi_detection_label_1: + switch (roi1Dlg.ShowDialog()) + { + case DialogResult.Cancel: return; + case DialogResult.Retry: goto methodLabel; + } + + roi_detection_label_2: + switch (roi2Dlg.ShowDialog()) + { + case DialogResult.Cancel: return; + case DialogResult.Retry: goto roi_detection_label_1; + } + + switch (roi3Dlg.ShowDialog()) + { + case DialogResult.Cancel: return; + case DialogResult.Retry: goto roi_detection_label_2; + } flowLabel: switch (flowDlg.ShowDialog()) @@ -1727,12 +1756,19 @@ namespace TBF case DialogResult.Retry: goto methodLabel; } + if (selectedMethod is BenchControl.TestMethods.RoiDetection.RoiDetection) + { + goto select_paths; + } + switch (volumeDlg.ShowDialog()) { case DialogResult.Cancel: return; case DialogResult.Retry: goto flowLabel; } + select_paths: + /// Depending on the chosen Q select the paths float Qaver = (test.Qfrom + test.Qto) / 2.0f; foreach (var path in feedingPaths) @@ -1773,7 +1809,7 @@ namespace TBF } goto flowLabel; #endif - + pressure_label: switch (pressureDlg.ShowDialog()) @@ -2020,5 +2056,52 @@ namespace TBF UpdateButtonStates(SharedButtons.SelectedItemPos.Middle); } } + + /// + /// Adds ROI data/process data prepared by the wizard to ROI-components in the selected sensors path + /// + /// Loaded procedure + /// Selected sensors path + /// ROI data + void AddProcessDataToRoiComponents(Config.Entities.Procedure procedure, string sensorsPathName, TestWizard.RoiData roiData) + { + /// Create controls for each sensors path used in this procedure. + /// Initialize it with its components (sensors or cameras) and add it to the list. + try + { + MetersPath sensorsPath = metersPaths.First(x => (x.Name == sensorsPathName)); + + if (sensorsPath != null) + { + IList cmpntsInMPath = new List(); + for (int i = 0; i < Config.Data.WMsCount; i++) + { + IComponent sensor = TbfComponents.FirstOrDefault(x => (x.Cfg.Name.Equals(sensorsPath.GetSensor(i)))); + cmpntsInMPath.Add(sensor); + } + + foreach (var cmpnt in cmpntsInMPath) + { + if (cmpnt != null && (cmpnt.Cfg.GetProcedureParams() != null)) + { + IParamsProvider procedureParams = cmpnt.Cfg.CreateProcedureParams(procedure); + BenchControl.Network.Camera.Roi.ProcedureParams roiParams = procedureParams as BenchControl.Network.Camera.Roi.ProcedureParams; + if (roiParams != null) + { + roiParams.PulsesPerLtr = (float)roiData.PulsesPerLiter; + roiParams.DetectionImagesCount = roiData.N; + roiParams.DetectionPeriod1 = roiData.P1; + roiParams.DetectionPeriod2 = roiData.P2; + roiParams.RoiParams = roiData.GetRoiParams(); + } + } + } + } + } + catch + { + } + } + } } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 4c6624ae7..3fa8f087c 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.12.533.1")] -[assembly: AssemblyFileVersion("2.12.533.1")] +[assembly: AssemblyVersion("2.12.534.1")] +[assembly: AssemblyFileVersion("2.12.534.1")] diff --git a/TestBenchFramework/Properties/Resources.Designer.cs b/TestBenchFramework/Properties/Resources.Designer.cs index 6fd3d8148..59f730733 100644 --- a/TestBenchFramework/Properties/Resources.Designer.cs +++ b/TestBenchFramework/Properties/Resources.Designer.cs @@ -60,6 +60,36 @@ namespace TBF.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap RoiStyle1 { + get { + object obj = ResourceManager.GetObject("RoiStyle1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap RoiStyle2 { + get { + object obj = ResourceManager.GetObject("RoiStyle2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap RoiStyle3 { + get { + object obj = ResourceManager.GetObject("RoiStyle3", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/TestBenchFramework/Properties/Resources.resx b/TestBenchFramework/Properties/Resources.resx index 9132fc007..eaad1a066 100644 --- a/TestBenchFramework/Properties/Resources.resx +++ b/TestBenchFramework/Properties/Resources.resx @@ -136,4 +136,13 @@ ..\Resources\TestPassedImage2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\RoiStyle1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\RoiStyle2.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\RoiStyle3.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/TestBenchFramework/Resources/RoiStyle1.bmp b/TestBenchFramework/Resources/RoiStyle1.bmp new file mode 100644 index 000000000..5e03cde25 Binary files /dev/null and b/TestBenchFramework/Resources/RoiStyle1.bmp differ diff --git a/TestBenchFramework/Resources/RoiStyle2.bmp b/TestBenchFramework/Resources/RoiStyle2.bmp new file mode 100644 index 000000000..a6df83649 Binary files /dev/null and b/TestBenchFramework/Resources/RoiStyle2.bmp differ diff --git a/TestBenchFramework/Resources/RoiStyle3.bmp b/TestBenchFramework/Resources/RoiStyle3.bmp new file mode 100644 index 000000000..18ae2ed56 Binary files /dev/null and b/TestBenchFramework/Resources/RoiStyle3.bmp differ diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 650996523..420f874f8 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -573,6 +573,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Clockwise. + /// + internal static string Clockwise { + get { + return ResourceManager.GetString("Clockwise", resourceCulture); + } + } + /// /// Looks up a localized string similar to close. /// @@ -816,6 +825,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Counterclockwise. + /// + internal static string Counterclockwise { + get { + return ResourceManager.GetString("Counterclockwise", resourceCulture); + } + } + /// /// Looks up a localized string similar to Create DB. /// @@ -3354,6 +3372,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to ROI Data. + /// + internal static string ROI_Data { + get { + return ResourceManager.GetString("ROI_Data", resourceCulture); + } + } + /// /// Looks up a localized string similar to ROI Detection in Progress. /// @@ -4464,6 +4491,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Turning direction. + /// + internal static string Turning_direction { + get { + return ResourceManager.GetString("Turning_direction", resourceCulture); + } + } + /// /// Looks up a localized string similar to Type. /// diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 023903981..761314640 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -1401,4 +1401,16 @@ Wählen Sie Bilder aus und drücken Sie 'Wiederholen', um die Erkennung zu wiederholen + + Richtung drehen + + + Im Uhrzeigersinn + + + Gegen den Uhrzeigersinn + + + ROI Daten + \ No newline at end of file diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index bdfda9917..7d8104c1d 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1702,4 +1702,16 @@ Select images and press Retry to retry RoI detection + + Clockwise + + + Counterclockwise + + + ROI Data + + + Turning direction + \ No newline at end of file diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 29043ae9f..69e89b6b1 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -1530,12 +1530,25 @@ PressureSelection.cs - + Form - - SensorsSelection.cs + + Roi1.cs + + Form + + + Roi2.cs + + + Form + + + Roi3.cs + + Form @@ -2278,8 +2291,14 @@ PressureSelection.cs - - SensorsSelection.cs + + Roi1.cs + + + Roi2.cs + + + Roi3.cs VolumeAndErrorSelection.cs @@ -2394,6 +2413,9 @@ + + + Always diff --git a/TestBenchFramework/TestWizard/Roi1.Designer.cs b/TestBenchFramework/TestWizard/Roi1.Designer.cs new file mode 100644 index 000000000..2e9340799 --- /dev/null +++ b/TestBenchFramework/TestWizard/Roi1.Designer.cs @@ -0,0 +1,188 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +namespace TBF.TestWizard +{ + partial class Roi1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); + this.stylePictureBox = new System.Windows.Forms.PictureBox(); + this.fwButton = new System.Windows.Forms.Button(); + this.bwButton = new System.Windows.Forms.Button(); + this.teetgCountTextBox = new System.Windows.Forms.TextBox(); + this.teethCount = new System.Windows.Forms.Label(); + this.cancelButton = new System.Windows.Forms.Button(); + this.nextButton = new System.Windows.Forms.Button(); + this.backButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit(); + this.horizSplitContainer.Panel1.SuspendLayout(); + this.horizSplitContainer.Panel2.SuspendLayout(); + this.horizSplitContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.stylePictureBox)).BeginInit(); + this.SuspendLayout(); + // + // horizSplitContainer + // + this.horizSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.horizSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.horizSplitContainer.Location = new System.Drawing.Point(0, 0); + this.horizSplitContainer.Name = "horizSplitContainer"; + this.horizSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // horizSplitContainer.Panel1 + // + this.horizSplitContainer.Panel1.Controls.Add(this.stylePictureBox); + this.horizSplitContainer.Panel1.Controls.Add(this.fwButton); + this.horizSplitContainer.Panel1.Controls.Add(this.bwButton); + this.horizSplitContainer.Panel1.Controls.Add(this.teetgCountTextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.teethCount); + // + // horizSplitContainer.Panel2 + // + this.horizSplitContainer.Panel2.Controls.Add(this.cancelButton); + this.horizSplitContainer.Panel2.Controls.Add(this.nextButton); + this.horizSplitContainer.Panel2.Controls.Add(this.backButton); + this.horizSplitContainer.Size = new System.Drawing.Size(284, 262); + this.horizSplitContainer.SplitterDistance = 182; + this.horizSplitContainer.TabIndex = 1; + // + // stylePictureBox + // + this.stylePictureBox.Location = new System.Drawing.Point(79, 12); + this.stylePictureBox.Name = "stylePictureBox"; + this.stylePictureBox.Size = new System.Drawing.Size(128, 128); + this.stylePictureBox.TabIndex = 7; + this.stylePictureBox.TabStop = false; + // + // fwButton + // + this.fwButton.Location = new System.Drawing.Point(220, 54); + this.fwButton.Name = "fwButton"; + this.fwButton.Size = new System.Drawing.Size(41, 44); + this.fwButton.TabIndex = 6; + this.fwButton.Text = "->"; + this.fwButton.UseVisualStyleBackColor = true; + this.fwButton.Click += new System.EventHandler(this.fwButton_Click); + // + // bwButton + // + this.bwButton.Location = new System.Drawing.Point(24, 54); + this.bwButton.Name = "bwButton"; + this.bwButton.Size = new System.Drawing.Size(41, 44); + this.bwButton.TabIndex = 5; + this.bwButton.Text = "<-"; + this.bwButton.UseVisualStyleBackColor = true; + this.bwButton.Click += new System.EventHandler(this.bwButton_Click); + // + // teetgCountTextBox + // + this.teetgCountTextBox.Location = new System.Drawing.Point(175, 150); + this.teetgCountTextBox.Name = "teetgCountTextBox"; + this.teetgCountTextBox.Size = new System.Drawing.Size(32, 20); + this.teetgCountTextBox.TabIndex = 4; + this.teetgCountTextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // teethCount + // + this.teethCount.AutoSize = true; + this.teethCount.Location = new System.Drawing.Point(76, 153); + this.teethCount.Name = "teethCount"; + this.teethCount.Size = new System.Drawing.Size(65, 13); + this.teethCount.TabIndex = 1; + this.teethCount.Text = "Teeth count"; + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(186, 17); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 42); + this.cancelButton.TabIndex = 27; + this.cancelButton.Text = "&Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // nextButton + // + this.nextButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.nextButton.Location = new System.Drawing.Point(105, 17); + this.nextButton.Name = "nextButton"; + this.nextButton.Size = new System.Drawing.Size(75, 42); + this.nextButton.TabIndex = 26; + this.nextButton.Text = "&Next >"; + this.nextButton.UseVisualStyleBackColor = true; + this.nextButton.Click += new System.EventHandler(this.nextButton_Click); + // + // backButton + // + this.backButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.backButton.DialogResult = System.Windows.Forms.DialogResult.Retry; + this.backButton.Location = new System.Drawing.Point(24, 17); + this.backButton.Name = "backButton"; + this.backButton.Size = new System.Drawing.Size(75, 42); + this.backButton.TabIndex = 25; + this.backButton.Text = "< &Back"; + this.backButton.UseVisualStyleBackColor = true; + this.backButton.Click += new System.EventHandler(this.backButton_Click); + // + // Roi1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.horizSplitContainer); + this.Name = "Roi1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Pointer/arrow style"; + this.Load += new System.EventHandler(this.Roi1_Load); + this.horizSplitContainer.Panel1.ResumeLayout(false); + this.horizSplitContainer.Panel1.PerformLayout(); + this.horizSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).EndInit(); + this.horizSplitContainer.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.stylePictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer horizSplitContainer; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button nextButton; + private System.Windows.Forms.Button backButton; + private System.Windows.Forms.TextBox teetgCountTextBox; + private System.Windows.Forms.Label teethCount; + private System.Windows.Forms.PictureBox stylePictureBox; + private System.Windows.Forms.Button fwButton; + private System.Windows.Forms.Button bwButton; + + } +} \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/Roi1.cs b/TestBenchFramework/TestWizard/Roi1.cs new file mode 100644 index 000000000..dc412d961 --- /dev/null +++ b/TestBenchFramework/TestWizard/Roi1.cs @@ -0,0 +1,136 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Drawing; +using System.Windows.Forms; +using TBF.Resources; + +namespace TBF.TestWizard +{ + public partial class Roi1 : Form + { + RoiData roiData; + + const int StylesCount = 3; + int styleIdx; /// 0 .. StylesCount - 1 + + + public Roi1() + { + InitializeComponent(); + } + + public Roi1(bool first, bool last, RoiData roiData) + : this() + { + this.roiData = roiData; + + Text = "Pointer/arrow style"; + teethCount.Text = "Teeth count"; + + backButton.Text = Strings.BackBtnText; + nextButton.Text = Strings.NextBtnText; + cancelButton.Text = Strings.CancelBtnText; + + if (first) backButton.Visible = false; + if (last) nextButton.Text = Strings.FinishBtnText; + } + + + private void Roi1_Load(object sender, EventArgs e) + { + if (roiData == null) return; + + RefreshWizardPage(); + } + + void RefreshWizardPage() + { + teetgCountTextBox.Text = roiData.TeethCount.ToString(); + styleIdx = roiData.StyleIdx; + LoadImageAndUpdateFwBwBtns(); + nextButton.Enabled = IsFormValid(); + } + + void LoadImageAndUpdateFwBwBtns() + { + switch (styleIdx) + { + default: + case 0: + stylePictureBox.Image = new Bitmap(TBF.Properties.Resources.RoiStyle1); + break; + case 1: + stylePictureBox.Image = new Bitmap(TBF.Properties.Resources.RoiStyle2); + break; + case 2: + stylePictureBox.Image = new Bitmap(TBF.Properties.Resources.RoiStyle3); + break; + } + + fwButton.Enabled = styleIdx < StylesCount - 1; + bwButton.Enabled = styleIdx > 0; + } + + void UpdateTest() + { + roiData.StyleIdx = styleIdx; + roiData.TeethCount = int.Parse(teetgCountTextBox.Text); + } + + bool IsFormValid() + { + int teethCnt; + return int.TryParse(teetgCountTextBox.Text, out teethCnt) + && teethCnt > 0 && teethCnt <= 20 + && styleIdx >= 0 && styleIdx < StylesCount + && (styleIdx == 2 || teethCnt == 1); + } + + private void backButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Retry; + Close(); + } + + private void nextButton_Click(object sender, EventArgs e) + { + if (roiData != null && IsFormValid()) + { + UpdateTest(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.None; + } + } + + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void anyTextBox_TextChanged(object sender, EventArgs e) + { + nextButton.Enabled = IsFormValid(); + } + + private void bwButton_Click(object sender, EventArgs e) + { + if (styleIdx > 0) styleIdx--; + LoadImageAndUpdateFwBwBtns(); + nextButton.Enabled = IsFormValid(); + } + + private void fwButton_Click(object sender, EventArgs e) + { + if (styleIdx < StylesCount - 1) styleIdx++; + LoadImageAndUpdateFwBwBtns(); + nextButton.Enabled = IsFormValid(); + } + } +} diff --git a/TestBenchFramework/TestWizard/SensorsSelection.resx b/TestBenchFramework/TestWizard/Roi1.resx similarity index 100% rename from TestBenchFramework/TestWizard/SensorsSelection.resx rename to TestBenchFramework/TestWizard/Roi1.resx diff --git a/TestBenchFramework/TestWizard/SensorsSelection.Designer.cs b/TestBenchFramework/TestWizard/Roi2.Designer.cs similarity index 67% rename from TestBenchFramework/TestWizard/SensorsSelection.Designer.cs rename to TestBenchFramework/TestWizard/Roi2.Designer.cs index f70a1e8d8..d96d228c7 100644 --- a/TestBenchFramework/TestWizard/SensorsSelection.Designer.cs +++ b/TestBenchFramework/TestWizard/Roi2.Designer.cs @@ -1,9 +1,9 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2017 Sensus Metering Systems /// namespace TBF.TestWizard { - partial class SensorsSelection + partial class Roi2 { /// /// Required designer variable. @@ -32,10 +32,15 @@ namespace TBF.TestWizard private void InitializeComponent() { this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); + this.r2TextBox = new System.Windows.Forms.TextBox(); + this.r1TextBox = new System.Windows.Forms.TextBox(); + this.r2Label = new System.Windows.Forms.Label(); + this.r1Label = new System.Windows.Forms.Label(); this.cancelButton = new System.Windows.Forms.Button(); this.nextButton = new System.Windows.Forms.Button(); this.backButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit(); + this.horizSplitContainer.Panel1.SuspendLayout(); this.horizSplitContainer.Panel2.SuspendLayout(); this.horizSplitContainer.SuspendLayout(); this.SuspendLayout(); @@ -48,6 +53,13 @@ namespace TBF.TestWizard this.horizSplitContainer.Name = "horizSplitContainer"; this.horizSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; // + // horizSplitContainer.Panel1 + // + this.horizSplitContainer.Panel1.Controls.Add(this.r2TextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.r1TextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.r2Label); + this.horizSplitContainer.Panel1.Controls.Add(this.r1Label); + // // horizSplitContainer.Panel2 // this.horizSplitContainer.Panel2.Controls.Add(this.cancelButton); @@ -57,6 +69,40 @@ namespace TBF.TestWizard this.horizSplitContainer.SplitterDistance = 182; this.horizSplitContainer.TabIndex = 1; // + // r2TextBox + // + this.r2TextBox.Location = new System.Drawing.Point(137, 93); + this.r2TextBox.Name = "r2TextBox"; + this.r2TextBox.Size = new System.Drawing.Size(59, 20); + this.r2TextBox.TabIndex = 5; + this.r2TextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // r1TextBox + // + this.r1TextBox.Location = new System.Drawing.Point(137, 63); + this.r1TextBox.Name = "r1TextBox"; + this.r1TextBox.Size = new System.Drawing.Size(59, 20); + this.r1TextBox.TabIndex = 4; + this.r1TextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // r2Label + // + this.r2Label.AutoSize = true; + this.r2Label.Location = new System.Drawing.Point(83, 96); + this.r2Label.Name = "r2Label"; + this.r2Label.Size = new System.Drawing.Size(21, 13); + this.r2Label.TabIndex = 2; + this.r2Label.Text = "R2"; + // + // r1Label + // + this.r1Label.AutoSize = true; + this.r1Label.Location = new System.Drawing.Point(83, 66); + this.r1Label.Name = "r1Label"; + this.r1Label.Size = new System.Drawing.Size(21, 13); + this.r1Label.TabIndex = 1; + this.r1Label.Text = "R1"; + // // cancelButton // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -92,16 +138,18 @@ namespace TBF.TestWizard this.backButton.UseVisualStyleBackColor = true; this.backButton.Click += new System.EventHandler(this.backButton_Click); // - // SensorsSelection + // Roi2 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 262); this.Controls.Add(this.horizSplitContainer); - this.Name = "SensorsSelection"; + this.Name = "Roi2"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "SensorsSelection"; - this.Load += new System.EventHandler(this.SensorsSelection_Load); + this.Text = "Pointer/arrow size"; + this.Load += new System.EventHandler(this.Roi2_Load_1); + this.horizSplitContainer.Panel1.ResumeLayout(false); + this.horizSplitContainer.Panel1.PerformLayout(); this.horizSplitContainer.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).EndInit(); this.horizSplitContainer.ResumeLayout(false); @@ -115,5 +163,10 @@ namespace TBF.TestWizard private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.Button nextButton; private System.Windows.Forms.Button backButton; + private System.Windows.Forms.TextBox r2TextBox; + private System.Windows.Forms.TextBox r1TextBox; + private System.Windows.Forms.Label r2Label; + private System.Windows.Forms.Label r1Label; + } } \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/Roi2.cs b/TestBenchFramework/TestWizard/Roi2.cs new file mode 100644 index 000000000..d7d40c57f --- /dev/null +++ b/TestBenchFramework/TestWizard/Roi2.cs @@ -0,0 +1,97 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using TBF.Resources; + +namespace TBF.TestWizard +{ + public partial class Roi2 : Form + { + RoiData roiData; + + + public Roi2() + { + InitializeComponent(); + } + + public Roi2(bool first, bool last, RoiData roiData) + : this() + { + this.roiData = roiData; + + Text = "Pointer/arrow size"; + r1Label.Text = "R1"; + r2Label.Text = "R2"; + + backButton.Text = Strings.BackBtnText; + nextButton.Text = Strings.NextBtnText; + cancelButton.Text = Strings.CancelBtnText; + + if (first) backButton.Visible = false; + if (last) nextButton.Text = Strings.FinishBtnText; + } + + + private void Roi2_Load_1(object sender, EventArgs e) + { + if (roiData == null) return; + + RefreshWizardPage(); + } + + void RefreshWizardPage() + { + r1TextBox.Text = roiData.R1.ToString(); + r2TextBox.Text = roiData.R2.ToString(); + nextButton.Enabled = IsFormValid(); + } + + void UpdateTest() + { + roiData.R1 = int.Parse(r1TextBox.Text); + roiData.R2 = int.Parse(r2TextBox.Text); + } + + bool IsFormValid() + { + int r1, r2; + return int.TryParse(r1TextBox.Text, out r1) && + int.TryParse(r2TextBox.Text, out r2) && + (r2 > r1) && (r1 > 0); + } + + private void backButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Retry; + Close(); + } + + private void nextButton_Click(object sender, EventArgs e) + { + if (roiData != null && IsFormValid()) + { + UpdateTest(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.None; + } + } + + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void anyTextBox_TextChanged(object sender, EventArgs e) + { + nextButton.Enabled = IsFormValid(); + } + } +} diff --git a/TestBenchFramework/TestWizard/Roi2.resx b/TestBenchFramework/TestWizard/Roi2.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/TestWizard/Roi2.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/Roi3.Designer.cs b/TestBenchFramework/TestWizard/Roi3.Designer.cs new file mode 100644 index 000000000..910bcbc61 --- /dev/null +++ b/TestBenchFramework/TestWizard/Roi3.Designer.cs @@ -0,0 +1,173 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +namespace TBF.TestWizard +{ + partial class Roi3 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); + this.directionComboBox = new System.Windows.Forms.ComboBox(); + this.directionLabel = new System.Windows.Forms.Label(); + this.pulsesPerLiterTextBox = new System.Windows.Forms.TextBox(); + this.pulsesPerLiterLabel = new System.Windows.Forms.Label(); + this.cancelButton = new System.Windows.Forms.Button(); + this.nextButton = new System.Windows.Forms.Button(); + this.backButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit(); + this.horizSplitContainer.Panel1.SuspendLayout(); + this.horizSplitContainer.Panel2.SuspendLayout(); + this.horizSplitContainer.SuspendLayout(); + this.SuspendLayout(); + // + // horizSplitContainer + // + this.horizSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.horizSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.horizSplitContainer.Location = new System.Drawing.Point(0, 0); + this.horizSplitContainer.Name = "horizSplitContainer"; + this.horizSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // horizSplitContainer.Panel1 + // + this.horizSplitContainer.Panel1.Controls.Add(this.directionComboBox); + this.horizSplitContainer.Panel1.Controls.Add(this.directionLabel); + this.horizSplitContainer.Panel1.Controls.Add(this.pulsesPerLiterTextBox); + this.horizSplitContainer.Panel1.Controls.Add(this.pulsesPerLiterLabel); + // + // horizSplitContainer.Panel2 + // + this.horizSplitContainer.Panel2.Controls.Add(this.cancelButton); + this.horizSplitContainer.Panel2.Controls.Add(this.nextButton); + this.horizSplitContainer.Panel2.Controls.Add(this.backButton); + this.horizSplitContainer.Size = new System.Drawing.Size(284, 262); + this.horizSplitContainer.SplitterDistance = 182; + this.horizSplitContainer.TabIndex = 1; + // + // directionComboBox + // + this.directionComboBox.FormattingEnabled = true; + this.directionComboBox.Location = new System.Drawing.Point(129, 98); + this.directionComboBox.Name = "directionComboBox"; + this.directionComboBox.Size = new System.Drawing.Size(132, 21); + this.directionComboBox.TabIndex = 5; + this.directionComboBox.SelectedIndexChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // directionLabel + // + this.directionLabel.AutoSize = true; + this.directionLabel.Location = new System.Drawing.Point(21, 101); + this.directionLabel.Name = "directionLabel"; + this.directionLabel.Size = new System.Drawing.Size(86, 13); + this.directionLabel.TabIndex = 4; + this.directionLabel.Text = "Turning direction"; + // + // pulsesPerLiterTextBox + // + this.pulsesPerLiterTextBox.Location = new System.Drawing.Point(129, 57); + this.pulsesPerLiterTextBox.Name = "pulsesPerLiterTextBox"; + this.pulsesPerLiterTextBox.Size = new System.Drawing.Size(132, 20); + this.pulsesPerLiterTextBox.TabIndex = 3; + this.pulsesPerLiterTextBox.TextChanged += new System.EventHandler(this.anyTextBox_TextChanged); + // + // pulsesPerLiterLabel + // + this.pulsesPerLiterLabel.AutoSize = true; + this.pulsesPerLiterLabel.Location = new System.Drawing.Point(21, 60); + this.pulsesPerLiterLabel.Name = "pulsesPerLiterLabel"; + this.pulsesPerLiterLabel.Size = new System.Drawing.Size(75, 13); + this.pulsesPerLiterLabel.TabIndex = 2; + this.pulsesPerLiterLabel.Text = "Pulses per liter"; + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(186, 17); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 42); + this.cancelButton.TabIndex = 2; + this.cancelButton.Text = "&Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // nextButton + // + this.nextButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.nextButton.Location = new System.Drawing.Point(105, 17); + this.nextButton.Name = "nextButton"; + this.nextButton.Size = new System.Drawing.Size(75, 42); + this.nextButton.TabIndex = 1; + this.nextButton.Text = "&Next >"; + this.nextButton.UseVisualStyleBackColor = true; + this.nextButton.Click += new System.EventHandler(this.nextButton_Click); + // + // backButton + // + this.backButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.backButton.DialogResult = System.Windows.Forms.DialogResult.Retry; + this.backButton.Location = new System.Drawing.Point(24, 17); + this.backButton.Name = "backButton"; + this.backButton.Size = new System.Drawing.Size(75, 42); + this.backButton.TabIndex = 0; + this.backButton.Text = "< &Back"; + this.backButton.UseVisualStyleBackColor = true; + this.backButton.Click += new System.EventHandler(this.backButton_Click); + // + // Roi3 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.horizSplitContainer); + this.Name = "Roi3"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ROI Data"; + this.Load += new System.EventHandler(this.Roi3_Load); + this.horizSplitContainer.Panel1.ResumeLayout(false); + this.horizSplitContainer.Panel1.PerformLayout(); + this.horizSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).EndInit(); + this.horizSplitContainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer horizSplitContainer; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button nextButton; + private System.Windows.Forms.Button backButton; + private System.Windows.Forms.TextBox pulsesPerLiterTextBox; + private System.Windows.Forms.Label pulsesPerLiterLabel; + private System.Windows.Forms.ComboBox directionComboBox; + private System.Windows.Forms.Label directionLabel; + + } +} \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/Roi3.cs b/TestBenchFramework/TestWizard/Roi3.cs new file mode 100644 index 000000000..1960eb930 --- /dev/null +++ b/TestBenchFramework/TestWizard/Roi3.cs @@ -0,0 +1,100 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using TBF.Resources; + +namespace TBF.TestWizard +{ + public partial class Roi3 : Form + { + RoiData roiData; + + + public Roi3() + { + InitializeComponent(); + } + + public Roi3(bool first, bool last, RoiData roiData) + : this() + { + this.roiData = roiData; + + Text = Strings.ROI_Data; + pulsesPerLiterLabel.Text = Strings.PulsesPerLtr; + directionLabel.Text = Strings.Turning_direction; + + backButton.Text = Strings.BackBtnText; + nextButton.Text = Strings.NextBtnText; + cancelButton.Text = Strings.CancelBtnText; + + if (first) backButton.Visible = false; + if (last) nextButton.Text = Strings.FinishBtnText; + } + + + private void Roi3_Load(object sender, EventArgs e) + { + if (roiData == null) return; + + directionComboBox.Items.Add(Strings.Clockwise); + directionComboBox.Items.Add(Strings.Counterclockwise); + + RefreshWizardPage(); + } + + void RefreshWizardPage() + { + pulsesPerLiterTextBox.Text = roiData.PulsesPerLiter.ToString(); + directionComboBox.Text = (roiData.Direction == TurningDirection.Clockwise) ? Strings.Clockwise : Strings.Counterclockwise; + + nextButton.Enabled = IsFormValid(); + } + + void UpdateTest() + { + roiData.PulsesPerLiter = Utils.ParseUDouble(pulsesPerLiterTextBox.Text); + roiData.Direction = (directionComboBox.Text == Strings.Clockwise) ? TurningDirection.Clockwise : TurningDirection.Counterclockwise; + } + + bool IsFormValid() + { + double dummy; + return Utils.TryParseUDouble(pulsesPerLiterTextBox.Text, out dummy) && + directionComboBox.Items.Contains(directionComboBox.Text); + } + + private void backButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Retry; + Close(); + } + + private void nextButton_Click(object sender, EventArgs e) + { + if (IsFormValid()) + { + UpdateTest(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.None; + } + } + + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void anyTextBox_TextChanged(object sender, EventArgs e) + { + nextButton.Enabled = IsFormValid(); + } + } +} diff --git a/TestBenchFramework/TestWizard/Roi3.resx b/TestBenchFramework/TestWizard/Roi3.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/TestWizard/Roi3.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/TestWizard/RoiData.cs b/TestBenchFramework/TestWizard/RoiData.cs new file mode 100644 index 000000000..a46a69e9e --- /dev/null +++ b/TestBenchFramework/TestWizard/RoiData.cs @@ -0,0 +1,89 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +namespace TBF.TestWizard +{ + public enum TurningDirection + { + Clockwise, + Counterclockwise, + Count, + } + + public class RoiData + { + /// Set by the wizard + public int StyleIdx; + public int TeethCount; + public int R1; + public int R2; + public double PulsesPerLiter; + public TurningDirection Direction; + + /// Calculated + public int WidHgh; + public int CxCy; + public int R3; + public int P1; + public int P2; + public int N; + public double Q; /// [m3/h] + + + public RoiData() + { + TeethCount = 1; + R1 = 30; + R2 = 80; + PulsesPerLiter = 36.0; + } + + + /// + /// Calculate additional data from data entered by the wizard + /// + public void Calculate() + { + WidHgh = 2 * R2 + 1; + CxCy = R2; + + double acqTime; /// Duration of image sequence + switch (StyleIdx) + { + default: + case 0: + R3 = (int)System.Math.Round(0.8 * R2); + P1 = 1; + P2 = 19; + N = 10; + acqTime = 3.0; + break; + case 1: + R3 = 0; + P1 = 1; + P2 = 19; + N = 10; + acqTime = 3.0; + break; + case 2: + R3 = 0; + P1 = 1; + P2 = 1; + N = 10; + acqTime = 3.0; + break; + } + + double vol = 360.0 / PulsesPerLiter; /// Liters per 1 rotation + double flowLps = vol / acqTime; + Q = 3.6 * flowLps; /// Convert to m3 / h + } + + public string GetRoiParams() + { + return string.Format("{0} {0} {1} {1} {2} {3} {4} 0 360 360 {5} {6}", + WidHgh, CxCy, R1, R2, R3, TeethCount, + (Direction == TestWizard.TurningDirection.Clockwise) ? 1 : -1); + } + } +} diff --git a/TestBenchFramework/TestWizard/SensorsSelection.cs b/TestBenchFramework/TestWizard/SensorsSelection.cs deleted file mode 100644 index 79626ee34..000000000 --- a/TestBenchFramework/TestWizard/SensorsSelection.cs +++ /dev/null @@ -1,84 +0,0 @@ -/// -/// Copyright (c) 2013-2015 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Config.Entities; -using TBF.Resources; - -namespace TBF.TestWizard -{ - public partial class SensorsSelection : Form - { - Test test; - - public SensorsSelection() - { - InitializeComponent(); - } - - public SensorsSelection(Test test) - : this() - { - this.test = test; - } - - private void SensorsSelection_Load(object sender, EventArgs e) - { - if (test == null) return; - - backButton.Text = Strings.BackBtnText; - nextButton.Text = Strings.NextBtnText; - cancelButton.Text = Strings.CancelBtnText; - - RefreshWizardPage(); - } - - void RefreshWizardPage() - { - nextButton.Enabled = IsFormValid(); - } - - void UpdateTest() - { - } - - bool IsFormValid() - { - return true; - } - - private void backButton_Click(object sender, EventArgs e) - { - if (test != null && IsFormValid()) UpdateTest(); - DialogResult = DialogResult.Retry; - Close(); - } - - private void nextButton_Click(object sender, EventArgs e) - { - if (test != null && IsFormValid()) - { - UpdateTest(); - DialogResult = DialogResult.OK; - Close(); - } - else - { - DialogResult = DialogResult.None; - } - } - - private void cancelButton_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - } -}