private UInt64 cp(byte mod, float x, float y, float z, float velocity) { CPCmd pdbCmd; UInt64 cmdIndex = 0; pdbCmd.cpMode = mod; pdbCmd.x = x; pdbCmd.y = y; pdbCmd.z = z; pdbCmd.velocity = velocity; while (true) { int ret = DobotDll.SetCPCmd(ref pdbCmd, true, ref cmdIndex); if (ret == 0) { break; } } return(cmdIndex); }
// event handle private void ProcessEvt(object sender, EventArgs e) { if (!isConnectted) { return; } Button obj = (Button)sender; String con = obj.Content.ToString(); UInt64 cmdIndex = 0; float x, y, z, r, gripper, pTime; if (!float.TryParse(X.Text, out x) || !float.TryParse(Y.Text, out y) || !float.TryParse(Z.Text, out z) || !float.TryParse(rHead.Text, out r) || !float.TryParse(isGripper.Text, out gripper) || !float.TryParse(pauseTime.Text, out pTime)) { Msg("Please input float formate", MsgInfoType.Error); return; } Msg("", MsgInfoType.Info); switch (con) { case "SendPlaybackCmd": { PTPCmd pdbCmd; obj.IsEnabled = false; pdbCmd.ptpMode = (byte)modeStyle.SelectedIndex; pdbCmd.x = x; pdbCmd.y = y; pdbCmd.z = z; pdbCmd.rHead = r; int ret = DobotDll.SetPTPCmd(ref pdbCmd, true, ref cmdIndex); while (true) { UInt64 retIndex = 0; int ind = DobotDll.GetQueuedCmdCurrentIndex(ref retIndex); if (ind == 0 && cmdIndex <= retIndex) { obj.IsEnabled = true; break; } } float waitTime = 0; if (float.TryParse(pauseTime.Text, out waitTime) && waitTime > 0) { WAITCmd waitcmd; waitcmd.timeout = (uint)waitTime; DobotDll.SetWAITCmd(ref waitcmd, false, ref cmdIndex); } } break; case "SendCPCmd": { CPCmd cpCmd; cpCmd.x = x; cpCmd.y = y; cpCmd.z = z; cpCmd.velocity = 100; cpCmd.cpMode = (byte)ContinuousPathMode.CPAbsoluteMode; int ret = DobotDll.SetCPCmd(ref cpCmd, true, ref cmdIndex); while (true) { UInt64 retIndex = 0; int ind = DobotDll.GetQueuedCmdCurrentIndex(ref retIndex); if (ind == 0 && cmdIndex <= retIndex) { obj.IsEnabled = true; break; } } } break; default: break; } }