From 0494054171d22734529354444b339ae139592d4d Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 16 Nov 2021 22:40:23 +0100 Subject: [PATCH] Yet more MainWnd, MainSeq, etc. changes,ver. 3.1.1811 --- Common/Enums.cs | 4 +- Common/ProcedureInfo.cs | 37 +++- Results/BatchResults.cs | 5 +- Results/Entities/Batch.cs | 1 + TBF/Properties/AssemblyInfo.cs | 4 +- TBF/Rig/Sequences/MainSeq.cs | 8 +- TBF/Rig/Sequences/MainSeqUtils.cs | 3 +- TBF/UI/MainWnd.Designer.cs | 1 + TBF/UI/MainWnd.cs | 351 ++++++++++++++++-------------- TBF/UI/MainWnd.resx | 54 ++--- 10 files changed, 259 insertions(+), 209 deletions(-) diff --git a/Common/Enums.cs b/Common/Enums.cs index 7abbfce78..a7173c812 100644 --- a/Common/Enums.cs +++ b/Common/Enums.cs @@ -70,8 +70,8 @@ namespace Common [Description("None")] None, [Description("Local procedures")] FromLocalDB, [Description("Shared procedures")] FromSharedDB, - [Description("Orders from Oracle DB")] OrderNrFromOracleDB, - [Description("Orders from Tracing DB")] OrderNrFromTracingDB, + [Description("Orders from Oracle DB")] OrderFromOracleDB, + [Description("Orders from Tracing DB")] OrderFromTracingDB, #endif Count } diff --git a/Common/ProcedureInfo.cs b/Common/ProcedureInfo.cs index 833662ad8..a31714fa7 100644 --- a/Common/ProcedureInfo.cs +++ b/Common/ProcedureInfo.cs @@ -13,47 +13,62 @@ namespace Common public class ProcedureInfo { public readonly ProcedureSelection Source; - public readonly string Signature; - public readonly int ItemNr; + public int ItemNr; public readonly string Name; + public readonly string Signature; + public string Variant; + public string Order; + public string Workflow; + public bool IsNative; public ProcedureSelection ResolvedSource; /// ProcedureSelection.FromLocalDB or ProcedureSelection.FromSharedDB when Resolved==true public string ResolvedName; - public string Order; - public string Variant; - public ProcedureInfo(ProcedureSelection source, int itemNr, string name, string signature = null, string variant = null) + public ProcedureInfo(ProcedureSelection source, int itemNr, string name, string signature = null, + string variant = null, string order = null, string workflow = null) { Source = source; - Signature = (signature == null) ? string.Empty : signature; ItemNr = itemNr; Name = name; + Signature = (signature == null) ? string.Empty : signature; + Variant = (variant == null) ? string.Empty : variant; + Order = order; + Workflow = workflow; + if (source == ProcedureSelection.FromLocalDB || source == ProcedureSelection.FromSharedDB) { + IsNative = true; ResolvedSource = source; ResolvedName = name; } else { + IsNative = false; ResolvedSource = ProcedureSelection.None; ResolvedName = string.Empty; } - Variant = (variant == null) ? string.Empty : variant; } public static string GetSignature(ProcedureSelection source, ICollection allSources) { - return (source == ProcedureSelection.OrderNrFromOracleDB) ? "" - : (source == ProcedureSelection.OrderNrFromTracingDB) ? "" + return (source == ProcedureSelection.OrderFromOracleDB) ? "" + : (source == ProcedureSelection.OrderFromTracingDB) ? "" : (source == ProcedureSelection.FromSharedDB) ? "R" : (allSources != null && allSources.Contains(ProcedureSelection.FromSharedDB)) ? "L" : ""; } + public bool IsValid + { + get { + return (ResolvedSource != ProcedureSelection.None) && !string.IsNullOrEmpty(ResolvedName); + } + } + public override string ToString() { switch (Source) { - case ProcedureSelection.OrderNrFromOracleDB: - case ProcedureSelection.OrderNrFromTracingDB: + case ProcedureSelection.OrderFromOracleDB: + case ProcedureSelection.OrderFromTracingDB: return Name; case ProcedureSelection.FromSharedDB: case ProcedureSelection.FromLocalDB: diff --git a/Results/BatchResults.cs b/Results/BatchResults.cs index 81a719b29..fa213944e 100644 --- a/Results/BatchResults.cs +++ b/Results/BatchResults.cs @@ -44,7 +44,7 @@ namespace Results public static BatchResults NewFromProcedure(int batchNr, int benchId, string benchName, string a1, string a2, string a3, string a4, string a5, string user, int userNr, string programVer, Config.Entities.Procedure procedure, - WaterMeterData[] waterMeterDatas, int[] waterMeterParts, string variant, string order, + WaterMeterData[] waterMeterDatas, int[] waterMeterParts, string variant, string order, string workflow, double realDensity, double atTemperature, double buoyancy) { BatchResults d = new BatchResults(waterMeterDatas.Length); @@ -66,8 +66,9 @@ namespace Results UserNumber = userNr, ProcedureName = procedure.Name, ProcedureDescription = procedure.Description, - WatermetersStr = variant, + WatermetersStr = (variant != null) ? variant : string.Empty, PurchaseOrder = order, + Workflow = workflow, ProcedureRevision = procedure.Revision, StartTime = DateTime.Now, SampleDensity = realDensity, diff --git a/Results/Entities/Batch.cs b/Results/Entities/Batch.cs index 702ca6556..de72f7ef2 100644 --- a/Results/Entities/Batch.cs +++ b/Results/Entities/Batch.cs @@ -24,6 +24,7 @@ namespace Results.Entities public virtual string ProcedureName { get; set; } public virtual bool IsRemoteProcedure { get; set; } /// Stara Tura, not mapped to DB public virtual string PurchaseOrder { get; set; } /// Stara Tura, Nanjing, not mapped to DB + public virtual string Workflow { get; set; } /// Stara Tura, Nanjing, not mapped to DB public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB public virtual int ProcedureRevision { get; set; } public virtual string WatermetersStr { get; set; } /// CEVAK, not mapped to DB diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 7d83e2fa1..a75bb6a35 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.1.1810.0")] -[assembly: AssemblyFileVersion("3.1.1810.0")] +[assembly: AssemblyVersion("3.1.1811.0")] +[assembly: AssemblyFileVersion("3.1.1811.0")] diff --git a/TBF/Rig/Sequences/MainSeq.cs b/TBF/Rig/Sequences/MainSeq.cs index 1011aeef5..ac00c40de 100644 --- a/TBF/Rig/Sequences/MainSeq.cs +++ b/TBF/Rig/Sequences/MainSeq.cs @@ -377,7 +377,7 @@ namespace TBF.Rig.Sequences if (selection == Selection.RestoreBatch) { - BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure, string.Empty, null); + BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure); RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored } else if (selection == Selection.RestoreAndFixBatch) @@ -385,7 +385,7 @@ namespace TBF.Rig.Sequences /// /// Restore and fix a batch - part 1 (fix "Previous workstep is missing" error) /// - BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure, string.Empty, null); + BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure); RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++) @@ -426,7 +426,9 @@ namespace TBF.Rig.Sequences else if (selection != Selection.RestoreInterruptedSession) { /// This is a regular session => initialize BatchRslts - BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure, Bridge.SelectedProcedure.Variant, Bridge.SelectedProcedure.Order); + BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure, Bridge.SelectedProcedure.Variant, + Bridge.SelectedProcedure.Order, + Bridge.SelectedProcedure.Workflow); } diff --git a/TBF/Rig/Sequences/MainSeqUtils.cs b/TBF/Rig/Sequences/MainSeqUtils.cs index b76aa8aeb..e03b9c55a 100644 --- a/TBF/Rig/Sequences/MainSeqUtils.cs +++ b/TBF/Rig/Sequences/MainSeqUtils.cs @@ -534,7 +534,7 @@ namespace TBF.Rig.Sequences /// New batch number /// Selected procedure /// Created BatchResults - Results.BatchResults CreateNewBatchResults(int newBatchNr, Procedure procedure, string variant, string order) + Results.BatchResults CreateNewBatchResults(int newBatchNr, Procedure procedure, string variant = null, string order = null, string workflow = null) { /// /// Prepare new water meters @@ -621,6 +621,7 @@ namespace TBF.Rig.Sequences waterMeterParts, variant, order, + workflow, Formulas.RealDensity(), Formulas.AtTemperature(), Formulas.Buoyancy()); diff --git a/TBF/UI/MainWnd.Designer.cs b/TBF/UI/MainWnd.Designer.cs index 62fe0c67b..76ddc74fc 100644 --- a/TBF/UI/MainWnd.Designer.cs +++ b/TBF/UI/MainWnd.Designer.cs @@ -221,6 +221,7 @@ namespace TBF.UI this.procedureComboBox.FormattingEnabled = true; this.procedureComboBox.Name = "procedureComboBox"; this.procedureComboBox.SelectedIndexChanged += new System.EventHandler(this.procedureComboBox_SelectedIndexChanged); + this.procedureComboBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.procedureComboBox_KeyPress); // // progressGroupBox // diff --git a/TBF/UI/MainWnd.cs b/TBF/UI/MainWnd.cs index a12b7f89c..fae53e180 100644 --- a/TBF/UI/MainWnd.cs +++ b/TBF/UI/MainWnd.cs @@ -32,11 +32,21 @@ namespace TBF.UI const string ProcSeparator = " "; /// string separating procedure number and procedure name public BenchControlPanel BenchControlPanel; - public ProcedureInfo SelectedProcedure; - public Procedure CurrentProcedure; public bool IsShutdownDisabled; public bool IsShutdownPCAfterClosingTbf; + /// + /// Procedure selection + /// + IList localProcedures; /// procedures loaded form the local DB + IList remoteProcedures; /// Procedures loaded from thr remote/shared DB + IList mySqlOrders; /// Production orders loaded from the production tracing DB + IList oracleOrders; /// Production orders loaded from the Oracle DB + IList procedureInfos; /// Composed procedure infos + /// + public ProcedureInfo SelectedProcedure; + public Procedure CurrentProcedure; + /// /// This dialog is shown when TBF program is shutting down /// @@ -105,16 +115,18 @@ namespace TBF.UI Program.Version, TBF.DB.CurrentBench.BenchName, TBF.DB.CurrentBench.IsRealBench ? "" : Strings._offline); - /// + + localProcedures = new List(); + remoteProcedures = new List(); + mySqlOrders = new List(); + oracleOrders = new List(); + procedureInfos = new List(); + SelectedProcedure = null; + CurrentProcedure = null; + + /// /// Customize menu items /// - graphsToolStripMenuItem.Text = Strings.Graphs; - eventLogsTSMenuItem.Text = Strings.Event_logs; - calendarTSMenuItem.Text = Strings.Calendar; - settingsTSMenuItem.Text = Strings.Settings; - optoHeadsToolStripMenuItem.Text = Strings.Optical_heads; - clearCountersToolStripMenuItem.Text = Strings.Clear_counters; - helpTSMenuItem.Text = Strings.Help; #if CAMERA /// Add 'Camera' menu item cameraTSMItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -138,6 +150,27 @@ namespace TBF.UI /// Load the list of components from the database var session = TBF.DB.CreateSession(DBKind.Config); cmpntEntities = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + + /// + /// Set TBF.Data members when there is a BenchInfo or an iPerlBenchInfo component + /// + foreach (var cmpnt in cmpntEntities) + { + if (cmpnt.ClassName == "DataContainer.BenchInfo") + { + var cfg = new TBF.Rig.DataContainer.BenchInfo.Factory().CmpntCfgFromCmpntEntity(cmpnt) + as TBF.Rig.DataContainer.BenchInfo.ComponentCfg; + TBF.Data.SetData(cfg.WaterMetersCount, cfg.CompoundMetersCount, cfg.LinesCount); + break; + } + else if (cmpnt.ClassName == "DataContainer.iPerlBenchInfo") + { + var cfg = new TBF.Rig.DataContainer.iPerlBenchInfo.Factory().CmpntCfgFromCmpntEntity(cmpnt) + as TBF.Rig.DataContainer.iPerlBenchInfo.ComponentCfg; + TBF.Data.SetData(cfg.WaterMetersCount, cfg.CompoundMetersCount, cfg.LinesCount); + break; + } + } } catch (Exception) { @@ -145,27 +178,6 @@ namespace TBF.UI cmpntEntities = new List(); } - /// - /// Set TBF.Data members when there is a BenchInfo or an iPerlBenchInfo component - /// - foreach (var cmpnt in cmpntEntities) - { - if (cmpnt.ClassName == "DataContainer.BenchInfo") - { - var cfg = new TBF.Rig.DataContainer.BenchInfo.Factory().CmpntCfgFromCmpntEntity(cmpnt) - as TBF.Rig.DataContainer.BenchInfo.ComponentCfg; - TBF.Data.SetData(cfg.WaterMetersCount, cfg.CompoundMetersCount, cfg.LinesCount); - break; - } - else if (cmpnt.ClassName == "DataContainer.iPerlBenchInfo") - { - var cfg = new TBF.Rig.DataContainer.iPerlBenchInfo.Factory().CmpntCfgFromCmpntEntity(cmpnt) - as TBF.Rig.DataContainer.iPerlBenchInfo.ComponentCfg; - TBF.Data.SetData(cfg.WaterMetersCount, cfg.CompoundMetersCount, cfg.LinesCount); - break; - } - } - Rig.StateMachine.MachineState = TBF.DB.CurrentBench.IsRealBench ? Rig.MachineState.StartingUp : Rig.MachineState.Disabled; /// if (Rig.StateMachine.MachineState == Rig.MachineState.StartingUp) @@ -179,8 +191,8 @@ namespace TBF.UI string msg; Rig.GenericDevices.IBenchInfo benchInfo = Rig.Sequences.ProcessData.BenchInfo; bool sharedDBUsed = benchInfo != null ? benchInfo.Sources.Contains(ProcedureSelection.FromSharedDB) : false; - bool oracleDBUsed = benchInfo != null ? benchInfo.Sources.Contains(ProcedureSelection.OrderNrFromOracleDB) : false; - bool tracingDBUsed = benchInfo != null ? benchInfo.Sources.Contains(ProcedureSelection.OrderNrFromTracingDB) : false; + bool oracleDBUsed = benchInfo != null ? benchInfo.Sources.Contains(ProcedureSelection.OrderFromOracleDB) : false; + bool tracingDBUsed = benchInfo != null ? benchInfo.Sources.Contains(ProcedureSelection.OrderFromTracingDB) : false; if (sharedDBUsed && !Rig.StateMachine.IsRemoteDBCompatible(out msg)) { @@ -228,7 +240,15 @@ namespace TBF.UI void Localize() { - procedureGroupBox.Text = Strings.Procedure; + graphsToolStripMenuItem.Text = Strings.Graphs; + eventLogsTSMenuItem.Text = Strings.Event_logs; + calendarTSMenuItem.Text = Strings.Calendar; + settingsTSMenuItem.Text = Strings.Settings; + optoHeadsToolStripMenuItem.Text = Strings.Optical_heads; + clearCountersToolStripMenuItem.Text = Strings.Clear_counters; + helpTSMenuItem.Text = Strings.Help; + + procedureGroupBox.Text = Strings.Procedure; activityGroupBox.Text = Strings.Activity; progressGroupBox.Text = Strings.Progress; } @@ -450,18 +470,18 @@ namespace TBF.UI /// private void MainWnd_KeyPress(object sender, KeyPressEventArgs e) { -#if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT || GENESIS || CEVAK_200 || TURA_SPECIAL +#if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT || GENESIS || CEVAK_200 || TURA_SPECIAL || TURA_IPERL || TURA_IPERL_NEW /// Do nothing = do not process keys #else - //if (BenchControlPanel != null && BenchControlPanel.ProcessKey(e.KeyChar)) - //{ - // e.Handled = true; - // log.WarnFormat("'{0}' key pressed, handled by BenchControlPanel", e.KeyChar); - //} - //else - //{ - // log.WarnFormat("'{0}' key pressed, not handled", e.KeyChar); - //} + if (BenchControlPanel != null && BenchControlPanel.ProcessKey(e.KeyChar)) + { + e.Handled = true; + log.WarnFormat("'{0}' key pressed, handled by BenchControlPanel", e.KeyChar); + } + else + { + log.WarnFormat("'{0}' key pressed, not handled", e.KeyChar); + } #endif } @@ -587,9 +607,15 @@ namespace TBF.UI procedureComboBox.Enabled = ((args.Flags & ButtonsEtc.ProcedureCmbBoxEn) != 0); optoHeadsToolStripMenuItem.Enabled = ((args.Flags & ButtonsEtc.ProcedureCmbBoxEn) != 0); - if (procedureComboBox.Enabled && ProceduresUpdated) + if (procedureComboBox.Enabled) { - ReloadProcedureComboBoxItems(); + if (ProceduresUpdated) ReloadProcedureComboBoxItems(); + procedureGroupBox.BackColor = Color.Yellow; + procedureComboBox.Focus(); + } + else + { + procedureGroupBox.BackColor = SystemColors.Control; } IsShutdownDisabled = ((args.Flags & ButtonsEtc.ProcedureCmbBoxEn) == 0); @@ -703,65 +729,79 @@ namespace TBF.UI ReloadProcedureComboBoxItems(procName); } - IList mySqlOrders = new List(); - IList oracleOrders = new List(); - public void ReloadProcedureComboBoxItems(string procedureNameToSelect) { - /// Ensure there is at least one way to select a procedure - ICollection sources; - if (Rig.Sequences.ProcessData.BenchInfo == null) + if (!procedureComboBox.Enabled) { - sources = new ProcedureSelection[] { ProcedureSelection.FromLocalDB }; + /// Test cycle in progress, reload combo box items when the session is finished + ProceduresUpdated = true; } else { - bool noneOnly = true; - foreach (var s in Rig.Sequences.ProcessData.BenchInfo.Sources) if (s != ProcedureSelection.None) { noneOnly = false; break; } + /// + /// Ensure there is at least one source = one way to select a procedure + /// + ICollection sources; + if (Rig.Sequences.ProcessData.BenchInfo == null) + { + sources = new ProcedureSelection[] { ProcedureSelection.FromLocalDB }; + } + else + { + bool noneOnly = true; + foreach (var s in Rig.Sequences.ProcessData.BenchInfo.Sources) if (s != ProcedureSelection.None) { noneOnly = false; break; } + + sources = noneOnly + ? new ProcedureSelection[] { ProcedureSelection.FromLocalDB } + : Rig.Sequences.ProcessData.BenchInfo.Sources; + } - sources = noneOnly - ? new ProcedureSelection[] { ProcedureSelection.FromLocalDB } - : Rig.Sequences.ProcessData.BenchInfo.Sources; - } - if (procedureComboBox.Enabled) - { bool procedureSet = false; procedureComboBox.Items.Clear(); - IList procInfos = new List(); - IList nativeProcedures = new List(); - IList nativeSources = new List(); + procedureInfos.Clear(); foreach (var src in sources) { string signature = ProcedureInfo.GetSignature(src, sources); int itemNr = 1; - if (src == ProcedureSelection.FromLocalDB || src == ProcedureSelection.FromSharedDB) + if (src == ProcedureSelection.FromLocalDB) { - var procedures = TBF.DB.CreateSession((src == ProcedureSelection.FromSharedDB) ? DBKind.RemoteConfig : DBKind.Config) - .QueryOver() - .Where(x => (x.ProcedureState == ProcedureState.Active)) - .OrderBy(x => x.ItemNr).Asc - .List(); + localProcedures = TBF.DB.CreateSession(DBKind.Config) + .QueryOver() + .Where(x => (x.ProcedureState == ProcedureState.Active)) + .OrderBy(x => x.ItemNr).Asc + .List(); - foreach (var proc in procedures) + foreach (var proc in localProcedures) { - nativeProcedures.Add(proc); - nativeSources.Add(src); - procInfos.Add(new ProcedureInfo(src, itemNr++, proc.Name, signature, proc.Watermeters)); + procedureInfos.Add(new ProcedureInfo(src, itemNr++, proc.Name, signature, proc.Watermeters)); } } - else if (src == ProcedureSelection.OrderNrFromOracleDB) + else if (src == ProcedureSelection.FromSharedDB) + { + remoteProcedures = TBF.DB.CreateSession(DBKind.RemoteConfig) + .QueryOver() + .Where(x => (x.ProcedureState == ProcedureState.Active)) + .OrderBy(x => x.ItemNr).Asc + .List(); + + foreach (var proc in remoteProcedures) + { + procedureInfos.Add(new ProcedureInfo(src, itemNr++, proc.Name, signature, proc.Watermeters)); + } + } + else if (src == ProcedureSelection.OrderFromOracleDB) { oracleOrders = Rig.Sequences.ProcessData.OracleDB.ReadOrderNumbers(); foreach (var order in oracleOrders) { - procInfos.Add(new ProcedureInfo(src, itemNr++, order.AuftragsNummer.ToString(), signature, order.VariantenCode)); + procedureInfos.Add(new ProcedureInfo(src, 0, order.AuftragsNummer.ToString(), signature, order.VariantenCode, order.AuftragsNummer)); } } - else if (src == ProcedureSelection.OrderNrFromTracingDB) + else if (src == ProcedureSelection.OrderFromTracingDB) { try { @@ -777,19 +817,24 @@ namespace TBF.UI foreach (var order in mySqlOrders) { - procInfos.Add(new ProcedureInfo(src, itemNr++, order.POName, signature, order.VariantCode)); + procedureInfos.Add(new ProcedureInfo(src, 0, order.POName, signature, order.VariantCode, order.POName, order.Workflow)); } } } - foreach (var pInfo in procInfos) + ResolveOrders(procedureInfos); + + foreach (var procInfo in procedureInfos) { - procedureComboBox.Items.Add(pInfo); - if (!procedureSet && (procedureNameToSelect == pInfo.Name)) + if (procInfo.IsValid) { - procedureSet = true; - procedureComboBox.Text = pInfo.ToString(); - SelectedProcedure = pInfo; + procedureComboBox.Items.Add(procInfo); + if (!procedureSet && (procedureNameToSelect == procInfo.Name)) + { + procedureSet = true; + procedureComboBox.Text = procInfo.ToString(); + SelectedProcedure = procInfo; + } } } @@ -799,15 +844,9 @@ namespace TBF.UI SelectedProcedure = null; } - ResolveOrders(procInfos, nativeProcedures, nativeSources); - ProceduresUpdated = false; if (SelectedProcedure != null) BenchControlPanel.ReloadTests(); - } - else - { - ProceduresUpdated = true; } } @@ -817,30 +856,49 @@ namespace TBF.UI /// ProcedureInfo-s that contain unresolved, as well as resolved (native) procedures /// Native procedures /// ProcedureSelection sources of native procedures (the same list items count as nativeProcedures) - void ResolveOrders(IList procInfos, IList nativeProcedures, IList nativeSources) + void ResolveOrders(IList procInfos) { foreach (var pi in procInfos) { - if (pi.ResolvedSource == ProcedureSelection.None) + if (!pi.IsNative) { - for (int i = 0; i < nativeProcedures.Count; i++) + if (pi.Source == ProcedureSelection.OrderFromTracingDB) { - var np = nativeProcedures[i]; - if (IsMatch(pi, np)) + /// pi.Name is the order name (the production order number) + /// Production orders in the tracing DB contain test procedure names + var order = mySqlOrders.FirstOrDefault(x => x.POName == pi.Name); + var procInfo = (order == null) ? null : procInfos.FirstOrDefault(x => x.IsNative && x.Name == order.TestProcedure); + if (procInfo != null) { - pi.ResolvedName = np.Name; - pi.ResolvedSource = nativeSources[i]; - break; + pi.ItemNr = procInfo.ItemNr; + pi.ResolvedName = procInfo.Name; + pi.ResolvedSource = procInfo.Source; + } + } + else if (pi.Source == ProcedureSelection.OrderFromOracleDB) + { + /// pi.Name is the order name (the production order number) + /// Production orders in Oracle DB contain varian codes + var order = oracleOrders.FirstOrDefault(x => x.AuftragsNummer == pi.Name); + var vaco = (order == null) ? null : order.VariantenCode; + foreach (var pi2 in procInfos) + { + if (pi2.IsNative && IsMatch(pi, pi2)) + { + pi.ItemNr = pi2.ItemNr; + pi.ResolvedName = pi2.Name; + pi.ResolvedSource = pi2.Source; + } } } } } } - bool IsMatch(ProcedureInfo procInfo, Procedure nativeProcedure) + bool IsMatch(ProcedureInfo procInfoToBeResolved, ProcedureInfo nativeProcedure) { - string var1 = procInfo.Variant; - string var2 = nativeProcedure.Watermeters; + string var1 = procInfoToBeResolved.Variant; + string var2 = nativeProcedure.Variant; if (var2.Length == 0 || var1.Length != var2.Length) return false; @@ -854,75 +912,46 @@ namespace TBF.UI private void procedureComboBox_SelectedIndexChanged(object sender, EventArgs e) { - var benchInfo = TBF.Rig.Sequences.ProcessData.BenchInfo; - int separPos = procedureComboBox.Text.IndexOf(ProcSeparator); - int orderNumber; + foreach (var item in procedureComboBox.Items) + { + var procInfo = item as ProcedureInfo; + if (procInfo != null && procInfo.IsValid && procInfo.ToString() == procedureComboBox.Text) + { + SelectedProcedure = procInfo; - if (benchInfo == null) - { - int procNr = int.Parse(procedureComboBox.Text.Substring(0, separPos)); - string procName = procedureComboBox.Text.Substring(separPos + ProcSeparator.Length); - UpdateProcedure(procNr, procName, ProcedureSelection.FromLocalDB); - } - else if (int.TryParse(procedureComboBox.Text, out orderNumber)) - { - if (benchInfo.Sources.Contains(ProcedureSelection.OrderNrFromTracingDB)) - { - var orderInfo = mySqlOrders.FirstOrDefault(x => x.POName == procedureComboBox.Text); - if (orderInfo != null) + BenchControlPanel.ReloadTests(); + if (CurrentProcedure != null && CurrentProcedure.Description != null) { - UpdateProcedure(0, orderInfo.TestProcedure, ProcedureSelection.OrderNrFromTracingDB, procedureComboBox.Text); + descriptionLabel.Text = CurrentProcedure.Description; } - } - else if (benchInfo.Sources.Contains(ProcedureSelection.OrderNrFromOracleDB)) - { - var orderDetails = oracleOrders.FirstOrDefault(x => x.AuftragsNummer == procedureComboBox.Text); - if (orderDetails != null) + if (CurrentProcedure != null && testProgressControls != null) { - UpdateProcedure(0, orderDetails.AuftragsNummer, ProcedureSelection.OrderNrFromOracleDB, procedureComboBox.Text); + testProgressControls.ProcedureSelectedInUI(this, new UiBridge.ProcedureSelectedEventArgs(CurrentProcedure)); + } + if (!string.IsNullOrEmpty(procInfo.ResolvedName)) + { + Program.LocalSettings.LastProcedureName = procInfo.ResolvedName; + Program.LocalSettings.LastProcedureSource = procInfo.ResolvedSource; + Program.LocalSettings.LastProcedureNr = procInfo.ItemNr; + Program.LocalSettings.Save(); } } - } - else if (!string.IsNullOrEmpty(procedureComboBox.Text) && (procedureComboBox.Text[0] == 'L' || procedureComboBox.Text[0] == 'R')) - { - int procNr = int.Parse(procedureComboBox.Text.Substring(1, separPos)); - string procName = procedureComboBox.Text.Substring(separPos + ProcSeparator.Length); - var source = (procedureComboBox.Text[0] == 'R') ? ProcedureSelection.FromSharedDB : ProcedureSelection.FromLocalDB; - UpdateProcedure(procNr, procName, source); - } - else - { - int procNr = int.Parse(procedureComboBox.Text.Substring(0, separPos)); - string procName = procedureComboBox.Text.Substring(separPos + ProcSeparator.Length); - UpdateProcedure(procNr, procName, ProcedureSelection.FromLocalDB); } } - public void UpdateProcedure(int procedureNr, string procedureName, ProcedureSelection source, string order = null) - { - SelectedProcedure = new ProcedureInfo(source, 0, procedureName, - ProcedureInfo.GetSignature(source, (Rig.Sequences.ProcessData.BenchInfo != null) ? Rig.Sequences.ProcessData.BenchInfo.Sources : null)); - SelectedProcedure.ResolvedSource = ProcedureSelection.FromLocalDB; - SelectedProcedure.ResolvedName = procedureName; - SelectedProcedure.Order = order; - - BenchControlPanel.ReloadTests(); - if (CurrentProcedure != null && CurrentProcedure.Description != null) - { - descriptionLabel.Text = CurrentProcedure.Description; - } - if (CurrentProcedure != null && testProgressControls != null) - { - testProgressControls.ProcedureSelectedInUI(this, new UiBridge.ProcedureSelectedEventArgs(CurrentProcedure)); - } - if (!string.IsNullOrEmpty(procedureName)) - { - Program.LocalSettings.LastProcedureName = procedureName; - Program.LocalSettings.LastProcedureSource = source; - Program.LocalSettings.LastProcedureNr = procedureNr; - Program.LocalSettings.Save(); - } - } + private void procedureComboBox_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == '\r' && procedureComboBox.Enabled) + { + /// Enter key was pressed ... + procedureComboBox_SelectedIndexChanged(sender, e as EventArgs); + if (SelectedProcedure != null && SelectedProcedure.IsValid) + { + /// and according to procedureComboBox.Text a valid procedure was selected => start a test cycle + Bridge.Ui2Bench(UI2BenchCmd.StartCycle); + } + } + } /// /// Save UI settings to Program.LocalSettings and save them to a file. diff --git a/TBF/UI/MainWnd.resx b/TBF/UI/MainWnd.resx index 6299a926d..ac00428df 100644 --- a/TBF/UI/MainWnd.resx +++ b/TBF/UI/MainWnd.resx @@ -643,7 +643,7 @@ 4, 4, 4, 4 - 1012, 523 + 1012, 582 1 @@ -652,7 +652,7 @@ processTabPageCtrl - TBF.UI.Process.ProcessTabPageCtrl24, TBF, Version=3.1.1656.0, Culture=neutral, PublicKeyToken=null + TBF.UI.Process.ProcessTabPageCtrl, TBF, Version=3.1.1810.0, Culture=neutral, PublicKeyToken=null processTabPage @@ -664,7 +664,7 @@ 4, 5 - 1012, 523 + 1012, 582 30 @@ -688,7 +688,7 @@ 4, 5 - 1012, 523 + 1012, 582 22 @@ -721,7 +721,7 @@ 4, 4, 4, 4 - 1012, 523 + 1012, 582 0 @@ -730,7 +730,7 @@ resultsTabPageCtrl - TBF.UI.ResultsMI.ResultsTabPageCtrl, TBF, Version=3.1.1656.0, Culture=neutral, PublicKeyToken=null + TBF.UI.ResultsMI.ResultsTabPageCtrl, TBF, Version=3.1.1810.0, Culture=neutral, PublicKeyToken=null resultsTabPage @@ -742,7 +742,7 @@ 4, 5 - 1012, 523 + 1012, 582 15 @@ -772,7 +772,7 @@ 0, 0 - 1012, 523 + 1012, 582 0 @@ -781,7 +781,7 @@ graphsTabPageCtrl - TBF.UI.Graphs.GraphsTabPageCtrl, TBF, Version=3.1.1656.0, Culture=neutral, PublicKeyToken=null + TBF.UI.Graphs.GraphsTabPageCtrl, TBF, Version=3.1.1810.0, Culture=neutral, PublicKeyToken=null graphsTabPage @@ -793,7 +793,7 @@ 4, 5 - 1012, 523 + 1012, 582 32 @@ -826,7 +826,7 @@ 4, 4, 4, 4 - 1012, 523 + 1012, 582 0 @@ -835,7 +835,7 @@ eventLogsTabPageCtrl - TBF.UI.EventLogs.EventLogsTabPageCtrl, TBF, Version=3.1.1656.0, Culture=neutral, PublicKeyToken=null + TBF.UI.EventLogs.EventLogsTabPageCtrl, TBF, Version=3.1.1810.0, Culture=neutral, PublicKeyToken=null eventLogsTabPage @@ -847,7 +847,7 @@ 4, 5 - 1012, 523 + 1012, 582 21 @@ -877,7 +877,7 @@ 0, 0 - 1012, 523 + 1012, 582 0 @@ -886,7 +886,7 @@ calendarTabPageCtrl - TBF.UI.Calendar.CalendarTabPageCtrl, TBF, Version=3.1.1656.0, Culture=neutral, PublicKeyToken=null + TBF.UI.Calendar.CalendarTabPageCtrl, TBF, Version=3.1.1810.0, Culture=neutral, PublicKeyToken=null calendarTabPage @@ -898,7 +898,7 @@ 4, 5 - 1012, 523 + 1012, 582 33 @@ -928,7 +928,7 @@ 0, 0 - 1012, 523 + 1012, 582 0 @@ -937,7 +937,7 @@ picturesTabPageCtrl - TBF.UI.Camera.PicturesTabPageCtrl, TBF, Version=3.1.1656.0, Culture=neutral, PublicKeyToken=null + TBF.UI.Camera.PicturesTabPageCtrl, TBF, Version=3.1.1810.0, Culture=neutral, PublicKeyToken=null picturesTabPage @@ -949,7 +949,7 @@ 4, 5 - 1012, 523 + 1012, 582 31 @@ -1291,19 +1291,19 @@ Event logs - 152, 22 + 150, 22 Users - 152, 22 + 150, 22 Language - 152, 22 + 150, 22 Profiles @@ -1321,31 +1321,31 @@ Test results - 152, 22 + 150, 22 Back up - 152, 22 + 150, 22 Password - 152, 22 + 150, 22 Upgrade - 152, 22 + 150, 22 Optical heads - 152, 22 + 150, 22 Clear counters