Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveHiveEngine/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs @ 7287

Last change on this file since 7287 was 7287, checked in by ascheibe, 13 years ago

#1744

  • added the new Hive engine. The engine can now be executed in the Hive. If child tasks are created it pauses and is transfered back to the server. If the child tasks are finished it is sent back to a slave.
  • changed the server so that it reschedules paused parent tasks if their childs are finished as well as tasks where FinishWhenChildJobsFinished is set to false
File size: 4.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Core.Views;
24using HeuristicLab.MainForm;
25
26namespace HeuristicLab.HiveEngine.Views {
27  [View("Hive Engine View")]
28  [Content(typeof(HiveEngine), IsDefaultView = true)]
29  public sealed partial class HiveEngineView : ItemView {
30    public new HiveEngine Content {
31      get { return (HiveEngine)base.Content; }
32      set { base.Content = value; }
33    }
34
35    public HiveEngineView() {
36      InitializeComponent();
37    }
38
39    protected override void DeregisterContentEvents() {
40      Content.ExecutionTimeOnHiveChanged -= new EventHandler(Content_ExecutionTimeOnHiveChanged);
41      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
42      base.DeregisterContentEvents();
43    }
44
45    protected override void RegisterContentEvents() {
46      base.RegisterContentEvents();
47      Content.ExecutionTimeOnHiveChanged += new EventHandler(Content_ExecutionTimeOnHiveChanged);
48      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
49    }
50
51    #region Event Handlers (Content)
52    private void Content_ExecutionTimeChanged(object sender, EventArgs e) {
53      if (InvokeRequired) {
54        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
55      } else {
56        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
57      }
58    }
59
60    private void Content_ExecutionTimeOnHiveChanged(object sender, EventArgs e) {
61      if (InvokeRequired) {
62        Invoke(new EventHandler(Content_ExecutionTimeOnHiveChanged), sender, e);
63      } else {
64        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
65      }
66    }
67    #endregion
68
69    protected override void OnContentChanged() {
70      base.OnContentChanged();
71      if (Content == null) {
72        resourceIdsTextBox.Text = string.Empty;
73        priorityTextBox.Text = string.Empty;
74        executionTimeOnHiveTextBox.Text = string.Empty;
75        isPrivilegedCheckBox.Checked = false;
76        hiveExperimentListView.Content = null;
77        logView.Content = null;
78      } else {
79        resourceIdsTextBox.Text = Content.ResourceNames;
80        priorityTextBox.Text = Content.Priority.ToString();
81        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
82        isPrivilegedCheckBox.Checked = Content.IsPrivileged;
83        hiveExperimentListView.Content = Content.Jobs;
84        logView.Content = Content.Log;
85      }
86    }
87
88    protected override void SetEnabledStateOfControls() {
89      base.SetEnabledStateOfControls();
90      // Enable or disable controls based on whether the content is null or the view is set readonly
91      if (Content != null) {
92        resourceIdsTextBox.ReadOnly = this.ReadOnly;
93        priorityTextBox.ReadOnly = this.ReadOnly;
94        isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged;
95      } else {
96        resourceIdsTextBox.ReadOnly = false;
97        priorityTextBox.ReadOnly = false;
98        isPrivilegedCheckBox.Enabled = false;
99      }
100    }
101
102    #region Event Handlers (child controls)
103    private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
104      Content.ResourceNames = resourceIdsTextBox.Text;
105    }
106
107    private void priorityTextBox_Validated(object sender, EventArgs e) {
108      Content.Priority = int.Parse(priorityTextBox.Text);
109    }
110
111    private void isPrivilegedCheckBox_Validated(object sender, EventArgs e) {
112      Content.IsPrivileged = isPrivilegedCheckBox.Checked;
113    }
114    #endregion
115  }
116}
Note: See TracBrowser for help on using the repository browser.