Ejemplo n.º 1
0
        private void button_AMove_Click(object sender, EventArgs e)
        {
            double ratio_ = Convert.ToDouble(this.numericUpDown_ratio.Value);
            double pos_   = Convert.ToDouble(this.numericUpDown_Pos.Value);

            Motion.Axis(axisId_).AbsMove(pos_, ratio_);
        }
Ejemplo n.º 2
0
        private void button_RMoveN_Click(object sender, EventArgs e)
        {
            double ratio_ = Convert.ToDouble(this.numericUpDown_ratio.Value);
            double dist_  = Convert.ToDouble(this.numericUpDown_Dis.Value);

            Motion.Axis(axisId_).RelMove(-dist_, ratio_);
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            //运动测试
            const int posNum_ = 5;

            double[] posX = new double[posNum_] {
                0, 100, 100, 0, 0
            };
            double[] posY = new double[posNum_] {
                0, 0, 100, 100, 0
            };
            int times_ = Convert.ToInt32(numericUpDown_Times.Value);

            while (times_-- > 0)
            {
                for (int i = 0; i < posNum_; i++)
                {
                    Motion.Axis(X).AbsMove(posX[i]);
                    Motion.Axis(Y).AbsMove(posY[i]);

                    Motion.Axis(X).MotionDone();
                    Motion.Axis(Y).MotionDone();
                }
            }
        }
Ejemplo n.º 4
0
        public DebugUi()
        {
            InitializeComponent();
            int i, j = 0;

            this.dataGridView_Axis.Rows.Clear();
            this.dataGridView_Axis.Rows.Add(Motion.AxisNum);

            _bitGreen  = _GenColorImage(Color.Green);
            _bitGray   = _GenColorImage(Color.LightGray);
            _bitRed    = _GenColorImage(Color.Red);
            _bitMagent = _GenColorImage(Color.DarkMagenta);


            for (i = 0; i < Motion.AxisNum; i++)
            {
                j = 0;
                // this.dataGridView_Axis.Rows[i].HeaderCell.Value = i.ToString();
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = i.ToString();
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = Motion.Axis(i).name;
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = "0.000";
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = "0.000";

                this.dataGridView_Axis.Rows[i].Cells[10].Value = "配置";
            }
        }
Ejemplo n.º 5
0
        private void dataGridView_Axis_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0 || e.RowIndex >= Motion.AxisNum)
                {
                    return;
                }
                switch (e.ColumnIndex)
                {
                case 9:
                    bool cmd_ = Convert.ToBoolean(this.dataGridView_Axis.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue);
                    Motion.Axis(e.RowIndex).SetEnabled(cmd_);
                    break;

                case 10:
                    AxisConfig a = new AxisConfig(e.RowIndex);
                    a.ShowDialog(this);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 6
0
        private void button7_Click(object sender, EventArgs e)
        {
            //线性模式触发
            double start    = -10;
            double interval = 10;
            int    number   = 10;
            int    err      = 0;

            err = Motion.Axis(X).TriggerLinear(0, start, interval, number);
        }
Ejemplo n.º 7
0
 private void dataGridView_Axis_SelectionChanged(object sender, EventArgs e)
 {
     if (dataGridView_Axis.CurrentRow.Index < 0 || dataGridView_Axis.CurrentRow.Index >= Motion.AxisNum)
     {
         splitContainer1.Panel2.Enabled = false;
         return;
     }
     splitContainer1.Panel2.Enabled = true;
     axisId_         = dataGridView_Axis.CurrentRow.Index;
     label_Name.Text = Motion.Axis(axisId_).name;
 }
Ejemplo n.º 8
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int j = 0;

            for (int i = 0; i < Motion.AxisNum; i++)
            {
                j = 2;
                MotionIO mio_ = Motion.Axis(i).MIO;
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = Motion.Axis(i).CmdPos.ToString();
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = Motion.Axis(i).FbkPos.ToString();
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = mio_.NEL ? _bitMagent : _bitGray;
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = mio_.PEL ? _bitMagent : _bitGray;
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = mio_.Moving ? _bitGray : _bitGreen;
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = mio_.Alarm ? _bitRed : _bitGray;
                this.dataGridView_Axis.Rows[i].Cells[j++].Value = mio_.Enabled ? _bitGreen : _bitGray;
            }
        }
Ejemplo n.º 9
0
        private void button4_Click(object sender, EventArgs e)
        {
            //点表模式触发
            double start    = 80;
            double interval = -10;
            int    number   = 10;
            int    err      = 0;

            var ch0 = new List <double>();
            var ch1 = new List <double>();

            for (int i = 0; i < number; i++)
            {
                ch0.Add(start + i * interval);
                ch1.Add(start + i * interval + 1);
            }
            err = Motion.Axis(X).TriggerData(ch0, ch1);
        }
