aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-04-12 12:47:19 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-04-12 12:47:19 +0300
commit9c0bad738d47742f39f2b02b240591653da6bc12 (patch)
treeb3cb5e2d15927f4b04d971998b156a8673863d4e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels
parent8926f5b786ba07b3c21a1ada6ed9939a41e247d5 (diff)
downloadTango-9c0bad738d47742f39f2b02b240591653da6bc12.tar.gz
Tango-9c0bad738d47742f39f2b02b240591653da6bc12.zip
Added changes to PMR hardware.
Implemented Start Job and Record. Fixed issue with logs timeline event width. Implemented 'Event Resolved' event to event logs.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs40
1 files changed, 39 insertions, 1 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 cdfeee54d..036b01e34 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
@@ -35,6 +35,7 @@ using System.Speech.Synthesis;
using System.Media;
using Tango.MachineStudio.Common.EventLogging;
using Tango.MachineStudio.Common.Speech;
+using Microsoft.Practices.ServiceLocation;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -58,6 +59,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
private ObservablesContext _activeJobDbContext;
private IEventLogger _eventLogger;
private ISpeechProvider _speech;
+ private DataCapture.ViewModels.MainViewVM _dataCaptureVM;
+ private bool _isRecording;
#region Properties
@@ -556,6 +559,11 @@ namespace Tango.MachineStudio.Developer.ViewModels
public RelayCommand StartJobCommand { get; set; }
/// <summary>
+ /// Gets or sets the start job and record command.
+ /// </summary>
+ public RelayCommand StartJobAndRecordCommand { get; set; }
+
+ /// <summary>
/// Gets or sets the stop job command.
/// </summary>
public RelayCommand StopJobCommand { get; set; }
@@ -642,6 +650,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Initializing relay commands...");
+ _dataCaptureVM = ServiceLocator.Current.GetInstance<DataCapture.ViewModels.MainViewVM>();
+ _dataCaptureVM.RelayCommandsInvalidated += (_, __) => StartJobAndRecordCommand.RaiseCanExecuteChanged();
+
//Initialize Commands...
EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null);
EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null);
@@ -656,6 +667,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null);
DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null);
StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution)));
+ StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && 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);
@@ -1053,7 +1065,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (segment.ID != -1)
{
_speech.SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
- _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex));
+ _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex) + Environment.NewLine + segment.ToJsonString());
}
else
{
@@ -1081,6 +1093,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
InvokeUI(() =>
{
_notification.ShowError("Job failed. " + ex.Message);
+ StopRecordingIfInProgress();
});
};
@@ -1089,12 +1102,14 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log(String.Format("Job {0} has completed.", RunningJob.Name));
_eventLogger.Log(String.Format("Job {0} has completed.", RunningJob.Name));
SetJobCompleted();
+ StopRecordingIfInProgress();
};
_jobHandler.Canceled += (x, y) =>
{
LogManager.Log(String.Format("Job {0} has been canceled.", RunningJob.Name));
_eventLogger.Log(String.Format("Job {0} has been canceled.", RunningJob.Name));
+ StopRecordingIfInProgress();
//Finally Canceled..
};
}
@@ -1104,6 +1119,29 @@ namespace Tango.MachineStudio.Developer.ViewModels
_eventLogger.Log(ex, "An error occurred while starting the job.");
_notification.ShowError("An error occurred while starting the job. " + Environment.NewLine + ex.Message);
SetJobFailed();
+ StopRecordingIfInProgress();
+ }
+ }
+
+ /// <summary>
+ /// Starts the job and record using the data capture module.
+ /// </summary>
+ private void StartJobAndRecord()
+ {
+ _isRecording = true;
+ _dataCaptureVM.StartDiagnosticsRecording();
+ StartJob();
+ }
+
+ /// <summary>
+ /// Stops the recording if in progress.
+ /// </summary>
+ private void StopRecordingIfInProgress()
+ {
+ if (_isRecording)
+ {
+ _isRecording = false;
+ InvokeUI(() => _dataCaptureVM.StopRecorderOrPlayer());
}
}