diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/Component.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/Component.cs index e1ee0b6a2..d39fd3d56 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/Component.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/Component.cs @@ -35,7 +35,7 @@ namespace TBF.BenchControl.TestMethods.Endurance public IList Execute(Test test) { - return (new EnduranceSeq()).Execute(test, DebugLevel); + return (new EnduranceSeq()).Execute(test, testMethodCfg.Cycle, DebugLevel); } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleDlg.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleDlg.cs index ea0922f46..2a3fcf05b 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleDlg.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleDlg.cs @@ -5,8 +5,6 @@ using System; using System.Collections.Generic; using System.Windows.Forms; using log4net; -using NHibernate; -using Config.Entities; using TBF.BenchControl.GenericDevices; using TBF.Resources; diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStep.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStep.cs index e2e5503e7..8acf19066 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStep.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStep.cs @@ -6,16 +6,16 @@ namespace TBF.BenchControl.TestMethods.Endurance { public class CycleStep { - public virtual int Duration { get; set; } /// Duration in seconds - public virtual string Message { get; set; } /// Message - public virtual int ValvesOpen { get; set; } /// List of valves to be opened - public virtual int ValvesClose { get; set; } /// List of valves to be closed + public uint Duration { get; set; } /// Duration in seconds + //public virtual string Message { get; set; } /// Message + public uint ValvesOpen { get; set; } /// List of valves to be opened + public uint ValvesClose { get; set; } /// List of valves to be closed public CycleStep() { Duration = 1; - Message = string.Empty; + //Message = string.Empty; ValvesOpen = 0; ValvesClose = 0; } @@ -23,7 +23,7 @@ namespace TBF.BenchControl.TestMethods.Endurance public override string ToString() { - return string.Format("{0}~{1}~{2}~{3}", Duration, Message, ValvesOpen, ValvesClose); + return string.Format("{0}~{1}~{2}", Duration, ValvesOpen, ValvesClose); } @@ -35,24 +35,24 @@ namespace TBF.BenchControl.TestMethods.Endurance { string[] strArr = savedStr.Split(new char[] { '~' }); - int duration; - int vO; - int vC; - if (strArr.Length != 4 || !int.TryParse(strArr[0], out duration) - || !int.TryParse(strArr[2], out vO) - || !int.TryParse(strArr[3], out vC)) + uint duration; + uint vOpen; + uint vClose; + if (strArr.Length != 3 || !uint.TryParse(strArr[0], out duration) + || !uint.TryParse(strArr[1], out vOpen) + || !uint.TryParse(strArr[2], out vClose)) { Duration = 1; - Message = string.Empty; + //Message = string.Empty; ValvesOpen = 0; ValvesClose = 0; } else { Duration = duration; - Message = strArr[1]; - ValvesOpen = vO; - ValvesClose = vC; + //Message = strArr[1]; + ValvesOpen = vOpen; + ValvesClose = vClose; } } @@ -77,7 +77,6 @@ namespace TBF.BenchControl.TestMethods.Endurance if (!string.IsNullOrEmpty(savedCycle)) { - string[] lines = savedCycle.Split(new char[] { 'ยง' }); foreach (var line in lines) { diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStepsCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStepsCtrl.cs index 0e801d0d9..529135b0f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStepsCtrl.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/CycleStepsCtrl.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using log4net; -using Config.Entities; using TBF.BenchControl.GenericDevices; using TBF.Resources; @@ -21,7 +20,7 @@ namespace TBF.BenchControl.TestMethods.Endurance enum Column { Duration, - Message, + //Message, FixedColumnsCount, } readonly int fixedCount = (int)Column.FixedColumnsCount; @@ -55,8 +54,8 @@ namespace TBF.BenchControl.TestMethods.Endurance /// /// ListViewEx columns /// - Columns.Add(Strings.Duration_s, 70 * parent.Dpi / PathsDlg.Dpi100pct); - Columns.Add(Strings.Message, 100 * parent.Dpi / PathsDlg.Dpi100pct); + Columns.Add(Strings.Duration_ms, 100 * parent.Dpi / PathsDlg.Dpi100pct); + //Columns.Add(Strings.Message, 100 * parent.Dpi / PathsDlg.Dpi100pct); /// vCount = 0; foreach (var vlv in parent.Valves) @@ -78,9 +77,9 @@ namespace TBF.BenchControl.TestMethods.Endurance parent.Controls.Add(tb); /// Message - editors[(int)Column.Message] = tb = new TextBox(); - tb.Visible = false; - parent.Controls.Add(tb); + //editors[(int)Column.Message] = tb = new TextBox(); + //tb.Visible = false; + //parent.Controls.Add(tb); /// Valves for (int i = fixedCount; i < fixedCount + vCount; i++) @@ -96,12 +95,14 @@ namespace TBF.BenchControl.TestMethods.Endurance base.RedrawAll(); } + void listViewEx_SubItemClicked(object sender, Results.Forms.SubItemEventArgs e) { if (!Unlocked || e.SubItem >= editors.Length) return; StartEditing(editors[e.SubItem], e.Item, e.SubItem); } + void listViewEx_SubItemRightClicked(object sender, Results.Forms.SubItemEventArgs e) { if (!Unlocked || e.SubItem >= editors.Length) return; @@ -128,26 +129,27 @@ namespace TBF.BenchControl.TestMethods.Endurance } } + void listViewEx_SubItemEndEditing(object sender, Results.Forms.SubItemEndEditingEventArgs e) { if (e.SubItem == (int)Column.Duration) { - int duration; - if (!int.TryParse(e.DisplayText, out duration) || duration <= 0) + uint duration; + if (!uint.TryParse(e.DisplayText, out duration) || (duration % 10) != 0) { e.DisplayText = e.Item.Text; e.Cancel = true; } } - else if (e.SubItem == (int)Column.Message) - { - if (e.DisplayText.Length >= 255) - { - // Message too long - e.DisplayText = e.Item.SubItems[e.SubItem].Text; - e.Cancel = true; - } - } + //else if (e.SubItem == (int)Column.Message) + //{ + // if (e.DisplayText.Length >= 255) + // { + // // Message too long + // e.DisplayText = e.Item.SubItems[e.SubItem].Text; + // e.Cancel = true; + // } + //} else if ((e.SubItem >= fixedCount) && (e.SubItem < fixedCount + vCount)) { if ((e.DisplayText != Strings.open) && (e.DisplayText != Strings.close) && (e.DisplayText != "---")) @@ -162,6 +164,7 @@ namespace TBF.BenchControl.TestMethods.Endurance } } + public override void DrawOne(object myItem) { CycleStep step = (CycleStep)myItem; @@ -169,7 +172,7 @@ namespace TBF.BenchControl.TestMethods.Endurance ListViewItem lvi = new ListViewItem(step.Duration.ToString()); lvi.UseItemStyleForSubItems = false; - lvi.SubItems.Add(string.IsNullOrEmpty(step.Message) ? string.Empty : step.Message); + //lvi.SubItems.Add(string.IsNullOrEmpty(step.Message) ? string.Empty : step.Message); for (int i = 0; i < parent.Valves.Count; i++) { @@ -195,6 +198,7 @@ namespace TBF.BenchControl.TestMethods.Endurance Items.Add(lvi); } + public override void UpdateOne(ListViewItem lvi, object myItem) { CycleStep step = (CycleStep)myItem; @@ -202,8 +206,8 @@ namespace TBF.BenchControl.TestMethods.Endurance /// /// Duration /// - int duration; - if (int.TryParse(lvi.Text, out duration) && duration > 0) + uint duration; + if (uint.TryParse(lvi.Text, out duration) && (duration % 10) != 0) step.Duration = duration; else lvi.Text = step.Duration.ToString(); @@ -211,18 +215,17 @@ namespace TBF.BenchControl.TestMethods.Endurance /// /// Message /// - if (lvi.SubItems[(int)Column.Message].Text.Length == 0) - step.Message = string.Empty; - else - step.Message = lvi.SubItems[(int)Column.Message].Text; - + //if (lvi.SubItems[(int)Column.Message].Text.Length == 0) + // step.Message = string.Empty; + //else + // step.Message = lvi.SubItems[(int)Column.Message].Text; /// /// Valves /// int k = 0; - int valvesOpen = 0; - int valvesClose = 0; + uint valvesOpen = 0; + uint valvesClose = 0; /// for (int i = 0; i < parent.Valves.Count; i++) { @@ -230,22 +233,24 @@ namespace TBF.BenchControl.TestMethods.Endurance string lviSubitText = lvi.SubItems[fixedCount + k++].Text; if (lviSubitText.Equals(Strings.open)) { - valvesOpen += (1 << i); + valvesOpen += ((uint)1 << i); } if (lviSubitText.Equals(Strings.close)) { - valvesClose += (1 << i); + valvesClose += ((uint)1 << i); } } step.ValvesOpen = valvesOpen; step.ValvesClose = valvesClose; } + public void AddOne() { base.AddOne(new CycleStep()); } + public new void RemoveSelected() { bool lastItemRemoved = base.RemoveSelected(); diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs index 49828f9eb..648379787 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs @@ -27,6 +27,7 @@ namespace TBF.BenchControl.TestMethods.Endurance /// Event.Error . . . . . . Unspecified error /// public IList Execute(Config.Entities.Test test, + string enduranceCycleStr, Config.Entities.DebugMode debugLevel) { IList e = new List(); /// Events from currently running operations @@ -71,7 +72,7 @@ namespace TBF.BenchControl.TestMethods.Endurance //------------------------------------------------ if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); /// - State.Create("FlyingStart : Starting the pump") + State.Create("Endurance : Starting the pump") .AddOperation(checkUiOp) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60)) @@ -93,7 +94,7 @@ namespace TBF.BenchControl.TestMethods.Endurance Bridge.OnActivity(this, Strings.Setting_the_flow); //------------------------------------------------ int flowSetTime0 = StateMachine.Time; - State.Create("FlyingStart : Setting the flow") + State.Create("Endurance : Setting the flow") .AddOperation(checkUiOp) .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min. .EnterState(); @@ -125,9 +126,9 @@ namespace TBF.BenchControl.TestMethods.Endurance /// 2 = measurement through line 2 /// 3 = continuous test { - /// - /// Endurance test : measurement through line 1 or line 2 - /// + ///----------------------------------------------------- + /// Flying start measurement through line 1 or line 2 + ///----------------------------------------------------- /// Extract cameras from the current sensors path, add operations to the detection state IList measureOperations = new List(); @@ -140,7 +141,7 @@ namespace TBF.BenchControl.TestMethods.Endurance //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_in_progress); //------------------------------------------------ - State.Create("FlyingStart : Starting the test") + State.Create("Endurance : Starting the test") .AddOperation(checkUiOp) .AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp)) .AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown)) @@ -395,9 +396,31 @@ namespace TBF.BenchControl.TestMethods.Endurance { /// /// Endurance test : switching mode - /// + /// - } + IList enduranceCycle = CycleStep.StringToCycle(enduranceCycleStr); + int stepsCount = Math.Min(enduranceCycle.Count, 80); + + /// Fill in CyclePar[] array + uint[] cyclePar = new uint[2 * stepsCount + 3]; + uint duration = 0; + uint state = 0; + for (int i = 0; i < stepsCount; i++) + { + state = state | enduranceCycle[i].ValvesOpen; + state = state & (~enduranceCycle[i].ValvesClose); + + cBrd.SetCyclePar(2 * i + 1, duration / 10); + cBrd.SetCyclePar(2 * i + 2, state); + + duration += enduranceCycle[i].Duration; + } + cBrd.SetCyclePar(2 * stepsCount + 1, 0); + cBrd.SetCyclePar(2 * stepsCount + 2, 0); + cBrd.SetCyclePar(0, duration / 10); + + + } @@ -413,7 +436,7 @@ namespace TBF.BenchControl.TestMethods.Endurance /// Quit this sequence /// ///----------------------/// - State.Create("FlyingStart : Stopping diverter, gate, etc.") + State.Create("Endurance : Stopping diverter, gate, etc.") .AddOperation(checkUiOp) .AddOperation(cBrd.StopPreviousOp()) .EnterState(); diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 415fe4b3b..fab147427 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1068,6 +1068,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Duration [ms]. + /// + internal static string Duration_ms { + get { + return ResourceManager.GetString("Duration_ms", resourceCulture); + } + } + /// /// Looks up a localized string similar to PMax duration [s]. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 238d85ad1..776a6e6e9 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1600,4 +1600,7 @@ Endurance cycle + + Duration [ms] + \ No newline at end of file