aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs66
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml83
2 files changed, 112 insertions, 37 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 7891f96b7..cdfeee54d 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
@@ -34,6 +34,7 @@ using Tango.Core.Helpers;
using System.Speech.Synthesis;
using System.Media;
using Tango.MachineStudio.Common.EventLogging;
+using Tango.MachineStudio.Common.Speech;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -55,10 +56,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
private IAuthenticationProvider _authentication;
private ObservablesContext _machineDbContext;
private ObservablesContext _activeJobDbContext;
- private SpeechSynthesizer _speech;
- private SoundPlayer _soundPlayer;
- private SoundPlayer _soundPlayerErr;
private IEventLogger _eventLogger;
+ private ISpeechProvider _speech;
#region Properties
@@ -112,7 +111,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
set { _spoolTypes = value; RaisePropertyChangedAuto(); }
}
-
/// <summary>
/// Gets or sets the application manager.
/// </summary>
@@ -473,6 +471,16 @@ namespace Tango.MachineStudio.Developer.ViewModels
set { _jobFilter = value; RaisePropertyChangedAuto(); OnJobFilterChanged(); }
}
+ private ObservableCollection<MachinesEvent> _jobEvents;
+ /// <summary>
+ /// Gets or sets the running job events.
+ /// </summary>
+ public ObservableCollection<MachinesEvent> JobEvents
+ {
+ get { return _jobEvents; }
+ set { _jobEvents = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Commands
@@ -600,10 +608,12 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
/// <param name="applicationManager">The application manager.</param>
/// <param name="notificationProvider">The notification provider.</param>
- public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger)
+ public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech)
{
SelectedJobs = new ObservableCollection<Job>();
+ JobEvents = new ObservableCollection<MachinesEvent>();
+
LogManager.Log("Initializing machine Db context...");
_machineDbContext = ObservablesContext.CreateDefault();
@@ -624,6 +634,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
_authentication = authentication;
_notification = notificationProvider;
+ _speech = speech;
_navigation = navigation;
ApplicationManager = applicationManager;
VideoCaptureProvider = videoCaptureProvider;
@@ -631,11 +642,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Initializing relay commands...");
- _speech = new SpeechSynthesizer();
- _soundPlayer = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Developer.bip.wav"));
- _soundPlayerErr = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Developer.error.wav"));
- _speech.SelectVoice(_speech.GetInstalledVoices().LastOrDefault(x => x.VoiceInfo.Gender == VoiceGender.Female).VoiceInfo.Name);
-
//Initialize Commands...
EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null);
EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null);
@@ -662,12 +668,25 @@ namespace Tango.MachineStudio.Developer.ViewModels
DisplayJobEmbroideryFileCommand = new RelayCommand<Job>(DisplayJobEmbroideryFile);
ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
+
+ _eventLogger.NewLog += _eventLogger_NewLog;
}
#endregion
#region Event Handlers
+ private void _eventLogger_NewLog(object sender, MachinesEvent e)
+ {
+ if (IsJobRunning)
+ {
+ InvokeUI(() =>
+ {
+ JobEvents.Add(e);
+ });
+ }
+ }
+
/// <summary>
/// Handles the application manager connected machine changes event.
/// </summary>
@@ -744,7 +763,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
if (IsJobRunning)
{
- SpeakError(events.Last().EventType.Name);
+ _speech.SpeakError(events.Last().EventType.Name);
if (events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.AbortRunningJob)))
{
@@ -758,22 +777,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
#endregion
- #region Sound
-
- private void SpeakInfo(String text)
- {
- _soundPlayer.Play();
- _speech.SpeakAsync(text);
- }
-
- private void SpeakError(String text)
- {
- _soundPlayerErr.Play();
- _speech.SpeakAsync(text);
- }
-
- #endregion
-
#region Properties Changes
/// <summary>
@@ -961,7 +964,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
IsJobRunning = false;
IsJobFailed = true;
- SpeakError("Job Failed!");
+ _speech.SpeakError("Job Failed!");
}
}
@@ -973,7 +976,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Setting job completed state...");
IsJobRunning = false;
IsJobCompleted = true;
- SpeakInfo("Job Completed!");
+ _speech.SpeakInfo("Job Completed!");
}
/// <summary>
@@ -994,6 +997,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
return;
}
+ JobEvents.Clear();
RunningJobRemainingTime = TimeSpan.Zero;
RunningJobProgress = 0;
IsJobFailed = false;
@@ -1048,12 +1052,12 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (segment.ID != -1)
{
- SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
+ _speech.SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
_eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex));
}
else
{
- SpeakInfo(String.Format("Inter Segment Started."));
+ _speech.SpeakInfo(String.Format("Inter Segment Started."));
_eventLogger.Log("Inter Segment Started.");
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml
index 30941f3dd..94570196f 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml
@@ -3,12 +3,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels"
xmlns:global="clr-namespace:Tango.MachineStudio.Developer"
xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
+
+ <UserControl.Resources>
+ <converters:DateTimeUTCToStringConverter x:Key="DateTimeUTCToStringConverter" />
+ </UserControl.Resources>
+
<Grid>
<Grid Margin="40">
<DockPanel>
@@ -29,13 +35,78 @@
</Grid>
<Grid>
- <DataGrid Background="Transparent" Margin="0 20 0 0" BorderThickness="1" BorderBrush="Gainsboro">
+ <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding JobEvents}" SelectedItem="{Binding SelectedJobEvent}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" IsReadOnly="True">
+ <DataGrid.RowStyle>
+ <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
+ <Style.Triggers>
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" />
+ <Setter Property="Cursor" Value="Hand"></Setter>
+ </Trigger>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ <Trigger Property="IsFocused" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </DataGrid.RowStyle>
+ <DataGrid.CellStyle>
+ <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
+ <Setter Property="BorderThickness" Value="0"/>
+ <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
+ <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+ <Style.Triggers>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </DataGrid.CellStyle>
<DataGrid.Columns>
- <DataGridTextColumn Width="Auto" Header="#"/>
- <DataGridTextColumn Width="200" Header="TIME STAMP"/>
- <DataGridTextColumn Width="100" Header="CODE"/>
- <DataGridTextColumn Width="200" Header="NAME"/>
- <DataGridTextColumn Width="1*" Header="DESCRIPTION"/>
+ <DataGridTemplateColumn Header="#">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <materialDesign:PackIcon Width="16" Height="16">
+ <materialDesign:PackIcon.Style>
+ <Style TargetType="materialDesign:PackIcon">
+ <Setter Property="Kind" Value="Alert"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Category}" Value="Info">
+ <Setter Property="Kind" Value="Information"></Setter>
+ <Setter Property="Foreground" Value="DimGray"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Category}" Value="Warning">
+ <Setter Property="Kind" Value="Alert"></Setter>
+ <Setter Property="Foreground" Value="#FFA300"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Category}" Value="Error">
+ <Setter Property="Kind" Value="AlertOctagon"></Setter>
+ <Setter Property="Foreground" Value="#FF5C5C"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Category}" Value="Critical">
+ <Setter Property="Kind" Value="BellPlus"></Setter>
+ <Setter Property="Foreground" Value="Red"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </materialDesign:PackIcon.Style>
+ </materialDesign:PackIcon>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+ <DataGridTextColumn Header="DATE TIME" Binding="{Binding DateTime,Converter={StaticResource DateTimeUTCToStringConverter},ConverterParameter='MM/dd/yyyy HH:mm:ss.fff'}" />
+ <DataGridTextColumn Header="GROUP" Binding="{Binding EventType.EventTypesGroup.Name}" />
+ <DataGridTextColumn Header="EVENT" Binding="{Binding EventType.Name}" />
+ <DataGridTemplateColumn Header="MESSAGE" Width="1*">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding Description}" TextTrimming="CharacterEllipsis"></TextBlock>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>