Changeset 3261
- Timestamp:
- 04/04/10 00:03:13 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/EngineView.cs
r3260 r3261 60 60 protected override void DeregisterContentEvents() { 61 61 Content.Prepared -= new EventHandler(Content_Prepared); 62 Content.Started -= new EventHandler(Content_Started); 63 Content.Stopped -= new EventHandler(Content_Stopped); 62 Content.RunningChanged -= new EventHandler(Content_RunningChanged); 64 63 Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged); 65 64 Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); … … 74 73 base.RegisterContentEvents(); 75 74 Content.Prepared += new EventHandler(Content_Prepared); 76 Content.Started += new EventHandler(Content_Started); 77 Content.Stopped += new EventHandler(Content_Stopped); 75 Content.RunningChanged += new EventHandler(Content_RunningChanged); 78 76 Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged); 79 77 Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); … … 102 100 Invoke(new EventHandler(Content_Prepared), sender, e); 103 101 else { 102 executionTimeCounter = 0; 104 103 UpdateExecutionTimeTextBox(); 105 104 Log("Engine prepared"); 106 105 } 107 106 } 108 protected virtual void Content_Started(object sender, EventArgs e) { 109 executionTimeCounter = 0; 107 protected virtual void Content_RunningChanged(object sender, EventArgs e) { 110 108 if (InvokeRequired) 111 Invoke(new EventHandler(Content_ Started), sender, e);109 Invoke(new EventHandler(Content_RunningChanged), sender, e); 112 110 else { 113 111 UpdateExecutionTimeTextBox(); 114 Log("Engine started"); 115 } 116 } 117 protected virtual void Content_Stopped(object sender, EventArgs e) { 118 if (InvokeRequired) 119 Invoke(new EventHandler(Content_Stopped), sender, e); 120 else { 121 UpdateExecutionTimeTextBox(); 122 if (Content.Finished) Log("Engine finished"); 112 if (Content.Running) Log("Engine started"); 113 else if (Content.Finished) Log("Engine finished"); 123 114 else Log("Engine stopped"); 124 115 } -
trunk/sources/HeuristicLab.Core/3.3/Engine.cs
r3226 r3261 142 142 /// of class <see cref="ThreadPool"/>.</remarks> 143 143 public void Start() { 144 Running = true;145 Canceled = false;146 144 ThreadPool.QueueUserWorkItem(new WaitCallback(Run), null); 147 145 } … … 150 148 /// of class <see cref="ThreadPool"/>.</remarks> 151 149 public void Step() { 152 Running = true;153 Canceled = false;154 150 ThreadPool.QueueUserWorkItem(new WaitCallback(RunStep), null); 155 151 } … … 162 158 private void Run(object state) { 163 159 OnStarted(); 160 Running = true; 161 Canceled = false; 164 162 DateTime start = DateTime.Now; 165 163 DateTime end; … … 171 169 } 172 170 ExecutionTime += DateTime.Now - start; 171 Canceled = false; 172 Running = false; 173 173 OnStopped(); 174 174 } 175 175 private void RunStep(object state) { 176 176 OnStarted(); 177 Running = true; 178 Canceled = false; 177 179 DateTime start = DateTime.Now; 178 180 if ((!Canceled) && (!Finished)) 179 181 ProcessNextOperator(); 180 182 ExecutionTime += DateTime.Now - start; 183 Canceled = false; 184 Running = false; 181 185 OnStopped(); 182 186 } … … 241 245 if (Stopped != null) 242 246 Stopped(this, EventArgs.Empty); 243 Canceled = false;244 Running = false;245 247 } 246 248 protected virtual void OnCanceledChanged() { } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs
r3260 r3261 78 78 Content.Prepared -= new EventHandler(Content_Prepared); 79 79 Content.ProblemChanged -= new EventHandler(Content_ProblemChanged); 80 Content.Started -= new EventHandler(Content_Started); 81 Content.Stopped -= new EventHandler(Content_Stopped); 80 Content.RunningChanged -= new EventHandler(Content_RunningChanged); 82 81 base.DeregisterContentEvents(); 83 82 } … … 88 87 Content.Prepared += new EventHandler(Content_Prepared); 89 88 Content.ProblemChanged += new EventHandler(Content_ProblemChanged); 90 Content.Started += new EventHandler(Content_Started); 91 Content.Stopped += new EventHandler(Content_Stopped); 89 Content.RunningChanged += new EventHandler(Content_RunningChanged); 92 90 } 93 91 … … 127 125 Invoke(new EventHandler(Content_Prepared), sender, e); 128 126 else { 127 executionTimeCounter = 0; 129 128 resultsView.Content = Content.Results.AsReadOnly(); 130 129 startButton.Enabled = !Content.Finished; … … 141 140 } 142 141 } 143 protected virtual void Content_Started(object sender, EventArgs e) { 144 executionTimeCounter = 0; 145 if (InvokeRequired) 146 Invoke(new EventHandler(Content_Started), sender, e); 142 protected virtual void Content_RunningChanged(object sender, EventArgs e) { 143 if (InvokeRequired) 144 Invoke(new EventHandler(Content_RunningChanged), sender, e); 147 145 else { 148 SaveEnabled = false; 149 parameterCollectionView.Enabled = false; 150 newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = false; 151 problemViewHost.Enabled = false; 152 resultsView.Enabled = false; 153 startButton.Enabled = false; 154 stopButton.Enabled = true; 155 resetButton.Enabled = false; 156 UpdateExecutionTimeTextBox(); 157 } 158 } 159 protected virtual void Content_Stopped(object sender, EventArgs e) { 160 if (InvokeRequired) 161 Invoke(new EventHandler(Content_Stopped), sender, e); 162 else { 163 SaveEnabled = true; 164 parameterCollectionView.Enabled = true; 165 newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = true; 166 problemViewHost.Enabled = true; 167 resultsView.Enabled = true; 168 startButton.Enabled = !Content.Finished; 169 stopButton.Enabled = false; 170 resetButton.Enabled = true; 146 SaveEnabled = !Content.Running; 147 parameterCollectionView.Enabled = !Content.Running; 148 newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = !Content.Running; 149 problemViewHost.Enabled = !Content.Running; 150 resultsView.Enabled = !Content.Running; 151 startButton.Enabled = !Content.Running && !Content.Finished; 152 stopButton.Enabled = Content.Running; 153 resetButton.Enabled = !Content.Running; 171 154 UpdateExecutionTimeTextBox(); 172 155 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs
r3260 r3261 171 171 this.startButton.Size = new System.Drawing.Size(24, 24); 172 172 this.startButton.TabIndex = 7; 173 this.toolTip.SetToolTip(this.startButton, "Start/Resume Algorithm");173 this.toolTip.SetToolTip(this.startButton, "Start/Resume Batch Run"); 174 174 this.startButton.UseVisualStyleBackColor = true; 175 175 this.startButton.Click += new System.EventHandler(this.startButton_Click); … … 183 183 this.stopButton.Size = new System.Drawing.Size(24, 24); 184 184 this.stopButton.TabIndex = 8; 185 this.toolTip.SetToolTip(this.stopButton, "Pause Algorithm");185 this.toolTip.SetToolTip(this.stopButton, "Pause Batch Run"); 186 186 this.stopButton.UseVisualStyleBackColor = true; 187 187 this.stopButton.Click += new System.EventHandler(this.stopButton_Click); … … 195 195 this.resetButton.Size = new System.Drawing.Size(24, 24); 196 196 this.resetButton.TabIndex = 9; 197 this.toolTip.SetToolTip(this.resetButton, "Reset Algorithm");197 this.toolTip.SetToolTip(this.resetButton, "Reset Batch Run"); 198 198 this.resetButton.UseVisualStyleBackColor = true; 199 199 this.resetButton.Click += new System.EventHandler(this.resetButton_Click); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r3260 r3261 62 62 Content.Prepared -= new EventHandler(Content_Prepared); 63 63 Content.AlgorithmChanged -= new EventHandler(Content_AlgorithmChanged); 64 Content.Started -= new EventHandler(Content_Started);65 Content.Stopped -= new EventHandler(Content_Stopped);66 64 Content.RepetitionsChanged -= new EventHandler(Content_RepetitionsChanged); 65 Content.RunningChanged -= new EventHandler(Content_RunningChanged); 67 66 base.DeregisterContentEvents(); 68 67 } … … 73 72 Content.Prepared += new EventHandler(Content_Prepared); 74 73 Content.AlgorithmChanged += new EventHandler(Content_AlgorithmChanged); 75 Content.Started += new EventHandler(Content_Started);76 Content.Stopped += new EventHandler(Content_Stopped);77 74 Content.RepetitionsChanged += new EventHandler(Content_RepetitionsChanged); 75 Content.RunningChanged += new EventHandler(Content_RunningChanged); 78 76 } 79 77 … … 128 126 } 129 127 } 130 private void Content_Started(object sender, EventArgs e) { 131 if (InvokeRequired) 132 Invoke(new EventHandler(Content_Started), sender, e); 133 else { 134 SaveEnabled = false; 135 repetitionsNumericUpDown.Enabled = false; 136 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = false; 137 startButton.Enabled = false; 138 stopButton.Enabled = true; 139 resetButton.Enabled = false; 140 UpdateExecutionTimeTextBox(); 141 } 142 } 143 private void Content_Stopped(object sender, EventArgs e) { 144 if (InvokeRequired) 145 Invoke(new EventHandler(Content_Stopped), sender, e); 146 else { 147 SaveEnabled = true; 148 repetitionsNumericUpDown.Enabled = true; 149 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = true; 150 startButton.Enabled = !Content.Finished; 151 stopButton.Enabled = false; 152 resetButton.Enabled = true; 128 private void Content_RunningChanged(object sender, EventArgs e) { 129 if (InvokeRequired) 130 Invoke(new EventHandler(Content_RunningChanged), sender, e); 131 else { 132 SaveEnabled = !Content.Running; 133 repetitionsNumericUpDown.Enabled = !Content.Running; 134 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = !Content.Running; 135 startButton.Enabled = !Content.Running && !Content.Finished; 136 stopButton.Enabled = Content.Running; 137 resetButton.Enabled = !Content.Running; 153 138 UpdateExecutionTimeTextBox(); 154 139 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/EngineAlgorithmView.cs
r3214 r3261 98 98 } 99 99 100 protected override void Content_ Started(object sender, EventArgs e) {100 protected override void Content_RunningChanged(object sender, EventArgs e) { 101 101 if (InvokeRequired) 102 Invoke(new EventHandler(Content_ Started), sender, e);102 Invoke(new EventHandler(Content_RunningChanged), sender, e); 103 103 else { 104 createUserDefinedAlgorithmButton.Enabled = false; 105 engineComboBox.Enabled = false; 106 engineViewHost.Enabled = false; 107 base.Content_Started(sender, e); 108 } 109 } 110 protected override void Content_Stopped(object sender, EventArgs e) { 111 if (InvokeRequired) 112 Invoke(new EventHandler(Content_Stopped), sender, e); 113 else { 114 createUserDefinedAlgorithmButton.Enabled = true; 115 engineComboBox.Enabled = true; 116 engineViewHost.Enabled = true; 117 base.Content_Stopped(sender, e); 104 createUserDefinedAlgorithmButton.Enabled = !Content.Running; 105 engineComboBox.Enabled = !Content.Running; 106 engineViewHost.Enabled = !Content.Running; 107 base.Content_RunningChanged(sender, e); 118 108 } 119 109 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/UserDefinedAlgorithmView.cs
r3177 r3261 75 75 } 76 76 77 protected override void Content_ Started(object sender, EventArgs e) {77 protected override void Content_RunningChanged(object sender, EventArgs e) { 78 78 if (InvokeRequired) 79 Invoke(new EventHandler(Content_ Started), sender, e);79 Invoke(new EventHandler(Content_RunningChanged), sender, e); 80 80 else { 81 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = false; 82 operatorGraphViewHost.Enabled = false; 83 globalScopeView.Enabled = false; 84 base.Content_Started(sender, e); 85 } 86 } 87 protected override void Content_Stopped(object sender, EventArgs e) { 88 if (InvokeRequired) 89 Invoke(new EventHandler(Content_Stopped), sender, e); 90 else { 91 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = true; 92 operatorGraphViewHost.Enabled = true; 93 globalScopeView.Enabled = true; 94 base.Content_Stopped(sender, e); 81 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = !Content.Running; 82 operatorGraphViewHost.Enabled = !Content.Running; 83 globalScopeView.Enabled = !Content.Running; 84 base.Content_RunningChanged(sender, e); 95 85 } 96 86 } -
trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs
r3260 r3261 112 112 } 113 113 public void Start() { 114 OnStarted(); 114 115 Running = true; 115 116 Canceled = false; 116 OnStarted();117 117 } 118 118 public void Stop() { … … 157 157 public event EventHandler Stopped; 158 158 protected virtual void OnStopped() { 159 Canceled = false; 160 Running = false; 159 161 if (Stopped != null) 160 162 Stopped(this, EventArgs.Empty); 161 Canceled = false;162 Running = false;163 163 } 164 164 protected virtual void OnCanceledChanged() { } -
trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs
r3260 r3261 142 142 } 143 143 public void Start() { 144 if (Algorithm != null) Algorithm.Start(); 144 if (Algorithm != null) { 145 OnStarted(); 146 Running = true; 147 canceled = false; 148 Algorithm.Start(); 149 } 145 150 } 146 151 public void Stop() { … … 186 191 if (Stopped != null) 187 192 Stopped(this, EventArgs.Empty); 188 canceled = false;189 Running = false;190 193 } 191 194 public event EventHandler<HeuristicLab.Common.EventArgs<Exception>> ExceptionOccurred; … … 195 198 } 196 199 200 private void RegisterAlgorithmEvents() { 201 algorithm.ExceptionOccurred += new EventHandler<HeuristicLab.Common.EventArgs<Exception>>(Algorithm_ExceptionOccurred); 202 algorithm.Started += new EventHandler(Algorithm_Started); 203 algorithm.Stopped += new EventHandler(Algorithm_Stopped); 204 } 197 205 private void DeregisterAlgorithmEvents() { 198 algorithm.RunningChanged -= new EventHandler(Algorithm_RunningChanged);199 206 algorithm.ExceptionOccurred -= new EventHandler<HeuristicLab.Common.EventArgs<Exception>>(Algorithm_ExceptionOccurred); 200 } 201 202 private void RegisterAlgorithmEvents() { 203 algorithm.RunningChanged += new EventHandler(Algorithm_RunningChanged); 204 algorithm.ExceptionOccurred += new EventHandler<HeuristicLab.Common.EventArgs<Exception>>(Algorithm_ExceptionOccurred); 205 } 206 207 private void Algorithm_RunningChanged(object sender, EventArgs e) { 208 if (Algorithm.Running) { 209 Running = true; 210 OnStarted(); 211 } else { 212 if (!canceled) { 213 ExecutionTime += Algorithm.ExecutionTime; 214 runs.Add(new Run("Run " + Algorithm.ExecutionTime.ToString(), Algorithm)); 215 Algorithm.Prepare(); 216 if (runs.Count < repetitions) Algorithm.Start(); 217 else OnStopped(); 218 } else { 219 OnStopped(); 220 } 221 } 222 } 207 algorithm.Started -= new EventHandler(Algorithm_Started); 208 algorithm.Stopped -= new EventHandler(Algorithm_Stopped); 209 } 210 223 211 private void Algorithm_ExceptionOccurred(object sender, HeuristicLab.Common.EventArgs<Exception> e) { 224 212 OnExceptionOccurred(e.Value); 213 } 214 private void Algorithm_Started(object sender, EventArgs e) { 215 if (!Running) { 216 OnStarted(); 217 Running = true; 218 canceled = false; 219 } 220 } 221 private void Algorithm_Stopped(object sender, EventArgs e) { 222 if (!canceled) { 223 ExecutionTime += Algorithm.ExecutionTime; 224 runs.Add(new Run("Run " + Algorithm.ExecutionTime.ToString(), Algorithm)); 225 Algorithm.Prepare(); 226 227 if (runs.Count < repetitions) 228 Algorithm.Start(); 229 else { 230 Running = false; 231 OnStopped(); 232 } 233 } else { 234 canceled = false; 235 Running = false; 236 OnStopped(); 237 } 225 238 } 226 239 #endregion -
trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs
r3260 r3261 216 216 Engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred); 217 217 Engine.ExecutionTimeChanged += new EventHandler(Engine_ExecutionTimeChanged); 218 Engine.RunningChanged += new EventHandler(Engine_RunningChanged); 219 } 218 Engine.Stopped += new EventHandler(Engine_Stopped); 219 } 220 220 221 private void DeregisterEngineEvents() { 221 222 Engine.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred); 222 223 Engine.ExecutionTimeChanged -= new EventHandler(Engine_ExecutionTimeChanged); 223 Engine. RunningChanged -= new EventHandler(Engine_RunningChanged);224 Engine.Stopped -= new EventHandler(Engine_Stopped); 224 225 } 225 226 … … 230 231 OnExecutionTimeChanged(); 231 232 } 232 private void Engine_ RunningChanged(object sender, EventArgs e) {233 if (!Engine.Running)OnStopped();233 private void Engine_Stopped(object sender, EventArgs e) { 234 OnStopped(); 234 235 } 235 236 }
Note: See TracChangeset
for help on using the changeset viewer.