aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-26 14:21:53 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-26 14:21:53 +0300
commit1061758f95b7ba633e6bcc2c3556b42f033b1a79 (patch)
treec3cf106aa6b73fe1e0bfcd6b88399a5721990eb0 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI
parent761686de34252d76bda126c738d82c021ef6bf5d (diff)
downloadTango-1061758f95b7ba633e6bcc2c3556b42f033b1a79.tar.gz
Tango-1061758f95b7ba633e6bcc2c3556b42f033b1a79.zip
Working on logging module !
Modified PID Control Table.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs9
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs9
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs34
4 files changed, 45 insertions, 8 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
index f94a6c9d9..8b3233ab1 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
@@ -14,6 +14,7 @@ using Tango.MachineStudio.UI.Windows;
using Tango.Settings;
using Microsoft.Practices.ServiceLocation;
using Tango.MachineStudio.Common.EventLogging;
+using Tango.BL.Enumerations;
namespace Tango.MachineStudio.UI
{
@@ -49,6 +50,12 @@ namespace Tango.MachineStudio.UI
exceptionTrapper = new WpfGlobalExceptionTrapper();
exceptionTrapper.Initialize(this);
exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed;
+
+ var eventLogger = ServiceLocator.Current.GetInstance<IEventLogger>();
+ if (eventLogger != null)
+ {
+ eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
+ }
}
#region Global Exception Trapping
@@ -74,7 +81,7 @@ namespace Tango.MachineStudio.UI
var eventLogger = ServiceLocator.Current.GetInstance<IEventLogger>();
if (eventLogger != null)
{
- eventLogger.Log(e.Exception);
+ eventLogger.Log(e.Exception, "Application Crashed!");
}
}
catch { }
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 b4b1c5153..52602e6de 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs
@@ -18,6 +18,8 @@ using Tango.MachineStudio.Common;
using Tango.Settings;
using System.Windows;
using Tango.Integration.Services;
+using Tango.MachineStudio.Common.EventLogging;
+using Tango.BL.Enumerations;
namespace Tango.MachineStudio.UI.StudioApplication
{
@@ -189,6 +191,13 @@ namespace Tango.MachineStudio.UI.StudioApplication
LogManager.Log(ex, "Error disconnecting from machine.");
}
+ var eventLogger = ServiceLocator.Current.GetInstance<IEventLogger>();
+ if (eventLogger != null)
+ {
+ eventLogger.Log(EventTypes.ApplicationTerminated, "Application Terminated!");
+ eventLogger.FlushAll();
+ }
+
Thread.Sleep(1500);
Environment.Exit(0);
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);
}