示例#1
0
        private void BntRunAuto_Click(object sender, EventArgs e)
        {
            // runOrStop, true for run, false for stop
            if (runOrStop)
            {
                // Change the button to Stop function
                this.BntRunAuto.Text = "终止";

                // Disable manual menu to avoid
                this.MenuManual.Enabled  = false;
                this.MenuParaSet.Enabled = false;
                this.MenuComSet.Enabled  = false;

                // Init auto control
                float initTemp     = float.Parse(TxtInitTemp.Text);
                float intervalTemp = float.Parse(TxtIntervalTemp.Text);
                autoStep = new StepControl(initTemp, intervalTemp, intervalTemp > 0);

                // Record the start time
                GlbVars.ctrlStartTime = DateTime.Now;
                // Run
                blinkTimer.Enabled = true;
                autoStep.ThisTurn();
                GlbVars.tempReadTimer.Enabled = true;
            }
            else
            {
                // Change the button to Stop function
                this.BntRunAuto.Text = "运行";

                // Enable all menus
                this.MenuManual.Enabled  = true;
                this.MenuParaSet.Enabled = true;
                this.MenuComSet.Enabled  = true;

                // Stop timer
                GlbVars.tempReadTimer.Enabled = false;
                blinkTimer.Enabled            = false;

                // Fix flucShow to read and show
                PicFlucShow.BackColor = Color.Red;
                PicFlucShow.Visible   = true;

                // Finish the temperature data file
                Data2File.FinishTempFile();
            }

            runOrStop = !runOrStop;
        }
示例#2
0
        private void BntRun_Click(object sender, EventArgs e)
        {
            // runOrStop, true for run, false for stop
            if (runOrStop)
            {
                // Change the button to Stop function
                this.BntRun.Text = "终止";

                // Init auto control
                float initTemp     = float.Parse(TxtInitTemp.Text);
                float intervalTemp = float.Parse(TxtIntervalTemp.Text);
                autoStep = new StepControl(initTemp, intervalTemp, intervalTemp > 0);

                // Record the start time
                GlbVars.ctrlStartTime = DateTime.Now;
                // Run
                blinkTimer.Enabled = true;
                autoStep.ThisTurn();
                GlbVars.tempReadTimer.Enabled = true;
            }
            else
            {
                // Change the button to Stop function
                this.BntRun.Text = "运行";

                // Stop timer
                GlbVars.tempReadTimer.Enabled = false;
                blinkTimer.Enabled            = false;

                // Fix Blink to visible
                BlinkBlink.Visible = true;

                // Finish the temperature data file
                Data2File.FinishTempFile();
            }

            runOrStop = !runOrStop;
        }
示例#3
0
        /// <summary>
        /// Timer to check if this turn of run is over
        /// </summary>
        private void CheckTimer_Tick(object sender, System.Timers.ElapsedEventArgs e)
        {
            float temperature = 0;
            bool  steady      = autoStep.CheckFluc(out temperature);

            // Update UI
            this.Invoke(new EventHandler(delegate
            {
                // Update temperature show
                this.LblTempShowAuto.Text = temperature.ToString("0.000 ℃");
                // Save temperature data
                Data2File.Temp2File(temperature);

                // Update fluc flag
                if (steady)
                {
                    this.PicFlucShow.BackColor = Color.Green;
                }
                else
                {
                    this.PicFlucShow.BackColor = Color.Red;
                }
            }));

            // If steady, inform conductivity measurement equipment
            if (steady)
            {
                // Create a critical region
                GlbVars.tempReadTimer.Enabled = false;
                autoStep.InformCondMeas();
                GlbVars.tempReadTimer.Enabled = true;

                int remainTimes = int.Parse(TxtTimes.Text);

                // Remain times dcrease 1
                remainTimes--;
                this.Invoke(new EventHandler(delegate
                {
                    this.TxtTimes.Text = remainTimes.ToString();
                }));

                // If there no remain times, finish all test
                if (remainTimes == 0)
                {
                    // Game over
                    GlbVars.tempReadTimer.Enabled = false;
                    MessageBox.Show("所有测试结束");

                    // Finish the temperature data file
                    Data2File.FinishTempFile();

                    // Click Run button to change the status to STOP status
                    this.Invoke(new EventHandler(delegate
                    {
                        this.BntRunAuto.PerformClick();
                    }));
                }
                // If there is, start next turn of run
                else
                {
                    autoStep.NextTurn();
                }
            }
        }