From 17a77c30765fe8a0d3ca57a9ec60fb43b82432d2 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 8 Apr 2018 16:55:37 +0300 Subject: Implemented timeline events ! --- .../Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels') 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 f455faa9e..63994f592 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 @@ -33,6 +33,7 @@ using System.Windows; using Tango.Core.Helpers; using System.Speech.Synthesis; using System.Media; +using Tango.MachineStudio.Common.EventLogging; namespace Tango.MachineStudio.Developer.ViewModels { @@ -57,6 +58,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private SpeechSynthesizer _speech; private SoundPlayer _soundPlayer; private SoundPlayer _soundPlayerErr; + private IEventLogger _eventLogger; #region Properties @@ -598,7 +600,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) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger) { SelectedJobs = new ObservableCollection(); @@ -625,6 +627,7 @@ namespace Tango.MachineStudio.Developer.ViewModels _navigation = navigation; ApplicationManager = applicationManager; VideoCaptureProvider = videoCaptureProvider; + _eventLogger = eventLogger; LogManager.Log("Initializing relay commands..."); @@ -1011,6 +1014,8 @@ namespace Tango.MachineStudio.Developer.ViewModels _jobHandler = MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); + _eventLogger.Log(String.Format("Job '{0}' started...", ActiveJob.Name)); + _jobHandler.StatusReceived += (x, status) => { if (IsJobRunning) @@ -1044,10 +1049,12 @@ namespace Tango.MachineStudio.Developer.ViewModels if (segment.ID != -1) { SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex)); + _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex)); } else { SpeakInfo(String.Format("Inter Segment Started.")); + _eventLogger.Log("Inter Segment Started."); } } } @@ -1064,6 +1071,7 @@ namespace Tango.MachineStudio.Developer.ViewModels _jobHandler.Failed += (x, ex) => { LogManager.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name)); + _eventLogger.Log(ex, String.Format("Job {0} has failed.", RunningJob.Name)); SetJobFailed(); InvokeUI(() => @@ -1075,18 +1083,21 @@ namespace Tango.MachineStudio.Developer.ViewModels _jobHandler.Completed += (x, e) => { LogManager.Log(String.Format("Job {0} has completed.", RunningJob.Name)); + _eventLogger.Log(String.Format("Job {0} has completed.", RunningJob.Name)); SetJobCompleted(); }; _jobHandler.Canceled += (x, y) => { LogManager.Log(String.Format("Job {0} has been canceled.", RunningJob.Name)); + _eventLogger.Log(String.Format("Job {0} has been canceled.", RunningJob.Name)); //Finally Canceled.. }; } catch (Exception ex) { LogManager.Log(ex); + _eventLogger.Log(ex, "An error occurred while starting the job."); _notification.ShowError("An error occurred while starting the job. " + Environment.NewLine + ex.Message); SetJobFailed(); } -- cgit v1.3.1 From a0e25846735104f09a18647220db59804977e73a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 8 Apr 2018 17:48:58 +0300 Subject: Fixed issue with "Application Started" event. Fixed issue with segment indexing after emb import. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../ViewModels/MainViewVM.cs | 2 +- .../EventLogging/DefaultEventLogger.cs | 29 +++++++++++------- .../Tango.MachineStudio.UI/App.xaml.cs | 6 ---- .../ViewModels/LoadingViewVM.cs | 4 +++ .../Tango.BL/EntitiesExtensions/Machine.cs | 2 +- .../Tango.BL/EntitiesExtensions/MediaColor.cs | 33 +++++++++++++++++++++ .../Tango.BL/ExtensionMethods/MediaColor.cs | 33 --------------------- Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 2 +- 10 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs delete mode 100644 Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index e570d5638..dff82fd11 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 1589c0595..b6a391fd4 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf 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 63994f592..7891f96b7 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 @@ -1752,7 +1752,7 @@ namespace Tango.MachineStudio.Developer.ViewModels segment.Length = totalLength; segment.Name = "Embroidery Segment"; - segment.SegmentIndex = vm.Paths.IndexOf(path) + 2; + segment.SegmentIndex = vm.Paths.IndexOf(path); if (path.Brush is SolidColorBrush) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs index 91aa049e9..f3ae1002b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs @@ -78,21 +78,28 @@ namespace Tango.MachineStudio.Common.EventLogging { if (!_isInitialized) { - _db = ObservablesContext.CreateDefault(); - _db.Configuration.LazyLoadingEnabled = false; + try + { + _db = ObservablesContext.CreateDefault(); + _db.Configuration.LazyLoadingEnabled = false; - _db.ActionTypes.ToList(); - _db.EventTypesActions.ToList(); - _db.EventTypesCategories.ToList(); - _db.EventTypesGroups.ToList(); - _db.EventTypes.ToList(); + _db.ActionTypes.ToList(); + _db.EventTypesActions.ToList(); + _db.EventTypesCategories.ToList(); + _db.EventTypesGroups.ToList(); + _db.EventTypes.ToList(); - foreach (var type in _db.EventTypes) + foreach (var type in _db.EventTypes) + { + _eventTypesGuids.Add((EventTypes)type.Code, type); + } + + _isInitialized = true; + } + catch { - _eventTypesGuids.Add((EventTypes)type.Code, type); + _isInitialized = false; } - - _isInitialized = true; } } 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 8b3233ab1..76c7b3e58 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -50,12 +50,6 @@ namespace Tango.MachineStudio.UI exceptionTrapper = new WpfGlobalExceptionTrapper(); exceptionTrapper.Initialize(this); exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed; - - var eventLogger = ServiceLocator.Current.GetInstance(); - if (eventLogger != null) - { - eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); - } } #region Global Exception Trapping 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 5776cadc2..512341f7e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -14,6 +14,7 @@ using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; using Tango.BL; using Tango.MachineStudio.Common.EventLogging; +using Tango.BL.Enumerations; namespace Tango.MachineStudio.UI.ViewModels { @@ -66,6 +67,9 @@ namespace Tango.MachineStudio.UI.ViewModels try { ObservablesEntitiesAdapter.Instance.Initialize(); + + _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + InvokeUI(() => { _studioModuleLoader.LoadModules(); diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs index e00715795..ff32ba02f 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Machine.cs @@ -31,7 +31,7 @@ namespace Tango.BL.Entities foreach (var segment in job.Segments) { - segment.SegmentIndex = job.Segments.IndexOf(segment); + //segment.SegmentIndex = job.Segments.IndexOf(segment); foreach (var stop in segment.BrushStops) { diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs new file mode 100644 index 000000000..e4a312775 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MediaColor.cs @@ -0,0 +1,33 @@ +using ColorMine.ColorSpaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.BL.Entities +{ + public partial class MediaColor + { + private Color _color; + + public Color Color + { + get { return _color; } + set { _color = value; RaisePropertyChangedAuto(); } + } + + protected override void RaisePropertyChanged(string propName) + { + base.RaisePropertyChanged(propName); + + if (propName == nameof(L) || propName == nameof(A) || propName == nameof(B)) + { + Lab lab = new Lab(L, A, B); + var rgb = lab.To(); + Color = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs b/Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs deleted file mode 100644 index e4a312775..000000000 --- a/Software/Visual_Studio/Tango.BL/ExtensionMethods/MediaColor.cs +++ /dev/null @@ -1,33 +0,0 @@ -using ColorMine.ColorSpaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media; - -namespace Tango.BL.Entities -{ - public partial class MediaColor - { - private Color _color; - - public Color Color - { - get { return _color; } - set { _color = value; RaisePropertyChangedAuto(); } - } - - protected override void RaisePropertyChanged(string propName) - { - base.RaisePropertyChanged(propName); - - if (propName == nameof(L) || propName == nameof(A) || propName == nameof(B)) - { - Lab lab = new Lab(L, A, B); - var rgb = lab.To(); - Color = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); - } - } - } -} diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index d56324d8f..04c1b0a6b 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -97,7 +97,7 @@ - + -- cgit v1.3.1