Ejemplo n.º 1
0
        public bool Run()
        {
            // packet keys
            PacketKey   k   = new PacketKey();
            JSONBuilder kjb = new JSONBuilder();

            kjb.closeMe();
            k.addToJSON(kjb);

            Console.WriteLine(kjb.ToString());
            Console.WriteLine("====");

            // packets
            Packet p  = new Packet(new ComData("test"));
            string sp = p.Pack();

            Console.WriteLine(sp);

            Packet p2;

            Packet.Unpack(sp, out p2);

            Console.WriteLine(p2);

            return(true);
        }
Ejemplo n.º 2
0
        public string Pack()
        {
            JSONBuilder jb = new JSONBuilder();

            Key.addToJSON(jb);
            jb.addObject("Data", Data);
            jb.closeMe();
            return(jb.ToString());
        }
Ejemplo n.º 3
0
        public bool Run()
        {
            // Cursor and Keyframes
            // too - move to unit tests
            //ArmCursor ac = new ArmCursor(Vector3.UnitX, Quaternion.Identity);
            //KeyFrame kf = new KeyFrame(ac, (float)Math.PI);
            //JSONBuilder jkf = new JSONBuilder();
            //ComData cd1 = new ComData(kf);
            //cd1.addToJSON(jkf);
            //Console.WriteLine(jkf.ToString());

            //ComData cd1b = new ComData("");
            //cd1b.fillFromJSON(new JSONDecoder(jkf.ToString()));
            //KeyFrame kf2 = new KeyFrame();
            //Console.WriteLine(cd1b.TryParse(ref kf2));

            Angle[] a =
            {
                new Angle(0.1f),
                new Angle(0.2f),
                new Angle(0.3f),
                new Angle(0.4f)
            };
            JSONBuilder           ja = new JSONBuilder();
            JSONableArray <Angle> aa = new JSONableArray <Angle>(a, (str) => { return(new Angle(float.Parse(str))); });
            ComData cd2 = new ComData(aa);

            cd2.addToJSON(ja);
            Console.WriteLine(ja.ToString());

            ComData cd2b = new ComData("");

            cd2b.fillFromJSON(new JSONDecoder(ja.ToString()));
            JSONableArray <Angle> aa2 = new JSONableArray <Angle>((str) => { return(new Angle(float.Parse(str))); });

            Console.WriteLine(cd2b.TryParse(ref aa2));

            return(true);
        }
Ejemplo n.º 4
0
        public string pack()
        {
            JSONBuilder jb = new JSONBuilder();

            jb.beginItem();

            jb.addField("flavour");
            jb.addPrimitive(flavour.ToString());

            jb.addField("key");
            key.addToJSON(jb);

            if (flavour != Flavour.ECHO)
            {
                jb.addField("data");
                data.addToJSON(jb);
            }

            jb.endItem();

            return(jb.ToString());
        }