Example #1
0
        /// <summary>
        /// 设置单轴紧急停止
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <returns></returns>
        public static short SR_AxisEmgStop(int Cardtype, short card, short axis)
        {
            short           shrResult;
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[Cardtype];

            if (Base_ == null || Base_.SR_AxisEmgStop == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)Cardtype) + "控制卡初始化失败!");
                return(shrFail);
            }
            shrResult = Base_.SR_AxisEmgStop(card, axis);
            if (shrResult != shrGtsSuccess)
            {
                return(-1);
            }
            return(0);
        }
Example #2
0
        /// <summary>
        /// 伺服电机回原函数
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="axisName"></param>
        /// <returns></returns>
        public static short GoHome(AxisConfig axisC)
        {
            //return AxisHomeNeg_Ori(axisC);

            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            if (axisC == null)
            {
                return(shrFail);
            }
            short shrResult = -1;

            switch (axisC.GoHomeType)
            {
            case 0:
                shrResult = Base_.SR_GoHome(axisC);
                break;

            case 1:
                shrResult = Base_.SR_GoHome(axisC);
                break;

            case 2:
                shrResult = Base_.SR_GoOneHome(axisC);
                break;

            case 3:
                shrResult = Base_.SR_GoOneHomeOrg(axisC);
                break;

            default:
                shrResult = Base_.SR_GoHome(axisC);
                break;
            }

            if (shrResult != shrSuccess)
            {
                return(shrFail);
            }
            return(shrResult);
        }
Example #3
0
        /// <summary>
        /// 获取轴运动状态 1,运动,0 飞运动 -1异常
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public static short SR_GetAxisStatus(AxisConfig axisC)
        {
            short           shrResult  = 0;
            int             axisStatus = 0;
            NewCtrlCardBase Base_      = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(-1);
            }
            shrResult = Base_.SR_GetAxisStatus(axisC.CardNum, axisC.AxisNum, out axisStatus);
            if (shrResult == 1)
            {
                return(-1);
            }
            return((short)axisStatus);
        }
Example #4
0
        /// <summary>
        /// 读取板卡规划位置
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="pos"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static short SR_GetPrfPos(int Cardtype, short card, short axis, ref double pos)
        {
            short           shrResult;
            int             posV  = 0;
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[Cardtype];

            shrResult = Base_.SR_GetPrfPos(card, axis, ref pos);
            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)Cardtype) + "控制卡初始化失败!");
                return(shrFail);
            }
            if (shrResult != shrGtsSuccess)
            {
                return(-1);
            }
            return(0);
        }
Example #5
0
        /// <summary>
        /// 获取单通道(Bit)输入IO状态,函数执行成功 判断status参数值 TRUE 有信号输入  FALSE无信号输入
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="ioName"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static short GetInputIoBitStatus(string stationName, string ioName, out bool status)
        {
            short shrResult;

            status = false;
            if (ioName == null)
            {
                status = true;
                return(0);
            }
            IOParameter     ioP   = StationManage.FindInputIo(ioName);
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)ioP.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)ioP.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            if (ioP == null)
            {
                MessageBoxLog.Show(stationName + "\r\nIO:<" + ioName + ">没有找到,请配置");
                return(shrFail);
            }

            shrResult = Base_.SR_GetInputBit(ioP.CardNum, ioP.IOBit, out status);
            if (ioP.Logic == 0)
            {
                if (status)
                {
                    status = false;
                }
                else
                {
                    status = true;
                }
            }
            if (shrResult
                == -1)
            {
                return(shrFail);
            }

            return(shrSuccess);
        }
Example #6
0
        /// <summary>
        /// 轴绝对运动
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="axisName"></param>
        /// <param name="pointName"></param>
        /// <returns></returns>
        public static short AxisAbsoluteMove(string stationName, string axisName, string pointName, int asxisIndex)
        {
            StationModule stationM = StationManage.FindStation(stationName);

            if (stationM == null)
            {
                return(shrFail);
            }
            AxisConfig axisC = StationManage.FindAxis(stationM, axisName);

            if (axisC == null)
            {
                return(shrFail);
            }
            PointAggregate pointA = StationManage.FindPoint(stationM, pointName);

            if (pointA == null)
            {
                return(shrFail);
            }
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            short shrResult = 0;

            if (pointA.tag_motionType == 0)
            {
                shrResult = Base_.SR_AbsoluteMove(axisC, pointA.arrPoint[asxisIndex]);
            }
            else
            {
                shrResult = Base_.SR_RelativeMove(axisC, pointA.arrPoint[asxisIndex]);
            }
            if (shrResult != shrSuccess)
            {
                return(shrFail);
            }
            return(shrSuccess);
        }
