serialPort.cs 3.6 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dal;
using Comm;
using MachineDll;

namespace serialPortSoft
{
    public partial class serialPort : Form
    {
        #region 定义
        private double washTime;
        private double testTime;
        private readonly Fuction fuction = new Fuction();
        private TheMachine theMachine;
        #endregion

        public serialPort()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PortSetting ps = new PortSetting();
            ps.Show();
        
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.groupBox1.ForeColor = Color.Gray;
            this.label1.ForeColor = Color.Gray;
            this.label2.ForeColor = Color.Gray;
            this.textBox1.ForeColor = Color.Gray;
            this.textBox2.ForeColor = Color.Gray;
            this.button4.ForeColor = Color.Gray;
            this.button5.ForeColor = Color.Gray;
            this.button6.ForeColor = Color.Gray;
            this.button7.ForeColor = Color.Gray;
            this.button8.ForeColor = Color.Gray;
            this.button9.ForeColor = Color.Gray;
            this.button10.ForeColor = Color.Gray;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.groupBox1.ForeColor = Color.Black;
            this.label1.ForeColor = Color.Black;
            this.label2.ForeColor = Color.Black;
            this.textBox1.ForeColor = Color.Black;
            this.textBox2.ForeColor = Color.Black;
            this.button5.ForeColor = Color.Black;
            this.button6.ForeColor = Color.Black;
            this.button8.ForeColor = Color.Black;
            this.button10.ForeColor = Color.Black;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
        /**
         * 清洗功能
         */
        private void button5_Click(object sender, EventArgs e)
        {
            this.button4.ForeColor = Color.Gray;
            this.button7.ForeColor = Color.Black;
            this.button9.ForeColor = Color.Black;
            try
            {
                theMachine.GetControllor.OpenY1();
                System.Threading.Thread.Sleep(1500);
                theMachine.GetControllor.OpenY2();
                System.Threading.Thread.Sleep(1500);
                theMachine.GetControllor.CloseY0();
                this.button6.Text = "正常";
            }catch(Exception ex){
                this.button6.Text = "异常";
            }
        }
        /**
         * 过滤功能
         */
        private void button8_Click(object sender, EventArgs e)
        {
            this.button4.ForeColor = Color.Black;
            this.button7.ForeColor = Color.Gray;
            this.button9.ForeColor = Color.Black;
            try
            {
                theMachine.GetControllor.CloseY1();
                System.Threading.Thread.Sleep(1500);
                theMachine.GetControllor.OpenY2();
                System.Threading.Thread.Sleep(1500);
                theMachine.GetControllor.OpenY0();
                this.button6.Text = "正常";
            }
            catch
            {
                this.button6.Text = "异常";
            }
 
        }

    }
}