コード例 #1
0
        /// <summary>
        /// Point To Point Move
        /// </summary>
        /// <param name="style"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        private UInt64 ptp(byte style, float x, float y, float z, float r)
        {
            PTPCmd pdbCmd;
            UInt64 cmdIndex = 0;

            pdbCmd.ptpMode = style;
            pdbCmd.x       = x;
            pdbCmd.y       = y;
            pdbCmd.z       = z;
            pdbCmd.rHead   = r;
            while (true)
            {
                int ret = DobotDll.SetPTPCmd(ref pdbCmd, true, ref cmdIndex);
                if (ret == 0)
                {
                    break;
                }
            }

            while (true)
            {
                UInt64 retIndex = 0;
                int    ind      = DobotDll.GetQueuedCmdCurrentIndex(ref retIndex);
                if (ind == 0 && cmdIndex <= retIndex)
                {
                    break;
                }
            }

            float   waitTime = 500;
            WAITCmd waitcmd;

            waitcmd.timeout = (uint)waitTime;
            DobotDll.SetWAITCmd(ref waitcmd, false, ref cmdIndex);

            return(cmdIndex);
        }
コード例 #2
0
        // 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":
            {
                obj.IsEnabled = false;
                cmdIndex      = ptp((byte)modeStyle.SelectedIndex, x, y, z, r);
                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":
            {
                cmdIndex = cp((byte)ContinuousPathMode.CPAbsoluteMode, x, y, z, 100);
                while (true)
                {
                    UInt64 retIndex = 0;
                    int    ind      = DobotDll.GetQueuedCmdCurrentIndex(ref retIndex);
                    if (ind == 0 && cmdIndex <= retIndex)
                    {
                        obj.IsEnabled = true;
                        break;
                    }
                }
            } break;

            default:
                break;
            }
        }