Example #1
0
 public int RelLine_P(int[] axisList, double[] posList, JFMotionParam mp)
 {
     _CheckAxisEnable(axisList, "RelLine_P");
     if (posList == null || posList.Count() != axisList.Count())
     {
         throw new ArgumentException("RelLine_P(int[] axisList, double[] posList) failed By: posList.Count() != axisList.Count()");
     }
     lock (ml)
     {
         HTM.MOTION_PARA _mp = new HTM.MOTION_PARA()
         {
             vStart  = mp.vs,
             vMax    = mp.vm,
             vEnd    = mp.ve,
             acc     = mp.acc,
             dec     = mp.dec,
             sFactor = mp.curve,
             timeout = double.MaxValue
         };
         int opt = HTM.Line(axisList, axisList.Count(), posList, 1.0, HTM.MotionMode.RS, ref _mp);
         if (opt != 0)
         {
             return((int)ErrorDef.InvokeFailed);
         }
         return((int)ErrorDef.Success);
     }
 }
Example #2
0
 /// <summary>
 /// 以指定速度作速度运动
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="speed"></param>
 /// <returns></returns>
 public int VelMove(int axis, double velocity, bool isPositive)
 {
     _CheckAxisEnable(axis, "VelMove");
     if (velocity <= 0)
     {
         return((int)ErrorDef.ParamError);
     }
     lock (ml)
     {
         HTM.MOTION_PARA mp = new HTM.MOTION_PARA()
         {
             vStart  = _motionParams[axis].vs,
             vMax    = velocity,
             vEnd    = _motionParams[axis].ve,
             acc     = _motionParams[axis].acc,
             dec     = _motionParams[axis].dec,
             sFactor = _motionParams[axis].curve,
             timeout = double.MaxValue
         };
         int opt = HTM.Speed(axis, isPositive?1.0:-1.0, ref mp);
         if (0 != opt)
         {
             return((int)ErrorDef.InvokeFailed);
         }
         return((int)ErrorDef.Success);
     }
 }
Example #3
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;
        }
Example #4
0
 /// <summary>
 /// 以指定运动参数做速度运动
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="mp"></param>
 /// <returns></returns>
 public int VelMove_P(int axis, JFMotionParam mp, bool isPositive)
 {
     _CheckAxisEnable(axis, "VelMove_P");
     lock (ml)
     {
         HTM.MOTION_PARA _mp = new HTM.MOTION_PARA()
         {
             vStart  = mp.vs,
             vMax    = mp.vm,
             vEnd    = mp.ve,
             acc     = mp.acc,
             dec     = mp.dec,
             sFactor = mp.curve,
             timeout = double.MaxValue
         };
         int opt = HTM.Speed(axis, isPositive?1.0:-1.0, ref _mp);
         if (0 != opt)
         {
             return((int)ErrorDef.InvokeFailed);
         }
         return((int)ErrorDef.Success);
     }
 }
Example #5
0
 public int RelMove(int axis, double distance)
 {
     _CheckAxisEnable(axis, "RelMove");
     lock (ml)
     {
         HTM.MOTION_PARA mp = new HTM.MOTION_PARA()
         {
             vStart  = _motionParams[axis].vs,
             vMax    = _motionParams[axis].vm,
             vEnd    = _motionParams[axis].ve,
             acc     = _motionParams[axis].acc,
             dec     = _motionParams[axis].dec,
             sFactor = _motionParams[axis].curve,
             timeout = double.MaxValue
         };
         int opt = HTM.Move(axis, distance, 1.0, HTM.MotionMode.RS, ref mp);
         if (0 != opt)
         {
             return((int)ErrorDef.InvokeFailed);
         }
         return((int)ErrorDef.Success);
     }
 }
Example #6
0
 public int AbsArc2CE_P(int axis1, int axis2, double center1, double center2, double pos1, double pos2, bool isPositive, JFMotionParam mp)
 {
     _CheckAxisEnable(axis1, "AbsArc2CE_P");
     _CheckAxisEnable(axis2, "AbsArc2CE_P");
     lock (ml)
     {
         HTM.MOTION_PARA _mp = new HTM.MOTION_PARA()
         {
             vStart  = mp.vs,
             vMax    = mp.vm,
             vEnd    = mp.ve,
             acc     = mp.acc,
             dec     = mp.dec,
             sFactor = mp.curve,
             timeout = double.MaxValue
         };
         int opt = HTM.ArcCe(axis1, axis2, center1, center2, pos1, pos2, isPositive ? 1 : 0, 1.0, HTM.MotionMode.AS, ref _mp);
         if (0 != opt)
         {
             return((int)ErrorDef.InvokeFailed);
         }
         return((int)ErrorDef.Success);
     }
 }
Example #7
0
 public int BuffRelArc2CA(int axis1, int axis2, double center1, double center2, double angle, JFMotionParam mp)
 {
     _CheckAxisEnable(axis1, "BuffRelArc2CA");
     _CheckAxisEnable(axis2, "BuffRelArc2CA");
     lock (ml)
     {
         HTM.MOTION_PARA _mp = new HTM.MOTION_PARA()
         {
             vStart  = mp.vs,
             vMax    = mp.vm,
             vEnd    = mp.ve,
             acc     = mp.acc,
             dec     = mp.dec,
             sFactor = mp.curve,
             timeout = double.MaxValue
         };
         int opt = HTM.ArcCa(axis1, axis2, center1, center2, angle, 1.0, HTM.MotionMode.RS | HTM.MotionMode.BUF, ref _mp);
         if (0 != opt)
         {
             return((int)ErrorDef.InvokeFailed);
         }
         return((int)ErrorDef.Success);
     }
 }