/**
     * Actualiza la información de la ventana "Positions(0/0)".
     * @return void
     */
    public void UpdatePositionLog()
    {
        int    nSync      = 0;
        string auxLog     = "";
        string auxSyncLog = "";

        // Get positions name and sync state
        for (int i = 0; i < targetControl.Count(); i++)
        {
            TargetModel model = targetControl.GetTarget(i).GetComponent <TargetModel>();
            auxLog += model.GetName() + "\n";

            if (!model.GetSync())
            {
                auxSyncLog += "No sync" + "\n";
            }
            else
            {
                auxSyncLog += "\n";
                nSync++;
            }
        }
        // Write positions name
        positionLog.text = auxLog;
        // Write positions sync state
        positionSyncLog.text = auxSyncLog;
        // Fix containers to fit names
        AdjustContent(positionLog.gameObject, contentPositionLog);

        // Count data
        UpdateCountData(nSync, targetControl.Count());
    }
    /**
     * Guarda las posiciones actuales y sus datos en el fichero "backup.txt". (normal|relative) name x y z p r (relativeTo).
     * @return void
     */
    public void Save()
    {
        string[] lines = new string[targetControl.Count()];

        // Get positions data
        for (int i = 0; i < targetControl.Count(); i++)
        {
            string      aux    = "";
            TargetModel target = targetControl.GetTarget(i).GetComponent <TargetModel>();

            // Relative position?
            if (target.GetRelativeTo() == null)
            {
                aux += NORMAL + " ";
                aux += target.GetName() + " ";
                aux += target.GetPositionInScorbot().x + " ";
                aux += target.GetPositionInScorbot().y + " ";
                aux += target.GetPositionInScorbot().z + " ";
                aux += target.GetPitch() + " ";
                aux += target.GetRoll();
            }
            else
            {
                aux += RELATIVE + " ";
                aux += target.GetName() + " ";
                aux += target.GetRelativePosInScorbot().x + " ";
                aux += target.GetRelativePosInScorbot().y + " ";
                aux += target.GetRelativePosInScorbot().z + " ";
                aux += target.GetRelativeP() + " ";
                aux += target.GetRelativeR() + " ";
                aux += target.GetRelativeTo().GetComponent <TargetModel>().GetName();
            }

            lines[i] = aux;
        }

        // Overwrite everything
        System.IO.File.WriteAllLines(BACKUP_FILE, lines);

        gameController.backupFileOutput.text = "File saved.";
    }
Exemple #3
0
 public void RemoveTarget()
 {
     if (target)
     {
         targetControl.Remove(target);
     }
     UpdateTargets(targetControl.GetNames());
     if (targetControl.Count() >= 1)
     {
         SetTarget(targetControl.GetTarget(0));
     }
 }
Exemple #4
0
    public void RunCommandOffline(string line_command)
    {
        string[] ListCommandLine = line_command.Split(' ');

        switch (ListCommandLine[0].ToLower())
        {
        case "home":
            CommandControl.Home(Robot);
            break;

        case "move":
            break;

        case "movel":
            CommandControl.Home(Robot);
            break;

        case "movec":
            CommandControl.Home(Robot);
            break;

        case "teach":
            /* */

            Transform target = TargetControl.GetTarget(ListCommandLine[1]);
            //target.position;
            //target.GetComponent<TargetModel>().GetPitch();
            //target.GetComponent<TargetModel>().GetRoll();


            //CommandControl.Teach(Robot, TargetControl.GetTarget(ListCommandLine[1]),);
            break;

        case "here":
            CommandControl.Home(Robot);
            break;

        case "defp":
            CommandControl.Home(Robot);
            break;

        case "teachr":
            break;

        case "speed":

            break;

        case "speedl":
            break;

        case "shiftc":

            break;

        case "jaw":
            break;

        case "profile":

            break;

        case "moves":
            break;

        case "help":
            break;

        default:
            break;
        }
        Terminal.GetComponent <Terminal>().Input_View(true);
    }
    /**
     * Elimina la posición (objeto) seleccionada en la lista de posiciones.
     * @return void
     */
    public void RemoveTarget()
    {
        stateMessageControl.NewBlock();
        if (!target)
        {
            stateMessageControl.WriteMessage("Done. Nothing to delete", true);
            return;
        }

        string name = target.GetComponent <TargetModel>().GetName();

        // Delete target
        targetControl.Remove(target);
        // Update targets
        UpdateTargets(targetControl.GetNames());
        if (targetControl.Count() >= 1)
        {
            SetTarget(targetControl.GetTarget(0));
        }

        stateMessageControl.WriteMessage("Done. Deleted \"" + name + "\"", true);
        stateMessageControl.UpdatePositionLog();
    }
