Ejemplo n.º 1
0
        public void ReadCadPoint(ref double[,] scans, int startIndex, int length)
        {
            if (length > scans.GetLength(0))
            {
                throw new ArgumentOutOfRangeException("Reading out of array bounds error");
            }
            int num = this._cadDataPoints.Count();

            for (int i = 0; i < length; i++)
            {
                Point point = this._cadDataPoints[this.currentReadIndex++];
                scans[startIndex + i, 0] = point.X;
                scans[startIndex + i, 1] = point.Y;
                scans[startIndex + i, 2] = StaticTool.CaculateFocus((uint)StaticTool.GetRadius((uint)point.X, (uint)point.Y)) + Parameter.cadFilescanPara.FocusOffset; //聚焦
                scans[startIndex + i, 3] = 32767;
                scans[startIndex + i, 4] = 32767;
                scans[startIndex + i, 5] = Parameter.cadFilescanPara.BeamValue;                              //this._preHeatScan[5];//power
                scans[startIndex + i, 6] = StaticTool.CaculateLinerVal((uint)point.X, (uint)point.Y, true);  //this._preHeatScan[6];//astX
                scans[startIndex + i, 7] = StaticTool.CaculateLinerVal((uint)point.X, (uint)point.Y, false); //this._preHeatScan[7];//astY
                if (this.currentReadIndex == num)
                {
                    this.currentReadIndex = 0;
                }
            }
        }
Ejemplo n.º 2
0
        private List <Point> Jump(Point start, Point end, out List <FocusAst> focusAsts)
        {
            focusAsts = new List <FocusAst>();
            double addX = 0, addY = 0;
            Line   jumpLine      = new Line(start, end);
            int    jumpPointsNum = 200;                                              //要求插点时间为200us
            //计算插点个数
            int    num    = (int)(jumpPointsNum * this._preHeatFrequency / 1000000); //除以1000000,将s转为us
            double lineX1 = jumpLine.Dx * 0.85;
            double lineX2 = jumpLine.Dx - lineX1;
            double lineY1 = jumpLine.Dy * 0.85;
            double lineY2 = jumpLine.Dy - lineY1;

            if (num != 1)
            {
                addX = lineX2 / (num - 1);
                addY = lineY2 / (num - 1);
            }
            List <Point> jumpPoints = new List <Point>();

            for (int i = 0; i < num; i++)//从0开始,起点要扫一次
            {
                ushort x = (ushort)(start.X + i * addX + lineX1);
                ushort y = (ushort)(start.Y + i * addY + lineY1);
                jumpPoints.Add(new Point(x, y));
                ushort focus = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius((uint)x, (uint)y)) + _focusOffset);
                ushort astX  = (ushort)(StaticTool.CaculateLinerVal((uint)x, (uint)y, true));
                ushort astY  = (ushort)(StaticTool.CaculateLinerVal((uint)x, (uint)y, false));
                focusAsts.Add(new FocusAst(focus, astX, astY));
            }
            return(jumpPoints);
        }
Ejemplo n.º 3
0
 private void BtnTest_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(tx.Text.Trim()) || string.IsNullOrEmpty(ty.Text.Trim()))
     {
         return;
     }
     testX.Text = StaticTool.CaculateLinerVal(uint.Parse(tx.Text.Trim()), uint.Parse(ty.Text.Trim()), true).ToString();
     testY.Text = StaticTool.CaculateLinerVal(uint.Parse(tx.Text.Trim()), uint.Parse(ty.Text.Trim()), false).ToString();
 }
Ejemplo n.º 4
0
        private void ChbCal_CheckedChanged(object sender, EventArgs e)
        {
            if (chbCal.Checked && _beamScan != null)
            {
                _beamScan.Astig1 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), true);
                _beamScan.Astig2 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), false);

                _beamScan.Focus = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()))) + ushort.Parse(txtFocusAdd.Text.Trim()));
            }
        }
Ejemplo n.º 5
0
        private List <Point> Hack(Line line, ref double rest, out List <FocusAst> focusAsts)
        {
            double       a    = ((line.Length / ((double)this._preHeatSpeed)) * this._preHeatFrequency) - rest; //点的个数减去偏移
            double       num3 = line.Dx / a;                                                                    //x增量
            double       num4 = line.Dy / a;                                                                    //y增量
            double       x    = line.Start.X;                                                                   //起点x
            double       y    = line.Start.Y;                                                                   //起点y
            List <Point> list = new List <Point>();

            focusAsts = new List <FocusAst>();
            for (int i = 0; i < a; i++)
            {
                ushort num8  = (ushort)((num3 * (i + rest)) + x);
                ushort num9  = (ushort)((num4 * (i + rest)) + y);
                ushort focus = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius((uint)num8, (uint)num9)) + _focusOffset);
                ushort astX  = (ushort)(StaticTool.CaculateLinerVal((uint)num8, (uint)num9, true));
                ushort astY  = (ushort)(StaticTool.CaculateLinerVal((uint)num8, (uint)num9, false));
                list.Add(new Point((double)num8, (double)num9));
                focusAsts.Add(new FocusAst(focus, astX, astY));
            }
            rest = Math.Ceiling(a) - a;
            return(list);
        }
