aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-11-26 18:02:02 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-11-26 18:02:02 +0200
commitd3b9770dd5e1d34e9433a115cbed5ef1a53546f6 (patch)
tree0c3a48ae71edc947956c10fea8a411ad80564f34 /Software/Visual_Studio/PPC
parent6fb22273d15ed476ccbd3820de6af9bc0deee793 (diff)
downloadTango-d3b9770dd5e1d34e9433a115cbed5ef1a53546f6.tar.gz
Tango-d3b9770dd5e1d34e9433a115cbed5ef1a53546f6.zip
Working on PPC event notifications.
Diffstat (limited to 'Software/Visual_Studio/PPC')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs58
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs24
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs7
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs9
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml2
8 files changed, 101 insertions, 5 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
index 7ee99bc14..af2e44615 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
@@ -4,8 +4,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
+using Tango.BL.Enumerations;
using Tango.Integration.Operation;
using Tango.PPC.Common;
+using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Notifications.NotificationItems;
using Tango.PPC.Jobs.NavigationObjects;
using Tango.PPC.Jobs.Views;
@@ -18,6 +20,13 @@ namespace Tango.PPC.Jobs.ViewModels
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class MainViewVM : PPCViewModel
{
+ private Dictionary<EventTypes, NotificationItem> _notifications;
+
+ public MainViewVM() : base()
+ {
+ _notifications = new Dictionary<EventTypes, NotificationItem>();
+ }
+
/// <summary>
/// Called when the application has been started.
/// </summary>
@@ -25,6 +34,8 @@ namespace Tango.PPC.Jobs.ViewModels
{
MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted;
MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed;
+ MachineProvider.MachineOperator.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents;
+ MachineProvider.MachineOperator.MachineEventsStateProvider.EventsResolved += MachineEventsStateProvider_EventsResolved;
}
/// <summary>
@@ -77,5 +88,52 @@ namespace Tango.PPC.Jobs.ViewModels
}));
}
}
+
+ private void MachineEventsStateProvider_NewEvents(object sender, IEnumerable<MachinesEvent> events)
+ {
+ foreach (var item in events)
+ {
+ var notificationItem = new MessageNotificationItem();
+ notificationItem.CanClose = false;
+ notificationItem.Message = item.EventType.Description;
+ notificationItem.ExpandedMessage = item.Description;
+ notificationItem.Pressed += (_, __) =>
+ {
+ NotificationProvider.ShowInfo($"{item.EventType.Description} Selected !");
+ };
+
+ switch (item.Category)
+ {
+ case EventTypesCategories.Info:
+ notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Info;
+ break;
+ case EventTypesCategories.Warning:
+ notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Warning;
+ break;
+ case EventTypesCategories.Error:
+ notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Error;
+ break;
+ case EventTypesCategories.Critical:
+ notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Error;
+ break;
+ }
+
+ NotificationProvider.PushNotification(notificationItem);
+ _notifications.Add(item.EventType.Type, notificationItem);
+ }
+ }
+
+ private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> events)
+ {
+ foreach (var item in events)
+ {
+ if (_notifications.ContainsKey(item.EventType.Type))
+ {
+ var notification = _notifications[item.EventType.Type];
+ _notifications.Remove(item.EventType.Type);
+ NotificationProvider.PopNotification(notification);
+ }
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
index a4932eafc..5d2124113 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
@@ -87,6 +87,8 @@ namespace Tango.PPC.Common.Connection
public DefaultMachineProvider()
{
MachineOperator = new MachineOperator();
+ MachineOperator.EnableEventsNotification = true;
+ MachineOperator.EnableJobResume = true;
}
/// <summary>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs
index 1fdf0c729..c96fe9dee 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs
@@ -14,6 +14,14 @@ namespace Tango.PPC.Common.Notifications
/// </summary>
public abstract class NotificationItem : ItemBase
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="NotificationItem"/> class.
+ /// </summary>
+ public NotificationItem() : base()
+ {
+ CanClose = true;
+ }
+
private bool _isExpanded;
/// <summary>
/// Gets or sets a value indicating whether the notification panel is expanded.
@@ -24,13 +32,27 @@ namespace Tango.PPC.Common.Notifications
set { _isExpanded = value; RaisePropertyChangedAuto(); }
}
+ private bool _canClose;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance can close.
+ /// </summary>
+ public bool CanClose
+ {
+ get { return _canClose; }
+ set { _canClose = value; RaisePropertyChangedAuto(); }
+ }
+
/// <summary>
/// Called when the item has been pressed.
/// </summary>
protected override void OnPreesed()
{
base.OnPreesed();
- Close();
+
+ if (CanClose)
+ {
+ Close();
+ }
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml
index 9b583a117..dbd9a0eca 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml
@@ -54,7 +54,7 @@
<StackPanel Margin="10 0 0 0" VerticalAlignment="Center">
<TextBlock Text="{Binding Message}" TextTrimming="CharacterEllipsis" TextWrapping="Wrap"></TextBlock>
- <TextBlock Margin="0 20 0 0" Text="{Binding ExpandedMessage}" TextWrapping="Wrap" Visibility="{Binding IsExpanded,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock>
+ <TextBlock Margin="5 20 0 0" Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding ExpandedMessage}" TextWrapping="Wrap" Visibility="{Binding IsExpanded,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock>
</StackPanel>
</DockPanel>
</ContentControl>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
index 3393689d1..dc67d2137 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
@@ -9,6 +9,7 @@ using Tango.PPC.Common.Application;
using Tango.PPC.Common.Authentication;
using Tango.PPC.Common.Connection;
using Tango.PPC.Common.Connectivity;
+using Tango.PPC.Common.EventLogging;
using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.Navigation;
using Tango.PPC.Common.Notifications;
@@ -88,6 +89,12 @@ namespace Tango.PPC.Common
[TangoInject]
public IStorageProvider StorageProvider { get; set; }
+ /// <summary>
+ /// Gets or sets the event logger.
+ /// </summary>
+ [TangoInject]
+ public IEventLogger EventLogger { get; set; }
+
private PPCSettings _settings;
/// <summary>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
index 4021d89ef..957a4ee1d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -24,6 +24,8 @@ using System.Data.SqlClient;
using Tango.BL.Builders;
using Tango.PPC.Common.Threading;
using System.Diagnostics;
+using Tango.PPC.Common.EventLogging;
+using Tango.BL.Enumerations;
namespace Tango.PPC.UI.PPCApplication
{
@@ -38,6 +40,7 @@ namespace Tango.PPC.UI.PPCApplication
private IMachineProvider _machineProvider;
private Machine _machine;
private IDispatcherProvider _dispatcher;
+ private IEventLogger _eventLogger;
/// <summary>
/// Occurs when the application has started.
@@ -99,10 +102,12 @@ namespace Tango.PPC.UI.PPCApplication
/// <summary>
/// Initializes a new instance of the <see cref="DefaultPPCApplicationManager"/> class.
/// </summary>
- public DefaultPPCApplicationManager(IMachineProvider machineProvider, IDispatcherProvider dispatcherProvider)
+ public DefaultPPCApplicationManager(IMachineProvider machineProvider, IDispatcherProvider dispatcherProvider, IEventLogger eventLogger)
{
_machineProvider = machineProvider;
_dispatcher = dispatcherProvider;
+ _eventLogger = eventLogger;
+ ;
if (!DesignMode)
{
@@ -166,6 +171,8 @@ namespace Tango.PPC.UI.PPCApplication
_machine = new MachineBuilder(ObservablesContext.CreateDefault()).SetFirst().WithOrganization().WithConfiguration().Build();
}
+ _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
+
initialized = true;
}
catch (Exception ex)
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
index 4bf83242f..11751d822 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
@@ -68,10 +68,10 @@ namespace Tango.PPC.UI
TangoIOC.Default.Register<IPPCModuleLoader, DefaultPPCModuleLoader>();
TangoIOC.Default.Register<INavigationManager, DefaultNavigationManager>();
TangoIOC.Default.Register<IMachineProvider, DefaultMachineProvider>();
+ TangoIOC.Default.Register<IEventLogger, DefaultEventLogger>();
TangoIOC.Default.Register<IPPCApplicationManager, DefaultPPCApplicationManager>();
TangoIOC.Default.Register<ExternalBridgeScanner, ExternalBridgeScanner>();
TangoIOC.Default.Register<IDiagnosticsFrameProvider, DefaultDiagnosticsFrameProvider>();
- TangoIOC.Default.Register<IEventLogger, DefaultEventLogger>();
TangoIOC.Default.Register<IPPCExternalBridgeService, PPCExternalBridgeService>();
TangoIOC.Default.Register<IMachineSetupManager, MachineSetupManager>();
TangoIOC.Default.Register<IMachineUpdateManager, MachineUpdateManager>();
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
index 4ca7e39ec..8d438aa8f 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
@@ -32,7 +32,7 @@
<DataTemplate>
<touch:TouchButton Style="{StaticResource TangoFlatButton}" Padding="0" Command="{Binding PressedCommand}" components:TransformationHelper.TransformWhenPressed="False">
<DockPanel>
- <touch:TouchIconButton DockPanel.Dock="Right" Background="Transparent" Padding="20" Style="{StaticResource TangoRoundTouchIconButton}" Command="{Binding CloseCommand}" CommandParameter="{Binding}" HorizontalAlignment="Right" MaxHeight="60" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" Icon="Close" Foreground="White" />
+ <touch:TouchIconButton Visibility="{Binding CanClose,Converter={StaticResource BooleanToVisibilityConverter}}" DockPanel.Dock="Right" Background="Transparent" Padding="20" Style="{StaticResource TangoRoundTouchIconButton}" Command="{Binding CloseCommand}" CommandParameter="{Binding}" HorizontalAlignment="Right" MaxHeight="60" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" Icon="Close" Foreground="White" />
<ContentControl Content="{Binding Converter={StaticResource ItemBaseConverter}}"/>
</DockPanel>
</touch:TouchButton>