Ejemplo n.º 1
0
        /// <summary>
        /// 时间显示、链接状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GCode_Test_Load(object sender, EventArgs e)
        {
            this.label6.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //gAxis gaxis = gCodeService.GCode_axisCurrentLocation();
            timer          = new Timer();
            timer.Interval = 1000;
            timer.Tick    += new EventHandler(Timer_Tick);
            timer.Start();

            if (gCodeService.GCode_link())
            {
                this.lb_linkState.Text      = "已连接";
                this.lb_linkState.BackColor = Color.Green;
                MotionParameters mp = new MotionParameters()
                {
                };
                gCodeService.GCode_axisInitialization();            //轴初始化
                this.timer1.Start();
            }
            else
            {
                this.lb_linkState.Text      = "未连接";
                this.lb_linkState.BackColor = Color.Red;
                this.timer1.Stop();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 停止
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_stop_Click(object sender, EventArgs e)
        {
            timer3.Start();
            MotionParameters mp = new MotionParameters()
            {
                runningSpeed      = (int)nud_runningSpeed.Value,
                accTime           = (int)num_accTime.Value,
                decTime           = (int)num_decTime.Value,
                movementDistance  = (int)num_movementDistance.Value,
                returnToZeroSpeed = (int)num_returnToZeroSpeed.Value,
                axis = GetAxis()
            };

            gCodeService.GCode_stop(mp);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 手动运行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_manualRunning_MouseDown(object sender, MouseEventArgs e)
        {
            timer3.Start();
            MotionParameters mp = new MotionParameters()
            {
                runningSpeed      = (int)nud_runningSpeed.Value,
                accTime           = (int)num_accTime.Value,
                decTime           = (int)num_decTime.Value,
                movementDistance  = (int)num_movementDistance.Value,
                returnToZeroSpeed = (int)num_returnToZeroSpeed.Value,
                axis      = GetAxis(),
                direction = GetDirection()
            };

            gCodeService.GCode_manualRunning(mp);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 定长运行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_fixedLength_Click(object sender, EventArgs e)
        {
            timer3.Start();

            if (rb_xAxis.Checked)
            {
                this.lb_xAxisState.Text      = "未回零";
                this.lb_xAxisState.BackColor = Color.White;
            }
            else if (rb_yAxis.Checked)
            {
                this.lb_yAxisState.Text      = "未回零";
                this.lb_yAxisState.BackColor = Color.White;
            }
            else if (rb_zAxis.Checked)
            {
                this.lb_zAxisState.Text      = "未回零";
                this.lb_zAxisState.BackColor = Color.White;
            }
            else if (rb_uAxis.Checked)
            {
                this.lb_uAxisState.Text      = "未回零";
                this.lb_uAxisState.BackColor = Color.White;
            }

            MotionParameters mp = new MotionParameters()
            {
                runningSpeed      = (int)nud_runningSpeed.Value,
                accTime           = (int)num_accTime.Value,
                decTime           = (int)num_decTime.Value,
                movementDistance  = (int)num_movementDistance.Value,
                returnToZeroSpeed = (int)num_returnToZeroSpeed.Value,
                axis = GetAxis()
            };


            gCodeService.GCode_fixedLength(mp);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 轴选取控制、各轴回零状态显示
        /// </summary>
        /// <returns></returns>
        private ushort GetAxis()
        {
            ushort           axis = 0;
            MotionParameters mp   = new MotionParameters()
            {
            };

            if (rb_xAxis.Checked)
            {
                axis             = 0;
                rb_yAxis.Enabled = false;
                rb_zAxis.Enabled = false;
                rb_uAxis.Enabled = false;
                //if (gCodeService.GCode_axisState(mp)== 1 )
                //{

                //    rb_yAxis.Enabled = true;
                //    rb_zAxis.Enabled = true;
                //    rb_uAxis.Enabled = true;
                //    if (gCodeService.GCode_returnToZeroState(mp) == 1)
                //    {
                //        lb_xAxisState.Text = "已回零";
                //        lb_xAxisState.BackColor = Color.Green;
                //    }
                //    timer3.Stop();
                //}
            }
            else if (rb_yAxis.Checked)
            {
                axis             = 1;
                rb_xAxis.Enabled = false;
                rb_zAxis.Enabled = false;
                rb_uAxis.Enabled = false;
                //if (gCodeService.GCode_axisState(mp) == 1)
                //{
                //    rb_xAxis.Enabled = true;
                //    rb_zAxis.Enabled = true;
                //    rb_uAxis.Enabled = true;
                //    if (gCodeService.GCode_returnToZeroState(mp) == 1)
                //    {
                //        lb_xAxisState.Text = "已回零";
                //        lb_xAxisState.BackColor = Color.Green;
                //    }
                //    timer3.Stop();
                //}
            }
            else if (rb_zAxis.Checked)
            {
                axis             = 2;
                rb_yAxis.Enabled = false;
                rb_xAxis.Enabled = false;
                rb_uAxis.Enabled = false;

                //if (gCodeService.GCode_axisState(mp) == 1)
                //{
                //    rb_xAxis.Enabled = true;
                //    rb_yAxis.Enabled = true;
                //    rb_uAxis.Enabled = true;
                //    if (gCodeService.GCode_returnToZeroState(mp) == 1)
                //    {
                //        lb_xAxisState.Text = "已回零";
                //        lb_xAxisState.BackColor = Color.Green;
                //    }
                //    timer3.Stop();
                //}
            }
            else if (rb_uAxis.Checked)
            {
                axis             = 3;
                rb_yAxis.Enabled = false;
                rb_xAxis.Enabled = false;
                rb_zAxis.Enabled = false;

                //if (gCodeService.GCode_axisState(mp) == 1)
                //{
                //    rb_xAxis.Enabled = true;
                //    rb_zAxis.Enabled = true;
                //    rb_yAxis.Enabled = true;
                //    if (gCodeService.GCode_returnToZeroState(mp) == 1)
                //    {
                //        lb_xAxisState.Text = "已回零";
                //        lb_xAxisState.BackColor = Color.Green;
                //    }
                //    timer3.Stop();
                //}
            }
            return(axis);
        }
Ejemplo n.º 6
0
        private void timer3_Tick(object sender, EventArgs e)
        {
            //GetAxis();
            MotionParameters mp = new MotionParameters()
            {
                axis = GetAxis()
            };

            if (rb_xAxis.Checked)
            {
                if (gCodeService.GCode_axisState(mp) == 1)
                {
                    rb_yAxis.Enabled = true;
                    rb_zAxis.Enabled = true;
                    rb_uAxis.Enabled = true;
                    if ((gCodeService.GCode_returnToZeroState(mp) == 1) && (gCodeService.GCode_axisLocation(mp) == 0))
                    {
                        lb_xAxisState.Text      = "已回零";
                        lb_xAxisState.BackColor = Color.Green;
                    }
                    timer3.Stop();
                }
            }
            else if (rb_yAxis.Checked)
            {
                if (gCodeService.GCode_axisState(mp) == 1)
                {
                    rb_xAxis.Enabled = true;
                    rb_zAxis.Enabled = true;
                    rb_uAxis.Enabled = true;
                    if (gCodeService.GCode_returnToZeroState(mp) == 1 && (gCodeService.GCode_axisLocation(mp) == 0))
                    {
                        lb_yAxisState.Text      = "已回零";
                        lb_yAxisState.BackColor = Color.Green;
                    }
                    timer3.Stop();
                }
            }
            else if (rb_zAxis.Checked)
            {
                if (gCodeService.GCode_axisState(mp) == 1)
                {
                    rb_xAxis.Enabled = true;
                    rb_yAxis.Enabled = true;
                    rb_uAxis.Enabled = true;
                    if (gCodeService.GCode_returnToZeroState(mp) == 1 && (gCodeService.GCode_axisLocation(mp) == 0))
                    {
                        lb_zAxisState.Text      = "已回零";
                        lb_zAxisState.BackColor = Color.Green;
                    }
                    timer3.Stop();
                }
            }
            else if (rb_uAxis.Checked)
            {
                if (gCodeService.GCode_axisState(mp) == 1)
                {
                    rb_xAxis.Enabled = true;
                    rb_zAxis.Enabled = true;
                    rb_yAxis.Enabled = true;
                    if (gCodeService.GCode_returnToZeroState(mp) == 1 && (gCodeService.GCode_axisLocation(mp) == 0))
                    {
                        lb_uAxisState.Text      = "已回零";
                        lb_uAxisState.BackColor = Color.Green;
                    }
                    timer3.Stop();
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 指定轴停止运动
 /// </summary>
 /// <param name="mp"></param>
 public static void GCode_stop(MotionParameters mp)
 {
     GCode_RW_Data.GCode_stop(mp);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 定长运动
 /// </summary>
 /// <param name="mp"></param>
 public static void GCode_fixedLength(MotionParameters mp)
 {
     GCode_RW_Data.GCode_fixedLength(mp);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 读取回零状态
 /// </summary>
 /// <param name="mp"></param>
 /// <returns></returns>
 public static ushort GCode_returnToZeroState(MotionParameters mp)
 {
     return(GCode_RW_Data.GCode_returnToZeroState(mp));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 轴回零
 /// </summary>
 /// <param name="mp"></param>
 public static void GCode_axisReturnToZero(MotionParameters mp)
 {
     GCode_RW_Data.GCode_axisReturnToZero(mp);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 轴当前位置计数器值
 /// </summary>
 /// <param name="mp"></param>
 /// <returns></returns>
 public static double    GCode_axisLocation(MotionParameters mp)
 {
     return(GCode_RW_Data.GCode_axisLocation(mp));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 轴状态
 /// </summary>
 /// <param name="mp"></param>
 /// <returns></returns>
 public static short GCode_axisState(MotionParameters mp)
 {
     return(GCode_RW_Data.GCode_axisState(mp));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 手动运行
 /// </summary>
 /// <param name="mp"></param>
 public static void GCode_manualRunning(MotionParameters mp)
 {
     GCode_RW_Data.GCode_manualRunning(mp);
 }