示例#1
0
        public void ToSpeed(int axis, double speed, double taccel_sec, double tdecel_sec)
        {
            var pls_ms = speed / 1000.0;
            var acc_ms = speed / taccel_sec / (1000.0 * 1000.0);
            var dec_ms = speed / tdecel_sec / (1000.0 * 1000.0);
            var a      = Axis.Of(axis);

            N.GT_AxisOn(card, a).Verify();
            N.GT_ClrSts(card, a, 1).Verify();
            N.GT_PrfJog(card, a).Verify();
            Api.TJogPrm param;
            N.GT_GetJogPrm(card, a, out param).Verify();
            param.acc = acc_ms;
            param.dec = acc_ms;
            N.GT_SetJogPrm(card, a, ref param).Verify();
            N.GT_SetVel(card, a, pls_ms).Verify();
            N.GT_Update(card, a.Mask).Verify();
        }
示例#2
0
        void HomeAsync(int axis, double speed)
        {
            var a      = Axis.Of(axis);
            var pls_ms = speed / 1000.0;
            var acc_ms = (speed * 10.0) / (1000.0 * 1000.0);

            N.GT_ClrSts(card, a, 1).Verify();
            N.GT_AxisOn(card, a).Verify();
            N.GT_SetCaptureMode(card, a, Api.CAPTURE_HOME).Verify();
            N.GT_ZeroPos(card, a, 1).Verify();
            Offset(axis, -10000000, speed, 0.01, 0.01);

            Task.Run(async() =>
            {
                try
                {
                    short cap = 0;
                    int pos   = 0;
                    do
                    {
                        N.GT_GetCaptureStatus(card, a, out cap, out pos).Verify();
                        if (cap != 0)
                        {
                            N.GT_SetPos(card, a, pos).Verify();
                            N.GT_Update(card, a.Mask).Verify();
                            break;
                        }
                        await Task.Delay(1);
                    } while (!IsStop(axis));

                    while (!IsStop(axis))
                    {
                        await Task.Delay(1);
                    }

                    return(cap != 0);
                }
                catch (Exception)
                {
                    return(false);
                }
            });
        }
示例#3
0
        public void Locate(int axis, double position, double speed, double taccel_sec, double tdecel_sec)
        {
            var pls_ms = speed / 1000.0;
            var acc_ms = speed / taccel_sec / (1000.0 * 1000.0);
            var dec_ms = speed / tdecel_sec / (1000.0 * 1000.0);
            var a      = Axis.Of(axis);

            N.GT_ClrSts(card, a, 1).Verify();
            N.GT_AxisOn(card, a).Verify();
            N.GT_PrfTrap(card, a).Verify();
            Api.TTrapPrm param;
            N.GT_GetTrapPrm(card, a, out param).Verify();
            param.velStart = 0;
            param.acc      = acc_ms;
            param.dec      = dec_ms;

            N.GT_SetTrapPrm(card, a, ref param).Verify();
            N.GT_SetPos(card, a, position.Round()).Verify();
            N.GT_SetVel(card, a, pls_ms).Verify();
            N.GT_Update(card, a.Mask).Verify();
        }