aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs89
1 files changed, 77 insertions, 12 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index 943afa21a..867ac7ec1 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -38,6 +38,7 @@ using Tango.Core.ExtensionMethods;
using Tango.ColorConversion;
using Tango.Integration.Emergency;
using Tango.PMR.MachineStatus;
+using Newtonsoft.Json;
namespace Tango.Integration.Operation
{
@@ -51,6 +52,7 @@ namespace Tango.Integration.Operation
public const String FIRMWARE_UPGRADE_FOLDER_NAME = "UpgradePackage";
public const String FIRMWARE_UPGRADE_CONFIG_FILE_NAME = "package.cfg";
public const String JOB_DESCRIPTION_FILE_NAME = "job_segments.jdf";
+ public const int MAX_DISPENSER_NANOLITER = 130000000;
private bool _diagnosticsSent;
private bool _eventsSent;
@@ -97,6 +99,7 @@ namespace Tango.Integration.Operation
FirmwareUpgradeMode = FirmwareUpgradeModes.DFU | FirmwareUpgradeModes.TFP_PACKAGE;
GradientGenerationConfiguration = new DefaultGradientGenerationConfiguration();
EmergencyNotificationProvider = new UsbEmergencyNotificationProvider("COM1");
+ EnableJobLiquidQuantityValidation = true;
}
/// <summary>
@@ -248,6 +251,12 @@ namespace Tango.Integration.Operation
}
/// <summary>
+ /// Gets or sets a value indicating whether to enable liquid quantity validation before starting the job.
+ /// The validation is done using the reported <see cref="MachineStatus" />.
+ /// </summary>
+ public bool EnableJobLiquidQuantityValidation { get; set; }
+
+ /// <summary>
/// Gets or sets the firmware upgrade mode.
/// </summary>
public FirmwareUpgradeModes FirmwareUpgradeMode { get; set; }
@@ -1323,7 +1332,7 @@ namespace Tango.Integration.Operation
});
}
- private void ValidateJobLiquidQuantity(JobTicket ticket, ProcessParametersTable processParameters, Configuration configuration)
+ private void ValidateJobLiquidQuantity(Job job, ProcessParametersTable processParameters, Configuration configuration)
{
Dictionary<int, double> liquidQuantities = new Dictionary<int, double>();
@@ -1332,23 +1341,76 @@ namespace Tango.Integration.Operation
liquidQuantities.Add(pack.PackIndex, 0);
}
- for (int segmentIndex = 0; segmentIndex < ticket.Segments.Count; segmentIndex++)
+ for (int i = 0; i < Math.Max(job.NumberOfUnits, 1); i++)
+ {
+ for (int segmentIndex = 0; segmentIndex < job.Segments.Count; segmentIndex++)
+ {
+ var segment = job.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;
+
+ for (int stopIndex = 0; stopIndex < stop_count; stopIndex++)
+ {
+ var stop = segment.BrushStops[stopIndex];
+
+ foreach (var liquidVolumes in stop.LiquidVolumes)
+ {
+ liquidQuantities[liquidVolumes.IdsPack.PackIndex] += liquidVolumes.NanoliterPerCentimeter * stop_length_centimeters;
+ }
+ }
+ }
+ }
+
+ if (MachineStatus != null)
{
- var segment = ticket.Segments[segmentIndex];
- var segment_length_cm = segment.Length * 100d;
+ var exception = new InsufficientLiquidQuantityException($"Insufficient liquids level.");
- var stop_count = segment.BrushStops.Count - (segment.BrushStops.Count == 1 ? 0 : 1);
- var stop_length_centimeters = segment_length_cm / stop_count;
+ bool shouldThrow = false;
- for (int stopIndex = 0; stopIndex < stop_count; stopIndex++)
+ foreach (var liquidQuantity in liquidQuantities)
{
- var stop = segment.BrushStops[stopIndex];
+ int index = liquidQuantity.Key;
+ var packLevel = MachineStatus.IDSPacksLevels.SingleOrDefault(x => x.Index == index);
+ var idsPack = configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == index);
+
+ if (packLevel != null)
+ {
+ var idsLevel = new InsufficientLiquidQuantityException.IDSPackLevel()
+ {
+ IdsPack = idsPack,
+ Current = packLevel.DispenserLevel,
+ Required = (int)liquidQuantities[index]
+ };
- foreach (var dispenser in stop.Dispensers)
+ if (liquidQuantities[index] > packLevel.DispenserLevel)
+ {
+ shouldThrow = true;
+ }
+
+ exception.IdsPackLevels.Add(idsLevel);
+ }
+ else
{
- liquidQuantities[dispenser.Index] += dispenser.NanoliterPerCentimeter * stop_length_centimeters;
+ LogManager.Log($"Could not validate required liquid quantity for job. Missing IDS Pack level at index {index}.", LogCategory.Warning);
}
}
+
+
+ if (shouldThrow)
+ {
+ throw LogManager.Log(exception, JsonConvert.SerializeObject(exception.IdsPackLevels.Select(x => new
+ {
+ Liquid = x.IdsPack.LiquidType.Name,
+ x.Required,
+ x.Current
+ }).ToList()));
+ }
+ }
+ else
+ {
+ LogManager.Log("Could not validate required liquid quantity for job. No machine status received", LogCategory.Warning);
}
}
@@ -1525,6 +1587,11 @@ namespace Tango.Integration.Operation
job.NumberOfUnits = 1;
}
+ if (EnableJobLiquidQuantityValidation)
+ {
+ ValidateJobLiquidQuantity(job, processParameters, job.Machine.Configuration);
+ }
+
var originalJob = job;
var clonedJob = job.Clone();
clonedJob.Guid = job.Guid;
@@ -1697,8 +1764,6 @@ namespace Tango.Integration.Operation
ticket.Segments.AddRange(segs);
}
- ValidateJobLiquidQuantity(ticket, processParameters, job.Machine.Configuration);
-
request.JobTicket = ticket.Clone();
request.JobTicket.UploadStrategy = JobUploadStrategy;