Exemple #1
0
        private void changeClusterPosition()
        {
            List <CellGroup> clusterList = PublicParameters.networkCells;
            double           avg         = CellGroup.getAverageSensors();

            for (int x = 0; x < clusterList.Count(); x++)
            {
                CellGroup oldCluster         = PublicParameters.networkCells[x];
                Point     oldClusterLocation = oldCluster.clusterLocMargin;

                int oldNodesCount = oldCluster.clusterNodes.Count;
                if (oldNodesCount < avg)
                {
                    //Consider changing the cluster
                    //Construct 8 clusters and compare between each of them
                    //Construct the 8 clusters by adding them to a temporary list in ReCheck
                    for (int i = 1; i <= 8; i++)
                    {
                        CellGroup tempCluster = new CellGroup(oldClusterLocation, oldCluster.getID());
                        //Console.WriteLine("Old Position X: {0} Y: {1}", tempCluster.clusterPoint.X, tempCluster.clusterPoint.Y);
                        tempCluster.incDecPos(i, (0.334));
                        // Console.WriteLine("New Position X: {0} Y: {1}", tempCluster.clusterPoint.X, tempCluster.clusterPoint.Y);
                        tempCluster.findNearestSensorRecheck(false);
                    }
                    CellGroup maxCluster = new CellGroup();
                    maxCluster = maxCluster.getMaxSensors();
                    maxCluster.findNearestSensorRecheck(true);
                }
            }
        }
Exemple #2
0
        private void buildFromDirection(String direction, Point startFrom, double count)
        {
            switch (direction)
            {
            case "center":

                CellGroup cluster = new CellGroup(startFrom, assignID);
                cluster.findNearestSensor(false);
                if (cluster.isNotEmpty())
                {
                    addIdsToSensorA(cluster);
                    assignID++;
                }

                break;

            case "right":
                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster0 = new CellGroup(startFrom, assignID);
                    cluster0.incDecPos(1, i + 1);
                    cluster0.findNearestSensor(true);
                    if (cluster0.isNotEmpty())
                    {
                        //ui.MainWindow.net
                        cluster0.findNearestSensor(false);
                        addIdsToSensorA(cluster0);
                        assignID++;
                    }
                }
                break;

            case "left":

                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster1 = new CellGroup(startFrom, assignID);
                    cluster1.incDecPos(2, i + 1);
                    cluster1.findNearestSensor(true);
                    if (cluster1.isNotEmpty())
                    {
                        cluster1.findNearestSensor(false);
                        addIdsToSensorA(cluster1);
                        assignID++;
                    }
                }
                break;

            case "up":

                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster2 = new CellGroup(startFrom, assignID);
                    cluster2.incDecPos(3, i + 1);
                    cluster2.findNearestSensor(true);
                    if (cluster2.isNotEmpty())
                    {
                        cluster2.findNearestSensor(false);
                        addIdsToSensorA(cluster2);
                        assignID++;
                    }
                }
                break;

            case "down":

                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster3 = new CellGroup(startFrom, assignID);
                    cluster3.incDecPos(4, i + 1);
                    cluster3.findNearestSensor(true);
                    if (cluster3.isNotEmpty())
                    {
                        cluster3.findNearestSensor(false);
                        addIdsToSensorA(cluster3);
                        assignID++;
                    }
                }
                break;

            case "upright":

                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster4 = new CellGroup(startFrom, assignID);
                    cluster4.incDecPos(5, i + 1);
                    cluster4.findNearestSensor(true);
                    if (cluster4.isNotEmpty())
                    {
                        cluster4.buildClustersunderTop = i + 1;
                        cluster4.findNearestSensor(false);
                        addIdsToSensorA(cluster4);
                        assignID++;
                    }
                }
                break;

            case "downleft":

                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster5 = new CellGroup(startFrom, assignID);
                    cluster5.incDecPos(6, i + 1);
                    cluster5.findNearestSensor(true);
                    if (cluster5.isNotEmpty())
                    {
                        cluster5.buildClustersunderTop = i + 1;
                        cluster5.findNearestSensor(false);
                        addIdsToSensorA(cluster5);
                        assignID++;
                    }
                }

                break;

            case "upleft":

                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster6 = new CellGroup(startFrom, assignID);
                    cluster6.incDecPos(7, i + 1);
                    cluster6.findNearestSensor(true);
                    if (cluster6.isNotEmpty())
                    {
                        cluster6.buildClustersunderTop = i + 1;
                        cluster6.findNearestSensor(false);
                        addIdsToSensorA(cluster6);
                        assignID++;
                    }
                }
                break;

            case "downright":

                for (int i = 0; i < count; i++)
                {
                    CellGroup cluster7 = new CellGroup(startFrom, assignID);
                    cluster7.incDecPos(8, i + 1);
                    cluster7.findNearestSensor(true);
                    if (cluster7.isNotEmpty())
                    {
                        cluster7.buildClustersunderTop = i + 1;
                        cluster7.findNearestSensor(false);
                        addIdsToSensorA(cluster7);
                        assignID++;
                    }
                }
                break;
            }
        }