Example #1
0
 /// <summary>
 /// 克隆工序信息并指定其工序号
 /// </summary>
 /// <returns></returns>
 public Process Clone(int processNo)
 {
     Process process = new Process(this.ProcessType, this.ProcessShape, this.isOutside, processNo, this.StartPoint);
     process.SideType = this.SideType;
     process.IntoPoint = this.IntoPoint.Clone();
     process.Height = this.Height;
     process.Diameter = this.Diameter;
     process.RecDirection = this.RecDirection;
     return process;
 }
Example #2
0
        /// <summary>
        /// 铣矩形动作
        /// </summary>
        /// <param name="process"></param>
        /// <param name="strVel"></param>
        /// <param name="maxVel"></param>
        /// <param name="tAcc"></param>
        /// <param name="tDec"></param>
        private static void recDrill(Process process, int strVel, int maxVel, double tAcc, double tDec)
        {
            //根据铣矩形的环绕方向进行加工
            int directCOE = process.RecDirection == Direction.ClockWise ? -1 : 1;
            short rc = 0;
            //移动轴的节点
            ushort[] _nodeMove = new ushort[2];
            //线性移动距离的脉冲数
            int[] _moveLinePulse = new int[2] { 0, (int)((process.Height - Spindle.BladeDiameter) * Tool.ZPulsePerMill) };
            switch (process.SideType) {
                case SideType.Front:
                    _nodeMove[0] = 1;
                    _nodeMove[1] = 3;
                    _moveLinePulse[0] = directCOE * (int)((process.Width - Spindle.BladeDiameter) * Tool.XPulsePerMill);
                    break;
                case SideType.Left:
                    _nodeMove[0] = 2;
                    _nodeMove[1] = 3;
                    _moveLinePulse[0] = -directCOE * (int)((process.Width - Spindle.BladeDiameter) * Tool.YPulsePerMill);
                    break;
                case SideType.Back:
                    _nodeMove[0] = 1;
                    _nodeMove[1] = 3;
                    _moveLinePulse[0] = -directCOE * (int)((process.Width - Spindle.BladeDiameter) * Tool.XPulsePerMill);
                    break;
                case SideType.Right:
                    _nodeMove[0] = 2;
                    _nodeMove[1] = 3;
                    _moveLinePulse[0] = directCOE * (int)((process.Width - Spindle.BladeDiameter) * Tool.YPulsePerMill);
                    break;
            }
            //钻入一定深度
            waitPause();
            rc = DMC.CS_DMC_01_start_ta_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
                process.IntoPoint.XPulse, process.IntoPoint.YPulse, strVel, getMaxSpeed(maxVel, CoeTable.DrillingIn), tAcc, tDec);
            waitForDone(Parameter.xyNodeGroup, currentProcessNo, WaitMode.Always, DebugAction.DrillIn);

            //向下移动一段距离,注意,这里的速度需要限制为z轴的最大速度
            waitPause();
            rc = DMC.CS_DMC_01_start_sr_move_xy(ControlCard.CardNo, ref _nodeMove[0], ref Parameter.slotGroup[0],
                0, -_moveLinePulse[1], strVel, getMaxSpeed(new Point(), new Point(0, 0, _moveLinePulse[1], 0), maxVel, CoeTable.DrillingRec), tAcc, tDec);
            waitForDone(_nodeMove, currentProcessNo, WaitMode.Always, DebugAction.MillRec);

            //横着移动一段距离
            waitPause();
            rc = DMC.CS_DMC_01_start_sr_move_xy(ControlCard.CardNo, ref _nodeMove[0], ref Parameter.slotGroup[0],
                _moveLinePulse[0], 0, strVel, getMaxSpeed(maxVel, CoeTable.DrillingRec), tAcc, tDec);
            waitForDone(_nodeMove, currentProcessNo, WaitMode.Always, DebugAction.MillRec);

            //向上移动一段距离
            waitPause();
            rc = DMC.CS_DMC_01_start_sr_move_xy(ControlCard.CardNo, ref _nodeMove[0], ref Parameter.slotGroup[0],
                0, _moveLinePulse[1], strVel, getMaxSpeed(new Point(), new Point(0, 0, _moveLinePulse[1], 0), maxVel, CoeTable.DrillingRec), tAcc, tDec);
            waitForDone(_nodeMove, currentProcessNo, WaitMode.Always, DebugAction.MillRec);

            //横着移动一段距离
            waitPause();
            rc = DMC.CS_DMC_01_start_sr_move_xy(ControlCard.CardNo, ref _nodeMove[0], ref Parameter.slotGroup[0],
                -_moveLinePulse[0], 0, strVel, getMaxSpeed(maxVel, CoeTable.DrillingRec), tAcc, tDec);
            waitForDone(_nodeMove, currentProcessNo, WaitMode.Always, DebugAction.MillRec);

            //退刀
            waitPause();
            rc = DMC.CS_DMC_01_start_ta_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
                process.StartPoint.XPulse, process.StartPoint.YPulse, strVel, getMaxSpeed(maxVel, CoeTable.DrillingOut), tAcc, tDec);
            waitForDone(Parameter.xyNodeGroup, currentProcessNo, WaitMode.Always, DebugAction.DrillOut);
        }
