Changeset 704
- Timestamp:
- 10/29/08 16:01:41 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 9 added
- 8 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Communication.Data/HeuristicLab.Communication.Data.csproj
r584 r704 59 59 --> 60 60 <ItemGroup> 61 <Compile Include="Message.cs" /> 61 62 <Compile Include="DummyDriverConfiguration.cs" /> 62 63 <Compile Include="HeuristicLabCommunicationDataPlugin.cs" /> … … 109 110 <DependentUpon>TcpNetworkDriverConfigurationView.cs</DependentUpon> 110 111 </Compile> 112 <Compile Include="WindowedView.cs"> 113 <SubType>Form</SubType> 114 </Compile> 115 <Compile Include="WindowedView.Designer.cs"> 116 <DependentUpon>WindowedView.cs</DependentUpon> 117 </Compile> 111 118 </ItemGroup> 112 119 <ItemGroup> … … 134 141 <DependentUpon>TcpNetworkDriverConfigurationView.cs</DependentUpon> 135 142 <SubType>Designer</SubType> 143 </EmbeddedResource> 144 <EmbeddedResource Include="WindowedView.resx"> 145 <DependentUpon>WindowedView.cs</DependentUpon> 136 146 </EmbeddedResource> 137 147 </ItemGroup> -
trunk/sources/HeuristicLab.Communication.Data/ProcessData.cs
r591 r704 88 88 public void Initialize(IDriverConfiguration configuration) { 89 89 Configuration = configuration; 90 StartProcess();91 90 } 92 91 93 public bool Connect() { 94 return true; 92 public bool Connect() { 93 StartProcess(); 94 return process != null && !process.HasExited; 95 95 } 96 96 … … 104 104 StreamWriter writer = process.StandardInput; 105 105 writer.WriteLine(s); 106 writer.WriteLine( ".");106 writer.WriteLine(((char)4).ToString()); 107 107 } 108 108 … … 113 113 do { 114 114 line = reader.ReadLine(); 115 if (line.Equals( ".")) break;115 if (line.Equals(((char)4).ToString())) break; 116 116 buffer.AppendLine(line); 117 117 } while (true); -
trunk/sources/HeuristicLab.Communication.Data/Protocol.cs
r591 r704 30 30 namespace HeuristicLab.Communication.Data { 31 31 public class Protocol : ItemBase, IEditable { 32 private StringDataname;33 public StringDataName {32 private string name; 33 public string Name { 34 34 get { return name; } 35 35 set { … … 38 38 } 39 39 } 40 private I temList<ProtocolState> states;41 public I temList<ProtocolState> States {40 private IList<ProtocolState> states; 41 public IList<ProtocolState> States { 42 42 get { return states; } 43 43 set { 44 states.ItemAdded -= new EventHandler<ItemIndexEventArgs>(States_ItemAdded);45 states.ItemRemoved -= new EventHandler<ItemIndexEventArgs>(States_ItemRemoved);46 44 states = value; 47 states.ItemAdded += new EventHandler<ItemIndexEventArgs>(States_ItemAdded); 48 states.ItemRemoved += new EventHandler<ItemIndexEventArgs>(States_ItemRemoved); 49 // if the newly assigned states don't contain the currently selected initial state 45 // if the newly assigned states list doesn't contain the currently selected initial state 50 46 if (!states.Contains(initialState)) 51 47 if (states.Count > 0) … … 65 61 66 62 public Protocol() { 67 name = new StringData("Unnamed protocol"); 68 states = new ItemList<ProtocolState>(); 69 states.ItemAdded += new EventHandler<ItemIndexEventArgs>(States_ItemAdded); 70 states.ItemRemoved += new EventHandler<ItemIndexEventArgs>(States_ItemRemoved); 63 name = "Unnamed protocol"; 64 states = new List<ProtocolState>(); 65 71 66 ProtocolState firstState = new ProtocolState(); 72 firstState.Name = new StringData("InitialState"); 73 firstState.AcceptingState = new BoolData(true); 74 firstState.Protocol = this; 67 firstState.Name = "InitialState"; 75 68 states.Add(firstState); 76 69 initialState = firstState; 77 }78 79 public void Dispose() {80 states.ItemAdded -= new EventHandler<ItemIndexEventArgs>(States_ItemAdded);81 states.ItemRemoved -= new EventHandler<ItemIndexEventArgs>(States_ItemRemoved);82 70 } 83 71 … … 89 77 } 90 78 79 #region clone & persistence 91 80 public override object Clone(IDictionary<Guid, object> clonedObjects) { 92 81 Protocol clone = new Protocol(); 93 82 clonedObjects.Add(Guid, clone); 94 clone.Name = (StringData)Auxiliary.Clone(Name, clonedObjects); 95 clone.States = (ItemList<ProtocolState>)Auxiliary.Clone(States, clonedObjects); 83 clone.Name = (string)name.Clone(); 84 clone.States = new List<ProtocolState>(states.Count); 85 foreach (ProtocolState state in states) 86 clone.States.Add((ProtocolState)state.Clone(clonedObjects)); 96 87 // iterate through the states and select the appropriate state in the clone 97 for (int i = 0 ; i < states.Count ; i++) 98 if (states[i].Equals(initialState)) 99 clone.InitialState = clone.States[i]; 88 int index = states.IndexOf(initialState); 89 if (index >= 0) clone.InitialState = clone.States[index]; 100 90 return clone; 101 91 } 102 92 103 #region States Events104 void States_ItemRemoved(object sender, ItemIndexEventArgs e) {105 e.Item.Changed -= new EventHandler(State_Changed);106 State_Changed(this, new EventArgs());107 }108 109 void States_ItemAdded(object sender, ItemIndexEventArgs e) {110 e.Item.Changed += new EventHandler(State_Changed);111 ((ProtocolState)e.Item).Protocol = this;112 State_Changed(this, new EventArgs());113 }114 #endregion115 116 public EventHandler StatesChanged;117 void State_Changed(object sender, EventArgs e) {118 if (StatesChanged != null) StatesChanged(sender, e);119 }120 121 #region persistence122 93 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) { 123 94 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 124 XmlNode nameNode = PersistenceManager.Persist("Name", Name, document, persistedObjects); 125 XmlNode statesNode = PersistenceManager.Persist("States", States, document, persistedObjects); 126 XmlNode initialStatesNode = PersistenceManager.Persist("InitialState", InitialState, document, persistedObjects); 127 node.AppendChild(nameNode); 95 96 XmlAttribute nameAttrib = document.CreateAttribute("Name"); 97 nameAttrib.Value = this.name; 98 node.Attributes.Append(nameAttrib); 99 100 XmlNode statesNode = document.CreateNode(XmlNodeType.Element, "States", null); 101 foreach (ProtocolState state in states) { 102 XmlNode tmp = state.GetXmlNode("State", document, persistedObjects); 103 if (state.Equals(initialState)) { 104 XmlAttribute initialStateAttrib = document.CreateAttribute("InitialState"); 105 initialStateAttrib.Value = "1"; 106 tmp.Attributes.Append(initialStateAttrib); 107 } 108 statesNode.AppendChild(tmp); 109 } 128 110 node.AppendChild(statesNode); 129 node.AppendChild(initialStatesNode); 111 130 112 return node; 131 113 } … … 133 115 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) { 134 116 base.Populate(node, restoredObjects); 135 name = (StringData)PersistenceManager.Restore(node.SelectSingleNode("Name"), restoredObjects); 136 states = (ItemList<ProtocolState>)PersistenceManager.Restore(node.SelectSingleNode("States"), restoredObjects); 137 states.ItemAdded += new EventHandler<ItemIndexEventArgs>(States_ItemAdded); 138 states.ItemRemoved += new EventHandler<ItemIndexEventArgs>(States_ItemRemoved); 139 initialState = (ProtocolState)PersistenceManager.Restore(node.SelectSingleNode("InitialState"), restoredObjects); 117 name = node.Attributes.GetNamedItem("Name").Value; 118 119 XmlNode statesNode = node.SelectSingleNode("States"); 120 states = new List<ProtocolState>(statesNode.ChildNodes.Count); 121 foreach (XmlNode childNode in statesNode.ChildNodes) { 122 ProtocolState tmp = new ProtocolState(); 123 tmp.Populate(childNode, restoredObjects); 124 states.Add(tmp); 125 XmlNode initialStateNode = childNode.Attributes.GetNamedItem("InitialState"); 126 if (initialStateNode != null && initialStateNode.Value.Equals("1")) initialState = tmp; 127 } 140 128 } 141 #endregion persistence129 #endregion clone & persistence 142 130 } 143 131 } -
trunk/sources/HeuristicLab.Communication.Data/ProtocolEditor.Designer.cs
r591 r704 36 36 } 37 37 if (Protocol != null) Protocol.Changed -= new System.EventHandler(Protocol_Changed); 38 nameViewControl.Dispose();39 statesItemListView.Dispose();40 38 base.Dispose(disposing); 41 39 } … … 48 46 /// </summary> 49 47 private void InitializeComponent() { 50 HeuristicLab.Data.StringData stringData2 = new HeuristicLab.Data.StringData();51 this.nameViewControl = new HeuristicLab.Data.StringDataView();52 48 this.protocolNameLabel = new System.Windows.Forms.Label(); 53 this.initialStateLabel = new System.Windows.Forms.Label();54 this.initialStateComboBox = new System.Windows.Forms.ComboBox();55 49 this.protocolStatesLabel = new System.Windows.Forms.Label(); 56 this.statesItemListView = new HeuristicLab.Data.ItemListView<ProtocolState>(); 57 this.invertButton = new System.Windows.Forms.Button(); 50 this.statesListBox = new System.Windows.Forms.ListBox(); 51 this.stateChartPictureBox = new System.Windows.Forms.PictureBox(); 52 this.addStateButton = new System.Windows.Forms.Button(); 53 this.removeStateButton = new System.Windows.Forms.Button(); 54 this.nameTextBox = new System.Windows.Forms.TextBox(); 55 this.setAsInitialStateButton = new System.Windows.Forms.Button(); 56 ((System.ComponentModel.ISupportInitialize)(this.stateChartPictureBox)).BeginInit(); 58 57 this.SuspendLayout(); 59 //60 // nameViewControl61 //62 this.nameViewControl.Caption = "View (StringData)";63 this.nameViewControl.Location = new System.Drawing.Point(89, 3);64 this.nameViewControl.Name = "nameViewControl";65 this.nameViewControl.Size = new System.Drawing.Size(180, 28);66 stringData2.Data = "";67 this.nameViewControl.StringData = stringData2;68 this.nameViewControl.TabIndex = 1;69 58 // 70 59 // protocolNameLabel … … 77 66 this.protocolNameLabel.Text = "Protocol Name:"; 78 67 // 79 // initialStateLabel80 //81 this.initialStateLabel.AutoSize = true;82 this.initialStateLabel.Location = new System.Drawing.Point(275, 6);83 this.initialStateLabel.Name = "initialStateLabel";84 this.initialStateLabel.Size = new System.Drawing.Size(62, 13);85 this.initialStateLabel.TabIndex = 5;86 this.initialStateLabel.Text = "Initial State:";87 //88 // initialStateComboBox89 //90 this.initialStateComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;91 this.initialStateComboBox.FormattingEnabled = true;92 this.initialStateComboBox.Location = new System.Drawing.Point(343, 3);93 this.initialStateComboBox.Name = "initialStateComboBox";94 this.initialStateComboBox.Size = new System.Drawing.Size(166, 21);95 this.initialStateComboBox.TabIndex = 6;96 this.initialStateComboBox.SelectedIndexChanged += new System.EventHandler(this.initialStateComboBox_SelectedIndexChanged);97 //98 68 // protocolStatesLabel 99 69 // … … 105 75 this.protocolStatesLabel.Text = "Protocol States:"; 106 76 // 107 // states ItemListView77 // statesListBox 108 78 // 109 this.statesItemListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 79 this.statesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 80 | System.Windows.Forms.AnchorStyles.Left))); 81 this.statesListBox.FormattingEnabled = true; 82 this.statesListBox.Location = new System.Drawing.Point(6, 48); 83 this.statesListBox.MultiColumn = true; 84 this.statesListBox.Name = "statesListBox"; 85 this.statesListBox.Size = new System.Drawing.Size(159, 303); 86 this.statesListBox.TabIndex = 10; 87 this.statesListBox.SelectedIndexChanged += new System.EventHandler(this.statesListBox_SelectedIndexChanged); 88 this.statesListBox.DoubleClick += new System.EventHandler(this.statesListBox_DoubleClick); 89 // 90 // stateChartPictureBox 91 // 92 this.stateChartPictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 110 93 | System.Windows.Forms.AnchorStyles.Left) 111 94 | System.Windows.Forms.AnchorStyles.Right))); 112 this.state sItemListView.Caption = "View";113 this.state sItemListView.ItemList = null;114 this.state sItemListView.Location = new System.Drawing.Point(3, 51);115 this.state sItemListView.Name = "statesItemListView";116 this.state sItemListView.Size = new System.Drawing.Size(613, 308);117 this.state sItemListView.TabIndex = 7;95 this.stateChartPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 96 this.stateChartPictureBox.Location = new System.Drawing.Point(172, 48); 97 this.stateChartPictureBox.Name = "stateChartPictureBox"; 98 this.stateChartPictureBox.Size = new System.Drawing.Size(444, 303); 99 this.stateChartPictureBox.TabIndex = 11; 100 this.stateChartPictureBox.TabStop = false; 118 101 // 119 // invertButton102 // addStateButton 120 103 // 121 this.invertButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 122 this.invertButton.Location = new System.Drawing.Point(3, 363); 123 this.invertButton.Name = "invertButton"; 124 this.invertButton.Size = new System.Drawing.Size(162, 23); 125 this.invertButton.TabIndex = 9; 126 this.invertButton.Text = "Invert Send/Receive"; 127 this.invertButton.UseVisualStyleBackColor = true; 128 this.invertButton.Click += new System.EventHandler(this.invertButton_Click); 104 this.addStateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 105 this.addStateButton.Location = new System.Drawing.Point(6, 357); 106 this.addStateButton.Name = "addStateButton"; 107 this.addStateButton.Size = new System.Drawing.Size(77, 23); 108 this.addStateButton.TabIndex = 12; 109 this.addStateButton.Text = "Add"; 110 this.addStateButton.UseVisualStyleBackColor = true; 111 this.addStateButton.Click += new System.EventHandler(this.addStateButton_Click); 112 // 113 // removeStateButton 114 // 115 this.removeStateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 116 this.removeStateButton.Location = new System.Drawing.Point(89, 357); 117 this.removeStateButton.Name = "removeStateButton"; 118 this.removeStateButton.Size = new System.Drawing.Size(75, 23); 119 this.removeStateButton.TabIndex = 13; 120 this.removeStateButton.Text = "Remove"; 121 this.removeStateButton.UseVisualStyleBackColor = true; 122 this.removeStateButton.Click += new System.EventHandler(this.removeStateButton_Click); 123 // 124 // nameTextBox 125 // 126 this.nameTextBox.Location = new System.Drawing.Point(89, 3); 127 this.nameTextBox.Name = "nameTextBox"; 128 this.nameTextBox.Size = new System.Drawing.Size(142, 20); 129 this.nameTextBox.TabIndex = 14; 130 // 131 // setAsInitialStateButton 132 // 133 this.setAsInitialStateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 134 this.setAsInitialStateButton.Location = new System.Drawing.Point(170, 357); 135 this.setAsInitialStateButton.Name = "setAsInitialStateButton"; 136 this.setAsInitialStateButton.Size = new System.Drawing.Size(75, 23); 137 this.setAsInitialStateButton.TabIndex = 15; 138 this.setAsInitialStateButton.Text = "Set Initital"; 139 this.setAsInitialStateButton.UseVisualStyleBackColor = true; 140 this.setAsInitialStateButton.Click += new System.EventHandler(this.setAsInitialStateButton_Click); 129 141 // 130 142 // ProtocolEditor … … 132 144 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 133 145 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 134 this.Controls.Add(this.invertButton); 146 this.Controls.Add(this.setAsInitialStateButton); 147 this.Controls.Add(this.nameTextBox); 148 this.Controls.Add(this.removeStateButton); 149 this.Controls.Add(this.addStateButton); 150 this.Controls.Add(this.stateChartPictureBox); 151 this.Controls.Add(this.statesListBox); 135 152 this.Controls.Add(this.protocolStatesLabel); 136 this.Controls.Add(this.statesItemListView);137 this.Controls.Add(this.initialStateComboBox);138 this.Controls.Add(this.initialStateLabel);139 153 this.Controls.Add(this.protocolNameLabel); 140 this.Controls.Add(this.nameViewControl);141 154 this.Name = "ProtocolEditor"; 142 155 this.Size = new System.Drawing.Size(619, 389); 156 ((System.ComponentModel.ISupportInitialize)(this.stateChartPictureBox)).EndInit(); 143 157 this.ResumeLayout(false); 144 158 this.PerformLayout(); … … 148 162 #endregion 149 163 150 private HeuristicLab.Data.StringDataView nameViewControl;151 164 private System.Windows.Forms.Label protocolNameLabel; 152 private System.Windows.Forms.Label initialStateLabel;153 private System.Windows.Forms.ComboBox initialStateComboBox;154 165 private System.Windows.Forms.Label protocolStatesLabel; 155 private HeuristicLab.Data.ItemListView<ProtocolState> statesItemListView; 156 private System.Windows.Forms.Button invertButton; 166 private System.Windows.Forms.ListBox statesListBox; 167 private System.Windows.Forms.PictureBox stateChartPictureBox; 168 private System.Windows.Forms.Button addStateButton; 169 private System.Windows.Forms.Button removeStateButton; 170 private System.Windows.Forms.TextBox nameTextBox; 171 private System.Windows.Forms.Button setAsInitialStateButton; 157 172 } 158 173 } -
trunk/sources/HeuristicLab.Communication.Data/ProtocolEditor.cs
r591 r704 39 39 public ProtocolEditor() { 40 40 InitializeComponent(); 41 statesListBox.DrawMode = DrawMode.OwnerDrawFixed; 42 statesListBox.DrawItem += new DrawItemEventHandler(statesListBox_DrawItem); 41 43 } 44 45 void statesListBox_DrawItem(object sender, DrawItemEventArgs e) { 46 if (e.Index >= 0) { // during Items.Clear() this method is called with index -1 47 ListBox lb = (ListBox)sender; 48 ProtocolState state = (ProtocolState)lb.Items[e.Index]; 49 e.DrawBackground(); 50 e.DrawFocusRectangle(); 51 SolidBrush textColor = new SolidBrush(Color.Black); 52 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) textColor.Color = Color.White; 53 if (Protocol.InitialState.Equals(state)) 54 e.Graphics.DrawString(state.Name, new Font(e.Font.FontFamily, e.Font.Size, FontStyle.Bold), textColor, e.Bounds); 55 else 56 e.Graphics.DrawString(state.Name, e.Font, textColor, e.Bounds); 57 } 58 } 59 42 60 public ProtocolEditor(Protocol protocol) 43 61 : this() { … … 46 64 47 65 protected override void RemoveItemEvents() { 66 nameTextBox.DataBindings.Clear(); 48 67 Protocol.Changed -= new EventHandler(Protocol_Changed); 49 Protocol.StatesChanged -= new EventHandler(States_Changed);50 Protocol.Name.Changed -= new EventHandler(ProtocolName_Changed);51 68 base.RemoveItemEvents(); 52 69 } … … 54 71 base.AddItemEvents(); 55 72 Protocol.Changed += new EventHandler(Protocol_Changed); 56 Protocol.StatesChanged += new EventHandler(States_Changed); 57 Protocol.Name.Changed += new EventHandler(ProtocolName_Changed); 58 } 59 60 private void BuildInitialStateComboBox() { 61 // Rebuild the two ComboBoxes depicting the initial and final state 62 IList<ProtocolState> states = new List<ProtocolState>(Protocol.States.Count); 63 int initialSelectedIndex = -1; 64 for (int i = 0 ; i < Protocol.States.Count ; i++) { 65 states.Add((ProtocolState)Protocol.States[i]); 66 if (Protocol.States[i].Guid.Equals(Protocol.InitialState.Guid)) 67 initialSelectedIndex = i; 68 } 69 initialStateComboBox.SelectedIndexChanged -= new EventHandler(initialStateComboBox_SelectedIndexChanged); 70 BindingList<ProtocolState> bl = new BindingList<ProtocolState>(states); 71 initialStateComboBox.DataSource = bl; 72 initialStateComboBox.DisplayMember = "Name"; 73 initialStateComboBox.ValueMember = "Guid"; 74 initialStateComboBox.SelectedIndex = initialSelectedIndex; 75 initialStateComboBox.SelectedIndexChanged += new EventHandler(initialStateComboBox_SelectedIndexChanged); 73 nameTextBox.DataBindings.Add("Text", Protocol, "Name"); 76 74 } 77 75 … … 80 78 if (Protocol == null) { 81 79 Caption = "Protocol"; 82 nameViewControl.Enabled = false; 83 nameViewControl.StringData = null; 84 statesItemListView.Enabled = false; 85 statesItemListView.ItemList = null; 86 initialStateComboBox.Enabled = false; 87 initialStateComboBox.DataSource = null; 88 initialStateComboBox.Items.Clear(); 80 nameTextBox.Enabled = false; 81 setAsInitialStateButton.Enabled = false; 82 addStateButton.Enabled = false; 83 removeStateButton.Enabled = false; 84 statesListBox.Enabled = false; 85 86 nameTextBox.Text = ""; 87 statesListBox.Items.Clear(); 89 88 } else { 90 Caption = Protocol.Name.Data; 91 nameViewControl.StringData = Protocol.Name; 92 nameViewControl.Enabled = true; 93 statesItemListView.ItemList = Protocol.States; 94 statesItemListView.Enabled = true; 95 BuildInitialStateComboBox(); 96 initialStateComboBox.Enabled = true; 89 Caption = Protocol.Name; 90 91 statesListBox.Items.Clear(); 92 foreach (ProtocolState state in Protocol.States) 93 statesListBox.Items.Add(state); 94 95 statesListBox.Enabled = true; 96 addStateButton.Enabled = true; 97 removeStateButton.Enabled = true; 98 setAsInitialStateButton.Enabled = true; 99 nameTextBox.Enabled = true; 97 100 } 98 101 } 99 102 100 #region Custom events101 103 void Protocol_Changed(object sender, EventArgs e) { 102 104 Refresh(); 103 105 } 104 106 105 void States_Changed(object sender, EventArgs e) { 107 private void addStateButton_Click(object sender, EventArgs e) { 108 ProtocolState tmp = new ProtocolState(); 109 int index = statesListBox.SelectedIndex; 110 if (index < 0) { 111 Protocol.States.Add(tmp); 112 } else { 113 Protocol.States.Insert(index, tmp); 114 } 106 115 Refresh(); 116 statesListBox.SelectedIndex = index; 107 117 } 108 118 109 void ProtocolName_Changed(object sender, EventArgs e) { 110 Caption = Protocol.Name.Data; 119 private void removeStateButton_Click(object sender, EventArgs e) { 120 if (statesListBox.SelectedIndex >= 0) { 121 int index = statesListBox.SelectedIndex; 122 Protocol.States.RemoveAt(statesListBox.SelectedIndex); 123 Refresh(); 124 if (Protocol.States.Count > 0) 125 statesListBox.SelectedIndex = ((index < Protocol.States.Count) ? (index) : (Protocol.States.Count - 1)); 126 } 111 127 } 112 #endregion113 128 114 #region ComboBox events 115 private void initialStateComboBox_SelectedIndexChanged(object sender, EventArgs e) { 116 if (initialStateComboBox.SelectedIndex >= 0) 117 Protocol.InitialState = (ProtocolState)initialStateComboBox.SelectedItem; 129 private void setAsInitialStateButton_Click(object sender, EventArgs e) { 130 if (statesListBox.SelectedIndex >= 0) { 131 Protocol.InitialState = (ProtocolState)statesListBox.SelectedItem; 132 statesListBox.Refresh(); 133 } 118 134 } 119 #endregion120 135 121 private void invertButton_Click(object sender, EventArgs e) { 122 for (int i = 0 ; i < Protocol.States.Count ; i++) { 123 ConstrainedItemList tmp = ((ProtocolState)Protocol.States[i]).SendingData; 124 ((ProtocolState)Protocol.States[i]).SendingData = ((ProtocolState)Protocol.States[i]).ReceivingData; 125 ((ProtocolState)Protocol.States[i]).ReceivingData = tmp; 136 private void statesListBox_DoubleClick(object sender, EventArgs e) { 137 if (lastDeselectedIndex >= 0 || lastSelectedIndex >= 0) { 138 statesListBox.SelectedIndex = (lastDeselectedIndex >= 0) ? (lastDeselectedIndex) : (lastSelectedIndex); 139 ProtocolState selected = (ProtocolState)statesListBox.Items[(lastDeselectedIndex >= 0) ? (lastDeselectedIndex) : (lastSelectedIndex)]; 140 bool editingInitial = (Protocol.InitialState == selected); 141 ProtocolState selectedClone = (ProtocolState)selected.Clone(new Dictionary<Guid, object>()); 142 IView stateView = selectedClone.CreateView(); 143 using (WindowedView display = new WindowedView(stateView as UserControl)) { 144 display.ShowDialog(this); 145 if (display.DialogResult == DialogResult.OK) { 146 Protocol.States[(lastDeselectedIndex >= 0) ? (lastDeselectedIndex) : (lastSelectedIndex)] = selectedClone; 147 if (editingInitial) Protocol.InitialState = selectedClone; 148 Refresh(); 149 } 150 } 126 151 } 127 Refresh(); 152 } 153 154 private int lastSelectedIndex = -1; 155 private int lastDeselectedIndex = -1; 156 157 private void statesListBox_SelectedIndexChanged(object sender, EventArgs e) { 158 if (statesListBox.SelectedIndex >= 0) { 159 if (lastSelectedIndex == statesListBox.SelectedIndex) { 160 lastDeselectedIndex = statesListBox.SelectedIndex; 161 statesListBox.SelectedIndex = -1; 162 lastSelectedIndex = -1; 163 } else { 164 lastSelectedIndex = statesListBox.SelectedIndex; 165 lastDeselectedIndex = -1; 166 } 167 } 128 168 } 129 169 } -
trunk/sources/HeuristicLab.Communication.Data/ProtocolState.cs
r591 r704 30 30 namespace HeuristicLab.Communication.Data { 31 31 public class ProtocolState : ItemBase { 32 private StringDataname;33 public StringDataName {32 private string name; 33 public string Name { 34 34 get { return name; } 35 35 set { 36 name.Changed -= new EventHandler(Name_Changed);37 36 name = value; 38 name.Changed += new EventHandler(Name_Changed);39 37 OnChanged(); 40 38 } 41 39 } 42 private BoolData acceptingState;43 public BoolData AcceptingState{44 get { return acceptingState; }40 private bool giveBatch; 41 public bool GiveBatch { 42 get { return giveBatch; } 45 43 set { 46 acceptingState= value;44 giveBatch = value; 47 45 OnChanged(); 48 46 } 49 47 } 50 private ConstrainedItemList sendingData;51 public ConstrainedItemList SendingData{52 get { return sendingData; }48 private ItemList<IVariable> give; 49 public ItemList<IVariable> Give { 50 get { return give; } 53 51 set { 54 sendingData= value;52 give = value; 55 53 OnChanged(); 56 54 } 57 55 } 58 private ConstrainedItemList receivingData;59 public ConstrainedItemList ReceivingData{60 get { return receivingData; }56 private bool expectBatch; 57 public bool ExpectBatch { 58 get { return expectBatch; } 61 59 set { 62 receivingData= value;60 expectBatch = value; 63 61 OnChanged(); 64 62 } 65 63 } 66 private ItemList< StateTransition> stateTransitions;67 public ItemList< StateTransition> StateTransitions{68 get { return stateTransitions; }64 private ItemList<IVariable> expect; 65 public ItemList<IVariable> Expect { 66 get { return expect; } 69 67 set { 70 stateTransitions = value; 71 OnChanged(); 72 } 73 } 74 private Protocol protocol; 75 public Protocol Protocol { 76 get { return protocol; } 77 set { 78 protocol = value; 68 expect = value; 79 69 OnChanged(); 80 70 } … … 82 72 83 73 public ProtocolState() { 84 name = new StringData("Unnamed state"); 85 name.Changed += new EventHandler(Name_Changed); 86 acceptingState = new BoolData(true); 87 sendingData = new ConstrainedItemList(); 88 sendingData.AddConstraint(new ItemTypeConstraint(typeof(Variable))); 89 receivingData = new ConstrainedItemList(); 90 receivingData.AddConstraint(new ItemTypeConstraint(typeof(Variable))); 91 stateTransitions = null; 92 protocol = null; 93 } 94 95 public void Dispose() { 96 name.Changed -= new EventHandler(Name_Changed); 74 name = Guid.NewGuid().ToString(); 75 giveBatch = false; 76 expectBatch = false; 77 give = new ItemList<IVariable>(); 78 expect = new ItemList<IVariable>(); 97 79 } 98 80 … … 101 83 } 102 84 85 #region clone & persistence 103 86 public override object Clone(IDictionary<Guid, object> clonedObjects) { 104 87 ProtocolState clone = new ProtocolState(); 105 88 clonedObjects.Add(Guid, clone); 106 clone.name = (StringData)Auxiliary.Clone(Name, clonedObjects); 107 clone.acceptingState = (BoolData)Auxiliary.Clone(AcceptingState, clonedObjects); 108 clone.sendingData = (ConstrainedItemList)Auxiliary.Clone(SendingData, clonedObjects); 109 clone.receivingData = (ConstrainedItemList)Auxiliary.Clone(ReceivingData, clonedObjects); 110 if (StateTransitions != null) 111 clone.stateTransitions = (ItemList<StateTransition>)Auxiliary.Clone(StateTransitions, clonedObjects); 112 else clone.StateTransitions = null; 113 clone.protocol = Protocol; 89 90 clone.name = (string)name.Clone(); 91 clone.giveBatch = giveBatch; 92 clone.expectBatch = expectBatch; 93 94 clone.give = new ItemList<IVariable>(); 95 for (int i = 0; i < give.Count; i++) 96 clone.give.Add((IVariable)give[i].Clone()); 97 98 clone.expect = new ItemList<IVariable>(); 99 for (int i = 0; i < expect.Count; i++) 100 clone.expect.Add((IVariable)expect[i].Clone()); 101 114 102 return clone; 115 103 } 116 104 117 #region persistence105 // use a simpler serialization for the protocol to make reading it in other programming languages easier 118 106 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) { 119 107 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 120 XmlNode protocolNode = PersistenceManager.Persist("ParentProtocol", Protocol, document, persistedObjects); 121 node.AppendChild(protocolNode); 122 XmlNode nameNode = PersistenceManager.Persist("Name", Name, document, persistedObjects); 123 node.AppendChild(nameNode); 124 XmlNode acceptingNode = PersistenceManager.Persist("AcceptingState", AcceptingState, document, persistedObjects); 125 node.AppendChild(acceptingNode); 126 XmlNode requestNode = PersistenceManager.Persist("Request", SendingData, document, persistedObjects); 127 node.AppendChild(requestNode); 128 XmlNode responseNode = PersistenceManager.Persist("Response", ReceivingData, document, persistedObjects); 129 node.AppendChild(responseNode); 130 if (StateTransitions != null) { 131 XmlNode transitionsNode = PersistenceManager.Persist("StateTransitions", StateTransitions, document, persistedObjects); 132 node.AppendChild(transitionsNode); 108 XmlAttribute nameAttrib = document.CreateAttribute("Name"); 109 nameAttrib.Value = this.name; 110 node.Attributes.Append(nameAttrib); 111 XmlAttribute giveBatchAttrib = document.CreateAttribute("GiveBatch"); 112 giveBatchAttrib.Value = giveBatch.ToString(); 113 node.Attributes.Append(giveBatchAttrib); 114 XmlAttribute expectBatchAttrib = document.CreateAttribute("ExpectBatch"); 115 expectBatchAttrib.Value = expectBatch.ToString(); 116 node.Attributes.Append(expectBatchAttrib); 117 118 XmlNode giveNode = document.CreateNode(XmlNodeType.Element, "Give", null); 119 foreach (IVariable param in give) { 120 XmlNode tmp = document.CreateNode(XmlNodeType.Element, "Parameter", null); 121 XmlAttribute paramNameAttrib = document.CreateAttribute("Name"); 122 paramNameAttrib.Value = param.Name; 123 tmp.Attributes.Append(paramNameAttrib); 124 XmlAttribute valueTypeAttrib = document.CreateAttribute("Type"); 125 Type type = param.Value.GetType(); 126 valueTypeAttrib.Value = type.FullName + ", " + type.Assembly.FullName.Substring(0, type.Assembly.FullName.IndexOf(",")); 127 tmp.Attributes.Append(valueTypeAttrib); 128 giveNode.AppendChild(tmp); 133 129 } 130 node.AppendChild(giveNode); 131 132 XmlNode expectNode = document.CreateNode(XmlNodeType.Element, "Expect", null); 133 foreach (IVariable param in expect) { 134 XmlNode tmp = document.CreateNode(XmlNodeType.Element, "Parameter", null); 135 XmlAttribute paramNameAttrib = document.CreateAttribute("Name"); 136 paramNameAttrib.Value = param.Name; 137 tmp.Attributes.Append(paramNameAttrib); 138 XmlAttribute valueTypeAttrib = document.CreateAttribute("Type"); 139 Type type = param.Value.GetType(); 140 valueTypeAttrib.Value = type.FullName + ", " + type.Assembly.FullName.Substring(0, type.Assembly.FullName.IndexOf(",")); 141 tmp.Attributes.Append(valueTypeAttrib); 142 expectNode.AppendChild(tmp); 143 } 144 node.AppendChild(expectNode); 134 145 return node; 135 146 } 136 147 148 // use a simpler serialization for the protocol to make reading it in other programming languages easier 137 149 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) { 138 150 base.Populate(node, restoredObjects); 139 protocol = (Protocol)PersistenceManager.Restore(node.SelectSingleNode("ParentProtocol"), restoredObjects); 140 name = (StringData)PersistenceManager.Restore(node.SelectSingleNode("Name"), restoredObjects); 141 acceptingState = (BoolData)PersistenceManager.Restore(node.SelectSingleNode("AcceptingState"), restoredObjects); 142 sendingData = (ConstrainedItemList)PersistenceManager.Restore(node.SelectSingleNode("Request"), restoredObjects); 143 receivingData = (ConstrainedItemList)PersistenceManager.Restore(node.SelectSingleNode("Response"), restoredObjects); 144 XmlNode transitions = node.SelectSingleNode("StateTransitions"); 145 if (transitions != null) 146 stateTransitions = (ItemList<StateTransition>)PersistenceManager.Restore(transitions, restoredObjects); 147 else 148 stateTransitions = null; 151 name = node.Attributes.GetNamedItem("Name").Value; 152 bool.TryParse(node.Attributes.GetNamedItem("GiveBatch").Value, out giveBatch); 153 bool.TryParse(node.Attributes.GetNamedItem("ExpectBatch").Value, out expectBatch); 154 155 give = new ItemList<IVariable>(); 156 XmlNodeList giveParams = node.SelectSingleNode("Give").SelectNodes("Parameter"); 157 foreach (XmlNode param in giveParams) { 158 IItem tmp = (IItem)Activator.CreateInstance(System.Type.GetType(param.Attributes.GetNamedItem("Type").Value)); 159 IVariable var = new Variable(param.Attributes.GetNamedItem("Name").Value, tmp); 160 give.Add(var); 161 } 162 163 expect = new ItemList<IVariable>(); 164 XmlNodeList expectParams = node.SelectSingleNode("Expect").SelectNodes("Parameter"); 165 foreach (XmlNode param in expectParams) { 166 IItem tmp = (IItem)Activator.CreateInstance(System.Type.GetType(param.Attributes.GetNamedItem("Type").Value)); 167 IVariable var = new Variable(param.Attributes.GetNamedItem("Name").Value, tmp); 168 expect.Add(var); 169 } 149 170 } 150 #endregion persistence 151 152 private void Name_Changed(object sender, EventArgs e) { 153 OnChanged(); 154 } 171 #endregion clone & persistence 155 172 156 173 public override string ToString() { 157 return Name.ToString();174 return name.ToString(); 158 175 } 159 176 } -
trunk/sources/HeuristicLab.Communication.Data/ProtocolStateView.Designer.cs
r591 r704 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 HeuristicLab.Data.StringData stringData1 = new HeuristicLab.Data.StringData();48 HeuristicLab.Data.BoolData boolData1 = new HeuristicLab.Data.BoolData();49 this.nameStringDataView = new HeuristicLab.Data.StringDataView();50 47 this.nameLabel = new System.Windows.Forms.Label(); 51 48 this.communicationDataTabControl = new System.Windows.Forms.TabControl(); 52 this.sendTabPage = new System.Windows.Forms.TabPage(); 53 this.outboundCommunicationDataView = new HeuristicLab.Data.ConstrainedItemListView(); 54 this.receiveTabPage = new System.Windows.Forms.TabPage(); 55 this.inboundCommunicationDataView = new HeuristicLab.Data.ConstrainedItemListView(); 56 this.transitionTabPage = new System.Windows.Forms.TabPage(); 57 this.removeTransitionButton = new System.Windows.Forms.Button(); 58 this.addTransitionButton = new System.Windows.Forms.Button(); 59 this.stateTransitionTabControl = new System.Windows.Forms.TabControl(); 60 this.acceptingStateLabel = new System.Windows.Forms.Label(); 61 this.acceptingStateBoolDataView = new HeuristicLab.Data.BoolDataView(); 49 this.giveTabPage = new System.Windows.Forms.TabPage(); 50 this.giveBatchCheckBox = new System.Windows.Forms.CheckBox(); 51 this.giveVariablesLabel = new System.Windows.Forms.Label(); 52 this.giveBatchLabel = new System.Windows.Forms.Label(); 53 this.expectTabPage = new System.Windows.Forms.TabPage(); 54 this.expectVariablesLabel = new System.Windows.Forms.Label(); 55 this.expectBatchCheckBox = new System.Windows.Forms.CheckBox(); 56 this.expectBatchLabel = new System.Windows.Forms.Label(); 57 this.nameTextBox = new System.Windows.Forms.TextBox(); 58 this.giveItemListView = new HeuristicLab.Data.ItemListView<HeuristicLab.Core.IVariable>(); 59 this.expectItemListView = new HeuristicLab.Data.ItemListView<HeuristicLab.Core.IVariable>(); 62 60 this.communicationDataTabControl.SuspendLayout(); 63 this.sendTabPage.SuspendLayout(); 64 this.receiveTabPage.SuspendLayout(); 65 this.transitionTabPage.SuspendLayout(); 61 this.giveTabPage.SuspendLayout(); 62 this.expectTabPage.SuspendLayout(); 66 63 this.SuspendLayout(); 67 //68 // nameStringDataView69 //70 this.nameStringDataView.Caption = "View (StringData)";71 this.nameStringDataView.Location = new System.Drawing.Point(48, 14);72 this.nameStringDataView.Name = "nameStringDataView";73 this.nameStringDataView.Size = new System.Drawing.Size(178, 26);74 stringData1.Data = "";75 this.nameStringDataView.StringData = stringData1;76 this.nameStringDataView.TabIndex = 1;77 64 // 78 65 // nameLabel … … 90 77 | System.Windows.Forms.AnchorStyles.Left) 91 78 | System.Windows.Forms.AnchorStyles.Right))); 92 this.communicationDataTabControl.Controls.Add(this.sendTabPage); 93 this.communicationDataTabControl.Controls.Add(this.receiveTabPage); 94 this.communicationDataTabControl.Controls.Add(this.transitionTabPage); 79 this.communicationDataTabControl.Controls.Add(this.giveTabPage); 80 this.communicationDataTabControl.Controls.Add(this.expectTabPage); 95 81 this.communicationDataTabControl.Location = new System.Drawing.Point(3, 46); 96 82 this.communicationDataTabControl.Name = "communicationDataTabControl"; 97 83 this.communicationDataTabControl.SelectedIndex = 0; 98 this.communicationDataTabControl.Size = new System.Drawing.Size(4 83, 381);84 this.communicationDataTabControl.Size = new System.Drawing.Size(404, 324); 99 85 this.communicationDataTabControl.TabIndex = 5; 100 86 // 101 // sendTabPage 102 // 103 this.sendTabPage.Controls.Add(this.outboundCommunicationDataView); 104 this.sendTabPage.Location = new System.Drawing.Point(4, 22); 105 this.sendTabPage.Name = "sendTabPage"; 106 this.sendTabPage.Padding = new System.Windows.Forms.Padding(3); 107 this.sendTabPage.Size = new System.Drawing.Size(475, 355); 108 this.sendTabPage.TabIndex = 0; 109 this.sendTabPage.Text = "Send"; 110 this.sendTabPage.UseVisualStyleBackColor = true; 111 // 112 // outboundCommunicationDataView 113 // 114 this.outboundCommunicationDataView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 87 // giveTabPage 88 // 89 this.giveTabPage.Controls.Add(this.giveItemListView); 90 this.giveTabPage.Controls.Add(this.giveBatchCheckBox); 91 this.giveTabPage.Controls.Add(this.giveVariablesLabel); 92 this.giveTabPage.Controls.Add(this.giveBatchLabel); 93 this.giveTabPage.Location = new System.Drawing.Point(4, 22); 94 this.giveTabPage.Name = "giveTabPage"; 95 this.giveTabPage.Padding = new System.Windows.Forms.Padding(3); 96 this.giveTabPage.Size = new System.Drawing.Size(396, 298); 97 this.giveTabPage.TabIndex = 0; 98 this.giveTabPage.Text = "Give"; 99 this.giveTabPage.UseVisualStyleBackColor = true; 100 // 101 // giveBatchCheckBox 102 // 103 this.giveBatchCheckBox.AutoSize = true; 104 this.giveBatchCheckBox.Location = new System.Drawing.Point(58, 20); 105 this.giveBatchCheckBox.Name = "giveBatchCheckBox"; 106 this.giveBatchCheckBox.Size = new System.Drawing.Size(15, 14); 107 this.giveBatchCheckBox.TabIndex = 9; 108 this.giveBatchCheckBox.UseVisualStyleBackColor = true; 109 // 110 // giveVariablesLabel 111 // 112 this.giveVariablesLabel.AutoSize = true; 113 this.giveVariablesLabel.Location = new System.Drawing.Point(13, 48); 114 this.giveVariablesLabel.Name = "giveVariablesLabel"; 115 this.giveVariablesLabel.Size = new System.Drawing.Size(53, 13); 116 this.giveVariablesLabel.TabIndex = 8; 117 this.giveVariablesLabel.Text = "Variables:"; 118 // 119 // giveBatchLabel 120 // 121 this.giveBatchLabel.AutoSize = true; 122 this.giveBatchLabel.Location = new System.Drawing.Point(13, 20); 123 this.giveBatchLabel.Name = "giveBatchLabel"; 124 this.giveBatchLabel.Size = new System.Drawing.Size(38, 13); 125 this.giveBatchLabel.TabIndex = 6; 126 this.giveBatchLabel.Text = "Batch:"; 127 // 128 // expectTabPage 129 // 130 this.expectTabPage.Controls.Add(this.expectItemListView); 131 this.expectTabPage.Controls.Add(this.expectVariablesLabel); 132 this.expectTabPage.Controls.Add(this.expectBatchCheckBox); 133 this.expectTabPage.Controls.Add(this.expectBatchLabel); 134 this.expectTabPage.Location = new System.Drawing.Point(4, 22); 135 this.expectTabPage.Name = "expectTabPage"; 136 this.expectTabPage.Padding = new System.Windows.Forms.Padding(3); 137 this.expectTabPage.Size = new System.Drawing.Size(396, 298); 138 this.expectTabPage.TabIndex = 1; 139 this.expectTabPage.Text = "Expect"; 140 this.expectTabPage.UseVisualStyleBackColor = true; 141 // 142 // expectVariablesLabel 143 // 144 this.expectVariablesLabel.AutoSize = true; 145 this.expectVariablesLabel.Location = new System.Drawing.Point(13, 48); 146 this.expectVariablesLabel.Name = "expectVariablesLabel"; 147 this.expectVariablesLabel.Size = new System.Drawing.Size(53, 13); 148 this.expectVariablesLabel.TabIndex = 12; 149 this.expectVariablesLabel.Text = "Variables:"; 150 // 151 // expectBatchCheckBox 152 // 153 this.expectBatchCheckBox.AutoSize = true; 154 this.expectBatchCheckBox.Location = new System.Drawing.Point(58, 20); 155 this.expectBatchCheckBox.Name = "expectBatchCheckBox"; 156 this.expectBatchCheckBox.Size = new System.Drawing.Size(15, 14); 157 this.expectBatchCheckBox.TabIndex = 10; 158 this.expectBatchCheckBox.UseVisualStyleBackColor = true; 159 // 160 // expectBatchLabel 161 // 162 this.expectBatchLabel.AutoSize = true; 163 this.expectBatchLabel.Location = new System.Drawing.Point(13, 20); 164 this.expectBatchLabel.Name = "expectBatchLabel"; 165 this.expectBatchLabel.Size = new System.Drawing.Size(38, 13); 166 this.expectBatchLabel.TabIndex = 6; 167 this.expectBatchLabel.Text = "Batch:"; 168 // 169 // nameTextBox 170 // 171 this.nameTextBox.Location = new System.Drawing.Point(48, 14); 172 this.nameTextBox.Name = "nameTextBox"; 173 this.nameTextBox.Size = new System.Drawing.Size(137, 20); 174 this.nameTextBox.TabIndex = 6; 175 // 176 // giveItemListView 177 // 178 this.giveItemListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 115 179 | System.Windows.Forms.AnchorStyles.Left) 116 180 | System.Windows.Forms.AnchorStyles.Right))); 117 this.outboundCommunicationDataView.Caption = "View"; 118 this.outboundCommunicationDataView.ConstrainedItemList = null; 119 this.outboundCommunicationDataView.Location = new System.Drawing.Point(6, 6); 120 this.outboundCommunicationDataView.Name = "outboundCommunicationDataView"; 121 this.outboundCommunicationDataView.Size = new System.Drawing.Size(463, 343); 122 this.outboundCommunicationDataView.TabIndex = 0; 123 // 124 // receiveTabPage 125 // 126 this.receiveTabPage.Controls.Add(this.inboundCommunicationDataView); 127 this.receiveTabPage.Location = new System.Drawing.Point(4, 22); 128 this.receiveTabPage.Name = "receiveTabPage"; 129 this.receiveTabPage.Padding = new System.Windows.Forms.Padding(3); 130 this.receiveTabPage.Size = new System.Drawing.Size(475, 355); 131 this.receiveTabPage.TabIndex = 1; 132 this.receiveTabPage.Text = "Receive"; 133 this.receiveTabPage.UseVisualStyleBackColor = true; 134 // 135 // inboundCommunicationDataView 136 // 137 this.inboundCommunicationDataView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 181 this.giveItemListView.Caption = "View"; 182 this.giveItemListView.ItemList = null; 183 this.giveItemListView.Location = new System.Drawing.Point(16, 64); 184 this.giveItemListView.Name = "giveItemListView"; 185 this.giveItemListView.Size = new System.Drawing.Size(377, 231); 186 this.giveItemListView.TabIndex = 10; 187 // 188 // expectItemListView 189 // 190 this.expectItemListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 138 191 | System.Windows.Forms.AnchorStyles.Left) 139 192 | System.Windows.Forms.AnchorStyles.Right))); 140 this.inboundCommunicationDataView.Caption = "View"; 141 this.inboundCommunicationDataView.ConstrainedItemList = null; 142 this.inboundCommunicationDataView.Location = new System.Drawing.Point(6, 6); 143 this.inboundCommunicationDataView.Name = "inboundCommunicationDataView"; 144 this.inboundCommunicationDataView.Size = new System.Drawing.Size(463, 343); 145 this.inboundCommunicationDataView.TabIndex = 0; 146 // 147 // transitionTabPage 148 // 149 this.transitionTabPage.Controls.Add(this.removeTransitionButton); 150 this.transitionTabPage.Controls.Add(this.addTransitionButton); 151 this.transitionTabPage.Controls.Add(this.stateTransitionTabControl); 152 this.transitionTabPage.Location = new System.Drawing.Point(4, 22); 153 this.transitionTabPage.Name = "transitionTabPage"; 154 this.transitionTabPage.Padding = new System.Windows.Forms.Padding(3); 155 this.transitionTabPage.Size = new System.Drawing.Size(475, 355); 156 this.transitionTabPage.TabIndex = 2; 157 this.transitionTabPage.Text = "State Transition"; 158 this.transitionTabPage.UseVisualStyleBackColor = true; 159 // 160 // removeTransitionButton 161 // 162 this.removeTransitionButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 163 this.removeTransitionButton.Enabled = false; 164 this.removeTransitionButton.Location = new System.Drawing.Point(365, 326); 165 this.removeTransitionButton.Name = "removeTransitionButton"; 166 this.removeTransitionButton.Size = new System.Drawing.Size(104, 23); 167 this.removeTransitionButton.TabIndex = 2; 168 this.removeTransitionButton.Text = "Remove Transition"; 169 this.removeTransitionButton.UseVisualStyleBackColor = true; 170 this.removeTransitionButton.Click += new System.EventHandler(this.removeTransitionButton_Click); 171 // 172 // addTransitionButton 173 // 174 this.addTransitionButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 175 this.addTransitionButton.Location = new System.Drawing.Point(6, 326); 176 this.addTransitionButton.Name = "addTransitionButton"; 177 this.addTransitionButton.Size = new System.Drawing.Size(104, 23); 178 this.addTransitionButton.TabIndex = 1; 179 this.addTransitionButton.Text = "Add Transition"; 180 this.addTransitionButton.UseVisualStyleBackColor = true; 181 this.addTransitionButton.Click += new System.EventHandler(this.addTransitionButton_Click); 182 // 183 // stateTransitionTabControl 184 // 185 this.stateTransitionTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 186 | System.Windows.Forms.AnchorStyles.Left) 187 | System.Windows.Forms.AnchorStyles.Right))); 188 this.stateTransitionTabControl.Location = new System.Drawing.Point(0, 0); 189 this.stateTransitionTabControl.Name = "stateTransitionTabControl"; 190 this.stateTransitionTabControl.SelectedIndex = 0; 191 this.stateTransitionTabControl.Size = new System.Drawing.Size(475, 320); 192 this.stateTransitionTabControl.TabIndex = 0; 193 // 194 // acceptingStateLabel 195 // 196 this.acceptingStateLabel.AutoSize = true; 197 this.acceptingStateLabel.Location = new System.Drawing.Point(232, 17); 198 this.acceptingStateLabel.Name = "acceptingStateLabel"; 199 this.acceptingStateLabel.Size = new System.Drawing.Size(86, 13); 200 this.acceptingStateLabel.TabIndex = 6; 201 this.acceptingStateLabel.Text = "Accepting State:"; 202 // 203 // acceptingStateBoolDataView 204 // 205 boolData1.Data = true; 206 this.acceptingStateBoolDataView.BoolData = boolData1; 207 this.acceptingStateBoolDataView.Caption = "View"; 208 this.acceptingStateBoolDataView.Enabled = false; 209 this.acceptingStateBoolDataView.Location = new System.Drawing.Point(324, 17); 210 this.acceptingStateBoolDataView.Name = "acceptingStateBoolDataView"; 211 this.acceptingStateBoolDataView.Size = new System.Drawing.Size(15, 23); 212 this.acceptingStateBoolDataView.TabIndex = 7; 193 this.expectItemListView.Caption = "View"; 194 this.expectItemListView.ItemList = null; 195 this.expectItemListView.Location = new System.Drawing.Point(16, 64); 196 this.expectItemListView.Name = "expectItemListView"; 197 this.expectItemListView.Size = new System.Drawing.Size(377, 231); 198 this.expectItemListView.TabIndex = 13; 213 199 // 214 200 // ProtocolStateView … … 216 202 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 217 203 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 218 this.Controls.Add(this.acceptingStateBoolDataView); 219 this.Controls.Add(this.acceptingStateLabel); 204 this.Controls.Add(this.nameTextBox); 220 205 this.Controls.Add(this.communicationDataTabControl); 221 206 this.Controls.Add(this.nameLabel); 222 this.Controls.Add(this.nameStringDataView);223 207 this.Name = "ProtocolStateView"; 224 this.Size = new System.Drawing.Size(4 89, 430);208 this.Size = new System.Drawing.Size(410, 373); 225 209 this.communicationDataTabControl.ResumeLayout(false); 226 this.sendTabPage.ResumeLayout(false); 227 this.receiveTabPage.ResumeLayout(false); 228 this.transitionTabPage.ResumeLayout(false); 210 this.giveTabPage.ResumeLayout(false); 211 this.giveTabPage.PerformLayout(); 212 this.expectTabPage.ResumeLayout(false); 213 this.expectTabPage.PerformLayout(); 229 214 this.ResumeLayout(false); 230 215 this.PerformLayout(); … … 234 219 #endregion 235 220 236 private HeuristicLab.Data.StringDataView nameStringDataView;237 221 private System.Windows.Forms.Label nameLabel; 238 222 private System.Windows.Forms.TabControl communicationDataTabControl; 239 private System.Windows.Forms.TabPage sendTabPage; 240 private System.Windows.Forms.TabPage receiveTabPage; 241 private HeuristicLab.Data.ConstrainedItemListView outboundCommunicationDataView; 242 private HeuristicLab.Data.ConstrainedItemListView inboundCommunicationDataView; 243 private System.Windows.Forms.Label acceptingStateLabel; 244 private HeuristicLab.Data.BoolDataView acceptingStateBoolDataView; 245 private System.Windows.Forms.TabPage transitionTabPage; 246 private System.Windows.Forms.TabControl stateTransitionTabControl; 247 private System.Windows.Forms.Button addTransitionButton; 248 private System.Windows.Forms.Button removeTransitionButton; 223 private System.Windows.Forms.TabPage giveTabPage; 224 private System.Windows.Forms.TabPage expectTabPage; 225 private System.Windows.Forms.Label giveBatchLabel; 226 private System.Windows.Forms.Label expectBatchLabel; 227 private System.Windows.Forms.CheckBox giveBatchCheckBox; 228 private System.Windows.Forms.Label giveVariablesLabel; 229 private System.Windows.Forms.Label expectVariablesLabel; 230 private System.Windows.Forms.CheckBox expectBatchCheckBox; 231 private System.Windows.Forms.TextBox nameTextBox; 232 private HeuristicLab.Data.ItemListView<HeuristicLab.Core.IVariable> giveItemListView; 233 private HeuristicLab.Data.ItemListView<HeuristicLab.Core.IVariable> expectItemListView; 249 234 250 235 } -
trunk/sources/HeuristicLab.Communication.Data/ProtocolStateView.cs
r591 r704 46 46 47 47 protected override void RemoveItemEvents() { 48 nameTextBox.DataBindings.Clear(); 49 giveBatchCheckBox.DataBindings.Clear(); 50 expectBatchCheckBox.DataBindings.Clear(); 48 51 ProtocolState.Changed -= new EventHandler(ProtocolState_Changed); 49 ProtocolState.Protocol.StatesChanged -= new EventHandler(States_Changed);50 if (ProtocolState.StateTransitions != null) {51 for (int i = 0 ; i < ProtocolState.StateTransitions.Count ; i++) {52 ProtocolState.StateTransitions[i].Changed -= new EventHandler(StateTransitions_Changed);53 }54 }55 52 base.RemoveItemEvents(); 56 53 } … … 58 55 base.AddItemEvents(); 59 56 ProtocolState.Changed += new EventHandler(ProtocolState_Changed); 60 ProtocolState.Protocol.StatesChanged += new EventHandler(States_Changed); 61 if (ProtocolState.StateTransitions != null) { 62 for (int i = 0 ; i < ProtocolState.StateTransitions.Count ; i++) { 63 ProtocolState.StateTransitions[i].Changed += new EventHandler(StateTransitions_Changed); 64 } 65 } 57 expectBatchCheckBox.DataBindings.Add("Checked", ProtocolState, "ExpectBatch"); 58 giveBatchCheckBox.DataBindings.Add("Checked", ProtocolState, "GiveBatch"); 59 nameTextBox.DataBindings.Add("Text", ProtocolState, "Name"); 66 60 } 67 61 … … 69 63 base.UpdateControls(); 70 64 if (ProtocolState == null) { 71 nameStringDataView.Enabled = false; 72 nameStringDataView.StringData = null; 73 acceptingStateBoolDataView.Enabled = false; 74 acceptingStateBoolDataView.BoolData = null; 75 outboundCommunicationDataView.Enabled = false; 76 outboundCommunicationDataView.ConstrainedItemList = null; 77 inboundCommunicationDataView.Enabled = false; 78 inboundCommunicationDataView.ConstrainedItemList = null; 79 stateTransitionTabControl.Controls.Clear(); 65 nameTextBox.Enabled = false; 66 communicationDataTabControl.Enabled = false; 67 giveItemListView.ItemList = null; 68 expectItemListView.ItemList = null; 80 69 } else { 81 nameStringDataView.StringData = ProtocolState.Name; 82 nameStringDataView.Enabled = true; 83 acceptingStateBoolDataView.Enabled = true; 84 acceptingStateBoolDataView.BoolData = ProtocolState.AcceptingState; 85 outboundCommunicationDataView.ConstrainedItemList = ProtocolState.SendingData; 86 outboundCommunicationDataView.Enabled = true; 87 inboundCommunicationDataView.ConstrainedItemList = ProtocolState.ReceivingData; 88 inboundCommunicationDataView.Enabled = true; 70 nameTextBox.Text = ProtocolState.Name; 71 giveBatchCheckBox.Checked = ProtocolState.GiveBatch; 72 expectBatchCheckBox.Checked = ProtocolState.ExpectBatch; 89 73 90 addTransitionButton.Enabled = (ProtocolState.Protocol.States.Count > 1);91 removeTransitionButton.Enabled = (ProtocolState.StateTransitions != null && ProtocolState.StateTransitions.Count > 0);74 giveItemListView.ItemList = ProtocolState.Give; 75 expectItemListView.ItemList = ProtocolState.Expect; 92 76 93 stateTransitionTabControl.Controls.Clear(); 94 ItemList<StateTransition> stateTransitions = ProtocolState.StateTransitions; 95 if (stateTransitions != null) { 96 for (int i = 0 ; i < stateTransitions.Count ; i++) { 97 StateTransition stateTransition = (StateTransition)stateTransitions[i]; 98 TabPage newTransitionTabPage = new TabPage((stateTransition.TargetState == null) ? ("no target") : (stateTransition.TargetState.Name.ToString())); 99 Control stateTransitionView = (Control)stateTransition.CreateView(); 100 stateTransitionTabControl.Controls.Add(newTransitionTabPage); 101 102 newTransitionTabPage.Controls.Add(stateTransitionView); 103 newTransitionTabPage.Location = new Point(4, 22); 104 newTransitionTabPage.Padding = new Padding(3); 105 newTransitionTabPage.Size = stateTransitionTabControl.ClientSize; 106 newTransitionTabPage.UseVisualStyleBackColor = true; 107 108 stateTransitionView.Location = new Point(0, 0); 109 stateTransitionView.Size = newTransitionTabPage.ClientSize; 110 stateTransitionView.Dock = DockStyle.Fill; 111 stateTransitionView.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right); 112 } 113 } 77 communicationDataTabControl.Enabled = true; 78 nameTextBox.Enabled = true; 114 79 } 115 80 } … … 121 86 #endregion 122 87 123 #region Protocol.States change handling (parent object)124 void States_Changed(object sender, EventArgs e) {125 for (int i = 0 ; i < stateTransitionTabControl.TabCount ; i++)126 stateTransitionTabControl.TabPages[i].Controls[0].Refresh();127 addTransitionButton.Enabled = (ProtocolState.Protocol.States.Count > 1);128 }129 #endregion130 131 #region StateTransitions change handling (child object)132 void StateTransitions_Changed(object sender, EventArgs e) {133 for (int i = 0 ; i < stateTransitionTabControl.TabCount ; i++) {134 if (((StateTransition)ProtocolState.StateTransitions[i]).TargetState != null)135 stateTransitionTabControl.TabPages[i].Text = ((StateTransition)ProtocolState.StateTransitions[i]).TargetState.Name.ToString();136 }137 }138 #endregion139 140 #region Button events141 private void addTransitionButton_Click(object sender, EventArgs e) {142 //ProtocolState.AcceptingState = new BoolData(false);143 StateTransition stateTransition = new StateTransition();144 stateTransition.Changed += new EventHandler(StateTransitions_Changed);145 stateTransition.SourceState = ProtocolState;146 147 if (ProtocolState.StateTransitions == null) {148 ItemList<StateTransition> temp = new ItemList<StateTransition>();149 temp.Add(stateTransition);150 ProtocolState.StateTransitions = temp;151 } else {152 ProtocolState.StateTransitions.Add(stateTransition);153 Refresh();154 }155 removeTransitionButton.Enabled = true;156 }157 158 private void removeTransitionButton_Click(object sender, EventArgs e) {159 if (stateTransitionTabControl.TabCount > 0) {160 int selIdx = stateTransitionTabControl.SelectedIndex;161 ProtocolState.StateTransitions[selIdx].Changed -= new EventHandler(StateTransitions_Changed);162 stateTransitionTabControl.Controls.RemoveAt(selIdx);163 ProtocolState.StateTransitions.RemoveAt(selIdx);164 if (ProtocolState.StateTransitions.Count == 0) {165 //ProtocolState.AcceptingState = new BoolData(true);166 ProtocolState.StateTransitions = null;167 removeTransitionButton.Enabled = false;168 }169 }170 }171 #endregion172 88 } 173 89 } -
trunk/sources/HeuristicLab.Communication.Data/SocketData.cs
r591 r704 112 112 113 113 public void Close() { 114 tcpOut.Client.Close(); 115 tcpOut.Close(); 116 tcpOut = null; 117 while (tcpIn.Connected) ; 118 tcpIn.Client.Close(); 119 tcpIn.Close(); 120 tcpIn = null; 114 121 tcpListener.Stop(); 115 if ((tcpOut != null && tcpOut.Connected) && (tcpIn != null && tcpIn.Connected)) {116 Write("CLOSING");117 if (Read() != null)118 throw new InvalidOperationException("ERROR in SocketData: Out of sync during Close()");119 }120 if (tcpIn != null) {121 tcpIn.Close();122 tcpIn = null;123 }124 if (tcpOut != null) {125 tcpOut.Close();126 tcpOut = null;127 }128 122 buffer = ""; 129 123 } -
trunk/sources/HeuristicLab.Communication.Data/StateTransitionView.cs
r591 r704 49 49 protected override void RemoveItemEvents() { 50 50 StateTransition.Changed -= new EventHandler(StateTransition_Changed); 51 ConstrainedItemList request = StateTransition.SourceState.SendingData;52 ConstrainedItemList response = StateTransition.SourceState.ReceivingData;53 54 request.Changed -= new EventHandler(VariablesList_Changed);55 request.ItemAdded -= new EventHandler<ItemIndexEventArgs>(Parameter_Added);56 request.ItemRemoved -= new EventHandler<ItemIndexEventArgs>(Parameter_Removed);57 for (int i = 0 ; i < request.Count ; i++)58 request[i].Changed -= new EventHandler(Parameter_Changed);59 response.Changed -= new EventHandler(VariablesList_Changed);60 response.ItemAdded -= new EventHandler<ItemIndexEventArgs>(Parameter_Added);61 response.ItemRemoved -= new EventHandler<ItemIndexEventArgs>(Parameter_Removed);62 for (int i = 0 ; i < response.Count ; i++)63 response[i].Changed -= new EventHandler(Parameter_Changed);64 51 base.RemoveItemEvents(); 65 52 } … … 67 54 base.AddItemEvents(); 68 55 StateTransition.Changed += new EventHandler(StateTransition_Changed); 69 ConstrainedItemList request = StateTransition.SourceState.SendingData;70 ConstrainedItemList response = StateTransition.SourceState.ReceivingData;71 72 request.Changed += new EventHandler(VariablesList_Changed);73 request.ItemAdded += new EventHandler<ItemIndexEventArgs>(Parameter_Added);74 request.ItemRemoved += new EventHandler<ItemIndexEventArgs>(Parameter_Removed);75 for (int i = 0 ; i < request.Count ; i++)76 request[i].Changed += new EventHandler(Parameter_Changed);77 response.Changed += new EventHandler(VariablesList_Changed);78 response.ItemAdded += new EventHandler<ItemIndexEventArgs>(Parameter_Added);79 response.ItemRemoved += new EventHandler<ItemIndexEventArgs>(Parameter_Removed);80 for (int i = 0 ; i < response.Count ; i++) {81 response[i].Changed += new EventHandler(Parameter_Changed);82 }83 56 } 84 57 … … 121 94 private void BuildTargetStateComboBox() { 122 95 ComboBox comboBox = targetStateComboBox; 123 ItemList<ProtocolState> states ;124 if (StateTransition.SourceState == null || StateTransition.SourceState.Protocol == null)96 ItemList<ProtocolState> states = null; 97 /*if (StateTransition.SourceState == null || StateTransition.SourceState.Protocol == null) 125 98 states = null; 126 99 else 127 states = StateTransition.SourceState.Protocol.States; 100 states = StateTransition.SourceState.Protocol.States;*/ 128 101 ProtocolState selected = StateTransition.TargetState; 129 102 ProtocolState forbidden = StateTransition.SourceState; … … 152 125 private void BuildVariablesListBox() { 153 126 ListBox variables = variablesListBox; 154 ConstrainedItemList request = StateTransition.SourceState.SendingData;155 ConstrainedItemList response = StateTransition.SourceState.ReceivingData; 127 /*ConstrainedItemList request = StateTransition.SourceState.SendingData; 128 ConstrainedItemList response = StateTransition.SourceState.ReceivingData;*/ 156 129 variables.Items.Clear(); 157 130 variables.Items.Add("==Sending=="); 158 for (int i = 0 ; i < request.Count ; i++) {131 /*for (int i = 0 ; i < request.Count ; i++) { 159 132 variables.Items.Add(request[i]); 160 } 133 }*/ 161 134 variables.Items.Add("==Receiving=="); 162 for (int i = 0 ; i < response.Count ; i++) {135 /*for (int i = 0 ; i < response.Count ; i++) { 163 136 variables.Items.Add(response[i]); 164 } 137 }*/ 165 138 } 166 139 -
trunk/sources/HeuristicLab.Communication.Operators/DataStreamCommunicator.cs
r591 r704 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Text; 26 using System.Xml; 25 27 using HeuristicLab.Core; 26 28 using HeuristicLab.Data; … … 28 30 29 31 namespace HeuristicLab.Communication.Operators { 30 public class DataStreamCommunicator : OperatorBase {32 public class DataStreamCommunicator : CommunicatorBase { 31 33 public override string Description { 32 34 get { 33 return @" TODO";35 return @"Sends a message if present and otherwise listens for incoming messages"; 34 36 } 35 37 } 36 38 37 39 public DataStreamCommunicator() { 38 AddVariableInfo(new VariableInfo("CurrentState", "", typeof(ProtocolState), VariableKind.In));39 40 AddVariableInfo(new VariableInfo("DataStream", "", typeof(IDataStream), VariableKind.In)); 40 AddVariableInfo(new VariableInfo("Message", "", typeof(StringData), VariableKind.New | VariableKind.Deleted));41 41 } 42 42 43 public override IOperation Apply(IScope scope) { 44 ProtocolState currentState = GetVariableValue<ProtocolState>("CurrentState", scope, true); 45 IDataStream connection = GetVariableValue<IDataStream>("DataStream", scope, true); 46 IVariableInfo info = GetVariableInfo("Message"); 47 string actualName = ""; 48 if (!info.Local) 49 actualName = scope.TranslateName(info.FormalName); 43 private string Encode(Message message) { 44 XmlDocument document = new XmlDocument(); 45 return message.GetXmlNode("Message", document, new Dictionary<Guid, IStorable>()).ToString(); 46 } 50 47 51 if (currentState.SendingData.Count > 0) { 52 string toSend = GetVariableValue<StringData>(info.FormalName, scope, false).Data; 53 connection.Write(toSend); 54 if (info.Local) RemoveVariable(info.ActualName); 55 else scope.RemoveVariable(actualName); 48 private Message Decode(string m) { 49 XmlDocument document = new XmlDocument(); 50 document.LoadXml(m); 51 Message message = new Message(); 52 message.Populate(document.SelectSingleNode("Message"), new Dictionary<Guid, IStorable>()); 53 return message; 54 } 55 56 protected override void Send(IScope scope, Protocol protocol, ProtocolState currentState, Message message) { 57 IDataStream connection = scope.GetVariableValue<IDataStream>("DataStream", true); 58 connection.Write("PROTOCOL_ID " + protocol.Name); 59 if (connection.Read().Equals("ACK")) { 60 connection.Write("STATE_ID " + currentState.Name); 61 if (connection.Read().Equals("ACK")) { 62 connection.Write(Encode(message)); 63 } 56 64 } 65 } 57 66 58 if (currentState.ReceivingData.Count > 0) { 59 string received = connection.Read(); 60 if (info.Local) AddVariable(new Variable(info.ActualName, new StringData(received))); 61 else scope.AddVariable(new Variable(actualName, new StringData(received))); 67 protected override Message Receive(IScope scope, Protocol protocol, ProtocolState currentState) { 68 IDataStream connection = scope.GetVariableValue<IDataStream>("DataStream", true); 69 Message message = new Message(); 70 string rcvd = connection.Read(); 71 if (rcvd.StartsWith("PROTOCOL_ID ")) { 72 if (rcvd.Substring(12).Equals(protocol.Name)) { 73 connection.Write("ACK"); 74 rcvd = connection.Read(); 75 if (rcvd.StartsWith("STATE_ID ")) { 76 if (rcvd.Substring(9).Equals(currentState.Name)) { 77 connection.Write("ACK"); 78 message = Decode(connection.Read()); 79 return message; 80 } else { 81 connection.Write("SYNCERROR STATE_ID"); 82 return null; 83 } 84 } else { 85 connection.Write("ERROR"); 86 return null; 87 } 88 } else { 89 connection.Write("SYNCERROR PROTOCOL_ID"); 90 return null; 91 } 92 } else { 93 connection.Write("ERROR"); 94 return null; 62 95 } 63 return null;64 96 } 65 97 } -
trunk/sources/HeuristicLab.Communication.Operators/DataStreamFinisher.cs
r591 r704 42 42 IDataStream datastream = GetVariableValue<IDataStream>("DataStream", scope, true); 43 43 44 datastream.Write("REQUEST_CLOSE"); 45 string response = datastream.Read(); 46 if (!response.Equals("REQUEST_CLOSE")) throw new InvalidOperationException("ERROR in DataStreamFinisher: Closing connection was denied"); 47 datastream.Write("ACK"); 48 response = datastream.Read(); 49 if (!response.Equals("ACK")) throw new InvalidOperationException("ERROR in DataStreamFinisher: Closing connection was denied"); 44 50 datastream.Close(); 45 51 -
trunk/sources/HeuristicLab.Communication.Operators/HeuristicLab.Communication.Operators.csproj
r584 r704 44 44 --> 45 45 <ItemGroup> 46 <Compile Include="CurrentStateConstraintChecker.cs" /> 47 <Compile Include="CurrentStateInitializer.cs" /> 48 <Compile Include="CurrentStateVariableInjector.cs" /> 46 <Compile Include="CommunicatorBase.cs" /> 47 <Compile Include="CurrentStateInitializer.cs"> 48 <SubType>Code</SubType> 49 </Compile> 49 50 <Compile Include="DataStreamCommunicator.cs" /> 50 51 <Compile Include="DataStreamFinisher.cs" /> 51 52 <Compile Include="HeuristicLabCommunicationOperatorsPlugin.cs" /> 52 53 <Compile Include="LocalProcessInitiator.cs" /> 54 <Compile Include="MessageInjector.cs" /> 55 <Compile Include="MessageProcessor.cs" /> 53 56 <Compile Include="Properties\AssemblyInfo.cs" /> 54 57 <Compile Include="ProtocolInjector.cs" /> … … 59 62 <DependentUpon>ProtocolInjectorView.cs</DependentUpon> 60 63 </Compile> 61 <Compile Include="SimpleReceiveItemDeserializer.cs" />62 <Compile Include="SimpleSendItemSerializer.cs" />63 64 <Compile Include="StateTransistor.cs" /> 64 <Compile Include="Sub scopeCurrentStateLooseDataCollector.cs" />65 <Compile Include="Sub scopeCurrentStateLooseDataDistributor.cs" />65 <Compile Include="SubScopeMessageComposer.cs" /> 66 <Compile Include="SubScopeMessageDecomposer.cs" /> 66 67 <Compile Include="TcpNetworkInitiator.cs" /> 67 <Compile Include="XMLConstrainedItemListDeserializer.cs" />68 <Compile Include="XMLConstrainedItemListSerializer.cs" />69 68 </ItemGroup> 70 69 <ItemGroup> -
trunk/sources/HeuristicLab.Communication.Operators/StateTransistor.cs
r591 r704 44 44 45 45 public override IOperation Apply(IScope scope) { 46 ProtocolState currentState = GetVariableValue<ProtocolState>("CurrentState", scope, true);46 /*ProtocolState currentState = GetVariableValue<ProtocolState>("CurrentState", scope, true); 47 47 // Terminate as soon as an accepting state is reached 48 48 if (currentState.AcceptingState.Data) return null; … … 111 111 112 112 sp.AddSubOperator(nextTransistor); 113 return new AtomicOperation(sp, scope); 113 return new AtomicOperation(sp, scope);*/ 114 return null; 114 115 } 115 116 }
Note: See TracChangeset
for help on using the changeset viewer.