From 602d0d5308876e02ae077b2d2032a4881a582378 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Tue, 17 Dec 2024 09:59:31 +0100 Subject: [PATCH 1/9] Add logging for process start and measurement steps Updated `PMaxTestSeq` to include logging of process data at key steps: process start and measurement. Added TODO comments to review logging positions for alignment with expected workflow. --- TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs b/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs index 95f2bf1e6..d69d7f6a5 100644 --- a/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -111,6 +111,10 @@ namespace TBF.Rig.TestMethods.PMaxTest Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting)); //------------------------------------------------ + //TODO BUMI - check this possition for sstart logging - when finish remove this comment + //--- log start process in this section + LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); + float pumpPower = test.PumpPower; while (true) { @@ -179,6 +183,12 @@ namespace TBF.Rig.TestMethods.PMaxTest Bridge.OnActivity(this, Strings.Test_in_progress); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); //------------------------------------------------ + + //TODO BUMI - check if is ok possition to start logging - at last remove comment + //--- log start process in this section + LogProcessDataHeader(processDataLogger, "Start flow test"); + + State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) @@ -200,6 +210,8 @@ namespace TBF.Rig.TestMethods.PMaxTest } while (e.Contains(Event.TimerBusy)); + LogProcessDataHeader(processDataLogger, "Measurement"); + /// /// PMaxTest completed /// From 25602fb914495e4083eac8ce7cb0446e998b66da Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Thu, 19 Dec 2024 14:16:25 +0100 Subject: [PATCH 2/9] Bug fix - Refactor flow meter handling and add validation checks. Simplified flow meter logic by introducing a reusable variable for `LtrPerPulse` and handling potential null values. Added batch components correlation validation to ensure water meter counts align with configuration, preventing mismatches. Additionally, improved code formatting for consistency and readability. --- TBF/Rig/Sequences/SequenceBase.cs | 14 +- .../Bench/Components/ComponentsManagerDlg.cs | 626 ++++++++++-------- TBF/UI/Process/ProcessTabPageCtrl.cs | 4 + 3 files changed, 368 insertions(+), 276 deletions(-) diff --git a/TBF/Rig/Sequences/SequenceBase.cs b/TBF/Rig/Sequences/SequenceBase.cs index 1e8ae42e0..02831ccac 100644 --- a/TBF/Rig/Sequences/SequenceBase.cs +++ b/TBF/Rig/Sequences/SequenceBase.cs @@ -1505,23 +1505,25 @@ namespace TBF.Rig.Sequences tstRslt.DensityLine = Formulas.RealDensity(); tstRslt.DensityDiv = Formulas.RealDensity(); + double flowMeterLtrPerPulse = outPath.FlowMeter?.LtrPerPulse ?? 1; + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = DateTime.Now; tstRslt.EndTime = DateTime.Now + new TimeSpan(0, 0, 1); tstRslt.FlowSetTime = 10; tstRslt.TestTime = tstRslt.TargetTime(); - tstRslt.PulsesMaster = (outPath.FlowMeter.LtrPerPulse > 1E-6) ? (1.0075 * tstRslt.TargetVolume() / outPath.FlowMeter.LtrPerPulse) : 1; + tstRslt.PulsesMaster = (flowMeterLtrPerPulse > 1E-6) ? (1.0075 * tstRslt.TargetVolume() / flowMeterLtrPerPulse) : 1; tstRslt.MassStartRaw = 0; tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); tstRslt.MassEndRaw = tstRslt.TargetVolume() * Formulas.RealDensity() / 1000.0f; tstRslt.MassEnd = MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections); - tstRslt.Flow = 3.6 * outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster / tstRslt.TestTime; + tstRslt.Flow = 3.6 * flowMeterLtrPerPulse * tstRslt.PulsesMaster / tstRslt.TestTime; tstRslt.MassOfEvapWater = 0; tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityLine; /// [l] commercially true volume - tstRslt.VolumeMaster = outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient - tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.Flow, tstRslt.TempDownMean); /// Corrected master pulses per liter - tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (outPath.FlowMeter.LtrPerPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); + tstRslt.VolumeMaster = flowMeterLtrPerPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.ConstMasterRaw = flowMeterLtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.ConstMasterCorr = outPath.FlowMeter?.LtrPerPulseCorrected(tstRslt.Flow, tstRslt.TempDownMean) ?? 1; /// Corrected master pulses per liter + tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (flowMeterLtrPerPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); diff --git a/TBF/UI/Bench/Components/ComponentsManagerDlg.cs b/TBF/UI/Bench/Components/ComponentsManagerDlg.cs index a8aee6825..534e9f0a1 100644 --- a/TBF/UI/Bench/Components/ComponentsManagerDlg.cs +++ b/TBF/UI/Bench/Components/ComponentsManagerDlg.cs @@ -1,9 +1,11 @@ /// /// Copyright (c) 2013-2021 Sensus Slovensko a.s. /// + using System; using System.Collections.Generic; using System.IO; +using System.Web.UI; using System.Windows.Forms; using log4net; using NHibernate; @@ -13,27 +15,31 @@ using Config.Entities; using TBF.Rig; using TBF.Rig.Generic; using TBF.Resources; +using TBF.Rig.GenericDevices; +using TBF.Rig.WaterMeters.WaterMeter; using TBF.UI.Shared; namespace TBF.UI.Bench.Components { - public partial class ComponentsManagerDlg : Form, IParentOfListViewEx - { - static readonly ILog log = LogManager.GetLogger(typeof(ComponentsManagerDlg)); + public partial class ComponentsManagerDlg : Form, IParentOfListViewEx + { + static readonly ILog log = LogManager.GetLogger(typeof(ComponentsManagerDlg)); - /// - /// List of components (=component configuration instances) - /// - IList cmpntEntities; + /// + /// List of components (=component configuration instances) + /// + IList cmpntEntities; - IList toBeDeletedEntities; + IList toBeDeletedEntities; - ISession session; + ISession session; - SelectComponentClassDlg selectComponentTypeDlg; /// Constructed once, the selection is kept between dialog usages + SelectComponentClassDlg selectComponentTypeDlg; - CfgUpdateFlags flags; /// Or-ed from particular Flags from ComponentParametersDlg - + /// Constructed once, the selection is kept between dialog usages + CfgUpdateFlags flags; + + /// Or-ed from particular Flags from ComponentParametersDlg /// /// ListViewEx columns /// @@ -50,27 +56,29 @@ namespace TBF.UI.Bench.Components } MySortOrder sortOrder = MySortOrder.Ascending; - int sortColumn = -1; /// 0-based index of column to be used for sorting + int sortColumn = -1; - /// Editors used by listViewEx + /// 0-based index of column to be used for sorting + /// Editors used by listViewEx ComboBox debugCB; + ComboBox logCB; - bool unlocked; + bool unlocked; - public ComponentsManagerDlg() - { - toBeDeletedEntities = new List(); + public ComponentsManagerDlg() + { + toBeDeletedEntities = new List(); - InitializeComponent(); + InitializeComponent(); - flags = CfgUpdateFlags.None; + flags = CfgUpdateFlags.None; - selectComponentTypeDlg = new SelectComponentClassDlg(); + selectComponentTypeDlg = new SelectComponentClassDlg(); - /// SharedDlgButtons configuration + /// SharedDlgButtons configuration sharedButtons.ParentForm = this; - sharedButtons.RequiredGroupMembership = new GID[] { GID.Metrologists }; + sharedButtons.RequiredGroupMembership = new GID[] { GID.Metrologists }; sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove | @@ -81,34 +89,35 @@ namespace TBF.UI.Bench.Components SharedButtons.Buttons.Export | SharedButtons.Buttons.Import; sharedButtons.Unlocked += Unlocked; - sharedButtons.OKClicked += okButton_Click; - sharedButtons.CancelClicked += cancelButton_Click; - sharedButtons.AddClicked += addButton_Click; - sharedButtons.RemoveClicked += removeButton_Click; - sharedButtons.UpClicked += upButton_Click; - sharedButtons.DownClicked += downButton_Click; - sharedButtons.EditClicked += editButton_Click; + sharedButtons.OKClicked += okButton_Click; + sharedButtons.CancelClicked += cancelButton_Click; + sharedButtons.AddClicked += addButton_Click; + sharedButtons.RemoveClicked += removeButton_Click; + sharedButtons.UpClicked += upButton_Click; + sharedButtons.DownClicked += downButton_Click; + sharedButtons.EditClicked += editButton_Click; sharedButtons.CopyClicked += copyButton_Click; sharedButtons.ExportClicked += exportButton_Click; sharedButtons.ImportClicked += importButton_Click; } - private void ComponentsManagerDlg_Load(object sender, EventArgs e) - { + private void ComponentsManagerDlg_Load(object sender, EventArgs e) + { LoadFormPosition(); Text = Strings.Test_Bench_Components_Configuration; LocalSettings ls = Program.LocalSettings; - listViewEx.Columns.Add(Strings.Nr, (ls.ComponentsColumnCount > 0) ? ls.ComponentsColumnWidths[0] : 40); - listViewEx.Columns.Add(Strings.Name, (ls.ComponentsColumnCount > 1) ? ls.ComponentsColumnWidths[1] : 80); - listViewEx.Columns.Add(Strings.Type, (ls.ComponentsColumnCount > 2) ? ls.ComponentsColumnWidths[2] : 120); - listViewEx.Columns.Add(Strings.Parent, (ls.ComponentsColumnCount > 3) ? ls.ComponentsColumnWidths[3] : 55); - listViewEx.Columns.Add(Strings.Mode, (ls.ComponentsColumnCount > 4) ? ls.ComponentsColumnWidths[4] : 55); - listViewEx.Columns.Add(Strings.Logging, (ls.ComponentsColumnCount > 5) ? ls.ComponentsColumnWidths[5] : 55); - listViewEx.Columns.Add(Strings.Parameters, (ls.ComponentsColumnCount > 6) ? ls.ComponentsColumnWidths[6] : 600); + listViewEx.Columns.Add(Strings.Nr, (ls.ComponentsColumnCount > 0) ? ls.ComponentsColumnWidths[0] : 40); + listViewEx.Columns.Add(Strings.Name, (ls.ComponentsColumnCount > 1) ? ls.ComponentsColumnWidths[1] : 80); + listViewEx.Columns.Add(Strings.Type, (ls.ComponentsColumnCount > 2) ? ls.ComponentsColumnWidths[2] : 120); + listViewEx.Columns.Add(Strings.Parent, (ls.ComponentsColumnCount > 3) ? ls.ComponentsColumnWidths[3] : 55); + listViewEx.Columns.Add(Strings.Mode, (ls.ComponentsColumnCount > 4) ? ls.ComponentsColumnWidths[4] : 55); + listViewEx.Columns.Add(Strings.Logging, (ls.ComponentsColumnCount > 5) ? ls.ComponentsColumnWidths[5] : 55); + listViewEx.Columns.Add(Strings.Parameters, + (ls.ComponentsColumnCount > 6) ? ls.ComponentsColumnWidths[6] : 600); listViewEx.HeaderStyle = ColumnHeaderStyle.Clickable; - debugCB = new ComboBox(); + debugCB = new ComboBox(); for (DebugMode level = 0; level < DebugMode.Count; level++) debugCB.Items.Add(level.ToDescription()); splitContainer.Panel1.Controls.Add(debugCB); @@ -119,23 +128,23 @@ namespace TBF.UI.Bench.Components listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked); listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing); - sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Edit); + sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Edit); - session = TBF.DB.CreateSession(DBKind.Config); - cmpntEntities = session.QueryOver() - .OrderBy(x => x.ItemNr).Asc - .List(); + session = TBF.DB.CreateSession(DBKind.Config); + cmpntEntities = session.QueryOver() + .OrderBy(x => x.ItemNr).Asc + .List(); - RedrawAll(); - } + RedrawAll(); + } void listViewEx_SubItemClicked(object sender, SubItemEventArgs e) { - if (unlocked && e.SubItem == (int)Column.DebugMode) + if (unlocked && e.SubItem == (int)Column.DebugMode) { listViewEx.StartEditing(debugCB, e.Item, e.SubItem); } - else if (unlocked && e.SubItem == (int)Column.Logging) + else if (unlocked && e.SubItem == (int)Column.Logging) { listViewEx.StartEditing(logCB, e.Item, e.SubItem); } @@ -146,7 +155,7 @@ namespace TBF.UI.Bench.Components if (!unlocked || ((e.SubItem != (int)Column.DebugMode) && (e.SubItem != (int)Column.Logging))) 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)) + Strings.Confirmation, MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { int columnNr = e.SubItem; string value = null; @@ -204,10 +213,11 @@ namespace TBF.UI.Bench.Components if (debugCB.Text.Equals(level.ToDescription())) { cmpnt.DebugMode = level; - flags |= CfgUpdateFlags.RestartRqrd; + flags |= CfgUpdateFlags.RestartRqrd; return; } } + e.DisplayText = cmpnt.DebugMode.ToString(); } else if (e.SubItem == (int)Column.Logging) @@ -217,35 +227,36 @@ namespace TBF.UI.Bench.Components if (logCB.Text.Equals(level.ToDescription())) { cmpnt.LogLevel = level; - flags |= CfgUpdateFlags.RestartRqrd; - return; + flags |= CfgUpdateFlags.RestartRqrd; + return; } } + e.DisplayText = cmpnt.LogLevel.ToString(); } } - private void Unlocked(object sender, EventArgs e) - { - unlocked = true; + private void Unlocked(object sender, EventArgs e) + { + unlocked = true; - if (listViewEx.SelectedItems.Count == 1) - { - int ix = listViewEx.SelectedIndices[0]; - Focus(); - listViewEx.Items[ix].Selected = true; - listViewEx.Items[ix].EnsureVisible(); - } - } + if (listViewEx.SelectedItems.Count == 1) + { + int ix = listViewEx.SelectedIndices[0]; + Focus(); + listViewEx.Items[ix].Selected = true; + listViewEx.Items[ix].EnsureVisible(); + } + } - void RedrawAll() - { - listViewEx.Items.Clear(); - foreach (var cmpnt in cmpntEntities) DrawOne(cmpnt); - } + void RedrawAll() + { + listViewEx.Items.Clear(); + foreach (var cmpnt in cmpntEntities) DrawOne(cmpnt); + } - void DrawOne(Component cmpnt) - { + void DrawOne(Component cmpnt) + { ListViewItem lvi = new ListViewItem(cmpnt.ItemNr.ToString()); lvi.Tag = cmpnt; lvi.SubItems.Add(cmpnt.Name); @@ -254,18 +265,17 @@ namespace TBF.UI.Bench.Components IComponentCfg cmpCfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt); if (cmpCfg != null) - { + { lvi.SubItems.Add(cmpCfg.DebugLevel.ToDescription()); - lvi.SubItems.Add(cmpCfg.LogLevel.ToDescription()); - lvi.SubItems.Add(cmpCfg.ToString(-1)); - - } - else - { - lvi.SubItems.Add("---"); - lvi.SubItems.Add("---"); - lvi.SubItems.Add("Not a component"); - } + lvi.SubItems.Add(cmpCfg.LogLevel.ToDescription()); + lvi.SubItems.Add(cmpCfg.ToString(-1)); + } + else + { + lvi.SubItems.Add("---"); + lvi.SubItems.Add("---"); + lvi.SubItems.Add("Not a component"); + } listViewEx.Items.Add(lvi); } @@ -304,10 +314,10 @@ namespace TBF.UI.Bench.Components private void LoadFormPosition() { LocalSettings ls = Program.LocalSettings; - Width = (ls.ComponentsDlgWidth > 0) ? ls.ComponentsDlgWidth : 850; + Width = (ls.ComponentsDlgWidth > 0) ? ls.ComponentsDlgWidth : 850; Height = (ls.ComponentsDlgHeight > 0) ? ls.ComponentsDlgHeight : 500; - Left = (ls.ComponentsDlgLeft != 0) ? ls.ComponentsDlgLeft : 200; - Top = (ls.ComponentsDlgTop != 0) ? ls.ComponentsDlgTop : 100; + Left = (ls.ComponentsDlgLeft != 0) ? ls.ComponentsDlgLeft : 200; + Top = (ls.ComponentsDlgTop != 0) ? ls.ComponentsDlgTop : 100; } /// @@ -334,7 +344,11 @@ namespace TBF.UI.Bench.Components { for (int i = 0; i < (int)Column.ColumnsCount; i++) { - if (listViewEx.Columns[i].Width != ls.ComponentsColumnWidths[i]) { anyColumnDiffers = true; break; } + if (listViewEx.Columns[i].Width != ls.ComponentsColumnWidths[i]) + { + anyColumnDiffers = true; + break; + } } } @@ -366,84 +380,149 @@ namespace TBF.UI.Bench.Components } /// - /// OK + /// OK /// private void okButton_Click(object sender, EventArgs e) - { - if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0) - { + { + ValidateComponents(); + if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0) + { SaveDBChanges(session); - flags = CfgUpdateFlags.None; /// Changes saved + flags = CfgUpdateFlags.None; /// Changes saved } SaveUISettings(); DialogResult = DialogResult.OK; - Close(); - return; - } + Close(); + return; + } - /// Cancel - private void cancelButton_Click(object sender, EventArgs e) - { + private void ValidateComponents() + { + Boolean invalid = false; + string validationMessage = ""; + //validation cycle + invalid = !ValidateMetersBatchCount(out validationMessage); + + if (invalid) + { + MessageBox.Show(validationMessage, Strings.Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + + private Boolean ValidateMetersBatchCount(out string message) + { + bool invalid = false; + + TBF.Rig.DataContainer.BenchInfo.ComponentCfg benchInfo = null; + int waterMetersCount = 0; + int iWaterMeterComponentCount = 0; + foreach (Component component in cmpntEntities) + { + if (component == null) + { + continue; + } + + string className = (string.IsNullOrEmpty(component.ClassName) ? string.Empty : component.ClassName); + if (className == "DataContainer.BenchInfo") + { + try + { + var cfg = new TBF.Rig.DataContainer.BenchInfo.Factory().CmpntCfgFromCmpntEntity(component) + as TBF.Rig.DataContainer.BenchInfo.ComponentCfg; + + waterMetersCount = cfg.WaterMetersCount; + } + catch (Exception e) + { + log.Error("Finding of DataContainer.BenchInfo data unsuccessfully!"); + } + } + + if (className == "WaterMeter") + { + iWaterMeterComponentCount++; + } + } + + + invalid = (waterMetersCount != iWaterMeterComponentCount); + + + if (invalid) + { + message = "The count of water meters on the bench does not match the count of their components!"; + return false; + } + + message = ""; + return true; + } + + /// Cancel + private void cancelButton_Click(object sender, EventArgs e) + { SaveUISettings(); - if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0) - { - DialogResult dr = MessageBox.Show(Strings.Changes_will_be_lost_Do_you_want_to_proceed, - Strings.Warning, - MessageBoxButtons.YesNo, - MessageBoxIcon.Question); - if (dr != DialogResult.Yes) return; - } + if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0) + { + DialogResult dr = MessageBox.Show(Strings.Changes_will_be_lost_Do_you_want_to_proceed, + Strings.Warning, + MessageBoxButtons.YesNo, + MessageBoxIcon.Question); + if (dr != DialogResult.Yes) return; + } - flags = CfgUpdateFlags.None; /// Abandoning changes confirmed + flags = CfgUpdateFlags.None; /// Abandoning changes confirmed DialogResult = DialogResult.Cancel; - Close(); - return; - } + Close(); + return; + } - /// Add a new component - private void addButton_Click(object sender, EventArgs e) - { - selectComponentTypeDlg.SelectedScriptName = null; - DialogResult dialogRslt = selectComponentTypeDlg.ShowDialog(); - if (dialogRslt != DialogResult.OK) return; + /// Add a new component + private void addButton_Click(object sender, EventArgs e) + { + selectComponentTypeDlg.SelectedScriptName = null; + DialogResult dialogRslt = selectComponentTypeDlg.ShowDialog(); + if (dialogRslt != DialogResult.OK) return; - IComponentFactory factory = selectComponentTypeDlg.SlctdCmpntFactory; + IComponentFactory factory = selectComponentTypeDlg.SlctdCmpntFactory; IComponentCfg cfg = factory.DefaultConfig(); if (selectComponentTypeDlg.SelectedScriptName == null) - { + { /// /// Create a single component of the selected type /// IComponentCfgCtrl cfgControl = cfg.GetControl(cmpntEntities); - cfgControl.Config = cfg; - cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1; + cfgControl.Config = cfg; + cfgControl.Config.ItemNr = + (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1; - ComponentParametersDlg cfgForm = new ComponentParametersDlg(this); - cfgForm.CmpntEntities = cmpntEntities; - cfgForm.ComponentCfgCtrl = cfgControl; - cfgForm.UnlockAfterStart = true; - dialogRslt = cfgForm.ShowDialog(); - if (dialogRslt != DialogResult.OK) return; + ComponentParametersDlg cfgForm = new ComponentParametersDlg(this); + cfgForm.CmpntEntities = cmpntEntities; + cfgForm.ComponentCfgCtrl = cfgControl; + cfgForm.UnlockAfterStart = true; + dialogRslt = cfgForm.ShowDialog(); + if (dialogRslt != DialogResult.OK) return; - flags |= CfgUpdateFlags.RestartRqrd; - AddOne(cfgForm.Config.CreateDbEntity()); - } - else - { + flags |= CfgUpdateFlags.RestartRqrd; + AddOne(cfgForm.Config.CreateDbEntity()); + } + else + { /// /// Create more components, read their names and other properties from a file /// using (TextReader reader = new StreamReader(selectComponentTypeDlg.SelectedScriptName)) - { - int zeroBasedIdx = 0; - string line = reader.ReadLine(); - while (line != null) - { - line.Trim(); + { + int zeroBasedIdx = 0; + string line = reader.ReadLine(); + while (line != null) + { + line.Trim(); if (line.Length > 0) { string[] words = line.Split(new char[] { ' ', '\t' }); @@ -451,83 +530,85 @@ namespace TBF.UI.Bench.Components if (UpdateCfg(ref cfg, words, ref zeroBasedIdx)) { flags |= CfgUpdateFlags.RestartRqrd; - cfg.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1; + cfg.ItemNr = (cmpntEntities.Count > 0) + ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) + : 1; AddOne(cfg.CreateDbEntity()); } - + zeroBasedIdx++; } - line = reader.ReadLine(); - } - } - } - } + line = reader.ReadLine(); + } + } + } + } - void AddOne(Component cmpnt) - { - cmpntEntities.Add(cmpnt); - DrawOne(cmpnt); - } + void AddOne(Component cmpnt) + { + cmpntEntities.Add(cmpnt); + DrawOne(cmpnt); + } - /// Delete the component - private void removeButton_Click(object sender, EventArgs e) - { - if (listViewEx.SelectedIndices.Count != 1) return; - int ix = listViewEx.SelectedIndices[0]; - if (ix < 0) return; - - Component selectedCmpnt = (Component)listViewEx.Items[ix].Tag; + /// Delete the component + private void removeButton_Click(object sender, EventArgs e) + { + if (listViewEx.SelectedIndices.Count != 1) return; + int ix = listViewEx.SelectedIndices[0]; + if (ix < 0) return; + + Component selectedCmpnt = (Component)listViewEx.Items[ix].Tag; if (selectedCmpnt.Id != 0) toBeDeletedEntities.Add(selectedCmpnt); cmpntEntities.Remove(selectedCmpnt); flags |= CfgUpdateFlags.AnyChange; - RedrawAll(); - } + RedrawAll(); + } - /// DoubleClick -> Edit the component - private void listViewEx_MouseDoubleClick(object sender, MouseEventArgs e) - { - editButton_Click(sender, e); - } + /// DoubleClick -> Edit the component + private void listViewEx_MouseDoubleClick(object sender, MouseEventArgs e) + { + editButton_Click(sender, e); + } - /// Edit a component - private void editButton_Click(object sender, EventArgs e) - { + /// Edit a component + private void editButton_Click(object sender, EventArgs e) + { if (listViewEx.SelectedIndices.Count != 1) return; ListViewItem lvi = listViewEx.SelectedItems[0]; Component component = lvi.Tag as Component; if (component == null) return; - IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(component); - if (cfg != null) - { + IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(component); + if (cfg != null) + { ComponentParametersDlg cfgForm = new ComponentParametersDlg(this, component.Id); - cfgForm.CmpntEntities = cmpntEntities; + cfgForm.CmpntEntities = cmpntEntities; cfgForm.ComponentCfgCtrl = cfg.GetControl(cmpntEntities); - cfgForm.ComponentCfgCtrl.Config = cfg; - DialogResult dr = cfgForm.ShowDialog(); - if (dr != DialogResult.OK) return; + cfgForm.ComponentCfgCtrl.Config = cfg; + DialogResult dr = cfgForm.ShowDialog(); + if (dr != DialogResult.OK) return; - flags |= cfgForm.Flags; + flags |= cfgForm.Flags; - sharedButtons.UnlockButtons(); /// Unlock this dialog buttons as changes were enabled - unlocked = true; /// in the ComponentParametersDlg. + sharedButtons.UnlockButtons(); /// Unlock this dialog buttons as changes were enabled + unlocked = true; /// in the ComponentParametersDlg. - Component modified = cfgForm.Config.CreateDbEntity(); - Component original = (Component)lvi.Tag; + Component modified = cfgForm.Config.CreateDbEntity(); + Component original = (Component)lvi.Tag; - original.Name = modified.Name; - original.ClassName = modified.ClassName; - original.Parent = modified.Parent; - original.DebugMode = modified.DebugMode; - original.LogLevel = modified.LogLevel; - original.Parameters = modified.Parameters; + original.Name = modified.Name; + original.ClassName = modified.ClassName; + original.Parent = modified.Parent; + original.DebugMode = modified.DebugMode; + original.LogLevel = modified.LogLevel; + original.Parameters = modified.Parameters; - RedrawAll(); - } - } + RedrawAll(); + } + } /// Copy a component private void copyButton_Click(object sender, EventArgs e) @@ -535,7 +616,7 @@ namespace TBF.UI.Bench.Components if (listViewEx.SelectedIndices.Count != 1) return; ListViewItem lvi = listViewEx.SelectedItems[0]; - IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity((Component)lvi.Tag); + IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity((Component)lvi.Tag); if (cfg != null) { cfg.Name += Strings.New_name_copy; @@ -543,7 +624,9 @@ namespace TBF.UI.Bench.Components { IComponentCfgCtrl cfgControl = cfg.GetControl(cmpntEntities); cfgControl.Config = cfg; - cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1; + cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) + ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) + : 1; ComponentParametersDlg cfgForm = new ComponentParametersDlg(this); cfgForm.CmpntEntities = cmpntEntities; @@ -588,7 +671,8 @@ namespace TBF.UI.Bench.Components IComponentCfgCtrl cfgControl = cfg.GetControl(cmpntEntities); cfgControl.Config = cfg; cfgControl.Config.Name = cfgControl.Config.Name + " imported"; - cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1; + cfgControl.Config.ItemNr = + (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1; ComponentParametersDlg cfgForm = new ComponentParametersDlg(this); cfgForm.CmpntEntities = cmpntEntities; @@ -601,88 +685,90 @@ namespace TBF.UI.Bench.Components } } - private void upButton_Click(object sender, EventArgs e) - { - if (listViewEx.SelectedIndices.Count != 1) return; - int ix = listViewEx.SelectedIndices[0]; - if (ix < 1) return; + private void upButton_Click(object sender, EventArgs e) + { + if (listViewEx.SelectedIndices.Count != 1) return; + int ix = listViewEx.SelectedIndices[0]; + if (ix < 1) return; - Component item1 = (Component)(listViewEx.Items[ix - 1].Tag); - Component item2 = (Component)(listViewEx.Items[ix].Tag); - (item1 as IHasItemNr).ItemNr++; - (item2 as IHasItemNr).ItemNr--; - cmpntEntities.RemoveAt(ix); - cmpntEntities.Insert(ix - 1, item2); + Component item1 = (Component)(listViewEx.Items[ix - 1].Tag); + Component item2 = (Component)(listViewEx.Items[ix].Tag); + (item1 as IHasItemNr).ItemNr++; + (item2 as IHasItemNr).ItemNr--; + cmpntEntities.RemoveAt(ix); + cmpntEntities.Insert(ix - 1, item2); - flags |= CfgUpdateFlags.AnyChange; + flags |= CfgUpdateFlags.AnyChange; - RedrawAll(); + RedrawAll(); - Focus(); - listViewEx.Items[ix - 1].Selected = true; - listViewEx.Items[ix - 1].EnsureVisible(); - } + Focus(); + listViewEx.Items[ix - 1].Selected = true; + listViewEx.Items[ix - 1].EnsureVisible(); + } - private void downButton_Click(object sender, EventArgs e) - { - if (listViewEx.SelectedIndices.Count != 1) return; - int ix = listViewEx.SelectedIndices[0]; - if (ix >= listViewEx.Items.Count - 1) return; + private void downButton_Click(object sender, EventArgs e) + { + if (listViewEx.SelectedIndices.Count != 1) return; + int ix = listViewEx.SelectedIndices[0]; + if (ix >= listViewEx.Items.Count - 1) return; - Component item1 = (Component)(listViewEx.Items[ix].Tag); - Component item2 = (Component)(listViewEx.Items[ix + 1].Tag); - (item1 as IHasItemNr).ItemNr++; - (item2 as IHasItemNr).ItemNr--; - cmpntEntities.RemoveAt(ix + 1); - cmpntEntities.Insert(ix, item2); + Component item1 = (Component)(listViewEx.Items[ix].Tag); + Component item2 = (Component)(listViewEx.Items[ix + 1].Tag); + (item1 as IHasItemNr).ItemNr++; + (item2 as IHasItemNr).ItemNr--; + cmpntEntities.RemoveAt(ix + 1); + cmpntEntities.Insert(ix, item2); - flags |= CfgUpdateFlags.AnyChange; + flags |= CfgUpdateFlags.AnyChange; - RedrawAll(); + RedrawAll(); - Focus(); - listViewEx.Items[ix + 1].Selected = true; - listViewEx.Items[ix + 1].EnsureVisible(); - } + Focus(); + listViewEx.Items[ix + 1].Selected = true; + listViewEx.Items[ix + 1].EnsureVisible(); + } - private void componentsListView_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewEx.SelectedIndices.Count == 1) - { - sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Edit); - } - else - { - sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Edit); - } - } + private void componentsListView_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewEx.SelectedIndices.Count == 1) + { + sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Edit); + } + else + { + sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Edit); + } + } - public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos) - { - if (selectedItemPos == SharedButtons.SelectedItemPos.None) - { - sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down); - } - else if (selectedItemPos == SharedButtons.SelectedItemPos.First) - { - sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Down); - sharedButtons.DisableButtons(SharedButtons.Buttons.Up); - } - else if (selectedItemPos == SharedButtons.SelectedItemPos.Last) - { - sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up); - sharedButtons.DisableButtons(SharedButtons.Buttons.Down); - } - else if (selectedItemPos == SharedButtons.SelectedItemPos.FirstAndLast) - { - sharedButtons.EnableButtons(SharedButtons.Buttons.Remove); - sharedButtons.DisableButtons(SharedButtons.Buttons.Up | SharedButtons.Buttons.Down); - } - else - { - sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down); - } - } + public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos) + { + if (selectedItemPos == SharedButtons.SelectedItemPos.None) + { + sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | + SharedButtons.Buttons.Down); + } + else if (selectedItemPos == SharedButtons.SelectedItemPos.First) + { + sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Down); + sharedButtons.DisableButtons(SharedButtons.Buttons.Up); + } + else if (selectedItemPos == SharedButtons.SelectedItemPos.Last) + { + sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up); + sharedButtons.DisableButtons(SharedButtons.Buttons.Down); + } + else if (selectedItemPos == SharedButtons.SelectedItemPos.FirstAndLast) + { + sharedButtons.EnableButtons(SharedButtons.Buttons.Remove); + sharedButtons.DisableButtons(SharedButtons.Buttons.Up | SharedButtons.Buttons.Down); + } + else + { + sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | + SharedButtons.Buttons.Down); + } + } private void ComponentsManagerDlg_FormClosing(object sender, FormClosingEventArgs e) { @@ -691,9 +777,9 @@ namespace TBF.UI.Bench.Components if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0) { DialogResult dr = MessageBox.Show(Strings.Do_you_want_to_save_changes, - Strings.Warning, - MessageBoxButtons.YesNo, - MessageBoxIcon.Question); + Strings.Warning, + MessageBoxButtons.YesNo, + MessageBoxIcon.Question); if (dr == DialogResult.Yes) { SaveDBChanges(session); @@ -702,7 +788,7 @@ namespace TBF.UI.Bench.Components if (CurrentUser.Restore(this)) Program.MainWnd.UpdateUser(); } - + /// /// Updates component configuration from a script file @@ -713,7 +799,7 @@ namespace TBF.UI.Bench.Components /// true = udated component configuration should be saved, new component should be created bool UpdateCfg(ref IComponentCfg cfg, string[] words, ref int zeroBasedIdx) { - string name = words[words.Length - 1]; /// The last word is the component name + string name = words[words.Length - 1]; /// The last word is the component name cfg.Name = name.Replace("#", (zeroBasedIdx + 1).ToString()); if (cfg is Rig.BuiltIn.Valve.ValveCfg) @@ -760,9 +846,9 @@ namespace TBF.UI.Bench.Components } else if (cfg is Rig.Modbus.Meret.AdjustableScale.AdjustableMeterCfg) { - (cfg as IChildComponentCfg).ParentName = "CB"; - (cfg as Rig.Modbus.Meret.AdjustableScale.AdjustableMeterCfg).ModbusAddress = (byte)(zeroBasedIdx + 1); - return true; + (cfg as IChildComponentCfg).ParentName = "CB"; + (cfg as Rig.Modbus.Meret.AdjustableScale.AdjustableMeterCfg).ModbusAddress = (byte)(zeroBasedIdx + 1); + return true; } else if (cfg is Rig.RegisterReaders.PulsesFromUniCB.RRCfg) { @@ -818,4 +904,4 @@ namespace TBF.UI.Bench.Components listViewEx.Sort(); } } -} +} \ No newline at end of file diff --git a/TBF/UI/Process/ProcessTabPageCtrl.cs b/TBF/UI/Process/ProcessTabPageCtrl.cs index 2c4415113..aeb391a81 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl.cs @@ -1181,6 +1181,10 @@ namespace TBF.UI.Process if (args.TestRslt != null) { + if (ProcessData.BatchRslts.Batch.WaterMeters.Count < wmsCount) + { + throw new Exception("Water Meter components cout is smaller as Bench Info water meter count!"); + } for (int i = 0; i < wmsCount; i++) { var wm = ProcessData.BatchRslts.Batch.WaterMeters[i]; From 4e5e3d63e1ac035360ad38b4d038f58add338651 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Tue, 7 Jan 2025 16:21:28 +0100 Subject: [PATCH 3/9] Fixed problem with F2 formating of decimal num --- TBF/Boxes/DoubleBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TBF/Boxes/DoubleBox.cs b/TBF/Boxes/DoubleBox.cs index d66eb3698..f90508298 100644 --- a/TBF/Boxes/DoubleBox.cs +++ b/TBF/Boxes/DoubleBox.cs @@ -76,7 +76,7 @@ namespace TBF.Boxes } else { - return string.Format(Format, Val * Factor); + return string.Format( $"{{0:{Format}}}", Val * Factor); } } From b2d2f8c13bd8f278931b31d3bfb2d48218b3339e Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Tue, 7 Jan 2025 16:22:18 +0100 Subject: [PATCH 4/9] Solved problem with Null Exeprion in ProcessData.cs --- TBF/Rig/Sequences/ProcessData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TBF/Rig/Sequences/ProcessData.cs b/TBF/Rig/Sequences/ProcessData.cs index cd2e86105..f4f74888b 100644 --- a/TBF/Rig/Sequences/ProcessData.cs +++ b/TBF/Rig/Sequences/ProcessData.cs @@ -539,7 +539,7 @@ namespace TBF.Rig.Sequences AmbTemp, /// ambient temperature in degree C AmbHumi, /// ambient humidity in R% AmbPress, /// ambient pressure in mbar (= 1 hPa) - outPath.RegValve.Position.ToString("F1")); /// regulation valve position in % (0=closed / 100=open) + outPath.RegValve?.Position.ToString("F1")); /// regulation valve position in % (0=closed / 100=open) } public void LogProcessDataHeaderHeatMeters(ILog logger, string sectionName) From c1d966d86a66a5c6ef3e17fee9dc93bf33a13cc7 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Tue, 7 Jan 2025 16:23:01 +0100 Subject: [PATCH 5/9] final add process data to PMaxTestSeq.cs --- TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs b/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs index d69d7f6a5..037b29da6 100644 --- a/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -110,10 +110,6 @@ namespace TBF.Rig.TestMethods.PMaxTest Bridge.OnActivity(this, Strings.Setting_the_water_pressure); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting)); //------------------------------------------------ - - //TODO BUMI - check this possition for sstart logging - when finish remove this comment - //--- log start process in this section - LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); float pumpPower = test.PumpPower; while (true) @@ -178,6 +174,10 @@ namespace TBF.Rig.TestMethods.PMaxTest int startTime = StateMachine.Time; int endTime = startTime + testParams.DurationPMax; + + //TODO BUMI - check this possition for sstart logging - when finish remove this comment + //--- log start process in this section + LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_in_progress); @@ -186,13 +186,14 @@ namespace TBF.Rig.TestMethods.PMaxTest //TODO BUMI - check if is ok possition to start logging - at last remove comment //--- log start process in this section - LogProcessDataHeader(processDataLogger, "Start flow test"); + LogProcessDataHeader(processDataLogger, "Starting the test"); State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(new Operations.TimerOp(testParams.DurationPMax)) + .AddOperation(processDataLoggingOp) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -209,8 +210,7 @@ namespace TBF.Rig.TestMethods.PMaxTest Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } while (e.Contains(Event.TimerBusy)); - - LogProcessDataHeader(processDataLogger, "Measurement"); + /// /// PMaxTest completed From fed3281525b83adc9a886e8bdbd9923187d3dbfa Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Wed, 8 Jan 2025 07:43:58 +0100 Subject: [PATCH 6/9] log for processData in LeakTestSeq.cs set --- TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs b/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs index b7f3c9313..8a3a3b8a1 100644 --- a/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs @@ -123,6 +123,11 @@ namespace TBF.Rig.TestMethods.LeakTest Bridge.OnActivity(this, Strings.Setting_the_water_pressure); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.FlowSetting)); //------------------------------------------------ + + //TODO BUMI - check this possition for sstart logging - when finish remove this comment + //--- log start process in this section + LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); + float pumpPower = test.PumpPower; int startTime = StateMachine.Time; @@ -214,10 +219,14 @@ namespace TBF.Rig.TestMethods.LeakTest Bridge.OnActivity(this, Strings.Test_in_progress); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); //------------------------------------------------ + + LogProcessDataHeader(processDataLogger, "Maximum water pressure set"); + State.Create(string.Format("{0}({1}) : Maximum water pressure set", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(new Operations.TimerOp(testParams.DurationPMax)) + .AddOperation(processDataLoggingOp) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -246,10 +255,14 @@ namespace TBF.Rig.TestMethods.LeakTest //----------------------------------------------------- Bridge.OnActivity(this, Strings.Measuring_the_weight); //----------------------------------------------------- + + LogProcessDataHeader(processDataLogger, "Measuring the start mass"); + State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(scale.ReadStableMassOp(ref StartMass, test.TimeFlow2Mass, test.MassMethod, test.MassRepeats, test.MassSpread)) + .AddOperation(processDataLoggingOp) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -275,10 +288,14 @@ namespace TBF.Rig.TestMethods.LeakTest ///------------------------------------------------ Bridge.OnActivity(this, Strings.Test_in_progress); ///------------------------------------------------ + + LogProcessDataHeader(processDataLogger, "Starting the test"); + State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(new Operations.TimerOp(testParams.DurationLeak)) + .AddOperation(processDataLoggingOp) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -305,10 +322,14 @@ namespace TBF.Rig.TestMethods.LeakTest //----------------------------------------------------- Bridge.OnActivity(this, Strings.Measuring_the_weight); //----------------------------------------------------- + + LogProcessDataHeader(processDataLogger, " Measuring the end mass"); + State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(scale.ReadStableMassOp(ref EndMass, test.TimeStop2Mass, test.MassMethod, test.MassRepeats, test.MassSpread)) + .AddOperation(processDataLoggingOp) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); From 3b9e8d754deee29c8a1a1cbb5861b359e89b2605 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Fri, 10 Jan 2025 08:48:52 +0100 Subject: [PATCH 7/9] fix valve Debug Simulate mode --- TBF/Properties/AssemblyInfo.cs | 4 ++-- TBF/Rig/BuiltIn/SetValvesOp.cs | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 96405e871..82b21bf67 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.9.2143.2")] -[assembly: AssemblyFileVersion("3.9.2143.2")] +[assembly: AssemblyVersion("3.9.2144.1")] +[assembly: AssemblyFileVersion("3.9.2144.1")] diff --git a/TBF/Rig/BuiltIn/SetValvesOp.cs b/TBF/Rig/BuiltIn/SetValvesOp.cs index 4ded37d00..5c01e037c 100644 --- a/TBF/Rig/BuiltIn/SetValvesOp.cs +++ b/TBF/Rig/BuiltIn/SetValvesOp.cs @@ -3,6 +3,7 @@ /// using System; using System.Collections.Generic; +using Common; using log4net; using Dirichlet.Numerics; using TBF.Boxes; @@ -259,6 +260,11 @@ namespace TBF.Rig.BuiltIn /// Start this operation public void Start() { + if (cb.DebugLevel == DebugMode.Simulate) + { + return ; + } + UInt128 changed = cb.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose, StateMachine.LogicalFnValves); if (timeStamp != null && switchPoints[0].TimeSec == timeShift) @@ -277,7 +283,12 @@ namespace TBF.Rig.BuiltIn /// public Event Run() { - if (nextIx >= switchPoints.Count) + if (cb.DebugLevel == DebugMode.Simulate) + { + return Event.ValvesSet; + } + + if (nextIx >= switchPoints.Count) { return (StateMachine.Time >= swStartTime + maxDelayTime + waitOnCBDelay) ? Event.ValvesSet : Event.ValvesBusy; } @@ -306,6 +317,11 @@ namespace TBF.Rig.BuiltIn /// Start this operation public void Stop() { + if (cb.DebugLevel == DebugMode.Simulate) + { + return; + } + if (switchTime != null && startStopValveBitNr >= 16 && startStopValveBitNr <= 23 && cb is ControlBoard.Uni.UniCB) { switchTime.Val = (cb as ControlBoard.Uni.UniCB).Data.ValveSwitchTime[startStopValveBitNr - 16]; From a20b0761fd785a0b2d6f9c3cd69da7e638c2d70f Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Wed, 26 Mar 2025 10:22:50 +0100 Subject: [PATCH 8/9] Fix nested string formatting in DoubleBox's return statement Revised the return statement to correctly handle nested string formatting by ensuring the format string is constructed properly. This resolves potential formatting issues with dynamic values. --- TBF/Boxes/DoubleBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TBF/Boxes/DoubleBox.cs b/TBF/Boxes/DoubleBox.cs index f90508298..6cc20a0e7 100644 --- a/TBF/Boxes/DoubleBox.cs +++ b/TBF/Boxes/DoubleBox.cs @@ -76,7 +76,7 @@ namespace TBF.Boxes } else { - return string.Format( $"{{0:{Format}}}", Val * Factor); + return string.Format(string.Format("{{0:{0}}}", Format), Val * Factor); } } From 47e09584f259df1e86dd58f2c49185aca5141672 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Tue, 9 Sep 2025 12:51:26 +0200 Subject: [PATCH 9/9] Frequency pulse meter --- .../FrequencyMeterFromUniCB/Factory.cs | 24 ++++ .../FrequencyRegisterReader.cs | 47 +++++++ .../FrequencyMeterFromUniCB/RRCfg.cs | 51 +++++++ .../FrequencyMeterFromUniCB/RRCfgCtrl.cs | 106 ++++++++++++++ .../RRCfgCtrl.designer.cs | 133 ++++++++++++++++++ .../FrequencyMeterFromUniCB/RRCfgCtrl.resx | 120 ++++++++++++++++ .../FrequencyMeterFromUniCB/RRProcParams.cs | 132 +++++++++++++++++ TBF/Rig/TbfComponents.cs | 1 + TBF/TBF.csproj | 13 ++ 9 files changed, 627 insertions(+) create mode 100644 TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/Factory.cs create mode 100644 TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/FrequencyRegisterReader.cs create mode 100644 TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfg.cs create mode 100644 TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.cs create mode 100644 TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.designer.cs create mode 100644 TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.resx create mode 100644 TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRProcParams.cs diff --git a/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/Factory.cs b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/Factory.cs new file mode 100644 index 000000000..3c1304afe --- /dev/null +++ b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/Factory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Config.Entities; +using TBF.Rig.Generic; + +namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return GetType().Namespace.Substring(8); } } + + public override string ToString() { return ClassName; } + + public IComponent DummyComponent() { return new FrequencyRegisterReader(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new FrequencyRegisterReader(cfg, components); } + + public IComponentCfg DefaultConfig() { return new RRCfg("Frequency", this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Component component) + { + return ComponentCfgBase.CreateFromDbEntity(RRCfg.Serializer, component, this); + } + } +} \ No newline at end of file diff --git a/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/FrequencyRegisterReader.cs b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/FrequencyRegisterReader.cs new file mode 100644 index 000000000..0d0e15e36 --- /dev/null +++ b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/FrequencyRegisterReader.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using Common; +using log4net; +using TBF.Rig.GenericDevices; + +namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB +{ + public class FrequencyRegisterReader : ComponentBase, GenericDevices.IRegReader + { + private static readonly ILog log = LogManager.GetLogger(typeof(FrequencyRegisterReader)); + + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); } + + readonly RRCfg rrCfg; + readonly TBF.Rig.ControlBoard.IControlBoard cb; + + public int Position { get{ return rrCfg.Position; } } + public Common.RegisterReaderType RegisterReaderType { get { return Common.RegisterReaderType.Pulses; } } + public double PulsesPerLtr { get { return rrCfg.ProcParams.PulsesPerLtr; } } + public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); ; } } + public int Filter { get { return rrCfg.ProcParams.Filter; } } + + public int WMPulses { get { return cb.PulsesWM(Position); } } + public int WMRefPulses { get { return cb.RefPulsesWM(Position); } } + public double WMVolume { get { return LtrsPerPulse * Convert.ToDouble(WMPulses); } } + + public double BeginWMState { get { return 0; } } /// Always 0 + public double EndWMState { get { return WMVolume; } } /// Derived from WMVolume + + + public FrequencyRegisterReader() { } + + public FrequencyRegisterReader(Generic.IComponentCfg cfg, IList components) + : base(cfg) + { + rrCfg = cfg as RRCfg; + + cb = TbfComponents.FindComponent(cfg.ParentName, components) as TBF.Rig.ControlBoard.IControlBoard; + if (cb == null) throw new Exception("Cannot find " + Name + " parent"); + + log.Warn(this.ToString()); + } + + public override void Initialize() { } + } +} \ No newline at end of file diff --git a/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfg.cs b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfg.cs new file mode 100644 index 000000000..eb4250125 --- /dev/null +++ b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfg.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using System.Xml.Serialization; +using Common; +using Config.Entities; +using TBF.Rig.Generic; + +namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB +{ + public class RRCfg : ComponentCfgBase, Generic.IChildComponentCfg + { + + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + IComponentCfgCtrl IComponentCfg.GetControl(IList cmpntEntities) { return new RRCfgCtrl(); } + + /// + /// Serialized parameters + /// + public int Position; /// 1..nrWaterMeters + + /// Procedure parameters + [XmlIgnore] + public RRProcParams ProcParams; + public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; } + public override IParamsProvider CreateProcParamsProvider() { return new RRProcParams(true); } + + /// Private parameterless constructor invoked by all other (public) constructors + RRCfg() + { + ProcParams = new RRProcParams(true); + } + + public RRCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + Factory = factory; + ParentName = "UniCB"; + Position = 1; + } + + string IComponentCfg.ToString(int i) + { + return string.Format("Name={0}, Parent={1}, Position={2}", + Name, + (string.IsNullOrEmpty(ParentName) ? "-" : ParentName), + Position); + } + } +} \ No newline at end of file diff --git a/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.cs b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.cs new file mode 100644 index 000000000..9d148c43f --- /dev/null +++ b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.cs @@ -0,0 +1,106 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using Common; +using TBF.Rig.Generic; +using TBF.UI.Bench.Components; + +namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB +{ + public partial class RRCfgCtrl : UserControl, IComponentCfgCtrl + { + ComponentParametersDlg parent; + + bool IComponentCfgCtrl.ShowMore { get { return false; } } + + RRCfg config; + + IComponentCfg IComponentCfgCtrl.Config + { + get { return config as IComponentCfg; } + set + { + config = value as RRCfg; + Redraw(); + } + } + + public RRCfgCtrl() + { + InitializeComponent(); + } + + private void RegisterReaderCfgCtrl_Load(object sender, EventArgs e) + { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + if (parent.CmpntEntities != null) + { + foreach (var cmpnt in parent.CmpntEntities) + { + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Uni.Factory) + { + parentNameComboBox.Items.Add(cmpnt.Name); + } + } + } + + Redraw(); + } + + void IComponentCfgCtrl.Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + + componentNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; + positionTextBox.Text = config.Position.ToString(); + } + + void IComponentCfgCtrl.Unlock() + { + nameTextBox.Enabled = true; + parentNameComboBox.Enabled = true; + positionTextBox.Enabled = true; + } + + CfgUpdateFlags IComponentCfgCtrl.VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + int dummy; + if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Parent Name'"; + } + if (!int.TryParse(positionTextBox.Text, out dummy) || (dummy < 1)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "'Position' should be >= 1"; + } + return flags; + } + + CfgUpdateFlags IComponentCfgCtrl.UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; + config.Position = int.Parse(positionTextBox.Text); + + return flags; + } + } +} diff --git a/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.designer.cs b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.designer.cs new file mode 100644 index 000000000..b001066db --- /dev/null +++ b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.designer.cs @@ -0,0 +1,133 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB +{ + partial class RRCfgCtrl + { + /// + /// 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.positionTextBox = new System.Windows.Forms.TextBox(); + this.positionLabel = new System.Windows.Forms.Label(); + this.parentNameLabel = new System.Windows.Forms.Label(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.componentNameLabel = new System.Windows.Forms.Label(); + this.parentNameComboBox = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // positionTextBox + // + this.positionTextBox.Enabled = false; + this.positionTextBox.Location = new System.Drawing.Point(136, 119); + this.positionTextBox.Name = "positionTextBox"; + this.positionTextBox.Size = new System.Drawing.Size(46, 20); + this.positionTextBox.TabIndex = 6; + // + // positionLabel + // + this.positionLabel.AutoSize = true; + this.positionLabel.Location = new System.Drawing.Point(26, 122); + this.positionLabel.Name = "positionLabel"; + this.positionLabel.Size = new System.Drawing.Size(44, 13); + this.positionLabel.TabIndex = 5; + this.positionLabel.Text = "Position"; + // + // parentNameLabel + // + this.parentNameLabel.AutoSize = true; + this.parentNameLabel.Location = new System.Drawing.Point(26, 96); + this.parentNameLabel.Name = "parentNameLabel"; + this.parentNameLabel.Size = new System.Drawing.Size(69, 13); + this.parentNameLabel.TabIndex = 3; + this.parentNameLabel.Text = "Parent Name"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(136, 67); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(26, 70); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // componentNameLabel + // + this.componentNameLabel.AutoSize = true; + this.componentNameLabel.Location = new System.Drawing.Point(133, 43); + this.componentNameLabel.Name = "componentNameLabel"; + this.componentNameLabel.Size = new System.Drawing.Size(83, 13); + this.componentNameLabel.TabIndex = 0; + this.componentNameLabel.Text = "ComonentName"; + // + // parentNameComboBox + // + this.parentNameComboBox.Enabled = false; + this.parentNameComboBox.FormattingEnabled = true; + this.parentNameComboBox.Location = new System.Drawing.Point(136, 93); + this.parentNameComboBox.Name = "parentNameComboBox"; + this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); + this.parentNameComboBox.TabIndex = 4; + // + // RegisterReaderCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.parentNameComboBox); + this.Controls.Add(this.positionTextBox); + this.Controls.Add(this.positionLabel); + this.Controls.Add(this.parentNameLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.componentNameLabel); + this.Name = "RegisterReaderCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.RegisterReaderCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox positionTextBox; + private System.Windows.Forms.Label positionLabel; + private System.Windows.Forms.Label parentNameLabel; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label componentNameLabel; + private System.Windows.Forms.ComboBox parentNameComboBox; + } +} diff --git a/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.resx b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.resx new file mode 100644 index 000000000..d58980a38 --- /dev/null +++ b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRCfgCtrl.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/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRProcParams.cs b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRProcParams.cs new file mode 100644 index 000000000..228c8a8c3 --- /dev/null +++ b/TBF/Rig/RegisterReaders/FrequencyMeterFromUniCB/RRProcParams.cs @@ -0,0 +1,132 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using Common; +using Config.Entities; +using TBF.Rig.Generic; +using TBF.Resources; + +namespace TBF.Rig.RegisterReaders.FrequencyMeterFromUniCB +{ + public class RRProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RRProcParams) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public double PulsesPerLtr; /// [l^-1] + public int Filter; + + public override void InitializeAll() + { + PulsesPerLtr = 1.0; + Filter = 0; + } + + string[] paramNames = new string[] + { + Strings.PulsesPerLtr, + Strings.Filter, + }; + public override string ParamName(int i) { return paramNames[i]; } + public override int ParamsCount() { return paramNames.Length; } + + public override string ToString(int i) + { + switch (i) + { + case 0: return PulsesPerLtr.ToString(); + case 1: return Filter.ToString(); + default: return string.Empty; + } + } + + /// Retrieves parameters from UI controls + CfgUpdateFlags IParamsProvider.UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: PulsesPerLtr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.None; + case 1: Filter = int.Parse(strValue); return CfgUpdateFlags.None; + default: return CfgUpdateFlags.None; + } + } + + /// Verifies whether strings in UI controls represent valid parameters + bool IParamsProvider.ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + double dummy; + int idummy; + switch (i) + { + case 0: + if (Utils.TryParseUDouble(strValue, out dummy)) return true; + break; + + case 1: + if (int.TryParse(strValue, out idummy) && (idummy >= 0)) return true; + break; + + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(RRProcParams prms) + { + prms.PulsesPerLtr = this.PulsesPerLtr; + prms.Filter = this.Filter; + } + + IParamsProvider IParamsProvider.Clone() + { + RRProcParams pars = new RRProcParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateFromDbEntity(ComponentProcedure dbEntity) + { + if (dbEntity == null) return; + try + { + RRProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as RRProcParams; + + procedureParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + procedure = dbEntity.Procedure; + + if (tmp != null) tmp.CopyContentTo(this); + } + catch + { + } + } + + + public RRProcParams() + { + } + + public RRProcParams(bool initialize) + { + if (initialize) InitializeAll(); + } + + public RRProcParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure) + { + this.procedureParamsEntity = procedureParamsEntity; + this.componentName = componentName; + this.procedure = procedure; + } + } +} diff --git a/TBF/Rig/TbfComponents.cs b/TBF/Rig/TbfComponents.cs index 42a9545a1..40c93aaf2 100644 --- a/TBF/Rig/TbfComponents.cs +++ b/TBF/Rig/TbfComponents.cs @@ -124,6 +124,7 @@ namespace TBF.Rig new BuiltIn.PumpTandem.PumpFactory(), new RegisterReaders.DataStream.MefImport.Factory(), /// 'Interface for data stream stream via MEF' new RegisterReaders.DataStream.Reader.Factory(), /// 'RegisterReader for data stream stream via MEF' + new RegisterReaders.FrequencyMeterFromUniCB.Factory(), /// new RegisterReaders.PulsesFromUniCB.Factory(), /// 'RegisterReader' new RegisterReaders.StandingStartStop.Factory(), /// 'RegisterReader for standing start/stop' new TestMethods.iPerlCommunication.iPerlHead.Factory(), /// 'RegisterReader for iPerl' diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 46aaa5544..f8aaa1c39 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1136,6 +1136,16 @@ WriterCfgCtrl.cs + + + + + UserControl + + + RRCfgCtrl.cs + + @@ -3012,6 +3022,9 @@ WriterCfgCtrl.cs + + RRCfgCtrl.cs + CycleBeginningForm.cs