Example #1
0
        public void Go(string text)
        {
            Match match = Regex.Match(text, @"go (.+) (meter|second)");

            number = Convert.ToInt32(ExtractNumber(match.Groups[1].ToString()));
            var unit_of_measure = match.Groups[2].ToString();

            if (unit_of_measure == "meter")
            {
                MotorValue.acceleration_distance = number;
                MessageBox.Show("The feature has not been set yet.");
            }
            else if (unit_of_measure == "second")
            {
                MotorValue.acceleration_time = number;
            }
            MotorValue.acceleration_angle = 0;
            MotorValue.acceleration_way   = "Forward";
            _motorControl.SendCommand();
        }
Example #2
0
        public void onKeyDown(KeyEventArgs e)
        {
            if (motorKeys.Contains(e.Key))   // W,A,S,D are used for direction controlling.
            {
                MotorValue.acceleration_time     = 0;
                MotorValue.acceleration_distance = 0;
                if (Keyboard.IsKeyDown(Key.D))
                {
                    MotorValue.direction_way   = "Right";
                    MotorValue.direction_angle = 1;
                }
                else if (Keyboard.IsKeyDown(Key.A))
                {
                    MotorValue.direction_way   = "Left";
                    MotorValue.direction_angle = 1;
                }

                if (Keyboard.IsKeyDown(Key.W))
                {
                    MotorValue.acceleration_way   = "Forward";
                    MotorValue.acceleration_angle = 1;
                }
                else if (Keyboard.IsKeyDown(Key.D))
                {
                    MotorValue.acceleration_way   = "Backward";
                    MotorValue.acceleration_angle = 1;
                }
                _motorControl.SendCommand();
            }
            if (Keyboard.IsKeyDown(Key.Space) && !HornValue.isPressed) //Space is used for horn.
            {
                HornValue.isPressed = true;
                HornValue.time      = 0;
                _hornControl.SendCommand();
            }
            if (Keyboard.IsKeyDown(Key.RightShift) && !BrakeValue.IsPressed) // Right Shift is used for brake.
            {
                BrakeValue.IsPressed = true;
                _brakeControl.SendCommand();
            }
        }