Beispiel #1
0
 public void RepairXPosAndLength(float ypos, CutLine line)
 {
     if (!Fixed)//圆形工件
     {
         float offsetX = 2 * Globals.TabCenter.X - Center.X;
         float r       = Length / 2;                         //为圆形的半径
         float a       = Math.Abs(ypos - Center.Y) % Length; //相对距离对直径求余数
         if (a > r)                                          //如果距离在半径和直径中间
         {
             a = Length - a;                                 //直接求剩余距离
         }
         float b = 0;
         if (a != r)
         {
             b = (float)Math.Sqrt(r * r - a * a);
         }
         line.Length = b * 2 + PreWidth * 2;             //双边预留
         if (line.Dir)
         {
             line.StartPos.X = offsetX + (b + PreWidth);// //正向划切 E|<------------<--|S
         }
         else
         {
             line.StartPos.X = offsetX - (b + PreWidth);////反向划切 S|-->------------>|E
         }
     }
 }
Beispiel #2
0
 public void RepairCutLines(int num)
 {
     if (num > cuttingIndex)
     {
         if (num < Count)
         {
             //totalLine = num;
             var ls = lines.Where(c => c.Index >= num).ToList();
             foreach (var item in ls)
             {
                 lines.Remove(item);
                 if (this.CH != null && this.CH.StandMode == false)//非标准模式
                 {
                     this.CH.Lines.Remove(item);
                 }
             }
         }
         else
         {
             int   max     = num - Count;
             bool  dir     = this.Lines.Last().Dir;
             float offsetX = 2 * Globals.TabCenter.X - Center.X;
             int   index   = 0;
             if (this.CH != null)
             {
                 index = this.CH.Lines.IndexOf(this.Lines.Last());
             }
             for (int i = 0; i < max; i++)
             {
                 CutLine line = new CutLine();
                 line.CutStep   = CutStep.Ready;
                 line.ReDepth   = this.ReDepth;
                 line.ReDepth2  = this.ReDepth2;
                 line.SinDir    = this.SinDir;
                 line.Abs       = false;//走相对运动
                 line.Speed     = this.Speed;
                 line.BackSpeed = this.BackSpeed;
                 line.SelfPos   = this.SelfPos;
                 line.Length    = this.Length + PreWidth * 2;
                 if (SinDir || Dual)//单向划切或者多刀划切
                 {
                     line.Dir = this.Dir;
                 }
                 else//双向划切
                 {
                     dir      = !dir;//方向取反
                     line.Dir = dir;
                 }
                 line.StartPos.Y = Forward ? indexStep : -indexStep;
                 line.StartPos.X = line.Dir ? (offsetX + line.Length / 2) : (offsetX - line.Length / 2);//暂时不修正划切起始位置 等划切开始时修正
                 Add(line);
                 if (this.CH != null && this.CH.StandMode == false)
                 {
                     this.CH.Lines.Insert(index++, line);
                 }
             }
         }
     }
 }
Beispiel #3
0
        public virtual void InitCutRunData(bool create = true)
        {
            this.Lines.Clear();
            bool  dir     = this.Dir; //正向还是反向
            float offsetX = 2 * Globals.TabCenter.X - Center.X;

            SetStyle(CutState.Cutting | CutState.Complate | CutState.Pause, false);
            cuttingIndex = 0;
            if (create)
            {
                for (int i = 0; i < totalLine; i++)
                {
                    float   h    = 0;//距离工作台中心距离
                    CutLine line = new CutLine();
                    line.CutStep   = CutStep.Ready;
                    line.ReDepth   = this.ReDepth;
                    line.ReDepth2  = this.ReDepth2;
                    line.SinDir    = this.SinDir;
                    line.Abs       = false;//走相对运动
                    line.Speed     = this.Speed;
                    line.BackSpeed = this.BackSpeed;
                    line.SelfPos   = this.SelfPos;
                    if (SinDir || Dual)//单向划切或者多刀划切
                    {
                        line.Dir = this.Dir;
                    }
                    else//双向划切
                    {
                        line.Dir = dir;
                        dir      = !dir;
                    }
                    float step = 0;
                    if (Forward)//向前划切
                    {
                        step = indexStep;
                    }
                    else
                    {
                        step = -indexStep;
                    }
                    h = StartPos.Y + step * i;
                    if (line.Abs)
                    {
                        line.StartPos.Y = h;    //Y轴的位置为当前位置+乘以偏移位置*i
                    }
                    else
                    {
                        if (i == 0)
                        {
                            line.StartPos.Y = 0;    //第一刀分度配置为0
                        }
                        else
                        {
                            line.StartPos.Y = step;
                        }
                    }
                    if (Fixed)                                                     //方片处理
                    {
                        line.Length = this.Length + PreWidth * 2;                  //为双边预留
                        if (line.Dir)                                              //正向划切 E|<------------<--|S
                        {
                            line.StartPos.X = offsetX + line.Length / 2;           //起始位置-单边预留
                        }
                        else                                                       //反向划切 S|-->------------>|E
                        {
                            line.StartPos.X = offsetX - line.Length / 2;           //起始位置-宽度-单边预留
                        }
                    }
                    else                                                //宽度进行处理
                    {
                        float r = Length / 2;                           //为圆形的半径
                        float a = Math.Abs(h - Center.Y) % Length;      //相对距离对直径求余数
                        if (a > r)                                      //如果距离在半径和直径中间
                        {
                            a = Length - a;                             //直接求剩余距离
                        }
                        float b = 0;
                        if (a != r)
                        {
                            b = (float)Math.Sqrt(r * r - a * a);
                        }
                        line.Length = b * 2 + PreWidth * 2;             //双边预留
                        if (line.Dir)
                        {
                            line.StartPos.X = offsetX + (b + PreWidth);// //正向划切 E|<------------<--|S
                        }
                        else
                        {
                            line.StartPos.X = offsetX - (b + PreWidth);////反向划切 S|-->------------>|E
                        }
                    }
                    this.Add(line);
                }
                totalLine = this.Lines.Count;
            }
        }
Beispiel #4
0
 public bool Remove(CutLine item)
 {
     return(Lines.Remove(item));
 }
Beispiel #5
0
 public void Add(CutLine item)
 {
     item.Index = Lines.Count;
     item.Seg   = this;
     Lines.Add(item);
 }