Exemplo n.º 1
0
        private void tempOnRead(ComData raw)
        {
            switch (raw.getDataType())
            {
            case ComData.REQUEST:
                Console.WriteLine("Requst: " + raw.GetRequest().ToString());
                break;

            case ComData.STRING:
                Console.WriteLine("String : " + raw.getMessage());
                break;

            default:
                Console.WriteLine(raw.getDataType());
                break;
            }
        }
Exemplo n.º 2
0
        protected override void onComRead(ComData raw)
        {
            switch (raw.getDataType())
            {
            case ComData.REQUEST:
                Console.WriteLine("Requst: " + raw.GetRequest().ToString());
                break;

            case ComData.STRING:
                Console.WriteLine("String : " + raw.getMessage());
                break;

            case "KeyFrame":
                KeyFrame f = new KeyFrame();
                if (!raw.TryParse(ref f))
                {
                    Console.WriteLine("failed keyframe");
                    return;
                }
                driver.SetTarget(f.cursor);
                break;

            case "JSONableArray":
                JSONableArray <float> a = new JSONableArray <float>(float.Parse);
                if (!raw.TryParse(ref a))
                {
                    Console.WriteLine("failed array");
                    return;
                }

                Angle[] angles = new Angle[6];
                float[] rawF   = a.getArray();
                Array.Copy(Array.ConvertAll(rawF, (x) => { return(new Angle(x)); }),
                           2, angles, 0, angles.Length); // first 2 is time and gripper

                //Console.WriteLine("array: {0}", string.Join<Angle>(", ", angles));
                driver.SetTarget(angles);
                break;

            default:
                Console.WriteLine("defaulted with: " + raw.getDataType());
                break;
            }
        }