private void Retry(TransportOperationMachine startingPoint) { LogService.Log(LogType.System, LogMessageType.Debug, GetType().Name, string.Format(CultureInfo.InvariantCulture, "Retrying Tray move at '{0}'.", startingPoint.Station.Name)); NumberOfRetries--; // Dispose of the old machines. DisposeSubmachines(); // Create new first machine to execute. InitializeSubmachine(startingPoint.Operation); // Restart execution of whichever machine died, but don't raise the Started event. switch (startingPoint.Operation) { case TransportOperation.BeginPickup: BeginPickupMachine.Execute(); break; case TransportOperation.CompletePickup: CompletePickupMachine.Execute(); break; case TransportOperation.BeginDropoff: BeginDropoffMachine.Execute(); break; case TransportOperation.CompleteDropoff: CompleteDropoffMachine.Execute(); break; } }
public void SafeStop() { lock (_subMachineLock) { if (_isComplete || IsStopped) { return; } if (CurrentOperation == TransportOperation.BeginPickup || CurrentOperation == TransportOperation.CompletePickup) { // In this case, the drop-off machines won't be built or executed. IsStopped = true; // It is not necessary to stop either pick-up machine, since they do not allow stopping internally. } // Communicate to drop-off sub-machines that this was stopped. Only BeginDropoff // will interrupt an actual move. CompleteDropoff will recover. else if (BeginDropoffMachine != null) { BeginDropoffMachine.Stop(); // BeginDropoff may have ignored the stop attempt, in which case TrayMover is not stopped. IsStopped = BeginDropoffMachine.IsStopped; } LogService.Log(LogType.System, LogMessageType.Debug, GetType().Name, string.Format(CultureInfo.InvariantCulture, "Stopping {0} was {1}.", Name, (IsStopped ? "successful" : "not allowed"))); } }