aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-08 18:39:11 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-08 18:39:11 +0200
commitba06627369df7c7eebc38fbefc22f2f78124f33a (patch)
tree217cbc456affe5b39dd74ced2de48ae611ecb5c4 /Software/Visual_Studio
parent860c4f663dfdd2ba7676d7e02bf0509b30389cd5 (diff)
downloadTango-ba06627369df7c7eebc38fbefc22f2f78124f33a.tar.gz
Tango-ba06627369df7c7eebc38fbefc22f2f78124f33a.zip
Improved performance of generic protobuf message decoding..
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs22
-rw-r--r--Software/Visual_Studio/Tango.PMR/MessageFactory.cs25
2 files changed, 25 insertions, 22 deletions
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.
/// </summary>
/// <seealso cref="Tango.SharedUI.ViewModel" />
- public class MainViewVM : ViewModel<IMainView>, 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";
@@ -596,18 +596,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <summary>
/// Initializes a new instance of the <see cref="MainViewVM"/> class.
/// </summary>
- public MainViewVM(IMainView view) : base(view, true)
- {
-
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="MainViewVM"/> class.
- /// </summary>
/// <param name="applicationManager">The application manager.</param>
/// <param name="notificationProvider">The notification provider.</param>
- [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<Job>();
@@ -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
/// </summary>
public static class MessageFactory
{
+ private static Dictionary<MessageType, Type> _pmrTypes;
+ private static MethodInfo _parseTangoMessageMethod;
+
+ static MessageFactory()
+ {
+ _parseTangoMessageMethod = typeof(MessageFactory).GetMethod("ParseTangoMessage", BindingFlags.Public | BindingFlags.Static);
+
+ _pmrTypes = new Dictionary<MessageType, Type>();
+ var types = typeof(MessageFactory).Assembly.GetTypes().ToList();
+
+ foreach (var value in Enum.GetValues(typeof(MessageType)).OfType<MessageType>())
+ {
+ var type = types.SingleOrDefault(x => x.Name == value.ToOriginalName());
+
+ if (type != null)
+ {
+ _pmrTypes.Add(value, type);
+ }
+ }
+ }
+
/// <summary>
/// Creates a new <see cref="TangoMessage{T}"/>.
/// </summary>
@@ -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 });
}
/// <summary>
@@ -121,7 +142,7 @@ namespace Tango.PMR
/// <returns></returns>
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);
}