Esempio n. 1
0
        /*
         * Función: AddTreeChilds
         * Descripción: Función recursiva que recorre el archivo XML y llena el árbol de comandos
         * Autor: Christian Vargas
         * Fecha de creación: 30/07/15
         * Fecha de modificación: --/--/--
         * Entradas: Nodo inicial
         * Salidas: Árbol cargado con datos del XML
         */
        private void AddTreeChilds(CommandNode parent, XmlNode xmlNode)
        {
            CommandNode newNode;

            if (xmlNode.Name == "menu")
            {
                newNode = parent.AddChild(Types.Menu, xmlNode.ChildNodes[0].InnerText, xmlNode.ChildNodes[1].InnerText);
                for (int i = 2; i < xmlNode.ChildNodes.Count; i++)
                {
                    AddTreeChilds(newNode, xmlNode.ChildNodes[i]);
                }
            }
            else if (xmlNode.Name == "page")
            {
                newNode = parent.AddChild(Types.Page, "", "");
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    AddTreeChilds(newNode, xmlNode.ChildNodes[i]);
                }
            }
            else if (xmlNode.Name == "command")
            {
                newNode = parent.AddChild(Types.Command, xmlNode.ChildNodes[0].InnerText, xmlNode.ChildNodes[1].InnerText);
            }
        }
