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.cs86
1 files changed, 85 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index 8cc2465b9..d75e2fc49 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -21,6 +21,8 @@ using Tango.BL.Entities;
using Tango.PMR.Hardware;
using Google.Protobuf;
using Tango.PMR.Connection;
+using Tango.BL.Enumerations;
+using Tango.BL.ColorConversion;
namespace Tango.Integration.Operation
{
@@ -471,6 +473,74 @@ namespace Tango.Integration.Operation
#region Public Methods
/// <summary>
+ /// Prints the specified job.
+ /// The process parameters table will be calculated using color conversion gamut region.
+ /// This method cannot accept brush stops with 'Volume' as color space.
+ /// </summary>
+ /// <param name="job">The job.</param>
+ /// <returns></returns>
+ public JobHandler Print(Job job)
+ {
+ //Check not brush stop has color space 'Volume'.
+ if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32()))
+ {
+ throw new InvalidOperationException("Cannot print a brush stop with volume color space when process parameters table has not been specified.");
+ }
+
+ //Get least common process parameters table index.
+ int processParametersTableIndex = TangoColorConverter.GetLeastCommonProcessParametersTableIndex(job.Segments.SelectMany(x => x.BrushStops));
+
+ if (job.Rml == null)
+ {
+ throw new NullReferenceException("Job RML is null");
+ }
+
+ var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active);
+
+ if (processGroup == null)
+ {
+ throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name);
+ }
+
+ var processParameters = processGroup.ProcessParametersTables.FirstOrDefault(x => x.TableIndex == processParametersTableIndex);
+
+ if (processParameters == null)
+ {
+ throw new NullReferenceException("Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name);
+ }
+
+ //Perform color correction
+ foreach (var stop in job.Segments.SelectMany(x => x.BrushStops))
+ {
+ if (stop.LiquidVolumes == null)
+ {
+ var suggestions = TangoColorConverter.GetSuggestions(stop);
+
+ if (suggestions.OutOfGamut)
+ {
+ throw new InvalidOperationException("Cannot print a brush stop which is out of gamut.");
+ }
+
+ stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters);
+
+ foreach (var outputLiquid in suggestions.SingleCoordinates.OutputLiquids)
+ {
+ var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32());
+
+ if (liquidVolume == null)
+ {
+ throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'.");
+ }
+
+ liquidVolume.Volume = outputLiquid.Volume;
+ }
+ }
+ }
+
+ return Print(job, processParameters);
+ }
+
+ /// <summary>
/// Prints the specified job using the specified job parameters.
/// </summary>
/// <param name="job">The job.</param>
@@ -478,10 +548,24 @@ namespace Tango.Integration.Operation
/// <returns></returns>
public JobHandler Print(Job job, ProcessParametersTable processParameters)
{
+ var originalJob = job;
+
CurrentProcessParameters = processParameters;
JobRequest request = new JobRequest();
+ job = job.Clone();
+
+ var segments = job.Segments.ToList();
+
+ for (int i = 0; i < job.NumberOfUnits - 1; i++)
+ {
+ foreach (var s in segments)
+ {
+ job.Segments.Add(s);
+ }
+ }
+
JobTicket ticket = new JobTicket();
ticket.EnableInterSegment = job.EnableInterSegment;
ticket.InterSegmentLength = job.InterSegmentLength;
@@ -553,7 +637,7 @@ namespace Tango.Integration.Operation
{
LogManager.Log(ex, "Failed to cancel job.");
}
- }, job, processParameters);
+ }, originalJob, processParameters);
LogRequestSent(request);
bool responseLogged = false;