Example #1
0
 private void ButtonManualGoFourForward_Click(object sender, RoutedEventArgs e)
 {
     RobotController.SubmitCommand(RobotTranslator.EncodeTo(0, new List <RobotActions>()
     {
         RobotActions.Forward, RobotActions.Forward, RobotActions.Forward, RobotActions.Forward
     }));
 }
Example #2
0
        private void TextBoxDirectCommands_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                try
                {
                    // Add the command identifier and a wait time, if it was not supplied
                    string command = TextBoxDirectCommands.Text;
                    if (!command.StartsWith(RobotMessageResultServer.IDENTIFIER_GO))
                    {
                        command =
                            RobotMessageResultServer.IDENTIFIER_GO + CommunicationConstants.MSG_SUB_DELIMITER +
                            "0" + CommunicationConstants.MSG_SUB_DELIMITER +
                            command;
                    }

                    // Check whether the translation would raise an exception
                    RobotTranslator.DecodeTo(command);

                    // Submit the command
                    RobotController.SubmitCommand(command);

                    // Clear message window
                    TextBoxDirectCommands.Text = "";
                }
                catch (Exception)
                {
                    LogMessage("Invalid command!");
                }
            }
        }
Example #3
0
        private void EmulatedControlTreeViewItem_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                TextBox    castedSender = (TextBox)sender;
                ClientInfo clientInfo   = _inputBoxEmulatedControls[castedSender];
                string     message      = castedSender.Text;
                castedSender.Text = "";
                try
                {
                    ControlMessageResultClient messageResult = ControlTranslator.DecodeFrom(message);
                    string robotCommand;
                    switch (messageResult.Type)
                    {
                    case ControlMessageTypesClient.Path: robotCommand = _server.ConvertToRobCmd(messageResult.RobotID, messageResult.WaitTime, messageResult.Path); break;

                    case ControlMessageTypesClient.Pickup: robotCommand = RobotTranslator.EncodeToPickup(); break;

                    case ControlMessageTypesClient.Setdown: robotCommand = RobotTranslator.EncodeToSetdown(); break;

                    case ControlMessageTypesClient.Rest: robotCommand = RobotTranslator.EncodeToRest(); break;

                    case ControlMessageTypesClient.GetItem: robotCommand = RobotTranslator.EncodeToGetItem(); break;

                    case ControlMessageTypesClient.PutItem: robotCommand = RobotTranslator.EncodeToPutItem(); break;

                    default: throw new ArgumentException("Unknown command type: " + messageResult.Type.ToString());
                    }
                    _server.SendMsg(ClientType.R, messageResult.RobotID, robotCommand);
                }
                catch (Exception ex)
                {
                    ShowMessage("Error: " + ex.Message);
                }
            }
        }
Example #4
0
 private void ButtonManualGoStop_Click(object sender, RoutedEventArgs e)
 {
     RobotController.SubmitCommand(RobotTranslator.EncodeToRest());
 }