Example #7
0
        /// <summary>
        /// 初始化卡
        /// </summary>
        /// <param name="card"></param>
        /// <returns></returns>
        public static short initCard(int[] card)
        {
            short ret  = 0;
            short ret1 = 0;

            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_gts]    = new NewCtRLCard_gts(4);
            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_8940]   = new NewCtrlCard_ZWX8940();
            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_8960m]  = new NewCtrlCard_ZWX8690m();
            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_IO3224] = new NewCtrlCard_IO3224();

            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_DMC3800] = new NewCtrlCard_DMC3000(8, 0);
            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_DMC3600] = new NewCtrlCard_DMC3000(6, 1);
            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_DMC3400] = new NewCtrlCard_DMC3000(4, 2);

            tag_NewCtrlCardBase[(int)MotionCardManufacturer.MotionCardManufacturer_DMC1000B] = new NewCtrlCard_DMC1000B(4);

            for (int i = 0; i < (int)(MotionCardManufacturer.MotionCardManufacturer_max); i++)
            {
                if (card[i] == 0 || i == (int)MotionCardManufacturer.MotionCardManufacturer_8940)
                {
                    continue;
                }
                NewCtrlCardBase Base_ = tag_NewCtrlCardBase[i];
                ret = Base_.SR_InitCard();

                if (ret <= 0)
                {
                    tag_CardCount[i]     = 0;
                    tag_CardAxisCount[i] = 0;
                    tag_initResult       = 1;
                    ret1 = -1;
                    // return -1;
                }
                else
                {
                    tag_CardCount[i]     = ret;
                    tag_CardAxisCount[i] = Base_.tag_AxisCount;
                }
            }
            tag_isInit = 1;
            return(ret1);
        }
Example #8
0
        /// <summary>
        /// 设定正负方向限位输入nLMT信号的模式
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public static short set_pulse_mode(AxisConfig axisC)
        {
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null || Base_.SR_set_pulse_mode == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            if (axisC == null)
            {
                return(shrFail);
            }
            short shrResult = (short)Base_.SR_set_pulse_mode((int)axisC.CardNum, (int)axisC.AxisNum, axisC.tag_CC_value, axisC.tag_CC_logic, axisC.tag_dir_logic);

            if (shrResult != shrSuccess)
            {
                return(shrFail);
            }
            return(shrResult);
        }
Example #9
0
        /// <summary>
        /// 设定正负方向限位输入nLMT信号的模式
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public static short set_limit_mode(AxisConfig axisC)
        {
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null || Base_.SR_set_limit_mode == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            if (axisC == null)
            {
                return(shrFail);
            }
            short shrResult = Base_.SR_set_limit_mode(axisC.CardNum, axisC.AxisNum, axisC.tag_IoLimtPEnable, axisC.tag_IoLimtNEnable, axisC.tag_IoLimtPNHighEnable);

            if (shrResult != shrSuccess)
            {
                return(shrFail);
            }
            return(shrResult);
        }
Example #10
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);
        }
Example #11
0
        /// <summary>
        /// IO输出
        /// </summary>
        /// <param name="io">IO类对象</param>
        /// <param name="ioValue">输出状态</param>
        /// <returns></returns>
        public static short SetOutputIoBit(IOParameter io, short ioValue)
        {
            short shrResult = 0;

            if (io == null)
            {
                return(shrFail);
            }
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)io.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)io.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            shrResult = Base_.SR_SetOutputBit(io.CardNum, io.IOBit, ioValue);
            if (shrResult != shrSuccess)
            {
                return(shrFail);
            }

            return(shrSuccess);
        }
