Exemplo n.º 1
0
        /// <summary>
        /// 单轴绝对运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_AbsoluteMove(AxisConfig axisC, PointModule point)
        {
            short shrResult = 0;

            if (point.dblPonitSpeed == 0.0)
            {
                MessageBoxLog.Show(axisC.AxisName + "速度设置位0,急停请设置");
                return(-1);
            }

            if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
            {
                return(-1);
            }
            LTDMC.dmc_set_s_profile((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, 0, point.db_S_Time);                                                                          //设置S段时间(0-0.05s)
            LTDMC.dmc_set_profile((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, axisC.StartSpeed, point.dblPonitSpeed, point.db_StopSpeed, point.dblAccTime, point.dblDecTime); //设置起始速度、运行速度、停止速度、加速时间、减速时间
            shrResult = LTDMC.dmc_pmove((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, (int)(point.dblPonitValue * axisC.Eucf), 1);                                              //定长运动


            if (shrResult != shrGtsSuccess)
            {
                CommandResult("_SR_RelativeMove", shrResult);
                return(shrFail);
            }
            return(shrResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 单轴相对运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_RelativeMove(AxisConfig axisC, PointModule point)
        {
            short shrResult = 0;

            if (point.dblPonitSpeed == 0.0)
            {
                MessageBoxLog.Show(axisC.AxisName + "速度设置位0,急停请设置");
                return(-1);
            }
            if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
            {
                return(-1);
            }

            Dmc1000.d1000_set_s_profile(axisC.CardNum * tag_AxisCount + axisC.AxisNum, point.db_S_Time);            //设置S段时间(0-0.05s)
            // Dmc1000.d1000_set_profile((ushort)axisC.CardNum, (ushort)axisC.AxisNum, dblPonitSpeed.StartSpeed, point.dblPonitSpeed, point.db_StopSpeed, point.dblAccTime, point.dblDecTime);//设置起始速度、运行速度、停止速度、加速时间、减速时间
            shrResult = (short)Dmc1000.d1000_start_t_move(axisC.CardNum * tag_AxisCount + axisC.AxisNum,
                                                          (int)(point.dblPonitValue * axisC.Eucf), (int)point.dblPonitStartSpeed, (int)point.dblPonitSpeed, point.dblAcc);//定长运动


            if (shrResult != shrGtsSuccess)
            {
                CommandResult("_SR_RelativeMove", shrResult);
                return(shrFail);
            }
            return(shrResult);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 单轴连续运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            adt8960m.adt8960_set_startv(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblPonitStartSpeed); //
            adt8960m.adt8960_set_speed(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblPonitSpeed);       //
            adt8960m.adt8960_set_acc(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblAcc);                //

            return((short)adt8960m.adt8960_continue_move(axisC.CardNum, axisC.AxisNum + 1, dir));
        }
Exemplo n.º 4
0
 public PointAggregate(string stationName, string pointName)
 {
     strName        = pointName;
     strStationName = stationName;
     arrPoint       = new PointModule[StationManage.intStationAxisCount];
     for (int i = 0; i < StationManage.intStationAxisCount; i++)
     {
         arrPoint[i] = new PointModule();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 单轴连续运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            int ddir = 1;

            if (dir == 1)
            {
                ddir = -1;
            }
            return((short)Dmc1000.d1000_start_sv_move(axisC.CardNum * tag_AxisCount + axisC.AxisNum, (int)point.dblPonitStartSpeed,
                                                      (int)point.dblPonitSpeed * ddir, point.dblAccTime));//连续运动
        }
Exemplo n.º 6
0
        /// <summary>
        /// 寻找原点,一次寻找pos1 ,
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short HomeFindHomeSinge(AxisConfig axisC, int pos1)
        {
            short       shrResult = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed);

            point.dblPonitValue = pos1;
            shrResult           = SR_RelativeMove(axisC, point);
            if (shrResult != 0)
            {
                return(-1);
            }
            Thread.Sleep(10);
            while (true)
            {
                if (WorkBase.IsRestExit())
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-1);
                }

                SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);                         //采集原点信号

                if (!axisC.tag_homeIoHighLow)                                                              //如果信号位高电平
                {
                    if (!pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));                                      //停止轴
                        return(0);
                    }
                }
                else
                {
                    if (pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }

                if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-2);
                }
                if (AxisState == 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-3);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 寻找原点,一次寻找pos1 ,
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short HomeFindHomeSinge(AxisConfig axisC, int pos1)
        {
            short       shrResult = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule();

            point.dblPonitSpeed = axisC.Speed;
            point.dblAcc        = axisC.Acc;
            point.dblDec        = axisC.Dec;
            point.dblDec        = axisC.tag_accTime;
            point.dblPonitValue = pos1;
            shrResult           = _SR_RelativeMove(axisC, point);
            if (shrResult != 0)
            {
                CommandResult("_SR_RelativeMove", shrResult);
                return(1);
            }
            Thread.Sleep(10);
            while (true)
            {
                _SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);

                if (!axisC.tag_homeIoHighLow)
                {
                    if (!pIo)
                    {
                        _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }
                else
                {
                    if (pIo)
                    {
                        _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }

                if (_SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(3);
                }
                Thread.Sleep(1);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 单轴连续运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            if (dir == 0)
            {
                dir = 1;
            }
            else
            {
                dir = 0;
            }
            LTDMC.dmc_set_s_profile((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, 0, point.db_S_Time);                                                                          //设置S段时间(0-0.05s)
            LTDMC.dmc_set_profile((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, axisC.StartSpeed, point.dblPonitSpeed, point.db_StopSpeed, point.dblAccTime, point.dblDecTime); //设置起始速度、运行速度、停止速度、加速时间、减速时间
            short ret = LTDMC.dmc_vmove((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, (ushort)dir);                                                                             //连续运动

            return(ret);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 运行第二段距离
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short HomeMoveTwoDis(AxisConfig axisC)
        {
            short       shrResult = 0;
            int         AxisState = 0;
            PointModule point     = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed);

            point.dblPonitValue = axisC.intSecondFindOriginDis;
            if (axisC.HomeDir == 0)
            {
                point.dblPonitValue = 0 - point.dblPonitValue;
            }

            shrResult = SR_RelativeMove(axisC, point);             //单轴的相对运动
            if (shrResult != 0)
            {
                return(-1);
            }
            if (point.dblPonitValue == 0)
            {
                return(-1);
            }
            Thread.Sleep(10);

            while (true)
            {
                if (WorkBase.IsRestExit())
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-1);
                }

                if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(0);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 单轴连续运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
            {
                return(-1);
            }
            int ddir = 1;

            if (dir == 1)
            {
                ddir = -1;
            }
            int   speed = (int)point.dblPonitSpeed * ddir;
            int   dblPonitStartSpeed = (int)point.dblPonitStartSpeed * ddir;
            short ret = (short)Dmc1000.d1000_start_sv_move(axisC.CardNum * tag_AxisCount + axisC.AxisNum, (int)dblPonitStartSpeed,
                                                           (int)speed, point.dblAccTime);

            return(ret);           //连续运动
        }
Exemplo n.º 11
0
        /// <summary>
        /// 单轴绝对运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_AbsoluteMove(AxisConfig axisC, PointModule point)
        {
            short shrResult = 0;

            if (point.dblPonitStartSpeed == 0.0)
            {
                MessageBoxLog.Show(axisC.AxisName + "速度设置位0,急停请设置");
                return(-1);
            }

            adt8960m.adt8960_set_startv(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblPonitStartSpeed); //
            adt8960m.adt8960_set_speed(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblPonitSpeed);       //
            adt8960m.adt8960_set_acc(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblAcc);                //

            shrResult = (short)adt8960m.adt8960_symmetry_absolute_move(axisC.CardNum, axisC.AxisNum + 1, (int)(point.dblPonitValue * axisC.Eucf), (int)axisC.StartSpeed, (int)point.dblPonitSpeed, (int)point.dblAccTime, (int)point.dblAcc, 1);
            if (shrResult != shrGtsSuccess)
            {
                CommandResult("adt8960_symmetry_relative_move", shrResult);
                return(shrFail);
            }
            return(shrResult);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 单轴绝对运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public static short SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            short shrResult = 0;

            if (point.dblPonitSpeed == 0)
            {
                MessageBoxLog.Show(axisC.AxisName + "速度设置位0,急停请设置");
                return(-1);
            }
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            shrResult = Base_.SR_continue_move(axisC, point, dir);
            if (shrResult != shrGtsSuccess)
            {
                return(shrFail);
            }
            return(shrSuccess);
        }
Exemplo n.º 13
0
        public short HomeFindOneHomeIO(AxisConfig axisC)
        {
            short       shrResult = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule(true, false, 0, axisC.HomeSpeed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed);

            point.dblPonitValue = axisC.intThreeFindOriginDis;

            shrResult = SR_RelativeMove(axisC, point);
            if (shrResult != 0)
            {
                return(-1);
            }

            while (true)
            {
                if (WorkBase.IsRestExit())
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-1);
                }
                SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                if (axisC.tag_homeIoHighLow)
                {
                    if (pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        shrResult = 0;
                        break;
                    }
                }
                else
                {
                    if (!pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        shrResult = 0;
                        break;
                    }
                }
                if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(3);
                }
                Thread.Sleep(1);
            }

            SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
            Thread.Sleep(1000);
            int countzeor = 30;

            while (countzeor >= 0)
            {
                if (WorkBase.IsRestExit())
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-1);
                }
                int   status = 0;
                short r      = SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out status);
                if (r != 0)
                {
                    return(-1);
                }
                if (status == 0)
                {
                    break;
                }
            }

            while (countzeor >= 0)
            {
                double pos = 0;
                double Enc = 0;

                Thread.Sleep(1000);

                SR_GetPrfPos(axisC.CardNum, (short)(axisC.AxisNum), ref pos);
                SR_GetEncPos(axisC.CardNum, (short)(axisC.AxisNum), ref Enc);
                SR_SetPrfPos(axisC.CardNum, (short)(axisC.AxisNum), 0);
                SR_SetEncPos(axisC.CardNum, (short)(axisC.AxisNum), 0);
                SR_GetPrfPos(axisC.CardNum, (short)(axisC.AxisNum), ref pos);
                SR_GetEncPos(axisC.CardNum, (short)(axisC.AxisNum), ref Enc);

                if (pos < 5 && pos > -5 && Enc < 5 && Enc > -5)
                {
                    return(0);
                }

                countzeor--;
                Thread.Sleep(10);
            }
            if (countzeor >= 0)
            {
                return(0);
            }

            return(-1);
        }
Exemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short HomeFindLimit(AxisConfig axisC)
        {
            short       shrResult = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed);

            if (axisC.HomeDir == 1)                                    //回零方向,默认为0
            {
                point.dblPonitValue = 0 - axisC.intFirstFindOriginDis; //第一次找原点距离
            }
            else
            {
                point.dblPonitValue = axisC.intFirstFindOriginDis;
            }

            if (axisC.HomeDir == 0)
            {
                SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);                 //获取正限输入状态
            }
            else
            {
                SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);                //获取负限输入状态
            }

            if (axisC.tag_IoLimtPNHighEnable == 0)             //正负限位高电平有效
            {
                if (!pIo)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(0);
                }
            }
            else
            {
                if (pIo)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(0);
                }
            }

            shrResult = SR_RelativeMove(axisC, point);             //单轴的相对运动

            if (shrResult != 0)
            {
                CommandResult("_SR_AbsoluteMove", shrResult);
                return(-1);
            }
            Thread.Sleep(10);

            while (true)
            {
                if (WorkBase.IsRestExit())
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-1);
                }

                if (axisC.HomeDir == 0)
                {
                    SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                }

                else
                {
                    SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                }
                if (axisC.tag_IoLimtPNHighEnable == 0)
                {
                    if (!pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }
                else
                {
                    if (pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }

                if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    if (axisC.HomeDir == 0)
                    {
                        SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                    }

                    else
                    {
                        SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                    }
                    if (axisC.tag_IoLimtPNHighEnable == 0)
                    {
                        if (!pIo)
                        {
                            SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                            return(0);
                        }
                    }
                    else
                    {
                        if (pIo)
                        {
                            SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                            return(0);
                        }
                    }
                    return(3);
                }
            }
        }
