Exemplo n.º 1
0
        public void InitHandlers()
        {
            CoOrdinate currentRoom = new CoOrdinate(3, 3);

            RobotHardware.IHardwareRobot cleaningRobot     = new RobotHardware.Hardware(currentRoom.X, currentRoom.Y);
            IRobotVisitMonitor           robotVisitMonitor = RobotVisitMonitorFactory.CreateRobotVisitMonitor(
                RobotVisitMonitorType.RobotVisitMonitorWithConsoleOutput, cleaningRobot);
            Room room = new SimpleRoom();

            _algorithmEssentials = new AlgorithmEssentials(room, cleaningRobot, robotVisitMonitor);

            _firstObstacleHandler           = new ObstacleHandler(_algorithmEssentials);
            _obstacleHandlerWithCellRevisit = new ObstacleHandler(_algorithmEssentials, true);
        }
Exemplo n.º 2
0
        public void CircularCleaningAlgorithmOnSquareShapeTest()
        {
            // Define the min and max co-ordinate for the room
            _currentRoom = new CoOrdinate(3, 3);

            // Create the Robot
            _cleaningRobot = new RobotHardware.Hardware(_currentRoom.X, _currentRoom.Y);

            // Create the required robot visit monitor. Current visit monitor can print the robot path to console
            _robotVisitMonitor = RobotVisitMonitorFactory.CreateRobotVisitMonitor(
                RobotVisitMonitorType.RobotVisitMonitorWithConsoleOutput, _cleaningRobot);

            // Create a simple room
            _room = new SimpleRoom();

            // Create the algorithm essentials with the above robot, visit monitor and room.
            _algorithmEssentials = new AlgorithmEssentials(_room, _cleaningRobot, _robotVisitMonitor);

            // Ask the CleaningAlgorithmFactory to create the CleaningAlgorithm instance by passing the required
            // required CleaningAlgorithmType
            _cleaningAlgorithm = CleaningAlgorithmFactory.CreateCleaningAlgorithm(
                CleaningAlgorithmType.CircularCleaningAlgorithm, _algorithmEssentials);

            Assert.AreEqual(CleanStatus.Complete, _cleaningAlgorithm.Clean());

            Assert.AreEqual("Turn Left", _algorithmEssentials.RobotVisitMonitor.GetPathAt(0));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(1));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(2));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(3));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(4));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(5));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(6));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(7));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(8));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(9));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(10));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(11));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(12));
            Assert.AreEqual("Move Forward", _algorithmEssentials.RobotVisitMonitor.GetPathAt(13));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(14));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(15));
            Assert.AreEqual("Turn Right", _algorithmEssentials.RobotVisitMonitor.GetPathAt(16));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Define the min and max co-ordinate for the room
            CoOrdinate currentRoom = new CoOrdinate(1, 5);

            // Create the Robot
            RobotHardware.IHardwareRobot cleaningRobot = new RobotHardware.Hardware(currentRoom.X, currentRoom.Y);

            // Create the required robot visit monitor. Current visit monitor can print the robot path to console
            IRobotVisitMonitor robotVisitMonitor = RobotVisitMonitorFactory.CreateRobotVisitMonitor(
                RobotVisitMonitorType.RobotVisitMonitorWithConsoleOutput, cleaningRobot);

            // Create a simple room
            Room room = new SimpleRoom();

            // Create the algorithm essentials with the above robot, visit monitor and room.
            AlgorithmEssentials algorithmEssentials = new AlgorithmEssentials(room, cleaningRobot, robotVisitMonitor);

            // Ask the CleaningAlgorithmFactory to create the CleaningAlgorithm instance by passing the required
            // required CleaningAlgorithmType
            CleaningAlgorithm cleaningAlgorithm = CleaningAlgorithmFactory.CreateCleaningAlgorithm(
                CleaningAlgorithmType.CircularCleaningAlgorithm, algorithmEssentials);

            // Ask the ReturnAlgorithmFactory to create the ReturnAlgorithm instance by passing the required
            // required ReturnAlgorithmType
            ReturnAlgorithm returnAlgorithm = ReturnAlgorithmFactory.CreateReturnAlgorithm(
                ReturnAlgorithmType.SimpleReturnAlgorithm, algorithmEssentials);

            // Create a CleaningManager to manage the cleaning and returning process
            CleaningManager manager = new CleaningManager(cleaningAlgorithm, returnAlgorithm);

            bool overallOperationStatus = manager.Clean();

            Console.WriteLine("Cleaning Status : {0}", manager.GetCleanStatus());
            Console.WriteLine("Return Status : {0}", manager.GetReturnStatus());

            robotVisitMonitor.PrintRobotPath();

            Console.ReadKey();
        }
 public AlgorithmEssentials(Room inRoom, RobotHardware.IHardwareRobot inRobot, IRobotVisitMonitor inRobotVisitMonitor)
 {
     _room              = inRoom;
     _robot             = inRobot;
     _robotVisitMonitor = inRobotVisitMonitor;
 }