コード例 #1
0
ファイル: DemoForm.cs プロジェクト: xusongfei/LeadChina
        private void PointTableMove()
        {
            var ptStatus = new PTSTS();
            var Line     = new PTLINE();
            var dwell    = new PTDWL();

            dwell.DwTime = 200;

            int ptbId = 0, dimension = 2;
            var axisIdArray = new[] { 0, 1 };

            //double vStart = 5000;
            //double vMax = 40000;
            //double vEnd = 5000;


            var ret = APS168.APS_pt_disable(_card0.CardId, ptbId);

            ret = APS168.APS_pt_enable(_card0.CardId, ptbId, dimension, axisIdArray);

            ret = APS168.APS_pt_set_absolute(_card0.CardId, ptbId);
            ret = APS168.APS_pt_set_trans_buffered(_card0.CardId, ptbId);
            ret = APS168.APS_pt_set_acc(_card0.CardId, ptbId, 500000);
            ret = APS168.APS_pt_set_dec(_card0.CardId, ptbId, 500000);


            foreach (DataRow row in _pointTable.Rows)
            {
                while (true)
                {
                    ret            = APS168.APS_get_pt_status(_card0.CardId, ptbId, ref ptStatus);
                    _bufFreeSpace  = ptStatus.PntBufFreeSpace;
                    _bufUsageSpace = ptStatus.PntBufUsageSpace;
                    _bufRunningCnt = (int)ptStatus.RunningCnt;
                    if (ptStatus.PntBufFreeSpace > 10)
                    {
                        //ret = APS168.APS_pt_set_vs(_card0.CardId, ptbId, vStart);
                        ret = APS168.APS_pt_set_vm(_card0.CardId, ptbId, Convert.ToDouble(row[4]));
                        ret = APS168.APS_pt_set_ve(_card0.CardId, ptbId, Convert.ToDouble(row[5]));

                        Line.Dim = dimension;
                        Line.Pos = new[] { Convert.ToDouble(row[1]), Convert.ToDouble(row[2]), 0, 0, 0, 0 };
                        ret      = APS168.APS_pt_line(_card0.CardId, ptbId, ref Line, ref ptStatus);
                        ret      = APS168.APS_pt_ext_set_do_ch(_card0.CardId, ptbId, 8, 1);
                        ret      = APS168.APS_pt_dwell(_card0.CardId, ptbId, ref dwell, ref ptStatus);
                        ret      = APS168.APS_pt_ext_set_do_ch(_card0.CardId, ptbId, 8, 0);
                        ret      = APS168.APS_pt_dwell(_card0.CardId, ptbId, ref dwell, ref ptStatus);
                        break;
                    }

                    Thread.Sleep(1);
                }
            }

            //等待buffer跑完, motionStatus的ptbFlag=false则连续运动结束。
            var ptbFlag = true;

            while (ptbFlag)
            {
                var motionStatus = APS168.APS_motion_status(axisIdArray[0]);
                ptbFlag = (motionStatus & (1 << 11)) != 0;

                ret            = APS168.APS_get_pt_status(_card0.CardId, ptbId, ref ptStatus);
                _bufFreeSpace  = ptStatus.PntBufFreeSpace;
                _bufUsageSpace = ptStatus.PntBufUsageSpace;
                _bufRunningCnt = (int)ptStatus.RunningCnt;
                Thread.Sleep(100);
            }
        }