Exemplo n.º 15
0
        public short HomeFindHomeIO(AxisConfig axisC)
        {
            short shrResult = 0;
            bool  pIo       = false;
            int   AxisState = 0;
            int   pos       = 0;

            if (axisC.HomeDir == 0)
            {
                pos = 0 - pos;
            }



            PointModule point = new PointModule();

            point.dblPonitSpeed = axisC.HomeSpeed;
            point.dblAcc        = axisC.Acc;
            point.dblDec        = axisC.Dec;
            point.dblDec        = axisC.tag_accTime;
            point.dblPonitValue = pos;
            shrResult           = _SR_RelativeMove(axisC, point);

            if (shrResult != 0)
            {
                CommandResult("_SR_RelativeMove", shrResult);
                return(1);
            }
            while (true)
            {
                _SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                if (axisC.tag_homeIoHighLow)
                {
                    if (pIo)
                    {
                        _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        shrResult = 0;
                        break;
                    }
                }
                else
                {
                    if (!pIo)
                    {
                        _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        shrResult = 0;
                        break;
                    }
                }
                if (_SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(3);
                }
                Thread.Sleep(1);
            }

            _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
            Thread.Sleep(700);
            shrResult = mc.GT_ZeroPos(axisC.CardNum, axisC.AxisNum, 1);
            if (shrResult != shrGtsSuccess)
            {
                CommandResult("GT_ZeroPos", shrResult);
                return(shrFail);
            }
            return(shrResult);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 单轴连续运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            short shrResult;

            mc.TJogPrm jog;
            //if (axisC.AxisNum == 4)
            //{
            //    _SR_SetOutputBit(0, 15, 1);//R轴动前关刹车
            //}
            shrResult = mc.GT_PrfJog(axisC.CardNum, axisC.AxisNum);
            if (shrResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfJog", shrResult);
                return(shrFail);
            }
            shrResult = mc.GT_GetJogPrm(axisC.CardNum, (short)(axisC.AxisNum), out jog);
            if (shrResult != shrGtsSuccess)
            {
                CommandResult("GT_GetJogPrm", shrResult);
                return(shrFail);
            }
            //jog.acc = axisC.Acc;
            //jog.dec = axisC.Dec;
            jog.acc    = point.dblAcc;
            jog.dec    = point.dblDec;
            jog.smooth = 0;
            shrResult  = mc.GT_SetJogPrm(axisC.CardNum, (short)(axisC.AxisNum), ref jog);
            if (shrResult != shrGtsSuccess)
            {
                CommandResult("GT_SetJogPrm", shrResult);
                return(shrFail);
            }
            if (dir == 0)
            {
                shrResult = mc.GT_SetVel(axisC.CardNum, (short)(axisC.AxisNum), point.dblPonitSpeed / 1000);
            }
            else
            {
                shrResult = mc.GT_SetVel(axisC.CardNum, (short)(axisC.AxisNum), -point.dblPonitSpeed / 1000);
            }


            if (shrResult != shrGtsSuccess)
            {
                CommandResult("GT_SetVel", shrResult);
                return(shrFail);
            }
            shrResult = mc.GT_ClrSts(axisC.CardNum, (short)(axisC.AxisNum), 1);
            if (shrResult != shrGtsSuccess)
            {
                CommandResult("GT_ClrSts", shrResult);
                return(shrFail);
            }
            shrResult = mc.GT_Update(axisC.CardNum, 1 << (axisC.AxisNum - 1));
            if (shrResult != shrGtsSuccess)
            {
                CommandResult("GT_Update", shrResult);
                return(shrFail);
            }
            return(0);
        }
