aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-01-19 16:44:31 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-01-19 16:44:31 +0200
commit601c03423f2f623d28df991ef6870e3d981ffe05 (patch)
tree1bec616b2dce06c2c8f3f5dd4e58f4afc42b1945 /Software/Visual_Studio
parent43eaac54536c3534df14fff9efa9ddae40877903 (diff)
downloadTango-601c03423f2f623d28df991ef6870e3d981ffe05.tar.gz
Tango-601c03423f2f623d28df991ef6870e3d981ffe05.zip
Calculation DispenserLevel in Emulator for each packLevel for run Job.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs110
1 files changed, 86 insertions, 24 deletions
diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
index 8ac03b23f..06a287693 100644
--- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
+++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
@@ -693,51 +693,113 @@ namespace Tango.Emulations.Emulators
double centimeter_per_second = request.Message.JobTicket.ProcessParameters.DyeingSpeed;
- double progress = 0;
_cancelJob = false;
bool message_sent = false;
- double length = job.Length;
+ int units = (int)Math.Max(job.NumberOfUnits, 1);
+ double unit_length = job.Length / units;
Task.Factory.StartNew(() =>
{
MachineStatus.State = MachineState.RunningJob;
- while (progress < length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS && !_cancelJob)
+ List<JobBrushStop> calculatedStops = new List<JobBrushStop>();
+
+ for (int i = 0; i < job.NumberOfUnits; i++)
{
- var status = new PMR.Printing.JobStatus();
- status.Progress = progress;
+ double progress = 0;
+ double lastProgress = 0;
- if (!message_sent)
+ while (progress < unit_length + (i == units - 1 ? (job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS) : 0) && !_cancelJob)
{
- message_sent = true;
- status.Message = "Demo Message From Emulator...";
- }
+ var status = new PMR.Printing.JobStatus();
+ status.Progress = progress;
- if (!EmulateCorruption)
- {
- if (_current_job_resume_token == null)
+ if (!message_sent)
+ {
+ message_sent = true;
+ status.Message = "Demo Message From Emulator...";
+ }
+
+ if (!EmulateCorruption)
{
- Transporter.SendResponse<JobResponse>(new JobResponse()
+ if (_current_job_resume_token == null)
{
- Status = status,
+ Transporter.SendResponse<JobResponse>(new JobResponse()
+ {
+ Status = status,
- }, request.Container.Token);
+ }, request.Container.Token);
+ }
+ else
+ {
+ Transporter.SendResponse<ResumeCurrentJobResponse>(new ResumeCurrentJobResponse()
+ {
+ Status = status,
+
+ }, _current_job_resume_token);
+ }
}
- else
+
+ progress += Math.Min((centimeter_per_second / 1000d), (unit_length + (i == units - 1 ? (job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS) : 0)) - progress);
+
+
+ double currentPosition = 0;
+ double nextStopPosition = unit_length;
+ for (int seg_index = 0; seg_index < _current_job_ticket.Segments.Count(); seg_index++)
{
- Transporter.SendResponse<ResumeCurrentJobResponse>(new ResumeCurrentJobResponse()
+ var segment = _current_job_ticket.Segments[seg_index];
+ if ((seg_index + 1) < _current_job_ticket.Segments.Count())
+ {
+ nextStopPosition = _current_job_ticket.Segments[seg_index + 1].Length;
+ }
+
+ for (int index = 0; index < segment.BrushStops.Count(); index++)
{
- Status = status,
+ var stop = segment.BrushStops[index];
+ if ((index + 1) < segment.BrushStops.Count())
+ {
+ var nextStop = segment.BrushStops[index + 1];
+ nextStopPosition = nextStop.OffsetMeters;
+ }
+
+ if (!calculatedStops.Contains(stop))
+ {
+ var brushStopPosition = currentPosition + stop.OffsetMeters;
+ if (brushStopPosition >= lastProgress && brushStopPosition <= progress)
+ {
+ foreach (var dispenser in stop.Dispensers)
+ {
+ var quantity = dispenser.NanoliterPerCentimeter * (nextStopPosition - stop.OffsetMeters) * 100d;
+ var packLevel = MachineStatus.IDSPacksLevels.SingleOrDefault(x => x.Index == dispenser.Index);
+ if (packLevel != null)
+ {
+ packLevel.DispenserLevel -= (int)quantity;
+ }
+ }
- }, _current_job_resume_token);
+ calculatedStops.Add(stop);
+ }
+ }
+ }
+ currentPosition += segment.Length;
}
- }
+ lastProgress = progress;
- progress += Math.Min((centimeter_per_second / 1000d), (length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS) - progress);
+ Thread.Sleep(100);
+ }
- Thread.Sleep(100);
+ if (_cancelJob)
+ {
+ break;
+ }
}
+ foreach( var packLevel in MachineStatus.IDSPacksLevels)
+ {
+ Debug.WriteLine($"packLevel.DispenserLevel = {packLevel.DispenserLevel}");
+ Debug.WriteLine($"quantity = {130000000 - packLevel.DispenserLevel}");
+ Debug.WriteLine($"packLevel.Index = {packLevel.Index}");
+ }
_current_job_ticket = null;
if (_cancelJob)
@@ -765,7 +827,7 @@ namespace Tango.Emulations.Emulators
{
Status = new PMR.Printing.JobStatus()
{
- Progress = length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS,
+ Progress = unit_length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS,
}
}, request.Container.Token, !_cancelJob);
@@ -776,7 +838,7 @@ namespace Tango.Emulations.Emulators
{
Status = new PMR.Printing.JobStatus()
{
- Progress = length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS,
+ Progress = unit_length + job.ProcessParameters.DryerBufferLength * ProcessParametersTable.DRYER_METERS_PER_CYCLE + ProcessParametersTable.DRYER_TO_SPOOL_LENGTH_METERS,
}
}, _current_job_resume_token, !_cancelJob);