Ejemplo n.º 6
0
 private void AddValuesTimer_Tick(object sender, EventArgs e)
 {
     if (isAstXAdd)
     {
         ushort.TryParse(txtast_X.Text, out ushort value);
         value += 150;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Astig1 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), true);
             }
             else
             {
                 _beamScan.Astig1 = value;
             }
         }
         txtast_X.Text = value.ToString();
     }
     else if (isAstXMinus)
     {
         ushort.TryParse(txtast_X.Text, out ushort value);
         value -= 150;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Astig1 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), true);
             }
             else
             {
                 _beamScan.Astig1 = value;
             }
         }
         txtast_X.Text = value.ToString();
     }
     else if (isAstYAdd)
     {
         ushort.TryParse(txtast_Y.Text, out ushort value);
         value += 150;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Astig2 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), false);
             }
             else
             {
                 _beamScan.Astig2 = value;
             }
         }
         txtast_Y.Text = value.ToString();
     }
     else if (isAstYMinus)
     {
         ushort.TryParse(txtast_Y.Text, out ushort value);
         value -= 150;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Astig2 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), false);
             }
             else
             {
                 _beamScan.Astig2 = value;
             }
         }
         txtast_Y.Text = value.ToString();
     }
     else if (isFocusAdd)
     {
         ushort.TryParse(txtFo.Text, out ushort value);
         value += 10;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Focus = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()))) + ushort.Parse(txtFocusAdd.Text.Trim()));
             }
             else
             {
                 _beamScan.Focus = value;
             }
         }
         txtFo.Text = value.ToString();
     }
     else if (isFocusMinus)
     {
         ushort.TryParse(txtFo.Text, out ushort value);
         value -= 10;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Focus = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()))) + ushort.Parse(txtFocusAdd.Text.Trim()));
             }
             else
             {
                 _beamScan.Focus = value;
             }
         }
         txtFo.Text = value.ToString();
     }
     else if (isXAdd)
     {
         ushort.TryParse(txtX.Text, out ushort value);
         if (value > Parameter.Points.X22)
         {
             _beamScan.X = (ushort)Parameter.Points.X22;
             txtX.Text   = Parameter.Points.X22.ToString();
             return;
         }
         value += 50;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.X      = value;
                 _beamScan.Focus  = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()))) + ushort.Parse(txtFocusAdd.Text.Trim()));
                 _beamScan.Astig1 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), true);
                 _beamScan.Astig2 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), false);
             }
             else
             {
                 _beamScan.X = value;
                 //Debug.Write("X=" + _beamScan.X.ToString());
             }
         }
         txtX.Text = value.ToString();
     }
     else if (isXMinus)
     {
         ushort.TryParse(txtX.Text, out ushort value);
         if (value < Parameter.Points.X11)
         {
             _beamScan.X = (ushort)Parameter.Points.X11;
             txtX.Text   = Parameter.Points.X11.ToString();
             return;
         }
         value -= 50;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.X      = value;
                 _beamScan.Focus  = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()))) + ushort.Parse(txtFocusAdd.Text.Trim()));
                 _beamScan.Astig1 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), true);
                 _beamScan.Astig2 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), false);
             }
             else
             {
                 _beamScan.X = value;
                 Debug.WriteLine("X=" + value.ToString());
             }
         }
         txtX.Text = value.ToString();
     }
     else if (isYAdd)
     {
         ushort.TryParse(txtY.Text, out ushort value);
         if (value > Parameter.Points.Y22)
         {
             _beamScan.X = (ushort)Parameter.Points.Y22;
             txtY.Text   = Parameter.Points.Y22.ToString();
             return;
         }
         value += 50;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Y      = value;
                 _beamScan.Focus  = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()))) + ushort.Parse(txtFocusAdd.Text.Trim()));
                 _beamScan.Astig1 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), true);
                 _beamScan.Astig2 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), false);
             }
             else
             {
                 _beamScan.Y = value;
             }
         }
         txtY.Text = value.ToString();
     }
     else if (isYMinus)
     {
         ushort.TryParse(txtY.Text, out ushort value);
         if (value < Parameter.Points.Y11)
         {
             _beamScan.X = (ushort)Parameter.Points.Y11;
             txtY.Text   = Parameter.Points.Y11.ToString();
             return;
         }
         value -= 50;
         if (_beamScan != null)
         {
             if (chbCal.Checked)
             {
                 _beamScan.Y      = value;
                 _beamScan.Focus  = (ushort)(StaticTool.CaculateFocus((uint)StaticTool.GetRadius(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()))) + ushort.Parse(txtFocusAdd.Text.Trim()));
                 _beamScan.Astig1 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), true);
                 _beamScan.Astig2 = (ushort)StaticTool.CaculateLinerVal(ushort.Parse(txtX.Text.Trim()), ushort.Parse(txtY.Text.Trim()), false);
             }
             else
             {
                 _beamScan.Y = value;
             }
         }
         txtY.Text = value.ToString();
     }
     // double[] scan = { _beamScan.X, _beamScan.Y ,_beamScan.Focus,
     //32767,32767, _beamScan.Astig1, _beamScan.Astig2,_beamScan.BeamCurrent};
     double[] scan = { _beamScan.X, _beamScan.Y, _beamScan.Focus,
                       32767,             32767, _beamScan.BeamCurrent,_beamScan.Astig1, _beamScan.Astig2 };
     //BeamStart(SignalCardModeEnum.SingleOut);
     if (!_isDirecStop)
     {
         GlobleParameter._eBMBeamScan.WriteRaw(scan);
     }
 }