Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/EngineJob.cs @ 6033

Last change on this file since 6033 was 6033, checked in by cneumuel, 13 years ago

#1233

  • created baseclass for jobs (ItemJob) which derives OperatorJobs and EngineJobs
  • created special view for OptimizerJobs which derives from a more general view
  • removed logic from domain class HiveExperiment and moved it into RefreshableHiveExperiment
  • improved ItemTreeView
  • corrected plugin dependencies
  • fixed bug in database trigger when deleting HiveExperiments
  • added delete cascade for Plugin and PluginData
  • lots of fixes
File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Drawing;
4using HeuristicLab.Common;
5using HeuristicLab.Core;
6using HeuristicLab.Hive;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace HeuristicLab.HiveEngine {
10  [StorableClass]
11  public class EngineJob : ItemJob {
12    [Storable]
13    protected IOperation initialOperation;
14    public IOperation InitialOperation {
15      get { return initialOperation; }
16      set { initialOperation = value; }
17    }
18
19    public new IEngine Item {
20      get { return (IEngine)base.Item; }
21      set { base.Item = value; }
22    }
23
24    public override TimeSpan ExecutionTime {
25      get { return Item.ExecutionTime; }
26    }
27
28    public override ExecutionState ExecutionState {
29      get { return Item.ExecutionState; }
30    }
31
32    #region constructors and cloning
33    public EngineJob() { }
34    public EngineJob(IOperation initialOperation, IEngine engine) {
35      this.initialOperation = initialOperation;
36      this.Item = engine;
37    }
38
39    [StorableConstructor]
40    protected EngineJob(bool deserializing) : base(deserializing) { }
41    protected EngineJob(EngineJob original, Cloner cloner)
42      : base(original, cloner) {
43      this.initialOperation = cloner.Clone(original.initialOperation);
44    }
45    public override IDeepCloneable Clone(Cloner cloner) {
46      return new EngineJob(this, cloner);
47    }
48    #endregion
49
50    public override bool IsParallelizable {
51      get { return false; }
52    }
53
54    public override void Prepare() { }
55
56    public override void Start() {
57      Item.Prepare(initialOperation);
58      Item.Start();
59    }
60   
61    public override void Pause() {
62      Item.Pause();
63    }
64
65    public override void Stop() {
66      Item.Stop();
67    }
68   
69    public override void Resume(IEnumerable<IJob> childJobs) {
70      throw new NotImplementedException();
71    }
72
73    protected override void RegisterItemEvents() {
74      Item.Stopped += new EventHandler(engine_Stopped);
75      Item.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred);
76    }
77
78    protected override void DeregisterItemEvents() {
79      Item.Stopped -= new EventHandler(engine_Stopped);
80      Item.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred);
81    }
82
83    private void engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
84      OnJobFailed(e);
85    }
86
87    private void engine_Stopped(object sender, EventArgs e) {
88      OnJobStopped();
89    }
90
91    public override bool CanChangeDescription {
92      get { return false; }
93    }
94
95    public override bool CanChangeName {
96      get { return false; }
97    }
98
99    public override string Description {
100      get { return string.Empty; }
101      set { throw new NotSupportedException(); }
102    }
103
104    public override string Name {
105      get { return Item.ToString(); }
106      set { throw new NotSupportedException(); }
107    }
108
109    public override string ItemDescription {
110      get { return Description; }
111    }
112
113    public override Image ItemImage {
114      get { return HeuristicLab.Common.Resources.VSImageLibrary.Operator; }
115    }
116   
117    public override string ItemName {
118      get { return "EngineJob"; }
119    }
120
121    public override Version ItemVersion {
122      get { return null; }
123    }
124  }
125}
Note: See TracBrowser for help on using the repository browser.