Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4946


Ignore:
Timestamp:
11/26/10 16:38:35 (13 years ago)
Author:
mkommend
Message:

Minor changes in DebugEngine (ticket #47).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DebugEngine/DebugEngine.cs

    r4909 r4946  
    4040      : base(deserializing) {
    4141      pausePending = stopPending = false;
    42       timer = new System.Timers.Timer(100);
    43       timer.AutoReset = true;
    44       timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    45     }
     42      InitializeTimer();
     43    }
     44
    4645    protected DebugEngine(DebugEngine original, Cloner cloner)
    4746      : base(original, cloner) {
     
    4948      Log = cloner.Clone(original.Log);
    5049      ExecutionStack = cloner.Clone(original.ExecutionStack);
    51       OperatorTrace = new ItemList<IOperator>(original.OperatorTrace.Select(op => cloner.Clone(op)));
     50      OperatorTrace = cloner.Clone(OperatorTrace);
    5251      operatorParents = original.operatorParents.ToDictionary(kvp => cloner.Clone(kvp.Key), kvp => cloner.Clone(kvp.Value));
    5352      pausePending = original.pausePending;
    5453      stopPending = original.stopPending;
    55       timer = new System.Timers.Timer(100);
    56       timer.AutoReset = true;
    57       timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    58       this.currentOperation = cloner.Clone(original.currentOperation);
    59       this.currentOperator = cloner.Clone(original.currentOperator);
     54      InitializeTimer();
     55      currentOperation = cloner.Clone(original.currentOperation);
     56      currentOperator = cloner.Clone(original.currentOperator);
    6057    }
    6158    public DebugEngine()
     
    6663      operatorParents = new Dictionary<IAtomicOperation, IAtomicOperation>();
    6764      pausePending = stopPending = false;
     65      InitializeTimer();
     66    }
     67
     68    public override IDeepCloneable Clone(Cloner cloner) {
     69      return new DebugEngine(this, cloner);
     70    }
     71
     72    private void InitializeTimer() {
    6873      timer = new System.Timers.Timer(100);
    6974      timer.AutoReset = true;
    7075      timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
    71     }
    72 
    73     public override IDeepCloneable Clone(Cloner cloner) {
    74       return new DebugEngine(this, cloner);
    7576    }
    7677
     
    100101      get { return currentOperation; }
    101102      private set {
    102         if (value == currentOperation)
    103           return;
    104         currentOperation = value;
    105         OnOperationChanged(value);
     103        if (value != currentOperation) {
     104          currentOperation = value;
     105          OnOperationChanged(value);
     106        }
    106107      }
    107108    }
     
    126127
    127128    public event EventHandler<OperationChangedEventArgs> CurrentOperationChanged;
    128 
    129129    protected virtual void OnOperationChanged(IOperation newOperation) {
    130130      EventHandler<OperationChangedEventArgs> handler = CurrentOperationChanged;
     
    264264        } else if (operations != null) {
    265265          Log.LogMessage("Expanding operation collection");
    266           ExpandOperationCollection(operations);
     266          ExecutionStack.AddRange(operations.Reverse());
     267          CurrentOperation = null;
    267268        } else if (ExecutionStack.Count > 0) {
    268269          Log.LogMessage("Popping execution stack");
     
    273274        }
    274275        GenerateOperationTrace();
    275       } catch (Exception x) {
     276      }
     277      catch (Exception x) {
    276278        OnExceptionOccurred(x);
    277279      }
     
    315317          currentOperator = null;
    316318          CurrentOperation = null;
    317         } catch (Exception ex) {
     319        }
     320        catch (Exception ex) {
    318321          OnExceptionOccurred(new OperatorExecutionException(operation.Operator, ex));
    319322          Pause();
     
    332335    }
    333336
    334     protected virtual void ExpandOperationCollection(OperationCollection operations) {
    335       ExecutionStack.AddRange(operations.Reverse());
    336       CurrentOperation = null;
    337     }
    338 
    339337    protected virtual string Name(IAtomicOperation operation) {
    340338      return string.IsNullOrEmpty(operation.Operator.Name) ? operation.Operator.ItemName : operation.Operator.Name;
Note: See TracChangeset for help on using the changeset viewer.