From 4e48c569f1cae820ffade8a786354b2ba79b50b4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 6 Mar 2018 18:28:51 +0200 Subject: Some improvements on hive. --- .../Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 2 +- 1 file changed, 1 insertion(+), 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 566dc7a16..dfaeb7044 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 @@ -1710,7 +1710,7 @@ namespace Tango.MachineStudio.Developer.ViewModels Red = stop.Color.R, Green = stop.Color.G, Blue = stop.Color.B, - OffsetPercent = stop.Offset, + OffsetPercent = stop.Offset * 100d, ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()), }); } -- cgit v1.3.1 From ba06627369df7c7eebc38fbefc22f2f78124f33a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 8 Mar 2018 18:39:11 +0200 Subject: Improved performance of generic protobuf message decoding.. --- .../ViewModels/MainViewVM.cs | 22 ++----------------- Software/Visual_Studio/Tango.PMR/MessageFactory.cs | 25 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 22 deletions(-) (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 dfaeb7044..b2dded955 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 @@ -40,7 +40,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Represents the developer module main view, view model. /// /// - public class MainViewVM : ViewModel, IShutdownRequestBlocker, IShutdownListener + public class MainViewVM : ViewModel, IShutdownRequestBlocker, IShutdownListener { private static object _syncLock = new object(); private const string EMB_FORMATS_EXPORT = "Baby Lock (PES)|*.pes|Tajima (DST)|*.dst|EXP|*.exp|PCS|*.pcs|HUS|*.hus|KSM|*.ksm"; @@ -593,21 +593,12 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Constructors - /// - /// Initializes a new instance of the class. - /// - public MainViewVM(IMainView view) : base(view, true) - { - - } - /// /// Initializes a new instance of the class. /// /// The application manager. /// The notification provider. - [PreferredConstructor] - public MainViewVM(IMainView view, IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this(view) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) { SelectedJobs = new ObservableCollection(); @@ -1799,14 +1790,5 @@ namespace Tango.MachineStudio.Developer.ViewModels } #endregion - - #region IMainView - - protected override void OnViewAttached() - { - base.OnViewAttached(); - } - - #endregion } } diff --git a/Software/Visual_Studio/Tango.PMR/MessageFactory.cs b/Software/Visual_Studio/Tango.PMR/MessageFactory.cs index 2c4eb3d13..b1d2a7c55 100644 --- a/Software/Visual_Studio/Tango.PMR/MessageFactory.cs +++ b/Software/Visual_Studio/Tango.PMR/MessageFactory.cs @@ -14,6 +14,27 @@ namespace Tango.PMR /// public static class MessageFactory { + private static Dictionary _pmrTypes; + private static MethodInfo _parseTangoMessageMethod; + + static MessageFactory() + { + _parseTangoMessageMethod = typeof(MessageFactory).GetMethod("ParseTangoMessage", BindingFlags.Public | BindingFlags.Static); + + _pmrTypes = new Dictionary(); + var types = typeof(MessageFactory).Assembly.GetTypes().ToList(); + + foreach (var value in Enum.GetValues(typeof(MessageType)).OfType()) + { + var type = types.SingleOrDefault(x => x.Name == value.ToOriginalName()); + + if (type != null) + { + _pmrTypes.Add(value, type); + } + } + } + /// /// Creates a new . /// @@ -98,7 +119,7 @@ namespace Tango.PMR { MessageContainer container = MessageContainer.Parser.ParseFrom(data); IMessage message = ExtractMessageFromContainer(container); - return (ITangoMessage)typeof(MessageFactory).GetMethod("ParseTangoMessage",BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(message.GetType()).Invoke(null, new[] { data }); + return (ITangoMessage)_parseTangoMessageMethod.MakeGenericMethod(message.GetType()).Invoke(null, new[] { data }); } /// @@ -121,7 +142,7 @@ namespace Tango.PMR /// public static IMessage ExtractMessageFromContainer(MessageContainer container) { - var type = typeof(MessageFactory).Assembly.GetTypes().ToList().SingleOrDefault(x => x.Name == container.Type.ToOriginalName()); + var type = _pmrTypes[container.Type]; MessageParser parser = type.GetProperty("Parser").GetValue(container) as MessageParser; return parser.ParseFrom(container.Data); } -- cgit v1.3.1