Ejemplo n.º 1
0
        private void DoRTest()
        {
            MyStopWatch sw = new MyStopWatch();

            while (RTest_flag)
            {
                int pos1 = 6400 * 20 / 16;
                int time = int.Parse(Txt_RDelay.Text);
                switch (flag)
                {
                case 0:
                    headcard.PfMove(6, -(int)(pos1), int.Parse(Txt_RPf.Text), Chk_R1.Checked);
                    headcard.PfMove(7, -(int)(pos1), int.Parse(Txt_RPf.Text), Chk_R2.Checked);
                    if (Chk_R1.Checked || Chk_R2.Checked)
                    {
                        num1++;
                    }

                    sw.StartStopWatch(time);
                    flag = 1;
                    break;

                case 1:
                    if (sw.TimeUp())
                    {
                        SetRText("", num1);
                        headcard.PfMove(6, 0, int.Parse(Txt_RPf.Text), Chk_R1.Checked);
                        headcard.PfMove(7, 0, int.Parse(Txt_RPf.Text), Chk_R2.Checked);
                        if (Chk_R1.Checked || Chk_R2.Checked)
                        {
                            num1++;
                        }
                        sw.StartStopWatch(time);
                        flag = 3;
                    }
                    break;

                case 3:
                    if (sw.TimeUp())
                    {
                        SetRText("", num1);
                        Thread.Sleep(15);
                        flag = 0;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 2
0
    private int home()
    {
        HZC_Head08Card headcard = new HZC_Head08Card(1, 7);
        int            status   = 0;

        switch (home_flag)
        {
        case 0:
            headcard.SetPos(axis, 0);
            headcard.SetEncPos(axis, 0);
            if (headcard.GetAxisSensor(homesensorid) == sensorstate)
            {
                home_flag = 1;
            }
            else
            {
                home_flag = 20;
            }
            break;

        case 1:    //处于感应状态
            //headcard.PfMove(axis, pulse, 0);
            headcard.CnstMove(axis, speed1, -10000);
            home_flag = 2;
            break;

        case 2:
            int s = -1;
            s = headcard.GetAxisSensor(homesensorid);
            if (s != sensorstate)
            {
                headcard.AbortMoving(axis);
                sw.StartStopWatch(150);
                while (!sw.TimeUp())
                {
                    ;
                }
                home_flag = 3;
            }
            break;

        case 3:
            headcard.SearchForhomepos(axis, 0, 450, 300);

            sw.StartStopWatch(300);

            home_flag = 4;
            break;

        case 4:
            //if (headcard.GetStatus(axis) != 0) break;

            while (!sw.TimeUp())
            {
                ;
            }
            if (headcard.GetAxisSensor(homesensorid) == 0)
            {
                headcard.SetPos(axis, 0);
            }
            else
            {
                home_flag = 3;
                break;
            }
            home_flag = 0;
            status    = 1;
            break;

        case 20:    //未感应状态
            headcard.CnstMove(axis, speed1, 10000);
            home_flag = 21;

            break;

        case 21:
            //headcard.CnstMove(axis, 100, 1000);
            if (headcard.GetAxisSensor(homesensorid) == sensorstate)
            {
                headcard.AbortMoving(axis);
                sw.StartStopWatch(150);
                while (!sw.TimeUp())
                {
                    ;
                }
                home_flag = 1;
            }
            break;
        }
        return(status);
    }
Ejemplo n.º 3
0
        private void DoTest()
        {
            MyStopWatch sw = new MyStopWatch();

            while (Test_flag)
            {
                double pos = ZData.ZPulse * int.Parse(Txt_TestDis.Text) / ZData.Z_Thread;
                //int pos1 = 6400*20/16;
                int pf   = int.Parse(Txt_TestPf.Text);
                int time = int.Parse(Txt_DelayTime.Text);
                switch (flag)
                {
                case 0:
                    headcard.PfMove(0, -(int)pos, pf, Chk_Box1.Checked);
                    headcard.PfMove(1, -(int)pos, pf, Chk_Box2.Checked);
                    headcard.PfMove(2, -(int)pos, pf, Chk_Box3.Checked);
                    headcard.PfMove(3, -(int)pos, pf, Chk_Box4.Checked);
                    headcard.PfMove(4, -(int)pos, pf, Chk_Box5.Checked);
                    headcard.PfMove(5, -(int)pos, pf, Chk_Box6.Checked);
                    //headcard.PfMove(6, -(int)(pos1), pf, Chk_R1.Checked);
                    //headcard.PfMove(7, -(int)(pos1), pf, Chk_R2.Checked);
                    if (Chk_Box1.Checked || Chk_Box2.Checked || Chk_Box3.Checked || Chk_Box4.Checked || Chk_Box5.Checked || Chk_Box6.Checked)
                    {
                        num++;
                    }

                    sw.StartStopWatch(time);
                    flag = 1;
                    break;

                case 1:
                    if (sw.TimeUp())
                    {
                        SetText("", num);
                        headcard.PfMove(0, 0, pf, Chk_Box1.Checked);
                        headcard.PfMove(1, 0, pf, Chk_Box2.Checked);
                        headcard.PfMove(2, 0, pf, Chk_Box3.Checked);
                        headcard.PfMove(3, 0, pf, Chk_Box4.Checked);
                        headcard.PfMove(4, 0, pf, Chk_Box5.Checked);
                        headcard.PfMove(5, 0, pf, Chk_Box6.Checked);
                        //headcard.PfMove(6, 0, pf, Chk_R1.Checked);
                        //headcard.PfMove(7, 0, pf, Chk_R2.Checked);
                        if (Chk_Box1.Checked || Chk_Box2.Checked || Chk_Box3.Checked || Chk_Box4.Checked || Chk_Box5.Checked || Chk_Box6.Checked)
                        {
                            num++;
                        }
                        sw.StartStopWatch(time);
                        flag = 3;
                    }
                    break;

                case 3:
                    if (sw.TimeUp())
                    {
                        SetText("", num);
                        Thread.Sleep(15);
                        flag = 0;
                    }
                    break;
                }
            }
        }