From 0c7904ace0b17162b4b1c47ab157d085e73e0e15 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 18 Feb 2018 12:45:43 +0200 Subject: More work on new developer module.. --- .../Navigation/DeveloperNavigationView.cs | 3 +- .../Tango.MachineStudio.Developer.csproj | 14 + .../ViewModels/MainViewVM.cs | 90 +++-- .../Views/DeveloperView.xaml | 411 ++++++++++++++++++- .../Views/JobView.xaml | 440 +++------------------ .../Views/RunningJobView.xaml | 45 +++ .../Views/RunningJobView.xaml.cs | 28 ++ .../Tango.MachineStudio.Developer/app.config | 10 + .../Tango.MachineStudio.Developer/packages.config | 1 + 9 files changed, 620 insertions(+), 422 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationView.cs index 90548d1b4..6d1c6669e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationView.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationView.cs @@ -9,6 +9,7 @@ namespace Tango.MachineStudio.Developer.Navigation public enum DeveloperNavigationView { MachineJobSelectionView, - JobView + JobView, + RunningJobView } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 1291fb0cd..086d6cd91 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -31,6 +31,12 @@ 4 + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll @@ -56,6 +62,7 @@ ..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + ..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll @@ -132,6 +139,9 @@ GlobalVersionInfo.cs + + RunningJobView.xaml + Designer MSBuild:Compile @@ -156,6 +166,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + 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 267f0bb0c..2e5d42296 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 @@ -48,6 +48,8 @@ namespace Tango.MachineStudio.Developer.ViewModels private int _fullScreenGraphIndex; private JobHandler _jobHandler; private DeveloperNavigationManager _navigation; + private ObservablesContext _dbJobContext; + private Job _jobFromList; #region Properties @@ -399,9 +401,14 @@ namespace Tango.MachineStudio.Developer.ViewModels public RelayCommand RemoveBrushStopCommand { get; set; } /// - /// Gets or sets the save jobs command. + /// Gets or sets the save job command. /// - public RelayCommand SaveJobsCommand { get; set; } + public RelayCommand SaveJobCommand { get; set; } + + /// + /// Gets or sets the discard job command. + /// + public RelayCommand DiscardJobCommand { get; set; } /// /// Gets or sets the start job command. @@ -478,7 +485,8 @@ namespace Tango.MachineStudio.Developer.ViewModels RemoveJobCommand = new RelayCommand(RemoveJob, () => SelectedJob != null); AddBrushStopCommand = new RelayCommand(AddBrushStop, () => SelectedSegment != null); RemoveBrushStopCommand = new RelayCommand(RemoveBrushStop, () => SelectedBrushStop != null); - SaveJobsCommand = new RelayCommand(SaveJobs, () => SelectedMachine != null); + SaveJobCommand = new RelayCommand(SaveJob, () => SelectedMachine != null); + DiscardJobCommand = new RelayCommand(DiscardJob, () => SelectedMachine != null); StartJobCommand = new RelayCommand(StartJob, () => SelectedJob != null && !IsJobRunning); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); @@ -615,22 +623,53 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Private Methods - private void LoadJob() + private async void LoadJob() { if (SelectedJob != null) { - Task.Factory.StartNew(() => + using (_notification.PushTaskItem("Loading job details...")) { - SelectedSegment = SelectedJob.Segments.FirstOrDefault(); + await Task.Factory.StartNew(() => + { + _dbJobContext = ObservablesContext.CreateDefault(); - SelectedJob.LengthChanged -= SelectedJob_LengthChanged; - SelectedJob.LengthChanged += SelectedJob_LengthChanged; + _jobFromList = SelectedJob; + SelectedJob = _dbJobContext.Jobs.SingleOrDefault(x => x.Guid == SelectedJob.Guid); + SelectedRML = SelectedJob.Rml; - UpdateEstimatedDuration(); - }); + SelectedSegment = SelectedJob.Segments.FirstOrDefault(); - _navigation.NavigateTo(DeveloperNavigationView.JobView); + SelectedJob.LengthChanged -= SelectedJob_LengthChanged; + SelectedJob.LengthChanged += SelectedJob_LengthChanged; + + UpdateEstimatedDuration(); + }); + + _navigation.NavigateTo(DeveloperNavigationView.JobView); + } + } + } + private async void SaveJob() + { + if (SelectedJob != null) + { + using (_notification.PushTaskItem("Saving machine jobs...")) + { + SelectedJob.LastUpdated = DateTime.UtcNow; + SelectedJob.Rml = SelectedRML; + await _dbJobContext.SaveChangesAsync(); + await _jobFromList.Reload(); + } + } + } + + private void DiscardJob() + { + if (_notification.ShowQuestion("This will discard the current job changes. Are you sue?")) + { + _dbJobContext.Dispose(); + _navigation.NavigateTo(DeveloperNavigationView.MachineJobSelectionView); } } @@ -689,6 +728,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private void CloseJobCompletionStatusBar() { + _navigation.NavigateTo(DeveloperNavigationView.JobView); IsJobCompleted = false; IsJobFailed = false; IsJobCanceled = false; @@ -723,6 +763,12 @@ namespace Tango.MachineStudio.Developer.ViewModels return; } + if (SelectedProcessParametersTable == null) + { + _notification.ShowError("No process parameters table selected. Could not execute the specified job."); + return; + } + RunningJobRemainingTime = TimeSpan.Zero; RunningJobProgress = 0; IsJobFailed = false; @@ -735,6 +781,8 @@ namespace Tango.MachineStudio.Developer.ViewModels RunningJobSegments = CreateRunningJobEffectiveSegments(RunningJob); + _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); + _jobHandler = MachineOperator.Print(SelectedJob, SelectedProcessParametersTable); _jobHandler.StatusReceived += (x, status) => @@ -785,18 +833,6 @@ namespace Tango.MachineStudio.Developer.ViewModels }; } - private async void SaveJobs() - { - if (SelectedJob != null) - { - using (_notification.PushTaskItem("Saving machine jobs...")) - { - SelectedJob.CreationDate = DateTime.UtcNow; - await SelectedJob.SaveAsync(); - } - } - } - private void UpdateEstimatedDuration() { if (SelectedJob != null && SelectedProcessParametersTable != null && SelectedProcessParametersTable.DyeingSpeed > 0) @@ -957,7 +993,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedMachine != null) { - SelectedMachine.Jobs.Add(new Job() + SelectedMachine.Jobs.Add(new Job(DateTime.UtcNow) { Name = "Untitled Job", CreationDate = DateTime.UtcNow, @@ -1158,7 +1194,6 @@ namespace Tango.MachineStudio.Developer.ViewModels } SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedRMLGuid = SelectedRML != null ? SelectedRML.Guid : null; SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = SelectedJob != null ? SelectedJob.Guid : null; return Task.FromResult(true); @@ -1177,11 +1212,6 @@ namespace Tango.MachineStudio.Developer.ViewModels SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); } - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedRMLGuid != null) - { - SelectedRML = Adapter.Rmls.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedRMLGuid); - } - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) { SelectedJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml index 9a48f605b..5dbbde482 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml @@ -3,22 +3,413 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:localConverters="clr-namespace:Tango.MachineStudio.Developer.Converters" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.Developer" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Transparent + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Job Completed Successfully + + + + + + + + + + + + + + + + + + + + + + + Job Failed To Complete + + + + + + + + + + + + + + + + + + + + + + + + + Job Aborted By User + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 17e0461e8..0568d5f60 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 @@ -154,16 +154,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Completed Successfully - - - - - - - - - - - - - - - - - - - - - - - Job Failed To Complete - - - - - - - - - - - - - - - - - - - - - - - - - Job Aborted By User - - - - - - - - - - - - - - @@ -667,8 +321,8 @@ - - + + # SEGMENT @@ -686,8 +340,8 @@ - - + + @@ -739,7 +393,7 @@ Name - + @@ -749,7 +403,7 @@ Winding Method - + @@ -760,8 +414,8 @@ Inter Segment - - + + @@ -772,7 +426,7 @@ Lubrication - + @@ -795,13 +449,21 @@ - - + + + + + @@ -824,7 +486,7 @@ Length - + @@ -850,22 +512,29 @@ - - + + - + + + + + + + + RML LIQUID FACTORS ( Max Nanolitter/CM ) + - - LIQUID FACTORS ( Max Nanolitter/CM ) + @@ -903,7 +572,7 @@ - + @@ -913,19 +582,19 @@ - - - + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml.cs new file mode 100644 index 000000000..74ace554e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.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.MachineStudio.Developer.Views +{ + /// + /// Interaction logic for RunningJobView.xaml + /// + public partial class RunningJobView : UserControl + { + public RunningJobView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config index cacd4cd77..4a6cb0526 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/app.config @@ -1,5 +1,9 @@  + + +
+ @@ -8,4 +12,10 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config index 6c338d81b..7994d1504 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config @@ -1,6 +1,7 @@  + -- cgit v1.3.1