From ccaec5a493d2880c1d82b64bcad804fa51db6c57 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 25 Apr 2021 13:38:55 +0300 Subject: Job runs fixes. --- .../JobRuns/BasicJobRunsLogger.cs | 5 +++++ .../Tango.Integration/Operation/MachineOperator.cs | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/Tango.Integration') diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index 7ba38c9ca..2b7c931f0 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -8,6 +8,7 @@ using Tango.BL.Builders; using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.Core; +using Tango.Core.ExtensionMethods; using Tango.Integration.Operation; namespace Tango.Integration.JobRuns @@ -177,6 +178,8 @@ namespace Tango.Integration.JobRuns job.LastRun = DateTime.UtcNow; } + LogManager.Log($"Inserting job run for '{run.JobName}'...\n{run.ToJsonString(nameof(JobRun.JobString), nameof(JobRun.LiquidQuantityString))}"); + db.SaveChanges(); } } @@ -264,6 +267,8 @@ namespace Tango.Integration.JobRuns db.JobRuns.Add(run); + LogManager.Log($"Inserting head cleaning job run...\n{run.ToJsonString(nameof(JobRun.JobString), nameof(JobRun.LiquidQuantityString))}"); + db.SaveChanges(); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index bf21df35d..5bceef5aa 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -45,6 +45,7 @@ using Tango.PMR.Power; using Tango.PMR.ThreadLoading; using Tango.BL.DTO; using Tango.PMR.IFS; +using System.Diagnostics; namespace Tango.Integration.Operation { @@ -1701,7 +1702,6 @@ namespace Tango.Integration.Operation processParameters = cache.ProcessParametersDTO.ToObservable(); job = cache.JobDTO.ToObservable(); configuration = cache.MachineConfigurationDTO.ToObservable(); - _machineStatusBeforeJobStart = cache.MachineStatus; CurrentProcessParameters = processParameters; } catch (Exception ex) @@ -1752,6 +1752,14 @@ namespace Tango.Integration.Operation RunningJobStatus = s; }; + if (MachineStatus != null) + { + _machineStatusBeforeJobStart = MachineStatus.Clone(); + } + else + { + _machineStatusBeforeJobStart = cache.MachineStatus.Clone(); + } _jobStartDate = DateTime.UtcNow; _jobUploadingStartDate = _jobStartDate; @@ -2165,6 +2173,8 @@ namespace Tango.Integration.Operation /// The handler. private void SaveLastJobLiquidQuantities(Job job, Configuration configuration, ProcessParametersTable processParameters, JobHandler handler) { + LogManager.Log($"Calculating job run liquid quantities using '{JobLiquidQuantityCalculationMode}' method..."); + if (configuration == null) { configuration = _machineConfiguration; @@ -2183,6 +2193,12 @@ namespace Tango.Integration.Operation if (packLevelAfter != null && packLevelBefore != null) { + if (packLevelAfter.DispenserLevel > packLevelBefore.DispenserLevel) + { + LogManager.Log($"Invalid '{pack.LiquidType.Name}' dispenser level calculated: {packLevelBefore.DispenserLevel} - {packLevelAfter.DispenserLevel} = {packLevelBefore.DispenserLevel - packLevelAfter.DispenserLevel}. Ignoring..."); + continue; + } + _lastJobLiquidQuantities.Add(new BL.ValueObjects.JobRunLiquidQuantity() { LiquidType = pack.LiquidType.Type, @@ -2195,10 +2211,12 @@ namespace Tango.Integration.Operation { _lastJobLiquidQuantities = CreateJobRunLiquidQuantities(job, configuration, processParameters, handler.Status.Progress, handler.Status.TotalProgress); } + + LogManager.Log($"Job run liquid quantities calculation completed:\n{_lastJobLiquidQuantities.ToJsonString()}"); } catch (Exception ex) { - LogManager.Log(ex, LogCategory.Critical, "Error saving last job liquid quantities."); + LogManager.Log(ex, LogCategory.Critical, "Error calculating and saving last job run liquid quantities."); } } -- cgit v1.3.1