From e89f04cbdda4e34baef11d43c9f812773911a33c Mon Sep 17 00:00:00 2001 From: Roy Date: Mon, 26 Dec 2022 21:33:29 +0200 Subject: Implemented Waste Replace Handling. Implemented Job Stop on Out Of Range on MachineOperator. Implemented job upload error on Volumes out of range. --- .../Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs | 14 ++++- .../Tango.PPC.UI/Dialogs/WasteReplacementView.xaml | 37 +++++++++++ .../Dialogs/WasteReplacementView.xaml.cs | 28 +++++++++ .../Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs | 69 +++++++++++++++++++++ .../PPC/Tango.PPC.UI/Images/waste_replace.png | Bin 0 -> 6701 bytes .../Printing/DefaultPrintingManager.cs | 2 +- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 11 +++- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 19 ++++++ .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- 9 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/waste_replace.png (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs index 38413b24c..6a1c830b5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs @@ -928,6 +928,8 @@ namespace Tango.PPC.Jobs.ViewModels rmlGuid = Settings.DefaultRmlGuid; } + var machine = await new MachineBuilder(db).SetFirst().WithConfiguration().BuildAsync(); + Job job = new Job(); job.LastUpdated = DateTime.UtcNow; job.JobSource = JobSource.Local; @@ -954,8 +956,11 @@ namespace Tango.PPC.Jobs.ViewModels IColorConverter converter = new DefaultColorConverter(); + int segmentIndex = 0; + foreach (var stop in segments.SelectMany(x => x.BrushStops).Where(x => x.BrushColorSpace != ColorSpaces.RGB)) { + segmentIndex++; var output = converter.Convert(stop, false); var suggestion = output.CreateSingleSuggestion(); stop.Red = suggestion.Color.R; @@ -964,13 +969,20 @@ namespace Tango.PPC.Jobs.ViewModels stop.BestMatchR = suggestion.Color.R; stop.BestMatchG = suggestion.Color.G; stop.BestMatchB = suggestion.Color.B; + + stop.SetLiquidVolumes(machine.Configuration, job.Rml, job.Rml.GetActiveProcessGroup().ProcessParametersTables[suggestion.ProcessParametersTableIndex]); + + if (stop.IsLiquidVolumesOutOfRange) + { + throw new InvalidOperationException($"Volumes out of range for thread '{job.Rml.FinalName}' at segment {segmentIndex}."); + } } db.Jobs.Add(job); await db.SaveChangesAsync(); } - LoadJobs(() => + LoadJobs(() => { NotificationProvider.PushNotification(new MessageNotificationItem($"Csv job '{e.Name}' received successfully.", "", MessageNotificationItem.MessageNotificationItemTypes.Success, () => { }, NotificationItem.NotificationPriority.Low)); e.Confirm(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml new file mode 100644 index 000000000..6279ce81c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml @@ -0,0 +1,37 @@ + + + + + LATER + DONE + + + + Replace Waste Cartridge + + The waste cartridge is close to full and needs to be replaced. + + Please open the cartridge door, insert two empty cartridges then close the door. + + + When finish press "DONE". + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml.cs new file mode 100644 index 000000000..5bddf160b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Dialogs +{ + /// + /// Interaction logic for SpoolReplaceView.xaml + /// + public partial class WasteReplacementView : UserControl + { + public WasteReplacementView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs new file mode 100644 index 000000000..0e2f4bb56 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.DI; +using Tango.PMR.Diagnostics; +using Tango.PPC.Common.Connection; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class WasteReplacementViewVM : DialogViewVM + { + private bool _doorClosed; + private bool _doorOpened; + + [TangoInject] + private IMachineProvider MachineProvider { get; set; } + + public WasteReplacementViewVM() + { + TangoIOC.Default.Inject(this); + MachineProvider.MachineOperator.EventsNotification += MachineOperator_EventsNotification; + } + + private void MachineOperator_EventsNotification(object sender, StartEventsNotificationResponse e) + { + if (!_doorOpened) + { + if (e.Events.Select(x => x.Type).Contains(PMR.Diagnostics.EventType.CartridgesCoverOpen)) + { + _doorOpened = true; + } + } + else + { + if (!e.Events.Select(x => x.Type).Contains(PMR.Diagnostics.EventType.CartridgesCoverOpen)) + { + _doorClosed = true; + InvalidateRelayCommands(); + } + } + } + + protected override void Accept() + { + DisposeEvents(); + base.Accept(); + } + + protected override void Cancel() + { + DisposeEvents(); + base.Cancel(); + } + + protected override bool CanOK() + { + return base.CanOK() && _doorClosed && _doorOpened; + } + + private void DisposeEvents() + { + MachineProvider.MachineOperator.EventsNotification -= MachineOperator_EventsNotification; + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/waste_replace.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/waste_replace.png new file mode 100644 index 000000000..f39a6f94d Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/waste_replace.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index 83f4d4f29..d920b32a4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -340,7 +340,7 @@ namespace Tango.PPC.UI.Printing } if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.IsLiquidVolumesOutOfRange)) { - throw new InvalidOperationException("Error starting job. Total ink volume is out of range."); + throw new InvalidOperationException($"The specified ink volumes at segment {job.Segments.SelectMany(x => x.BrushStops).First(x => x.IsLiquidVolumesOutOfRange).Segment.SegmentIndex} exceeds the maximum allowed total volume for the current thread."); } if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.BrushColorSpace == ColorSpaces.Catalog && x.ColorCatalogsItem == null && !x.IsTransparent && !x.IsWhite)) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 26ab3293a..464de7da9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -152,6 +152,10 @@ SafetyLevelOperationsConfirmationView.xaml + + + WasteReplacementView.xaml + SpoolReplaceView.xaml @@ -292,6 +296,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -499,6 +507,7 @@ rc.exe PreserveNewest + @@ -827,7 +836,7 @@ if $(ConfigurationName) == Debug "rc.exe" "$(TargetPath)" --set-version-string " - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index e35ed3591..50f4ed054 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -100,10 +100,29 @@ namespace Tango.PPC.UI.ViewModels MachineProvider.MachineConnected += MachineProvider_MachineConnected; + MachineProvider.MachineOperator.WasteReplacementRequired += MachineOperator_WasteReplacementRequired; + _screenSaverTimer.Elapsed += _screenSaverTimer_Elapsed; _screenSaverTimer.Start(); } + #region Waste Replacement + + private void MachineOperator_WasteReplacementRequired(object sender, EventArgs e) + { + InvokeUI(async () => + { + var vm = await NotificationProvider.ShowDialog(); + + if (MachineProvider.IsConnected) + { + await MachineProvider.MachineOperator.CompleteWasteReplacement(vm.DialogResult); + } + }); + } + + #endregion + #region Power Up private void MachineOperator_PowerUpEnded(object sender, EventArgs e) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + -- cgit v1.3.1