From e332170566c295fb4ff375498867f984f1570707 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 16 Feb 2018 19:04:47 +0200 Subject: Before developer module redesign. --- .../ViewModels/MainViewVM.cs | 84 ++++++++++- .../Views/MainView.xaml | 153 +++++++++++++++------ .../Views/MainView.xaml.cs | 2 +- 3 files changed, 193 insertions(+), 46 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') 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 b2f6c3579..013129fc1 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 @@ -47,7 +47,6 @@ namespace Tango.MachineStudio.Developer.ViewModels private int _fullScreenGraphIndex; private JobHandler _jobHandler; - #region Properties /// @@ -329,6 +328,16 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _fullScreenGraph = value; RaisePropertyChangedAuto(); } } + private List _runningJobSegments; + /// + /// Gets or sets the running job segments. + /// + public List RunningJobSegments + { + get { return _runningJobSegments; } + set { _runningJobSegments = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -477,11 +486,21 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Event Handlers + /// + /// Handles the diagnostics provider frame received event. + /// + /// The sender. + /// The response. private void DiagnosticsFrameProvider_FrameReceived(object sender, PushDiagnosticsResponse response) { PopulateDiagnosticsData(response); } + /// + /// Handles the application manager connected machine changes event. + /// + /// The sender. + /// The machine. private void ApplicationManager_ConnectedMachineChanged(object sender, IExternalBridgeClient machine) { MachineOperator = machine; @@ -497,11 +516,21 @@ namespace Tango.MachineStudio.Developer.ViewModels InvalidateLiquidFactorsAndProcessTables(); } + /// + /// Handles the LengthChanged event of the SelectedJob. + /// + /// The source of the event. + /// The instance containing the event data. private void SelectedJob_LengthChanged(object sender, EventArgs e) { UpdateEstimatedDuration(); } + /// + /// Handles the DyeingSpeedMinInkUptakeChanged event of the SelectedProcessParametersTable. + /// + /// The source of the event. + /// The instance containing the event data. private void SelectedProcessParametersTable_DyeingSpeedMinInkUptakeChanged(object sender, EventArgs e) { if (SelectedSegment != null) @@ -693,6 +722,7 @@ namespace Tango.MachineStudio.Developer.ViewModels RunningJob = SelectedJob; _runningJobEstimatedDuration = EstimatedDuration; + RunningJobSegments = CreateRunningJobEffectiveSegments(RunningJob); _jobHandler = MachineOperator.Print(SelectedJob, SelectedProcessParametersTable); @@ -700,6 +730,27 @@ namespace Tango.MachineStudio.Developer.ViewModels { RunningJobRemainingTime = _runningJobEstimatedDuration - TimeSpan.FromSeconds(RunningJobProgress / (SelectedProcessParametersTable.DyeingSpeed / 100d)); RunningJobProgress = status.Progress; + + foreach (var segment in RunningJobSegments) + { + 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) + { + segment.Started = true; + } + if (remaining <= TimeSpan.Zero) + { + segment.Completed = true; + segment.Started = false; + } + } }; _jobHandler.Failed += (x, ex) => @@ -729,6 +780,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { using (_notification.PushTaskItem("Saving machine jobs...")) { + SelectedJob.CreationDate = DateTime.UtcNow; await SelectedJob.SaveAsync(); } } @@ -938,6 +990,36 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + private List CreateRunningJobEffectiveSegments(Job job) + { + List segments = new List(); + 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, + BrushStops = new System.Collections.ObjectModel.ObservableCollection() + { + new BrushStop() + { + Color = Colors.White, + } + }, + Started = false, + Completed = false + }); + } + } + + return segments; + } + #endregion #region Override Methods 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 b6d859cd4..240e3127c 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 @@ -255,17 +255,17 @@ - - - - + + + + - + @@ -279,9 +279,10 @@ - - - + + + + @@ -289,7 +290,7 @@ - + @@ -298,53 +299,85 @@ - - - - - - - - - - - - + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - - + + - + - + - + @@ -357,8 +390,8 @@ - - + + @@ -804,7 +837,22 @@ - + + + + + + + + + + + + + + + + @@ -812,7 +860,7 @@ MACHINE JOBS - + @@ -1027,6 +1075,23 @@ + + + + + + + + + + + + + + + + + @@ -1106,8 +1171,8 @@