Esempio n. 2
0
 /*
  * Función: GetGrammar
  * Descripción: Función que llena y devuelve la gramática usando los vectores de comandos y el árbol de comandos
  * Autor: Christian Vargas
  * Fecha de creación: 16/08/15
  * Fecha de modificación: --/--/--
  * Entradas: Nodo inicial del árbol de comandos
  * Salidas: (Choices, gramática para entrenar a Kinect)
  */
 public static Choices GetGrammar(CommandNode commandTree)
 {
     grammar = new Choices();
     grammar.Add(UNLOCK_COMMAND);
     foreach (string command in GEOMETRIC_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in MENU_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in DICTATION_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string characterSound in CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     foreach (string characterSound in ALT_CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     AddNodeToGrammar(commandTree);
     AddNumbers();
     return grammar;
 }
Esempio n. 3
0
        /*
         * Función: AddChild
         * Descripción: Función que añade un hijo a un nodo de árbol de comandos
         * Autor: Christian Vargas
         * Fecha de creación: 30/07/15
         * Fecha de modificación: --/--/--
         * Entradas: childType (Types, el tipo de nodo), childText (string, el texto del nodo), childCode (string, el código del nodo)
         * Salidas: (CommandNode, el hijo del nodo de árbol de comando con datos validos)
         */
        private CommandNode AddChild(Types childType, string childText, string childCode)
        {
            CommandNode childNode = new CommandNode(childType, childText, childCode);

            this.children.Add(childNode);
            return(childNode);
        }
Esempio n. 4
0
 /*
  * Función: GetGrammar
  * Descripción: Función que llena y devuelve la gramática usando los vectores de comandos y el árbol de comandos
  * Autor: Christian Vargas
  * Fecha de creación: 16/08/15
  * Fecha de modificación: --/--/--
  * Entradas: Nodo inicial del árbol de comandos
  * Salidas: (Choices, gramática para entrenar a Kinect)
  */
 public static Choices GetGrammar(CommandNode commandTree)
 {
     grammar = new Choices();
     grammar.Add(UNLOCK_COMMAND);
     foreach (string command in GEOMETRIC_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in MENU_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in DICTATION_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string characterSound in CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     foreach (string characterSound in ALT_CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     AddNodeToGrammar(commandTree);
     AddNumbers();
     return(grammar);
 }
Esempio n. 5
0
 /*
  * Función: AddNodeToGrammar
  * Descripción: Función recursiva que recorre el árbol de comandos y agrega los textos de menú y comando a la gramática
  * Autor: Christian Vargas
  * Fecha de creación: 30/07/15
  * Fecha de modificación: --/--/--
  * Entradas: Nodo inicial
  * Salidas: Gramática actualizada
  */
 private static void AddNodeToGrammar(CommandNode node)
 {
     if (node == null)
     {
         Console.WriteLine("El árbol de comandos no se inicializo antes de crear la gramática");
         return;
     }
     if (node.type == Types.Command)
     {
         grammar.Add(node.text);
     }
     else if (node.type == Types.Menu)
     {
         grammar.Add(node.text);
         foreach (CommandNode child in node.children)
         {
             AddNodeToGrammar(child);
         }
     }
     else
     {
         foreach (CommandNode child in node.children)
         {
             AddNodeToGrammar(child);
         }
     }
 }
Esempio n. 6
0
 /*
  * Función: AddChild
  * Descripción: Función que añade un hijo a un nodo de árbol de comandos
  * Autor: Christian Vargas
  * Fecha de creación: 30/07/15
  * Fecha de modificación: --/--/--
  * Entradas: childType (Types, el tipo de nodo), childText (string, el texto del nodo), childCode (string, el código del nodo)
  * Salidas: (CommandNode, el hijo del nodo de árbol de comando con datos validos)
  */
 private CommandNode AddChild(Types childType, string childText, string childCode)
 {
     CommandNode childNode = new CommandNode(childType, childText, childCode);
     this.children.Add(childNode);
     return childNode;
 }
Esempio n. 7
0
 /*
  * Función: AddTreeChilds
  * Descripción: Función recursiva que recorre el archivo XML y llena el árbol de comandos
  * Autor: Christian Vargas
  * Fecha de creación: 30/07/15
  * Fecha de modificación: --/--/--
  * Entradas: Nodo inicial
  * Salidas: Árbol cargado con datos del XML
  */
 private void AddTreeChilds(CommandNode parent, XmlNode xmlNode)
 {
     CommandNode newNode;
     if (xmlNode.Name == "menu")
     {
         newNode = parent.AddChild(Types.Menu, xmlNode.ChildNodes[0].InnerText, xmlNode.ChildNodes[1].InnerText);
         for (int i = 2; i < xmlNode.ChildNodes.Count; i++)
         {
             AddTreeChilds(newNode, xmlNode.ChildNodes[i]);
         }
     }
     else if (xmlNode.Name == "page")
     {
         newNode = parent.AddChild(Types.Page, "", "");
         for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
         {
             AddTreeChilds(newNode, xmlNode.ChildNodes[i]);
         }
     }
     else if (xmlNode.Name == "command")
     {
         newNode = parent.AddChild(Types.Command, xmlNode.ChildNodes[0].InnerText, xmlNode.ChildNodes[1].InnerText);
     }
 }
Esempio n. 8
0
 /*
  * Función: AddNodeToGrammar
  * Descripción: Función recursiva que recorre el árbol de comandos y agrega los textos de menú y comando a la gramática
  * Autor: Christian Vargas
  * Fecha de creación: 30/07/15
  * Fecha de modificación: --/--/--
  * Entradas: Nodo inicial
  * Salidas: Gramática actualizada
  */
 private static void AddNodeToGrammar(CommandNode node)
 {
     if (node == null)
     {
         Console.WriteLine("El árbol de comandos no se inicializo antes de crear la gramática");
         return;
     }
     if (node.type == Types.Command)
     {
         grammar.Add(node.text);
     }
     else if (node.type == Types.Menu)
     {
         grammar.Add(node.text);
         foreach (CommandNode child in node.children)
         {
             AddNodeToGrammar(child);
         }
     }
     else
     {
         foreach (CommandNode child in node.children)
         {
             AddNodeToGrammar(child);
         }
     }
 }
Esempio n. 9
0
 /*
  * Función: Form_Main_Load
  * Descripción: Función que es llamada cuando la aplicación inicia
  * Autor: Christian Vargas
  * Fecha de creación: 07/06/15
  * Fecha de modificación: --/--/--
  * Entradas: --
  * Salidas: Programa inicializado
  */
 private void Form_Main_Load(object sender, EventArgs e)
 {
     //Se genera el árbol de comandos
     commandTree = new CommandNode(Types.Root, "", "");
     commandTree.CreateTree("commands.xml");
     //Se inicializan las listas
     downloadedMol = new List<string>();
     selectedList = new List<string>();
     //Se cargan los dispositivos y se inicializan los clientes y servidores UDP
     LoadDevices();
     udpClient = new UdpClient(IP, OUT_PORT);
     endPoint = new IPEndPoint(IPAddress.Parse(IP), IN_PORT);
     udpServer = new UdpClient(endPoint);
 }