Exemplo n.º 17
0
        //往下移动
        private void Jog_minusBT_MouseDown(object sender, MouseEventArgs e)
        {
            if (!Work.IsMove(1))
            {
                return;
            }
            setspeed();
            if (arrAxis == null)
            {
                MessageBoxLog.Show("");
                return;
            }
            double pos = 0;

            if (arrAxis.SoftLimitEnablel == 0)
            {
                pos = arrAxis.SoftLimitMaxValue;
            }
            else
            {
                pos = -1000;
            }

            if (StationManage.Distancemode == "短距")
            {
                nowpset = StationManage.Shortdistanceset;

                /* if (!AxisSafeManage.AxisIsSafe(tag_work._Config.tag_safeStationModule, arrAxis, 0, (nowpoint - nowpset) * arrAxis.Eucf))
                 * {
                 *       return;
                 * }*/
                PointModule _pointModule = new PointModule();
                _pointModule.dblAcc             = arrAxis.Acc;
                _pointModule.blnPointEnable     = true;                     //表示点位是否启用
                _pointModule.blnIsSpecialPoint  = true;                     //表示此点位是否是特殊点位 方便对应轴速度快速改变
                _pointModule.dblPonitValue      = nowpoint - nowpset;       //点位数据
                _pointModule.dblPonitSpeed      = StationManage.Speedvalue; //点位速度
                _pointModule.dblAcc             = arrAxis.Acc;              //加速度
                _pointModule.dblDec             = arrAxis.Dec;              //减速度
                _pointModule.dblAccTime         = arrAxis.tag_accTime;      //加速时间
                _pointModule.dblDecTime         = arrAxis.tag_accTime;      //减速时间
                _pointModule.dblPonitStartSpeed = arrAxis.StartSpeed;       //初始速度
                _pointModule.db_S_Time          = arrAxis.tag_S_Time;       //初始速度
                resutl = NewCtrlCardV0.SR_AbsoluteMove(arrAxis, _pointModule);
                if (resutl != 0)
                {
                    MessageBoxLog.Show("轴运动异常");
                }
            }
            else
            {
                if (StationManage.Distancemode == "长距")
                {
                    nowpset = StationManage.Longdistanceset;

                    /*  if (!AxisSafeManage.AxisIsSafe(tag_work._Config.tag_safeStationModule, arrAxis, 0, (nowpoint - nowpset) * arrAxis.Eucf))
                     * {
                     *        return;
                     * }*/
                    PointModule _pointModule = new PointModule();
                    _pointModule.dblAcc             = arrAxis.Acc;
                    _pointModule.blnPointEnable     = true;                     //表示点位是否启用
                    _pointModule.blnIsSpecialPoint  = true;                     //表示此点位是否是特殊点位 方便对应轴速度快速改变
                    _pointModule.dblPonitValue      = nowpoint - nowpset;       //点位数据
                    _pointModule.dblPonitSpeed      = StationManage.Speedvalue; //点位速度
                    _pointModule.dblAcc             = arrAxis.Acc;              //加速度
                    _pointModule.dblDec             = arrAxis.Dec;              //减速度
                    _pointModule.dblAccTime         = arrAxis.tag_accTime;      //加速时间
                    _pointModule.dblDecTime         = arrAxis.tag_accTime;      //减速时间
                    _pointModule.dblPonitStartSpeed = arrAxis.StartSpeed;       //初始速度
                    _pointModule.db_S_Time          = arrAxis.tag_S_Time;       //初始速度
                    resutl = NewCtrlCardV0.SR_AbsoluteMove(arrAxis, _pointModule);
                    if (resutl != 0)
                    {
                        MessageBoxLog.Show("轴运动异常");
                    }
                }
                else
                {
                    /*   if (!AxisSafeManage.AxisIsSafe(tag_work._Config.tag_safeStationModule, arrAxis, 0, (nowpoint + nowpset) * arrAxis.Eucf))
                     * {
                     *         return;
                     * }*/
                    PointModule _pointModule = new PointModule();
                    _pointModule.dblAcc             = arrAxis.Acc;
                    _pointModule.blnPointEnable     = true;                     //表示点位是否启用
                    _pointModule.blnIsSpecialPoint  = true;                     //表示此点位是否是特殊点位 方便对应轴速度快速改变
                    _pointModule.dblPonitValue      = nowpoint - 6000;          //点位数据
                    _pointModule.dblPonitSpeed      = StationManage.Speedvalue; //点位速度
                    _pointModule.dblAcc             = arrAxis.Acc;              //加速度
                    _pointModule.dblDec             = arrAxis.Dec;              //减速度
                    _pointModule.dblAccTime         = arrAxis.tag_accTime;      //加速时间
                    _pointModule.dblDecTime         = arrAxis.tag_accTime;      //减速时间
                    _pointModule.dblPonitStartSpeed = arrAxis.StartSpeed;       //初始速度
                    _pointModule.db_S_Time          = arrAxis.tag_S_Time;       //初始速度
                    resutl = NewCtrlCardV0.SR_continue_move(arrAxis, _pointModule, 1);
                    if (resutl != 0)
                    {
                        MessageBoxLog.Show("轴运动异常");
                    }
                }
            }
        }
