public static void ChangeRingNode(RingNodes CurrentRN, bool isExpanding) { //First we find a new node (Expand or Collapse we start with expand) //Change this node with the other and change the clockwise and anticlockwise //Determine poisition of nodes //Sensor oldRingNode = CurrentRN.Node; Sensor newRingNode = FindNewRingNodeReplacement(CurrentRN); Sensor clock = CurrentRN.ClockWiseNeighbor; Sensor anti = CurrentRN.AntiClockWiseNeighbor; if (newRingNode != null) { //me,anti,clock RingNodes newNo = new RingNodes(newRingNode, CurrentRN.AntiClockWiseNeighbor, CurrentRN.ClockWiseNeighbor); newNo.AnchorNode = CurrentRN.AnchorNode; newRingNode.RingNodesRule = newNo; ReplaceTwoNodes(CurrentRN, newNo); ClearOldRingNodeData(CurrentRN, newNo); AddRemoveArrows(CurrentRN, newNo); markNeighboringRingNods(); RingNodesFunctions r = new RingNodesFunctions(); r.DeterminePositionofAllNodes(); Console.WriteLine("Change {0} to {1}", CurrentRN.Node.ID, newRingNode.ID); } else { Console.WriteLine("Failed to change node {0}", CurrentRN.Node.ID); //Failed } }
public static void doLastCheck() { RingNodesFunctions r = new RingNodesFunctions(); r.lastCheck(); populateRingNodes(); markNeighboringRingNods(); r.DeterminePositionofAllNodes(); }
public void ChangeRingNode(RingNodes CurrentRN) { MainCounter++; //First we find a new node (Expand or Collapse we start with expand) //Change this node with the other and change the clockwise and anticlockwise //Determine poisition of nodes //Sensor oldRingNode = CurrentRN.Node; myNewRingNodes.Clear(); Sensor newRingNode = FindNewRingNodeReplacement(CurrentRN); Sensor clock = CurrentRN.ClockWiseNeighbor; Sensor anti = CurrentRN.AntiClockWiseNeighbor; if (newRingNode != null) { if (PublicParameters.IsExanding) { double distance = Operations.DistanceBetweenTwoPoints(newRingNode.CenterLocation, PublicParameters.networkCenter); if (distance >= (PublicParameters.clusterRadius * 1.6)) { PublicParameters.IsExanding = false; } } else { double distance = Operations.DistanceBetweenTwoPoints(newRingNode.CenterLocation, PublicParameters.networkCenter); if (distance <= (PublicParameters.clusterRadius)) { PublicParameters.IsExanding = true; } } //me,anti,clock //Now i have myNewRingNodes loop through there and fix everything RingNodes newNo = new RingNodes(newRingNode, CurrentRN.AntiClockWiseNeighbor, CurrentRN.ClockWiseNeighbor); myNewRingNodes.Add(newRingNode); CheckNewRingNode(newNo); ReplaceTwoNodes(CurrentRN, myNewRingNodes); foreach (Sensor newRN in myNewRingNodes) { if (newRN.RingNodesRule.AntiClockWiseNeighbor.ID == newRN.RingNodesRule.ClockWiseNeighbor.ID) { Console.WriteLine("Error in Change RingNode"); } newRN.RingNodesRule.AnchorNode = CurrentRN.AnchorNode; } // RingNodes newNo = new RingNodes(newRingNode, CurrentRN.AntiClockWiseNeighbor, CurrentRN.ClockWiseNeighbor); // newNo.AnchorNode = CurrentRN.AnchorNode; // newRingNode.RingNodesRule = newNo; // ReplaceTwoNodes(CurrentRN, newNo); if (!myNewRingNodes.Contains(CurrentRN.Node)) { ClearOldRingNodeData(CurrentRN); } //AddRemoveArrows(CurrentRN, newNo); RingNodesFunctions r = new RingNodesFunctions(); //markNeighboringRingNods(); blah(); r.DeterminePositionofAllNodes(); // Console.WriteLine("Change {0} to {1}",CurrentRN.Node.ID,newRingNode.ID); } else { Console.WriteLine("Failed to change node {0}", CurrentRN.Node.ID); //Failed } }