aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2021-04-25 14:21:42 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2021-04-25 14:21:42 +0300
commit5b46b59ad0507ae5034f2a1113365712181a9c00 (patch)
treef53cbbecea1a5565dab89c6fd202c93ec95e1d3f /Software/Visual_Studio/Tango.Integration
parent6432cd503b7bf334a004b079ff8de6d289b5f0af (diff)
downloadTango-5b46b59ad0507ae5034f2a1113365712181a9c00.tar.gz
Tango-5b46b59ad0507ae5034f2a1113365712181a9c00.zip
Restored machine operator changes.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs375
1 files changed, 196 insertions, 179 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index 10c0420d4..33c450856 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -1224,14 +1224,14 @@ namespace Tango.Integration.Operation
}, token).Wait();
}, () =>
- {
- //Decline
- SendResponse<CartridgeValidationResponse>(new CartridgeValidationResponse()
- {
+ {
+ //Decline
+ SendResponse<CartridgeValidationResponse>(new CartridgeValidationResponse()
+ {
- }, token).Wait();
+ }, token).Wait();
- });
+ });
CartridgeValidationRequestReceived?.Invoke(this, e);
}
@@ -1710,7 +1710,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)
@@ -1761,6 +1760,14 @@ namespace Tango.Integration.Operation
RunningJobStatus = s;
};
+ if (MachineStatus != null)
+ {
+ _machineStatusBeforeJobStart = MachineStatus.Clone();
+ }
+ else
+ {
+ _machineStatusBeforeJobStart = cache.MachineStatus.Clone();
+ }
_jobStartDate = DateTime.UtcNow;
_jobUploadingStartDate = _jobStartDate;
@@ -1773,86 +1780,86 @@ namespace Tango.Integration.Operation
Thread.Sleep(500); //Just wait maybe Shlomo is getting this message to fast after restart ?
SendContinuousRequest<ResumeCurrentJobRequest, ResumeCurrentJobResponse>(request, new TransportContinuousRequestConfig() { ContinuousTimeout = ContinuousRequestTimeout, ShouldLog = true }).Subscribe((response) =>
- {
- if (!completed)
- {
- handler.RaiseStatusReceived(response.Message.Status);
- _last_job_status = handler.Status;
+ {
+ if (!completed)
+ {
+ handler.RaiseStatusReceived(response.Message.Status);
+ _last_job_status = handler.Status;
- if (response.Message.Status.Progress > 0)
- {
- if (_jobActualStartDate == null)
- {
- _jobActualStartDate = DateTime.UtcNow;
- }
- }
+ if (response.Message.Status.Progress > 0)
+ {
+ if (_jobActualStartDate == null)
+ {
+ _jobActualStartDate = DateTime.UtcNow;
+ }
+ }
- if (!responseLogged)
- {
- UpdateStatus(MachineStatuses.GettingReady);
- responseLogged = true;
- RunningJob = job;
- OnPrintingStarted(handler, job, true);
- }
+ if (!responseLogged)
+ {
+ UpdateStatus(MachineStatuses.GettingReady);
+ responseLogged = true;
+ RunningJob = job;
+ OnPrintingStarted(handler, job, true);
+ }
- if (JobHandlingMode == JobHandlerModes.SettingUp)
- {
- if (response.Message.Status.Progress > CurrentProcessParameters.DryerBufferLengthMeters)
- {
- if (!completed)
- {
- UpdateStatus(MachineStatuses.Printing);
- }
- }
- }
- else
- {
- if (response.Message.Status.Progress > 0)
- {
- if (!completed)
- {
- UpdateStatus(MachineStatuses.Printing);
- }
- }
- }
- }
- }, (ex) =>
- {
- if (!completed)
- {
- completed = true;
+ if (JobHandlingMode == JobHandlerModes.SettingUp)
+ {
+ if (response.Message.Status.Progress > CurrentProcessParameters.DryerBufferLengthMeters)
+ {
+ if (!completed)
+ {
+ UpdateStatus(MachineStatuses.Printing);
+ }
+ }
+ }
+ else
+ {
+ if (response.Message.Status.Progress > 0)
+ {
+ if (!completed)
+ {
+ UpdateStatus(MachineStatuses.Printing);
+ }
+ }
+ }
+ }
+ }, (ex) =>
+ {
+ if (!completed)
+ {
+ completed = true;
- if (Status != MachineStatuses.Disconnected)
- {
- UpdateStatus(MachineStatuses.ReadyToDye);
- }
+ if (Status != MachineStatuses.Disconnected)
+ {
+ UpdateStatus(MachineStatuses.ReadyToDye);
+ }
- if (!handler.IsCanceled)
- {
- SaveLastJobLiquidQuantities(job, configuration, processParameters, handler);
+ if (!handler.IsCanceled)
+ {
+ SaveLastJobLiquidQuantities(job, configuration, processParameters, handler);
- Exception finalException = ex;
+ Exception finalException = ex;
- if (ex is ContinuousResponseAbortedException continuousException)
- {
- finalException = new ContinuousResponseAbortedException($"Job aborted by the embedded device ({continuousException.Container.ErrorMessage}).");
- }
+ if (ex is ContinuousResponseAbortedException continuousException)
+ {
+ finalException = new ContinuousResponseAbortedException($"Job aborted by the embedded device ({continuousException.Container.ErrorMessage}).");
+ }
- OnPrintingFailed(handler, job, finalException);
- handler.RaiseFailed(finalException);
- }
- }
- }, () =>
- {
- if (!completed)
- {
- completed = true;
- UpdateStatus(MachineStatuses.ReadyToDye);
- SaveLastJobLiquidQuantities(job, configuration, processParameters, handler);
- OnPrintingCompleted(handler, job);
- handler.RaiseCompleted();
- }
- });
+ OnPrintingFailed(handler, job, finalException);
+ handler.RaiseFailed(finalException);
+ }
+ }
+ }, () =>
+ {
+ if (!completed)
+ {
+ completed = true;
+ UpdateStatus(MachineStatuses.ReadyToDye);
+ SaveLastJobLiquidQuantities(job, configuration, processParameters, handler);
+ OnPrintingCompleted(handler, job);
+ handler.RaiseCompleted();
+ }
+ });
return handler;
});
@@ -2285,6 +2292,8 @@ namespace Tango.Integration.Operation
/// <param name="handler">The handler.</param>
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;
@@ -2303,6 +2312,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,
@@ -2315,10 +2330,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.");
}
}
@@ -3085,95 +3102,95 @@ namespace Tango.Integration.Operation
_jobHeatingStartDate = DateTime.UtcNow;
SendContinuousRequest<JobRequest, JobResponse>(request, new TransportContinuousRequestConfig() { ContinuousTimeout = ContinuousRequestTimeout.Add(TimeSpan.FromSeconds(3)), ShouldLog = true }).Subscribe((response) =>
- {
- if (!completed)
- {
- handler.RaiseStatusReceived(response.Message.Status);
- _last_job_status = handler.Status;
+ {
+ if (!completed)
+ {
+ handler.RaiseStatusReceived(response.Message.Status);
+ _last_job_status = handler.Status;
- if (response.Message.Status.Progress > 0)
- {
- if (oldKeepAlive != UseKeepAlive)
- {
- UseKeepAlive = oldKeepAlive;
- }
+ if (response.Message.Status.Progress > 0)
+ {
+ if (oldKeepAlive != UseKeepAlive)
+ {
+ UseKeepAlive = oldKeepAlive;
+ }
- if (_jobActualStartDate == null)
- {
- _jobActualStartDate = DateTime.UtcNow;
- }
- }
+ if (_jobActualStartDate == null)
+ {
+ _jobActualStartDate = DateTime.UtcNow;
+ }
+ }
- if (!responseLogged)
- {
- requestSent = true;
- responseLogged = true;
- }
+ if (!responseLogged)
+ {
+ requestSent = true;
+ responseLogged = true;
+ }
- if (JobHandlingMode == JobHandlerModes.SettingUp)
- {
- if (response.Message.Status.Progress > processParameters.DryerBufferLengthMeters)
- {
- if (!completed)
- {
- UpdateStatus(MachineStatuses.Printing);
- }
- }
- }
- else
- {
- if (response.Message.Status.Progress > 0)
- {
- if (!completed)
- {
- UpdateStatus(MachineStatuses.Printing);
- }
- }
- }
- }
+ if (JobHandlingMode == JobHandlerModes.SettingUp)
+ {
+ if (response.Message.Status.Progress > processParameters.DryerBufferLengthMeters)
+ {
+ if (!completed)
+ {
+ UpdateStatus(MachineStatuses.Printing);
+ }
+ }
+ }
+ else
+ {
+ if (response.Message.Status.Progress > 0)
+ {
+ if (!completed)
+ {
+ UpdateStatus(MachineStatuses.Printing);
+ }
+ }
+ }
+ }
- }, (ex) =>
- {
- if (!completed)
- {
- completed = true;
+ }, (ex) =>
+ {
+ if (!completed)
+ {
+ completed = true;
- UseKeepAlive = oldKeepAlive;
+ UseKeepAlive = oldKeepAlive;
- if (Status != MachineStatuses.Disconnected)
- {
- UpdateStatus(MachineStatuses.ReadyToDye);
- }
+ if (Status != MachineStatuses.Disconnected)
+ {
+ UpdateStatus(MachineStatuses.ReadyToDye);
+ }
- if (!handler.IsCanceled)
- {
- SaveLastJobLiquidQuantities(originalJob, originalJob.Machine.Configuration, processParameters, handler);
+ if (!handler.IsCanceled)
+ {
+ SaveLastJobLiquidQuantities(originalJob, originalJob.Machine.Configuration, processParameters, handler);
- Exception finalException = ex;
+ Exception finalException = ex;
- if (ex is ContinuousResponseAbortedException continuousException)
- {
- finalException = new ContinuousResponseAbortedException($"Job aborted by the embedded device ({continuousException.Container.ErrorMessage}).");
- }
+ if (ex is ContinuousResponseAbortedException continuousException)
+ {
+ finalException = new ContinuousResponseAbortedException($"Job aborted by the embedded device ({continuousException.Container.ErrorMessage}).");
+ }
- OnPrintingFailed(handler, originalJob, finalException);
- handler.RaiseFailed(finalException);
- }
- }
- }, () =>
- {
- if (!completed)
- {
- completed = true;
+ OnPrintingFailed(handler, originalJob, finalException);
+ handler.RaiseFailed(finalException);
+ }
+ }
+ }, () =>
+ {
+ if (!completed)
+ {
+ completed = true;
- UseKeepAlive = oldKeepAlive;
+ UseKeepAlive = oldKeepAlive;
- UpdateStatus(MachineStatuses.ReadyToDye);
- SaveLastJobLiquidQuantities(clonedJob, originalJob.Machine.Configuration, processParameters, handler);
- OnPrintingCompleted(handler, clonedJob);
- handler.RaiseCompleted();
- }
- });
+ UpdateStatus(MachineStatuses.ReadyToDye);
+ SaveLastJobLiquidQuantities(clonedJob, originalJob.Machine.Configuration, processParameters, handler);
+ OnPrintingCompleted(handler, clonedJob);
+ handler.RaiseCompleted();
+ }
+ });
});
return handler;
@@ -4066,30 +4083,30 @@ namespace Tango.Integration.Operation
bool firstResponse = true;
SendContinuousRequest<StartPowerDownRequest, StartPowerDownResponse>(new StartPowerDownRequest(), new TransportContinuousRequestConfig() { ContinuousTimeout = TimeSpan.FromSeconds(2), ShouldLog = true }).ObserveOn(new NewThreadScheduler()).Subscribe((response) =>
- {
- if (firstResponse)
- {
- firstResponse = false;
- UpdateStatus(MachineStatuses.ShuttingDown);
- }
+ {
+ if (firstResponse)
+ {
+ firstResponse = false;
+ UpdateStatus(MachineStatuses.ShuttingDown);
+ }
- handler.RaiseStatusChanged(response);
- }, (ex) =>
- {
- if (_isPowerDownRequestInProgress)
- {
- _isPowerDownRequestInProgress = false;
- LogManager.Log(ex, "Power down error.");
- handler.RaiseFailed(ex);
- }
- }, () =>
- {
- if (_isPowerDownRequestInProgress)
- {
- _isPowerDownRequestInProgress = false;
- handler.RaiseCompleted();
- }
- });
+ handler.RaiseStatusChanged(response);
+ }, (ex) =>
+ {
+ if (_isPowerDownRequestInProgress)
+ {
+ _isPowerDownRequestInProgress = false;
+ LogManager.Log(ex, "Power down error.");
+ handler.RaiseFailed(ex);
+ }
+ }, () =>
+ {
+ if (_isPowerDownRequestInProgress)
+ {
+ _isPowerDownRequestInProgress = false;
+ handler.RaiseCompleted();
+ }
+ });
});
PowerDownStarted?.Invoke(this, new PowerDownStartedEventArgs()