diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-09 15:27:55 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-09 15:27:55 +0300 |
| commit | 4147c287ad90a05eae551d4ccfdccc707bebd86f (patch) | |
| tree | 24acd52ab1240dc34b04db280b9c7439c760231a /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels | |
| parent | ca96477441518c8300474a317e34cb5e7e1550fc (diff) | |
| download | Tango-4147c287ad90a05eae551d4ccfdccc707bebd86f.tar.gz Tango-4147c287ad90a05eae551d4ccfdccc707bebd86f.zip | |
Refactored job progress handling !!!
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.cs | 143 |
1 files changed, 27 insertions, 116 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 e2bba2d1d..9c6fa6239 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 @@ -67,6 +67,16 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Properties + private RunningJobStatus _runningJobStatus; + /// <summary> + /// Gets or sets the running job status. + /// </summary> + public RunningJobStatus RunningJobStatus + { + get { return _runningJobStatus; } + set { _runningJobStatus = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection<Machine> _machines; /// <summary> /// Gets or sets the machines. @@ -331,26 +341,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _runningJob = value; RaisePropertyChangedAuto(); } } - private double _runningJobProgress; - /// <summary> - /// Gets or sets the running job current progress. - /// </summary> - public double RunningJobProgress - { - get { return _runningJobProgress; } - set { _runningJobProgress = value; RaisePropertyChangedAuto(); } - } - - private TimeSpan _runningJobRemainingTime; - /// <summary> - /// Gets or sets the job remaining time. - /// </summary> - public TimeSpan RunningJobRemainingTime - { - get { return _runningJobRemainingTime; } - set { _runningJobRemainingTime = value; RaisePropertyChangedAuto(); } - } - private bool _isJobCompleted; /// <summary> /// Gets or sets a value indicating whether the running job has completed successfully. @@ -401,16 +391,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _machineOperator = value; RaisePropertyChangedAuto(); } } - private IRealTimeGraph _fullScreenGraph; - /// <summary> - /// Gets or sets the full screen graph. - /// </summary> - public IRealTimeGraph FullScreenGraph - { - get { return _fullScreenGraph; } - set { _fullScreenGraph = value; RaisePropertyChangedAuto(); } - } - private List<Segment> _runningJobSegments; /// <summary> /// Gets or sets the running job segments. @@ -1018,8 +998,8 @@ namespace Tango.MachineStudio.Developer.ViewModels } JobEvents.Clear(); - RunningJobRemainingTime = TimeSpan.Zero; - RunningJobProgress = 0; + //RunningJobRemainingTime = TimeSpan.Zero; + //RunningJobProgress = 0; IsJobFailed = false; IsJobCanceled = false; IsJobCompleted = false; @@ -1028,7 +1008,7 @@ namespace Tango.MachineStudio.Developer.ViewModels RunningJob = ActiveJob; _runningJobEstimatedDuration = EstimatedDuration; - RunningJobSegments = CreateRunningJobEffectiveSegments(RunningJob); + RunningJobSegments = RunningJob.GetEffectiveSegment(); _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); @@ -1040,55 +1020,25 @@ namespace Tango.MachineStudio.Developer.ViewModels _eventLogger.Log(String.Format("Job '{0}' started...", ActiveJob.Name)); - _jobHandler.StatusReceived += (x, status) => + _jobHandler.StatusChanged += (x, status) => { if (IsJobRunning) { - - RunningJobRemainingTime = _runningJobEstimatedDuration - TimeSpan.FromSeconds(RunningJobProgress / (SelectedProcessParametersTable.DyeingSpeed / 100d)); - RunningJobProgress = status.Progress; + RunningJobStatus = status; } + }; - foreach (var segment in RunningJobSegments) + _jobHandler.SegmentStarted += (x, segment) => + { + if (!segment.IsInterSegment) { - 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)); - TimeSpan remaining = segmentsDuration - TimeSpan.FromSeconds(RunningJobProgress / (SelectedProcessParametersTable.DyeingSpeed / 100d)); - if (remaining >= TimeSpan.Zero) - { - segment.RemainingTime = remaining; - } - if (remaining < segmentDuration) - { - if (!segment.Started) - { - segment.Started = true; - - if (segment.ID != -1) - { - _speech.SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex)); - _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex) + Environment.NewLine + segment.ToJsonString()); - } - else - { - _speech.SpeakInfo(String.Format("Inter Segment Started.")); - _eventLogger.Log("Inter Segment Started."); - } - } - } - if (remaining <= TimeSpan.Zero) - { - if (!segment.Completed) - { - segment.Completed = true; - } - } + _speech.SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex)); + _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex) + Environment.NewLine + segment.ToJsonString()); + } + else + { + _speech.SpeakInfo(String.Format("Inter Segment Started.")); + _eventLogger.Log("Inter Segment Started."); } }; @@ -1153,45 +1103,6 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - /// <summary> - /// Creates the running job effective segments. - /// </summary> - /// <param name="job">The job.</param> - /// <returns></returns> - private List<Segment> CreateRunningJobEffectiveSegments(Job job) - { - LogManager.Log("Creating job effective segments..."); - - List<Segment> segments = new List<Segment>(); - foreach (var s in job.Segments) - { - s.Completed = false; - s.Started = false; - segments.Add(s); - - if (job.EnableInterSegment && job.Segments.IndexOf(s) != job.Segments.Count - 1) - { - segments.Add(new Segment() - { - Length = job.InterSegmentLength, - ID = -1, - BrushStops = new System.Collections.ObjectModel.ObservableCollection<BrushStop>() - { - new BrushStop() - { - ColorSpace = ColorSpaces.Single(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()), - Color = Colors.White, - } - }, - Started = false, - Completed = false - }); - } - } - - return segments; - } - #endregion #region RML @@ -1445,7 +1356,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (ActiveJob != null && SelectedProcessParametersTable != null && SelectedProcessParametersTable.DyeingSpeed > 0) { - EstimatedDuration = TimeSpan.FromSeconds(ActiveJob.Length / (SelectedProcessParametersTable.DyeingSpeed / 100d)); + EstimatedDuration = ActiveJob.GetEstimatedDuration(SelectedProcessParametersTable); } } |
