diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 99 |
1 files changed, 67 insertions, 32 deletions
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 04d2fae4b..3f28c2cff 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 @@ -552,6 +552,12 @@ namespace Tango.MachineStudio.Developer.ViewModels public IAuthenticationProvider AuthenticationProvider { get; set; } + public DeveloperModuleSettings Settings + { + get { return _settings; } + set { _settings = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -742,7 +748,7 @@ namespace Tango.MachineStudio.Developer.ViewModels SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null && CanWork); DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null && CanWork); StartJobCommand = new RelayCommand(() => StartJob(), () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null); - StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null); + StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && CanWork); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning && CanWork); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); LoadJobCommand = new RelayCommand(() => LoadSelectedJob(), () => SelectedMachineJob != null && CanWork); @@ -783,7 +789,7 @@ namespace Tango.MachineStudio.Developer.ViewModels public override void OnApplicationReady() { - _settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>(); + Settings = SettingsManager.Default.GetOrCreate<DeveloperModuleSettings>(); SelectedJobs = new ObservableCollection<Job>(); JobEvents = new ObservableCollection<MachinesEvent>(); @@ -966,9 +972,23 @@ namespace Tango.MachineStudio.Developer.ViewModels private void MachineOperator_PreparingJobProgress(object sender, PreparingJobProgressEventArgs e) { - if (_preparingTaskItem != null) + var percent = (e.Progress / e.Total * 100d); + + if (_preparingTaskItem == null && percent == 0) + { + _preparingTaskItem = _notification.PushTaskItem("Preparing job for printing..."); + } + else if (percent == 100 && _preparingTaskItem != null) + { + _preparingTaskItem.Pop(); + _preparingTaskItem = null; + } + else { - _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%..."; + if (_preparingTaskItem != null) + { + _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%..."; + } } } @@ -1067,13 +1087,13 @@ namespace Tango.MachineStudio.Developer.ViewModels { _speech.SpeakError(events.Last().EventType.Name); - if (events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.StopJob))) - { - if (JobHandler != null) - { - InvokeUI(StopJob); - } - } + //if (events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.StopJob))) + //{ + // if (JobHandler != null) + // { + // InvokeUI(StopJob); + // } + //} } } @@ -1293,6 +1313,8 @@ namespace Tango.MachineStudio.Developer.ViewModels /// </summary> private async void StartJob(Func<Job, JobHandler> resumeFunc = null) { + SettingsManager.Default.Save(); + LogManager.Log(String.Format("Starting job {0}...", ActiveJob.Name)); if (MachineOperator == null || MachineOperator.State != TransportComponentState.Connected) { @@ -1325,23 +1347,22 @@ namespace Tango.MachineStudio.Developer.ViewModels IsFree = false; LogManager.Log("Sending job to machine operator..."); + MachineOperator.GradientGenerationConfiguration.IsEnabled = Settings.EnableGradientGeneration; + MachineOperator.GradientGenerationConfiguration.ResolutionCM = Settings.GradientResolutionCM; + if (resumeFunc == null) { - using (var item = _notification.PushTaskItem("Preparing job for printing...")) - { - _preparingTaskItem = item; - JobHandler = await MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); - } - - _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); - IsJobRunning = true; - ShowJobStatus = true; + JobHandler = await MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); } else { JobHandler = resumeFunc(ActiveJob); } + _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); + IsJobRunning = true; + ShowJobStatus = true; + _eventLogger.Log(String.Format("Job '{0}' started...", ActiveJob.Name)); JobHandler.StatusChanged += (x, status) => @@ -1386,7 +1407,7 @@ namespace Tango.MachineStudio.Developer.ViewModels InvokeUI(() => { - _notification.ShowError("Job failed. " + ex.Message); + _notification.ShowError("Job failed. " + ex.FlattenMessage()); StopRecordingIfInProgress(); }); }; @@ -1408,6 +1429,12 @@ namespace Tango.MachineStudio.Developer.ViewModels JobHandler.Canceled += (x, y) => { + if (_preparingTaskItem != null) + { + _preparingTaskItem.Pop(); + _preparingTaskItem = null; + } + LogManager.Log(String.Format("Job {0} has been canceled.", RunningJob.Name)); _eventLogger.Log(String.Format("Job {0} has been canceled.", RunningJob.Name)); StopRecordingIfInProgress(); @@ -1506,14 +1533,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - if (_selectedRML != ActiveJob.Rml) - { - _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); - } - else - { - _selectedRML = ActiveJob.Rml; - } + _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); if (_selectedRML.Ccts.Count == 0) { @@ -1757,6 +1777,11 @@ namespace Tango.MachineStudio.Developer.ViewModels InvalidateRelayCommands(); _disable_gamut_check = false; + + _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; + _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + + _settings.Save(); }); SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments); @@ -1994,6 +2019,11 @@ namespace Tango.MachineStudio.Developer.ViewModels SelectedSegments.ToList().ForEach(x => { + if (ActiveJob.Segments.Count == 1) + { + _notification.ShowInfo("A job must contain at least one segment."); + return; + } ActiveJob.Segments.Remove(x); x.DefferedDelete(_activeJobDbContext); }); @@ -2121,12 +2151,17 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedBrushStop != null && SelectedSegment != null) { - if (_notification.ShowQuestion("Are you sure you want to delete the selected colors?")) + if (_notification.ShowQuestion("Are you sure you want to delete the selected brush stops?")) { LogManager.Log(String.Format("Removing {0} brush stops...", SelectedBrushStops.Count)); SelectedBrushStops.ToList().ForEach(x => { + if (SelectedSegment.BrushStops.Count == 1) + { + _notification.ShowInfo("A job segment must contain at least one brush stop."); + return; + } SelectedSegment.BrushStops.Remove(x); x.DefferedDelete(_activeJobDbContext); }); @@ -2179,6 +2214,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { var cloned = stop.Clone(); cloned.StopIndex = SelectedSegment.BrushStops.Max(x => x.StopIndex) + 1; + cloned.SetLiquidVolumes(ActiveJob.Machine.Configuration, SelectedRML, SelectedProcessParametersTable); SelectedSegment.BrushStops.Add(cloned); } @@ -2412,8 +2448,7 @@ namespace Tango.MachineStudio.Developer.ViewModels public override void OnShuttingDown() { - _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + } #endregion |