Example #12
0
        public static void ReadAllIo(object o)
        {
            while (true)
            {
                int CardIndex = 0;
                int axisIndex = 0;
                for (MotionCardManufacturer i = 0; i < MotionCardManufacturer.MotionCardManufacturer_max; i++)
                {
                    NewCtrlCardBase Base  = NewCtrlCardV0.tag_NewCtrlCardBase[(int)i];
                    short           j     = 0;
                    short           n     = 0;
                    short           mInIo = 0;
                    if (Base == null || tag_CardHave[(int)i] == 0)
                    {
                        continue;
                    }

                    while (j < NewCtrlCardV0.tag_CardCount[(int)i])
                    {
                        ulong pLimitNValue = 0;
                        ulong pLimitPValue = 0;
                        ulong pOrgValue    = 0;

                        ulong pCardAxisAlarmValue = 0;
                        ulong pOnAxisEnableValue  = 0;

                        ulong pCardInIO  = 0;
                        ulong pCardOutIO = 0;
                        ulong one        = 1;
                        mInIo = 0;
                        while (mInIo < 64)
                        {
                            bool bInio  = true;
                            bool bOutio = true;
                            Base.SR_GetInputBit(j, mInIo, out bInio);
                            Base.SR_GetOutputBit(j, mInIo, out bOutio);
                            if (bInio == true)
                            {
                                pCardInIO = pCardInIO + (ulong)(one << mInIo);
                            }
                            else
                            {
                            }
                            if (bOutio == true)
                            {
                                pCardOutIO = pCardOutIO + (ulong)(one << mInIo);
                            }
                            mInIo++;
                        }

                        n = 1;
                        while (n <= NewCtrlCardV0.tag_CardAxisCount[(int)i])
                        {
                            bool   LimitNvar           = true;
                            bool   LimitPvar           = true;
                            bool   LimitOrgvar         = true;
                            bool   bCardAxisAlarmValue = true;
                            bool   bOnAxisEnableValue  = true;
                            double bOnAxisEncPosChange = 0;
                            double bOnAxisPrfPosChange = 0;
                            Base.SR_GetLimitNInput(j, n, out LimitNvar);
                            Base.SR_GetLimitPInput(j, n, out LimitPvar);
                            Base.SR_GetOriginInput(j, n, out LimitOrgvar);
                            Base.SR_GetAlarmInput(j, n, out bCardAxisAlarmValue);
                            //  Base.SR_GetServoEnable(j, n, out bOnAxisEnableValue);
                            //Base.SR_GetEncPos(j, n, ref bOnAxisEncPosChange);
                            //Base.SR_GetPrfPos(j, n, ref bOnAxisPrfPosChange);
                            if (LimitNvar == true)
                            {
                                pLimitNValue = pLimitNValue + (ulong)(one << n);
                            }
                            if (LimitPvar == true)
                            {
                                pLimitPValue = pLimitPValue + (ulong)(one << n);
                            }
                            if (LimitOrgvar == true)
                            {
                                pOrgValue = pOrgValue + (ulong)(one << n);
                            }
                            if (bCardAxisAlarmValue == true)
                            {
                                pCardAxisAlarmValue = pCardAxisAlarmValue + (ulong)(one << n);
                            }
                            if (bOnAxisEnableValue == true)
                            {
                                pOnAxisEnableValue = pOnAxisEnableValue + (ulong)(one << n);
                            }

                            Base.SR_GetEncPos(j, n, ref bOnAxisEncPosChange);
                            Base.SR_GetPrfPos(j, n, ref bOnAxisPrfPosChange);
                            if (tag_OnAxisEncPosChange[axisIndex] != bOnAxisEncPosChange || tag_IO_refresh > 0)
                            {
                                tag_OnAxisEncPosChange[axisIndex] = bOnAxisEncPosChange;
                                OnAxisEncPosChange((int)i, j, n, (int)bOnAxisEncPosChange);
                            }
                            if (tag_OnAxisPrfPosChange[axisIndex] != bOnAxisPrfPosChange || tag_IO_refresh > 0)
                            {
                                tag_OnAxisPrfPosChange[axisIndex] = bOnAxisPrfPosChange;
                                OnAxisPrfPosChange((int)i, j, n, (int)bOnAxisPrfPosChange);
                            }
                            axisIndex++;
                            n++;
                        }
                        if (tag_CardAxisLimitNIO[CardIndex] != pLimitNValue || tag_IO_refresh > 0)
                        {
                            tag_CardAxisLimitNIO[CardIndex] = pLimitNValue;
                            OnAxisLimitNChange((int)i, j, n, pLimitNValue);
                        }
                        if (tag_CardAxisLimitPIO[CardIndex] != pLimitPValue || tag_IO_refresh > 0)
                        {
                            tag_CardAxisLimitPIO[CardIndex] = pLimitPValue;
                            OnAxisLimitPChange((int)i, j, n, pLimitPValue);
                        }
                        if (tag_CardAxisOrgIO[CardIndex] != pOrgValue || tag_IO_refresh > 0)
                        {
                            tag_CardAxisOrgIO[CardIndex] = pOrgValue;
                            OnAxisHomeChange((int)i, j, n, pOrgValue);
                        }
                        if (tag_CardAxisAlarm[CardIndex] != pCardAxisAlarmValue || tag_IO_refresh > 0)
                        {
                            tag_CardAxisAlarm[CardIndex] = pCardAxisAlarmValue;
                            OnAxisAlarmChange((int)i, j, n, pCardAxisAlarmValue);
                        }

                        if (pCardInIO != tag_CardInIO[CardIndex] || tag_IO_refresh > 0)
                        {
                            tag_CardInIO[CardIndex] = pCardInIO;
                            OnInputIOChange((int)i, j, pCardInIO);
                        }
                        if (pCardOutIO != tag_CardInIO[CardIndex] || tag_IO_refresh > 0)
                        {
                            tag_CardOutIO[CardIndex] = pCardOutIO;
                            OnOutputIOChange((int)i, j, pCardOutIO);
                        }
                        if (tag_IO_refresh > 0)
                        {
                            tag_IO_refresh--;
                        }
                        CardIndex++;
                        j++;
                    }
                    //
                }
                Thread.Sleep(1);
            }
        }
