From f185c2ba392d7a05079ca1c3e27521bac053a103 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 1 Mar 2018 13:10:23 +0200 Subject: Upload Hardware Configuration & Process Parameters. --- .../ViewModels/MainViewVM.cs | 88 +++++++++++++++------- 1 file changed, 59 insertions(+), 29 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs') 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 99d275744..8314238fd 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 @@ -562,6 +562,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand DuplicateBrushStopCommand { get; set; } + /// + /// Gets or sets the push process parameters command. + /// + public RelayCommand PushProcessParametersCommand { get; set; } + #endregion #region Constructors @@ -613,7 +618,6 @@ namespace Tango.MachineStudio.Developer.ViewModels EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null); EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null); ToggleSideBarCommand = new RelayCommand(() => IsSideBarOpened = !IsSideBarOpened); - SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0); SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors, () => SelectedRML != null); AddSegmentCommand = new RelayCommand(AddSegment, () => ActiveJob != null); RemoveSegmentCommand = new RelayCommand(RemoveSelectedSegments, () => SelectedSegment != null); @@ -623,13 +627,15 @@ namespace Tango.MachineStudio.Developer.ViewModels RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null); SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null); DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null); - StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning); + StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning && MachineOperator != null); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null); DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null); DuplicateSegmentCommand = new RelayCommand(DuplicateSelectedSegments, () => SelectedSegment != null); DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null); + SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0); + PushProcessParametersCommand = new RelayCommand(PushProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0 && SelectedProcessParametersTable != null && MachineOperator != null); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; } @@ -1047,6 +1053,57 @@ namespace Tango.MachineStudio.Developer.ViewModels ApplicationManager.RequestModule("Data Base", SelectedRML); } + /// + /// Invalidates the liquid factors and process parameters tables. + /// + private void InvalidateLiquidFactorsAndProcessTables() + { + if (SelectedRML != null && SelectedMachine != null) + { + LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); + LiquidTypesRmls = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); + RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); + + var selectedHistory = RmlProcessParametersTableGroup; + + if (RmlProcessParametersTableGroup != null) + { + RmlProcessParametersTableGroup = RmlProcessParametersTableGroup.CloneGroup(); + RmlProcessParametersTableGroup.ProcessParametersTables = RmlProcessParametersTableGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).ToObservableCollection(); + } + + GroupsHistory = SelectedRML.ProcessParametersTablesGroups.OrderByDescending(x => x.SaveDate).OrderBy(x => !x.Active).ToObservableCollection(); + + _selectedGroupHistory = selectedHistory; + + RaisePropertyChangedAuto(nameof(SelectedGroupHistory)); + } + } + + #endregion + + #region Process Parameters Management + + /// + /// Uploads the selected process parameters table. + /// + private async void PushProcessParameters() + { + using (_notification.PushTaskItem("Uploading Process Parameters...")) + { + try + { + LogManager.Log(String.Format("Uploading process parameters table {0}...", SelectedProcessParametersTable.Name)); + await MachineOperator.UploadProcessParameters(SelectedProcessParametersTable); + } + catch (Exception ex) + { + LogManager.LogFormat(ex, "Failed to upload process parameters table {0}", SelectedProcessParametersTable.Name); + _notification.ShowError("Failed to upload the selected process parameters." + Environment.NewLine + ex.Message); + } + } + } + /// /// Saves the process parameters group. /// @@ -1087,33 +1144,6 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - /// - /// Invalidates the liquid factors and process parameters tables. - /// - private void InvalidateLiquidFactorsAndProcessTables() - { - if (SelectedRML != null && SelectedMachine != null) - { - LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - LiquidTypesRmls = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); - RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); - - var selectedHistory = RmlProcessParametersTableGroup; - - if (RmlProcessParametersTableGroup != null) - { - RmlProcessParametersTableGroup = RmlProcessParametersTableGroup.CloneGroup(); - RmlProcessParametersTableGroup.ProcessParametersTables = RmlProcessParametersTableGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).ToObservableCollection(); - } - - GroupsHistory = SelectedRML.ProcessParametersTablesGroups.OrderByDescending(x => x.SaveDate).OrderBy(x => !x.Active).ToObservableCollection(); - - _selectedGroupHistory = selectedHistory; - - RaisePropertyChangedAuto(nameof(SelectedGroupHistory)); - } - } - #endregion #region Active Job Management -- cgit v1.3.1