Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/06/10 09:20:18 (14 years ago)
Author:
cneumuel
Message:

refactoring of Result-Polling of HiveExperiment, polling is now much faster and code is cleaner (1092#)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/JobItem.cs

    r4145 r4170  
    2121    public override Image ItemImage {
    2222      get {
    23         if (jobDto.State == State.Offline) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared;
    24         else if (jobDto.State == State.Idle) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared;
    25         else if (jobDto.State == State.Calculating) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStarted;
    26         else if (jobDto.State == State.Abort) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped;
    27         else if (jobDto.State == State.Failed) return HeuristicLab.Common.Resources.VS2008ImageLibrary.Error;
    28         else if (jobDto.State == State.Finished) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped;
     23        if (State == State.Offline) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared;
     24        else if (State == State.Idle) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared;
     25        else if (State == State.Calculating) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStarted;
     26        else if (State == State.Abort) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped;
     27        else if (State == State.Failed) return HeuristicLab.Common.Resources.VS2008ImageLibrary.Error;
     28        else if (State == State.Finished) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped;
    2929        else return HeuristicLab.Common.Resources.VS2008ImageLibrary.Event;
    3030      }
     
    3333    [Storable]
    3434    private JobDto jobDto;
     35    /// <summary>
     36    /// Some static information about the job. Don't use State-Information out of there
     37    /// </summary>
    3538    public JobDto JobDto {
    3639      get { return jobDto; }
     
    4649
    4750    [Storable]
     51    private JobResult jobResult;
     52    public JobResult JobResult {
     53      private get { return jobResult; }
     54      set {
     55        if (jobResult != value) {
     56          jobResult = value;
     57          OnJobStateChanged();
     58          OnToStringChanged();
     59          OnItemImageChanged();
     60        }
     61      }
     62    }
     63
     64    public State State {
     65      get { return jobResult != null ? JobResult.State : JobDto.State; }
     66    }
     67
     68    public double? Percentage {
     69      get { return jobResult != null ? JobResult.Percentage : JobDto.Percentage; }
     70    }
     71
     72    public string Exception {
     73      get { return jobResult != null ? JobResult.Exception : JobDto.Exception; }
     74    }
     75
     76    public DateTime? DateCalculated {
     77      get { return jobResult != null ? JobResult.DateCalculated : JobDto.DateCalculated; }
     78    }
     79
     80    public DateTime? DateFinished {
     81      get { return jobResult != null ? JobResult.DateFinished : JobDto.DateFinished; }
     82    }
     83   
     84    [Storable]
    4885    private ResponseObject<SerializedJob> latestSnapshot;
    4986    public ResponseObject<SerializedJob> LatestSnapshot {
     
    5289        if (latestSnapshot != value) {
    5390          latestSnapshot = value;
    54           latestSnapshotTime = DateTime.Now;
     91          if (value != null) {
     92            latestSnapshotTime = DateTime.Now;
     93          }
    5594          SnapshotRequestedState = Experiment.SnapshotRequestedState.Idle;
    5695          OnLatestSnapshotChanged();
     
    114153    }
    115154
     155    public event EventHandler JobStateChanged;
     156    private void OnJobStateChanged() {
     157      LogMessage("JobStateChanged");
     158      EventHandler handler = JobStateChanged;
     159      if (handler != null) handler(this, EventArgs.Empty);
     160    }
     161
    116162    public void LogMessage(string message) {
    117163      lock (locker) {
     
    128174      clone.log = (ILog)cloner.Clone(this.log);
    129175      clone.optimizer = (IOptimizer)cloner.Clone(this.optimizer);
     176      clone.jobResult = (JobResult)cloner.Clone(this.jobResult);
    130177      return clone;
    131178    }
     
    142189    }
    143190
     191
    144192  }
    145193}
Note: See TracChangeset for help on using the changeset viewer.