Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/26/16 15:05:28 (9 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • improved network visualization
Location:
branches/OptimizationNetworks/HeuristicLab.Networks/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Networks/3.3/AlgorithmNode.cs

    r13459 r13799  
    5959    }
    6060
     61    [Storable]
     62    private IItemCollection<IAlgorithm> startedAlgorithms;
     63    public IItemCollection<IAlgorithm> StartedAlgorithms {
     64      get { return startedAlgorithms; }
     65    }
     66
    6167    [StorableConstructor]
    6268    protected AlgorithmNode(bool deserializing) : base(deserializing) { }
     
    6571      algorithm = cloner.Clone(original.algorithm);
    6672      runs = cloner.Clone(original.runs);
     73      startedAlgorithms = cloner.Clone(original.startedAlgorithms);
     74      RegisterStartedAlgorithmsEvents();
    6775    }
    6876    public AlgorithmNode()
    6977      : base("AlgorithmNode") {
    7078      runs = new RunCollection();
    71     }
     79      startedAlgorithms = new ItemCollection<IAlgorithm>();
     80      RegisterStartedAlgorithmsEvents();
     81    }
     82
    7283    public AlgorithmNode(string name)
    7384      : base(name) {
    7485      runs = new RunCollection();
     86      startedAlgorithms = new ItemCollection<IAlgorithm>();
     87      RegisterStartedAlgorithmsEvents();
    7588    }
    7689    public AlgorithmNode(string name, string description)
    7790      : base(name, description) {
    7891      runs = new RunCollection();
     92      startedAlgorithms = new ItemCollection<IAlgorithm>();
     93      RegisterStartedAlgorithmsEvents();
    7994    }
    8095
    8196    public override IDeepCloneable Clone(Cloner cloner) {
    8297      return new AlgorithmNode(this, cloner);
     98    }
     99
     100    [StorableHook(HookType.AfterDeserialization)]
     101    private void AfterDeserialization() {
     102      RegisterStartedAlgorithmsEvents();
     103    }
     104
     105    protected virtual void RegisterStartedAlgorithmsEvents() {
     106      startedAlgorithms.ItemsAdded += StartedAlgorithms_ItemsChanged;
     107      startedAlgorithms.ItemsRemoved += StartedAlgorithms_ItemsChanged;
     108    }
     109
     110    private void StartedAlgorithms_ItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IAlgorithm> e) {
     111      OnStartedAlgorithmsChanged();
    83112    }
    84113
     
    146175        algorithm.Prepare(true);
    147176        algorithm.ExceptionOccurred += (sender, args) => { exception = args.Value; };
    148         algorithm.Started += (sender, args) => { started.Set(); };
    149         algorithm.Stopped += (sender, args) => { stopped.Set(); };
     177        algorithm.Started += (sender, args) => { started.Set(); startedAlgorithms.Add((IAlgorithm)sender); };
     178        algorithm.Stopped += (sender, args) => { stopped.Set(); startedAlgorithms.Remove((IAlgorithm)sender); };
    150179        algorithm.Start();
    151180        stopped.WaitOne();
     
    175204    }
    176205
     206    public event EventHandler StartedAlgorithmsChanged;
     207    protected virtual void OnStartedAlgorithmsChanged() {
     208      var handler = StartedAlgorithmsChanged;
     209      if (handler != null) handler(this, EventArgs.Empty);
     210    }
     211
    177212    #region Ports Events
    178213    protected override void RegisterPortsEvents() {
  • branches/OptimizationNetworks/HeuristicLab.Networks/3.3/IAlgorithmNode.cs

    r11577 r13799  
    2020#endregion
    2121
     22using System;
     23using HeuristicLab.Core;
    2224using HeuristicLab.Core.Networks;
    2325using HeuristicLab.Optimization;
    24 using System;
    2526
    2627namespace HeuristicLab.Networks {
     
    2930    IAlgorithm Algorithm { get; set; }
    3031    RunCollection Runs { get; }
     32    IItemCollection<IAlgorithm> StartedAlgorithms { get; }
    3133
    3234    event EventHandler AlgorithmChanged;
     35    event EventHandler StartedAlgorithmsChanged;
    3336  }
    3437}
Note: See TracChangeset for help on using the changeset viewer.