diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-26 14:21:53 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-26 14:21:53 +0300 |
| commit | 1061758f95b7ba633e6bcc2c3556b42f033b1a79 (patch) | |
| tree | c3cf106aa6b73fe1e0bfcd6b88399a5721990eb0 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels | |
| parent | 761686de34252d76bda126c738d82c021ef6bf5d (diff) | |
| download | Tango-1061758f95b7ba633e6bcc2c3556b42f033b1a79.tar.gz Tango-1061758f95b7ba633e6bcc2c3556b42f033b1a79.zip | |
Working on logging module !
Modified PID Control Table.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs | 1 | ||||
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs | 34 |
2 files changed, 28 insertions, 7 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 54b83a5cc..5776cadc2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -70,7 +70,6 @@ namespace Tango.MachineStudio.UI.ViewModels { _studioModuleLoader.LoadModules(); _navigationManager.NavigateTo(NavigationView.LoginView); - _eventLogger.Log("Application started successfully"); IsLoading = false; }); } 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 f54a9dae1..81719287b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -1,4 +1,5 @@ using GalaSoft.MvvmLight.Ioc; +using GalaSoft.MvvmLight.Messaging; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -19,6 +20,7 @@ using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.EventLogging; +using Tango.MachineStudio.Common.Messages; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; @@ -321,12 +323,27 @@ namespace Tango.MachineStudio.UI.ViewModels { using (_notificationProvider.PushTaskItem("Disconnecting from machine...")) { - _isDisconnecting = true; - InvalidateRelayCommands(); - await ApplicationManager.ConnectedMachine.Disconnect(); - ApplicationManager.ConnectedMachine = null; - _isDisconnecting = false; - InvalidateRelayCommands(); + try + { + _isDisconnecting = true; + InvalidateRelayCommands(); + String serial = ApplicationManager.ConnectedMachine.SerialNumber; + await ApplicationManager.ConnectedMachine.Disconnect(); + ApplicationManager.ConnectedMachine = null; + _eventLogger.Log("Disconnected from machine " + serial); + + PostMessage(new MachineConnectionChangedMessage() { Machine = null }); + } + catch (Exception ex) + { + _eventLogger.Log(ex, "Error disconnecting from machine."); + LogManager.Log(ex, "Could not disconnect from machine."); + } + finally + { + _isDisconnecting = false; + InvalidateRelayCommands(); + } } } @@ -377,12 +394,14 @@ namespace Tango.MachineStudio.UI.ViewModels else { ApplicationManager.ConnectedMachine = x.SelectedMachine; + PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); } } catch (Exception ex) { LogManager.Log(ex); + _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber); _notificationProvider.ShowError(ex.Message); } @@ -403,6 +422,8 @@ namespace Tango.MachineStudio.UI.ViewModels await x.SelectedMachine.Connect(); x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber; ApplicationManager.ConnectedMachine = x.SelectedMachine; + + PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber)); SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; SettingsManager.SaveDefaultSettings(); @@ -410,6 +431,7 @@ namespace Tango.MachineStudio.UI.ViewModels catch (Exception ex) { LogManager.Log(ex); + _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber); _notificationProvider.ShowError(ex.Message); } |
