Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/08/11 14:54:17 (13 years ago)
Author:
cneumuel
Message:

#1233

  • updated jobstates documentation
  • enhanced ganttChart
  • fixed setting of jobstates
  • added option to force lifecycle-trigger (mainly for testing purposes)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/StateLogGanttChartListView.cs

    r5597 r5636  
    2020#endregion
    2121
     22using System;
    2223using System.Drawing;
     24using System.Linq;
    2325using HeuristicLab.Core;
    2426using HeuristicLab.Core.Views;
    2527using HeuristicLab.MainForm;
    26 using HeuristicLab.Services.Hive.Common.DataTransfer;
    2728
    2829namespace HeuristicLab.Clients.Hive.Views {
    2930  [View("StateLogGanttChartList View")]
    30   [Content(typeof(IItemList<StateLogItemList>), IsDefaultView = true)]
     31  [Content(typeof(IItemList<StateLogList>), IsDefaultView = true)]
    3132  public sealed partial class StateLogGanttChartListView : ItemView {
    32     public new IItemList<StateLogItemList> Content {
    33       get { return (IItemList<StateLogItemList>)base.Content; }
     33    public new IItemList<StateLogList> Content {
     34      get { return (IItemList<StateLogList>)base.Content; }
    3435      set { base.Content = value; }
    3536    }
     
    6162        // Add code when content has been changed and is not null
    6263        ganttChart.Reset();
    63         ganttChart.AddCategory(JobState.Offline.ToString(), Color.Brown);
    64         ganttChart.AddCategory(JobState.Waiting.ToString(), Color.Yellow);
    65         ganttChart.AddCategory(JobState.Transferring.ToString(), Color.Blue);
    66         ganttChart.AddCategory(JobState.Calculating.ToString(), Color.Green);
    67         ganttChart.AddCategory(JobState.Finished.ToString(), Color.DarkGreen);
    68         ganttChart.AddCategory(JobState.Aborted.ToString(), Color.Orange);
    69         ganttChart.AddCategory(JobState.Failed.ToString(), Color.Red);
     64        SetupCategories(ganttChart);
     65
     66        DateTime maxValue = Content.Max(x => x.Max(y => y.DateTime));
     67        var upperLimit = DateTime.FromOADate(Math.Min(DateTime.Now.AddSeconds(10).ToOADate(), maxValue.AddSeconds(10).ToOADate()));
    7068
    7169        for (int i = 0; i < Content.Count; i++) {
    7270          for (int j = 0; j < Content[i].Count - 1; j++) {
    73             string tooltip = string.Format("State: {0}\n{1} - {2}", Content[i][j].State, Content[i][j].DateTime, Content[i][j+1].DateTime);
    74             if (!string.IsNullOrEmpty(Content[i][j].Exception))
    75               tooltip += "\n" + Content[i][j].Exception;
    76             ganttChart.AddData(i + 1, Content[i][j].State.ToString(), Content[i][j].DateTime, Content[i][j + 1].DateTime, tooltip, false);
     71            if(Content[i][j].State != JobState.Offline && Content[i][j].State != JobState.Finished)
     72              AddData(ganttChart, i.ToString(), Content[i][j], Content[i][j+1], upperLimit);
     73          }
     74          if(Content[i].Count > 0) {
     75            AddData(ganttChart, i.ToString(), Content[i][Content[i].Count - 1], null, upperLimit);
    7776          }
    7877        }
     
    8079    }
    8180
     81    public static void SetupCategories(GanttChart ganttChart) {
     82      ganttChart.AddCategory(JobState.Offline.ToString(), Color.Gainsboro);
     83      ganttChart.AddCategory(JobState.Waiting.ToString(), Color.NavajoWhite);
     84      ganttChart.AddCategory(JobState.Transferring.ToString(), Color.CornflowerBlue);
     85      ganttChart.AddCategory(JobState.Calculating.ToString(), Color.DarkGreen);
     86      ganttChart.AddCategory(JobState.Finished.ToString(), Color.White);
     87      ganttChart.AddCategory(JobState.Aborted.ToString(), Color.Orange);
     88      ganttChart.AddCategory(JobState.Failed.ToString(), Color.Red);
     89    }
     90
     91    //private void AddData(int i, int j, DateTime upperLimit) {
     92    //  DateTime until = j < Content[i].Count - 1 ? Content[i][j + 1].DateTime : upperLimit;
     93    //  TimeSpan duration = until - Content[i][j].DateTime;
     94    //  string tooltip = string.Format("State: {0}\nDuration: {1}\n{2} - {3}", Content[i][j].State, Content[i][j].DateTime, duration, until);
     95    //  if (!string.IsNullOrEmpty(Content[i][j].Exception))
     96    //    tooltip += "\n" + Content[i][j].Exception;
     97    //  ganttChart.AddData(i + 1, Content[i][j].State.ToString(), Content[i][j].DateTime, until, tooltip, false);
     98    //}
     99
     100    public static void AddData(GanttChart ganttChart, string name, StateLog from, StateLog to, DateTime upperLimit) {
     101      DateTime until = to != null ? to.DateTime : upperLimit;
     102      TimeSpan duration = until - from.DateTime;
     103      string tooltip = string.Format("State: {0}\nDuration: {1}\n{2} - {3}", from.State, from.DateTime, duration, until);
     104      if (!string.IsNullOrEmpty(from.Exception))
     105        tooltip += "\n" + from.Exception;
     106      ganttChart.AddData(name, from.State.ToString(), from.DateTime, until, tooltip, false);
     107    }
     108   
    82109    protected override void SetEnabledStateOfControls() {
    83110      base.SetEnabledStateOfControls();
Note: See TracChangeset for help on using the changeset viewer.