Exemplo n.º 1
0
        private bool GoWest(int pIndex, Position pNodePosition, PropagationModel pPropagationModel, Parameters pParameters, Guid pNodeGuid)
        {
            bool signalAboveThreshold = false;
            var endPoint = pNodePosition.X - pIndex;

            var position = new Position { X = pNodePosition.X + pIndex, Y = pNodePosition.Y + pIndex };
            Debug.WriteLine("Going to SW corner. Starting point [{0}, {1}]", position.X, position.Y);

            if (position.X > mBlueprint.Columns) position.X = mBlueprint.Columns;
            if (position.Y > mBlueprint.Rows) return false;

            while (position.X != endPoint)
            {
                Debug.WriteLine("Counting signal strength for cell [{0}, {1}]", position.X, position.Y);
                var signal = pPropagationModel.CountSignalStrength(pNodePosition, position, pParameters);

                if (signal > mTreshold)
                {
                    signalAboveThreshold = true;
                    var cell = mBlueprint[(int)position.X, (int)position.Y];
                    cell.SetSignalSource(pNodeGuid.ToString(), signal);
                }
                position.X--;
            }

            return signalAboveThreshold;
        }
Exemplo n.º 2
0
        private bool GoEast(int pIndex, Position pNodePosition, PropagationModel pPropagationModel, Parameters pParameters, Guid pNodeGuid)
        {
            bool signalAboveThreshold = false;
            var endPoint = pNodePosition.X + pIndex;

            var position = new Position {X = pNodePosition.X - pIndex, Y = pNodePosition.Y - pIndex};
            Debug.WriteLine("Going to NE corner. Starting point [{0}, {1}]", position.X, position.Y);

            if (position.X < 0) position.X = 0;
            if (position.Y < 0) return false; // index outside cell area, dont count anything

            while (position.X != endPoint)
            {
                Debug.WriteLine("Counting signal strength for cell [{0}, {1}]", position.X, position.Y);
                var signal = pPropagationModel.CountSignalStrength(pNodePosition, position, pParameters);

                if (signal > mTreshold)
                {
                    signalAboveThreshold = true;
                    var cell = mBlueprint[(int)position.X, (int)position.Y];
                    cell.SetSignalSource(pNodeGuid.ToString(), signal);
                }
                position.X++;
            }

            return signalAboveThreshold;
        }