aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2021-04-19 00:29:23 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2021-04-19 00:29:23 +0300
commit35a617cbde0f62ef3b5a69b0cbe2965bb134e5ec (patch)
treebcfac6de4428454662e569d2ff90476e085d42f3
parentcaa0881daeb93c63aee889f06473be01998f1395 (diff)
downloadTango-35a617cbde0f62ef3b5a69b0cbe2965bb134e5ec.tar.gz
Tango-35a617cbde0f62ef3b5a69b0cbe2965bb134e5ec.zip
Validate liquid quantities fix when Mirta is generating gradients.
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs5
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest2
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs175
3 files changed, 113 insertions, 69 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 35e27c834..ba21e4875 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
@@ -895,7 +895,10 @@ namespace Tango.MachineStudio.Developer.ViewModels
stop.Corrected = true;
stop.IsOutOfGamut = false;
}
- catch { }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.ToString());
+ }
}
else if (stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32() || stop.ColorSpace.Code == BL.Enumerations.ColorSpaces.LAB.ToInt32())
{
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
index d72e75011..efc5f8179 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
@@ -16,7 +16,7 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
- <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
+ <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
</requestedPrivileges>
</security>
</trustInfo>
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index 91a2a1b77..10c0420d4 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -2031,7 +2031,7 @@ namespace Tango.Integration.Operation
private List<RequiredLiquid> ValidateJobLiquidQuantity(Job job, ProcessParametersTable processParameters, Configuration configuration)
{
- LogManager.Log("Validating job liquid quantities...");
+ LogManager.Log("Validating job liquid quantities using integral...");
Dictionary<int, double> liquidQuantities = new Dictionary<int, double>();
List<RequiredLiquid> requiredLiquids = new List<RequiredLiquid>();
@@ -2166,84 +2166,42 @@ namespace Tango.Integration.Operation
return requiredLiquids;
}
- /// <summary>
- /// Assign the liquid quantities spent by the last job using the job and the handler last status.
- /// </summary>
- /// <param name="job">The job.</param>
- /// <param name="configuration">The configuration.</param>
- /// <param name="handler">The handler.</param>
- private void SaveLastJobLiquidQuantities(Job job, Configuration configuration, ProcessParametersTable processParameters, JobHandler handler)
+ private List<RequiredLiquid> ValidateJobLiquidQuantity(JobTicket ticket, ProcessParametersTable processParameters, Configuration configuration)
{
- if (configuration == null)
- {
- configuration = _machineConfiguration;
- }
-
- try
- {
- _lastJobLiquidQuantities = new List<BL.ValueObjects.JobRunLiquidQuantity>();
-
- if (JobLiquidQuantityCalculationMode == JobLiquidQuantityCalculationMode.MachineStatus)
- {
- foreach (var pack in configuration.NoneEmptyIdsPacks.ToList())
- {
- var packLevelAfter = MachineStatus.IDSPacksLevels.SingleOrDefault(x => x.Index == pack.PackIndex);
- var packLevelBefore = _machineStatusBeforeJobStart.IDSPacksLevels.SingleOrDefault(x => x.Index == pack.PackIndex);
-
- if (packLevelAfter != null && packLevelBefore != null)
- {
- _lastJobLiquidQuantities.Add(new BL.ValueObjects.JobRunLiquidQuantity()
- {
- LiquidType = pack.LiquidType.Type,
- Quantity = packLevelBefore.DispenserLevel - packLevelAfter.DispenserLevel,
- });
- }
- }
- }
- else
- {
- _lastJobLiquidQuantities = CreateJobRunLiquidQuantities(job, configuration, processParameters, handler.Status.Progress, handler.Status.TotalProgress);
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, LogCategory.Critical, "Error saving last job liquid quantities.");
- }
- }
-
- private void ValidateJobLiquidQuantity(JobTicket ticket, ProcessParametersTable processParameters, Configuration configuration)
- {
- LogManager.Log("Validating job liquid quantity...");
+ LogManager.Log("Validating job liquid quantity using job ticket...");
Dictionary<int, double> liquidQuantities = new Dictionary<int, double>();
+ List<RequiredLiquid> requiredLiquids = new List<RequiredLiquid>();
foreach (var pack in configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex))
{
liquidQuantities.Add(pack.PackIndex, 0);
}
- for (int i = 0; i < Math.Max(ticket.NumberOfUnits, 1); i++)
+ for (int segmentIndex = 0; segmentIndex < ticket.Segments.Count; segmentIndex++)
{
- for (int segmentIndex = 0; segmentIndex < ticket.Segments.Count; segmentIndex++)
- {
- var segment = ticket.Segments[segmentIndex];
- var segment_length_cm = segment.Length * 100d;
+ var segment = ticket.Segments[segmentIndex];
+ var segment_length_cm = segment.Length * 100d;
- var stop_count = segment.BrushStops.Count - (segment.BrushStops.Count == 1 ? 0 : 1);
- var stop_length_centimeters = segment_length_cm / stop_count;
+ var stop_count = segment.BrushStops.Count - (segment.BrushStops.Count == 1 ? 0 : 1);
+ var stop_length_centimeters = segment_length_cm / stop_count;
- for (int stopIndex = 0; stopIndex < stop_count; stopIndex++)
- {
- var stop = segment.BrushStops[stopIndex];
+ for (int stopIndex = 0; stopIndex < stop_count; stopIndex++)
+ {
+ var stop = segment.BrushStops[stopIndex];
- foreach (var dispenser in stop.Dispensers)
- {
- liquidQuantities[dispenser.Index] += dispenser.NanoliterPerCentimeter * stop_length_centimeters;
- }
+ foreach (var dispenser in stop.Dispensers)
+ {
+ liquidQuantities[dispenser.Index] += dispenser.NanoliterPerCentimeter * stop_length_centimeters;
}
}
}
+ foreach (var key in liquidQuantities.Select(x => x.Key).ToList())
+ {
+ liquidQuantities[key] *= Math.Max(ticket.NumberOfUnits, 1);
+ }
+
if (MachineStatus != null)
{
var exception = new InsufficientLiquidQuantityException($"Insufficient liquids level.");
@@ -2266,9 +2224,26 @@ namespace Tango.Integration.Operation
Maximum = MAX_DISPENSER_NANOLITER,
};
- if (liquidQuantities[index] > packLevel.DispenserLevel)
+ requiredLiquids.Add(new RequiredLiquid()
+ {
+ IdsPack = idsPack,
+ Quantity = (int)liquidQuantities[index]
+ });
+
+ LogManager.Log($"Required {idsLevel.IdsPack.LiquidType.Type}: {idsLevel.Required}, Current: {idsLevel.Current}");
+
+ if (idsLevel.Required > idsLevel.Current)
{
shouldThrow = true;
+
+ string display_value = (((double)(idsLevel.Required - idsLevel.Current) / 1000000)).ToString("N2", CultureInfo.InvariantCulture);
+ idsLevel.Message = $"Missing {display_value} CC to complete the job.";
+
+ if (idsLevel.Required > idsLevel.Maximum)
+ {
+ display_value = (((double)(idsLevel.Required - idsLevel.Maximum)) / 1000000).ToString("N2", CultureInfo.InvariantCulture);
+ idsLevel.Message = $"Required ink exceeds the maximum capacity of the dispenser by {display_value} CC. Please reduce the segment length.";
+ }
}
exception.IdsPackLevels.Add(idsLevel);
@@ -2282,6 +2257,10 @@ namespace Tango.Integration.Operation
if (shouldThrow)
{
+ LogManager.Log("Liquid quantity validation failed due to insufficient quantity. Throwing exception...");
+
+ exception.IdsPackLevels = exception.IdsPackLevels.OrderBy(x => x.IdsPack.PackIndex).ToList();
+
throw LogManager.Log(exception, JsonConvert.SerializeObject(exception.IdsPackLevels.Select(x => new
{
Liquid = x.IdsPack.LiquidType.Name,
@@ -2294,6 +2273,53 @@ namespace Tango.Integration.Operation
{
LogManager.Log("Could not validate required liquid quantity for job. No machine status received", LogCategory.Warning);
}
+
+ return requiredLiquids;
+ }
+
+ /// <summary>
+ /// Assign the liquid quantities spent by the last job using the job and the handler last status.
+ /// </summary>
+ /// <param name="job">The job.</param>
+ /// <param name="configuration">The configuration.</param>
+ /// <param name="handler">The handler.</param>
+ private void SaveLastJobLiquidQuantities(Job job, Configuration configuration, ProcessParametersTable processParameters, JobHandler handler)
+ {
+ if (configuration == null)
+ {
+ configuration = _machineConfiguration;
+ }
+
+ try
+ {
+ _lastJobLiquidQuantities = new List<BL.ValueObjects.JobRunLiquidQuantity>();
+
+ if (JobLiquidQuantityCalculationMode == JobLiquidQuantityCalculationMode.MachineStatus)
+ {
+ foreach (var pack in configuration.NoneEmptyIdsPacks.ToList())
+ {
+ var packLevelAfter = MachineStatus.IDSPacksLevels.SingleOrDefault(x => x.Index == pack.PackIndex);
+ var packLevelBefore = _machineStatusBeforeJobStart.IDSPacksLevels.SingleOrDefault(x => x.Index == pack.PackIndex);
+
+ if (packLevelAfter != null && packLevelBefore != null)
+ {
+ _lastJobLiquidQuantities.Add(new BL.ValueObjects.JobRunLiquidQuantity()
+ {
+ LiquidType = pack.LiquidType.Type,
+ Quantity = packLevelBefore.DispenserLevel - packLevelAfter.DispenserLevel,
+ });
+ }
+ }
+ }
+ else
+ {
+ _lastJobLiquidQuantities = CreateJobRunLiquidQuantities(job, configuration, processParameters, handler.Status.Progress, handler.Status.TotalProgress);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, LogCategory.Critical, "Error saving last job liquid quantities.");
+ }
}
#endregion
@@ -2616,12 +2642,29 @@ namespace Tango.Integration.Operation
}
}
+ var segments = job.OrderedSegments.ToList();
+
List<RequiredLiquid> requiredLiquids = null;
- //Validate liquid quantities..
+ //Validate liquid quantities
if (EnableJobLiquidQuantityValidation)
{
- requiredLiquids = ValidateJobLiquidQuantity(job, processParameters, job.Machine.Configuration);
+ if (!originalJob.Rml.UseColorLibGradients) //Validate liquid quantities when ColorLib generate gradient is disabled
+ {
+ requiredLiquids = ValidateJobLiquidQuantity(job, processParameters, job.Machine.Configuration);
+ }
+ else //Validate liquid quantities when ColorLib generate gradient is enabled
+ {
+ JobTicket t = new JobTicket();
+ t.NumberOfUnits = (uint)originalJob.NumberOfUnits;
+
+ foreach (var segment in segments)
+ {
+ t.Segments.Add(CreatePMRJobSegment(segment, originalJob, processParameters));
+ }
+
+ requiredLiquids = ValidateJobLiquidQuantity(t, processParameters, job.Machine.Configuration);
+ }
}
else
{
@@ -2634,8 +2677,6 @@ namespace Tango.Integration.Operation
int max = job.OrderedSegments.Last().SegmentIndex + 1;
- var segments = job.OrderedSegments.ToList();
-
for (int i = 0; i < job.NumberOfUnits - 1; i++)
{
foreach (var s in segments)