public KinectStickEngine(CompiledProfile profile)
        {
            actualNode = null;
            instructionQueue = new List<CompiledSpeechPhrase>();
            joy = new VJoyWrapper();
            inputSimulator = new InputSimulator();
            this.profile = profile;

            ready = InitKinect() && LoadSpeechRecognitionEngine();
        }
        public InstructionsTreeNode(InstructionsTreeNode parent)
        {
            this.parent = parent;
            this.phraseIndex=-1;
            this.childs=new ArrayList();
            this.command=null;

            if (parent == null)
                this.level = 0;
            else
                this.level = parent.Level + 1;
        }
        public InstructionsTreeNode(int phraseIndex,InstructionsTreeNode parent,Command command=null)
        {
            this.phraseIndex = phraseIndex;
            this.parent = parent;
            this.command = null;
            this.childs = new ArrayList();

            if (parent == null)
                this.level = 0;
            else
                this.level = parent.Level + 1;
        }
 public InstructionsTree(int rootPhraseIndex=-1, Command rootCommand = null)
 {
     root = new InstructionsTreeNode(rootPhraseIndex, null, rootCommand);
 }
 public void AddChild(InstructionsTreeNode child)
 {
     child.parent = this;
     childs.Add(child);
 }
 public void ResetInstructionPipeline()
 {
     actualNode=null;
     instructionQueue.Clear();
 }
        private void InstructionFetch(int phraseIndex)
        {
            int i = 0;
            bool fetching=true;

            instructionQueue.Add(profile.phraseLibrary[phraseIndex]);

            //Si no hay una instrucción en curso, buscamos una que comience con el comando de voz captado:
            if (actualNode == null)
            {
                while (i < profile.instructionsTreeLibrary.GetLength(0) && fetching)
                {
                    if (profile.instructionsTreeLibrary[i].RootPrhaseIndex == phraseIndex)
                    {
                        actualNode = profile.instructionsTreeLibrary[i].Root;
                        fetching = false;
                    }
                    else
                        ++i;
                }

                if (actualNode != null)
                    InstructionAnalysis();
                else
                    instructionQueue.Clear();
            }
            else
            {
                actualNode = actualNode.SearchNode(phraseIndex);

                if (actualNode == null)
                {
                    LaunchRejectEvent(profile.phraseLibrary[phraseIndex]);
                    ResetInstructionPipeline();
                }
                else
                    InstructionAnalysis();
            }
        }