Ejemplo n.º 10
0
        public AxisConfig(int i)
        {
            InitializeComponent();
            axis                    = Motion.Axis(i);
            this.Text               = string.Format("轴{0}: {1}", axis.id, axis.name);
            this.textBox_Id.Text    = axis.id.ToString();
            this.textBox_Name.Text  = axis.name;
            this.textBox_Pulse.Text = axis.plsPerMm.ToString();

            this.comboBox_Home.SelectedIndex = (int)axis.homePara.mode;
            this.textBox_HomeAcc.Text        = axis.homePara.acc.ToString();
            this.textBox_HomeVel.Text        = axis.homePara.vel.ToString();
            this.textBox_Offset.Text         = axis.homePara.offset.ToString();
            this.textBox_HomeTimeout.Text    = axis.homePara.maxSeconds.ToString();

            this.textBox_Acc.Text     = axis.motionPara.acc.ToString();
            this.textBox_Vel.Text     = axis.motionPara.maxVel.ToString();
            this.textBox_Timeout.Text = axis.motionPara.maxSeconds.ToString();
        }
Ejemplo n.º 11
0
        private void button6_Click(object sender, EventArgs e)
        {
            double v_ = 200;  // mm/s
            double a_ = 2000; // mm/s^2

            double trigInterval = 3.0;
            double xc = 125, yc = 160; //扫描圆心
            double r = 100;            //扫描区域半径

            Axis    AX     = Motion.Axis(X);
            Axis    AY     = Motion.Axis(Y);
            Point2i axes   = new Point2i(X, Y);
            double  offset = -0.2; //两通道触发间隔


            Point2d pos2d_start = new Point2d();
            Point2d pos2d_end   = new Point2d();

            int err_ = 0;

            int direction_ = 0;

            bool use_tirgger_data = false;

            for (int i = 0; i < 2 * r / trigInterval - 1; i++)
            {
                //step0: 计算点位
                direction_    = (i % 2 == 0) ? 1 : -1;
                pos2d_start.y = yc - r + trigInterval * (i + 1);
                pos2d_start.x = xc - direction_ * Math.Sqrt(r * r - (pos2d_start.y - yc) * (pos2d_start.y - yc));
                pos2d_end.x   = 2 * xc - pos2d_start.x;
                pos2d_end.y   = pos2d_start.y - 0.3 * direction_; //Y适当错位,模拟斜着运动扫描(这里模拟走一个圆)
                Console.WriteLine("{0}: ({1}, {2}) -> ({3}, {4})", i, pos2d_start.x, pos2d_start.y, pos2d_end.x, pos2d_end.y);
                //step1: 运动到起点
                //XY移动到起点 AbsMoveOver = AbsMove + MotionDone
                //这里也可以用 Motion.Axis(X).AbsMove();
                if ((err_ = Motion.AbsMoveOver(axes, pos2d_start)) != 0)
                {
                    MessageBox.Show("Error: " + err_);
                    return;
                }
                //step2: 设置触发位置
                double triggerPos_ = pos2d_start.x + 0.5 * direction_; //第一个位置和当前位置相距一毫米
                //位置列表,绝对位置,单位mm
                if (use_tirgger_data)
                {
                    var trigPos0_ = new List <double>();
                    while ((pos2d_end.x - triggerPos_) * direction_ > 0)
                    {
                        trigPos0_.Add(triggerPos_);     //通道0触发光源
                        triggerPos_ += direction_ * trigInterval;
                    }
                    if ((err_ = AX.TriggerData(trigPos0_, direction_ * offset)) != 0)
                    {
                        MessageBox.Show("Error: " + err_);
                        return;
                    }
                }
                else //等间隔触发,绝对位置,单位mm
                {
                    int triggerCnt_ = (int)((Math.Abs(pos2d_end.x - pos2d_start.x) - 1.0) / trigInterval); //保证最后一个点至少与起点相距0.5mm
                    if ((err_ = AX.TriggerLinear(triggerPos_, direction_ * trigInterval, triggerCnt_, direction_ * offset)) != 0) //触发相机和光源
                    {
                        MessageBox.Show("Error: " + err_);
                        return;
                    }
                }

                //step3: 插补运动
                //LineOver = Line+LineDone
                if ((err_ = Motion.LineOver(axes, pos2d_end, v_, a_)) != 0)
                {
                    MessageBox.Show("Error: " + err_);
                    return;
                }

                //step4: 停止触发并process images
                if ((err_ = AX.TriggerStop()) != 0)
                {
                    MessageBox.Show("Error: " + err_);
                    return;
                }
            }
        }
Ejemplo n.º 12
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     Motion.Axis(X).SoftwareTrigger(1);
     System.Threading.Thread.Sleep(1);
     Motion.Axis(X).SoftwareTrigger(0);
 }
Ejemplo n.º 13
0
 private void button10_Click(object sender, EventArgs e)
 {
     //轴上电使能
     Motion.Axis(X).SetEnabled(true);
     Motion.Axis(Y).SetEnabled(true);
 }
Ejemplo n.º 14
0
 private void button_Home_Click(object sender, EventArgs e)
 {
     Motion.Axis(axisId_).Home();
 }
Ejemplo n.º 15
0
 private void button_Clear_Click(object sender, EventArgs e)
 {
     Motion.Axis(axisId_).ClearAlarm();
 }
Ejemplo n.º 16
0
 private void button5_Click(object sender, EventArgs e)
 {
     Motion.Axis(X).TriggerStop();
 }
Ejemplo n.º 17
0
 private void button3_Click(object sender, EventArgs e)
 {
     Motion.Axis(X).ZeroPos();
     Motion.Axis(Y).ZeroPos();
 }
Ejemplo n.º 18
0
 private void button9_Click(object sender, EventArgs e)
 {
     Motion.Axis(X).Home();
     Motion.Axis(Y).Home();
 }