From 4906ad513360078ecc40cb368b3a1a88f40b2c19 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 10 Mar 2021 15:46:20 +0200 Subject: Added job handler counter to track multi instance bugs. --- .../Tango.Integration/Operation/JobHandler.cs | 263 +-------------------- 1 file changed, 12 insertions(+), 251 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs index fce815bc3..605e8be47 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs @@ -26,6 +26,7 @@ namespace Tango.Integration.Operation protected double _last_progress; protected const int PROGRESS_REPORT_RANGE_METERS = 5; protected bool loggedContinueMessage; + private int _handlerCounter; #region Events @@ -148,6 +149,7 @@ namespace Tango.Integration.Operation public JobHandler() { CanCancel = true; + _handlerCounter++; } /// @@ -327,252 +329,6 @@ namespace Tango.Integration.Operation #region Private Methods - //protected virtual void InvalidateJobProgress(JobStatus s) - //{ - // JobStatus = s; - // bool invalidProgress = false; - - // if (_last_progress != s.Progress) - // { - // if (s.Progress <= PROGRESS_REPORT_RANGE_METERS || s.Progress >= Status.TotalProgress - PROGRESS_REPORT_RANGE_METERS) - // { - // LogManager.Log($"Updating job progress {s.Progress}/{Status.TotalProgress}..."); - // } - // else if (!loggedContinueMessage) - // { - // loggedContinueMessage = true; - // LogManager.Log($"Progress logging will continue {PROGRESS_REPORT_RANGE_METERS} meters before completion..."); - // } - // } - - // if (s.Progress < 0) - // { - // LogManager.Log($"Invalid job progress received '{s.Progress}'.", LogCategory.Error); - // invalidProgress = true; - // } - - // if (s.Progress > Status.TotalProgress) - // { - // LogManager.Log($"Invalid job progress received '{s.Progress}' while total progress is '{Status.TotalProgress}'.", LogCategory.Error); - // invalidProgress = true; - // } - - // if (s.Progress < _last_progress) - // { - // LogManager.Log($"Invalid job progress received '{s.Progress}' while last progress was '{_last_progress}'."); - // invalidProgress = true; - // } - - // if (invalidProgress) - // { - // return; - // } - - // _last_progress = s.Progress; - - // //Job Status - // if (IsCanceled) - // { - // Status.IsCanceled = IsCanceled; - // RaiseStatusChanged(); - // return; - // } - - // List unit_segments = new List(); - // double delta = s.Progress - Status.Progress; - - // Status.Progress = s.Progress; - // Status.RemainingTime = Status.TotalTime - Job.TranslateProgressToTime(Status.Progress, ProcessParameters); - // Status.RemainingProgress = Status.TotalProgress - Status.Progress; - - // if (Status.SettingUpProgress < Status.SettingUpTotalProgress) - // { - // Status.SettingUpProgress += delta; - // } - // else - // { - // if (Status.IsSettingUp && Status.Progress > 0) - // { - // Status.IsSettingUp = false; - // } - - // Status.ProgressMinusSettingUp += delta; - // } - - // if (s.Progress < Job.LengthIncludingNumberOfUnits || _mode == JobHandlerModes.SettingUp) - // { - // Status.ProgressWithoutFinalization += delta; - - // unit_segments = _effectiveSegments.ToList(); - - // if (Job.EnableInterSegment && Job.NumberOfUnits > 1 && Status.RemainingUnits > 1) - // { - // unit_segments.Add(Job.CreateInterSegment(Job.InterSegmentLength)); - // } - - // if (unit_segments.Count != Status.CurrentUnitSegments.Count) - // { - // Status.CurrentUnitSegments = unit_segments; - // } - - // Status.CurrentUnitTotalProgress = Status.RemainingUnits > 1 && Job.EnableInterSegment ? Job.Length + (Job.InterSegmentLength) : Job.Length; - - // if (_mode == JobHandlerModes.Finalization) - // { - // Status.CurrentUnitProgress += delta; - // } - // else - // { - // if (!Status.IsSettingUp) - // { - // Status.CurrentUnitProgress += delta; - // } - // } - - // if (Status.CurrentUnitProgress >= Status.CurrentUnitTotalProgress) - // { - // Status.CurrentUnitProgress = 0; - // Status.CurrentUnit++; - // } - - // Status.RemainingUnits = Job.NumberOfUnits - Status.CurrentUnit; - - // if (s.Message != _lastStatusMessage && s.Message != String.Empty) - // { - // Status.Message = s.Message; - // } - // else - // { - // Status.Message = null; - // } - - // _lastStatusMessage = s.Message; - - // RaiseStatusChanged(); - - // //Segments Completion - - // if (Status.CurrentUnit > _last_unit) - // { - // foreach (var segment in Status.CurrentUnitSegments) - // { - // segment.Started = false; - // segment.Completed = false; - // } - - // if (Job.NumberOfUnits > 1) - // { - // RaiseUnitCompleted(_last_unit); - // } - // } - - // _last_unit = Status.CurrentUnit; - - - // for (int i = 0; i < Status.CurrentUnitSegments.Count; i++) - // { - // Segment segment = Status.CurrentUnitSegments[i]; - // double previousSegmentsLengthWithThis = Status.CurrentUnitSegments.Take(i + 1).Sum(x => x.LengthWithFactor); - // TimeSpan segmentsDuration = Job.TranslateProgressToTime(previousSegmentsLengthWithThis, ProcessParameters); - // TimeSpan segmentRemainingTime = segmentsDuration - Job.TranslateProgressToTime(Status.CurrentUnitProgress, ProcessParameters); - - // if (i == 0 && Status.CurrentUnitProgress > 0) - // { - // if (!segment.Started) - // { - // segment.Started = true; - // RaiseSegmentStarted(segment); - // } - // } - - // if (Status.CurrentUnitProgress >= previousSegmentsLengthWithThis) - // { - // if (!segment.Completed) - // { - // segment.Completed = true; - // RaiseSegmentCompleted(segment); - // } - - // if (i < Status.CurrentUnitSegments.Count - 1) - // { - // if (!Status.CurrentUnitSegments[i + 1].Started) - // { - // Status.CurrentUnitSegments[i + 1].Started = true; - // RaiseSegmentStarted(Status.CurrentUnitSegments[i + 1]); - // } - // } - // } - - // if (segment.Started && !segment.Completed) - // { - // segment.RemainingTime = segmentRemainingTime; - // } - // } - - - // //Set Segment Completion for All Segments List - // for (int i = 0; i < Status.Segments.Count; i++) - // { - // Segment segment = Status.Segments[i]; - // double previousSegmentsLengthWithThis = Status.Segments.Take(i + 1).Sum(x => x.LengthWithFactor); - // TimeSpan segmentsDuration = Job.TranslateProgressToTime(previousSegmentsLengthWithThis, ProcessParameters); - // TimeSpan segmentRemainingTime = segmentsDuration - Job.TranslateProgressToTime(Status.Progress, ProcessParameters); - - // segment.Progress = Math.Min(Math.Max((previousSegmentsLengthWithThis - segment.Length - Status.Progress) * -1, 0), segment.Length); - - // if (i == 0 && Status.Progress > 0) - // { - // if (!segment.Started) - // { - // segment.Started = true; - // Status.CurrentSegment = segment; - // } - // } - - // if (Status.Progress >= previousSegmentsLengthWithThis) - // { - // if (!segment.Completed) - // { - // segment.Completed = true; - // } - - // if (i < Status.Segments.Count - 1) - // { - // if (!Status.Segments[i + 1].Started) - // { - // Status.Segments[i + 1].Started = true; - // Status.CurrentSegment = Status.Segments[i + 1]; - // } - // } - // } - - // if (segment.Started && !segment.Completed) - // { - // segment.RemainingTime = segmentRemainingTime; - // } - // } - // } - // else - // { - // //Finalizing - // if (!_finalizing) - // { - // _finalizing = true; - // Status.IsFinalizing = true; - // var last_Segment = _effectiveSegments.Last().Clone(); - // last_Segment.Length = ProcessParameters.DryerBufferLengthMeters; - // Status.CurrentUnitSegments = new List { last_Segment }; - // Status.CurrentUnitTotalProgress = last_Segment.Length; - // Status.CurrentUnitProgress = 0; - // Status.ProgressWithoutFinalization = Status.TotalProgressWithoutFinalization; - // RaiseFinalizing(); - // } - - // Status.CurrentUnitProgress += delta; - // Status.FinalizingProgress += delta; - // } - //} - protected virtual void InvalidateJobProgress(JobStatus s) { JobStatus = s; @@ -824,11 +580,11 @@ namespace Tango.Integration.Operation { if (segment.IsInterSegment) { - LogManager.Log($"Inter Segment started."); + LogManager.Log($"{GetJobHandlerString()} Inter Segment started."); } else { - LogManager.Log($"Segment {segment.SegmentIndex} of unit {Status.CurrentUnit + 1} started..."); + LogManager.Log($"{GetJobHandlerString()} Segment {segment.SegmentIndex} of unit {Status.CurrentUnit + 1} started..."); } SegmentStarted?.Invoke(this, segment); @@ -838,18 +594,18 @@ namespace Tango.Integration.Operation { if (segment.IsInterSegment) { - LogManager.Log($"Inter Segment completed."); + LogManager.Log($"{GetJobHandlerString()} Inter Segment completed."); } else { - LogManager.Log($"Segment {segment.SegmentIndex} of unit {Status.CurrentUnit + 1} completed."); + LogManager.Log($"{GetJobHandlerString()} Segment {segment.SegmentIndex} of unit {Status.CurrentUnit + 1} completed."); } SegmentCompleted?.Invoke(this, segment); } protected void RaiseUnitCompleted(int unit) { - LogManager.Log($"Unit {unit + 1} completed..."); + LogManager.Log($"{GetJobHandlerString()} Unit {unit + 1} completed..."); UnitCompleted?.Invoke(this, unit); } @@ -859,6 +615,11 @@ namespace Tango.Integration.Operation Finalizing?.Invoke(this, new EventArgs()); } + protected String GetJobHandlerString() + { + return $"JobHandler {_handlerCounter}:"; + } + #endregion #region Public Methods -- cgit v1.3.1