コード例 #1
0
        /// <summary>
        /// Ajoute une action du gripper
        /// </summary>
        /// <param name="processName">Nom du processus</param>
        /// <param name="action">Action de gripper</param>
        /// <param name="robot">Controller du robot</param>
        /// <returns>Indicateur de succès</returns>
        public static bool AddGripperAction(string processName, GripperAction.Action action, RobotController robot)
        {
            var process = new RobotProcess(processName);

            process.Commands.Add(new GripperAction()
            {
                Name    = action == GripperAction.Action.Open ? "Open gripper" : "Close gripper",
                Command = action
            });
            process.SaveProcess();
            try
            {
                robot.StopRelativeMovement();
                if (action == GripperAction.Action.Open)
                {
                    robot.OpenGripper();
                }
                else
                {
                    robot.CloseGripper();
                }
                robot.StartRelativeMovement();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #2
0
        public static bool AddTrayAction(string processName, TrayAction.Action action, RobotController robot)
        {
            var process = new RobotProcess(processName);

            process.Commands.Add(new TrayAction()
            {
                Name    = action == TrayAction.Action.Depose ? "Depose item" : "Withdraw item",
                Command = action
            });
            process.SaveProcess();
            return(true);
        }
コード例 #3
0
 /// <summary>
 /// Permet l'ajout d'un mouvement dans un processus
 /// </summary>
 /// <param name="processName">Nom du processus</param>
 /// <param name="movementName">Nom du mouvement à créer</param>
 /// <returns>Indicateur de succès</returns>
 public static bool AddMovement(string processName, string movementName)
 {
     try
     {
         var process = new RobotProcess(processName);
         process.Commands.Add(new Movement()
         {
             Name = movementName, Positions = new List <RobotPosition>()
         });
         process.SaveProcess();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #4
0
        /// <summary>
        /// Permet l'ajout de la position courante du robot dans un mouvement
        /// </summary>
        /// <param name="processName">Nom du processus</param>
        /// <param name="robot">Controller du robot</param>
        /// <returns>Indicateur de succès</returns>
        public static bool AddCurrentPosition(string processName, Guid idMovement, RobotController robot)
        {
            try
            {
                var process = new RobotProcess(processName);

                var mvt = (from cmd in process.Commands
                           where cmd.Id.Equals(idMovement)
                           select cmd).First() as Movement;

                mvt.Positions.Add(new RobotPosition(robot));
                process.SaveProcess();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// Supprime une commande d'un processus
        /// </summary>
        /// <param name="processName">Nom du processus</param>
        /// <param name="idCommand">Guid de la commande à supprimer</param>
        /// <returns>Indicateur de succès</returns>
        public static bool DeleteCommand(string processName, Guid idCommand)
        {
            try
            {
                var process  = new RobotProcess(processName);
                var commands = (from cmd in process.Commands
                                where cmd.Id.Equals(idCommand)
                                select cmd);

                if (commands.Count() > 0)
                {
                    process.Commands.Remove(commands.First());
                    process.SaveProcess();
                    return(true);
                }
                else
                {
                    foreach (var command in process.Commands)
                    {
                        if (command is Movement)
                        {
                            var mvt = command as Movement;

                            var positions = (from pos in mvt.Positions
                                             where pos.Id.Equals(idCommand)
                                             select pos);
                            if (positions.Count() > 0)
                            {
                                mvt.Positions.Remove(positions.First());
                                process.SaveProcess();
                                return(true);
                            }
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #6
0
        /// <summary>
        /// Permet d'inverser l'ordre d'execution de deux commandes
        /// </summary>
        /// <param name="processName">Nom du processus</param>
        /// <param name="guidCommandA">Id de la commande A</param>
        /// <param name="guidCommandB">Id de la commande B</param>
        /// <returns>Indicateur de succès</returns>
        public static bool SwitchCommand(string processName, Guid guidCommandA, Guid guidCommandB)
        {
            try
            {
                var process = new RobotProcess(processName);

                var commandA = (from cmd in process.Commands
                                where cmd.Id.Equals(guidCommandA)
                                select cmd).First();

                var commandB = (from cmd in process.Commands
                                where cmd.Id.Equals(guidCommandB)
                                select cmd).First();

                if (commandA == null || commandB == null)
                {
                    return(false);
                }

                var indexCommandA = process.Commands.IndexOf(commandA);
                var indexCommandB = process.Commands.IndexOf(commandB);

                if (!(indexCommandA >= 0 && indexCommandB >= 0))
                {
                    return(false);
                }

                process.Commands[indexCommandA] = commandB;
                process.Commands[indexCommandB] = commandA;

                process.SaveProcess();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #7
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));
        }