Beispiel #1
0
        /// <summary>运动控制卡初始化 </summary>

        internal void Open()
        {
            AxisCount = HTM.GetAxisNum();
            if (AxisCount > 0)
            {
                axisHomeDones   = new bool[AxisCount];
                detectHomeDones = new Thread[AxisCount];
                _motionParams   = new JFMotionParam[AxisCount];
                for (int i = 0; i < AxisCount; i++)
                {
                    HTM.AXIS_INFO ai;
                    HTM.GetAxisInfo(i, out ai);
                    HTM.MOTION_PARA mp = HTM.GetMotionPara(i);//HTM.GetMovePara(i, out mp);
                    //if (ret != 0)
                    //{
                    //    AxisCount = 0;
                    //    _motionParams = null;
                    //    throw new Exception(string.Format("MC_Htm.Init Failed :HTM.GetMovePara(axis = {0}) return errorCode = {1}", i, ret));
                    //}
                    _motionParams[i]       = new JFMotionParam();
                    _motionParams[i].vs    = mp.vStart;
                    _motionParams[i].vm    = mp.vMax;
                    _motionParams[i].ve    = mp.vEnd;
                    _motionParams[i].acc   = mp.acc;
                    _motionParams[i].dec   = mp.dec;
                    _motionParams[i].curve = mp.sFactor;
                    _motionParams[i].jerk  = 0;
                    axisHomeDones[i]       = false;
                    detectHomeDones[i]     = new Thread(new ParameterizedThreadStart(FuncDetectHomeDone));
                }
            }
            IsOpen = true;
        }
Beispiel #2
0
        public int SetHomeParam(int axis, JFHomeParam hp)
        {
            _CheckAxisEnable(axis, "SetHomeParam");
            HTM.AXIS_INFO axInfo;
            int           opt = HTM.GetAxisInfo(axis, out axInfo);

            if (opt != 0)
            {
                throw new Exception("SetHomeParam() Failed By: HTM.GetAxisInfo() return errorCode = " + opt);
            }

            axInfo.homeMode  = (sbyte)hp.mode;
            axInfo.homeDir   = (byte)(hp.dir ? 1 : 0);
            axInfo.homeEZA   = (byte)(hp.eza ? 1 : 0);
            axInfo.homeAcc   = hp.acc;
            axInfo.homeVm    = hp.vm;
            axInfo.homeVo    = hp.vo;
            axInfo.homeShift = hp.shift;
            opt = HTM.SetAxisInfo(axis, ref axInfo);
            if (0 != opt)
            {
                return((int)ErrorDef.InvokeFailed);
            }
            return((int)ErrorDef.Success);
        }
Beispiel #3
0
        /// <summary>单轴回零参数</summary>
        public int GetHomeParam(int axis, out JFHomeParam pm)
        {
            _CheckAxisEnable(axis, "GetHomeParam");
            HTM.AXIS_INFO axInfo;
            int           errCode = HTM.GetAxisInfo(axis, out axInfo);

            if (errCode != 0)
            {
                pm = new JFHomeParam();
                return((int)ErrorDef.InvokeFailed);
            }
            pm = new JFHomeParam()
            {
                mode   = axInfo.homeMode,
                dir    = axInfo.homeDir != 0,
                eza    = axInfo.homeEZA != 0,
                acc    = axInfo.homeAcc,
                vm     = axInfo.homeVm,
                vo     = axInfo.homeVo,
                va     = axInfo.homeVo,
                shift  = axInfo.homeShift,
                offset = 0
            };
            return((int)ErrorDef.Success);
        }
Beispiel #4
0
        public int SetSNLimit(int axis, bool enable, double pos)
        {
            _CheckAxisEnable(axis, "SetSNLimit");
            HTM.AXIS_INFO axi;
            int           nRet = HTM.GetAxisInfo(axis, out axi);

            if (nRet != 0)
            {
                throw new Exception("MDD_Htm.SetSNLimit failed: HTM.GetAxisInfo return errorCode = " + nRet);
            }

            if (enable)
            {
                axi.enableSEL = (byte)(axi.enableSEL | 0x01);
                axi.sMELPos   = pos;
            }
            else
            {
                axi.enableSEL = (byte)(axi.enableSEL & 0x02);
            }
            int opt = HTM.SetAxisInfo(axis, ref axi);

            if (0 != opt)
            {
                return((int)ErrorDef.InvokeFailed);
            }
            return((int)ErrorDef.Success);
        }
Beispiel #5
0
        public int SetPulseFactor(int axis, double plsFactor)
        {
            _CheckAxisEnable(axis, "SetPulseFactor");
            HTM.AXIS_INFO ai;
            int           opt = HTM.GetAxisInfo(axis, out ai);

            if (0 != opt)
            {
                throw new Exception("MDD_Htm.SetPulseFactor failed: HTM.GetAxisInfo return errorCode = " + opt);
            }
            ai.pulseFactor = plsFactor;
            opt            = HTM.SetAxisInfo(axis, ref ai);
            if (0 != opt)
            {
                return((int)ErrorDef.InvokeFailed);
            }
            return((int)ErrorDef.Success);
        }
Beispiel #6
0
        public int GetSNLimit(int axis, out bool enable, out double pos)
        {
            _CheckAxisEnable(axis, "GetSNLimit");
            enable = false;
            pos    = 0;
            HTM.AXIS_INFO axi;
            int           nRet = HTM.GetAxisInfo(axis, out axi);

            if (nRet != 0)
            {
                return((int)ErrorDef.InvokeFailed);
            }
            if ((axi.enableSEL & 0x01) != 0)
            {
                enable = true;
            }
            else
            {
                enable = false;
            }
            pos = axi.sMELPos;
            return((int)ErrorDef.Success);
        }