public void KillLinkReq(int kill1, int kill2) { //zabijamy linka //var kill1 = Convert.ToInt32(msg[0]); //var kill2 = Convert.ToInt32(msg[1]) for (int i1 = 0; i1 < this.Topo.AlgNetwork.edges.Count; i1++) { } ; //NewLog($"EDGE PRZED {this.Topo.AlgNetwork.edges.Count}", myWindow); //NewLog($"R{kill1} R{kill2} start", myWindow); try { for (int i1 = 0; i1 < this.Topo.AlgNetwork.edges.Count; i1++) { if (this.Topo.AlgNetwork.edges[i1].NodeFirst == kill1 && this.Topo.AlgNetwork.edges[i1].NodeSecond == kill2) { Killed = this.Topo.AlgNetwork.edges[i1]; //NewLog($"R{this.Topo.AlgNetwork.edges[i1].NodeFirst} R{this.Topo.AlgNetwork.edges[i1].NodeSecond} SUCCEED", myWindow); this.Topo.AlgNetwork.edges.RemoveAt(i1); } if (this.Topo.AlgNetwork.edges[i1].NodeSecond == kill1 && this.Topo.AlgNetwork.edges[i1].NodeFirst == kill2) { Killed = this.Topo.AlgNetwork.edges[i1]; //NewLog($"R{this.Topo.AlgNetwork.edges[i1].NodeFirst} R{this.Topo.AlgNetwork.edges[i1].NodeSecond} SUCCEED", myWindow); this.Topo.AlgNetwork.edges.RemoveAt(i1); } } NewLog($"Destroyed link between node {kill1} and node {kill2}", myWindow); string tmpmsg = MessageNames.KILL_LINK_CC + " " + kill1 + " " + kill2; SendMessage(IPCC, tmpmsg); for (int i1 = 0; i1 < this.Topo.AlgNetwork.edges.Count; i1++) { // NewLog($"PO R{this.Topo.AlgNetwork.edges[i1].NodeFirst} R{this.Topo.AlgNetwork.edges[i1].NodeSecond} START", myWindow); } ; this.Topo.AlgNetwork.counte = this.Topo.AlgNetwork.counte - 1; //NewLog($"EDGE po {this.Topo.AlgNetwork.edges.Count}", myWindow); } catch (Exception) { NewLog($"Killink R{kill1} R{kill2} failed", myWindow); } }
public void GetLink(string path) { XmlReader xmlReader = new XmlReader(path); int numberoflinks = xmlReader.GetNumberOfItems("connect"); this.Topo.AlgNetwork.counte = numberoflinks; for (int a = 0; a < numberoflinks; a++) { var node_name1 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect", "NODE1")); var node_name2 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect", "NODE2")); var path_id = Int32.Parse(xmlReader.GetAttributeValue(a, "connect", "PATH_ID")); var distance = Double.Parse(xmlReader.GetAttributeValue(a, "connect", "DROGA")); var port1 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect", "PORTIN")); var port2 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect", "PORTOUT")); AlgNode no = this.Topo.AlgNetwork.nodes.Find(x => x.IdNode == node_name1); AlgNode nd = this.Topo.AlgNetwork.nodes.Find(x => x.IdNode == node_name2); AlgLink algLink = new AlgLink(path_id, no, nd, distance); this.Topo.AlgNetwork.edges.Add(algLink); } int numberofconnectr = xmlReader.GetNumberOfItems("connect_r"); for (int a = 0; a < numberofconnectr; a++) { var node_name1 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect_r", "NODE1")); var node_name2 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect_r", "NODE2")); var port1 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect_r", "PORTIN")); var port2 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect_r", "PORTOUT")); //SNPLinkNode.Add(node_name1 + ":" + node_name2, port1 + ":" + port2); //SNPLinkNode.Add(node_name2 + ":" + node_name1, port2 + ":" + port1); SNPLinkNode.Add(node_name1 + ":" + port1 + ":" + node_name2 + ":" + port2); SNPLinkNode.Add(node_name2 + ":" + port2 + ":" + node_name1 + ":" + port1); } }