Ejemplo n.º 1
0
        private string getHandsXML()
        {
            LRValues handsConf    = getHands();
            string   handsConfXML = ComUtils.XmlUtils.Serialize <LRValues>(handsConf);

            return(handsConfXML);
        }
Ejemplo n.º 2
0
        private void ReceivePosture()
        {
            while (true)
            {
                if (iclipsControl)
                {
                    string data = "";
                    yarpPortPosture.receivedData(out data);
                    Console.WriteLine(data);
                    if (data.Length > 2)
                    {
                        data = data.Substring(1, data.Length - 2);   // remove first and last char from data, yarp puts the message in quotes ""
                    }
                    if (iclipsControl && data != null && data != "") //
                    {
                        if (File.Exists(System.IO.Path.Combine(postureDir, data + ".xml")))
                        {
                            if (handsAvailable)
                            {
                                string   handsConfXML = File.ReadAllText(System.IO.Path.Combine(postureDir, data + ".xml"), System.Text.Encoding.UTF8);
                                LRValues posture      = ComUtils.XmlUtils.Deserialize <LRValues>(handsConfXML);

                                handsAvailable = false;
                                setHands(posture);
                                handsAvailable = true;
                            }
                        }
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(500);
                }
            }
        }
Ejemplo n.º 3
0
        private void ReceiveHands()
        {
            while (true)
            {
                if (leapControl)
                {
                    string data = "";
                    yarpPortHands.receivedData(out data);

                    if (data.Length > 2)
                    {
                        data = data.Substring(1, data.Length - 2); // remove first and last char from data, yarp puts the message in quotes ""
                    }
                    if (leapControl && data != null && data != "")
                    {
                        LRValues handsConfiguration = ComUtils.XmlUtils.Deserialize <LRValues>(data);
                        setHands(handsConfiguration);
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(500);
                }
            }
        }
Ejemplo n.º 4
0
        private void LoadPosture(object sender, RoutedEventArgs e)
        {
            var dialog = new FileListDialog(0);

            if (dialog.ShowDialog() == true)
            {
                string   postureName  = dialog.ResponseText;
                string   handsConfXML = File.ReadAllText(System.IO.Path.Combine(postureDir, postureName + ".xml"), System.Text.Encoding.UTF8);
                LRValues posture      = ComUtils.XmlUtils.Deserialize <LRValues>(handsConfXML);
                setHands(posture);
            }
        }
Ejemplo n.º 5
0
        private LRValues getHands()
        {
            LRValues ret;

            lock (rightValues)
            {
                lock (leftValues)
                {
                    ret = new LRValues(0, rightValues, leftValues);
                }
            }
            return(ret);
        }
Ejemplo n.º 6
0
        private void ReceiveGesture()
        {
            while (true)
            {
                if (iclipsControl)
                {
                    string data = "";
                    yarpPortGesture.receivedData(out data);
                    Console.WriteLine(data);
                    if (data.Length > 2)
                    {
                        data = data.Substring(1, data.Length - 2); // remove first and last char from data, yarp puts the message in quotes ""
                    }
                    if (iclipsControl && data != null && data != "")
                    {
                        Console.WriteLine(data);
                        Console.WriteLine("control");
                        if (File.Exists(System.IO.Path.Combine(gestureDir, data + ".xml")))
                        {
                            Console.WriteLine("trovato file");
                            if (handsAvailable)
                            {
                                string   readText = File.ReadAllText(System.IO.Path.Combine(gestureDir, data + ".xml"), System.Text.Encoding.UTF8);
                                string[] lines    = readText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                int line = 0;
                                handsAvailable = false;
                                while (line < lines.Length - 3)
                                {
                                    Console.WriteLine("linea");
                                    LRValues gestFrame = ComUtils.XmlUtils.Deserialize <LRValues>(lines[line]);
                                    setHands(gestFrame);
                                    System.Threading.Thread.Sleep(timeDelta);
                                    line += 1;
                                }
                                handsAvailable = true;
                                Console.WriteLine("finito");
                            }
                        }
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(500);
                }
            }
        }
Ejemplo n.º 7
0
        private void setHands(LRValues handsConf)
        {
            for (int i = 0; i < 9; i++)
            {
                float leftValue  = handsConf.LeftValues[i];
                float rightValue = handsConf.RightValues[i];

                if (leftValue >= 0 && leftValue <= 1)
                {
                    this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background,
                                           new Action(() => ((Slider)this.FindName(String.Format("sldLH{0}", i + 1))).Value = leftValue));
                }

                if (rightValue >= 0 && rightValue <= 1)
                {
                    this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background,
                                           new Action(() => ((Slider)this.FindName(String.Format("sldRH{0}", i + 1))).Value = rightValue));
                }
            }
        }
Ejemplo n.º 8
0
        private void LoadGesture(object sender, RoutedEventArgs e)
        {
            var dialog = new FileListDialog(1);

            if (dialog.ShowDialog() == true)
            {
                spControl.IsEnabled = false;
                string   gestureName = dialog.ResponseText;
                string   readText    = File.ReadAllText(System.IO.Path.Combine(gestureDir, gestureName + ".xml"), System.Text.Encoding.UTF8);
                string[] lines       = readText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                int line = 0;

                while (line < lines.Length - 3)
                {
                    LRValues gestFrame = ComUtils.XmlUtils.Deserialize <LRValues>(lines[line]);
                    setHands(gestFrame);
                    System.Threading.Thread.Sleep(timeDelta);
                    line += 1;
                }
                spControl.IsEnabled = true;
            }
        }