Changeset 4871
- Timestamp:
- 11/20/10 14:13:32 (14 years ago)
- Location:
- branches/HeuristicLab.DebugEngine
- Files:
-
- 6 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DebugEngine/DebugEngine.cs
r4827 r4871 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Collections.Generic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Collections; 29 using System.Threading; 27 30 28 31 namespace HeuristicLab.DebugEngine { … … 30 33 [StorableClass] 31 34 [Item("Debug Engine", "Engine for debugging algorithms.")] 32 public class DebugEngine : Engine { 33 private IOperator currentOperator; 34 35 public class DebugEngine : Executable, IEngine { 36 37 38 #region Construction and Cloning 39 35 40 [StorableConstructor] 36 protected DebugEngine(bool deserializing) : base(deserializing) { } 37 protected DebugEngine(DebugEngine original, Cloner cloner) : base(original, cloner) { } 41 protected DebugEngine(bool deserializing) : base(deserializing) { 42 pausePending = stopPending = false; 43 timer = new System.Timers.Timer(100); 44 timer.AutoReset = true; 45 timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); 46 } 47 protected DebugEngine(DebugEngine original, Cloner cloner) : base(original, cloner) { 48 if (original.ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 49 Log = cloner.Clone(original.Log); 50 ExecutionStack = cloner.Clone(original.ExecutionStack); 51 pausePending = original.pausePending; 52 stopPending = original.stopPending; 53 timer = new System.Timers.Timer(100); 54 timer.AutoReset = true; 55 timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); 56 this.currentOperation = cloner.Clone(original.currentOperation); 57 this.currentOperator = cloner.Clone(original.currentOperator); 58 } 38 59 public DebugEngine() 39 60 : base() { 40 }41 42 public new Stack<IOperation> ExecutionStack {43 get { return base.ExecutionStack; }44 }45 46 public IAtomicOperation CurrentOperation { get; private set;}61 Log = new Log(); 62 ExecutionStack = new ExecutionStack(); 63 pausePending = stopPending = false; 64 timer = new System.Timers.Timer(100); 65 timer.AutoReset = true; 66 timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); 67 } 47 68 48 69 public override IDeepCloneable Clone(Cloner cloner) { 49 70 return new DebugEngine(this, cloner); 71 } 72 73 #endregion 74 75 #region Fields and Properties 76 77 [Storable] 78 public ILog Log { get; protected set; } 79 80 [Storable] 81 public ExecutionStack ExecutionStack { get; protected set; } 82 83 private bool pausePending, stopPending; 84 private DateTime lastUpdateTime; 85 private System.Timers.Timer timer; 86 87 [Storable] 88 private IOperator currentOperator; 89 90 [Storable] 91 private bool ignoreNextBreakpoint; 92 93 [Storable] 94 private IOperation currentOperation; 95 public virtual IOperation CurrentOperation { 96 get { return currentOperation; } 97 private set { 98 if (value == currentOperation) 99 return; 100 currentOperation = value; 101 OnOperationChanged(value); 102 } 103 } 104 105 public virtual IAtomicOperation CurrentAtomicOperation { 106 get { return CurrentOperation as IAtomicOperation; } 107 } 108 109 public virtual IExecutionContext CurrentExecutionContext { 110 get { return CurrentOperation as IExecutionContext; } 111 } 112 113 #endregion 114 115 #region Events 116 117 public event EventHandler<OperationChangedEventArgs> CurrentOperationChanged; 118 119 protected virtual void OnOperationChanged(IOperation newOperation) { 120 EventHandler<OperationChangedEventArgs> handler = CurrentOperationChanged; 121 if (handler != null) { 122 handler(this, new OperationChangedEventArgs(newOperation)); 123 } 124 } 125 126 #endregion 127 128 #region Std Methods 129 public sealed override void Prepare() { 130 base.Prepare(); 131 ExecutionStack.Clear(); 132 ignoreNextBreakpoint = false; 133 CurrentOperation = null; 134 OnPrepared(); 135 } 136 public void Prepare(IOperation initialOperation) { 137 base.Prepare(); 138 ExecutionStack.Clear(); 139 if (initialOperation != null) 140 ExecutionStack.Add(initialOperation); 141 ignoreNextBreakpoint = false; 142 CurrentOperation = null; 143 OnPrepared(); 144 } 145 protected override void OnPrepared() { 146 Log.LogMessage("Engine prepared"); 147 base.OnPrepared(); 148 } 149 150 public virtual void Step() { 151 OnStarted(); 152 lastUpdateTime = DateTime.Now; 153 ignoreNextBreakpoint = true; 154 timer.Start(); 155 ProcessNextOperation(); 156 timer.Stop(); 157 ExecutionTime += DateTime.Now - lastUpdateTime; 158 ignoreNextBreakpoint = false; 159 OnPaused(); 160 } 161 162 public override void Start() { 163 base.Start(); 164 CurrentOperation = null; 165 ThreadPool.QueueUserWorkItem(new WaitCallback(Run), null); 166 } 167 168 protected override void OnStarted() { 169 Log.LogMessage("Engine started"); 170 base.OnStarted(); 171 } 172 173 public override void Pause() { 174 base.Pause(); 175 pausePending = true; 176 if (currentOperator != null) currentOperator.Abort(); 177 } 178 179 protected override void OnPaused() { 180 Log.LogMessage("Engine paused"); 181 base.OnPaused(); 182 } 183 184 public override void Stop() { 185 CurrentOperation = null; 186 base.Stop(); 187 stopPending = true; 188 if (currentOperator != null) currentOperator.Abort(); 189 ignoreNextBreakpoint = false; 190 if (ExecutionState == ExecutionState.Paused) OnStopped(); 191 } 192 193 protected override void OnStopped() { 194 Log.LogMessage("Engine stopped"); 195 base.OnStopped(); 196 } 197 198 protected override void OnExceptionOccurred(Exception exception) { 199 Log.LogException(exception); 200 base.OnExceptionOccurred(exception); 201 } 202 203 private void Run(object state) { 204 OnStarted(); 205 pausePending = stopPending = false; 206 207 lastUpdateTime = DateTime.Now; 208 timer.Start(); 209 while (!pausePending && !stopPending && CanContinue) { 210 ProcessNextOperation(); 211 } 212 timer.Stop(); 213 ExecutionTime += DateTime.Now - lastUpdateTime; 214 215 if (pausePending) OnPaused(); 216 else OnStopped(); 217 } 218 219 private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { 220 DateTime now = DateTime.Now; 221 ExecutionTime += now - lastUpdateTime; 222 lastUpdateTime = now; 223 } 224 #endregion 225 226 #region Methods 227 228 public virtual bool CanContinue { 229 get { return CurrentOperation != null || ExecutionStack.Count > 0; } 50 230 } 51 231 … … 57 237 /// is pushed on the stack again.<br/> 58 238 /// If the execution was successful <see cref="EngineBase.OnOperationExecuted"/> is called.</remarks> 59 protected override void ProcessNextOperation() { 60 currentOperator = null; 61 IOperation next = ExecutionStack.Pop(); 62 OperationCollection coll = next as OperationCollection; 63 while (coll != null) { 64 Log.LogMessage("Expanding OperationCollection"); 65 for (int i = coll.Count - 1; i >= 0; i--) { 66 ExecutionStack.Push(coll[i]); 239 protected virtual void ProcessNextOperation() { 240 try { 241 IAtomicOperation atomicOperation = CurrentOperation as IAtomicOperation; 242 OperationCollection operations = CurrentOperation as OperationCollection; 243 if (atomicOperation != null && operations != null) 244 throw new InvalidOperationException("Current operation is both atomic and an operation collection"); 245 246 if (atomicOperation != null) { 247 Log.LogMessage(string.Format("Performing atomic operation {0}", Name(atomicOperation))); 248 PerformAtomicOperation(atomicOperation); 249 } else if (operations != null) { 250 Log.LogMessage("Expanding operation collection"); 251 ExpandOperationCollection(operations); 252 } else if (ExecutionStack.Count > 0) { 253 Log.LogMessage("Poping execution stack"); 254 CurrentOperation = ExecutionStack.Last(); 255 ExecutionStack.RemoveAt(ExecutionStack.Count - 1); 256 } else { 257 Log.LogMessage("Nothing to do"); 67 258 } 68 next = ExecutionStack.Count > 0 ? ExecutionStack.Pop() : null; 69 coll = next as OperationCollection; 70 } 71 IAtomicOperation operation = next as IAtomicOperation; 259 } catch (Exception x) { 260 OnExceptionOccurred(x); 261 } 262 } 263 264 protected virtual void PerformAtomicOperation(IAtomicOperation operation) { 72 265 if (operation != null) { 73 Log.LogMessage("Preparing IAtomicOperation"); 266 if (operation.Operator.Breakpoint) { 267 if (ignoreNextBreakpoint) { 268 ignoreNextBreakpoint = false; 269 } else { 270 ignoreNextBreakpoint = true; 271 Log.LogMessage(string.Format("Breaking before: {0}", Name(operation))); 272 Pause(); 273 return; 274 } 275 } 74 276 try { 75 277 currentOperator = operation.Operator; 76 CurrentOperation = operation; 77 if (operation.Operator.Breakpoint) { 78 Log.LogMessage(string.Format("Breakpoint: Before {0}", operation.Operator.Name != string.Empty ? operation.Operator.Name : operation.Operator.ItemName)); 79 Pause(); 278 IOperation successor = operation.Operator.Execute((IExecutionContext)operation); 279 CurrentOperation = null; 280 currentOperator = null; 281 if (successor != null) { 282 ExecutionStack.Add(successor); 80 283 } 81 Log.LogMessage("Executing IAtomicOperation");82 ExecutionStack.Push(operation.Operator.Execute((IExecutionContext)operation));83 284 } catch (Exception ex) { 84 285 OnExceptionOccurred(new OperatorExecutionException(operation.Operator, ex)); 85 286 Pause(); 86 287 } 87 } else { 88 Log.LogMessage("Nothing to do"); 89 CurrentOperation = null; 90 } 91 } 92 93 public override void Pause() { 94 base.Pause(); 95 if (currentOperator != null) currentOperator.Abort(); 96 } 97 public override void Stop() { 98 base.Stop(); 99 if (currentOperator != null) currentOperator.Abort(); 100 } 101 102 public virtual void Step() { 103 OnStarted(); 104 var lastUpdateTime = DateTime.Now; 105 if (ExecutionStack.Count > 0) { 106 while (ExecutionStack.Count > 0 && ExecutionStack.Peek() == null) 107 ExecutionStack.Pop(); 108 if (ExecutionStack.Count > 0) 109 ProcessNextOperation(); 110 } 111 ExecutionTime += DateTime.Now - lastUpdateTime; 112 OnPaused(); 113 } 288 } 289 } 290 291 protected virtual void ExpandOperationCollection(OperationCollection operations) { 292 ExecutionStack.AddRange(operations.Reverse()); 293 CurrentOperation = null; 294 } 295 296 protected virtual string Name(IAtomicOperation operation) { 297 return string.IsNullOrEmpty(operation.Operator.Name) ? operation.Operator.ItemName : operation.Operator.Name; 298 } 299 300 #endregion 114 301 } 115 302 } -
branches/HeuristicLab.DebugEngine/DebugEngineView.Designer.cs
r4765 r4871 49 49 this.label1 = new System.Windows.Forms.Label(); 50 50 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 51 this.executionStackView = new HeuristicLab.DebugEngine.ExecutionStackView(); 51 52 this.logView = new HeuristicLab.Core.Views.LogView(); 52 53 this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 53 this.executionStackTreeView = new System.Windows.Forms.TreeView();54 this.label2 = new System.Windows.Forms.Label();55 54 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 55 this.splitContainer3 = new System.Windows.Forms.SplitContainer(); 56 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 57 this.label3 = new System.Windows.Forms.Label(); 58 this.scopeTreeView = new System.Windows.Forms.TreeView(); 56 59 this.label4 = new System.Windows.Forms.Label(); 57 60 this.operationTextBox = new System.Windows.Forms.TextBox(); 58 this.label3 = new System.Windows.Forms.Label();59 this.scopeTreeView = new System.Windows.Forms.TreeView();60 61 this.stepButton = new System.Windows.Forms.Button(); 61 62 this.updateButton = new System.Windows.Forms.Button(); 62 63 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 63 64 this.parentButton = new System.Windows.Forms.Button(); 64 this.splitContainer3 = new System.Windows.Forms.SplitContainer();65 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();66 65 this.splitContainer1.Panel1.SuspendLayout(); 67 66 this.splitContainer1.Panel2.SuspendLayout(); … … 94 93 this.executionTimeTextBox.TabIndex = 1; 95 94 // 95 // executionStackView 96 // 97 this.executionStackView.Caption = "Execution Stack View"; 98 this.executionStackView.Content = null; 99 this.executionStackView.Dock = System.Windows.Forms.DockStyle.Fill; 100 this.executionStackView.Location = new System.Drawing.Point(0, 0); 101 this.executionStackView.Name = "executionStackView"; 102 this.executionStackView.ReadOnly = false; 103 this.executionStackView.Size = new System.Drawing.Size(433, 262); 104 this.executionStackView.TabIndex = 0; 105 // 96 106 // logView 97 107 // … … 114 124 // splitContainer1.Panel1 115 125 // 116 this.splitContainer1.Panel1.Controls.Add(this.executionStackTreeView); 117 this.splitContainer1.Panel1.Controls.Add(this.label2); 126 this.splitContainer1.Panel1.Controls.Add(this.executionStackView); 118 127 // 119 128 // splitContainer1.Panel2 … … 123 132 this.splitContainer1.SplitterDistance = 262; 124 133 this.splitContainer1.TabIndex = 3; 125 //126 // executionStackTreeView127 //128 this.executionStackTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)129 | System.Windows.Forms.AnchorStyles.Left)130 | System.Windows.Forms.AnchorStyles.Right)));131 this.executionStackTreeView.Location = new System.Drawing.Point(3, 16);132 this.executionStackTreeView.Name = "executionStackTreeView";133 this.executionStackTreeView.ShowNodeToolTips = true;134 this.executionStackTreeView.Size = new System.Drawing.Size(427, 243);135 this.executionStackTreeView.TabIndex = 2;136 this.executionStackTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.executionStackTreeView_NodeMouseDoubleClick);137 //138 // label2139 //140 this.label2.AutoSize = true;141 this.label2.Location = new System.Drawing.Point(3, 0);142 this.label2.Name = "label2";143 this.label2.Size = new System.Drawing.Size(85, 13);144 this.label2.TabIndex = 1;145 this.label2.Text = "Execution Stack";146 134 // 147 135 // splitContainer2 … … 166 154 this.splitContainer2.TabIndex = 0; 167 155 // 168 // label4 169 // 170 this.label4.AutoSize = true; 171 this.label4.Location = new System.Drawing.Point(3, 6); 172 this.label4.Name = "label4"; 173 this.label4.Size = new System.Drawing.Size(56, 13); 174 this.label4.TabIndex = 3; 175 this.label4.Text = "Operation:"; 176 // 177 // operationTextBox 178 // 179 this.operationTextBox.Location = new System.Drawing.Point(65, 3); 180 this.operationTextBox.Name = "operationTextBox"; 181 this.operationTextBox.ReadOnly = true; 182 this.operationTextBox.Size = new System.Drawing.Size(267, 20); 183 this.operationTextBox.TabIndex = 2; 156 // splitContainer3 157 // 158 this.splitContainer3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 159 | System.Windows.Forms.AnchorStyles.Left) 160 | System.Windows.Forms.AnchorStyles.Right))); 161 this.splitContainer3.Location = new System.Drawing.Point(3, 29); 162 this.splitContainer3.Name = "splitContainer3"; 163 this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; 164 // 165 // splitContainer3.Panel1 166 // 167 this.splitContainer3.Panel1.Controls.Add(this.parameterCollectionView); 168 // 169 // splitContainer3.Panel2 170 // 171 this.splitContainer3.Panel2.Controls.Add(this.label3); 172 this.splitContainer3.Panel2.Controls.Add(this.scopeTreeView); 173 this.splitContainer3.Size = new System.Drawing.Size(423, 471); 174 this.splitContainer3.SplitterDistance = 235; 175 this.splitContainer3.TabIndex = 4; 176 // 177 // parameterCollectionView 178 // 179 this.parameterCollectionView.Caption = "ParameterCollection View"; 180 this.parameterCollectionView.Content = null; 181 this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill; 182 this.parameterCollectionView.Location = new System.Drawing.Point(0, 0); 183 this.parameterCollectionView.Name = "parameterCollectionView"; 184 this.parameterCollectionView.ReadOnly = false; 185 this.parameterCollectionView.Size = new System.Drawing.Size(423, 235); 186 this.parameterCollectionView.TabIndex = 0; 184 187 // 185 188 // label3 … … 204 207 this.scopeTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.scopeTreeView_NodeMouseDoubleClick); 205 208 // 209 // label4 210 // 211 this.label4.AutoSize = true; 212 this.label4.Location = new System.Drawing.Point(3, 6); 213 this.label4.Name = "label4"; 214 this.label4.Size = new System.Drawing.Size(56, 13); 215 this.label4.TabIndex = 3; 216 this.label4.Text = "Operation:"; 217 // 218 // operationTextBox 219 // 220 this.operationTextBox.Location = new System.Drawing.Point(65, 3); 221 this.operationTextBox.Name = "operationTextBox"; 222 this.operationTextBox.ReadOnly = true; 223 this.operationTextBox.Size = new System.Drawing.Size(267, 20); 224 this.operationTextBox.TabIndex = 2; 225 // 206 226 // stepButton 207 227 // … … 239 259 this.parentButton.UseVisualStyleBackColor = true; 240 260 this.parentButton.Click += new System.EventHandler(this.parentButton_Click); 241 //242 // splitContainer3243 //244 this.splitContainer3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)245 | System.Windows.Forms.AnchorStyles.Left)246 | System.Windows.Forms.AnchorStyles.Right)));247 this.splitContainer3.Location = new System.Drawing.Point(3, 29);248 this.splitContainer3.Name = "splitContainer3";249 this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;250 //251 // splitContainer3.Panel1252 //253 this.splitContainer3.Panel1.Controls.Add(this.parameterCollectionView);254 //255 // splitContainer3.Panel2256 //257 this.splitContainer3.Panel2.Controls.Add(this.label3);258 this.splitContainer3.Panel2.Controls.Add(this.scopeTreeView);259 this.splitContainer3.Size = new System.Drawing.Size(423, 471);260 this.splitContainer3.SplitterDistance = 235;261 this.splitContainer3.TabIndex = 4;262 //263 // parameterCollectionView264 //265 this.parameterCollectionView.Caption = "ParameterCollection View";266 this.parameterCollectionView.Content = null;267 this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;268 this.parameterCollectionView.Location = new System.Drawing.Point(0, 0);269 this.parameterCollectionView.Name = "parameterCollectionView";270 this.parameterCollectionView.ReadOnly = false;271 this.parameterCollectionView.Size = new System.Drawing.Size(423, 235);272 this.parameterCollectionView.TabIndex = 0;273 261 // 274 262 // DebugEngineView … … 284 272 this.Size = new System.Drawing.Size(872, 538); 285 273 this.splitContainer1.Panel1.ResumeLayout(false); 286 this.splitContainer1.Panel1.PerformLayout();287 274 this.splitContainer1.Panel2.ResumeLayout(false); 288 275 this.splitContainer1.ResumeLayout(false); … … 307 294 private System.Windows.Forms.SplitContainer splitContainer1; 308 295 private System.Windows.Forms.SplitContainer splitContainer2; 309 private System.Windows.Forms.Label label2;310 296 private System.Windows.Forms.Label label3; 311 297 private System.Windows.Forms.TreeView scopeTreeView; 312 private System.Windows.Forms.TreeView executionStackTreeView;313 298 private System.Windows.Forms.Button stepButton; 314 299 private System.Windows.Forms.Button updateButton; … … 319 304 private System.Windows.Forms.SplitContainer splitContainer3; 320 305 private Core.Views.ParameterCollectionView parameterCollectionView; 306 private HeuristicLab.DebugEngine.ExecutionStackView executionStackView; 321 307 322 308 } -
branches/HeuristicLab.DebugEngine/DebugEngineView.cs
r4765 r4871 30 30 using HeuristicLab.Persistence.Auxiliary; 31 31 namespace HeuristicLab.DebugEngine { 32 32 33 /// <summary> 33 /// Base class for editors of engines.34 /// Engine espcially for debugging 34 35 /// </summary> 35 36 [View("DebugEngine View")] 36 37 [Content(typeof(DebugEngine), true)] 37 38 public partial class DebugEngineView : ItemView { 39 40 #region Basics 41 38 42 /// <summary> 39 43 /// Gets or sets the current engine. … … 46 50 47 51 /// <summary> 48 /// Initializes a new instance of <see cref=" EngineBaseEditor"/>.52 /// Initializes a new instance of <see cref="DebugEngineView"/>. 49 53 /// </summary> 50 54 public DebugEngineView() { … … 60 64 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 61 65 protected override void DeregisterContentEvents() { 66 Content.CurrentOperationChanged -= new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged); 62 67 Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged); 63 68 Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged); … … 73 78 Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged); 74 79 Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged); 80 Content.CurrentOperationChanged += new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged); 75 81 } 76 82 … … 84 90 logView.Content = null; 85 91 executionTimeTextBox.Text = "-"; 92 executionStackView.Content = null; 86 93 } else { 87 94 logView.Content = Content.Log; 88 95 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 96 executionStackView.Content = Content.ExecutionStack; 89 97 } 90 98 } … … 101 109 } 102 110 111 #endregion 112 103 113 protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) { 104 114 if (InvokeRequired) … … 109 119 110 120 void Content_ExecutionStateChanged(object sender, EventArgs e) { 111 switch (Content.ExecutionState) { 112 case ExecutionState.Paused: 113 case ExecutionState.Stopped: 114 case ExecutionState.Prepared: 115 UpdateView(); break; 116 } 117 } 118 119 protected virtual void UpdateView() { 120 if (InvokeRequired) { 121 Invoke(new Action(UpdateView)); 122 } else { 123 UpdateExecutionStack(); 121 if (InvokeRequired) 122 Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e); 123 else { 124 switch (Content.ExecutionState) { 125 case ExecutionState.Started: executionStackView.SuspendUpdate(); break; 126 default: executionStackView.ResumeUpdate(); break; 127 } 128 } 129 } 130 131 #region Current Operation 132 133 void Content_CurrentOperationChanged(object sender, OperationChangedEventArgs e) { 134 if (InvokeRequired) 135 Invoke(new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged), sender, e); 136 else 124 137 SetOperation(Content.CurrentOperation); 125 }126 138 } 127 139 … … 133 145 if (atomicOperation != null && atomicOperation.Operator != null) { 134 146 operationTextBox.Text = string.Format("Atomic {0}", atomicOperation.Operator.Name); 135 toolTip.SetToolTip(operationTextBox, TypeName(atomicOperation.Operator));147 toolTip.SetToolTip(operationTextBox, Utils.TypeName(atomicOperation.Operator)); 136 148 } 137 149 OperationCollection operationCollection = operation as OperationCollection; … … 152 164 } 153 165 154 private void UpdateExecutionStack() {155 executionStackTreeView.BeginUpdate();156 executionStackTreeView.Nodes.Clear();157 AddOperations(executionStackTreeView.Nodes, Content.ExecutionStack.ToArray());158 executionStackTreeView.ExpandAll();159 if (executionStackTreeView.Nodes.Count > 0)160 executionStackTreeView.TopNode = executionStackTreeView.Nodes[0];161 executionStackTreeView.EndUpdate();162 }163 164 166 private void UpdateScope(IScope scope) { 165 167 scopeTreeView.BeginUpdate(); … … 174 176 } 175 177 176 private string TypeName(object obj) { 177 if (obj == null) 178 return "null"; 179 return TypeNameParser.Parse(obj.GetType().ToString()).GetTypeNameInCode(true); 180 } 181 182 private void AddOperations(TreeNodeCollection nodes, IEnumerable<IOperation> operations) { 183 foreach (IOperation op in operations) { 184 if (op is IAtomicOperation) { 185 IAtomicOperation atom = op as IAtomicOperation; 186 TreeNode node = nodes.Add(atom.Operator.Name); 187 node.Tag = atom; 188 node.ToolTipText = TypeName(atom); 189 node.ImageKey = "AtomicOperation"; 190 if (atom.Operator.Breakpoint) 191 node.ForeColor = Color.Red; 192 foreach (var param in atom.Operator.Parameters) { 193 string typeName = "null"; 194 TreeNode paramNode = node.Nodes.Add(string.Format("Param {0} = {1}", param.Name, GetApproximateValue(param, ref typeName))); 195 paramNode.Tag = param; 196 paramNode.ToolTipText = string.Format("{0} = {1}", TypeName(param), typeName); 197 paramNode.ImageKey = "Parameter"; 198 } 199 } else if (op is OperationCollection) { 200 OperationCollection ops = op as OperationCollection; 201 TreeNode node = executionStackTreeView.Nodes.Add(string.Format("{0} Operations", ops.Count)); 202 node.Tag = op; 203 node.ToolTipText = TypeName(ops); 204 node.ImageKey = "OperationCollection"; 205 AddOperations(node.Nodes, ops); 206 } 207 } 208 } 209 178 179 180 /* 210 181 private string GetApproximateValue(IParameter param, ref string typeName) { 211 182 string valueString = "<none>"; … … 229 200 return valueString; 230 201 } 202 */ 231 203 232 204 private void AddScope(TreeNodeCollection nodes, IScope scope) { 233 205 TreeNode node = nodes.Add(scope.Name); 234 if (Content.Current Operation != null && Content.CurrentOperation.Scope == scope) {206 if (Content.CurrentAtomicOperation != null && Content.CurrentAtomicOperation.Scope == scope) { 235 207 node.ForeColor = Color.Red; 236 208 node.BackColor = Color.LightGray; … … 239 211 TreeNode varNode = node.Nodes.Add(string.Format("{0}={1}", var.Name, var.Value.ToString())); 240 212 varNode.Tag = var.Value; 241 varNode.ToolTipText = TypeName(var.Value);213 varNode.ToolTipText = Utils.TypeName(var.Value); 242 214 } 243 215 foreach (var subScope in scope.SubScopes) { 244 216 AddScope(node.Nodes, subScope); 217 } 218 } 219 220 #endregion 221 222 protected virtual void UpdateView() { 223 if (InvokeRequired) { 224 Invoke(new Action(UpdateView)); 225 } else { 226 SetOperation(Content.CurrentOperation); 245 227 } 246 228 } … … 249 231 Content.Step(); 250 232 UpdateView(); 251 }252 253 private void executionStackTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) {254 if (e.Node != null) {255 IAtomicOperation op = e.Node.Tag as IAtomicOperation;256 if (op != null) {257 op.Operator.Breakpoint = !op.Operator.Breakpoint;258 if (op.Operator.Breakpoint) {259 e.Node.ForeColor = Color.Red;260 } else {261 e.Node.ForeColor = Color.Black;262 }263 executionStackTreeView.SelectedNode = null;264 }265 IParameter param = e.Node.Tag as IParameter;266 if (param != null)267 MainFormManager.MainForm.ShowContent(param);268 }269 233 } 270 234 -
branches/HeuristicLab.DebugEngine/DebugEngineView.resx
r4765 r4871 122 122 <value> 123 123 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 124 YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAL EAAA125 C xABrSO9dQAAARBJREFUOE9j+P//PwM6Tuh5woxNHJsYhmaQIqABMkDMRIwhWA0onPX8f/zkt0rEGILV124 YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALDgAA 125 Cw4BQL7hQQAAARBJREFUOE9j+P//PwM6Tuh5woxNHJsYhmaQIqABMkDMRIwhWA0onPX8f/zkt0rEGILV 126 126 gNyZz/4ndN/7HzfhtQYh72A1IGPK0//z9v/+H9Rw8zXQAFt8huAKg/+z9/3637n173+30sv/gQbY4zIE 127 127 qwGRXY/+T9n263/J0r//E6b//W+TexanIVgNCGx++L917XuwZuOSL/+lo6/9N45c9t+h6Gw8ukuwGuBR … … 137 137 <value> 138 138 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 139 YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALD wAA140 Cw 8BkvkDpQAAAmFJREFUOE+dk21IU1EYx3cVVzkhaLCy+UaY0xwlZkYRmiGR7oMEUlAGfRGKvkRFVOQ0141 DddsVmtbvpQWhCFBSvaCUcRAk0gGm8SGM7JtrU1nzYFvu3P33znDRcLpSxceDvdefr/zv+d5Lidaufjg142 QKKIWwNSUo4Tz4u4RAl5xYsgJIuEcADCYlS8oQKLvvvKdam1n+PcqjUyN5ox7PyIVrMB1U9PoKxThZI7143 h3C1vwk2l2OWD40c15nbwITD/h5p/9hrVL2sgXpSA43bgGsOHeodLTj16QJK71XCOmlH3u1dbIHDOxGk144 8PXJW1D1HYWsfgs2NW3FSfOZmKjBcTMmydLmswWXnjegZvg0dusPoHXQiDH3OJw+F9IaFbFU8UptymYL145 DncdQ0lHBfosrxBZFvL5ZUEyFfgFm2d8lURal8kWFHeU4eIzNYULSHF8ROB6LQPI1CiRrskF3ZnC6y/L146 2YIdxr0Y/WqDf/pnEj1lry+Q5vkxlfTdN73W6w+IyX2Cy+PfOP7FxRaQHbFSB8maGOaFfR7vFLcYjiYs147 LEW5eVJzC1GJekjLFhR2lWJ72x7k3i0KZrUoQ/JmBdpHHmOJj0ppIiIpbx96iDzjP9q4s6sEWrcp1rJs148 XQEsLjv9HJAE6TSF1eVE5ZNqbK7LYSfYZir+I6AShb4Ilm92MoET6BzuiU0lbWXto7NsAYmNnBuFq3pO149 oThIYblagQfve9mCjOZ8vLC+hZwMzt9QfIAorHljQGA2sp/5L7S96wY5KHxwWHCltxEq0xGknJch5ZwM150 5foqGAe7MROKJHtn+ASm4H8f/gZt6J11yfCrBQAAAABJRU5ErkJggg==139 YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALDQAA 140 Cw0B7QfALAAAAmJJREFUOE+dk21IU1Ecxt3MCBX8MLRsvhHmtI0SM6OImSFR+kECKSiDvgRFX6IiKnKa 141 C9dsVmtbU2sWhCFBSvamFDFwrRcZbH7YmEZ2t9Y2Z24zU3ev29M9w0XS9UsXHg6Hc5/fec75/09S0tJH 142 BweS6dAQnw4bM5kZcyrz82Mmqwxm5n02EzKuoqdf8civ8967koTnn5GZHckzjX1Au1GD+sdHUdVVC+mt 143 fbjcL4eNcoTosPmIyqgHJyDi6xH0j75E3fMGyCYUULg0uOJQocnRhhOfzqHyTg2sE3aU3NzGDXB4xoPE 144 fHXiBmr7DiGraQPWyTfimPFUHNTsuB6HFCjF3IALT5vRYDqJ7eo9aB/UYtTlxJiXQk6LKJ4qoWx5ITfg 145 gOEwpJ370Wd5AWYxJqYXY2n+wDRsbucyiKAxnxtQ0VmF809kxFzKikczMV6vZQD5CglyFcUgOxNzxkUh 146 N2CLdidGvtjgm/yRQm7Z4w3kuL/7U755J9d4fIHV7JxPuX1rnZ8pbgC7I5a0lx2TI3Rsl9vj581Hovy5 147 hSjvF6vZuWiabFjJDSgzVGKzfgeKb5cHC9okYWGrCB3mh1igowKSiIVUdwzfR4l2hTJuNUihdOniJStU 148 lcJC2clxwCbIJSms1BhqHtVjfWMRd4JNuoo/AAIRqcth+WpnO3AcXaaeeFeSUh5/cJobwMZG0bWyZTUn 149 poSRmIUyEe697eUG5LWK8cz6GkK2cf42JRqImBVDGgRCzG7Ot6B/0w32ovDOYcGl3hbU6g4i/WwW0s9k 150 oVpdB+1gN6bCTKpniuav+Br/Z+E3/RykhyEkCzoAAAAASUVORK5CYII= 151 151 </value> 152 152 </data> … … 154 154 <value> 155 155 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 156 YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAL EQAA157 C xEBf2RfkQAAAN5JREFUOE9j/P//PwNFAGQALuxeeskYnzzYclwKVH3nSpXNefEfaEgEPkOwGgDTPG/f158 3/+GYYv+G8ds8MVlCIYByJrz5/7475R35L9WwAKchqAYgKy5dd2//5E9n/57lF38b5+1/7+G31yshqAY159 APJz8cyn/0F07Yr//+Mm//nvX3/vv2bI6v9Aw/+reE4D+gQ10LGGAcgAkAtgBqj7L8LQCDMIpwGTt//9160 nzvvL9gFqt6zSDcAFAMVSwfSgGWHf1PmApABoCgEYWX3SaSHAUgTMiY6JRLKPESlA1IMAQAvnrIcTgHP161 egAAAABJRU5ErkJggg==156 YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALDwAA 157 Cw8BkvkDpQAAANpJREFUOE9j+P//PwMlGK9m99JLxoQMx2mAqu9cqbI5L/4DDYnAZwhWA2Ca5+37+98w 158 bNF/45gNvrgMwTAAWXP+3B//nfKO/NcKWIDTEBQDkDW3rvv3P7Ln03+Psov/7bP2/9fwm4vVEBQDQH4u 159 nvn0P4iuXfH/f9zkP//96+/91wxZ/R9o+H8Vz2lAn6DGGtYwABkAcgHMAHX/RRgaYQbhNGDy9r//c+f9 160 BbtA1XsW6QaAYqBi6UAasOzwb8pcADIAFIUgrOw+ifQwAGlCxkSnREKZh6h0QIohAFsI3u6Zj7KhAAAA 161 AElFTkSuQmCC 162 162 </value> 163 163 </data> -
branches/HeuristicLab.DebugEngine/HeuristicLab.DebugEngine.csproj
r4759 r4871 125 125 <DependentUpon>DebugEngineView.cs</DependentUpon> 126 126 </Compile> 127 <Compile Include="ExecutionStack.cs" /> 128 <Compile Include="ExecutionStackView.cs"> 129 <SubType>UserControl</SubType> 130 </Compile> 131 <Compile Include="ExecutionStackView.Designer.cs"> 132 <DependentUpon>ExecutionStackView.cs</DependentUpon> 133 </Compile> 134 <Compile Include="OperationChangedEventArgs.cs" /> 127 135 <Compile Include="Properties\AssemblyInfo.cs" /> 136 <Compile Include="Utils.cs" /> 128 137 </ItemGroup> 129 138 <ItemGroup> 130 139 <EmbeddedResource Include="DebugEngineView.resx"> 131 140 <DependentUpon>DebugEngineView.cs</DependentUpon> 141 </EmbeddedResource> 142 <EmbeddedResource Include="ExecutionStackView.resx"> 143 <DependentUpon>ExecutionStackView.cs</DependentUpon> 132 144 </EmbeddedResource> 133 145 </ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.