From f27893986e9fd647a69be8569ecd5d944f853869 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 18 Apr 2019 20:48:48 +0300 Subject: Implemented machine status animations. --- .../Tango.Integration/Operation/MachineOperator.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs') diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index b25afd67d..2672b2d0f 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1356,7 +1356,7 @@ namespace Tango.Integration.Operation ThreadFactory.StartNew(async () => { - Status = MachineStatuses.Printing; + Status = MachineStatuses.GettingReady; RunningJob = originalJob; PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); @@ -1411,6 +1411,22 @@ namespace Tango.Integration.Operation responseLogged = true; LogResponseReceived(response.Message); } + + if (JobHandlingMode == JobHandlerModes.SettingUp) + { + if (response.Message.Status.Progress > request.JobTicket.ProcessParameters.DryerBufferLength) + { + Status = MachineStatuses.Printing; + } + } + else + { + if (response.Message.Status.Progress > 0) + { + Status = MachineStatuses.Printing; + } + } + }, (ex) => { if (!(ex is ContinuousResponseAbortedException)) -- cgit v1.3.1 From 09eabd45ecf65d6f900b9d53428e7576bdc4d825 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 18 Apr 2019 22:19:59 +0300 Subject: Implemented resume job on PPC. Fixed resume job on emulator. Fixed an issue with PPC event logger. Added getting ready status to machine operator. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Build/Shortcuts/Machine Emulator.lnk | Bin 1445 -> 1530 bytes .../Tango.PPC.Jobs/ViewModels/MainViewVM.cs | 34 +++++++++++++++++++++ .../EventLogging/DefaultEventLogger.cs | 25 ++++++++++++++- .../Tango.Emulations/Emulators/MachineEmulator.cs | 4 +-- .../Tango.Integration/Operation/MachineOperator.cs | 19 ++++++++++-- 7 files changed, 77 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 84eb6afc9..724b8c150 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index f3b9858f1..a2be2cb15 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk index 7417e4f31..697cc906e 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs index 7026a6ebc..d72f4544a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Builders; using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.Integration.Operation; @@ -28,6 +30,38 @@ namespace Tango.PPC.Jobs.ViewModels { MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed; + MachineProvider.MachineOperator.ResumingJob += MachineOperator_ResumingJob; + } + + private async void MachineOperator_ResumingJob(object sender, ResumingJobEventArgs e) + { + LogManager.Log($"Trying to resume job '{e.JobGuid}'..."); + + try + { + var job = await new JobBuilder(ObservablesContext.CreateDefault()).Set(e.JobGuid) + .WithConfiguration() + .WithRML() + .WithUser() + .WithSegments() + .WithBrushStops() + .BuildAsync(); + + e.Approve(job); + + InvokeUI(() => + { + NavigationManager.NavigateTo(nameof(JobProgressView)); + }); + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to resume the job."); + InvokeUI(() => + { + NotificationProvider.ShowError("An error occurred while trying to resume a job in progress."); + }); + } } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs index d540e3fd3..25eb2df04 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -79,6 +79,7 @@ namespace Tango.PPC.Common.EventLogging _machineProvider.MachineOperator.RequestSent += Machine_RequestSent; _machineProvider.MachineOperator.RequestFailed += Machine_RequestFailed; _machineProvider.MachineOperator.ResponseReceived += Machine_ResponseReceived; + _machineProvider.MachineOperator.StateChanged += MachineOperator_StateChanged; } #endregion @@ -113,6 +114,20 @@ namespace Tango.PPC.Common.EventLogging #region Event Handlers + /// + /// Handles the machine operator state changed event. + /// + /// The sender. + /// The e. + private void MachineOperator_StateChanged(object sender, Transport.TransportComponentState e) + { + if (e == Transport.TransportComponentState.Connected) + { + _events = new ConcurrentQueue(); + _currentEvents.Clear(); + } + } + /// /// Handles the RequestSent event of the connected machine. /// @@ -212,7 +227,15 @@ namespace Tango.PPC.Common.EventLogging machineEvent.UserGuid = _authentication.CurrentUser.Guid; machineEvent.User = _authentication.CurrentUser; _events.Enqueue(machineEvent); - _currentEvents.Add(machineEvent); + + if (!_currentEvents.Exists(x => x.Type == machineEvent.Type)) + { + if (machineEvent.Group != EventTypeGroups.Application && machineEvent.Group != EventTypeGroups.Transport) + { + _currentEvents.Add(machineEvent); + } + } + EventReceived?.Invoke(this, machineEvent); } } diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index f1d9487ff..8b83f1f73 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -606,7 +606,7 @@ namespace Tango.Emulations.Emulators Transporter.SendResponse(new ResumeCurrentJobResponse() { - }, request.Container.Token, false, ErrorCode.ContinuousResponseAborted); + }, _current_job_resume_token, false, ErrorCode.ContinuousResponseAborted); } } else @@ -631,7 +631,7 @@ namespace Tango.Emulations.Emulators Progress = job.Length + job.ProcessParameters.DryerBufferLength, } - }, request.Container.Token, !_cancelJob); + }, _current_job_resume_token, !_cancelJob); } } }); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 2672b2d0f..dd0872898 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -226,7 +226,7 @@ namespace Tango.Integration.Operation { get { - return Status == MachineStatuses.Printing; + return Status == MachineStatuses.Printing || Status == MachineStatuses.GettingReady; } } @@ -862,12 +862,27 @@ namespace Tango.Integration.Operation if (!responseLogged) { + Status = MachineStatuses.GettingReady; responseLogged = true; - Status = MachineStatuses.Printing; RunningJob = originalJob; PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); LogResponseReceived(response.Message); } + + if (JobHandlingMode == JobHandlerModes.SettingUp) + { + if (response.Message.Status.Progress > jobTicket.ProcessParameters.DryerBufferLength) + { + Status = MachineStatuses.Printing; + } + } + else + { + if (response.Message.Status.Progress > 0) + { + Status = MachineStatuses.Printing; + } + } }, (ex) => { if (!(ex is ContinuousResponseAbortedException)) -- cgit v1.3.1