Exemplo n.º 18
0
        public short HomeFindOneHomeIO(AxisConfig axisC)
        {
            short       shrResult = 0;
            int         Isfined   = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule(true, false, 0, axisC.HomeSpeed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed);

            point.dblPonitValue = axisC.intThreeFindOriginDis;

            shrResult = SR_RelativeMove(axisC, point);
            if (shrResult == 1)
            {
                return(1);
            }

            while (true)
            {
                SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                if (axisC.tag_homeIoHighLow)
                {
                    if (pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        shrResult = 0;
                        break;
                    }
                }
                else
                {
                    if (!pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        shrResult = 0;
                        break;
                    }
                }
                if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(3);
                }
                Thread.Sleep(1);
            }

            SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
            Thread.Sleep(100);
            if (SR_SetPrfPos(axisC.CardNum, (short)(axisC.AxisNum), 0) != 0)
            {
                return(4);
            }

            if (SR_SetEncPos(axisC.CardNum, (short)(axisC.AxisNum), 0) != 0)
            {
                return(5);
            }
            return(shrResult);
        }
Exemplo n.º 19
0
        public short HomeFindLimit(AxisConfig axisC)
        {
            short       shrResult = 0;
            int         Isfined   = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed);

            if (axisC.HomeDir == 1)
            {
                point.dblPonitValue = 0 - axisC.intFirstFindOriginDis;
            }
            else
            {
                point.dblPonitValue = axisC.intFirstFindOriginDis;
            }
            if (axisC.HomeDir == 0)
            {
                SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
            }

            else
            {
                SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
            }
            if (axisC.tag_IoLimtPNHighEnable == 0)
            {
                if (!pIo)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(0);
                }
            }
            else
            {
                if (pIo)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(0);
                }
            }

            shrResult = SR_RelativeMove(axisC, point);

            if (shrResult != 0)
            {
                CommandResult("_SR_AbsoluteMove", shrResult);
                return(1);
            }
            Thread.Sleep(10);
            while (true)
            {
                if (axisC.HomeDir == 0)
                {
                    SR_GetLimitPInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                }

                else
                {
                    SR_GetLimitNInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);
                }
                if (axisC.tag_IoLimtPNHighEnable == 0)
                {
                    if (!pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }
                else
                {
                    if (pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }

                if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(3);
                }
                Thread.Sleep(1);
            }
            SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
            return(4);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 单轴绝对运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_AbsoluteMove(AxisConfig axisC, PointModule point)
        {
            short card = axisC.CardNum;
            short axis = axisC.AxisNum;
            //if (axis == 4)
            //{
            //    _SR_SetOutputBit(0, 15, 1);//R轴动前关刹车
            //}
            short sResult;
            int   ipos;

            sResult = mc.GT_Stop(card, 1 << (axis - 1), 0);
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }

            //设置为点位模试
            sResult = mc.GT_PrfTrap(card, axis);
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            mc.TTrapPrm tprm;
            //读取点位运动参数
            sResult = mc.GT_GetTrapPrm(card, axis, out tprm);
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            tprm.acc        = (point.dblPonitSpeed / 1000) / axisC.AccTime;
            tprm.dec        = (point.dblPonitSpeed / 1000) / axisC.DecTime;
            tprm.smoothTime = 0;
            //设置点位运动参数
            sResult = mc.GT_SetTrapPrm(card, axis, ref tprm);
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            sResult = mc.GT_ClrSts(card, axis, 1);
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            sResult = mc.GT_ClrSts(card, axis, 1);            //1001 09
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            sResult = mc.GT_GetPos(card, axis, out ipos);
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            //设置目标位置
            //ipos = ipos + postion;
            sResult = mc.GT_SetPos(card, axis, (int)(point.dblPonitValue * axisC.Eucf));
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            //设置轴运动速度
            sResult = mc.GT_SetVel(card, axis, point.dblPonitSpeed / 1000);            //
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            //启动轴运动
            sResult = mc.GT_Update(card, 1 << (axis - 1));
            if (sResult != shrGtsSuccess)
            {
                CommandResult("GT_PrfTrap", sResult);
                return(shrFail);
            }
            return(shrGtsSuccess);
        }
