From 1e24679bf65e42e5df96113bd1eef371036f0940 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 24 Oct 2018 16:18:39 +0300 Subject: Implemented job resume!! --- .../ViewModels/MainViewVM.cs | 51 +++++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 07686165b..efdb8982d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -45,6 +45,7 @@ using Tango.AutoComplete.Editors; using System.Data.Entity; using System.Runtime.ExceptionServices; using Tango.BL.Builders; +using Tango.MachineStudio.Common.Navigation; namespace Tango.MachineStudio.Developer.ViewModels { @@ -63,6 +64,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private TimeSpan _runningJobEstimatedDuration; private JobHandler _jobHandler; private DeveloperNavigationManager _navigation; + private INavigationManager _msNavigation; private bool _blockInvalidateCommands; private IAuthenticationProvider _authentication; private ObservablesContext _machineDbContext; @@ -685,7 +687,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// The application manager. /// The notification provider. - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, INavigationManager navigationManager, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech) { CanWork = true; EnableColorConversion = true; @@ -695,6 +697,7 @@ namespace Tango.MachineStudio.Developer.ViewModels _notification = notificationProvider; _speech = speech; _navigation = navigation; + _msNavigation = navigationManager; ApplicationManager = applicationManager; VideoCaptureProvider = videoCaptureProvider; _eventLogger = eventLogger; @@ -720,11 +723,11 @@ namespace Tango.MachineStudio.Developer.ViewModels RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null && CanWork); SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null && CanWork); DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null && CanWork); - StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); + StartJobCommand = new RelayCommand(() => StartJob(), () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution))); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning && CanWork); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); - LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null && CanWork); + LoadJobCommand = new RelayCommand(() => LoadSelectedJob(), () => SelectedMachineJob != null && CanWork); DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null && CanWork); DuplicateSegmentCommand = new RelayCommand(DuplicateSelectedSegments, () => SelectedSegment != null && CanWork); DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null && CanWork); @@ -912,6 +915,33 @@ namespace Tango.MachineStudio.Developer.ViewModels MachineOperator.MachineEventsStateProvider.NewEvents -= MachineEventsStateProvider_NewEvents; MachineOperator.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents; + + MachineOperator.ResumingJob -= MachineOperator_ResumingJob; + MachineOperator.ResumingJob += MachineOperator_ResumingJob; + } + } + + private void MachineOperator_ResumingJob(object sender, ResumingJobEventArgs e) + { + if (_notification.ShowQuestion("Machine studio has detected a job in progress. Would you like to try and continue from there you were?")) + { + var job = _machineDbContext.Jobs.SingleOrDefault(x => x.Guid == e.JobGuid); + + if (job != null) + { + _msNavigation.NavigateToModule(); + SelectedMachine = _machineDbContext.Machines.SingleOrDefault(x => x.Guid == job.MachineGuid); + SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == job.Guid); + LoadSelectedJob(() => + { + StartJob(e.Approve); + }); + } + else + { + LogManager.Log($"Could not resume job. The running job with guid '{e.JobGuid}' was not found."); + _notification.ShowError("Could not resume job. The running job was not found."); + } } } @@ -1205,7 +1235,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Starts the job. /// - private void StartJob() + private void StartJob(Func resumeFunc = null) { LogManager.Log(String.Format("Starting job {0}...", ActiveJob.Name)); if (MachineOperator == null || MachineOperator.State != TransportComponentState.Connected) @@ -1242,7 +1272,14 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log("Sending job to machine operator..."); - _jobHandler = MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); + if (resumeFunc == null) + { + _jobHandler = MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); + } + else + { + _jobHandler = resumeFunc(ActiveJob); + } _eventLogger.Log(String.Format("Job '{0}' started...", ActiveJob.Name)); @@ -1573,7 +1610,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Loads the selected job. /// - private async void LoadSelectedJob() + private async void LoadSelectedJob(Action onCompleted = null) { if (SelectedMachineJob != null) { @@ -1662,6 +1699,8 @@ namespace Tango.MachineStudio.Developer.ViewModels } CanWork = true; + + onCompleted?.Invoke(); } } -- cgit v1.3.1 From 750df33d864df271c96939d3c12ee246f0e743c1 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 24 Oct 2018 17:07:50 +0300 Subject: Fixed issue with rml selection (no color conversion message..) and brush stops liquid volume not invalidating. --- .../Build/Shortcuts/Machine Emulator.lnk | Bin 1455 -> 1471 bytes .../Visual_Studio/Build/Shortcuts/Machine Studio.lnk | Bin 1516 -> 1532 bytes .../Build/Shortcuts/Proto Compiler GUI.lnk | Bin 1448 -> 1464 bytes .../ViewModels/MainViewVM.cs | 6 +++++- .../ViewModels/MainViewVM.cs | 12 ++++++++---- .../Tango.MachineStudio.Developer/Views/JobView.xaml | 11 ++--------- .../Tango.MachineStudio.UI/Properties/AssemblyInfo.cs | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk index 0b55f9468..e0ba28f69 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/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 96378d6e7..22c21c62c 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk index 8996e8019..2ebd7be68 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk and b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs index 58b264d41..f3e153134 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs @@ -370,7 +370,11 @@ namespace Tango.MachineStudio.ColorLab.ViewModels catch (Exception ex) { LogManager.Log(ex, "Error in color conversion."); - _notification.ShowError($"An error occurred while trying to convert from source color to Volume.\n" + ex.Message); + + InvokeUI(() => + { + _notification.ShowError($"An error occurred while trying to convert from source color to Volume.\n" + ex.Message); + }); } }); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index efdb8982d..f55ece6a1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1040,7 +1040,11 @@ namespace Tango.MachineStudio.Developer.ViewModels SelectedProcessParametersTable.DyeingSpeedMinInkUptakeChanged -= SelectedProcessParametersTable_DyeingSpeedMinInkUptakeChanged; SelectedProcessParametersTable.DyeingSpeedMinInkUptakeChanged += SelectedProcessParametersTable_DyeingSpeedMinInkUptakeChanged; - SetSegmentBrushStopsLiquidVolumes(SelectedSegment); + foreach (var segment in ActiveJob.Segments) + { + SetSegmentBrushStopsLiquidVolumes(segment); + } + UpdateEstimatedDuration(); } } @@ -1414,9 +1418,9 @@ namespace Tango.MachineStudio.Developer.ViewModels await SelectedRML.SaveAsync(_activeJobDbContext); LiquidTypesRmls = ActiveJob.Machine.Configuration.NoneEmptyIdsPacks.Where(x => !x.IsEmpty).OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); - if (SelectedSegment != null) + foreach (var segment in ActiveJob.Segments) { - SetSegmentBrushStopsLiquidVolumes(SelectedSegment); + SetSegmentBrushStopsLiquidVolumes(segment); } } @@ -1443,7 +1447,7 @@ namespace Tango.MachineStudio.Developer.ViewModels _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().WithMediaProperties().Build(); - if (_selectedRML.Cats.Count == 0) + if (_selectedRML.Ccts.Count == 0) { InvokeUI(() => { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 1c0bc515b..884f60875 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -353,15 +353,8 @@ - - - - - - - - - + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index 43c1d155c..8078e7241 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("3.5.54.18238")] +[assembly: AssemblyVersion("3.5.55.18238")] [assembly: ComVisible(false)] \ No newline at end of file -- cgit v1.3.1