- Timestamp:
- 08/04/10 15:13:28 (14 years ago)
- Location:
- branches/3.3-HiveMigration/sources/HeuristicLab.Hive
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/JobItemView.cs
r4144 r4145 47 47 Content.LatestSnapshotChanged += new EventHandler(Content_LatestSnapshotChanged); 48 48 Content.JobDtoChanged += new EventHandler(Content_JobDtoChanged); 49 Content.SnapshotRequestedStateChanged += new EventHandler(Content_SnapshotRequestedStateChanged); 49 50 } 50 51 … … 52 53 Content.LatestSnapshotChanged -= new EventHandler(Content_LatestSnapshotChanged); 53 54 Content.JobDtoChanged -= new EventHandler(Content_JobDtoChanged); 55 Content.SnapshotRequestedStateChanged -= new EventHandler(Content_SnapshotRequestedStateChanged); 54 56 base.DeregisterContentEvents(); 55 57 } … … 92 94 protected override void SetEnabledStateOfControls() { 93 95 base.SetEnabledStateOfControls(); 94 openSnapshotButton.Enabled = Content != null && Content.LatestSnapshot != null; 96 if (Content != null) { 97 openSnapshotButton.Enabled = Content.SnapshotRequestedState == SnapshotRequestedState.Idle; 98 requestSnapshotButton.Enabled = Content.SnapshotRequestedState == SnapshotRequestedState.Requested; 99 } 95 100 this.jobIdTextBox.ReadOnly = this.ReadOnly; 96 101 this.stateTextBox.ReadOnly = this.ReadOnly; … … 115 120 116 121 private void requestSnapshotButton_Click(object sender, EventArgs e) { 117 122 this.Content.RequestSnapshot(); 123 } 124 125 private void Content_SnapshotRequestedStateChanged(object sender, EventArgs e) { 126 SetEnabledStateOfControls(); 118 127 } 119 128 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/HiveExperiment.cs
r4144 r4145 158 158 isPollingResults = false; 159 159 resultPollingThreads = new Dictionary<Guid, Thread>(); 160 RegisterEvents(); 160 161 InitTimer(); 161 162 } … … 191 192 this.IsPollingResults = false; 192 193 this.stopResultsPollingPending = false; 194 RegisterEvents(); 193 195 LogMessage("I was deserialized."); 194 196 } 195 197 196 198 private void InitTimer() { 197 199 timer = new System.Timers.Timer(100); … … 556 558 lock (locker) { 557 559 log.LogMessage(message); 560 } 561 } 562 563 void JobItem_SnapshotRequestedStateChanged(object sender, EventArgs e) { 564 JobItem jobItem = (JobItem)sender; 565 if (jobItem.SnapshotRequestedState == SnapshotRequestedState.Requested) { 566 RequestSnapshot(jobItem.JobDto.Id); 558 567 } 559 568 } … … 588 597 ); 589 598 } 590 SerializedJob jobResult = response.Obj; 591 if (jobResult != null) { 592 Logger.Debug("HiveEngine: Results-polling - Got result!"); 593 594 //job = XmlParser.Deserialize<Job>(new MemoryStream(jobResult.SerializedJobData)); 595 596 throw new NotImplementedException("[chn] how to create a view in 3.3 and why should i do this here? shouldnt the caller of this method receive a result and decide what to do?"); 597 //ControlManager.Manager.ShowControl(job.Engine.CreateView()); 599 if (response.Success) { 600 GetJobItemById(jobId).LogMessage("Snapshot polling successfull for job " + jobId); 601 GetJobItemById(jobId).LatestSnapshot = response; 602 } else { 603 GetJobItemById(jobId).LogMessage("Error: Polling of Snapshot failed for job " + jobId + ": " + response.StatusMessage); 598 604 } 599 605 } … … 763 769 if (handler != null) handler(this, EventArgs.Empty); 764 770 } 771 772 private void RegisterEvents() { 773 jobItems.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_CollectionReset); 774 jobItems.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsAdded); 775 jobItems.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsRemoved); 776 jobItems.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsReplaced); 777 } 778 779 private void DeregisterEvents() { 780 jobItems.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_CollectionReset); 781 jobItems.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsAdded); 782 jobItems.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsRemoved); 783 jobItems.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<JobItem>>(jobItems_ItemsReplaced); 784 } 785 786 787 void jobItems_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<JobItem>> e) { 788 UpdateSnapshotRequestedEvents(e); 789 } 790 791 private void UpdateSnapshotRequestedEvents(CollectionItemsChangedEventArgs<IndexedItem<JobItem>> e) { 792 foreach (var item in e.OldItems) { 793 item.Value.SnapshotRequestedStateChanged -= new EventHandler(JobItem_SnapshotRequestedStateChanged); 794 } 795 foreach (var item in e.Items) { 796 item.Value.SnapshotRequestedStateChanged += new EventHandler(JobItem_SnapshotRequestedStateChanged); 797 } 798 } 799 800 void jobItems_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<JobItem>> e) { 801 UpdateSnapshotRequestedEvents(e); 802 } 803 804 void jobItems_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<JobItem>> e) { 805 UpdateSnapshotRequestedEvents(e); 806 } 807 808 void jobItems_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<JobItem>> e) { 809 foreach (var item in e.OldItems) { 810 item.Value.SnapshotRequestedStateChanged -= new EventHandler(JobItem_SnapshotRequestedStateChanged); 811 } 812 } 765 813 #endregion 766 814 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/JobItem.cs
r4144 r4145 13 13 14 14 namespace HeuristicLab.Hive.Experiment { 15 public enum SnapshotRequestedState { Idle, Requested } 16 15 17 [StorableClass] 16 18 public class JobItem : Item { … … 51 53 latestSnapshot = value; 52 54 latestSnapshotTime = DateTime.Now; 55 SnapshotRequestedState = Experiment.SnapshotRequestedState.Idle; 53 56 OnLatestSnapshotChanged(); 54 57 } … … 74 77 set { this.optimizer = value; } 75 78 } 76 79 80 [Storable] 81 private SnapshotRequestedState snapshotRequestedState; 82 public SnapshotRequestedState SnapshotRequestedState { 83 get { return snapshotRequestedState; } 84 private set { 85 this.snapshotRequestedState = value; 86 OnSnapshotRequestedStateChanged(); 87 } 88 } 89 77 90 public JobItem() { 78 91 log = new Log(); … … 117 130 return clone; 118 131 } 132 133 134 public event EventHandler SnapshotRequestedStateChanged; 135 private void OnSnapshotRequestedStateChanged() { 136 EventHandler handler = SnapshotRequestedStateChanged; 137 if (handler != null) handler(this, EventArgs.Empty); 138 } 139 140 public void RequestSnapshot() { 141 this.SnapshotRequestedState = Experiment.SnapshotRequestedState.Requested; 142 } 143 119 144 } 120 145 }
Note: See TracChangeset
for help on using the changeset viewer.