diff --git a/Config/Entities/MeasurementCorrection.cs b/Config/Entities/MeasurementCorrection.cs index 6d3bea7d0..1d6a5acef 100644 --- a/Config/Entities/MeasurementCorrection.cs +++ b/Config/Entities/MeasurementCorrection.cs @@ -12,11 +12,14 @@ namespace Config.Entities public virtual float Measurement { get; set; } public virtual float Correction { get; set; } - public MeasurementCorrection() { } + public MeasurementCorrection() + { + RangeIx = 0; + } public MeasurementCorrection(int rangeIx) { - RangeIx = rangeIx; + RangeIx = rangeIx; } } } diff --git a/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfg.cs b/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfg.cs index 32d7e8ccd..e294719f6 100644 --- a/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfg.cs +++ b/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfg.cs @@ -9,7 +9,7 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.Elde.FlowMeter { - public class FlowMeterCfg : ComponentCfgBase, GenericDevices.ICalibInfoCfg, IChildComponentCfg + public class FlowMeterCfg : ComponentCfgBase, GenericDevices.ICalibRangesCfg, IChildComponentCfg { public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(FlowMeterCfg) })[0]; public override XmlSerializer GetSerializer() { return Serializer; } diff --git a/TBF/BenchControl/GenericDevices/ICalibInfoCfg.cs b/TBF/BenchControl/GenericDevices/ICalibInfoCfg.cs index bcac7cb7b..455617953 100644 --- a/TBF/BenchControl/GenericDevices/ICalibInfoCfg.cs +++ b/TBF/BenchControl/GenericDevices/ICalibInfoCfg.cs @@ -1,30 +1,18 @@ -/// -/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// +/// Copyright (c) 2018 Sensus Metering Systems /// using System; using TBF.BenchControl.Generic; namespace TBF.BenchControl.GenericDevices { - public interface ICalibInfoCfg : IComponentCfg - { + public interface ICalibInfoCfg : IComponentCfg + { /// - /// Access to parameters displayed in Metrology tab page + /// Parameters displayed in Metrology tab page /// - - bool RangeEnabled(int rangeIx1); - - double GetTempLo(int rangeIx1); - double GetTempHi(int rangeIx1); - double GetPressLo(int rangeIx1); - double GetPressHi(int rangeIx1); - - string GetCalibCertificate(int rangeIx1); /// Get calibration certificate number - DateTime GetCalibDate(int rangeIx1); /// Get the date of calibration - DateTime GetCalibValidDate(int rangeIx1); /// Get calibration valid until (date) - - void SetCalibCertificate(int rangeIx1, string certificate); /// Set calibration certificate number - void SetCalibDate(int rangeIx1, DateTime date); /// Get the date of calibration - void SetCalibValidDate(int rangeIx1, DateTime date); /// Get calibration valid until (date) + string CalibCertificateNr { get; set; } /// calibration certificate number + DateTime CalibDate { get; set; } /// date of calibration + DateTime CalibValidDate { get; set; } /// calibration valid until (date) } } diff --git a/TBF/BenchControl/GenericDevices/ICalibRangesCfg.cs b/TBF/BenchControl/GenericDevices/ICalibRangesCfg.cs new file mode 100644 index 000000000..2bb88656e --- /dev/null +++ b/TBF/BenchControl/GenericDevices/ICalibRangesCfg.cs @@ -0,0 +1,30 @@ +/// +/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// +using System; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.GenericDevices +{ + public interface ICalibRangesCfg : IComponentCfg + { + /// + /// Access to parameters displayed in Metrology tab page + /// + + bool RangeEnabled(int rangeIx1); + + double GetTempLo(int rangeIx1); + double GetTempHi(int rangeIx1); + double GetPressLo(int rangeIx1); + double GetPressHi(int rangeIx1); + + string GetCalibCertificate(int rangeIx1); /// Get calibration certificate number + DateTime GetCalibDate(int rangeIx1); /// Get the date of calibration + DateTime GetCalibValidDate(int rangeIx1); /// Get calibration valid until (date) + + void SetCalibCertificate(int rangeIx1, string certificate); /// Set calibration certificate number + void SetCalibDate(int rangeIx1, DateTime date); /// Get the date of calibration + void SetCalibValidDate(int rangeIx1, DateTime date); /// Get calibration valid until (date) + } +} diff --git a/TBF/BenchControl/GenericDevices/IScaleCfg.cs b/TBF/BenchControl/GenericDevices/IScaleCfg.cs index 8288aa0e0..a60963f29 100644 --- a/TBF/BenchControl/GenericDevices/IScaleCfg.cs +++ b/TBF/BenchControl/GenericDevices/IScaleCfg.cs @@ -6,7 +6,7 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.GenericDevices { - public interface IScaleCfg : IComponentCfg + public interface IScaleCfg : ICalibInfoCfg { /// /// Parameters displayed in Metrology tab page @@ -14,11 +14,7 @@ namespace TBF.BenchControl.GenericDevices float BuoyancyTemp { get; set; } /// ambient temperature in [degree C] float BuoyancyPress { get; set; } /// ambient pressure in [100000 Pa] float BuoyancyHumi { get; set; } /// ambient relative humidity in [%] - float WeightStandardDensity { get; set; } /// density of the weight standard used to calibrate the scale [kg/m3] - - string CalibCertificateNr { get; set; } /// calibration certificate number - DateTime CalibDate { get; set; } /// date of calibration - DateTime CalibValidDate { get; set; } /// calibration valid until (date) + float WeightStandardDensity { get; set; } /// density of the weight standard used to calibrate the scale [kg/m3] } } diff --git a/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs b/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs index 1420bd658..1d133ba4d 100644 --- a/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs +++ b/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs @@ -144,7 +144,7 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections session.SaveOrUpdate(mc); } - ICalibInfoCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt) as ICalibInfoCfg; + ICalibRangesCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt) as ICalibRangesCfg; if (cfg != null) { cfg.SetCalibDate(rangeIx, DateTime.Now); diff --git a/TBF/MetrologyDlg.cs b/TBF/MetrologyDlg.cs index 66ecbb476..41188034a 100644 --- a/TBF/MetrologyDlg.cs +++ b/TBF/MetrologyDlg.cs @@ -47,6 +47,7 @@ namespace TBF int fixedCount = 0; int balancesCount = 0; + int levelMetersCount = 0; int flowMetersCount = 0; int pressMetersCount = 0; int tempMetersCount = 0; @@ -70,7 +71,7 @@ namespace TBF { BenchControl.Generic.IComponentFactory factory = TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName); - // Balance tab-pages + /// Balance tab-pages if (factory is BenchControl.MettlerToledo.Standard.BalanceFactory || factory is BenchControl.MettlerToledo.Standard.BalanceOldFactory || factory is BenchControl.MettlerToledo.Standard.BalanceNewFactory || @@ -87,7 +88,21 @@ namespace TBF metrologyTabControl.TabPages.Add(tabPage); } - // Flowmeter tab-pages + /// Level meters for tanks tab-pages + if (factory is BenchControl.Hart.Nivotrack.Factory) + { + levelMetersCount++; + TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); + MetrologyDlgLevelMeterTab uiControl = new MetrologyDlgLevelMeterTab(); + uiControl.MeterEntity = cmpnt; + uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; + uiControl.Dock = DockStyle.Fill; + tabPage.Tag = uiControl; + tabPage.Controls.Add(uiControl); + metrologyTabControl.TabPages.Add(tabPage); + } + + /// Flowmeter tab-pages if (factory is BenchControl.Elde.FlowMeter.FlowMeterFactory) { BenchControl.Elde.FlowMeter.FlowMeterCfg flowMeterCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.Elde.FlowMeter.FlowMeterCfg; @@ -100,7 +115,7 @@ namespace TBF TabPage tabPage = new TabPage(string.Format(((r == 0) ? " {0} " : " {0} r{1} "), cmpnt.Name, r)); MetrologyDlgFlowMeterTab uiControl = new MetrologyDlgFlowMeterTab(r); uiControl.MeterEntity = cmpnt; - uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibInfoCfg; + uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibRangesCfg; uiControl.Dock = DockStyle.Fill; tabPage.Tag = uiControl; tabPage.Controls.Add(uiControl); @@ -109,7 +124,7 @@ namespace TBF } } - // Pressure meter tab-pages + /// Pressure meter tab-pages if (factory is BenchControl.Elde.PressureMeter.PressureMeterFactory) { pressMetersCount++; @@ -122,7 +137,7 @@ namespace TBF metrologyTabControl.TabPages.Add(tabPage); } - // Temperature meter tab-pages + /// Temperature meter tab-pages if (factory is BenchControl.Elde.TempMeter.TempMeterFactory || factory is BenchControl.Elde.TempMeterInternal.TempMeterFactory) { @@ -136,7 +151,7 @@ namespace TBF metrologyTabControl.TabPages.Add(tabPage); } - // Platinum resistance temperature meter tab-pages + /// Platinum resistance temperature meter tab-pages if (factory is BenchControl.Keithley.TempMeter.Factory) { platinumTempMetersCount++; diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index 5474ef68c..014d861ae 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -2058,6 +2058,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Level. + /// + internal static string Level { + get { + return ResourceManager.GetString("Level", resourceCulture); + } + } + /// /// Looks up a localized string similar to Live. /// diff --git a/TBF/Resources/Strings.cs.resx b/TBF/Resources/Strings.cs.resx index f54dfc380..29adb043c 100644 --- a/TBF/Resources/Strings.cs.resx +++ b/TBF/Resources/Strings.cs.resx @@ -1335,4 +1335,7 @@ Chybí nádrž s měřením objemu + + Hladina + \ No newline at end of file diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 13fd12765..631d4b951 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -1873,4 +1873,7 @@ Missing a tank with volume measurement + + Level + \ No newline at end of file diff --git a/TBF/Resources/Strings.sk.resx b/TBF/Resources/Strings.sk.resx index 2784b1c36..31721e1d0 100644 --- a/TBF/Resources/Strings.sk.resx +++ b/TBF/Resources/Strings.sk.resx @@ -144,4 +144,7 @@ Zlyhala RFID komunikácia + + Hladina + \ No newline at end of file diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 700ab4f64..42dc5b7f6 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -515,6 +515,7 @@ ValveCfgCtrl.cs + @@ -524,7 +525,7 @@ - + @@ -2055,6 +2056,12 @@ MetrologyDlgPressMeterTab.cs + + UserControl + + + MetrologyDlgLevelMeterTab.cs + UserControl @@ -2910,6 +2917,9 @@ MetrologyDlgPressMeterTab.cs + + MetrologyDlgLevelMeterTab.cs + MetrologyDlgTempMeterTab.cs diff --git a/TBF/UiControls/MetrologyDlgFlowMeterTab.cs b/TBF/UiControls/MetrologyDlgFlowMeterTab.cs index 31570403a..875257a65 100644 --- a/TBF/UiControls/MetrologyDlgFlowMeterTab.cs +++ b/TBF/UiControls/MetrologyDlgFlowMeterTab.cs @@ -29,7 +29,7 @@ namespace TBF.UiControls /// /// Calibration information configuration /// - public BenchControl.GenericDevices.ICalibInfoCfg CalibInfoCfg; + public BenchControl.GenericDevices.ICalibRangesCfg CalibInfoCfg; /// /// A list of 'measurement-correction' pairs to be deleted from the database on OK. diff --git a/TBF/UiControls/MetrologyDlgLevelMeterTab.Designer.cs b/TBF/UiControls/MetrologyDlgLevelMeterTab.Designer.cs new file mode 100644 index 000000000..87fcd4d7c --- /dev/null +++ b/TBF/UiControls/MetrologyDlgLevelMeterTab.Designer.cs @@ -0,0 +1,291 @@ +/// +/// Copyright (c) 2018 Sensus Metering Systems +/// +namespace TBF.UiControls +{ + partial class MetrologyDlgLevelMeterTab + { + /// + /// 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 Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.calibrationGroupBox = new System.Windows.Forms.GroupBox(); + this.calibValidDateTextBox = new System.Windows.Forms.TextBox(); + this.calibValidDateLabel = new System.Windows.Forms.Label(); + this.calibDateTextBox = new System.Windows.Forms.TextBox(); + this.calibDateLabel = new System.Windows.Forms.Label(); + this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox(); + this.calibCertificateNrLabel = new System.Windows.Forms.Label(); + this.nameGroupBox = new System.Windows.Forms.GroupBox(); + this.pressFromToLabel = new System.Windows.Forms.Label(); + this.tempFromToLabel = new System.Windows.Forms.Label(); + this.cmpntNameLabel = new System.Windows.Forms.Label(); + this.testGroupBox = new System.Windows.Forms.GroupBox(); + this.correctedTextBox = new System.Windows.Forms.TextBox(); + this.measuredTextBox = new System.Windows.Forms.TextBox(); + this.correctedLabel = new System.Windows.Forms.Label(); + this.measuredLabel = new System.Windows.Forms.Label(); + this.listViewEx = new Results.Forms.ListViewEx(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.calibrationGroupBox.SuspendLayout(); + this.nameGroupBox.SuspendLayout(); + this.testGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox); + this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox); + this.splitContainer1.Panel1.Controls.Add(this.testGroupBox); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.listViewEx); + this.splitContainer1.Size = new System.Drawing.Size(650, 400); + this.splitContainer1.SplitterDistance = 102; + this.splitContainer1.TabIndex = 2; + // + // calibrationGroupBox + // + this.calibrationGroupBox.Controls.Add(this.calibValidDateTextBox); + this.calibrationGroupBox.Controls.Add(this.calibValidDateLabel); + this.calibrationGroupBox.Controls.Add(this.calibDateTextBox); + this.calibrationGroupBox.Controls.Add(this.calibDateLabel); + this.calibrationGroupBox.Controls.Add(this.calibCertificateNrTextBox); + this.calibrationGroupBox.Controls.Add(this.calibCertificateNrLabel); + this.calibrationGroupBox.Location = new System.Drawing.Point(186, 10); + this.calibrationGroupBox.Name = "calibrationGroupBox"; + this.calibrationGroupBox.Size = new System.Drawing.Size(228, 86); + this.calibrationGroupBox.TabIndex = 7; + this.calibrationGroupBox.TabStop = false; + this.calibrationGroupBox.Text = "Calibration"; + // + // calibValidDateTextBox + // + this.calibValidDateTextBox.Enabled = false; + this.calibValidDateTextBox.Location = new System.Drawing.Point(140, 59); + this.calibValidDateTextBox.Name = "calibValidDateTextBox"; + this.calibValidDateTextBox.Size = new System.Drawing.Size(82, 20); + this.calibValidDateTextBox.TabIndex = 15; + // + // calibValidDateLabel + // + this.calibValidDateLabel.AutoSize = true; + this.calibValidDateLabel.Location = new System.Drawing.Point(17, 62); + this.calibValidDateLabel.Name = "calibValidDateLabel"; + this.calibValidDateLabel.Size = new System.Drawing.Size(52, 13); + this.calibValidDateLabel.TabIndex = 14; + this.calibValidDateLabel.Text = "Valid until"; + // + // calibDateTextBox + // + this.calibDateTextBox.Enabled = false; + this.calibDateTextBox.Location = new System.Drawing.Point(140, 37); + this.calibDateTextBox.Name = "calibDateTextBox"; + this.calibDateTextBox.Size = new System.Drawing.Size(82, 20); + this.calibDateTextBox.TabIndex = 13; + // + // calibDateLabel + // + this.calibDateLabel.AutoSize = true; + this.calibDateLabel.Location = new System.Drawing.Point(17, 40); + this.calibDateLabel.Name = "calibDateLabel"; + this.calibDateLabel.Size = new System.Drawing.Size(30, 13); + this.calibDateLabel.TabIndex = 12; + this.calibDateLabel.Text = "Date"; + // + // calibCertificateNrTextBox + // + this.calibCertificateNrTextBox.Enabled = false; + this.calibCertificateNrTextBox.Location = new System.Drawing.Point(140, 15); + this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox"; + this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20); + this.calibCertificateNrTextBox.TabIndex = 11; + // + // calibCertificateNrLabel + // + this.calibCertificateNrLabel.AutoSize = true; + this.calibCertificateNrLabel.Location = new System.Drawing.Point(17, 18); + this.calibCertificateNrLabel.Name = "calibCertificateNrLabel"; + this.calibCertificateNrLabel.Size = new System.Drawing.Size(69, 13); + this.calibCertificateNrLabel.TabIndex = 10; + this.calibCertificateNrLabel.Text = "Certificate nr."; + // + // nameGroupBox + // + this.nameGroupBox.Controls.Add(this.pressFromToLabel); + this.nameGroupBox.Controls.Add(this.tempFromToLabel); + this.nameGroupBox.Controls.Add(this.cmpntNameLabel); + this.nameGroupBox.Location = new System.Drawing.Point(16, 10); + this.nameGroupBox.Name = "nameGroupBox"; + this.nameGroupBox.Size = new System.Drawing.Size(160, 86); + this.nameGroupBox.TabIndex = 5; + this.nameGroupBox.TabStop = false; + this.nameGroupBox.Text = "Component"; + // + // pressFromToLabel + // + this.pressFromToLabel.AutoSize = true; + this.pressFromToLabel.Location = new System.Drawing.Point(14, 62); + this.pressFromToLabel.Name = "pressFromToLabel"; + this.pressFromToLabel.Size = new System.Drawing.Size(0, 13); + this.pressFromToLabel.TabIndex = 2; + // + // tempFromToLabel + // + this.tempFromToLabel.AutoSize = true; + this.tempFromToLabel.Location = new System.Drawing.Point(14, 44); + this.tempFromToLabel.Name = "tempFromToLabel"; + this.tempFromToLabel.Size = new System.Drawing.Size(0, 13); + this.tempFromToLabel.TabIndex = 1; + // + // cmpntNameLabel + // + this.cmpntNameLabel.AutoSize = true; + this.cmpntNameLabel.Location = new System.Drawing.Point(43, 22); + this.cmpntNameLabel.Name = "cmpntNameLabel"; + this.cmpntNameLabel.Size = new System.Drawing.Size(64, 13); + this.cmpntNameLabel.TabIndex = 0; + this.cmpntNameLabel.Text = "cmpntName"; + // + // testGroupBox + // + this.testGroupBox.Controls.Add(this.correctedTextBox); + this.testGroupBox.Controls.Add(this.measuredTextBox); + this.testGroupBox.Controls.Add(this.correctedLabel); + this.testGroupBox.Controls.Add(this.measuredLabel); + this.testGroupBox.Location = new System.Drawing.Point(424, 10); + this.testGroupBox.Name = "testGroupBox"; + this.testGroupBox.Size = new System.Drawing.Size(170, 88); + this.testGroupBox.TabIndex = 4; + this.testGroupBox.TabStop = false; + this.testGroupBox.Text = "Correction test"; + // + // correctedTextBox + // + this.correctedTextBox.Location = new System.Drawing.Point(91, 37); + this.correctedTextBox.Name = "correctedTextBox"; + this.correctedTextBox.ReadOnly = true; + this.correctedTextBox.Size = new System.Drawing.Size(73, 20); + this.correctedTextBox.TabIndex = 5; + // + // measuredTextBox + // + this.measuredTextBox.Location = new System.Drawing.Point(91, 15); + this.measuredTextBox.Name = "measuredTextBox"; + this.measuredTextBox.Size = new System.Drawing.Size(73, 20); + this.measuredTextBox.TabIndex = 4; + this.measuredTextBox.TextChanged += new System.EventHandler(this.measuredTextBox_TextChanged); + // + // correctedLabel + // + this.correctedLabel.AutoSize = true; + this.correctedLabel.Location = new System.Drawing.Point(17, 40); + this.correctedLabel.Name = "correctedLabel"; + this.correctedLabel.Size = new System.Drawing.Size(53, 13); + this.correctedLabel.TabIndex = 3; + this.correctedLabel.Text = "Corrected"; + // + // measuredLabel + // + this.measuredLabel.AutoSize = true; + this.measuredLabel.Location = new System.Drawing.Point(17, 18); + this.measuredLabel.Name = "measuredLabel"; + this.measuredLabel.Size = new System.Drawing.Size(54, 13); + this.measuredLabel.TabIndex = 2; + this.measuredLabel.Text = "Measured"; + // + // listViewEx + // + this.listViewEx.AllowColumnReorder = true; + this.listViewEx.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewEx.DoubleClickActivation = false; + this.listViewEx.FullRowSelect = true; + this.listViewEx.GridLines = true; + this.listViewEx.Location = new System.Drawing.Point(0, 0); + this.listViewEx.Name = "listViewEx"; + this.listViewEx.Size = new System.Drawing.Size(650, 294); + this.listViewEx.TabIndex = 0; + this.listViewEx.UseCompatibleStateImageBehavior = false; + this.listViewEx.View = System.Windows.Forms.View.Details; + this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged); + // + // MetrologyDlgLevelMeterTab + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer1); + this.Name = "MetrologyDlgLevelMeterTab"; + this.Size = new System.Drawing.Size(650, 400); + this.Load += new System.EventHandler(this.MetrologyDlgLevelMeterTab_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.calibrationGroupBox.ResumeLayout(false); + this.calibrationGroupBox.PerformLayout(); + this.nameGroupBox.ResumeLayout(false); + this.nameGroupBox.PerformLayout(); + this.testGroupBox.ResumeLayout(false); + this.testGroupBox.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Label cmpntNameLabel; + private Results.Forms.ListViewEx listViewEx; + private System.Windows.Forms.GroupBox testGroupBox; + private System.Windows.Forms.TextBox correctedTextBox; + private System.Windows.Forms.TextBox measuredTextBox; + private System.Windows.Forms.Label correctedLabel; + private System.Windows.Forms.Label measuredLabel; + private System.Windows.Forms.GroupBox nameGroupBox; + private System.Windows.Forms.GroupBox calibrationGroupBox; + private System.Windows.Forms.TextBox calibValidDateTextBox; + private System.Windows.Forms.Label calibValidDateLabel; + private System.Windows.Forms.TextBox calibDateTextBox; + private System.Windows.Forms.Label calibDateLabel; + private System.Windows.Forms.TextBox calibCertificateNrTextBox; + private System.Windows.Forms.Label calibCertificateNrLabel; + private System.Windows.Forms.Label pressFromToLabel; + private System.Windows.Forms.Label tempFromToLabel; + + } +} diff --git a/TBF/UiControls/MetrologyDlgLevelMeterTab.cs b/TBF/UiControls/MetrologyDlgLevelMeterTab.cs new file mode 100644 index 000000000..3a283bc14 --- /dev/null +++ b/TBF/UiControls/MetrologyDlgLevelMeterTab.cs @@ -0,0 +1,342 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using TBF.Resources; + +namespace TBF.UiControls +{ + public partial class MetrologyDlgLevelMeterTab : UserControl, IMetrologyDlgTab + { + static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgLevelMeterTab)); + + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + Component meterEntity; + public Component MeterEntity + { + get { return meterEntity; } + set { meterEntity = value; } + } + + /// + /// Calibration information configuration + /// + public BenchControl.GenericDevices.ICalibInfoCfg CalibInfoCfg; + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + public IList ToBeRemoved + { + get { return toBeRemoved; } + set { toBeRemoved = value; } + } + IList toBeRemoved; + + MetrologyDlg parent; + bool unlocked; + Control measurementTextBox; + Control correctionTextBox; + + + public MetrologyDlgLevelMeterTab() + { + InitializeComponent(); + toBeRemoved = new List(); + } + + private void MetrologyDlgLevelMeterTab_Load(object sender, System.EventArgs e) + { + if (meterEntity == null) return; + + parent = ParentForm as MetrologyDlg; + + Localize(); + + /// Panel1 + cmpntNameLabel.Text = meterEntity.Name; + testGroupBox.Text = Strings.Test_measured_corrected; + measuredLabel.Text = Strings.Measured; + correctedLabel.Text = Strings.Corrected; + measuredTextBox.Text = string.Empty; + correctedTextBox.Text = string.Empty; + + /// Panel2 + measurementTextBox = new TextBox(); + correctionTextBox = new TextBox(); + this.Controls.Add(measurementTextBox); + this.Controls.Add(correctionTextBox); + + listViewEx.SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked); + listViewEx.SubItemRightClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemRightClicked); + listViewEx.SubItemEndEditing += new Results.Forms.SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing); + + listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 60 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mm]", Strings.Level), Width = 100 }); + listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mm]", Strings.Correction), Width = 100 }); + + RefreshAll(); + } + + void Localize() + { + nameGroupBox.Text = Strings.Component; + + calibrationGroupBox.Text = Strings.Calibration; + calibCertificateNrLabel.Text = Strings.Certificate; + calibDateLabel.Text = Strings.Date; + calibValidDateLabel.Text = Strings.Valid_until; + + testGroupBox.Text = Strings.Test_measured_corrected; + measuredLabel.Text = Strings.Measured; + correctedLabel.Text = Strings.Corrected; + } + + void RefreshAll() + { + if (CalibInfoCfg != null) + { + calibCertificateNrTextBox.Text = CalibInfoCfg.CalibCertificateNr; + calibDateTextBox.Text = CalibInfoCfg.CalibDate.ToShortDateString(); + calibValidDateTextBox.Text = CalibInfoCfg.CalibValidDate.ToShortDateString(); + } + + listViewEx.Items.Clear(); + foreach (var corr in MeterEntity.Corrections) + { + AddOneLVI(corr); + } + } + + void AddOneLVI(MeasurementCorrection corr) + { + int nr = listViewEx.Items.Count + 1; + ListViewItem lvi = new ListViewItem(nr.ToString()); + lvi.SubItems.Add(corr.Measurement.ToString()); + lvi.SubItems.Add((corr.Correction).ToString()); + lvi.Tag = corr; + listViewEx.Items.Add(lvi); + } + + void listViewEx_SubItemClicked(object sender, Results.Forms.SubItemEventArgs e) + { + if (unlocked && e.SubItem == 1) + { + listViewEx.StartEditing(measurementTextBox, e.Item, e.SubItem); + } + else if (unlocked && e.SubItem == 2) + { + listViewEx.StartEditing(correctionTextBox, e.Item, e.SubItem); + } + } + + void listViewEx_SubItemRightClicked(object sender, Results.Forms.SubItemEventArgs e) + { + if (!unlocked || e.SubItem < 1 || e.SubItem > 2) return; + + if (DialogResult.Yes == MessageBox.Show(Strings.Do_you_want_to_copy_this_value_to_all_cells_below_this_cell, + Strings.Confirmation, MessageBoxButtons.YesNo, MessageBoxIcon.Question)) + { + int columnNr = e.SubItem; + string value = null; + System.Drawing.Color backColor = System.Drawing.Color.White; + + foreach (ListViewItem item in listViewEx.Items) + { + if (value != null && item.SubItems.Count > columnNr) + { + item.SubItems[columnNr].Text = value; + item.SubItems[columnNr].BackColor = backColor; + ParseItem(item, columnNr, value); + } + else if (item == e.Item) + { + value = item.SubItems[columnNr].Text; + backColor = item.SubItems[columnNr].BackColor; + } + } + } + } + + void listViewEx_SubItemEndEditing(object sender, Results.Forms.SubItemEndEditingEventArgs e) + { + if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return; + + /// New value NOK, revert the original text + e.DisplayText = e.Item.Text; + e.Cancel = true; + } + + /// + /// Parse text of a ListViewItem + /// + /// true = value parsed OK + bool ParseItem(ListViewItem item, int subItem, string value) + { + float fvalue; + if (subItem == 1 && Utils.TryParseEFloat(value, out fvalue) && fvalue >= 0) + { + (item.Tag as MeasurementCorrection).Measurement = fvalue; + return true; + } + else if (subItem == 2 && Utils.TryParseEFloat(value, out fvalue)) + { + (item.Tag as MeasurementCorrection).Correction = fvalue; + return true; + } + else + { + return false; + } + } + + public void Unlock() + { + unlocked = true; + + calibCertificateNrTextBox.Enabled = true; + calibDateTextBox.Enabled = true; + calibValidDateTextBox.Enabled = true; + + if (listViewEx.SelectedItems.Count == 1) + { + int ix = listViewEx.SelectedIndices[0]; + listViewEx.Focus(); + listViewEx.Items[ix].Selected = true; + listViewEx.Items[ix].EnsureVisible(); + } + } + + public void OkBtnClicked() + { + if (CalibInfoCfg != null) + { + try + { + CalibInfoCfg.CalibCertificateNr = calibCertificateNrTextBox.Text; + CalibInfoCfg.CalibDate = DateTime.Parse(calibDateTextBox.Text); + CalibInfoCfg.CalibValidDate = DateTime.Parse(calibValidDateTextBox.Text); + + Component modified = CalibInfoCfg.CreateDbEntity(); + MeterEntity.Parameters = modified.Parameters; + } + catch + { + MessageBox.Show(Strings.Invalid_calib_info_Correct_pls, + Strings.Error, + MessageBoxButtons.OK, + MessageBoxIcon.Exclamation); + } + } + } + + public void CancelBtnClicked() + { + } + + public void AddOne() + { + MeasurementCorrection corr = new MeasurementCorrection(); + MeterEntity.Corrections.Add(corr); + AddOneLVI(corr); + + listViewEx.Focus(); + listViewEx.SelectedItems.Clear(); + listViewEx.Items[listViewEx.Items.Count - 1].Selected = true; + listViewEx.Items[listViewEx.Items.Count - 1].EnsureVisible(); + } + + public void RemoveSelected() + { + if (listViewEx.SelectedItems.Count != 1) return; + + int removeItemNr = listViewEx.SelectedIndices[0]; + + MeasurementCorrection selected = (MeasurementCorrection)listViewEx.SelectedItems[0].Tag; + if (selected.Id != 0) toBeRemoved.Add(selected); + MeterEntity.Corrections.RemoveAt(removeItemNr); + RefreshAll(); + + if (removeItemNr < listViewEx.Items.Count) + { + listViewEx.Focus(); + listViewEx.Items[removeItemNr].Selected = true; + listViewEx.Items[removeItemNr].EnsureVisible(); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + } + + public void MoveUpSelected() + { + } + + public void MoveDownSelected() + { + } + + /// + /// Event handler that indicates the selected item position + /// and updates 'Remove', 'Up' and 'Down' buttons in the parent dialog. + /// + private void listViewEx_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewEx.SelectedItems.Count != 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None); + } + else if (listViewEx.Items.Count == 1) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.FirstAndLast); + } + else if (listViewEx.SelectedIndices[0] == 0) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.First); + } + else if (listViewEx.SelectedIndices[0] == (listViewEx.Items.Count - 1)) + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Last); + } + else + { + parent.UpdateButtonStates(SharedButtons.SelectedItemPos.Middle); + } + } + + private void measuredTextBox_TextChanged(object sender, EventArgs e) + { + float measured; + if (float.TryParse(measuredTextBox.Text, + NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent, + CultureInfo.CurrentCulture, + out measured) || + float.TryParse(measuredTextBox.Text, + NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent, + CultureInfo.InvariantCulture, + out measured)) + { + double corrected = Config.Formulas.CorrectedValue(measured, meterEntity.Corrections); + correctedTextBox.Text = corrected.ToString(); + } + } + + public string GetWarningsBeforeSaving(ref Dictionary renmInfo) + { + return string.Empty; + } + + public void UpdateRelatedItems(Dictionary renameInfo) + { + } + } +} diff --git a/TBF/UiControls/MetrologyDlgLevelMeterTab.resx b/TBF/UiControls/MetrologyDlgLevelMeterTab.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/UiControls/MetrologyDlgLevelMeterTab.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