Example #1
0
        public void ProcessCommand(CmdMsg msg)
        {
            string str;

            switch (msg.Type)
            {
            case Command.MoveXYZ:
                str = String.Format("DS {0},{1},{2}",
                                    msg.Vector.X,
                                    msg.Vector.Y,
                                    msg.Vector.Z);
                Serial.WriteLine(str);
                break;

            case Command.MoveAngle:
                str = String.Format("DJ {0},{1}",
                                    msg.Vector.X,
                                    msg.Vector.Y
                                    );
                Serial.WriteLine(str);
                break;

            case Command.ToolStraight:
                str = MoveToolStraight(msg.Vector.X);
                Serial.WriteLine(str);
                break;

            case Command.Where:
                Serial.WriteLine("WH");
                break;

            case Command.Gripper:
                str = GripperAction((Vector3)msg.Vector);
                Serial.WriteLine(str);
                break;

            case Command.QueryPolar:
                GrabPolar((PositionGrab)msg.Position);
                break;

            case Command.QueryPour:
                MoveAroundCirclePoint((Circle3D)msg.Position);
                break;

            case Command.MovePosition:
                MovePosition(msg.Position.ToMelfaPosString());
                break;

            default:
                throw new NotImplementedException("No implementation to deal with this CmdMsg type");
            }
            ;

            Logger.Instance.Log($"Processing message: {msg.Type} Vector: {msg.Vector.ToString()}");
        }
        private void DataGrid_GotoButton_Click(object sender, RoutedEventArgs e)
        {
            Action <DataGrid, string> GotoSelectedGridPos = (grid, type) =>
            {
                var rows = grid.SelectedCells;
                var pos  = rows.ElementAt(0).Item as PolarPosition;
                if (pos != null)
                {
                    CmdMsg msg;
                    Logger.Instance.Log(pos.ToMelfaPosString());
                    if (type == "grab")
                    {
                        msg = new CmdMsg(Command.MovePosition, pos);
                    }
                    else
                    {
                        var pourPos = pos as Circle3D;
                        msg = new CmdMsg(Command.MovePosition, pourPos.GetPositionAtStartAngle());
                    }
                    RobotSend.Send(msg);
                }
            };

            var btn = sender as Button;

            if (btn == null)
            {
                return;
            }
            else if (btn.Name == "GotoGrab")
            {
                GotoSelectedGridPos(this.dataGrid, "grab");
            }
            else if (btn.Name == "GotoCircle")
            {
                GotoSelectedGridPos(this.dataCirclePourGrid, "pour");
            }
        }
Example #3
0
 public void Send(CmdMsg item)
 {
     Logger.Instance.Log("Added item to send queue");
     this.CmdQueue.Add(item);
 }