From 13e34402f91fae6229b2d9719ddb48ced1d37fbf Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 16 Jul 2018 15:51:33 +0300 Subject: Some fixed and improvements. --- .../Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 1 + 1 file changed, 1 insertion(+) (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 dacbc89b1..b4e588700 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 @@ -1478,6 +1478,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { seg.SegmentIndex = 1; } + ActiveJob.Segments.Add(seg); SelectedSegment = seg; AddBrushStop(); -- cgit v1.3.1 From 69bbedacee151090d5d0b6665b3a1614e65f1997 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 16 Jul 2018 20:01:10 +0300 Subject: Added color conversion to Machine Studio. Fixed issue with segments cloning. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../Images/arrow-long-right.png | Bin 0 -> 2169 bytes .../Tango.MachineStudio.Developer.csproj | 7 ++ .../ViewModels/MainViewVM.cs | 109 ++++++++++++++++++++- .../Views/JobView.xaml | 48 ++++++++- .../Views/JobView.xaml.cs | 23 +++++ .../ViewModels/ApplicationLogsViewVM.cs | 1 + .../ViewModels/EmbeddedLogsViewVM.cs | 1 + .../ViewModels/EventsViewVM.cs | 1 + .../Tango.MachineStudio.Common/StudioViewModel.cs | 10 +- .../Tango.MachineStudio.UI/Resources/BuildDate.txt | 2 +- .../Tango.BL/EntitiesExtensions/Job.cs | 5 + .../Tango.BL/EntitiesExtensions/Segment.cs | 6 ++ .../Implementation/BrushPicker.cs | 7 +- Software/Visual_Studio/Versioning/MachineStudio.cs | 4 +- 16 files changed, 211 insertions(+), 13 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 7ec69c408..972c5075b 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 493f8b3a4..3e7545385 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/Images/arrow-long-right.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png new file mode 100644 index 000000000..6c089d44e Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/arrow-long-right.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index f8f121dff..46396c791 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -224,6 +224,10 @@ {b112d89a-a106-41ae-a0c1-4abc84c477f5} Tango.DragAndDrop + + {942134ac-6ea2-4500-8f22-0f739b70a05f} + Tango.Hive + {4206ac58-3b57-4699-8835-90bf6db01a61} Tango.Integration @@ -349,5 +353,8 @@ + + + \ No newline at end of file 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 b4e588700..ab74fcca8 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 @@ -38,6 +38,7 @@ using System.Threading; using Tango.SharedUI.Helpers; using Tango.Core.DI; using Tango.MachineStudio.Common; +using Tango.BL.ColorConversion; namespace Tango.MachineStudio.Developer.ViewModels { @@ -64,9 +65,32 @@ namespace Tango.MachineStudio.Developer.ViewModels private DataCapture.ViewModels.MainViewVM _dataCaptureVM; private bool _isRecording; private DeveloperModuleSettings _settings; + private Thread _colorConversionThread; + private bool _hiveOpened; + private bool _color_changed_from_hive; #region Properties + private List _hiveSuggestions; + /// + /// Gets or sets the hive suggestions. + /// + public List HiveSuggestions + { + get { return _hiveSuggestions; } + set { _hiveSuggestions = value; RaisePropertyChangedAuto(); } + } + + private ColorConversionSuggestion _selectedSuggestion; + /// + /// Gets or sets the selected suggestion. + /// + public ColorConversionSuggestion SelectedSuggestion + { + get { return _selectedSuggestion; } + set { _selectedSuggestion = value; RaisePropertyChangedAuto(); OnSelectedSuggestionChanged(); } + } + private RunningJobStatus _runningJobStatus; /// /// Gets or sets the running job status. @@ -670,6 +694,83 @@ namespace Tango.MachineStudio.Developer.ViewModels ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; _eventLogger.NewLog += _eventLogger_NewLog; + + _colorConversionThread = new Thread(ColorConversionThreadMethod); + _colorConversionThread.IsBackground = true; + _colorConversionThread.Start(); + } + + private void ColorConversionThreadMethod() + { + while (true) + { + if (IsVisible && ActiveJob != null) + { + var stops = ActiveJob.Segments.SelectMany(x => x.BrushStops); + + foreach (var stop in stops) + { + if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32()) + { + try + { + var output = TangoColorConverter.GetSuggestions(stop); + stop.Red = output.SingleCoordinates.Red; + stop.Green = output.SingleCoordinates.Green; + stop.Blue = output.SingleCoordinates.Blue; + } + catch { } + } + } + } + + Thread.Sleep(500); + } + } + + public void OnHivePopupOpened() + { + if (SelectedBrushStop != null) + { + _hiveOpened = true; + HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(TangoColorConverter.GetSuggestions(SelectedBrushStop)); + } + } + + private void OnSelectedSuggestionChanged() + { + if (SelectedSuggestion != null && SelectedBrushStop != null && _hiveOpened) + { + _color_changed_from_hive = true; + SelectedBrushStop.Color = SelectedSuggestion.Color; + + var coords = SelectedSuggestion.Coordinates; + + foreach (var liquid in coords.OutputLiquids) + { + var liquidVolume = SelectedBrushStop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == liquid.LiquidType.ToInt32()); + + if (liquidVolume != null) + { + liquidVolume.Volume = liquid.Volume; + } + } + + _color_changed_from_hive = false; + } + } + + public void OnSelectedBrushColorChanged(Color color) + { + if (!_color_changed_from_hive && _hiveOpened) + { + HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(TangoColorConverter.GetSuggestions(SelectedBrushStop)); + } + } + + public void OnHivePopupClosed() + { + _hiveOpened = false; } #endregion @@ -1045,7 +1146,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } }; - _jobHandler.UnitCompleted += (x, unit) => + _jobHandler.UnitCompleted += (x, unit) => { _speech.SpeakInfo(String.Format("{0} Units Completed.", unit + 1)); _eventLogger.Log(String.Format("{0} Units Completed.", unit + 1)); @@ -1299,7 +1400,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Saves the active job. /// - private async void SaveActiveJob() + private void SaveActiveJob() { if (ActiveJob != null) { @@ -1310,7 +1411,7 @@ namespace Tango.MachineStudio.Developer.ViewModels ActiveJob.Rml = SelectedRML; ActiveJob.EstimatedDurationMili = (int)EstimatedDuration.TotalMilliseconds; - await ActiveJob.SaveAsync(_activeJobDbContext); + _activeJobDbContext.SaveChanges(); ReloadMachine(); SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == ActiveJob.Guid); } @@ -1836,7 +1937,5 @@ namespace Tango.MachineStudio.Developer.ViewModels } #endregion - - } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index b4deb72a9..e350f966b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -5,7 +5,10 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:global="clr-namespace:Tango.MachineStudio.Developer" xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:brushPicker="clr-namespace:Tango.BrushPicker;assembly=Tango.BrushPicker" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:colorConversion="clr-namespace:Tango.BL.ColorConversion;assembly=Tango.BL" + xmlns:hive="clr-namespace:Tango.Hive;assembly=Tango.Hive" xmlns:automation="clr-namespace:Tango.MachineStudio.Common.Automation;assembly=Tango.MachineStudio.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:techViews="clr-namespace:Tango.MachineStudio.Technician.Views;assembly=Tango.MachineStudio.Technician" @@ -66,6 +69,7 @@ + @@ -136,7 +140,7 @@ - + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index b48e91f31..bb17a502d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -242,5 +242,28 @@ namespace Tango.MachineStudio.Developer.Views editor.ParameterizedObject = draggedItem.ParameterizedObject; } } + + private void PopupButton_Checked(object sender, RoutedEventArgs e) + { + _vm.OnHivePopupOpened(); + } + + private void BrushPicker_ColorChanged(object sender, BrushPicker.ColorChangedEventArgs e) + { + + } + + private void ColorCanvas_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (e.NewValue.HasValue) + { + _vm.OnSelectedBrushColorChanged((Color)e.NewValue); + } + } + + private void PopupButton_Unchecked(object sender, RoutedEventArgs e) + { + _vm.OnHivePopupClosed(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs index 2bb96c1e5..2b12b1670 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs @@ -173,6 +173,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedLog != null) { _notification.ShowModalDialog(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); + SelectedLog = null; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs index ba18cbdb1..1895dd230 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs @@ -175,6 +175,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedLog != null) { _notification.ShowModalDialog(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); + SelectedLog = null; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs index c4f391c55..98fcf12db 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs @@ -181,6 +181,7 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted) { _notification.ShowModalDialog(new EventDetailsViewVM(SelectedEvent), (x) => { }, () => { }); + SelectedEvent = null; } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 77fad1fc6..96715dc20 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -15,6 +15,8 @@ namespace Tango.MachineStudio.Common /// public abstract class StudioViewModelInternal : ViewModel, IStudioViewModel { + public bool IsVisible { get; private set; } + /// /// Gets or sets a value indicating whether this view model studio module is currently loaded. /// @@ -42,6 +44,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedFrom() { + IsVisible = false; IsModuleLoaded = false; } @@ -50,6 +53,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedTo() { + IsVisible = true; IsModuleLoaded = true; } @@ -88,6 +92,8 @@ namespace Tango.MachineStudio.Common /// public abstract class StudioViewModel : ViewModel, IStudioViewModel where Module : IStudioModule { + public bool IsVisible { get; private set; } + /// /// Gets or sets a value indicating whether this view model studio module is currently loaded. /// @@ -115,6 +121,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedFrom() { + IsVisible = false; IsModuleLoaded = false; } @@ -123,6 +130,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedTo() { + IsVisible = true; IsModuleLoaded = true; } @@ -149,7 +157,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnApplicationStarted() { - + } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt index a112fbafb..4e5321cc7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt @@ -1 +1 @@ -Mon 07/16/2018 15:39:26.63 +Mon 07/16/2018 19:59:53.31 diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs index e5144386a..29e517695 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs @@ -267,6 +267,11 @@ namespace Tango.BL.Entities cloned.WindingMethod = WindingMethod; cloned.Segments = Segments.Select(x => x.Clone(cloned)).ToObservableCollection(); + foreach (var segment in cloned.Segments) + { + segment.JobGuid = cloned.Guid; + segment.Job = cloned; + } return cloned; } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs index 4b7c11272..634047f24 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs @@ -137,6 +137,12 @@ namespace Tango.BL.Entities cloned.BrushStops = BrushStops.Select(x => x.Clone()).ToObservableCollection(); + foreach (var stop in cloned.BrushStops) + { + stop.SegmentGuid = cloned.Guid; + stop.Segment = cloned; + } + return cloned; } diff --git a/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs b/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs index 5c834dcdf..d3bd2e372 100644 --- a/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs +++ b/Software/Visual_Studio/Tango.BrushPicker/Implementation/BrushPicker.cs @@ -553,10 +553,13 @@ namespace Tango.BrushPicker c.G = color.G; c.B = color.B; + if (e.OldValue != e.NewValue) + { + c.RaiseColorChangedEvent((Color)e.NewValue); + } + c._RGBSetInternally = false; } - - c.RaiseColorChangedEvent((Color)e.NewValue); } } diff --git a/Software/Visual_Studio/Versioning/MachineStudio.cs b/Software/Visual_Studio/Versioning/MachineStudio.cs index 072b392db..6aac33a9c 100644 --- a/Software/Visual_Studio/Versioning/MachineStudio.cs +++ b/Software/Visual_Studio/Versioning/MachineStudio.cs @@ -9,5 +9,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © Twine LTD 2017")] [assembly: AssemblyTrademark("Twine LTD")] -[assembly: AssemblyVersion("1.0.0.14")] -[assembly: AssemblyFileVersion("1.0.0.14")] +[assembly: AssemblyVersion("1.0.0.15")] +[assembly: AssemblyFileVersion("1.0.0.15")] -- cgit v1.3.1