From da1c997c138633c46daa8dc3c099b7164a536eb9 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 2 Aug 2023 15:44:56 +0300 Subject: Job Running Progress - added inter segments to logic. --- .../Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | 39 +++++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs index 684b9bd8c..f8c139cf6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs @@ -184,7 +184,7 @@ namespace Tango.PPC.UI.ViewModels { get { return GetVolumeLiquidType(LiquidTypes.LightYellow); } } - + //public double TransparentInkOutput //{ // get { return GetVolumeLiquidType(LiquidTypes.TransparentInk); } @@ -584,17 +584,38 @@ namespace Tango.PPC.UI.ViewModels IsDyeingProcess = (RunningJobStatus != null && RunningJobStatus.CurrentSegment != null); if (RunningJobStatus != null && RunningJobStatus.CurrentSegment != null) { - var currentSegmentIndex = Math.Max(_runningJobStatus.CurrentSegment.SegmentIndex - (Job.Segments.Count * RunningJobStatus.CurrentUnit), 0); - var segment = Job.Segments.FirstOrDefault(x => x.SegmentIndex == currentSegmentIndex); - // var segment = Job.Segments.FirstOrDefault(x => x.SegmentIndex == _runningJobStatus.CurrentSegment.SegmentIndex); - if (segment != null) + if(_runningJobStatus.CurrentSegment.IsInterSegment) { - if (_handler.JobTicket.Segments.Count > 0) + CurrentBrushStop = _runningJobStatus.CurrentSegment.BrushStops.FirstOrDefault(); + JobBrushStop = null; + } + else + { + var realsegmIndex = 1; + if (Job.EnableInterSegment && Job.InterSegmentLength > 0) { - JobBrushStop = _handler.JobTicket.Segments[Job.OrderedSegments.IndexOf(segment)].BrushStops.First(); - } + int segmentIndex = _runningJobStatus.CurrentSegment.SegmentIndex - (Job.EffectiveSegments.Count * RunningJobStatus.CurrentUnit); + if(RunningJobStatus.CurrentUnit > 0) + { + segmentIndex -= RunningJobStatus.CurrentUnit;// inter segment between units + } + realsegmIndex = (int)(segmentIndex/2) + 1; + } + else + { + realsegmIndex = Math.Max(_runningJobStatus.CurrentSegment.SegmentIndex - (Job.Segments.Count * RunningJobStatus.CurrentUnit), 0); + } + + var segment = Job.Segments.FirstOrDefault(x => x.SegmentIndex == realsegmIndex); + if (segment != null) + { + if (_handler.JobTicket.Segments.Count > 0) + { + JobBrushStop = _handler.JobTicket.Segments[Job.OrderedSegments.IndexOf(segment)].BrushStops.First(); + } + } + CurrentBrushStop = RunningJobStatus.CurrentSegment.FirstBrushStop; } - CurrentBrushStop = RunningJobStatus.CurrentSegment.FirstBrushStop; } } -- cgit v1.3.1 From f6b8be518df438baa155f718619ad04905b4fae5 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Fri, 25 Aug 2023 19:26:42 +0300 Subject: Resume button. Set SettingUpTotalProgress as global Start Position. --- .../Controls/RunningJobViewerEureka.xaml.cs | 12 ++-- .../Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | 77 +++++++++++++++++++++- .../Tango.Emulations/Emulators/MachineEmulator.cs | 10 +-- .../Tango.Integration/Operation/JobHandler.cs | 38 +++++++++-- .../Tango.Integration/Operation/MachineOperator.cs | 11 ++-- 5 files changed, 126 insertions(+), 22 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs index 11823f797..60c5a0346 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Controls/RunningJobViewerEureka.xaml.cs @@ -236,14 +236,14 @@ namespace Tango.PPC.UI.Controls if(slider_control != null) { slider_control.Value = SliderValue; - if(RunningJobStatus != null && RunningJobStatus.IsSettingUp == false && IsHasMultipleColorsSegments && ColorCanvas != null && ControlWidth > 0) + if(RunningJobStatus != null && RunningJobStatus.IsSettingUp == false && IsHasMultipleColorsSegments && ColorCanvas != null && ControlWidth > 0 && RunningJobStatus.CurrentUnitProgress > 0.01 && RunningJobStatus.CurrentUnitTotalProgress > 0) { double progress = RunningJobStatus.CurrentUnitProgress; double total = RunningJobStatus.CurrentUnitTotalProgress; int currentUnit = RunningJobStatus.CurrentUnit; - int totalUnits = Job.NumberOfUnits; - + int totalUnits = RunningJobStatus.RemainingUnits + RunningJobStatus.CurrentUnit;//Job.NumberOfUnits; + double simpleoffset = ((progress / total) * ControlWidth) ; double multiplier = (((double)(totalUnits - 1)) / (double)totalUnits); @@ -256,16 +256,16 @@ namespace Tango.PPC.UI.Controls _prevOffset = ControlWidth * (1-multiplier) * currentUnit; } _addOffset = _prevOffset; - //Debug.WriteLine($"OnSliderValueChanged prevOffset: '{_prevOffset}' currentUnit = {currentUnit}, total:{total}"); } - + // Debug.WriteLine($"OnSliderValueChanged Offset: '{offset}' CurrentUnitProgress = {RunningJobStatus.CurrentUnitProgress} progress= {progress} currentUnit = {currentUnit}, total:{total}"); offset += _addOffset; if (offset >= ControlWidth && currentUnit < (Job.NumberOfUnits - 2)) { offset -= ControlWidth;//round - //Debug.WriteLine($"OnSliderValueChanged round!!! offset: '{offset}' currentUnit = {currentUnit}, total:{total}"); + // Debug.WriteLine($"OnSliderValueChanged round!!! offset: '{offset}' currentUnit = {currentUnit}, total:{total}"); } + //if(currentUnit == (Job.NumberOfUnits - 1)) //{ // Debug.WriteLine($"OnSliderValueChanged offset: '{offset}' currentUnit = {currentUnit}. ControlWidth = {ControlWidth} total:{total}"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs index f8c139cf6..131476c9e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs @@ -24,6 +24,9 @@ using System.ComponentModel; using RealTimeGraphX.WPF; using RealTimeGraphX.DataPoints; using Tango.PPC.UI.Graphs; +using Tango.BL; +using System.Data.Entity; +using System.Windows.Media; namespace Tango.PPC.UI.ViewModels { @@ -41,6 +44,25 @@ namespace Tango.PPC.UI.ViewModels Motor = 3 } + public class TimeToDyeValueItem + { + public DateTime startTime; + public DateTime endTime; + public double totalValue; + }; + + public class TimeToDyeValueCollection + { + public DateTime StartTime { get; set;} + public List items; + public TimeToDyeValueCollection() + { + items = new List(); + } + }; + + private DispatcherTimer _productiondata_timer; + #region Properties [TangoInject] @@ -344,7 +366,10 @@ namespace Tango.PPC.UI.ViewModels public MachineStatusViewVM() { - + _productiondata_timer = new DispatcherTimer(); + _productiondata_timer.Interval = TimeSpan.FromMinutes(10); + _productiondata_timer.Tick += _productiondata_timer_Tick; + StopCommand = new RelayCommand(StopJob, () => CanStopped()); AbortCommand = new RelayCommand(AbortJob, () => CanStopped()); @@ -355,7 +380,7 @@ namespace Tango.PPC.UI.ViewModels ClearJobCommand = new RelayCommand(ClearJob, () => CanStopped()); - GoToJobCommand = new RelayCommand(GoToJob, () => IsEnableGoToJob()); + GoToJobCommand = new RelayCommand(GoToJob, () => IsEnableGoToJob()); JobStatusViewCommand = new RelayCommand(JobStatusView); OverviewViewCommand = new RelayCommand(OverviewView); ClearAllNotificationsCommand = new RelayCommand(ClearAllNotifications); @@ -397,6 +422,12 @@ namespace Tango.PPC.UI.ViewModels MachineProvider.MachineOperator.MachineStatusChanged += MachineOperator_MachineStatusChanged; + DateTime dateTime = DateTime.Now; + DateTime onedayEarlier = dateTime.AddDays(-1); + + GetCollectionDyePropByStartTime(onedayEarlier); + + _productiondata_timer.Start(); } #region Events @@ -520,6 +551,10 @@ namespace Tango.PPC.UI.ViewModels //} } + private void _productiondata_timer_Tick(object sender, EventArgs e) + { + var CurrentDateTime = DateTime.Now; + } #endregion #region printing @@ -749,6 +784,12 @@ namespace Tango.PPC.UI.ViewModels IsDisplayJobOutline = true; } } + + #endregion + + #region graph + + public TimeToDyeValueCollection graphDyeingValuesCollection = new TimeToDyeValueCollection(); private WpfGraphController CreateController(params WpfGraphDataSeries[] seriesCollection) { @@ -771,7 +812,10 @@ namespace Tango.PPC.UI.ViewModels private WpfGraphDataSeries CreateSeries(String name, GraphHelper.GraphColor fill) { - WpfGraphDataSeries series = new WpfGraphDataSeries(); + WpfGraphDataSeries series = new WpfGraphDataSeries() + { + Stroke = Colors.DodgerBlue, + }; series.Name = name; series.Fill = GraphHelper.GetGraphBrush(fill); series.StrokeThickness = 1; @@ -779,6 +823,33 @@ namespace Tango.PPC.UI.ViewModels return series; } + public async void GetCollectionDyePropByStartTime(DateTime starttime) + { + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var jobRuns = await db.JobRuns.Where(x => x.StartDate >= starttime).Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).OrderBy(y => y.StartDate).ToListAsync(); + double allvalues = 0; + graphDyeingValuesCollection.StartTime = starttime; + for ( int i = 0; i < jobRuns.Count; i++) + { + JobController.PushData(jobRuns[i].StartDate, allvalues); + if (i > 0) + { + allvalues += jobRuns[i-1].EndPosition; + } + graphDyeingValuesCollection.items.Add( new TimeToDyeValueItem(){ startTime = jobRuns[i].StartDate, endTime = jobRuns[i].EndDate, totalValue = allvalues }); + JobController.PushData(jobRuns[i].EndDate, allvalues); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading machine counters."); + + } + } #endregion } } diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 7074582d0..61d069847 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -851,10 +851,11 @@ namespace Tango.Emulations.Emulators for (int i = 0; i < units; i++) { - while (progress < unit_length + (!bIsResumeProcess && i == units - 1 ? dryerLength : 0) && !_cancelJob) - { - var status = new PMR.Printing.JobStatus(); - status.Progress = progress; + // while (progress < unit_length + (!bIsResumeProcess && i == units - 1 ? dryerLength : 0) && !_cancelJob) + while (progress < unit_length + ( i == units - 1 ? dryerLength : 0) && !_cancelJob) + { + var status = new PMR.Printing.JobStatus(); + status.Progress = progress; if (!message_sent) { @@ -891,6 +892,7 @@ namespace Tango.Emulations.Emulators addedResume = true; progress = firstUnitStartPosition; } + //LogManager.Log($" Emulator Progress = {progress}, units = {units}"); double currentPosition = 0; double nextStopPosition = unit_length; diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs index 4579ff08c..5d62f4269 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs @@ -9,6 +9,7 @@ using Tango.BL.Enumerations; using Tango.Core; using Tango.Logging; using Tango.PMR.Printing; +using static Tango.Integration.Operation.AdditionalJobConfiguration; namespace Tango.Integration.Operation { @@ -139,6 +140,8 @@ namespace Tango.Integration.Operation /// public JobTicket JobTicket { get; private set; } + public ResumeConfiguration ResumeConfig { get; private set; } + #endregion #region Constructors @@ -155,13 +158,14 @@ namespace Tango.Integration.Operation /// Initializes a new instance of the class. /// /// The cancel action. - public JobHandler(Action cancelAction, Job job, JobTicket jobTicket, ProcessParametersTable processParameters, JobHandlerModes mode) : this() + public JobHandler(Action cancelAction, Job job, JobTicket jobTicket, ProcessParametersTable processParameters, JobHandlerModes mode, ResumeConfiguration resumeConfig = null) : this() { _mode = mode; ProcessParameters = processParameters; Job = job; JobTicket = jobTicket; + ResumeConfig = resumeConfig; foreach (var s in Job.Segments) { @@ -187,6 +191,11 @@ namespace Tango.Integration.Operation Status.RemainingProgress = Status.TotalProgress; Status.CurrentUnitSegments = _effectiveSegments.ToList(); Status.SettingUpTotalProgress = processParameters.DryerBufferLengthMeters; + if (resumeConfig != null && resumeConfig.GlobalStartPosition > 0) + { + Status.SettingUpTotalProgress = resumeConfig.GlobalStartPosition; + Status.CurrentUnitProgress = ResumeConfig.FirstUnitStartPosition; + } Status.TotalProgressMinusSettingUp = Job.LengthIncludingNumberOfUnits; Status.IsSettingUp = true; @@ -332,7 +341,7 @@ namespace Tango.Integration.Operation protected virtual void InvalidateJobProgress(JobStatus s) { JobStatus = s; - + if (_last_progress != s.Progress) { if (s.Progress <= PROGRESS_REPORT_RANGE_METERS || s.Progress >= Status.TotalProgress - PROGRESS_REPORT_RANGE_METERS) @@ -383,7 +392,16 @@ namespace Tango.Integration.Operation Status.IsSettingUp = false; } - Status.ProgressMinusSettingUp = s.Progress - this.Status.SettingUpTotalProgress; + if (ResumeConfig != null && ResumeConfig.GlobalStartPosition > 0) + { + Status.ProgressMinusSettingUp = s.Progress - ProcessParameters.DryerBufferLengthMeters; + //LogManager.Log($" Status.ProgressMinusSettingUp {Status.ProgressMinusSettingUp} progress = {s.Progress}"); + + } + else + { + Status.ProgressMinusSettingUp = s.Progress - this.Status.SettingUpTotalProgress; + } } int units = (int)Math.Max(Job.NumberOfUnits, 1); @@ -411,6 +429,15 @@ namespace Tango.Integration.Operation break; } } + else if(ResumeConfig != null && ResumeConfig.GlobalStartPosition > 0) + { + if (!Status.IsSettingUp && s.Progress <= previousUnitsLengthWithoutThis + unitLength + ProcessParameters.DryerBufferLengthMeters) + { + currentUnitProgress = s.Progress - previousUnitsLengthWithoutThis - ProcessParameters.DryerBufferLengthMeters; + //LogManager.Log($"currentUnitProgress before ={currentUnitProgress} progress = {s.Progress}"); + break; + } + } else if (s.Progress <= previousUnitsLengthWithoutThis + unitLength + Status.SettingUpProgress) { if (!Status.IsSettingUp) @@ -425,6 +452,7 @@ namespace Tango.Integration.Operation Status.CurrentUnit = currentUnit; Status.CurrentUnitProgress = currentUnitProgress; + //LogManager.Log($"CurrentUnit {Status.CurrentUnit} currentUnitProgress {Status.CurrentUnitProgress} "); Status.RemainingUnits = this.Job.NumberOfUnits - this.Status.CurrentUnit; @@ -444,7 +472,7 @@ namespace Tango.Integration.Operation { Status.Message = s.Message; } - + _lastStatusMessage = s.Message; @@ -527,7 +555,7 @@ namespace Tango.Integration.Operation Status.CurrentSegment = segment; } } - + //if (Status.Progress >= previousSegmentsLengthWithThis) if (Status.ProgressMinusSettingUp >= previousSegmentsLengthWithThis) { diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 11634109f..07d2c9881 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -2596,6 +2596,8 @@ namespace Tango.Integration.Operation /// public Task Print(Job job, ProcessParametersTable processParameters, AdditionalJobConfiguration config = null) { + //processParameters.DryerBufferLength = 10; //TODO: REMOVE !!! + return Task.Factory.StartNew(() => { if (config == null) config = new AdditionalJobConfiguration(); @@ -2916,7 +2918,7 @@ namespace Tango.Integration.Operation handler.CanCancel = true; LogManager.Log(ex, "Failed to cancel job."); } - }, clonedJob, ticket, processParameters, JobHandlingMode); + }, clonedJob, ticket, processParameters, JobHandlingMode, config.ResumeConfig); handler.StatusChanged += (x, s) => { @@ -3252,9 +3254,10 @@ namespace Tango.Integration.Operation if (config.ResumeConfig != null) { - resumePreProgress = config.ResumeConfig.GlobalStartPosition - request.FirstUnitStartPosition; + resumePreProgress = config.ResumeConfig.GlobalStartPosition - processParameters.DryerBufferLengthMeters; request.FirstUnitStartPosition = config.ResumeConfig.FirstUnitStartPosition; - request.JobTicket.Length = (request.JobTicket.Length / Math.Max(request.JobTicket.NumberOfUnits, 1)) *(int)Math.Max(config.ResumeConfig.RemainingUnits, 1); + //LogManager.Log($" resumePreProgress = {resumePreProgress}, GlobalStartPosition {config.ResumeConfig.GlobalStartPosition} FirstUnitStartPosition {request.FirstUnitStartPosition}"); + request.JobTicket.Length = (request.JobTicket.Length / Math.Max(request.JobTicket.NumberOfUnits, 1)) * (int)Math.Max(config.ResumeConfig.RemainingUnits, 1); request.JobTicket.NumberOfUnits = (uint)Math.Max(config.ResumeConfig.RemainingUnits, 1); } @@ -3263,7 +3266,7 @@ namespace Tango.Integration.Operation if (!completed) { response.Message.Status.Progress += resumePreProgress; - + handler.RaiseStatusReceived(response.Message.Status); _last_job_status = handler.Status; -- cgit v1.3.1