private void updateRecieved(ComData data) { if (data.isType <ArmPose>()) { pose = (ArmPose)data.value[0]; updatePoseInfo(); workerResumeEvent.Set(); } else if (data.isType <Angle>()) { servoAngles = new Angle[data.value.Length]; for (int i = 0; i < data.value.Length; i++) { servoAngles[i] = (Angle)data.value[i]; } updateAngleInfo(); } updateLabelsDelegate(infoForLabels); }
protected override void onDataRecieved(ComData data) { if (data.isType <ComRequest>()) { ComRequest req = (ComRequest)data.value[0]; if (ComRequest.isSame(req, ComRequest.POSE)) { com.sendData(pose); } else if (ComRequest.isSame(req, ComRequest.CLOSE)) { Environment.Exit(0); } else if (ComRequest.isSame(req, ComRequest.ANGLES)) { com.sendData(targetAngles); } return; } else if (data.isType <KeyFrame>()) { KeyFrame k = (KeyFrame)data.value[0]; acceptKeyFrame(k); } else if (data.isType <Angle>()) { for (int i = 0; i < data.value.Length; i++) { Angle a = (Angle)data.value[i]; targetAngles[i] += a; } } else { Console.WriteLine(data.dataType); Console.WriteLine("unk >> " + data.dataType + " : " + data.value.ToString()); } updateController(); }