Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11452


Ignore:
Timestamp:
10/12/14 03:02:37 (8 years ago)
Author:
swagner
Message:

#2205: Worked on optimization networks

Location:
branches/OptimizationNetworks
Files:
3 added
13 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/AlgorithmNodeView.cs

    r11412 r11452  
    3030  [Content(typeof(AlgorithmNode), true)]
    3131  [Content(typeof(IAlgorithmNode), false)]
    32   public partial class AlgorithmNodeView : NodeView {
     32  public partial class AlgorithmNodeView : EntityView {
    3333    protected TypeSelectorDialog typeSelectorDialog;
    3434
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj

    r11449 r11452  
    103103      <DependentUpon>EntityView.cs</DependentUpon>
    104104    </Compile>
     105    <Compile Include="InputOutputPortView.cs">
     106      <SubType>UserControl</SubType>
     107    </Compile>
     108    <Compile Include="InputOutputPortView.Designer.cs">
     109      <DependentUpon>InputOutputPortView.cs</DependentUpon>
     110    </Compile>
    105111    <Compile Include="PortView.cs">
    106112      <SubType>UserControl</SubType>
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/NodeView.Designer.cs

    r11409 r11452  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.portCollectionView = new HeuristicLab.Optimization.Networks.Views.PortCollectionView();
    4748      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4849      this.SuspendLayout();
     
    5253      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    5354      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    54       this.nameTextBox.Location = new System.Drawing.Point(69, 0);
    55       this.nameTextBox.Size = new System.Drawing.Size(551, 20);
    5655      //
    57       // infoLabel
     56      // portCollectionView
    5857      //
    59       this.infoLabel.Location = new System.Drawing.Point(626, 3);
     58      this.portCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     59            | System.Windows.Forms.AnchorStyles.Left)
     60            | System.Windows.Forms.AnchorStyles.Right)));
     61      this.portCollectionView.Caption = "PortCollection View";
     62      this.portCollectionView.Content = null;
     63      this.portCollectionView.Location = new System.Drawing.Point(0, 26);
     64      this.portCollectionView.Name = "portCollectionView";
     65      this.portCollectionView.ReadOnly = false;
     66      this.portCollectionView.ShowDetails = true;
     67      this.portCollectionView.Size = new System.Drawing.Size(645, 491);
     68      this.portCollectionView.TabIndex = 3;
    6069      //
    6170      // NodeView
    6271      //
    6372      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     73      this.Controls.Add(this.portCollectionView);
    6474      this.Name = "NodeView";
    65       this.Size = new System.Drawing.Size(645, 517);
     75      this.Controls.SetChildIndex(this.nameLabel, 0);
     76      this.Controls.SetChildIndex(this.nameTextBox, 0);
     77      this.Controls.SetChildIndex(this.infoLabel, 0);
     78      this.Controls.SetChildIndex(this.portCollectionView, 0);
    6679      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    6780      this.ResumeLayout(false);
     
    7285    #endregion
    7386
     87    protected PortCollectionView portCollectionView;
     88
     89
    7490
    7591
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/NodeView.cs

    r11449 r11452  
    3838    }
    3939
    40     protected override void DeregisterContentEvents() {
    41       // remove events here
    42       base.DeregisterContentEvents();
    43     }
    44 
    45     protected override void RegisterContentEvents() {
    46       base.RegisterContentEvents();
    47       // add events here
    48     }
    49 
    5040    protected override void OnContentChanged() {
    5141      base.OnContentChanged();
    52       //...
     42      portCollectionView.Content = Content == null ? null : Content.Ports;
    5343    }
    5444
    5545    protected override void SetEnabledStateOfControls() {
    5646      base.SetEnabledStateOfControls();
    57       //...
     47      portCollectionView.Enabled = Content != null && !ReadOnly;
    5848    }
    5949  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/VariablesNodeView.Designer.cs

    r11412 r11452  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.portCollectionView = new HeuristicLab.Optimization.Networks.Views.PortCollectionView();
    4847      this.splitContainer = new System.Windows.Forms.SplitContainer();
    4948      this.variableCollectionView = new HeuristicLab.Core.Views.VariableCollectionView();
     49      this.portCollectionView = new HeuristicLab.Optimization.Networks.Views.PortCollectionView();
    5050      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5151      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     
    5959      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    6060      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    61       //
    62       // portCollectionView
    63       //
    64       this.portCollectionView.Caption = "PortCollection View";
    65       this.portCollectionView.Content = null;
    66       this.portCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
    67       this.portCollectionView.Location = new System.Drawing.Point(0, 0);
    68       this.portCollectionView.Name = "portCollectionView";
    69       this.portCollectionView.ReadOnly = false;
    70       this.portCollectionView.ShowDetails = true;
    71       this.portCollectionView.Size = new System.Drawing.Size(645, 238);
    72       this.portCollectionView.TabIndex = 0;
    7361      //
    7462      // splitContainer
     
    8977      this.splitContainer.Panel2.Controls.Add(this.variableCollectionView);
    9078      this.splitContainer.Size = new System.Drawing.Size(645, 491);
    91       this.splitContainer.SplitterDistance = 238;
     79      this.splitContainer.SplitterDistance = 237;
    9280      this.splitContainer.TabIndex = 3;
    9381      //
     
    10189      this.variableCollectionView.ReadOnly = false;
    10290      this.variableCollectionView.ShowDetails = true;
    103       this.variableCollectionView.Size = new System.Drawing.Size(645, 249);
     91      this.variableCollectionView.Size = new System.Drawing.Size(645, 250);
    10492      this.variableCollectionView.TabIndex = 0;
     93      //
     94      // portCollectionView
     95      //
     96      this.portCollectionView.Caption = "PortCollection View";
     97      this.portCollectionView.Content = null;
     98      this.portCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
     99      this.portCollectionView.Location = new System.Drawing.Point(0, 0);
     100      this.portCollectionView.Name = "portCollectionView";
     101      this.portCollectionView.ReadOnly = false;
     102      this.portCollectionView.ShowDetails = true;
     103      this.portCollectionView.Size = new System.Drawing.Size(645, 237);
     104      this.portCollectionView.TabIndex = 0;
    105105      //
    106106      // VariablesNodeView
     
    125125    #endregion
    126126
    127     protected PortCollectionView portCollectionView;
    128127    protected System.Windows.Forms.SplitContainer splitContainer;
    129128    protected Core.Views.VariableCollectionView variableCollectionView;
     129    private PortCollectionView portCollectionView;
    130130
    131131
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/VariablesNodeView.cs

    r11412 r11452  
    3030  [Content(typeof(VariablesNode), true)]
    3131  [Content(typeof(IVariablesNode), false)]
    32   public partial class VariablesNodeView : NodeView {
     32  public partial class VariablesNodeView : EntityView {
    3333    public new IVariablesNode Content {
    3434      get { return (IVariablesNode)base.Content; }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj

    r11449 r11452  
    8989    <Compile Include="Entity.cs" />
    9090    <Compile Include="Port.cs" />
     91    <Compile Include="MultiplierNode.cs" />
    9192    <Compile Include="VariablesNode.cs" />
    9293    <Compile Include="EventArgs.cs" />
     
    134135      <Name>HeuristicLab.Core-3.3</Name>
    135136    </ProjectReference>
     137    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     138      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     139      <Name>HeuristicLab.Data-3.3</Name>
     140    </ProjectReference>
    136141    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    137142      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs

    r11421 r11452  
    2525namespace HeuristicLab.Optimization.Networks {
    2626  public interface IInputOutputPort : IValuePort {
    27     IOutputInputPort OutputInputPort { get; }
     27    IOutputInputPort OutputInputPort { get; set; }
    2828
    2929    event EventHandler OutputInputPortChanged;
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IValuePort.cs

    r11421 r11452  
    2525namespace HeuristicLab.Optimization.Networks {
    2626  public interface IValuePort : IPort {
    27     //DISCUSS: Should there be a reference to the node of this port?
    28 
    2927    object Value { get; }
    3028
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs

    r11431 r11452  
    4646    IOutputInputPort IInputOutputPort.OutputInputPort {
    4747      get { return outputInputPort; }
     48      set {
     49        var val = value as IOutputInputPort<TIn, TOut>;
     50        if ((value != null) && (val == null))
     51          throw new InvalidOperationException(
     52            string.Format("Type mismatch. OutputInputPort is not a \"{0}\".",
     53                          typeof(IOutputInputPort<TIn, TOut>).GetPrettyName())
     54          );
     55        OutputInputPort = val;
     56      }
    4857    }
    4958
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs

    r11438 r11452  
    4444          RegisterOutputPortEvents();
    4545          OnOutputPortChanged();
     46          UpdateValue();
    4647        }
    4748      }
     
    7980    }
    8081
     82    protected virtual void UpdateValue() {
     83      if (OutputPort != null) {
     84        var value = OutputPort.Value;
     85        if (value != null)
     86          value = (T)value.Clone();
     87        Value = value;
     88        //DISCUSS: clone value?
     89        //DISCUSS: switch threads to decouple value propagation and to make communication asynchronous -> should be done in Node?
     90      }
     91    }
     92
    8193    public event EventHandler OutputPortChanged;
    8294    protected void OnOutputPortChanged() {
     
    96108    }
    97109    protected void OutputPort_ValueChanged(object sender, EventArgs e) {
    98       var value = OutputPort.Value;
    99       if (value != null)
    100         value = (T)value.Clone();
    101       Value = value;
    102       //DISCUSS: clone value?
    103       //DISCUSS: switch threads to decouple value propagation and to make communication asynchronous -> should be done in Node?
     110      UpdateValue();
    104111    }
    105112  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Plugin.cs.frame

    r11409 r11452  
    3232  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3333  [PluginDependency("HeuristicLab.Core", "3.3")]
     34  [PluginDependency("HeuristicLab.Data", "3.3")]
    3435  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    3536  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/VariablesNode.cs

    r11423 r11452  
    7777
    7878    private void UpdateVariable(IInputPort port) {
    79       IVariable var = null;
    80       if (variables.TryGetValue(port.Name, out var)) {
    81         var.Value = (IItem)port.Value;
    82       }
     79      if (!variables.ContainsKey(port.Name))
     80        variables.Add(new Variable(port.Name));
     81      variables[port.Name].Value = (IItem)port.Value;
    8382    }
    8483    private void UpdateOutputPort(IVariable variable) {
    8584      IPort port = null;
    8685      if (Ports.TryGetValue(variable.Name, out port)) {
    87         IOutputPort p = port as IOutputPort;
    88         if (p != null) {
    89           p.Value = variable.Value;
     86        IOutputPort o = port as IOutputPort;
     87        if (o != null) {
     88          o.Value = variable.Value;
     89        }
     90        IOutputInputPort oi = port as IOutputInputPort;
     91        if (oi != null) {
     92          var result = (IItem)oi.SendValue(variable.Value);
     93          if (!variables.ContainsKey(oi.Name + "Result"))
     94            variables.Add(new Variable(oi.Name + "Result"));
     95          variables[oi.Name + "Result"].Value = result;
    9096        }
    9197      }
     
    98104        port.Value = null;
    99105      }
     106    }
     107    private void UpdateOutputInputPort(IOutputInputPort port) {
     108      IVariable var = null;
     109      IItem result = null;
     110      if (variables.TryGetValue(port.Name, out var)) {
     111        result = (IItem)port.SendValue(var.Value);
     112      } else {
     113        result = (IItem)port.SendValue(null);
     114      }
     115      if (!variables.ContainsKey(port.Name + "Result"))
     116        variables.Add(new Variable(port.Name + "Result"));
     117      variables[port.Name + "Result"].Value = result;
    100118    }
    101119
     
    145163        UpdateOutputPort(o);
    146164      }
     165      IOutputInputPort oi = port as IOutputInputPort;
     166      if (oi != null) {
     167        oi.NameChanged += OutputInputPort_NameChanged;
     168        UpdateOutputInputPort(oi);
     169      }
    147170    }
    148171    private void DeregisterPortEvents(IPort port) {
     
    156179        o.NameChanged -= OutputPort_NameChanged;
    157180      }
     181      IOutputInputPort oi = port as IOutputInputPort;
     182      if (oi != null) {
     183        oi.NameChanged -= OutputInputPort_NameChanged;
     184      }
    158185    }
    159186    private void InputPort_NameChanged(object sender, EventArgs e) {
     
    165192    private void OutputPort_NameChanged(object sender, EventArgs e) {
    166193      UpdateOutputPort((IOutputPort)sender);
     194    }
     195    private void OutputInputPort_NameChanged(object sender, EventArgs e) {
     196      UpdateOutputInputPort((IOutputInputPort)sender);
    167197    }
    168198    #endregion
Note: See TracChangeset for help on using the changeset viewer.