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; } }