コード例 #1
0
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            if (this.Visible == false)
            {
                timer1.Enabled = false;
                return;
            }

            if (axis != null)
            {
                try
                {
                    ledEnabled.State = axis.IsEnabled;
                    ledHomed.State   = axis.IsHomed;

                    buttonHome.Enabled = axis.IsEnabled;
                    buttonMove.Enabled = axis.IsEnabled && ledHomed.State;
                    buttonStop.Enabled = axis.IsEnabled;

                    fmtActualPosition.Number  = axis.GetActualPosition();
                    fmtCommandPosition.Number = axis.GetCommandPosition();

                    if (checkHomedStatus)
                    {
                        TimeSpan elapsed = DateTime.Now.Subtract(homeStart);
                        if (elapsed.Seconds > 10)
                        {
                            checkHomedStatus = false;
                            if (!axis.IsHomed)
                            {
                                DisplayError("Failed to home within 10 seconds");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    DisplayError("Status update error: " + ex.Message);
                }
            }
        }