Example #3
0
 /// <summary>
 /// 加工面的切换
 /// </summary>
 /// <param name="cutPoint">工位的切边点</param>
 /// <param name="direction">加工环绕方向</param>
 /// <param name="startNo">起始序号</param>
 /// <param name="stopNo">终止序号</param>
 /// <param name="strVel">初始速度</param>
 /// <param name="maxVel">最大速度</param>
 /// <param name="tAcc">加速时间</param>
 /// <param name="tDec">减速时间</param>
 private static void sideChange(List<CutPoint> cutPoint, Process process, Direction direction, int startNo, int stopNo, int strVel, int maxVel, double tAcc, double tDec)
 {
     short rc = 0;
     //刀具位置与工件之间的间隙、当前切边点序号与下一切边点序号
     //当准备进行加工面切换时,直接使用起始点坐标的标志
     int blank = 0, iNext = 0, iNow = 0;
     bool useCurrentPoint = false;
     for (iNow = startNo; iNow < stopNo; iNow++) {
         waitPause();
         //切边点总共8个
         if (iNow >= 8) {
             //如果当前点的序号为8
             //则需要重置为0重新轮询
             iNow = iNow - 8;
             //下一个切边点的序号加1
             iNext = iNow + 1;
         }
         else if (iNow == 7) {
             //如果当前的切边点为7,则下一个点的序号重置为0
             iNext = 0;
         }
         else {
             //否则正常情况下下一个序号为当前序号加1
             iNext = iNow + 1;
         }
         //如果当前的加工面与下一个加工面不同,则要切换加工面
         if (cutPoint[iNow].SideType != cutPoint[iNext].SideType) {
             //获取圆心的绝对坐标坐标
             int angelPulse;
             //xy轴圆周运动,w轴做切线追随运动,到达下一个切边点
             if (cutPoint[iNow].SideType == SideType.Front || cutPoint[iNow].SideType == SideType.Back) {
                 //不用移动到下一切边点,可直接进行螺旋插补
                 if (useCurrentPoint == true) {
                     useCurrentPoint = false;
                     int[] _centerPulse = getCenterPulse(new Point(process.StartPoint.XPulse, cutPoint[iNow].YPulse, 0, process.StartPoint.WPulse), cutPoint[iNext], out angelPulse);
                     rc = DMC.CS_DMC_01_start_tr_heli_xy(ControlCard.CardNo, ref Parameter.xywNodeGroup[0], ref Parameter.slotGroup[0], _centerPulse[0] - process.StartPoint.XPulse,
                         _centerPulse[1] - process.StartPoint.YPulse, angelPulse, Tool.WPulsePerCircle, (short)direction, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                 }
                 else {
                     int[] _centerPulse = getCenterPulse(cutPoint[iNow], cutPoint[iNext], out angelPulse);
                     //如果是前后面,则对应的圆心的相对坐标需要在Y轴上加上一个“blank”
                     rc = DMC.CS_DMC_01_start_tr_heli_xy(ControlCard.CardNo, ref Parameter.xywNodeGroup[0], ref Parameter.slotGroup[0], _centerPulse[0] - cutPoint[iNow].XPulse,
                         _centerPulse[1] - cutPoint[iNow].YPulse + blank, angelPulse, Tool.WPulsePerCircle, (short)direction, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                 }
             }
             else {
                 if (useCurrentPoint == true) {
                     useCurrentPoint = false;
                     int[] _centerPulse = getCenterPulse(new Point(cutPoint[iNow].XPulse, process.StartPoint.YPulse, 0, process.StartPoint.WPulse), cutPoint[iNext], out angelPulse);
                     rc = DMC.CS_DMC_01_start_tr_heli_xy(ControlCard.CardNo, ref Parameter.xywNodeGroup[0], ref Parameter.slotGroup[0], _centerPulse[0] - process.StartPoint.XPulse,
                     _centerPulse[1] - process.StartPoint.YPulse, angelPulse, Tool.WPulsePerCircle, (short)direction, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                 }
                 else {
                     //否则在X轴上加上一个“blank”
                     int[] _centerPulse = getCenterPulse(cutPoint[iNow], cutPoint[iNext], out angelPulse);
                     rc = DMC.CS_DMC_01_start_tr_heli_xy(ControlCard.CardNo, ref Parameter.xywNodeGroup[0], ref Parameter.slotGroup[0], _centerPulse[0] - cutPoint[iNow].XPulse + blank,
                         _centerPulse[1] - cutPoint[iNow].YPulse, angelPulse, Tool.WPulsePerCircle, (short)direction, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                 }
             }
             waitForDone(Parameter.xywNodeGroup, currentProcessNo + 1, WaitMode.OnlyDebug, DebugAction.Move);
         }
         else {
             //如果加工面是前或者后
             if (cutPoint[iNow].SideType == SideType.Front || cutPoint[iNow].SideType == SideType.Back) {
                 if (iNow == startNo) {
                     //获取和工件之间的间隙
                     blank = cutPoint[iNow].YPulse - process.StartPoint.YPulse;
                     //如果当前点距离inow切边点的距离小于inow切边点与inext切边点间的距离则要移动到inext切边点
                     if (Math.Abs(process.StartPoint.XPulse - cutPoint[iNow].XPulse) <
                         Math.Abs(cutPoint[iNext].XPulse - cutPoint[iNow].XPulse)) {
                         //如果现在的序号等于起始号,则通过相对坐标的移动达到目的位置
                         rc = DMC.CS_DMC_01_start_tr_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
                             cutPoint[iNext].XPulse - process.StartPoint.XPulse, cutPoint[iNext].YPulse - cutPoint[iNow].YPulse, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                     }
                     else
                         //下一个螺旋插补,使用当前点
                         useCurrentPoint = true;
                 }
                 else {
                     //否则正常移动到下一个切边点的XY上的位置
                     rc = DMC.CS_DMC_01_start_tr_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
                         cutPoint[iNext].XPulse - cutPoint[iNow].XPulse, cutPoint[iNext].YPulse - cutPoint[iNow].YPulse, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                 }
                 waitForDone(Parameter.xyNodeGroup, currentProcessNo + 1, WaitMode.OnlyDebug, DebugAction.Move);
             }
             //否则移动y轴
             else {
                 if (iNow == startNo) {
                     //获取和工件之间的间隙
                     blank = cutPoint[iNow].XPulse - process.StartPoint.XPulse;
                     if (Math.Abs(process.StartPoint.YPulse - cutPoint[iNow].YPulse) <
                         Math.Abs(cutPoint[iNext].YPulse - cutPoint[iNow].YPulse)
                         ) {
                         //如果现在的序号等于起始号,则通过相对坐标的移动达到目的位置,这么做是为了方便使用线性插补命令
                         rc = DMC.CS_DMC_01_start_tr_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
                            cutPoint[iNext].XPulse - cutPoint[iNow].XPulse, cutPoint[iNext].YPulse - process.StartPoint.YPulse, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                     }
                     else
                         useCurrentPoint = true;
                 }
                 else {
                     //否则正常移动到下一个切边点的XY上的位置
                     rc = DMC.CS_DMC_01_start_tr_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
                          cutPoint[iNext].XPulse - cutPoint[iNow].XPulse, cutPoint[iNext].YPulse - cutPoint[iNow].YPulse, strVel, getMaxSpeed(maxVel, CoeTable.ProcessChanging), tAcc, tDec);
                 }
                 waitForDone(Parameter.xyNodeGroup, currentProcessNo + 1, WaitMode.OnlyDebug, DebugAction.Move);
             }
         }
     }
 }
Example #4
0
 /// <summary>
 /// 执行加工工序
 /// </summary>
 /// <param name="process">要加工的工序</param>
 /// <param name="strVel">初始速度</param>
 /// <param name="maxVel">最大速度</param>
 /// <param name="tAcc">加速时间</param>
 /// <param name="tDec">减速时间</param>
 private static void doProcess(Process process, int strVel, int maxVel, double tAcc, double tDec)
 {
     //根据加工形状进行选择工序
     switch (process.ProcessShape) {
         //铣圆
         case ProcessShape.Cir:
             cirDrill(process, strVel, maxVel, tAcc, tDec);
             break;
         //铣矩形
         case ProcessShape.Rec:
             recDrill(process, strVel, maxVel, tAcc, tDec);
             break;
     }
 }
Example #5
0
 /// <summary>
 /// 铣圆孔动作
 /// </summary>
 /// <param name="process">工序名</param>
 /// <param name="strVel">初始速度</param>
 /// <param name="maxVel">最大速度</param>
 /// <param name="tAcc">加速时间</param>
 /// <param name="tDec">减速时间</param>
 private static void cirDrill(Process process, int strVel, int maxVel, double tAcc, double tDec)
 {
     short rc = 0;
     //钻入一定深度
     waitPause();
     rc = DMC.CS_DMC_01_start_ta_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
         process.IntoPoint.XPulse, process.IntoPoint.YPulse, strVel, getMaxSpeed(maxVel, CoeTable.DrillingIn), tAcc, tDec);
     waitForDone(Parameter.xyNodeGroup, currentProcessNo, WaitMode.Always, DebugAction.DrillIn);
     //如果要铣圆孔的直径大于刀具直径,则进行正常的铣削加工,否则可视为钻孔
     if (process.Diameter > Spindle.BladeDiameter) {
         ushort[] _nodeCenter = new ushort[2];
         //中心脉冲,这里计算用的是相对坐标
         int[] _centerPulse = new int[2] { 0, 0 };
         switch (process.SideType) {
             case SideType.Front:
             case SideType.Back:
                 _nodeCenter[0] = 1;
                 _nodeCenter[1] = 3;
                 _centerPulse[0] = (int)((process.Diameter / 2 - Spindle.BladeRadius) * Tool.XPulsePerMill);
                 break;
             case SideType.Left:
             case SideType.Right:
                 _nodeCenter[0] = 2;
                 _nodeCenter[1] = 3;
                 _centerPulse[0] = (int)((process.Diameter / 2 - Spindle.BladeRadius) * Tool.YPulsePerMill);
                 break;
         }
         waitPause();
         rc = DMC.CS_DMC_01_start_sr_move_xy(ControlCard.CardNo, ref _nodeCenter[0], ref Parameter.slotGroup[0],
             _centerPulse[0], _centerPulse[1], strVel, getMaxSpeed(maxVel, CoeTable.DrillingCir), tAcc, tDec);
         //等待动作完成
         waitForDone(_nodeCenter, currentProcessNo, WaitMode.Always, DebugAction.MillCir);
         //xz轴圆弧插补360度铣一个孔,孔中心为定位中心
         waitPause();
         rc = DMC.CS_DMC_01_start_sr_arc_xy(ControlCard.CardNo, ref _nodeCenter[0], ref Parameter.slotGroup[0],
             -_centerPulse[0], _centerPulse[1], 359, strVel, getMaxSpeed(maxVel, CoeTable.DrillingCir), tAcc, tDec);
         //等待动作完成
         waitForDone(_nodeCenter, currentProcessNo, WaitMode.Always, DebugAction.MillCir);
     }
     //退刀
     waitPause();
     rc = DMC.CS_DMC_01_start_ta_move_xy(ControlCard.CardNo, ref Parameter.xyNodeGroup[0], ref Parameter.slotGroup[0],
         process.StartPoint.XPulse, process.StartPoint.YPulse, strVel, getMaxSpeed(maxVel, CoeTable.DrillingOut), tAcc, tDec);
     //等待动作完成
     waitForDone(Parameter.xyNodeGroup, currentProcessNo, WaitMode.Always, DebugAction.DrillOut);
 }
Example #6
0
 public void InsertProcess(int processNo, Process process)
 {
     ProcessList.Insert(processNo, process);
     //更改后续工序的工序号
     for (int number = processNo + 1; number < ProcessNum; number++) {
         ProcessList[number].Number = number;
     }
 }
Example #7
0
 /// <summary>
 /// 向工位添加一道工序
 /// </summary>
 /// <param name="process">工序</param>
 public void Add(Process process)
 {
     //调用工序列表的Add方法
     ProcessList.Add(process);
 }
Example #8
0
 /// <summary>
 /// 向工位添加一道工序
 /// </summary>
 /// <param name="processType">加工类型</param>
 /// <param name="processShape">加工形状</param>
 /// <param name="isOutside">指示是否为外侧面</param>
 /// <param name="startPoint">起始点坐标</param>
 public void Add(ProcessType processType, ProcessShape processShape, bool isOutside, Point startPoint)
 {
     //新建一道工序
     Process process = new Process(processType, processShape, isOutside, ProcessNum, startPoint);
     this.Add(process);
 }