Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11490


Ignore:
Timestamp:
10/24/14 05:05:47 (10 years ago)
Author:
swagner
Message:

#2205: Worked on optimization networks

Location:
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj

    r11489 r11490  
    9292    <Compile Include="ClientNode.cs" />
    9393    <Compile Include="AlgorithmServiceNode.cs" />
     94    <Compile Include="IConnectedPort.cs" />
    9495    <Compile Include="IGenericPort.cs" />
    9596    <Compile Include="IMessage.cs" />
    9697    <Compile Include="IMessageValue.cs" />
     98    <Compile Include="Message.cs" />
    9799    <Compile Include="ParameterizedPort.cs" />
    98100    <Compile Include="IClientNode.cs" />
     
    119121    <Compile Include="ClientServicePort.cs" />
    120122    <Compile Include="ClientPort.cs" />
     123    <Compile Include="GenericPort.cs" />
    121124    <Compile Include="ServicePort.cs" />
    122125    <Compile Include="Port.cs" />
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IGenericPort.cs

    r11489 r11490  
    2727namespace HeuristicLab.Optimization.Networks {
    2828  public interface IGenericPort : IParameterizedPort {
    29     IGenericPort ConnectedPort { get; set; }
     29    IConnectedPort ConnectedPort { get; set; }
    3030    bool PortConnectionValid { get; }
    3131
     
    4040    Task SendMessageAsync(IMessage message);
    4141    Task SendMessageAsync(IMessage message, CancellationToken token);
    42     event EventHandler<EventArgs<IMessage, CancellationToken>> MessageSent;
    4342
    44     void ReceiveMessage(IMessage message);
    45     void ReceiveMessage(IMessage message, CancellationToken token);
    46     Task ReceiveMessageAsync(IMessage message);
    47     Task ReceiveMessageAsync(IMessage message, CancellationToken token);
    4843    event EventHandler<EventArgs<IMessage, CancellationToken>> MessageReceived;
    4944  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IMessage.cs

    r11489 r11490  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223
    2324namespace HeuristicLab.Optimization.Networks {
    24   public interface IMessage {
     25  public interface IMessage : IItem {
    2526    MessageValueCollection Values { get; }
     27    IItem this[string valueName] { get; }
    2628  }
    2729}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPortParameter.cs

    r11489 r11490  
    2828    Type DataType { get; }
    2929    PortParameterType Type { get; set; }
    30     IItem Value { get; set; }
     30    IItem DefaultValue { get; set; }
    3131
    3232    event EventHandler TypeChanged;
    3333    event EventHandler ValueChanged;
     34
     35    IMessageValue CreateMessageValue();
    3436  }
    3537
    3638  public interface IPortParameter<T> : IPortParameter where T : class, IItem {
    37     new T Value { get; set; }
     39    new T DefaultValue { get; set; }
     40
     41    new IMessageValue<T> CreateMessageValue();
    3842  }
    3943}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortParameter.cs

    r11489 r11490  
    6363    }
    6464    [Storable]
    65     protected T value;
    66     public T Value {
    67       get { return value; }
     65    protected T defaultValue;
     66    public T DefaultValue {
     67      get { return defaultValue; }
    6868      set {
    69         if (value != this.value) {
    70           DeregisterValueEvents();
    71           this.value = value;
    72           RegisterValueEvents();
     69        if (value != this.defaultValue) {
     70          DeregisterDefaultValueEvents();
     71          this.defaultValue = value;
     72          RegisterDefaultValueEvents();
    7373          OnValueChanged();
    7474        }
    7575      }
    7676    }
    77     IItem IPortParameter.Value {
    78       get { return Value; }
     77    IItem IPortParameter.DefaultValue {
     78      get { return DefaultValue; }
    7979      set {
    8080        T val = value as T;
     
    8484                          typeof(T).GetPrettyName())
    8585          );
    86         Value = val;
     86        DefaultValue = val;
    8787      }
    8888    }
     
    9393      : base(original, cloner) {
    9494      this.type = original.type;
    95       this.value = cloner.Clone(original.value);
    96       RegisterValueEvents();
     95      this.defaultValue = cloner.Clone(original.defaultValue);
     96      RegisterDefaultValueEvents();
    9797    }
    9898    public PortParameter() : base("PortParameter") { }
     
    102102    [StorableHook(HookType.AfterDeserialization)]
    103103    private void AfterDeserialization() {
    104       RegisterValueEvents();
     104      RegisterDefaultValueEvents();
    105105    }
    106106
     
    111111    public override string ToString() {
    112112      var s = base.ToString();
    113       if (Value != null)
    114         s += ": " + Value.ToString();
     113      if (DefaultValue != null)
     114        s += ": " + DefaultValue.ToString();
    115115      return s;
    116116    }
     
    129129      OnToStringChanged();
    130130    }
    131     protected virtual void RegisterValueEvents() {
    132       if (value != null) {
    133         value.ToStringChanged += new EventHandler(Value_ToStringChanged);
     131
     132    public IMessageValue<T> CreateMessageValue() {
     133      if (DefaultValue == null)
     134        return new MessageValue<T>(Name);
     135      else
     136        return new MessageValue<T>(Name, (T)DefaultValue.Clone());
     137    }
     138    IMessageValue IPortParameter.CreateMessageValue() {
     139      return CreateMessageValue();
     140    }
     141
     142    #region DefaultValue Events
     143    protected virtual void RegisterDefaultValueEvents() {
     144      if (defaultValue != null) {
     145        defaultValue.ToStringChanged += new EventHandler(DefaultValue_ToStringChanged);
    134146      }
    135147    }
    136     protected virtual void DeregisterValueEvents() {
    137       if (value != null) {
    138         value.ToStringChanged -= new EventHandler(Value_ToStringChanged);
     148    protected virtual void DeregisterDefaultValueEvents() {
     149      if (defaultValue != null) {
     150        defaultValue.ToStringChanged -= new EventHandler(DefaultValue_ToStringChanged);
    139151      }
    140152    }
    141     private void Value_ToStringChanged(object sender, EventArgs e) {
     153    private void DefaultValue_ToStringChanged(object sender, EventArgs e) {
    142154      OnToStringChanged();
    143155    }
     156    #endregion
    144157  }
    145158}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortParameterType.cs

    r11489 r11490  
    2020#endregion
    2121
     22using System;
    2223
    2324namespace HeuristicLab.Optimization.Networks {
     25  [Flags]
    2426  public enum PortParameterType {
    25     Input,
    26     Output
     27    Input = 1,
     28    Output = 2
    2729  }
    2830}
Note: See TracChangeset for help on using the changeset viewer.