Beispiel #1
0
        public static CellGroup getClusterWithID(int findID)
        {
            CellGroup getCluster = new CellGroup();


            foreach (CellGroup findCluster in PublicParameters.networkCells)
            {
                if (findCluster.getID() == findID)
                {
                    // Console.WriteLine("Searching in {0}", findCluster.getID());
                    getCluster = findCluster;
                    //  Console.WriteLine("Returning");
                    return(findCluster);
                }
            }
            //   Console.WriteLine("Returned");
            // if (!foundCluster)
            //{
            //     throw new System.ArgumentException("Cluster not found", "original");
            //  }
            //  else
            // {
            return(getCluster);
            // }
        }
Beispiel #2
0
        public CellGroup getMaxSensors()
        {
            List <int> sensorsCount = new List <int>();

            foreach (CellGroup tempClus in changePosClus)
            {
                sensorsCount.Add(tempClus.clusterNodes.Count());
            }
            int maxCount = 0;

            foreach (int i in sensorsCount)
            {
                if (maxCount < i)
                {
                    maxCount = i;
                }
            }
            CellGroup foundMax = new CellGroup();

            foreach (CellGroup tempClus in changePosClus)
            {
                if (tempClus.clusterNodes.Count == maxCount)
                {
                    foundMax = tempClus;
                }
            }
            changePosClus.Clear();
            return(foundMax);
        }
Beispiel #3
0
        //Assign cluster IDs here

        private void addIdsToSensorA(CellGroup cluster)
        {
            foreach (Sensor sensor in cluster.getClusterNodes())
            {
                sensor.inCell = cluster.getID();
                //Console.WriteLine("Sensor {0} is in {1}", sensor.ID, cluster.getID());
            }
        }
Beispiel #4
0
 private void buildFromPointZero(Point startFrom, double count)
 {
     for (int i = 0; i < count; i++)
     {
         string    cellID   = "" + verticalCount + "" + horizCount;
         CellGroup cluster0 = new CellGroup(startFrom, cellID);
         cluster0.findNearestSensor(true);
         if (cluster0.isNotEmpty())
         {
             //ui.MainWindow.net
             cluster0.findNearestSensor(false);
             addIdsToSensorA(cluster0);
             horizCount++;
         }
         startFrom.X += cellXEdgeLength;
     }
 }
Beispiel #5
0
        private static void getAfterAverage()
        {
            double avg = Math.Abs(CellGroup.getAverageSensors());

            avg -= 2;
            double i = 0;
            double y = 0;

            foreach (CellGroup cell in PublicParameters.networkCells)
            {
                double count = cell.clusterNodes.Count;
                if (count > avg)
                {
                    i += count;
                    y++;
                }
            }
            AfterSmallAverage = Convert.ToInt32(i / y);
            //AfterSmallAverage = Math.Abs(i);
        }
Beispiel #6
0
        private void buildFromCenter(Canvas Canvase_SensingFeild)
        {
            double canvasHeight = Canvase_SensingFeild.ActualHeight;
            double canvasWidth  = Canvase_SensingFeild.ActualWidth;

            getNumberOfCells();
            getCellParameters();
            Point SenPointZero = SensingFieldArea.PointZero;


            CellGroup.getCenterOfNetwork();


            double xAxesCount = Math.Sqrt(NumberOfCells);
            double yAxesCount = Math.Sqrt(NumberOfCells);


            verticalCount = 1;
            horizCount    = 1;

            Point startfrom = SenPointZero;

            for (int i = 1; i <= yAxesCount; i++)
            {
                horizCount = 1;
                buildFromPointZero(startfrom, xAxesCount);
                verticalCount++;
                startfrom.Y -= (i) * cellYEdgeLength;
            }

            addIdsToSensorFinal();


            addClustersToWindow(Canvase_SensingFeild);

            //Tree tree = new Tree(Canvase_SensingFeild);
            // tree.displayTree();

            initAssignHead();
            populateClusterTables();
        }