public void StackBuildingElementConstructed(StackAlgorithm aAlg, StackOutputEntry aEntry) { lock (this) { iEngine.DataOutput.InsertAsFirstEntry(aEntry); } }
private void ExecuteHeadAlgorithm() { Trace("[SBAlgManager] ExecuteHeadAlgorithm() - iSynchronicity: {0}", iSynchronicity); StackAlgorithm alg = CurrentAlgorithm; alg.BuildStack(iSynchronicity); }
public void StackBuldingProgress(StackAlgorithm aAlg, int aPercent) { Trace("[SBAlgManager] StackBuldingProgress() - aAlg: {0}, aPercent: {1}", aAlg, aPercent); lock (this) { iProgressValueCurrent = aPercent; } // ReportEvent(TEvent.EAlgorithmProgress); }
private void EnqueueBackupAlgorithms(StackAlgorithm aExclude) { foreach (StackAlgorithm alg in iMasterAlgorithmTable) { string name = alg.Name; bool available = alg.IsAvailable(); Trace("[SBAlgManager] EnqueueBackupAlgorithms() - name: {0}, available: {1}", name, available); if (available && name != aExclude.Name) { iExecutionQueue.Enqueue(alg); } } }
public void StackBuildingComplete(StackAlgorithm aAlg) { // If the algorithm is still queued then everything went okay. If not, then we // had an exception and we should therefore ignore the completion as the algorithm // terminated unexpectedly. bool stillExists = iExecutionQueue.Contains(aAlg); Trace("[SBAlgManager] StackBuildingComplete() - aAlg: {0}, stillExists: {1}", aAlg, stillExists); if (stillExists) { iExecutionQueue.Clear(); ReportEvent(TEvent.EAlgorithmComplete); } }
private StackAlgorithm FindPrimaryAlgorithm() { StackAlgorithm ret = null; // foreach (StackAlgorithm alg in iMasterAlgorithmTable) { if (alg.IsAvailable()) { ret = alg; break; } } // Trace("[SBAlgManager] FindPrimaryAlgorithm() - ret: {0}", ret); return(ret); }
private void PrepareExecutionQueue() { iExecutionQueue.Clear(); // Find most appropriate algorithm... StackAlgorithm primary = FindPrimaryAlgorithm(); if (primary != null) { iExecutionQueue.Enqueue(primary); // Find backup algorithms EnqueueBackupAlgorithms(primary); } else { throw new Exception("No valid stack algorithms available"); } }
public void StackBuildingException(StackAlgorithm aAlg, Exception aException) { Trace("[SBAlgManager] STACK ALG EXCEPTION: " + aException.Message); Trace("[SBAlgManager] {0}", aException.StackTrace); StackAlgorithm alg = CurrentAlgorithm; // If we're executing using the fallback entry, then we're in trouble. // There is nothing we can do besides report the problem upwards. if (iExecutionQueue.Count == 1) { if (ExceptionHandler != null) { ExceptionHandler(this, aException); } } else { // Report event string message = string.Format(LibResources.StackAlgorithmManager_FailedAlgorithmWarning + System.Environment.NewLine + "{1}", alg.Name, aException.Message.ToString() ); iEngine.ReportMessage(StackEngine.TMessageType.ETypeWarning, message); // The primary algorithm has failed, let's roll back to the secondary // by dumping the primary algorithm and starting again. iExecutionQueue.Dequeue(); iEngine.DataOutput.Clear(); // Reset progress. iProgressValueCompleted += 100; iProgressValueCurrent = 0; // Start next algorithm... ExecuteHeadAlgorithm(); } }
public void StackBuildingStarted(StackAlgorithm aAlg) { Trace("[SBAlgManager] StackBuildingStarted() - aAlg: {0}", aAlg); ReportEvent(TEvent.EAlgorithmStarted); }