Beispiel #1
0
 public void MoveArc2(int[] axis, double[] firstpoint, double[] centerpoint, double radian)
 {
     try
     {
         if (!_isConnect)
         {
             throw new AcsMotionException("<MoveArc2>", "ACS未连接");
         }
         ACS.SPiiPlusNET.Axis[] axisGroup = new ACS.SPiiPlusNET.Axis[axis.Length + 1];
         for (int i = 0; i < axis.Length; i++)
         {
             axisGroup[i] = (ACS.SPiiPlusNET.Axis)axis[i];
             if (!IsMotorEnable(axis[i]))
             {
                 throw new AcsMotionException("<MoveArc2>", string.Format("{0}轴未上使能,请先上使能", ((AxisIndex)axis[i]).ToString()));
             }
             if (IsMotorMoving(axis[i]))
             {
                 throw new AcsMotionException("<MoveArc2>", string.Format("{0}轴还在运动中,请稍后再试", ((AxisIndex)axis[i]).ToString()));
             }
             if (!IsMotorHome(axis[i]))
             {
                 throw new AcsMotionException("<MoveArc2>", string.Format("{0}轴还没回过原点,请回原点后再试", ((AxisIndex)axis[i]).ToString()));
             }
         }
         axisGroup[axis.Length] = ACS.SPiiPlusNET.Axis.ACSC_NONE;
         _acs_api.Segment(MotionFlags.ACSC_NONE, axisGroup, firstpoint);
         _acs_api.SegmentArc2(MotionFlags.ACSC_NONE, axisGroup, centerpoint, radian, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
         this._acs_api.EndSequenceM(axisGroup);
     }
     catch (Exception ex)
     {
         throw new AcsMotionException("<MoveArc2>", "错误信息:MoveArc1 fail, " + ex.ToString());
     }
 }
Beispiel #2
0
 public void MoveGroupRelativePosition(int[] axis, double[] points)
 {
     try
     {
         if (!_isConnect)
         {
             throw new AcsMotionException("<MoveGroupRelativePosition>", "ACS未连接");
         }
         ACS.SPiiPlusNET.Axis[] axisGroup = new ACS.SPiiPlusNET.Axis[axis.Length + 1];
         for (int i = 0; i < axis.Length; i++)
         {
             axisGroup[i] = (ACS.SPiiPlusNET.Axis)axis[i];
             if (!IsMotorEnable(axis[i]))
             {
                 throw new AcsMotionException("<MoveGroupRelativePosition>", string.Format("{0}轴未上使能,请先上使能", ((AxisIndex)axis[i]).ToString()));
             }
             if (IsMotorMoving(axis[i]))
             {
                 throw new AcsMotionException("<MoveGroupRelativePosition>", string.Format("{0}轴还在运动中,请稍后再试", ((AxisIndex)axis[i]).ToString()));
             }
             if (!IsMotorHome(axis[i]))
             {
                 throw new AcsMotionException("<MoveGroupRelativePosition>", string.Format("{0}轴还没回过原点,请回原点后再试", ((AxisIndex)axis[i]).ToString()));
             }
         }
         axisGroup[axis.Length] = ACS.SPiiPlusNET.Axis.ACSC_NONE;
         this._acs_api.ToPointM(MotionFlags.ACSC_AMF_RELATIVE, axisGroup, points);
         this._acs_api.EndSequenceM(axisGroup);
     }
     catch (Exception ex)
     {
         throw new AcsMotionException("<MoveGroupRelativePosition>", "错误信息:群组运动失败, " + ex.ToString());
     }
 }
Beispiel #3
0
 public void WaitGroupMotionEnd(int[] axis)
 {
     try
     {
         ACS.SPiiPlusNET.Axis[] axisGroup = new ACS.SPiiPlusNET.Axis[axis.Length];
         for (int i = 0; i < axis.Length; i++)
         {
             axisGroup[i] = (ACS.SPiiPlusNET.Axis)axis[i];
             this._acs_api.WaitMotionEnd(axisGroup[i], int.MaxValue);
         }
     }
     catch (Exception ex)
     {
         throw new AcsMotionException("WaitGroupMotionEnd", "错误信息:群组运动到位失败, " + ex.ToString());
     }
 }
Beispiel #4
0
 public void MultPoint(int[] axis, List <double> axis1, List <double> axis2)
 {
     ACS.SPiiPlusNET.Axis[] axisGroup = new ACS.SPiiPlusNET.Axis[axis.Length + 1];
     for (int i = 0; i < axis.Length; i++)
     {
         axisGroup[i] = (ACS.SPiiPlusNET.Axis)axis[i];
         if (!IsMotorEnable(axis[i]))
         {
             throw new AcsMotionException("<MoveArc2>", string.Format("{0}轴未上使能,请先上使能", ((AxisIndex)axis[i]).ToString()));
         }
         if (IsMotorMoving(axis[i]))
         {
             throw new AcsMotionException("<MoveArc2>", string.Format("{0}轴还在运动中,请稍后再试", ((AxisIndex)axis[i]).ToString()));
         }
         if (!IsMotorHome(axis[i]))
         {
             throw new AcsMotionException("<MoveArc2>", string.Format("{0}轴还没回过原点,请回原点后再试", ((AxisIndex)axis[i]).ToString()));
         }
     }
     axisGroup[axis.Length] = ACS.SPiiPlusNET.Axis.ACSC_NONE;
     _acs_api.EnableM(axisGroup);
     _acs_api.MultiPointM(MotionFlags.ACSC_AMF_WAIT, axisGroup, 0);
     double[] poit = { 0, 0 };
     for (int i = 0; i < axis1.Count; i++)
     {
         poit[0] = axis1[i];
         poit[1] = axis2[i];
         try
         {
             // _acs_api.ExtAddPointM(axisGroup, poit, 0.1);
             _acs_api.AddPointM(axisGroup, poit);
         }
         catch (Exception e)
         {
             MessageBox.Show($"第{i}点:" + e.Message);
             _acs_api.DisableM(axisGroup);
             goto Flag;
         }
     }
     _acs_api.EndSequenceM(axisGroup);
     _acs_api.GoM(axisGroup);
     Flag :;
 }
Beispiel #5
0
        public void MovePathTest()
        {
            try
            {
                //int[] axis = new int[2];
                //axis[0] = 0;
                //axis[1] = 2;
                //double[] firstpoint = new double[2];
                //firstpoint[0] = 100;
                //firstpoint[1] = 200;
                //double[] centerpoint = new double[2];
                //centerpoint[0] = 100;
                //centerpoint[1] = 210;
                //double radian = -3.1415926;
                //double[] point1 = new double[2];
                //point1[0] = 120;
                //point1[1] = 220;
                //double[] point2 = new double[2];
                //point2[0] = 120;
                //point2[1] = 210;
                //double radian2 = -3.1415926;
                //ACS.SPiiPlusNET.Axis[] axisGroup = new ACS.SPiiPlusNET.Axis[axis.Length + 1];
                //for (int i = 0; i < axis.Length; i++)
                //{
                //    axisGroup[i] = (ACS.SPiiPlusNET.Axis)axis[i];
                //}
                //axisGroup[axis.Length] = ACS.SPiiPlusNET.Axis.ACSC_NONE;
                //_acs_api.Segment(MotionFlags.ACSC_NONE, axisGroup, firstpoint);
                //_acs_api.SegmentArc2(MotionFlags.ACSC_NONE, axisGroup, centerpoint, radian, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                //_acs_api.SegmentLine(MotionFlags.ACSC_NONE, axisGroup, point1, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                //_acs_api.SegmentArc2(MotionFlags.ACSC_NONE, axisGroup, point2, radian2, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                //_acs_api.SegmentLine(MotionFlags.ACSC_NONE, axisGroup, firstpoint, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                //this._acs_api.EndSequenceM(axisGroup);

                int[] axis = new int[2];
                axis[0] = 0;
                axis[1] = 2;
                ACS.SPiiPlusNET.Axis[] axisGroup = new ACS.SPiiPlusNET.Axis[axis.Length + 1];
                for (int i = 0; i < axis.Length; i++)
                {
                    axisGroup[i] = (ACS.SPiiPlusNET.Axis)axis[i];
                }
                axisGroup[axis.Length] = ACS.SPiiPlusNET.Axis.ACSC_NONE;


                double[] firstpoint = new double[2];
                firstpoint[0] = 100;
                firstpoint[1] = 200;
                double[] centerpoint1 = new double[2];
                centerpoint1[0] = 100;
                centerpoint1[1] = 220;
                double   radian1    = -3.1415926;
                double[] linepoint1 = new double[2];
                linepoint1[0] = 120;
                linepoint1[1] = 240;
                double[] centerpoint2 = new double[2];
                centerpoint2[0] = 120;
                centerpoint2[1] = 220;
                double radian2 = -3.1415926;

                _acs_api.Segment(MotionFlags.ACSC_NONE, axisGroup, firstpoint);
                _acs_api.SegmentArc2(MotionFlags.ACSC_NONE, axisGroup, centerpoint1, radian1, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                _acs_api.SegmentLine(MotionFlags.ACSC_NONE, axisGroup, linepoint1, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                _acs_api.SegmentArc2(MotionFlags.ACSC_NONE, axisGroup, centerpoint2, radian2, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                _acs_api.SegmentLine(MotionFlags.ACSC_NONE, axisGroup, firstpoint, Api.ACSC_NONE, Api.ACSC_NONE, null, null, Api.ACSC_NONE, null);
                this._acs_api.EndSequenceM(axisGroup);
            }
            catch (Exception ex)
            {
                throw new AcsMotionException("MovePathTest", "错误信息:MoveArc1 fail, " + ex.ToString());
            }
        }