diff --git a/TBF/BenchControl/Elde/Diverter/DiverterCfg.cs b/TBF/BenchControl/Elde/Diverter/DiverterCfg.cs index 4d04c77ac..38bc8a0df 100644 --- a/TBF/BenchControl/Elde/Diverter/DiverterCfg.cs +++ b/TBF/BenchControl/Elde/Diverter/DiverterCfg.cs @@ -1,6 +1,7 @@ /// /// Copyright (c) 2013-2016 Sensus Metering Systems /// +using System; using System.IO; using System.Collections.Generic; using System.Xml.Serialization; @@ -8,7 +9,7 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.Elde.Diverter { - public class DiverterCfg : ComponentCfgBase, IChildComponentCfg + public class DiverterCfg : ComponentCfgBase, IChildComponentCfg, GenericDevices.ICalibInfoCfg { public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DiverterCfg) })[0]; public override XmlSerializer GetSerializer() { return Serializer; } @@ -26,6 +27,27 @@ namespace TBF.BenchControl.Elde.Diverter public int ThresholdLo; /// 0..100 in %, threshold for low level when diverter transition time is measured public int ThresholdHi; /// 0..100 in %, threshold for high level when diverter transition time is measured + /// Calibration info serialized parameters displayed in Metrology tab page + string calibCertificateNr; + DateTime calibDate; + DateTime calibValidDate; + public string CalibCertificateNr + { + get { return calibCertificateNr; } + set { calibCertificateNr = value; } + } + public DateTime CalibDate + { + get { return calibDate; } + set { calibDate = value; } + } + public DateTime CalibValidDate + { + get { return calibValidDate; } + set { calibValidDate = value; } + } + + /// Private parameterless constructor invoked by all other (public) constructors DiverterCfg() { @@ -38,6 +60,7 @@ namespace TBF.BenchControl.Elde.Diverter StartingLevel = 50; ThresholdLo = 10; ThresholdHi = 90; + calibCertificateNr = string.Empty; } public DiverterCfg(IComponentFactory factory) diff --git a/TBF/BenchControl/Output/DB/SaveDiverterCorrections/Factory.cs b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/Factory.cs new file mode 100644 index 000000000..8e50656b8 --- /dev/null +++ b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { SaveDiverterCorr.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new SaveDiverterCorr(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new SaveDiverterCorr(cfg); } + + public IComponentCfg DefaultConfig() { return new SaveDiverterCorrCfg(this.GetType().Namespace.Substring(24), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(SaveDiverterCorrCfg.Serializer, component, this); + } + } +} diff --git a/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorr.cs b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorr.cs new file mode 100644 index 000000000..0549cf6e3 --- /dev/null +++ b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorr.cs @@ -0,0 +1,254 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using NHibernate; +using NHibernate.Criterion; +using Config; +using Config.Entities; +using TracingDB.Entities; +using TBF.BenchControl.Generic; +using TBF.BenchControl.GenericDevices; + +namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections +{ + public enum Retv + { + OK, + Error, + } + + public class SaveDiverterCorr : ComponentBase, IOperation, GenericDevices.IResultsWriter + { + private static readonly ILog log = LogManager.GetLogger(typeof(SaveDiverterCorr)); + public override string ToString() { return string.Format("SaveDiverterCorr({0})", Cfg.ToString(1)); } + + SaveDiverterCorrCfg myCfg; + + enum CurrentOp + { + None, + SaveDiverterCorrections, + } + + CurrentOp currentOp; + bool opCompleted; + bool anyError; + + /// + /// Results to parse for reference flowmeter corrections + /// + Results.Entities.Batch batch; + IList newCorrections; + + + public SaveDiverterCorr() {} + + public SaveDiverterCorr(Generic.IComponentCfg cfg) + : base(cfg) + { + myCfg = cfg as SaveDiverterCorrCfg; + currentOp = CurrentOp.None; + + log.Debug(this.ToString()); + } + + + /// + /// Writes the test cycle results into a file, Events: Event.ResultsWritten + /// + /// Procedure to print the results of + /// Results to write into the file + /// Reference to the operation + public IOperation WriteResultsOp(Results.Entities.Batch batch) + { + if (currentOp != CurrentOp.None) + throw new Exception("Sequence error"); + else + currentOp = CurrentOp.SaveDiverterCorrections; + + this.batch = batch; + + return this; + } + + + IList GetCorrections(Results.Entities.Batch batch, string diverterName) + { + /// Create a list of all test flows in this procedure + IList targetFlows = new List(); + foreach (var tr in batch.TestRslts) + { + if (tr.TestDone && tr.Evaluate() && + (tr.Name().Contains(myCfg.PatternForShortTests) || tr.Name().Contains(myCfg.PatternForLongTests)) && + (tr.Components != null) && (tr.Components.Diverter == diverterName)) + { + double trgtFlow = (tr.TestData.Qfrom + tr.TestData.Qto) / 2; + if (!targetFlows.Contains(trgtFlow)) targetFlows.Add(trgtFlow); + } + } + + IList rslt = new List(); + + foreach (double trgtFlow in targetFlows) + { + IList shortTestRslts = new List(); + IList longTestRslts = new List(); + /// + foreach (var tr in batch.TestRslts) + { + if (tr.TestDone && tr.Evaluate() && (tr.Components != null) && (tr.Components.Diverter == diverterName) && + (trgtFlow == (tr.TestData.Qfrom + tr.TestData.Qto) / 2)) + { + if (tr.Name().Contains(myCfg.PatternForShortTests)) shortTestRslts.Add(tr); + else if (tr.Name().Contains(myCfg.PatternForLongTests)) longTestRslts.Add(tr); + } + } + + if (shortTestRslts.Count == 1 && longTestRslts.Count == 1) + { + Results.Entities.TestRslt shTR = shortTestRslts[0]; + Results.Entities.TestRslt loTR = longTestRslts[0]; + + /// Calculate a correction and add it to the list + try + { + double factor = loTR.PulsesMaster / shTR.PulsesMaster * (shTR.MassEnd - shTR.MassStart) / (loTR.MassEnd - loTR.MassStart); + double correction = loTR.TestTime / (myCfg.ShortTestDiversionsCount - 1) * (factor - 1.0); + rslt.Add(new MeasurementCorrection { RangeIx = 0, Measurement = (float)trgtFlow, Correction = (float)correction }); + log.InfoFormat("Calculated diverter correction at {0} m3/h: {1} s", trgtFlow, correction); + } + catch (Exception exc) + { + log.ErrorFormat("Error when calculationg diverter correction at {0} m3/h: {1}", trgtFlow, exc.Message); + } + + } + } + + return rslt; + } + + + void DeleteExistingCorrections(ISession session, Component cmpnt) + { + for (int i = cmpnt.Corrections.Count - 1; i >= 0; i--) + { + session.Delete(cmpnt.Corrections[i]); + cmpnt.Corrections.RemoveAt(i); + } + session.SaveOrUpdate(cmpnt); + } + + + void SaveNewCorrections(ISession session, Component cmpnt, IList corrections) + { + if (cmpnt.Corrections == null) cmpnt.Corrections = new List(); + + foreach (var mc in corrections) + { + mc.RangeIx = 0; + cmpnt.Corrections.Add(mc); + session.SaveOrUpdate(mc); + } + + ICalibInfoCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt) as ICalibInfoCfg; + if (cfg != null) + { + cfg.CalibCertificateNr = string.Format(myCfg.CertificateFmt, batch.StartTime, batch.EndTime, batch.BatchNr); + cfg.CalibDate = DateTime.Now; + cfg.CalibValidDate = DateTime.Now + new TimeSpan(myCfg.ValidityDays, 0, 0, 0); + + Component modified = cfg.CreateDbEntity(); + cmpnt.Parameters = modified.Parameters; + } + + session.SaveOrUpdate(cmpnt); + } + + + /// Start this operation + public void Start() + { + opCompleted = false; + anyError = false; + } + + /// Run this operation + /// Event.ResultsWritten or Event.Error + public Event Run() + { + if (myCfg.DebugLevel == DebugMode.Simulate) + { + opCompleted = true; + return Event.ResultsWritten; + } + + if (currentOp == CurrentOp.SaveDiverterCorrections) + { + if (!opCompleted) + { + ITransaction transaction = null; + try + { + ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config); + transaction = session.BeginTransaction(); + + for (int div = 1; div <= myCfg.DivertersCount(); div++) + { + string diverterName = myCfg.GetDiverterName(div); + Elde.Diverter.Diverter diverter = TbfComponents.FindComponent(diverterName) as Elde.Diverter.Diverter; + + if (diverter != null) + { + var cmpntEntities = session.QueryOver() + .Where(cmpnt => (cmpnt.Name == diverterName)) + .List(); + + if (cmpntEntities.Count != 1) + { + log.ErrorFormat("No unique diverter named {0}", diverterName); + continue; + } + + newCorrections = GetCorrections(batch, diverterName); + DeleteExistingCorrections(session, cmpntEntities[0]); + SaveNewCorrections(session, cmpntEntities[0], newCorrections); + } + } + + transaction.Commit(); + session.Flush(); + opCompleted = true; + + log.WarnFormat("Measurement corrections successfully saved"); + } + catch (Exception exc) + { + if (transaction != null && !transaction.WasCommitted) transaction.Rollback(); + anyError = true; + + log.ErrorFormat("Failed to write corrections calculated from batch {0}: {1}", batch.BatchNr, exc.Message); + } + } + + if (anyError) + return Event.ResultsNotWritten; + else + return Event.ResultsWritten; + } + else + { + return Event.None; + } + } + + /// Stop this operation + public void Stop() + { + currentOp = CurrentOp.None; + } + } +} diff --git a/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfg.cs b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfg.cs new file mode 100644 index 000000000..fc1c2cce9 --- /dev/null +++ b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfg.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System.Xml.Serialization; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections +{ + public class SaveDiverterCorrCfg : ComponentCfgBase, Generic.IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(SaveDiverterCorrCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl() { return new SaveDiverterCorrCfgCtrl(); } + + public string Diverter1; + public string Diverter2; + public string Diverter3; + public string Diverter4; + public string Diverter5; + public string Diverter6; + public string PatternForShortTests; + public string PatternForLongTests; + public int ShortTestDiversionsCount; + + public string CertificateFmt; + public int ValidityDays; + + public int DivertersCount() { return 6; } + + /// + /// Get flowmeter name + /// + /// Flowmeter index 1 .. FlowmetersCount()==7 + /// Flowmeter name or null + public string GetDiverterName(int d) + { + switch (d) + { + case 1: return Diverter1; + case 2: return Diverter2; + case 3: return Diverter3; + case 4: return Diverter4; + case 5: return Diverter5; + case 6: return Diverter6; + case 7: return ShortTestDiversionsCount.ToString(); + default: return null; + } + } + + + /// Private parameterless constructor invoked by all other (public) constructors + SaveDiverterCorrCfg() + { + ParentName = string.Empty; + Diverter1 = "Div1"; + Diverter2 = "Div2"; + Diverter3 = null; + Diverter4 = null; + Diverter5 = null; + Diverter6 = null; + ShortTestDiversionsCount = 10; + PatternForShortTests = "short"; + PatternForLongTests = "long"; + } + + public SaveDiverterCorrCfg(string name, IComponentFactory factory) + : this() + { + this.Name = name; + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}, Flowmtr1={1}, Flowmtr2={2}, Flowmtr3={3}, Flowmtr4={4}, Flowmtr5={5}, Flowmtr6={6}", + Name, + string.IsNullOrEmpty(Diverter1) ? "---" : Diverter1, + string.IsNullOrEmpty(Diverter2) ? "---" : Diverter2, + string.IsNullOrEmpty(Diverter3) ? "---" : Diverter3, + string.IsNullOrEmpty(Diverter4) ? "---" : Diverter4, + string.IsNullOrEmpty(Diverter5) ? "---" : Diverter5, + string.IsNullOrEmpty(Diverter6) ? "---" : Diverter6); + } + } +} diff --git a/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.cs b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.cs new file mode 100644 index 000000000..7b38347b5 --- /dev/null +++ b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.cs @@ -0,0 +1,185 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections +{ + public partial class SaveDiverterCorrCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl + { + public bool ShowMore { get { return false; } } + + + ComponentParametersDlg parent; + + + SaveDiverterCorrCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as SaveDiverterCorrCfg; + Redraw(); + } + } + + public SaveDiverterCorrCfgCtrl() + { + InitializeComponent(); + } + + private void WriterCfgCtrl_Load(object sender, EventArgs e) + { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + if (parent.TbfComponents != null) + { + diverter1ComboBox.Items.Add("---"); + diverter2ComboBox.Items.Add("---"); + diverter3ComboBox.Items.Add("---"); + diverter4ComboBox.Items.Add("---"); + diverter5ComboBox.Items.Add("---"); + diverter6ComboBox.Items.Add("---"); + /// + foreach (var cmpnt in parent.TbfComponents) + { + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.BenchControl.Elde.Diverter.DiverterFactory) + { + diverter1ComboBox.Items.Add(cmpnt.Name); + diverter2ComboBox.Items.Add(cmpnt.Name); + diverter3ComboBox.Items.Add(cmpnt.Name); + diverter4ComboBox.Items.Add(cmpnt.Name); + diverter5ComboBox.Items.Add(cmpnt.Name); + diverter6ComboBox.Items.Add(cmpnt.Name); + } + } + } + + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + + diverter1ComboBox.Text = string.IsNullOrEmpty(config.Diverter1) ? "---" : config.Diverter1; + diverter2ComboBox.Text = string.IsNullOrEmpty(config.Diverter2) ? "---" : config.Diverter2; + diverter3ComboBox.Text = string.IsNullOrEmpty(config.Diverter3) ? "---" : config.Diverter3; + diverter4ComboBox.Text = string.IsNullOrEmpty(config.Diverter4) ? "---" : config.Diverter4; + diverter5ComboBox.Text = string.IsNullOrEmpty(config.Diverter5) ? "---" : config.Diverter5; + diverter6ComboBox.Text = string.IsNullOrEmpty(config.Diverter6) ? "---" : config.Diverter6; + patternShortTextBox.Text = config.PatternForShortTests; + patternLongTextBox.Text = config.PatternForLongTests; + diversionsCountTextBox.Text = config.ShortTestDiversionsCount.ToString(); + certificateTextBox.Text = config.CertificateFmt; + validityTextBox.Text = config.ValidityDays.ToString(); + } + + public void Unlock() + { + nameTextBox.Enabled = true; + + diverter1ComboBox.Enabled = true; + diverter2ComboBox.Enabled = true; + diverter3ComboBox.Enabled = true; + diverter4ComboBox.Enabled = true; + diverter5ComboBox.Enabled = true; + diverter6ComboBox.Enabled = true; + patternShortTextBox.Enabled = true; + patternLongTextBox.Enabled = true; + diversionsCountTextBox.Enabled = true; + certificateTextBox.Enabled = true; + validityTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + if (!diverter1ComboBox.Items.Contains(diverter1ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", diverter1Label.Text); + } + if (!diverter2ComboBox.Items.Contains(diverter2ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", diverter2Label.Text); + } + if (!diverter3ComboBox.Items.Contains(diverter3ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", diverter3Label.Text); + } + if (!diverter4ComboBox.Items.Contains(diverter4ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", diverter4Label.Text); + } + if (!diverter5ComboBox.Items.Contains(diverter5ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", diverter5Label.Text); + } + if (!diverter6ComboBox.Items.Contains(diverter6ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", diverter6Label.Text); + } + + int tmp; + if (!int.TryParse(diversionsCountTextBox.Text, out tmp) || tmp <= 2) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", validityLabel.Text); + } + + if (!int.TryParse(validityTextBox.Text, out tmp) || tmp < 0) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + string.Format("Invalid {0}", validityLabel.Text); + } + + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + if (config.Name != nameTextBox.Text) + { + config.Name = nameTextBox.Text; + flags |= CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd; + } + + flags |= UpdateDifferent(ref config.Diverter1, diverter1ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.Diverter2, diverter2ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.Diverter3, diverter3ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.Diverter4, diverter4ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.Diverter5, diverter5ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.Diverter6, diverter6ComboBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.PatternForShortTests, patternShortTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.PatternForLongTests, patternLongTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.ShortTestDiversionsCount, diversionsCountTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.CertificateFmt, certificateTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + flags |= UpdateDifferent(ref config.ValidityDays, validityTextBox.Text, CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd); + + return flags; + } + } +} diff --git a/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.designer.cs b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.designer.cs new file mode 100644 index 000000000..3b2fcd92f --- /dev/null +++ b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.designer.cs @@ -0,0 +1,369 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections +{ + partial class SaveDiverterCorrCfgCtrl + { + /// + /// 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.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.diverter1Label = new System.Windows.Forms.Label(); + this.diverter1ComboBox = new System.Windows.Forms.ComboBox(); + this.diverter2ComboBox = new System.Windows.Forms.ComboBox(); + this.diverter2Label = new System.Windows.Forms.Label(); + this.diverter3ComboBox = new System.Windows.Forms.ComboBox(); + this.diverter3Label = new System.Windows.Forms.Label(); + this.diverter4ComboBox = new System.Windows.Forms.ComboBox(); + this.diverter4Label = new System.Windows.Forms.Label(); + this.diverter5ComboBox = new System.Windows.Forms.ComboBox(); + this.diverter5Label = new System.Windows.Forms.Label(); + this.diverter6ComboBox = new System.Windows.Forms.ComboBox(); + this.diverter6Label = new System.Windows.Forms.Label(); + this.certificateTextBox = new System.Windows.Forms.TextBox(); + this.certificateLabel = new System.Windows.Forms.Label(); + this.validityTextBox = new System.Windows.Forms.TextBox(); + this.validityLabel = new System.Windows.Forms.Label(); + this.paternShortLabel = new System.Windows.Forms.Label(); + this.patternShortTextBox = new System.Windows.Forms.TextBox(); + this.patternLongTextBox = new System.Windows.Forms.TextBox(); + this.patternLongLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.diversionsCountTextBox = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(124, 31); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(285, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(15, 34); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(136, 9); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "ComonentName"; + // + // diverter1Label + // + this.diverter1Label.AutoSize = true; + this.diverter1Label.Location = new System.Drawing.Point(15, 57); + this.diverter1Label.Name = "diverter1Label"; + this.diverter1Label.Size = new System.Drawing.Size(53, 13); + this.diverter1Label.TabIndex = 3; + this.diverter1Label.Text = "Diverter 1"; + // + // diverter1ComboBox + // + this.diverter1ComboBox.Enabled = false; + this.diverter1ComboBox.FormattingEnabled = true; + this.diverter1ComboBox.Location = new System.Drawing.Point(124, 54); + this.diverter1ComboBox.Name = "diverter1ComboBox"; + this.diverter1ComboBox.Size = new System.Drawing.Size(69, 21); + this.diverter1ComboBox.TabIndex = 4; + // + // diverter2ComboBox + // + this.diverter2ComboBox.Enabled = false; + this.diverter2ComboBox.FormattingEnabled = true; + this.diverter2ComboBox.Location = new System.Drawing.Point(124, 78); + this.diverter2ComboBox.Name = "diverter2ComboBox"; + this.diverter2ComboBox.Size = new System.Drawing.Size(69, 21); + this.diverter2ComboBox.TabIndex = 6; + // + // diverter2Label + // + this.diverter2Label.AutoSize = true; + this.diverter2Label.Location = new System.Drawing.Point(15, 81); + this.diverter2Label.Name = "diverter2Label"; + this.diverter2Label.Size = new System.Drawing.Size(53, 13); + this.diverter2Label.TabIndex = 5; + this.diverter2Label.Text = "Diverter 2"; + // + // diverter3ComboBox + // + this.diverter3ComboBox.Enabled = false; + this.diverter3ComboBox.FormattingEnabled = true; + this.diverter3ComboBox.Location = new System.Drawing.Point(124, 102); + this.diverter3ComboBox.Name = "diverter3ComboBox"; + this.diverter3ComboBox.Size = new System.Drawing.Size(69, 21); + this.diverter3ComboBox.TabIndex = 8; + // + // diverter3Label + // + this.diverter3Label.AutoSize = true; + this.diverter3Label.Location = new System.Drawing.Point(15, 105); + this.diverter3Label.Name = "diverter3Label"; + this.diverter3Label.Size = new System.Drawing.Size(53, 13); + this.diverter3Label.TabIndex = 7; + this.diverter3Label.Text = "Diverter 3"; + // + // diverter4ComboBox + // + this.diverter4ComboBox.Enabled = false; + this.diverter4ComboBox.FormattingEnabled = true; + this.diverter4ComboBox.Location = new System.Drawing.Point(124, 126); + this.diverter4ComboBox.Name = "diverter4ComboBox"; + this.diverter4ComboBox.Size = new System.Drawing.Size(69, 21); + this.diverter4ComboBox.TabIndex = 10; + // + // diverter4Label + // + this.diverter4Label.AutoSize = true; + this.diverter4Label.Location = new System.Drawing.Point(15, 129); + this.diverter4Label.Name = "diverter4Label"; + this.diverter4Label.Size = new System.Drawing.Size(53, 13); + this.diverter4Label.TabIndex = 9; + this.diverter4Label.Text = "Diverter 4"; + // + // diverter5ComboBox + // + this.diverter5ComboBox.Enabled = false; + this.diverter5ComboBox.FormattingEnabled = true; + this.diverter5ComboBox.Location = new System.Drawing.Point(124, 150); + this.diverter5ComboBox.Name = "diverter5ComboBox"; + this.diverter5ComboBox.Size = new System.Drawing.Size(69, 21); + this.diverter5ComboBox.TabIndex = 12; + // + // diverter5Label + // + this.diverter5Label.AutoSize = true; + this.diverter5Label.Location = new System.Drawing.Point(15, 153); + this.diverter5Label.Name = "diverter5Label"; + this.diverter5Label.Size = new System.Drawing.Size(53, 13); + this.diverter5Label.TabIndex = 11; + this.diverter5Label.Text = "Diverter 5"; + // + // diverter6ComboBox + // + this.diverter6ComboBox.Enabled = false; + this.diverter6ComboBox.FormattingEnabled = true; + this.diverter6ComboBox.Location = new System.Drawing.Point(124, 174); + this.diverter6ComboBox.Name = "diverter6ComboBox"; + this.diverter6ComboBox.Size = new System.Drawing.Size(69, 21); + this.diverter6ComboBox.TabIndex = 14; + // + // diverter6Label + // + this.diverter6Label.AutoSize = true; + this.diverter6Label.Location = new System.Drawing.Point(15, 177); + this.diverter6Label.Name = "diverter6Label"; + this.diverter6Label.Size = new System.Drawing.Size(53, 13); + this.diverter6Label.TabIndex = 13; + this.diverter6Label.Text = "Diverter 6"; + // + // certificateTextBox + // + this.certificateTextBox.Enabled = false; + this.certificateTextBox.Location = new System.Drawing.Point(124, 244); + this.certificateTextBox.Name = "certificateTextBox"; + this.certificateTextBox.Size = new System.Drawing.Size(285, 20); + this.certificateTextBox.TabIndex = 20; + // + // certificateLabel + // + this.certificateLabel.AutoSize = true; + this.certificateLabel.Location = new System.Drawing.Point(15, 247); + this.certificateLabel.Name = "certificateLabel"; + this.certificateLabel.Size = new System.Drawing.Size(54, 13); + this.certificateLabel.TabIndex = 19; + this.certificateLabel.Text = "Certificate"; + // + // validityTextBox + // + this.validityTextBox.Enabled = false; + this.validityTextBox.Location = new System.Drawing.Point(124, 267); + this.validityTextBox.Name = "validityTextBox"; + this.validityTextBox.Size = new System.Drawing.Size(43, 20); + this.validityTextBox.TabIndex = 22; + // + // validityLabel + // + this.validityLabel.AutoSize = true; + this.validityLabel.Location = new System.Drawing.Point(15, 270); + this.validityLabel.Name = "validityLabel"; + this.validityLabel.Size = new System.Drawing.Size(71, 13); + this.validityLabel.TabIndex = 21; + this.validityLabel.Text = "Validity (days)"; + // + // paternShortLabel + // + this.paternShortLabel.AutoSize = true; + this.paternShortLabel.Location = new System.Drawing.Point(15, 201); + this.paternShortLabel.Name = "paternShortLabel"; + this.paternShortLabel.Size = new System.Drawing.Size(107, 13); + this.paternShortLabel.TabIndex = 15; + this.paternShortLabel.Text = "Pattern for short tests"; + // + // patternShortTextBox + // + this.patternShortTextBox.Enabled = false; + this.patternShortTextBox.Location = new System.Drawing.Point(124, 198); + this.patternShortTextBox.Name = "patternShortTextBox"; + this.patternShortTextBox.Size = new System.Drawing.Size(107, 20); + this.patternShortTextBox.TabIndex = 16; + // + // patternLongTextBox + // + this.patternLongTextBox.Enabled = false; + this.patternLongTextBox.Location = new System.Drawing.Point(124, 221); + this.patternLongTextBox.Name = "patternLongTextBox"; + this.patternLongTextBox.Size = new System.Drawing.Size(107, 20); + this.patternLongTextBox.TabIndex = 18; + // + // patternLongLabel + // + this.patternLongLabel.AutoSize = true; + this.patternLongLabel.Location = new System.Drawing.Point(15, 224); + this.patternLongLabel.Name = "patternLongLabel"; + this.patternLongLabel.Size = new System.Drawing.Size(104, 13); + this.patternLongLabel.TabIndex = 17; + this.patternLongLabel.Text = "Pattern for long tests"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(245, 201); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(132, 13); + this.label1.TabIndex = 23; + this.label1.Text = "Short test diversions count"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(245, 224); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(131, 13); + this.label2.TabIndex = 24; + this.label2.Text = "Long test diversions count"; + // + // diversionsCountTextBox + // + this.diversionsCountTextBox.Enabled = false; + this.diversionsCountTextBox.Location = new System.Drawing.Point(378, 198); + this.diversionsCountTextBox.Name = "diversionsCountTextBox"; + this.diversionsCountTextBox.Size = new System.Drawing.Size(31, 20); + this.diversionsCountTextBox.TabIndex = 25; + // + // textBox2 + // + this.textBox2.Enabled = false; + this.textBox2.Location = new System.Drawing.Point(378, 221); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(31, 20); + this.textBox2.TabIndex = 26; + this.textBox2.Text = "1"; + // + // SaveDiverterCorrCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox2); + this.Controls.Add(this.diversionsCountTextBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.patternLongLabel); + this.Controls.Add(this.patternLongTextBox); + this.Controls.Add(this.patternShortTextBox); + this.Controls.Add(this.paternShortLabel); + this.Controls.Add(this.validityTextBox); + this.Controls.Add(this.validityLabel); + this.Controls.Add(this.certificateTextBox); + this.Controls.Add(this.certificateLabel); + this.Controls.Add(this.diverter6ComboBox); + this.Controls.Add(this.diverter6Label); + this.Controls.Add(this.diverter5ComboBox); + this.Controls.Add(this.diverter5Label); + this.Controls.Add(this.diverter4ComboBox); + this.Controls.Add(this.diverter4Label); + this.Controls.Add(this.diverter3ComboBox); + this.Controls.Add(this.diverter3Label); + this.Controls.Add(this.diverter2ComboBox); + this.Controls.Add(this.diverter2Label); + this.Controls.Add(this.diverter1ComboBox); + this.Controls.Add(this.diverter1Label); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "SaveDiverterCorrCfgCtrl"; + this.Size = new System.Drawing.Size(450, 300); + this.Load += new System.EventHandler(this.WriterCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label diverter1Label; + private System.Windows.Forms.ComboBox diverter1ComboBox; + private System.Windows.Forms.ComboBox diverter2ComboBox; + private System.Windows.Forms.Label diverter2Label; + private System.Windows.Forms.ComboBox diverter3ComboBox; + private System.Windows.Forms.Label diverter3Label; + private System.Windows.Forms.ComboBox diverter4ComboBox; + private System.Windows.Forms.Label diverter4Label; + private System.Windows.Forms.ComboBox diverter5ComboBox; + private System.Windows.Forms.Label diverter5Label; + private System.Windows.Forms.ComboBox diverter6ComboBox; + private System.Windows.Forms.Label diverter6Label; + private System.Windows.Forms.TextBox certificateTextBox; + private System.Windows.Forms.Label certificateLabel; + private System.Windows.Forms.TextBox validityTextBox; + private System.Windows.Forms.Label validityLabel; + private System.Windows.Forms.Label paternShortLabel; + private System.Windows.Forms.TextBox patternShortTextBox; + private System.Windows.Forms.TextBox patternLongTextBox; + private System.Windows.Forms.Label patternLongLabel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox diversionsCountTextBox; + private System.Windows.Forms.TextBox textBox2; + } +} diff --git a/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.resx b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/BenchControl/Output/DB/SaveDiverterCorrections/SaveDiverterCorrCfgCtrl.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/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorrCfg.cs b/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorrCfg.cs index f6ffd27f8..0bc39038e 100644 --- a/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorrCfg.cs +++ b/TBF/BenchControl/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorrCfg.cs @@ -216,7 +216,14 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections public string ToString(int i) { return string.Format("Name={0}, Flowmtr1={1}, Flowmtr2={2}, Flowmtr3={3}, Flowmtr4={4}, Flowmtr5={5}, Flowmtr6={6}, Flowmtr7={7}", - Name, Flowmeter1, Flowmeter2, Flowmeter3, Flowmeter4, Flowmeter5, Flowmeter6, Flowmeter7); + Name, + string.IsNullOrEmpty(Flowmeter1) ? "---" : Flowmeter1, + string.IsNullOrEmpty(Flowmeter2) ? "---" : Flowmeter2, + string.IsNullOrEmpty(Flowmeter3) ? "---" : Flowmeter3, + string.IsNullOrEmpty(Flowmeter4) ? "---" : Flowmeter4, + string.IsNullOrEmpty(Flowmeter5) ? "---" : Flowmeter5, + string.IsNullOrEmpty(Flowmeter6) ? "---" : Flowmeter6, + string.IsNullOrEmpty(Flowmeter7) ? "---" : Flowmeter7); } } } diff --git a/TBF/BenchControl/TbfComponents.cs b/TBF/BenchControl/TbfComponents.cs index 7ec547908..cd94e68d4 100644 --- a/TBF/BenchControl/TbfComponents.cs +++ b/TBF/BenchControl/TbfComponents.cs @@ -121,6 +121,7 @@ namespace TBF.BenchControl Factories.Add(new Network.Camera.RoiForFixedStart.Factory()); Factories.Add(new Network.Comet.Ambient.Factory()); Factories.Add(new Output.DB.ProductionTracing.Factory()); + Factories.Add(new Output.DB.SaveDiverterCorrections.Factory()); Factories.Add(new Output.DB.SaveFlowmeterCorrections.Factory()); Factories.Add(new Output.DB.SensusOracle.Factory()); Factories.Add(new Output.FileWriters.Basic.FactorySingle()); diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 86ecd8bfa..97f102907 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -858,6 +858,15 @@ + + + + + UserControl + + + SaveDiverterCorrCfgCtrl.cs + @@ -2732,6 +2741,9 @@ TracingCfgCtrl.cs + + SaveDiverterCorrCfgCtrl.cs + SaveFlowmeterCorrCfgCtrl.cs