Exemplo n.º 21
0
        //初始化组件
        public void Init()
        {
            try
            {
                if (_PointSet != null)
                {
                    label_Step.Text = tag_stepName.ToString();

                    if (_PointSet.tag_isWait == 0)
                    {
                        checkBox_wait.Checked = false;
                    }
                    else
                    {
                        checkBox_wait.Checked = true;
                    }
                    textBox_name.Text       = _PointSet.strName;
                    checkBox_Enable.Checked = _PointSet.tag_isEnable;

                    checkBox_AxisStop.Checked = _PointSet.tag_isAxisStop;
                    if (_PointSet.tag_motionType == 0)
                    {
                        comboBox2.SelectedIndex = 0;
                    }
                    else
                    {
                        comboBox2.SelectedIndex = 1;
                    }
                    if (_PointSet.tag_MotionLineType == 0)
                    {
                        comboBox_Line.SelectedIndex = 0;
                    }
                    else
                    {
                        comboBox_Line.SelectedIndex = 1;
                    }


                    if (_PointSet.tag_isRest == 1)
                    {
                        checkBox_AxisRest.Checked = true;
                    }
                    else
                    {
                        checkBox_AxisRest.Checked = false;
                    }
                    textBox_Sleep.Text = _PointSet.tag_Sleep.ToString();
                    int ww = 5;
                    comboBox_delectAdd.Location = new Point(30, (this.Size.Height - textBox_name.Size.Height) / 2);

                    textBox_name.Location = new Point(comboBox_delectAdd.Location.X + comboBox_delectAdd.Size.Width + ww, (this.Size.Height - textBox_name.Size.Height) / 2);
                    int x = textBox_name.Location.X + textBox_name.Size.Width + ww;



                    int x2 = x;
                    if (_PointSet.arrPoint.Length < tag_stationM.arrAxis.Count)
                    {
                        PointModule[] arrPoint = new PointModule[tag_stationM.arrAxis.Count];

                        int mm = 0;
                        for (mm = 0; mm < _PointSet.arrPoint.Length; mm++)
                        {
                            arrPoint[mm] = _PointSet.arrPoint[mm];
                        }
                        for (mm = 0; mm < tag_stationM.arrAxis.Count; mm++)
                        {
                            arrPoint[mm] = new PointModule();;
                        }
                        _PointSet.arrPoint = arrPoint;
                    }
                    int i = 0;
                    for (i = 0; i < tag_stationM.arrAxis.Count; i++)
                    {
                        // if (_PointSet.arrPoint[i].blnPointEnable)
                        {
                            TextBox tex = null;
                            if (tag_textobj[i] == null)
                            {
                                tex = new TextBox();
                                this.Controls.Add(tex);
                            }
                            else
                            {
                                tex = (TextBox)tag_textobj[i];
                            }
                            tex.Text     = _PointSet.arrPoint[i].dblPonitValue.ToString();
                            tex.Size     = new Size(40, 20);
                            tex.Location = new Point(x2 + ww * i + tex.Size.Width * i,
                                                     (this.Size.Height - tex.Size.Height) / 2);
                            x = tex.Location.X;
                            tag_textobj[i] = tex;

                            if (!_PointSet.arrPoint[i].blnPointEnable)
                            {
                                tex.BackColor = Color.White;
                                tex.ForeColor = Color.Black;
                                tex.Enabled   = false;
                            }
                            else
                            {
                                tex.BackColor = Color.Green;
                                tex.ForeColor = Color.White;
                                tex.Enabled   = true;
                            }
                            tex.Visible = true;
                        }
                    }

                    while (i < tag_textobj.Length)
                    {
                        TextBox tex2 = (TextBox)tag_textobj[i];
                        if (tex2 != null)
                        {
                            tex2.Visible = false;
                        }
                        i++;
                    }
                    button_Exe.Location      = new Point(x + 50, (this.Size.Height - button_Exe.Size.Height) / 2);
                    butIoSet.Location        = new Point(button_Exe.Location.X + button_Exe.Size.Width + ww, (this.Size.Height - butIoSet.Size.Height) / 2);
                    button_save.Location     = new Point(butIoSet.Location.X + butIoSet.Size.Width + ww, (this.Size.Height - button_save.Size.Height) / 2);
                    checkBox_Enable.Location = new Point(button_save.Location.X + button_save.Size.Width + ww, (this.Size.Height - checkBox_Enable.Size.Height) / 2);
                    //  button1.Location = new Point(checkBox_Enable.Location.X + button_save.Size.Width + ww, (this.Size.Height - checkBox_Enable.Size.Height) / 2);



                    checkBox_wait.Location     = new Point(checkBox_Enable.Location.X + checkBox_Enable.Size.Width + ww, (this.Size.Height - checkBox_wait.Size.Height) / 2);
                    checkBox_AxisRest.Location = new Point(checkBox_wait.Location.X + checkBox_wait.Size.Width + ww, (this.Size.Height - checkBox_AxisRest.Size.Height) / 2);
                    checkBox_AxisStop.Location = new Point(checkBox_AxisRest.Location.X + checkBox_AxisRest.Size.Width + ww, (this.Size.Height - checkBox_AxisStop.Size.Height) / 2);
                    comboBox2.Location         = new Point(checkBox_AxisStop.Location.X + checkBox_AxisStop.Size.Width + ww, (this.Size.Height - comboBox2.Size.Height) / 2);
                    comboBox_Line.Location     = new Point(comboBox2.Location.X + comboBox2.Size.Width + ww, (this.Size.Height - comboBox_Line.Size.Height) / 2);
                    button_axisSafe.Location   = new Point(comboBox_Line.Location.X + comboBox_Line.Size.Width + ww, (this.Size.Height - button_axisSafe.Size.Height) / 2);
                    textBox_Sleep.Location     = new Point(button_axisSafe.Location.X + button_axisSafe.Size.Width + ww, (this.Size.Height - textBox_Sleep.Size.Height) / 2);

                    if ((_PointSet.tag_BeginFun != null || _PointSet.tag_EndFun != null) && Global.WorkVar.tag_GuanLian == true)
                    {
                        textBox_name.Enabled = false;
                    }
                    else
                    {
                        textBox_name.Enabled = true;
                    }
                }
            }
            catch
            { }
        }