From 1f0bbc0d4e1d826396bc288edbdfb81166428732 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 16 Dec 2021 10:01:08 +0100 Subject: [PATCH] DataEntry.S620 : Serial number assignment fixed, AssignedSN = -1 when not assigned, ver. 3.1.1843 --- TBF/Properties/AssemblyInfo.cs | 4 +- .../FormForMechanicalMetersWithTracing.cs | 62 +++++++++---------- .../S640Communication/S640CommForm.cs | 7 +++ 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index bed4002fa..4084ebcc0 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.1840.0")] -[assembly: AssemblyFileVersion("3.1.1840.0")] +[assembly: AssemblyVersion("3.1.1843.0")] +[assembly: AssemblyFileVersion("3.1.1843.0")] diff --git a/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs b/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs index 5dd8c822b..654816924 100644 --- a/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs +++ b/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs @@ -87,6 +87,9 @@ namespace TBF.Rig.DataEntry.S620 static IList uniqueCodeParts; static IList palety; + int lastProducedPcsCount; + int lastAssignedSN; + static FormForMechanicalMetersWithTracing() { workflows = new List(); @@ -417,27 +420,29 @@ namespace TBF.Rig.DataEntry.S620 assignedSNs.Clear(); var order = ProcessData.OrderInfo; - var oraOrder = order as TBF.Rig.Output.DB.SensusOracle.OrderDetails; /// + var oraOrder = order as TBF.Rig.Output.DB.SensusOracle.OrderDetails; if (oraOrder != null && (ProcessData.OracleDB == null || !ProcessData.OracleDB.ReadOrderDetails(ref oraOrder))) { - return false; + return false; /// Oracle order details could not be loaded } + lastProducedPcsCount = order.CurrentPcsCount; + lastAssignedSN = order.CurrentSN; for (int i = 0; i < textBoxesCount; i++) { bool passed = waterMeters[i].PassedFromTests(); - if (passed && !string.IsNullOrEmpty(bodyNrBoxes[i].Text) && checkBoxes[i].Checked) + if (passed && !string.IsNullOrEmpty(bodyNrBoxes[i].Text) && checkBoxes[i].Checked && lastProducedPcsCount < order.PiecesCount) { - int currentSerialNr = (order.CurrentSN < order.SNFirst) + int currentSerialNr = (lastAssignedSN < order.SNFirst) ? order.SNFirst - : order.CurrentSN + 1; + : lastAssignedSN + 1; serialNrBoxes[i].Text = currentSerialNr.ToString(string.Format("D{0}", snDigits)); - order.CurrentSN = currentSerialNr; - order.CurrentPcsCount++; + lastAssignedSN = currentSerialNr; + lastProducedPcsCount++; } else { @@ -775,21 +780,27 @@ namespace TBF.Rig.DataEntry.S620 } /// Read UI data and store them to 'interface' variables - int itmp; for (int i = 0; i < textBoxesCount; i++) { bodyNrText[i] = bodyNrBoxes[i].Text; if (atTheEnd) { - assignedSerialNr[i] = int.TryParse(serialNrBoxes[i].Text, out itmp) ? itmp : 0; - completeSerialNr[i] = string.Format("{0}{1}{2}", - (prefix != null) ? prefix : string.Empty, - assignedSerialNr[i].ToString(string.Format("D{0}", Math.Max(snDigits, 1))), - (suffix != null) ? suffix : string.Empty); + int nonnegativeSN; + bool isAssigned = int.TryParse(serialNrBoxes[i].Text, out nonnegativeSN) && nonnegativeSN >= 0; + assignedSerialNr[i] = !isAssigned ? -1 : nonnegativeSN; + completeSerialNr[i] = !isAssigned ? string.Empty : string.Format("{0}{1}{2}", (prefix != null) ? prefix : string.Empty, + assignedSerialNr[i].ToString(string.Format("D{0}", Math.Max(snDigits, 1))), + (suffix != null) ? suffix : string.Empty); } disabled[i] = !checkBoxes[i].Checked; } - purchaseOrder = (preSelectedPurchaseOrder != null) ? preSelectedPurchaseOrder : orderCB.Text; + + if (atTheEnd && ProcessData.OrderInfo != null) + { + ProcessData.OrderInfo.CurrentPcsCount = lastProducedPcsCount; + ProcessData.OrderInfo.CurrentSN = lastAssignedSN; + } + //SaveProductionTracingRecords(); /// TODO @@ -797,6 +808,9 @@ namespace TBF.Rig.DataEntry.S620 Close(); } + /// + /// Not used now + /// private void SaveProductionTracingRecords() { if (atTheEnd) @@ -1521,26 +1535,6 @@ namespace TBF.Rig.DataEntry.S620 } - /// - /// Returns next free serial number within specified range or 0 if no appropriate s/n is available - /// - /// Serial number or 0 - int GetNextSerialNr() - { - for (int sn = snRangeFirst; sn <= snRangeLast; sn++) - { - if (!foundSNs.Contains(sn) && !assignedSNs.Contains(sn)) - { - /// A free serial number within specified range found - assignedSNs.Add(sn); - return sn; - } - } - - return 0; /// No free serial number found - } - - /// /// Read released-active processes from the database. /// diff --git a/TBF/Rig/TestMethods/S640Communication/S640CommForm.cs b/TBF/Rig/TestMethods/S640Communication/S640CommForm.cs index e811a3559..fea2ab387 100644 --- a/TBF/Rig/TestMethods/S640Communication/S640CommForm.cs +++ b/TBF/Rig/TestMethods/S640Communication/S640CommForm.cs @@ -963,6 +963,13 @@ namespace TBF.Rig.TestMethods.S640Communication { /// Disable the water meter to prevent sealing wm.Disabled = true; + wm.AssignedSerialNr = -1; + wm.Prefix = order.SNPrefix; + wm.Suffix = order.SNSuffix; + wm.CompleteSerialNr = string.Empty; + + assignedSNs[i].Text = wm.CompleteSerialNr; + assignedRadioAddresses[i].Text = wm.RadioAddress; } else {