aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-09 15:27:55 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-09 15:27:55 +0300
commit4147c287ad90a05eae551d4ccfdccc707bebd86f (patch)
tree24acd52ab1240dc34b04db280b9c7439c760231a /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer
parentca96477441518c8300474a317e34cb5e7e1550fc (diff)
downloadTango-4147c287ad90a05eae551d4ccfdccc707bebd86f.tar.gz
Tango-4147c287ad90a05eae551d4ccfdccc707bebd86f.zip
Refactored job progress handling !!!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs143
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml6
2 files changed, 30 insertions, 119 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);
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml
index a3ac2f3b9..14c4cd78a 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml
@@ -95,7 +95,7 @@
</Grid>
<StackPanel DockPanel.Dock="Right" VerticalAlignment="Center" Margin="0 20 0 0">
<StackPanel Orientation="Horizontal">
- <TextBlock VerticalAlignment="Center" FontSize="30" FontFamily="{StaticResource digital-7}" Margin="0 0 40 0" Foreground="#FF6464" Width="100" Text="{Binding RunningJobRemainingTime,StringFormat=hh\\:mm\\:ss}"></TextBlock>
+ <TextBlock VerticalAlignment="Center" FontSize="30" FontFamily="{StaticResource digital-7}" Margin="0 0 40 0" Foreground="#FF6464" Width="100" Text="{Binding RunningJobStatus.RemainingTime,StringFormat=hh\\:mm\\:ss}"></TextBlock>
<Button Height="40" Width="170" Command="{Binding StopJobCommand}" Background="#FF6464" BorderBrush="#FF6464">
<StackPanel Orientation="Horizontal">
@@ -214,12 +214,12 @@
<Canvas.Left>
<MultiBinding Converter="{StaticResource JobProgressToPositionConverter}">
<Binding Path="RunningJob" />
- <Binding Path="RunningJobProgress" />
+ <Binding Path="RunningJobStatus.Progress" />
<Binding ElementName="jobProgressCanvas" Path="ActualWidth" />
</MultiBinding>
</Canvas.Left>
<materialDesign:PackIcon Kind="MapMarker" Foreground="#FF6464" Width="35" Height="35" Margin="-17 0 0 0" />
- <TextBlock Margin="-11 -23 0 0" FontSize="16" Foreground="#FF6464" VerticalAlignment="Top" Height="18" Text="{Binding RunningJobProgress,StringFormat=0.0}"></TextBlock>
+ <TextBlock Margin="-11 -23 0 0" FontSize="16" Foreground="#FF6464" VerticalAlignment="Top" Height="18" Text="{Binding RunningJobStatus.Progress,StringFormat=0.0}"></TextBlock>
</Grid>
</Canvas>
</Grid>