Example #1
0
        public override bool Send(CommBuffer buffer, out bool send, out bool free)
        {
            Command comm = null;

            if (!rotationSent)
            {
                comm = new Command_Rotate(c, angle);

                free = false;
            }
            else
            {
                comm = new Command_Move(c, distance);

                free = true;
            }

            bool dummySend, dummyFree;

            comm.Send(buffer, out dummySend, out dummyFree);

            send = true;
            return(true);
        }
Example #2
0
        Command ParseCommand(string line)
        {
            string upper = line.ToUpper();

            if (upper.StartsWith("MOVE"))
            {
                return(Command_Move.Parse(c, line));
            }
            if (upper.StartsWith("ROTATE"))
            {
                return(Command_Rotate.Parse(c, line));
            }
            if (upper.StartsWith("TAKE"))
            {
                return(Command_PickUp.Parse(c, line));
            }
            if (upper.StartsWith("LETGO"))
            {
                return(Command_LetGo.Parse(c, line));
            }
            if (upper.StartsWith("WAIT"))
            {
                return(Command_Wait.Parse(c, line));
            }
            if (upper.StartsWith("SETANGLE"))
            {
                return(Command_SetAngle.Parse(c, line));
            }
            if (upper.StartsWith("LOOKAT"))
            {
                return(Command_LookAt.Parse(c, line));
            }
            if (upper.StartsWith("MOVETO"))
            {
                return(Command_MoveTo.Parse(c, line));
            }
            if (upper.StartsWith("SETPRESCALER"))
            {
                return(Command_SetPrescaler.Parse(c, line));
            }
            if (upper.StartsWith("SERVO_MOVE"))
            {
                return(Command_MoveServo.Parse(c, line));
            }
            if (upper.StartsWith("DELAY"))
            {
                return(Command_Delay.Parse(c, line));
            }
            if (upper.StartsWith("KILLSENSORS"))
            {
                return(new Command_KillSensors(c));
            }
            if (upper.StartsWith("ULTRASOUND_ON"))
            {
                return(new Command_UltrasoundOn(c));
            }
            if (upper.StartsWith("ULTRASOUND_OFF"))
            {
                return(new Command_UltrasoundOff(c));
            }

            throw new Exception("Invalid command!");
        }