aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
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/Modules
parent2836f1031bf9c1414a80620e040c1414a45c1648 (diff)
downloadTango-fd2641e5aa4e915cc133310bd87d21278b84e50b.tar.gz
Tango-fd2641e5aa4e915cc133310bd87d21278b84e50b.zip
Working on machine events !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-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
4 files changed, 84 insertions, 14 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>