- Timestamp:
- 10/12/14 03:02:37 (10 years ago)
- Location:
- branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj
r11449 r11452 89 89 <Compile Include="Entity.cs" /> 90 90 <Compile Include="Port.cs" /> 91 <Compile Include="MultiplierNode.cs" /> 91 92 <Compile Include="VariablesNode.cs" /> 92 93 <Compile Include="EventArgs.cs" /> … … 134 135 <Name>HeuristicLab.Core-3.3</Name> 135 136 </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> 136 141 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 137 142 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs
r11421 r11452 25 25 namespace HeuristicLab.Optimization.Networks { 26 26 public interface IInputOutputPort : IValuePort { 27 IOutputInputPort OutputInputPort { get; }27 IOutputInputPort OutputInputPort { get; set; } 28 28 29 29 event EventHandler OutputInputPortChanged; -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IValuePort.cs
r11421 r11452 25 25 namespace HeuristicLab.Optimization.Networks { 26 26 public interface IValuePort : IPort { 27 //DISCUSS: Should there be a reference to the node of this port?28 29 27 object Value { get; } 30 28 -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs
r11431 r11452 46 46 IOutputInputPort IInputOutputPort.OutputInputPort { 47 47 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 } 48 57 } 49 58 -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs
r11438 r11452 44 44 RegisterOutputPortEvents(); 45 45 OnOutputPortChanged(); 46 UpdateValue(); 46 47 } 47 48 } … … 79 80 } 80 81 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 81 93 public event EventHandler OutputPortChanged; 82 94 protected void OnOutputPortChanged() { … … 96 108 } 97 109 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(); 104 111 } 105 112 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Plugin.cs.frame
r11409 r11452 32 32 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 33 33 [PluginDependency("HeuristicLab.Core", "3.3")] 34 [PluginDependency("HeuristicLab.Data", "3.3")] 34 35 [PluginDependency("HeuristicLab.Optimization", "3.3")] 35 36 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/VariablesNode.cs
r11423 r11452 77 77 78 78 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; 83 82 } 84 83 private void UpdateOutputPort(IVariable variable) { 85 84 IPort port = null; 86 85 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; 90 96 } 91 97 } … … 98 104 port.Value = null; 99 105 } 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; 100 118 } 101 119 … … 145 163 UpdateOutputPort(o); 146 164 } 165 IOutputInputPort oi = port as IOutputInputPort; 166 if (oi != null) { 167 oi.NameChanged += OutputInputPort_NameChanged; 168 UpdateOutputInputPort(oi); 169 } 147 170 } 148 171 private void DeregisterPortEvents(IPort port) { … … 156 179 o.NameChanged -= OutputPort_NameChanged; 157 180 } 181 IOutputInputPort oi = port as IOutputInputPort; 182 if (oi != null) { 183 oi.NameChanged -= OutputInputPort_NameChanged; 184 } 158 185 } 159 186 private void InputPort_NameChanged(object sender, EventArgs e) { … … 165 192 private void OutputPort_NameChanged(object sender, EventArgs e) { 166 193 UpdateOutputPort((IOutputPort)sender); 194 } 195 private void OutputInputPort_NameChanged(object sender, EventArgs e) { 196 UpdateOutputInputPort((IOutputInputPort)sender); 167 197 } 168 198 #endregion
Note: See TracChangeset
for help on using the changeset viewer.