diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-08-02 11:59:16 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-08-02 11:59:16 +0300 |
| commit | f4b51ad784cffc3493f32a9b4f1e9afc6fd2a43c (patch) | |
| tree | 1471983c9cfce00b4a0c6b26f6c3c0429405c904 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs | |
| parent | da3ed099835ff1dd9b21cdd590e252360df2312d (diff) | |
| parent | 66aa9beeec79e5f828fc13ce7a5e41c15227ec9a (diff) | |
| download | Tango-f4b51ad784cffc3493f32a9b4f1e9afc6fd2a43c.tar.gz Tango-f4b51ad784cffc3493f32a9b4f1e9afc6fd2a43c.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs | 72 |
1 files changed, 50 insertions, 22 deletions
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 e53ec0b39..df1ea5f7e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -37,6 +37,7 @@ using Tango.Settings; using Tango.SharedUI; using Tango.SharedUI.Controls; using Tango.SharedUI.Helpers; +using Tango.Transport; using Tango.Transport.Adapters; namespace Tango.MachineStudio.UI.ViewModels @@ -449,27 +450,33 @@ namespace Tango.MachineStudio.UI.ViewModels x.SelectedMachine.EnableEmbeddedDebugging = true; } - await x.SelectedMachine.Connect(); - - var authenticated = await x.SelectedMachine.As<IExternalBridgeSecureClient>().Authenticate(login.Password, Environment.MachineName, AuthenticationProvider.CurrentUser.Guid, "Machine Studio"); - if (!authenticated) + await x.SelectedMachine.As<IExternalBridgeSecureClient>().Connect(new PMR.Integration.ExternalBridgeLoginRequest() { - _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine."); - } - else + AppID = "Machine Studio", + HostName = Environment.MachineName, + Password = login.Password, + UserGuid = AuthenticationProvider.CurrentUser.Guid, + Intent = PMR.Integration.ExternalBridgeLoginIntent.Override, + }); + + ApplicationManager.ConnectedMachine = x.SelectedMachine; + (x.SelectedMachine as IExternalBridgeSecureClient).SessionClosed += (_, __) => { - ApplicationManager.ConnectedMachine = x.SelectedMachine; - (x.SelectedMachine as IExternalBridgeSecureClient).SessionClosed += (_, __) => + InvokeUI(() => { - InvokeUI(() => - { - _notificationProvider.ShowError("The remote machine has closed the current session. Machine disconnected."); - ApplicationManager.ConnectedMachine = null; - }); - }; - PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); - _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); - } + _notificationProvider.ShowError("The remote machine has closed the current session. Machine disconnected."); + ApplicationManager.ConnectedMachine = null; + }); + }; + PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); + _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); + + } + catch (ResponseErrorException ex) + { + LogManager.Log(ex); + _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber); + _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Container.ErrorMessage); } catch (Exception ex) { @@ -547,8 +554,8 @@ namespace Tango.MachineStudio.UI.ViewModels } catch (Exception ex) { - LogManager.Log(ex, "Error upload hardware configuration."); - NotificationProvider.ShowError("Error upload hardware configuration." + Environment.NewLine + ex.Message); + LogManager.Log(ex, "Error uploading hardware configuration."); + NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); } } } @@ -557,7 +564,7 @@ namespace Tango.MachineStudio.UI.ViewModels { if (NotificationProvider.ShowQuestion("This will reset the embedded device. Are you sure?")) { - using (NotificationProvider.PushTaskItem("Uploading hardware configuration...")) + using (NotificationProvider.PushTaskItem("Resetting the embedded device...")) { try { @@ -572,6 +579,25 @@ namespace Tango.MachineStudio.UI.ViewModels } } } + else if (x.Result == ConnectedMachineViewVM.ConnectedMachineVMResult.TurnOffHeaters) + { + if (NotificationProvider.ShowQuestion("This will reset the process parameters. Are you sure?")) + { + using (NotificationProvider.PushTaskItem("Resetting process parameters...")) + { + try + { + await ApplicationManager.ConnectedMachine.UploadProcessParameters(new ProcessParametersTable()); + NotificationProvider.ShowInfo("Heaters are turned off."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error resetting process parameters."); + NotificationProvider.ShowError("Error resetting process parameters." + Environment.NewLine + ex.Message); + } + } + } + } }); } @@ -737,7 +763,9 @@ namespace Tango.MachineStudio.UI.ViewModels private void ReportIssue() { - _notificationProvider.ShowModalDialog<ReportIssueViewVM, ReportIssueView>(new ReportIssueViewVM(TFSClient.Project, TFSClient.CreateBug()), async (vm) => + var bug = TFSClient.CreateBug(); + + _notificationProvider.ShowModalDialog<ReportIssueViewVM, ReportIssueView>(new ReportIssueViewVM(TFSClient.Project, bug), async (vm) => { using (_notificationProvider.PushTaskItem("Uploading bug report...")) { |
