Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/11/12 01:46:34 (12 years ago)
Author:
abeham
Message:

#1329:

  • Removed unnecessary DueDates parameter
  • Changed ValueParameter to FixedValueParameter for Jobs and Resources
  • Made Job and Task INotifyPropertyChanged
  • Added a JobView and TaskView
Location:
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs

    r8603 r8886  
    2020#endregion
    2121
     22using System.ComponentModel;
    2223using System.Text;
    2324using HeuristicLab.Common;
     
    2829  [Item("Job", "Represents a composition of tasks that require processing in a scheduling problem.")]
    2930  [StorableClass]
    30   public class Job : Item {
    31     [Storable]
    32     public double DueDate { get; set; }
    33     [Storable]
    34     public int Index { get; set; }
    35     [Storable]
    36     public ItemList<Task> Tasks { get; set; }
     31  public class Job : Item, INotifyPropertyChanged {
     32    [Storable(Name = "DueDate")] private double dueDate;
     33    public double DueDate {
     34      get { return dueDate; }
     35      set {
     36        bool changed = dueDate != value;
     37        dueDate = value;
     38        if (changed) OnPropertyChanged("DueDate");
     39      }
     40    }
     41
     42    [Storable(Name = "Index")]
     43    private int index;
     44    public int Index {
     45      get { return index; }
     46      set {
     47        bool changed = index != value;
     48        index = value;
     49        if (changed) OnPropertyChanged("Index");
     50      }
     51    }
     52
     53    [Storable(Name = "Tasks")]
     54    private ItemList<Task> tasks;
     55    public ItemList<Task> Tasks {
     56      get { return tasks; }
     57      set {
     58        bool changed = tasks != value;
     59        tasks = value;
     60        if (changed) OnPropertyChanged("Tasks");
     61      }
     62    }
    3763
    3864    [StorableConstructor]
     
    4975    public Job(int index, double dueDate)
    5076      : base() {
     77      DueDate = dueDate;
    5178      Index = index;
    5279      Tasks = new ItemList<Task>();
    53 
    54       DueDate = dueDate;
    55 
    5680    }
    5781
    5882    public override string ToString() {
    59       StringBuilder sb = new StringBuilder();
     83      var sb = new StringBuilder();
    6084      sb.Append("Job#" + Index + " [ ");
    6185      foreach (Task t in Tasks) {
     
    6892
    6993    internal Task GetPreviousTask(Task t) {
    70       if (t.TaskNr == 0)
    71         return null;
    72       else
    73         return Tasks[t.TaskNr - 1];
     94      if (t.TaskNr == 0) return null;
     95      return Tasks[t.TaskNr - 1];
    7496    }
    7597
    76 
     98    public event PropertyChangedEventHandler PropertyChanged;
     99    protected virtual void OnPropertyChanged(string propertyName) {
     100      var handler = PropertyChanged;
     101      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
     102    }
    77103  }
    78104}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs

    r8603 r8886  
    2020#endregion
    2121
     22using System.ComponentModel;
    2223using System.Text;
    2324using HeuristicLab.Common;
     
    2829  [Item("Task", "Represents a task that has to be scheduled.")]
    2930  [StorableClass]
    30   public class Task : Item {
    31     [Storable]
    32     public int TaskNr { get; set; }
    33     [Storable]
    34     public int ResourceNr { get; set; }
    35     [Storable]
    36     public int JobNr { get; set; }
    37     [Storable]
    38     public double Duration { get; set; }
    39     [Storable]
    40     public bool IsScheduled { get; set; }
     31  public class Task : Item, INotifyPropertyChanged {
     32    [Storable(Name = "TaskNr")]
     33    private int taskNr;
     34    public int TaskNr {
     35      get { return taskNr; }
     36      set {
     37        bool changed = taskNr != value;
     38        taskNr = value;
     39        if (changed) OnPropertyChanged("TaskNr");
     40      }
     41    }
     42    [Storable(Name = "ResourceNr")]
     43    private int resourceNr;
     44    public int ResourceNr {
     45      get { return resourceNr; }
     46      set {
     47        bool changed = resourceNr != value;
     48        resourceNr = value;
     49        if (changed) OnPropertyChanged("ResourceNr");
     50      }
     51    }
     52
     53    [Storable(Name = "JobNr")]
     54    private int jobNr;
     55    public int JobNr {
     56      get { return jobNr; }
     57      set {
     58        bool changed = jobNr != value;
     59        jobNr = value;
     60        if (changed) OnPropertyChanged("JobNr");
     61      }
     62    }
     63
     64    [Storable(Name = "Duration")]
     65    private double duration;
     66    public double Duration {
     67      get { return duration; }
     68      set {
     69        bool changed = duration != value;
     70        duration = value;
     71        if (changed) OnPropertyChanged("Duration");
     72      }
     73    }
     74
     75    [Storable(Name = "IsScheduled")]
     76    private bool isScheduled;
     77    public bool IsScheduled {
     78      get { return isScheduled; }
     79      set {
     80        bool changed = isScheduled != value;
     81        isScheduled = value;
     82        if (changed) OnPropertyChanged("IsScheduled");
     83      }
     84    }
    4185
    4286    [StorableConstructor]
     
    86130        task1.TaskNr == task2.TaskNr);
    87131    }
     132
     133    public event PropertyChangedEventHandler PropertyChanged;
     134    protected virtual void OnPropertyChanged(string propertyName) {
     135      var handler = PropertyChanged;
     136      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
     137    }
    88138  }
    89139}
Note: See TracChangeset for help on using the changeset viewer.