Beispiel #1
0
        /// <summary>
        /// Permet de démarrer l'éxécution d'un processus sur un robot
        /// </summary>
        /// <param name="robot">Robot éxécutant le processus</param>
        /// <param name="process">Processus à éxécuter</param>
        /// <returns>Indicateur de succès d'éxécution</returns>
        public static bool ExecuteProcess(RobotController robot, List <IRobotCommand> commands, Tray tray = null, LogManager log = null)
        {
            try
            {
                //Arrêt des mouvements relatifs du robot
                robot.StopRelativeMovement();
                // Parcours et éxécution des commandes
                foreach (var command in commands)
                {
                    if (command is Movement)
                    {
                        // Commande de mouvement
                        var mvt = command as Movement;
                        //Envoie de la liste de positions au robot
                        if (log != null)
                        {
                            log.AddLog("Info", string.Format("Movement start : {0} waypoints", mvt.Positions.Count()));
                        }
                        robot.PlayTrajectory(mvt.GetCartesianPositions());
                        if (log != null)
                        {
                            log.AddLog("Info", "Movement end");
                        }
                    }
                    else if (command is GripperAction)
                    {
                        // Commande d'action du gripper
                        var action = command as GripperAction;
                        if (action.Command == GripperAction.Action.Open)
                        {
                            //Ouverture pince
                            robot.OpenGripper();
                            if (log != null)
                            {
                                log.AddLog("Info", "Open gripper");
                            }
                        }
                        else if (action.Command == GripperAction.Action.Close)
                        {
                            //Fermeture pince
                            robot.CloseGripper();
                            if (log != null)
                            {
                                log.AddLog("Info", "Close gripper");
                            }
                        }
                    }
                    else if (command is TrayAction)
                    {
                        var action = command as TrayAction;

                        if (log != null)
                        {
                            log.AddLog("Info", action.Command == TrayAction.Action.Depose ? "Deposing item on Tray ..." : "Withdrawing item on Tray ...");
                        }

                        if (tray != null)
                        {
                            // Execution des commandes plateau
                            var commandsTray = tray.GetRobotCommand(action.Command == TrayAction.Action.Withdraw);
                            ExecuteProcess(robot, commandsTray, tray, log);
                        }
                        else
                        {
                            if (log != null)
                            {
                                log.AddLog("Error", "Tray not calibrated...");
                            }
                        }
                    }
                    else
                    {
                        //Commande inconnue
                        if (log != null)
                        {
                            log.AddLog("Error", "In ExecuteProcess(): Unknow command");
                        }
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                if (log != null)
                {
                    log.AddLog("Error", "Exception throw in ExecuteProcess(): " + e.Data);
                }
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        public static bool ExecuteProcess(RobotController robot, string processName, Tray tray = null, LogManager log = null)
        {
            var process = new RobotProcess(processName);

            return(ExecuteProcess(robot, process.Commands, tray, log));
        }