From eed57807589a6de896c27e988e2d0e8d1358faa4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 23 Oct 2018 15:41:42 +0300 Subject: Added storage api proto files. --- .../ViewModels/MachineConnectionViewVM.cs | 33 ++++++++++++ .../ViewModels/MainViewVM.cs | 62 +++++++++++++--------- 2 files changed, 69 insertions(+), 26 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs index 51b7168ed..7737911e0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs @@ -52,6 +52,8 @@ namespace Tango.MachineStudio.UI.ViewModels /// The scanner. public MachineConnectionViewVM(ExternalBridgeScanner scanner) { + EnableDiagnostics = true; + UploadHardwareConfiguration = true; Scanner = scanner; ConnectCommand = new RelayCommand(Connect, (x) => SelectedMachine != null); } @@ -97,5 +99,36 @@ namespace Tango.MachineStudio.UI.ViewModels Scanner.AvailableMachines.Add(_emulator); Scanner.Start(); } + + private bool _enableDiagnostics; + /// + /// Gets or sets a value indicating whether to enable diagnostics after connection. + /// + public bool EnableDiagnostics + { + get { return _enableDiagnostics; } + set { _enableDiagnostics = value; RaisePropertyChangedAuto(); } + } + + private bool _uploadHardwareConfiguration; + /// + /// Gets or sets a value indicating whether to upload hardware configuration after connection. + /// + public bool UploadHardwareConfiguration + { + get { return _uploadHardwareConfiguration; } + set { _uploadHardwareConfiguration = value; RaisePropertyChangedAuto(); } + } + + private bool _enableKeepAlive; + /// + /// Gets or sets a value indicating whether to use the keep alive mechanism. + /// + public bool EnableKeepAlive + { + get { return _enableKeepAlive; } + set { _enableKeepAlive = value; RaisePropertyChangedAuto(); } + } + } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 49a8ca807..9b625a6ee 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -445,6 +445,11 @@ namespace Tango.MachineStudio.UI.ViewModels } } + x.SelectedMachine.EnableDiagnostics = x.EnableDiagnostics; + x.SelectedMachine.EnableEmbeddedDebugging = x.EnableDiagnostics; + x.SelectedMachine.EnableEventsNotification = x.EnableDiagnostics; + x.SelectedMachine.UseKeepAlive = x.EnableKeepAlive; + if (x.SelectedMachine.RequiresAuthentication) { _notificationProvider.ShowModalDialog(async (login) => @@ -453,11 +458,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (x.SelectedMachine.EnableDiagnostics) - { - x.SelectedMachine.EnableEmbeddedDebugging = true; - } - await x.SelectedMachine.As().Connect(new PMR.Integration.ExternalBridgeLoginRequest() { AppID = "Machine Studio", @@ -479,6 +479,11 @@ namespace Tango.MachineStudio.UI.ViewModels PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); + if (x.UploadHardwareConfiguration) + { + UploadHardwareConfiguration(); + } + } catch (ResponseErrorException ex) { @@ -507,11 +512,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (x.SelectedMachine.EnableDiagnostics) - { - x.SelectedMachine.EnableEmbeddedDebugging = true; - } - await x.SelectedMachine.Connect(); x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber; ApplicationManager.SetConnectedMachine(x.SelectedMachine); @@ -520,6 +520,11 @@ namespace Tango.MachineStudio.UI.ViewModels _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber)); _settings.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; _settings.Save(); + + if (x.UploadHardwareConfiguration) + { + UploadHardwareConfiguration(); + } } catch (Exception ex) { @@ -560,22 +565,7 @@ namespace Tango.MachineStudio.UI.ViewModels { using (NotificationProvider.PushTaskItem("Uploading hardware configuration...")) { - try - { - using (ObservablesContext db = ObservablesContext.CreateDefault()) - { - var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.Machine.ConfigurationGuid); - var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.Machine.Guid); - - await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config); - } - NotificationProvider.ShowInfo("Hardware configuration uploaded successfully."); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error uploading hardware configuration."); - NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); - } + UploadHardwareConfiguration(); } } } @@ -623,6 +613,26 @@ namespace Tango.MachineStudio.UI.ViewModels InvalidateRelayCommands(); } + private async void UploadHardwareConfiguration() + { + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.Machine.ConfigurationGuid); + var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.Machine.Guid); + + await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config); + } + NotificationProvider.ShowInfo("Hardware configuration uploaded successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error uploading hardware configuration."); + NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); + } + } + /// /// Navigates to the home screen. /// -- cgit v1.3.1 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!! --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 20578304 -> 20578304 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes Software/PMR/Messages/Common/ErrorCode.proto | 12 +- Software/PMR/Messages/Common/MessageType.proto | 4 + .../PMR/Messages/Printing/CurrentJobRequest.proto | 9 + .../PMR/Messages/Printing/CurrentJobResponse.proto | 12 ++ Software/PMR/Messages/Printing/JobTicket.proto | 17 +- .../Printing/ResumeCurrentJobRequest.proto | 9 + .../Printing/ResumeCurrentJobResponse.proto | 12 ++ .../Build/Shortcuts/Machine Emulator.lnk | Bin 1471 -> 1455 bytes .../Build/Shortcuts/Machine Studio.lnk | Bin 1532 -> 1516 bytes .../Build/Shortcuts/Proto Compiler GUI.lnk | Bin 1464 -> 1448 bytes .../ViewModels/MainViewVM.cs | 51 +++++- .../Navigation/INavigationManager.cs | 2 + .../Modules/DefaultStudioModuleLoader.cs | 5 +- .../Navigation/DefaultNavigationManager.cs | 12 ++ .../Notifications/DefaultNotificationProvider.cs | 38 +++- .../DefaultStudioApplicationManager.cs | 17 +- .../ViewModels/MainViewVM.cs | 2 + .../Tango.MachineStudio.UI/Views/MainView.xaml | 20 ++- .../Editors/AutoCompleteTextBox.cs | 9 +- .../Tango.Emulations/Emulators/MachineEmulator.cs | 88 ++++++++-- .../Operation/IMachineOperator.cs | 10 ++ .../Tango.Integration/Operation/MachineOperator.cs | 141 +++++++++++++++ .../Operation/ResumingJobEventArgs.cs | 26 +++ .../Tango.Integration/Tango.Integration.csproj | 3 +- .../Visual_Studio/Tango.PMR/Common/ErrorCode.cs | 10 +- .../Visual_Studio/Tango.PMR/Common/MessageType.cs | 47 ++--- .../Tango.PMR/Printing/CurrentJobRequest.cs | 131 ++++++++++++++ .../Tango.PMR/Printing/CurrentJobResponse.cs | 195 +++++++++++++++++++++ .../Visual_Studio/Tango.PMR/Printing/JobTicket.cs | 95 ++++++---- .../Tango.PMR/Printing/ResumeCurrentJobRequest.cs | 131 ++++++++++++++ .../Tango.PMR/Printing/ResumeCurrentJobResponse.cs | 195 +++++++++++++++++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 6 +- 36 files changed, 1204 insertions(+), 105 deletions(-) create mode 100644 Software/PMR/Messages/Printing/CurrentJobRequest.proto create mode 100644 Software/PMR/Messages/Printing/CurrentJobResponse.proto create mode 100644 Software/PMR/Messages/Printing/ResumeCurrentJobRequest.proto create mode 100644 Software/PMR/Messages/Printing/ResumeCurrentJobResponse.proto create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/ResumingJobEventArgs.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Printing/CurrentJobRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Printing/CurrentJobResponse.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Printing/ResumeCurrentJobRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Printing/ResumeCurrentJobResponse.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 05382b4cb..35e6fba43 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 34218c424..fb57f7692 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index f14509fff..9383eee3c 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 e3144956b..995b71bf5 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Common/ErrorCode.proto b/Software/PMR/Messages/Common/ErrorCode.proto index 51774e6e9..cbdcfec25 100644 --- a/Software/PMR/Messages/Common/ErrorCode.proto +++ b/Software/PMR/Messages/Common/ErrorCode.proto @@ -24,9 +24,11 @@ enum ErrorCode //Job Failure JOB_UNSPECIFIED_ERROR = 2000; JOB_THREAD_BREAK = 2001; - JOB_WINDER_DANCER_FAIL = 2002; - JOB_POOLER_DANCER_FAIL = 2003; - JOB_FEEDER_DANCER_FAIL = 2004; - JOB_OUT_OF_DYE = 2005; - JOB_OTHER_ALARM = 2006; + JOB_WINDER_DANCER_FAIL = 2002; + JOB_POOLER_DANCER_FAIL = 2003; + JOB_FEEDER_DANCER_FAIL = 2004; + JOB_OUT_OF_DYE = 2005; + JOB_OTHER_ALARM = 2006; + NO_JOB_IN_PROGRESS = 2007; //Occurs when ResumeCurrentJobRequest was called but no job is in progress. + } diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index c19bbc2d8..c9a55552d 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -175,6 +175,10 @@ enum MessageType AbortJobResponse = 3003; UploadProcessParametersRequest = 3004; UploadProcessParametersResponse = 3005; + CurrentJobRequest = 3006; + CurrentJobResponse = 3007; + ResumeCurrentJobRequest = 3008; + ResumeCurrentJobResponse = 3009; diff --git a/Software/PMR/Messages/Printing/CurrentJobRequest.proto b/Software/PMR/Messages/Printing/CurrentJobRequest.proto new file mode 100644 index 000000000..1e5f57531 --- /dev/null +++ b/Software/PMR/Messages/Printing/CurrentJobRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Printing; +option java_package = "com.twine.tango.pmr.printing"; + +message CurrentJobRequest +{ + +} \ No newline at end of file diff --git a/Software/PMR/Messages/Printing/CurrentJobResponse.proto b/Software/PMR/Messages/Printing/CurrentJobResponse.proto new file mode 100644 index 000000000..5fe94db13 --- /dev/null +++ b/Software/PMR/Messages/Printing/CurrentJobResponse.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +import "JobTicket.proto"; + +package Tango.PMR.Printing; +option java_package = "com.twine.tango.pmr.printing"; + +message CurrentJobResponse +{ + bool IsJobInProgress = 1; + JobTicket JobTicket = 2; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Printing/JobTicket.proto b/Software/PMR/Messages/Printing/JobTicket.proto index ace279747..9d15d9433 100644 --- a/Software/PMR/Messages/Printing/JobTicket.proto +++ b/Software/PMR/Messages/Printing/JobTicket.proto @@ -10,17 +10,18 @@ option java_package = "com.twine.tango.pmr.printing"; message JobTicket { - string Name = 1; + string guid = 1; + string Name = 2; - bool EnableInterSegment = 2; - double InterSegmentLength = 3; + bool EnableInterSegment = 3; + double InterSegmentLength = 4; - double Length = 4; + double Length = 5; - ProcessParameters ProcessParameters = 5; + ProcessParameters ProcessParameters = 6; - JobWindingMethod WindingMethod = 6; - JobSpool Spool = 7; + JobWindingMethod WindingMethod = 7; + JobSpool Spool = 8; - repeated JobSegment Segments = 8; + repeated JobSegment Segments = 9; } \ No newline at end of file diff --git a/Software/PMR/Messages/Printing/ResumeCurrentJobRequest.proto b/Software/PMR/Messages/Printing/ResumeCurrentJobRequest.proto new file mode 100644 index 000000000..0ab3d7b62 --- /dev/null +++ b/Software/PMR/Messages/Printing/ResumeCurrentJobRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Printing; +option java_package = "com.twine.tango.pmr.printing"; + +message ResumeCurrentJobRequest +{ + +} \ No newline at end of file diff --git a/Software/PMR/Messages/Printing/ResumeCurrentJobResponse.proto b/Software/PMR/Messages/Printing/ResumeCurrentJobResponse.proto new file mode 100644 index 000000000..08c3ffcca --- /dev/null +++ b/Software/PMR/Messages/Printing/ResumeCurrentJobResponse.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +import "JobStatus.proto"; + +package Tango.PMR.Printing; +option java_package = "com.twine.tango.pmr.printing"; + +message ResumeCurrentJobResponse +{ + JobStatus Status = 1; + bool Canceled = 2; +} \ No newline at end of file diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk index 809dc39a4..0b55f9468 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 aaa476b0b..96378d6e7 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 349e9582e..8996e8019 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.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(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs index e20940c8d..6bd4d8829 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs @@ -101,6 +101,8 @@ namespace Tango.MachineStudio.Common.Navigation Task NavigateWithObject(TPass obj, bool pushToHistory = true) where TModule : IStudioModule; + void NavigateToModule() where T : IStudioModule; + /// /// Clears the navigation back history. /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs index 0def3c943..28f56e521 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs @@ -44,7 +44,10 @@ namespace Tango.MachineStudio.UI.Modules /// The e. private void _authenticationProvider_CurrentUserChanged(object sender, User e) { - LoadModules(); + if (e != null) + { + LoadModules(); + } } private SynchronizedObservableCollection _allModules; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs index 899ba846e..13ec6161d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core; using Tango.Core.Commands; +using Tango.Core.DI; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; @@ -384,5 +385,16 @@ namespace Tango.MachineStudio.UI.Navigation RaisePropertyChanged(nameof(CanNavigateBack)); } + + public void NavigateToModule() where T : IStudioModule + { + var loader = TangoIOC.Default.GetInstance(); + var module = loader.UserModules.SingleOrDefault(x => x.GetType() == typeof(T)); + + if (module != null) + { + TangoIOC.Default.GetInstance().StartModule(module); + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 6cff1ba17..80509e6c0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -11,6 +11,7 @@ using System.Windows.Media; using Tango.Core; using System.Collections.ObjectModel; using Tango.SharedUI; +using System.Collections.Concurrent; namespace Tango.MachineStudio.UI.Notifications { @@ -21,6 +22,8 @@ namespace Tango.MachineStudio.UI.Notifications /// public class DefaultNotificationProvider : ExtendedObject, INotificationProvider { + private int _message_count = 0; + /// /// The view types /// @@ -79,6 +82,8 @@ namespace Tango.MachineStudio.UI.Notifications { MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + _message_count++; + var result = new MessageBoxWindow() { Owner = Application.Current.MainWindow, @@ -89,7 +94,13 @@ namespace Tango.MachineStudio.UI.Notifications }.ShowDialog(); - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + _message_count--; + + if (_message_count == 0) + { + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } + return result; } @@ -377,8 +388,11 @@ namespace Tango.MachineStudio.UI.Notifications /// The task item. public void PushTaskItem(TaskItem taskItem) { - TaskItems.Add(taskItem); - CurrentTaskItem = taskItem; + InvokeUI(() => + { + TaskItems.Add(taskItem); + CurrentTaskItem = taskItem; + }); } /// @@ -400,14 +414,20 @@ namespace Tango.MachineStudio.UI.Notifications /// The task item. public void PopTaskItem(TaskItem taskItem) { - TaskItems.Remove(taskItem); - - if (TaskItems.Count > 0) + Task.Delay(1000).ContinueWith((x) => { - CurrentTaskItem = TaskItems.Last(); - } + InvokeUI(() => + { + TaskItems.Remove(taskItem); - RaisePropertyChanged(nameof(HasTaskItems)); + if (TaskItems.Count > 0) + { + CurrentTaskItem = TaskItems.Last(); + } + + RaisePropertyChanged(nameof(HasTaskItems)); + }); + }); } /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 8be7f486a..3864708fc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -25,6 +25,7 @@ using Tango.MachineStudio.UI.ViewModels; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.Views; using Tango.Integration.Operation; +using Tango.MachineStudio.UI.Windows; namespace Tango.MachineStudio.UI.StudioApplication { @@ -39,6 +40,7 @@ namespace Tango.MachineStudio.UI.StudioApplication private IStudioModuleLoader _moduleLoader; private INotificationProvider _notification; private List _openedWindows; + private List _notified_view_models; /// /// Initializes a new instance of the class. @@ -50,6 +52,7 @@ namespace Tango.MachineStudio.UI.StudioApplication _navigationManager = navigationManager; _notification = notification; _openedWindows = new List(); + _notified_view_models = new List(); Application.Current.MainWindow.ContentRendered += (_, __) => { @@ -286,6 +289,11 @@ namespace Tango.MachineStudio.UI.StudioApplication window.Closed += (x, y) => { _openedWindows.Remove(window); }; } + public bool IsModuleInNewWindow(IStudioModule module) + { + return _openedWindows.Exists(x => (x as ModuleWindow).ModuleContext.Module == module); + } + /// /// Gets the core libraries version. /// @@ -324,7 +332,14 @@ namespace Tango.MachineStudio.UI.StudioApplication /// public void NotifyApplicationReady() { - TangoIOC.Default.GetAllInstancesByBase().ToList().ForEach(x => x.OnApplicationReady()); + TangoIOC.Default.GetAllInstancesByBase().ToList().ForEach(x => + { + if (!_notified_view_models.Contains(x)) + { + x.OnApplicationReady(); + _notified_view_models.Add(x); + } + }); } /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 9b625a6ee..31e297cd1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -649,6 +649,8 @@ namespace Tango.MachineStudio.UI.ViewModels { IsMenuOpened = false; + if ((_applicationManager as DefaultStudioApplicationManager).IsModuleInNewWindow(module)) return; + if (module != null) { LogManager.Log(String.Format("Starting module '{0}'...", module.Name)); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 7edfa50c6..f66e247a9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -467,7 +467,7 @@ - +