Example #13
0
        /// <summary>
        /// 判断是否报警 TRUE 报警
        /// </summary>
        public bool IsAxisLimitAlarm()
        {
            int  CardIndex = 0;
            int  axisIndex = 0;
            bool ret       = false;

            for (MotionCardManufacturer i = 0; i < MotionCardManufacturer.MotionCardManufacturer_max; i++)
            {
                NewCtrlCardBase Base = NewCtrlCardV0.tag_NewCtrlCardBase[(int)i];
                short           j    = 0;
                short           n    = 0;
                if (Base == null || NewCtrlCardIO.tag_CardHave[(int)i] == 0)
                {
                    continue;
                }
                while (j < NewCtrlCardV0.tag_CardCount[(int)i])
                {
                    axisIndex = 0;
                    while (n < NewCtrlCardV0.tag_CardAxisCount[(int)i])
                    {
                        AxisConfig name = IshaveAxis((int)i, j, n);
                        if (name != null)
                        {
                            if (name.tag_IoLimtPNHighEnable == 1)
                            {
                                if ((((int)NewCtrlCardIO.tag_CardAxisLimitNIO[CardIndex] & (1 << n)) > 0) && name.tag_IoLimtNEnable == 0)
                                {
                                    LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴负限位(" + name.AxisName + ")报警", 0);
                                    ret = true;
                                }
                                if ((((int)NewCtrlCardIO.tag_CardAxisLimitPIO[CardIndex] & (1 << n)) > 0) && name.tag_IoLimtPEnable == 0)
                                {
                                    LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴正限位(" + name.AxisName + ")报警", 0);
                                    ret = true;
                                }
                            }
                            else
                            {
                                if ((((int)NewCtrlCardIO.tag_CardAxisLimitNIO[CardIndex] & (1 << n)) == 0) && name.tag_IoLimtNEnable == 0)
                                {
                                    LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴负限位(" + name.AxisName + ")报警", 0);
                                    ret = true;
                                }
                                if ((((int)NewCtrlCardIO.tag_CardAxisLimitPIO[CardIndex] & (1 << n)) == 0) && name.tag_IoLimtPEnable == 0)
                                {
                                    LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴正限位(" + name.AxisName + ")报警", 0);
                                    ret = true;
                                }
                            }
                        }
                        axisIndex++;
                        n++;
                    }

                    CardIndex++;
                    j++;
                }
                //
            }
            return(ret);
        }