private void HandleSubMachineInterrupted(object sender, TimeStampedEventArgs e) { var interruptedMachine = sender as TransportOperationMachine; lock (_subMachineLock) { if (_isComplete) { return; } // If the move was cancelled, don't retry. if (!IsStopped && NumberOfRetries > 0) { var logMessage = string.Format(CultureInfo.InvariantCulture, "Tray move failed at {0} due to internal interruption. Value of {0}'s IsTrayDetected property: [{1}]", interruptedMachine.Station.Name, interruptedMachine.Station.IsTrayDetected); LogService.Log(LogType.System, LogMessageType.Error, GetType().Name, logMessage); Retry(interruptedMachine); } else { // Only handle as an exception if the Mover was interrupted internally, not for an external Cancel (or quit). if (!IsStopped) { RaiseTransportationException(interruptedMachine, "interruption"); } TeardownForInterruption(); } } }
private void HandleSubMachineExpired(object sender, TimeStampedEventArgs e) { var expiredMachine = sender as TransportOperationMachine; lock (_subMachineLock) { if (_isComplete) { return; } if (IsStopped) { // If the move was cancelled, don't retry. TeardownForInterruption(); } else if (NumberOfRetries > 0) { var logMessage = string.Format(CultureInfo.InvariantCulture, "Tray move failed at {0} due to expiration. Value of {0}'s IsTrayDetected property: [{1}]", expiredMachine.Station.Name, expiredMachine.Station.IsTrayDetected); LogService.Log(LogType.System, LogMessageType.Error, GetType().Name, logMessage); Retry(expiredMachine); } else { RaiseTransportationException(expiredMachine, "expiration"); TeardownForExpiration(); } } }
private void ApplyPreexistingBreakpoints(object sender, TimeStampedEventArgs args) { if (!SupportsSelfPausing || !Configuration.HasDataValue("InitialBreakpoints")) { return; } var initialBreakpoints = Configuration.Data.InitialBreakpoints as List <int>; foreach (var nodeNumber in initialBreakpoints) { PauseAtNode(nodeNumber, true); } }
private void HandleSubmachineDone(object sender, TimeStampedEventArgs args) { var submachineHost = sender as ISubmachineHost; if (submachineHost != null) { submachineHost.SubmachineDone -= HandleSubmachineDone; submachineHost.SubmachinePaused -= HandleSubmachinePaused; submachineHost.SubmachineResumed -= HandleSubmachineResumed; submachineHost.SubmachinePausableNodeEntered -= HandleSubmachinePausableNodeEntered; } // Try to exit the current node. RunToCompletion(); }
public void HandleMachineQuitting(object sender, TimeStampedEventArgs args) { var quitter = sender as ActivityMachine; if (quitter != null) { quitter.Quitting -= HandleMachineQuitting; } // Nothing to do if it's already disposed if (_internalWaitEvent != null) { LogService.Log(LogType, LogMessageType.Trace, GetType().Name, String.Format(CultureInfo.InvariantCulture, "Signaling {0} to exit delay because parent machine has quit.", Name)); Continue(); } }
private void HandleSubMachineFinished(object sender, TimeStampedEventArgs e) { var doneMachine = sender as TransportOperationMachine; TransportOperation nextOperation; TransportOperationMachine nextMachine = null; // lock here because the submachine references will be accessed. lock (_subMachineLock) { nextMachine = GetNextOperation(doneMachine, out nextOperation); if (doneMachine.Operation == TransportOperation.CompleteDropoff) { TeardownForFinished(); } else { if (nextMachine != null && Transport.State.IsNoneOf(StationState.Stopped, StationState.Disabled) && !(Transport as IStation).HasErred) { CurrentOperation = nextOperation; OnOperationBeginning(nextOperation); // Last step, execute the next machine. nextMachine.Execute(); } else { TeardownForInterruption(); } } } if (nextMachine == null && !_isComplete) { Quit(); LogService.Log(LogType.System, LogMessageType.Error, GetType().Name, string.Format(CultureInfo.InvariantCulture, "Machine '{0}' failed due to missing {1} sub-machine.", Name, nextOperation.ToString())); } }