Example #1
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 #2
0
 private void ButtonManualGoStop_Click(object sender, RoutedEventArgs e)
 {
     RobotController.SubmitCommand(RobotTranslator.EncodeToRest());
 }