コード例 #2
0
        private void buttonArc3_Click(object sender, EventArgs e)
        {
            var boardId = Convert.ToInt32(txtCardId.Text);

            //重置触发计数
            APS168.APS_reset_trigger_count(boardId, 0);
            APS168.APS_reset_trigger_count(boardId, 1);

            var ptbId     = 0; //Point table id 0
            var dimension = 3; //2D point table
            var ret       = 0;

            var Axis_ID_Array = new[] { 0, 1, 2 };

            var Status = new PTSTS();
            var Line   = new PTLINE();

            //Check servo on or not
            //for (i = 0; i < dimension; i++)
            //{
            //    ret = APS168.APS_set_servo_on(Axis_ID_Array, 1);
            //}
            //Thread.Sleep(500); // Wait stable.

            //Enable point table
            ret = APS168.APS_pt_disable(boardId, ptbId);
            /////////////////////////ret = APS168.APS_pt_enable(boardId, ptbId, dimension, Axis_ID_Array);
            ret = APS168.APS_pt_enable(boardId, ptbId, dimension, Axis_ID_Array);

            //Configuration
            ret = APS168.APS_pt_set_absolute(boardId, ptbId);       //Set to absolute mode
            ret = APS168.APS_pt_set_trans_buffered(boardId, ptbId); //Set to buffer mode
            ret = APS168.APS_pt_set_acc(boardId, ptbId, 5000000);   //Set acc
            ret = APS168.APS_pt_set_dec(boardId, ptbId, 5000000);   //Set dec

            ret = APS168.APS_get_pt_status(boardId, ptbId, ref Status);
            if ((Status.BitSts & 0x02) == 0) //Buffer is not Full
            {
                Line.Dim = 3;


                double vepoint = 100000;

                double Vquick = 1500000;
                double Vslow  = 300000;


                {
                    var pwdell = new PTDWL();
                    pwdell.DwTime = 2000;

                    //Line.Pos = new double[] { -206000, -20000, 0, 0, 0, 0 };
                    //ret = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    //1st line


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, Vquick);
                    Line.Pos = new double[] { -218000, -22000, 50, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //1段起始点

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, Vslow * 0.6);
                    Line.Pos = new double[] { -56000, -22000, 50, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //high


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { 114000, -22000, 50, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //low

                    if (checkBoxOnly1.Checked)
                    {
                        ret = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);
                        ret = APS168.APS_pt_start(boardId, ptbId);
                        return;
                    }

                    //圆弧线段1
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -25000, 17000, 6250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { 35000, 17000, 6250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ////2nd line
                    ////bypass


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick); //Delete by Tony
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -126000, 14000, 12450, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //2段起始点


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);  //Set vm to 10000
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //Set ve to 5000
                    Line.Pos = new double[] { 34000, 14000, 12450, 0, 0, 0 }; //触发2
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    //圆弧线段2
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -125000, 18000, 18750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -65000, 18000, 18750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);


                    //3 line slow
                    //bypass

                    //slow

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -205000, -22000, 25000, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //第3段起始点


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -95000, -22000, 25000, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);


                    //quick

                    ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);  //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick); //Set vm to 10000
                    ret = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //ret = APS168.APS_pt_set_ve(boardId, ptbId, vepointlow); //Set ve to 5000


                    //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);//ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick); //Set vm to 10000
                    //ret = APS168.APS_pt_set_ve(boardId, ptbId, Vslow * 2); //ret = APS168.APS_pt_set_ve(boardId, ptbId, vepointlow); //Set ve to 5000
                    Line.Pos = new double[] { 120000, -22000, 25000, 0, 0, 0 }; //触发3
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);


                    //圆弧线段3
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow); //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -20000, 20500, 31250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow); //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { 35000, 20500, 31250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ////4 line


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);  //Set vm to 10000
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //Set ve to 5000
                    Line.Pos = new double[] { -130000, 20000, 37600, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);   //Set vm to 10000
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //Set ve to 5000
                    Line.Pos = new double[] { 35000, 20000, 37600, 0, 0, 0 }; //触发4
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    //圆弧线段4
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -125000, 23000, 43750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -90000, 23000, 43750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);
                }

                //Push 1st point to buffer
                ret = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);
            }

            ret = APS168.APS_pt_start(boardId, ptbId);
        }
コード例 #3
0
        private void PointTableMove(double x, double y)
        {
            PTSTS  ptStatus = new PTSTS();
            PTLINE Line     = new PTLINE();
            PTDWL  dwell    = new PTDWL();

            dwell.DwTime = 200;
            int _bufTotalPoint, _bufFreeSpace, _bufUsageSpace, _bufRunningCnt;

            Int32 ptbId = 0, dimension = 2;

            int[] axisIdArray = new int[] { 0, 1 };

            double vStart = 5000;
            double vMax   = 40000;
            double vEnd   = 5000;


            int ret = APS168.APS_pt_disable(0, 0);

            ret = APS168.APS_pt_enable(0, ptbId, dimension, axisIdArray);

            ret = APS168.APS_pt_set_absolute(0, ptbId);
            ret = APS168.APS_pt_set_trans_buffered(0, ptbId);
            ret = APS168.APS_pt_set_acc(0, ptbId, 500000);
            ret = APS168.APS_pt_set_dec(0, ptbId, 500000);

            {
                {
                    ret            = APS168.APS_get_pt_status(0, ptbId, ref ptStatus);
                    _bufFreeSpace  = ptStatus.PntBufFreeSpace;
                    _bufUsageSpace = ptStatus.PntBufUsageSpace;
                    _bufRunningCnt = (int)ptStatus.RunningCnt;
                    if (ptStatus.PntBufFreeSpace > 10)
                    {
                        ret = APS168.APS_pt_set_vm(0, ptbId, 1000); //最大速度
                        ret = APS168.APS_pt_set_ve(0, ptbId, 1000); //结束速度

                        Line.Dim = dimension;
                        Line.Pos = new Double[] { x, y, 0, 0, 0, 0 };
                        ret      = APS168.APS_pt_line(0, ptbId, ref Line, ref ptStatus);
                        ret      = APS168.APS_pt_ext_set_do_ch(0, ptbId, 8, 1);
                        ret      = APS168.APS_pt_dwell(0, ptbId, ref dwell, ref ptStatus);
                        ret      = APS168.APS_pt_ext_set_do_ch(0, ptbId, 8, 0);
                        ret      = APS168.APS_pt_dwell(0, ptbId, ref dwell, ref ptStatus);
                    }
                    else
                    {
                        Thread.Sleep(1);
                    }
                }
            }
            APS168.APS_pt_start(0, 0);
            //等待buffer跑完, motionStatus的ptbFlag=false则连续运动结束。
            bool ptbFlag = true;

            while (ptbFlag)
            {
                int motionStatus = APS168.APS_motion_status(axisIdArray[0]);
                ptbFlag = (motionStatus & (1 << 11)) != 0;

                ret            = APS168.APS_get_pt_status(0, ptbId, ref ptStatus);
                _bufFreeSpace  = ptStatus.PntBufFreeSpace;
                _bufUsageSpace = ptStatus.PntBufUsageSpace;
                _bufRunningCnt = (int)ptStatus.RunningCnt;
                Thread.Sleep(100);
            }
        }