Exemple #6
0
    public void RunCommandOffline(string line_command)
    {
        Term.Input      = false;
        Term.Input_text = false;
        bool help = false;
        int  value;
        bool isNumeric;

        if (Count_Command_Data >= 1 && Count_Command_Data < 6)
        {
            this.Teach(line_command);
        }

        else
        {
            Term.History.Push(line_command);
            Term.Log(TerminalLogType.Command, "{0}", line_command);

            string[] ListCommandLine = line_command.Split(' ');
            if (ListCommandLine.Count() > 1)
            {
                if (ListCommandLine[1].ToLower().Equals("-h"))
                {
                    Help(ListCommandLine[0].ToLower());
                    Term.Input_View(true);
                    help = true;
                }
                else
                {
                    Target = TargetControl.GetTarget(ListCommandLine[1]);
                }
            }

            if (!help)
            {
                switch (ListCommandLine[0].ToLower())
                {
                case "home":
                    CommandControl.Home(Robot);
                    Term.Input_View(true);
                    break;

                case "move":
                    if (Target == null)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Punto no creado");
                    }
                    else
                    {
                        CommandControl.Move(Robot, Target);
                    }
                    Term.Input_View(true);
                    break;

                case "movel":
                    if (Target == null)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Punto no creado");
                    }
                    else
                    {
                        CommandControl.MoveL(Robot, Target);
                    }
                    Term.Input_View(true);
                    break;

                case "movec":
                    Target2 = TargetControl.GetTarget(ListCommandLine[2]);
                    if (Target == null || Target2 == null)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Punto no creado");
                    }
                    else
                    {
                        CommandControl.MoveC(Robot, Target, Target2);
                    }
                    Term.Input_View(true);
                    break;

                case "teach":
                    if (Target == null)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Punto no creado");
                    }
                    else
                    {
                        XYZ = Target.GetComponent <TargetModel>().GetPositionInScorbot();
                        float truncated = (float)(Math.Truncate((double)XYZ.x * 100.0) / 100.0);
                        Term.Log(TerminalLogType.Log, "{0}", "       X -- [" + truncated + "] ");
                        Count_Command_Data++;
                        Term.Input_Text(true);
                    }
                    break;

                case "here":
                    if (Target == null)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Punto no creado");
                    }
                    else
                    {
                        CommandControl.Here(Robot, Target);
                    }
                    Term.Input_View(true);
                    break;

                case "teachr":
                    Target2 = TargetControl.GetTarget(ListCommandLine[2]);
                    if (Target == null || Target2 == null)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Punto no creado");
                    }
                    else
                    {
                        float truncated = (float)(Math.Truncate((double)Target.position.x * 100.0) / 100.0);
                        Term.Log(TerminalLogType.Log, "{0}", "       X -- [" + truncated + "]");
                        Count_Command_Data++;
                        Term.Input_Text(true);
                    }
                    break;

                case "speed":
                    //0-100
                    isNumeric = int.TryParse(ListCommandLine[1], out value);
                    if (isNumeric && value >= 0 && value <= 100)
                    {
                        CommandControl.Speed(Robot, value);
                    }
                    else
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Valor incorrecto [0-100]");
                    }
                    Term.Input_View(true);
                    break;

                case "speedl":
                    //0-300
                    isNumeric = int.TryParse(ListCommandLine[1], out value);
                    if (isNumeric && value >= 0 && value <= 300)
                    {
                        CommandControl.SpeedL(Robot, value);
                    }
                    else
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Valor incorrecto [0-300]");
                    }
                    Term.Input_View(true);
                    break;

                case "shiftc":
                    if (ListCommandLine.Count() == 5)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Comando mal escrito");
                    }
                    else if (Target == null)
                    {
                        Term.Log(TerminalLogType.Warning, "{0}", "Punto no creado");
                    }
                    else
                    {
                        isNumeric = int.TryParse(ListCommandLine[3], out value);
                        float valueFloat;
                        bool  isFloat = float.TryParse(ListCommandLine[4], out valueFloat);
                        if (isNumeric && isFloat && (value >= 0) && (value <= 4))
                        {
                            CommandControl.Shiftc(Robot, Target, value, valueFloat);
                        }
                        else
                        {
                            if (isNumeric)
                            {
                                Term.Log(TerminalLogType.Warning, "{0}", "Valor no permitido");
                            }
                            else
                            {
                                Term.Log(TerminalLogType.Warning, "{0}", "Eje no permitido");
                            }
                        }
                    }
                    Term.Input_View(true);
                    break;

                case "help":
                    Help();
                    Term.Input_View(true);
                    break;

                case "clear":
                    Term.Buffer.Clear();
                    Term.Input_View(true);
                    break;

                default:
                    Term.Log(TerminalLogType.Warning, "{0}", "Comando mal escrito");
                    Term.Input_View(true);
                    break;
                }
            }
        }
        help = false;
    }