aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-18 12:54:12 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-18 12:54:12 +0200
commitfd2641e5aa4e915cc133310bd87d21278b84e50b (patch)
tree8ec40d665967281db7617d0b8a0cc785913a32ed /Software/Visual_Studio/MachineStudio
parent2836f1031bf9c1414a80620e040c1414a45c1648 (diff)
downloadTango-fd2641e5aa4e915cc133310bd87d21278b84e50b.tar.gz
Tango-fd2641e5aa4e915cc133310bd87d21278b84e50b.zip
Working on machine events !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs93
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wavbin0 -> 146748 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/warning.pngbin0 -> 2121 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj3
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml10
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml42
9 files changed, 131 insertions, 23 deletions
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 920dfd922..c165552d1 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
@@ -356,5 +356,8 @@
<ItemGroup>
<Resource Include="Images\seamless-grid.jpg" />
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="error.wav" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ 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 4a16be957..f455faa9e 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
@@ -56,6 +56,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
private ObservablesContext _activeJobDbContext;
private SpeechSynthesizer _speech;
private SoundPlayer _soundPlayer;
+ private SoundPlayer _soundPlayerErr;
#region Properties
@@ -629,6 +630,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
_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...
@@ -644,7 +646,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null);
SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null);
DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null);
- StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning && MachineOperator != null);
+ StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution)));
StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning);
CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar);
LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null);
@@ -671,6 +673,25 @@ namespace Tango.MachineStudio.Developer.ViewModels
private void ApplicationManager_ConnectedMachineChanged(object sender, IExternalBridgeClient machine)
{
MachineOperator = machine;
+
+ if (MachineOperator != null)
+ {
+ MachineOperator.MachineEventsStateProvider.EventsChanged -= MachineEventsStateProvider_EventsChanged;
+ MachineOperator.MachineEventsStateProvider.EventsChanged += MachineEventsStateProvider_EventsChanged;
+
+ MachineOperator.MachineEventsStateProvider.NewEvents -= MachineEventsStateProvider_NewEvents;
+ MachineOperator.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents;
+ }
+ }
+
+ private void MachineEventsStateProvider_NewEvents(object sender, IEnumerable<MachinesEvent> events)
+ {
+ HandleNewHardwareEvents(events);
+ }
+
+ private void MachineEventsStateProvider_EventsChanged(object sender, IEnumerable<MachinesEvent> changedEvents)
+ {
+ InvokeUI(StartJobCommand.RaiseCanExecuteChanged);
}
/// <summary>
@@ -714,6 +735,42 @@ namespace Tango.MachineStudio.Developer.ViewModels
#endregion
+ #region Hardware Events
+
+ private void HandleNewHardwareEvents(IEnumerable<MachinesEvent> events)
+ {
+ if (IsJobRunning)
+ {
+ SpeakError(events.Last().EventType.Name);
+
+ if (events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.AbortRunningJob)))
+ {
+ if (_jobHandler != null)
+ {
+ InvokeUI(StopJob);
+ }
+ }
+ }
+ }
+
+ #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>
@@ -895,12 +952,14 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
private void SetJobFailed()
{
- LogManager.Log("Setting job failed state...");
- IsJobRunning = false;
- IsJobFailed = true;
+ if (IsJobRunning)
+ {
+ LogManager.Log("Setting job failed state...");
+ IsJobRunning = false;
+ IsJobFailed = true;
- _soundPlayer.Play();
- _speech.SpeakAsync("Job Failed!");
+ SpeakError("Job Failed!");
+ }
}
/// <summary>
@@ -911,8 +970,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Setting job completed state...");
IsJobRunning = false;
IsJobCompleted = true;
- _soundPlayer.Play();
- _speech.SpeakAsync("Job Completed!");
+ SpeakInfo("Job Completed!");
}
/// <summary>
@@ -955,11 +1013,20 @@ namespace Tango.MachineStudio.Developer.ViewModels
_jobHandler.StatusReceived += (x, status) =>
{
- RunningJobRemainingTime = _runningJobEstimatedDuration - TimeSpan.FromSeconds(RunningJobProgress / (SelectedProcessParametersTable.DyeingSpeed / 100d));
- RunningJobProgress = status.Progress;
+ if (IsJobRunning)
+ {
+
+ RunningJobRemainingTime = _runningJobEstimatedDuration - TimeSpan.FromSeconds(RunningJobProgress / (SelectedProcessParametersTable.DyeingSpeed / 100d));
+ RunningJobProgress = status.Progress;
+ }
foreach (var segment in RunningJobSegments)
{
+ if (!IsJobRunning)
+ {
+ break;
+ }
+
var previousSegmentsWithThis = RunningJobSegments.Where(s => RunningJobSegments.IndexOf(s) <= RunningJobSegments.IndexOf(segment)).ToList();
var segmentsDuration = TimeSpan.FromSeconds(previousSegmentsWithThis.Sum(s => s.Length) / (SelectedProcessParametersTable.DyeingSpeed / 100d));
var segmentDuration = TimeSpan.FromSeconds(segment.Length / (SelectedProcessParametersTable.DyeingSpeed / 100d));
@@ -973,15 +1040,14 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (!segment.Started)
{
segment.Started = true;
- _soundPlayer.Play();
if (segment.ID != -1)
{
- _speech.SpeakAsync(String.Format("Segment {0} Started.", segment.SegmentIndex));
+ SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
}
else
{
- _speech.SpeakAsync(String.Format("Inter Segment Started."));
+ SpeakInfo(String.Format("Inter Segment Started."));
}
}
}
@@ -1052,6 +1118,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
new BrushStop()
{
+ ColorSpace = ColorSpaces.Single(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()),
Color = Colors.White,
}
},
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav
new file mode 100644
index 000000000..4dce7d623
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml
index 6257fa2af..f704661cf 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml
@@ -88,7 +88,7 @@
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="30" FontStyle="Italic" VerticalAlignment="Center" Margin="50 10 10 0" Foreground="Silver" FontWeight="Bold">MACHINE DESIGNER</TextBlock>
<StackPanel Orientation="Horizontal" Margin="20 10 0 0" VerticalAlignment="Center">
- <fa:ImageAwesome Icon="Key" Width="24" Height="24" Foreground="Silver"></fa:ImageAwesome>
+ <materialDesign:PackIcon Kind="BarcodeScan" VerticalAlignment="Bottom" Width="24" Height="24" Foreground="Silver"></materialDesign:PackIcon>
<autoComplete:AutoCompleteTextBox FontSize="16" FontWeight="Bold" FontStyle="Italic" Width="300" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Enter serial number" DisplayMember="SerialNumber" Provider="{StaticResource ResourceKey=MachinesProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}">
<autoComplete:AutoCompleteTextBox.ItemTemplate>
<DataTemplate>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
index 3763a06b4..b4015b297 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
@@ -71,6 +71,7 @@ namespace Tango.MachineStudio.Common.EventLogging
_db.Configuration.LazyLoadingEnabled = false;
_db.ActionTypes.ToList();
+ _db.EventTypesActions.ToList();
_db.EventTypesCategories.ToList();
_db.EventTypesGroups.ToList();
_db.EventTypes.ToList();
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/warning.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/warning.png
new file mode 100644
index 000000000..a845b1226
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/warning.png
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
index 95c2a9925..0a92f2c91 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
@@ -424,6 +424,9 @@
<ItemGroup>
<Resource Include="Images\error-message.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\warning.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Debug $(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Machine Studio.lnk"
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml
index 83a6eece6..b988d0a76 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml
@@ -8,7 +8,7 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:vm="clr-namespace:Tango.MachineStudio.UI.ViewModels"
xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views"
- mc:Ignorable="d" Width="600" Height="400" Background="White" d:DataContext="{d:DesignInstance Type=vm:MachineSerialViewVM, IsDesignTimeCreatable=False}">
+ mc:Ignorable="d" Width="559" Height="266" Background="White" d:DataContext="{d:DesignInstance Type=vm:MachineSerialViewVM, IsDesignTimeCreatable=False}">
<UserControl.Resources>
<autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" />
@@ -36,15 +36,15 @@
<Grid>
<StackPanel Margin="0 10 0 0" >
- <TextBlock TextWrapping="Wrap" TextAlignment="Center">
+ <TextBlock TextWrapping="Wrap">
<Run>Connecting directly to a machine's embedded firmware requires the selection of an existing machine from the database in order for machine studio to function properly.</Run>
<LineBreak/>
<LineBreak/>
<Run>Please select a 'virtual machine' by entering the machine serial number</Run>
</TextBlock>
- <StackPanel Orientation="Horizontal" Margin="0 80 0 0" Width="300">
- <materialDesign:PackIcon Kind="Key" Width="24" Height="24" />
+ <StackPanel Orientation="Horizontal" Margin="0 20 0 0" Width="300" HorizontalAlignment="Left">
+ <materialDesign:PackIcon Kind="BarcodeScan" VerticalAlignment="Bottom" Width="24" Height="24" />
<autoComplete:AutoCompleteTextBox HorizontalContentAlignment="Stretch" Width="300" Margin="10 0 0 0" FontSize="16" Provider="{StaticResource MachinesProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" materialDesign:HintAssist.Hint="Serial Number / Name" DisplayMember="SerialNumber">
<autoComplete:AutoCompleteTextBox.ItemTemplate>
<DataTemplate>
@@ -65,7 +65,7 @@
</Grid>
<Grid Grid.Row="1">
- <Button HorizontalAlignment="Right" Width="140" Command="{Binding OKCommand}">OK</Button>
+ <Button HorizontalAlignment="Right" Width="140" Command="{Binding OKCommand}">CONNECT</Button>
</Grid>
</Grid>
</Grid>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml
index beade3d88..b7a4cc93f 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml
@@ -21,6 +21,7 @@
<converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" />
<converters:NullObjectToBooleanConverter x:Key="NullObjectToBooleanConverter" />
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
+ <converters:StringToWordsConverter x:Key="StringToWordsConverter" />
</UserControl.Resources>
<Grid>
@@ -234,7 +235,37 @@
<Run>hardware messages</Run>
</TextBlock>
</ToggleButton.ToolTip>
- <Image Source="/Images/error-message.png" Width="32" />
+ <Grid RenderTransformOrigin="0.5,0.5">
+ <Grid.Style>
+ <Style TargetType="Grid">
+ <Setter Property="Opacity" Value="1"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding ApplicationManager.ConnectedMachine.MachineEventsStateProvider.HasEvents}" Value="True">
+ <DataTrigger.EnterActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Duration="00:00:01" RepeatBehavior="Forever">
+ <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="1" />
+ <DiscreteDoubleKeyFrame KeyTime="00:00:0.5" Value="0" />
+ </DoubleAnimationUsingKeyFrames>
+ </Storyboard>
+ </BeginStoryboard>
+ </DataTrigger.EnterActions>
+ <DataTrigger.ExitActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Duration="00:00:00">
+ <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="1" />
+ </DoubleAnimationUsingKeyFrames>
+ </Storyboard>
+ </BeginStoryboard>
+ </DataTrigger.ExitActions>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Grid.Style>
+ <Image Source="/Images/warning.png" Width="50" />
+ </Grid>
</ToggleButton>
<Button Style="{StaticResource emptyButton}" Cursor="Hand" Command="{Binding UpdateCenterCommand}" Visibility="{Binding IsUpdateAvailable,Converter={StaticResource BooleanToVisibilityConverter}}">
@@ -397,7 +428,7 @@
</Border>
<Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Visibility="{Binding IsMachineErrorsOpened,Converter={StaticResource BooleanToVisibilityConverter}}">
- <Border Width="350" Background="#ECFFFFFF" BorderBrush="White" CornerRadius="5" Padding="5">
+ <Border Width="350" Background="#FFF1F1F1" BorderBrush="White" CornerRadius="5" Padding="5">
<Border.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="10" />
</Border.Effect>
@@ -431,7 +462,10 @@
</materialDesign:PackIcon.Style>
</materialDesign:PackIcon>
- <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Text="{Binding EventType.Name}"></TextBlock>
+ <StackPanel Margin="10 0 0 0" VerticalAlignment="Top">
+ <TextBlock Text="{Binding EventType.Name}"></TextBlock>
+ <TextBlock Margin="0 5 0 0" Text="{Binding Description}" FontSize="10" Foreground="DimGray" TextWrapping="Wrap"></TextBlock>
+ </StackPanel>
</StackPanel>
</StackPanel>
</Border>
@@ -441,7 +475,7 @@
</Border>
<Canvas HorizontalAlignment="Center">
- <Polygon Points="12,0 0,35 24,35" Fill="#86FFFFFF" Canvas.Top="-35" Canvas.Left="95"></Polygon>
+ <Polygon Points="12,0 0,31 24,31" Fill="#FFF1F1F1" Canvas.Top="-30" Canvas.Left="90"></Polygon>
</Canvas>
</Grid>
</Grid>