diff --git a/Common/CommonCore.Configuration/ServiceUrlsBackUp_New.cs b/Common/CommonCore.Configuration/ServiceUrlsBackUp_New.cs index e1d10030..8f168416 100644 --- a/Common/CommonCore.Configuration/ServiceUrlsBackUp_New.cs +++ b/Common/CommonCore.Configuration/ServiceUrlsBackUp_New.cs @@ -130,6 +130,9 @@ namespace Xylem.Common.CommonCore.Configuration private static readonly String DefaultGenesisGetKeySetIdServiceUrl = $"{ServerDns}/MeterProcessState/api/Password/getkeysetid?PcbId="; + private static readonly String DefaultGenesisSetPickingStateServiceUrl = + $"{ServerDns}/MeterProcessState/api/ProccesState/SetPickingState?PcbID="; + private static readonly String DefaultGenesisGetPasswordServiceUrl = $"{ServerDns}/MeterProcessState/api/Password/GetPassword?PcbId="; @@ -725,6 +728,16 @@ namespace Xylem.Common.CommonCore.Configuration DefaultGenesisGetKeySetIdServiceUrl; } + /// + /// Genesis get password url + /// + /// + public static String GenesisSetPickingStateServiceUrl() + { + return ConfigurationManager.AppSettings["GenesisSetPickingStateServiceUrl"] ?? + DefaultGenesisSetPickingStateServiceUrl; + } + /// /// Genesis get password url /// diff --git a/Common/Logic/ProductionOrderCore/OrderData/OrderDetailsDb.cs b/Common/Logic/ProductionOrderCore/OrderData/OrderDetailsDb.cs index deea2085..943d6648 100644 --- a/Common/Logic/ProductionOrderCore/OrderData/OrderDetailsDb.cs +++ b/Common/Logic/ProductionOrderCore/OrderData/OrderDetailsDb.cs @@ -19,6 +19,39 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData private const Int32 moderateTimeoutDbRequest = 10000; private const Int32 hugeTimeoutDbRequest = 30000; + /// + /// Set the picking state: + /// - reserved = null, + /// - successfully finished = 1, + /// - failed = 0. + /// + /// + /// + /// null, 1, 0 + /// true if successful + /// + /// - Initial. + /// + public static Boolean SetCordonelPickingStateToDb(String pcbId, Int64 orderNumber, Int32? state = null) + { + try + { + var strState = state == null ? "null" : $"{state}"; + var url = ServiceUrls.GenesisSetPickingStateServiceUrl(); + url += $@"{pcbId}&FertigungsauftragsNr={orderNumber}&successful={strState}"; + var retString = LocalWebRequest.PostRequestAsyncAndGetContent(url, moderateTimeoutDbRequest); + if (bool.TryParse(retString, out var result)) + { + return result; + } + return false; + } + catch (Exception) + { + return false; + } + } + /// /// Get all Cordonel serial numbers of a specific order. /// diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/CheckCordonelMapping.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/CheckCordonelMapping.cs index 3ced31ef..8c9deeb2 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/CheckCordonelMapping.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/CheckCordonelMapping.cs @@ -1,5 +1,6 @@ using System; using Xylem.Common.CommonCore.Consts; +using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts; using Xylem.Common.Logic.ProductionOrderCore.OrderData; using Resources = Xylem.Common.Production.ProductionUiCordonel.Properties.Resources; @@ -38,23 +39,25 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Picki return StatusReturn.Failed; } - SignalRunningState(); + SignalRunningState(5); + Meter.ReLogin(); + Meter.SetProcessState(DisplayCodes.PickingStarted); + Meter.Logout(); // Check mapping information if (!OrderDetailsDb.GetCordonelMapping(Meter.PcbId, out var cordonelMapping) || cordonelMapping == null || cordonelMapping.Count == 0) { - ErrorMsgDispatcher(Resources.StrErrorMsgMissingMappingInformation); - return StatusReturn.Failed; + return ErrorExit(Resources.StrErrorMsgMissingMappingInformation); } + ActualProcessProgress++; // Check if this meter is mapped to a different order if (cordonelMapping[0].CordonelAssignedPicking_FertigungsAuftragsNr != null && cordonelMapping[0].CordonelAssignedPicking_FertigungsAuftragsNr != Meter.OrderNumber) { - ErrorMsgDispatcher(Resources.StrErrorMsgMeterForOtherOrderAssigned + - $": {cordonelMapping[0].CordonelAssignedPicking_FertigungsAuftragsNr}"); - return StatusReturn.Failed; + return ErrorExit(Resources.StrErrorMsgMeterForOtherOrderAssigned + + $": {cordonelMapping[0].CordonelAssignedPicking_FertigungsAuftragsNr}"); } // Check if meter is already married to a serial number on a previous run @@ -66,13 +69,22 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Picki // Reserve picking for this device to lock other assembly line software to assign another Cordonel to // this order. + //TODO THW deactivated until WebAPI is implemented + //if (!OrderDetailsDb.SetCordonelPickingStateToDb(Meter.PcbId, Meter.OrderNumber)) + //{ + // return ErrorExit(Resources.StrErrorMsgPickingReservationFailed); + //} + ActualProcessProgress++; + + //TODO THW Read reservation status with GetOrderOverview to update the display + ActualProcessProgress++; // Get detailed order information to set e.g. the correct meter size needed for LUT installation if (!OrderDetailsDb.GetOrderDetails(Meter.OrderNumber, Meter.PcbId, out var orderDetails)) { - ErrorMsgDispatcher(Resources.StrErrorMsgMissingOrderInformation); - return StatusReturn.Failed; + return ErrorExit(Resources.StrErrorMsgMissingOrderInformation); } + ActualProcessProgress++; // Meter has to be connected in advance being able to overwrite the meter size. The meterSize will be // read out from Cordonel at Connect. This may be reassigned dependent on the orderDetails.MeterSize. @@ -82,15 +94,13 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Picki Meter.EnablePropertyChangeAbility(true); if (!Meter.SetMeterSize((MeterSize)orderDetails.MeterSize)) { - ErrorMsgDispatcher(Resources.StrErrorMsgChangingMeterSizeFromOrderFailed); - return StatusReturn.Failed; + return ErrorExit(Resources.StrErrorMsgChangingMeterSizeFromOrderFailed); } SuccessMsgDispatcher(Resources.StrSuccessMsgChangedMeterSizeFromOrder + $": {Meter.MeterSize}"); if (!Meter.SetPressureSensorAssembled(orderDetails.PressurePresent)) { - ErrorMsgDispatcher(Resources.StrErrorMsgPressureSensorSetupFromOrderFailed); - return StatusReturn.Failed; + return ErrorExit(Resources.StrErrorMsgPressureSensorSetupFromOrderFailed); } var pressurePresent = Meter.PressureSensorAssembled ? Resources.StrMsgPressureSensorApplied @@ -100,5 +110,19 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Picki return StatusReturn.Okay; } + + /// + /// Common error exit method. + /// + /// + /// + private StatusReturn ErrorExit(String errorMsg) + { + Meter.ReLogin(); + Meter.SetProcessState(DisplayCodes.PickingFailed); + Meter.Logout(); + ErrorMsgDispatcher(errorMsg); + return StatusReturn.Failed; + } } } diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/PrepareAssemblyRelease.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/PrepareAssemblyRelease.cs index 79c3ac73..453f0489 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/PrepareAssemblyRelease.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/PickingProcesses/PrepareAssemblyRelease.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using Xylem.Common.CommonCore.Consts; +using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts; +using Xylem.Common.Logic.ProductionOrderCore.OrderData; using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum; using Xylem.Common.Production.ProductionUiCordonel.Properties; using Xylem.Common.Production.ProductionUiCordonel.UserControls; @@ -47,25 +49,37 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Picki /// /// - Initial. /// + /// + /// - Final result message, display and push to database. + /// public override StatusReturn ExecuteProcess() { try { - _waitOnUserFeedback = true; SignalRunningState(MaxActualProgressSteps); - var ucDialog = (UcDialog)UserControl; - // Push progress will publish all application versions and the core version - var retVal = Meter.PushProgress("Assembly", Version.ToString()); - if (retVal == StatusReturn.Failed) - { - return retVal; - } + // Set picking for this device as finished successfully. + //TODO THW deactivated until WebAPI is implemented + //if (StatusReturn.Failed == Meter.PushProgress("Assembly", Version.ToString()) || + // !OrderDetailsDb.SetCordonelPickingStateToDb(Meter.PcbId, Meter.OrderNumber, 1)) + //{ + // OrderDetailsDb.SetCordonelPickingStateToDb(Meter.PcbId, Meter.OrderNumber, 0); + // Meter.Login(); + // Meter.SetProcessState(DisplayCodes.PickingFailed); + // Meter.Logout(); + // ErrorMsgDispatcher(Resources.StrErrorMsgPickingFinalizationFailed); + // return StatusReturn.Failed; + //} ActualProcessProgress++; - + Meter.ReLogin(); + Meter.SetProcessState(DisplayCodes.PickingTested); + Meter.Logout(); + // Initialize the ucDialog + _waitOnUserFeedback = true; + var ucDialog = (UcDialog)UserControl; ucDialog.SetHeadline(Resources.StrStateAssemblyLineRelease); ucDialog.SetMessage(Resources.StrInfoMeterBoxing); var OptionList = new List(); diff --git a/Common/Production/ProductionUiCordonel/Properties/Resources.Designer.cs b/Common/Production/ProductionUiCordonel/Properties/Resources.Designer.cs index fbb7ccf2..42ea54cb 100644 --- a/Common/Production/ProductionUiCordonel/Properties/Resources.Designer.cs +++ b/Common/Production/ProductionUiCordonel/Properties/Resources.Designer.cs @@ -708,6 +708,24 @@ namespace Xylem.Common.Production.ProductionUiCordonel.Properties { } } + /// + /// Looks up a localized string similar to ERROR: Assembly ready reporting for this Cordonel failed. + /// + internal static string StrErrorMsgPickingFinalizationFailed { + get { + return ResourceManager.GetString("StrErrorMsgPickingFinalizationFailed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to ERROR: Order reservation failed for this Cordonel. + /// + internal static string StrErrorMsgPickingReservationFailed { + get { + return ResourceManager.GetString("StrErrorMsgPickingReservationFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to ERROR: Pre- and flow-test status unknown. /// diff --git a/Common/Production/ProductionUiCordonel/Properties/Resources.de.resx b/Common/Production/ProductionUiCordonel/Properties/Resources.de.resx index 257e0b22..65982e8f 100644 --- a/Common/Production/ProductionUiCordonel/Properties/Resources.de.resx +++ b/Common/Production/ProductionUiCordonel/Properties/Resources.de.resx @@ -492,6 +492,12 @@ FEHLER: Dieser Cordonel ist einem anderen Fertigungsauftrag zugeordnet + + + FEHLER: Auftragsreservierung für diesen Cordonel fehlgeschlagen + + + FEHLER: Montageabschlußmeldung für diesen Cordonel fehlgeschlagen FEHLER: Dieser Cordonel kann keinem Auftrag zugeordnet werden diff --git a/Common/Production/ProductionUiCordonel/Properties/Resources.resx b/Common/Production/ProductionUiCordonel/Properties/Resources.resx index 16b1cf66..a5bd96f2 100644 --- a/Common/Production/ProductionUiCordonel/Properties/Resources.resx +++ b/Common/Production/ProductionUiCordonel/Properties/Resources.resx @@ -492,6 +492,12 @@ ERROR: This Cordonel is assigned to another production order + + + ERROR: Order reservation failed for this Cordonel + + + ERROR: Assembly ready reporting for this Cordonel failed ERROR: This Cordonel cannot be mapped to an order