//使配方读取按钮接通1S
        private void TimerCloseRead_Tick(object sender, EventArgs e)
        {
            //配方读取
            int rsno = CS7TCP.WriteBool(Z通讯设置.plcHandle, 0x84, device.address, 63, 1, 0);

            if (rsno == 0)
            {
                //配方读取后要刷新数据到界面
                refreshPeifang();
                btn_Recipe_Read.BackColor = Color.Red;
            }
            //配方保存
            int rsno1 = CS7TCP.WriteBool(Z通讯设置.plcHandle, 0x84, device.address, 63, 0, 0);

            if (rsno1 == 0)
            {
                btn_Recipe_Save.BackColor = Color.Red;
            }
            //配方确认
            int rsno2 = CS7TCP.WriteBool(Z通讯设置.plcHandle, 0x84, device.address, 63, 2, 0);

            if (rsno2 == 0)
            {
                btn_Recipe_OK.BackColor = Color.Red;
            }
            TimerCloseRead.Enabled = false;
        }
        //对3个按钮进行判断,判断哪一个按钮被按下
        public void btn_MouseDown(object sender)
        {
            A0开机画面 parent = (A0开机画面)Parent.FindForm();

            System.Windows.Forms.Button button = (System.Windows.Forms.Button)sender;
            int rsno = 0;

            switch (button.Name)
            {
            case "btn_Recipe_Save":
                rsno = CS7TCP.WriteBool(Z通讯设置.plcHandle, 0x84, device.address, 63, 0, 1);
                if (rsno == 0)
                {
                    btn_Recipe_Save.BackColor = Color.LightGreen;
                    parent.showLog(device.typeName + device.index + "配方保存操作执行成功");
                    //插入数据到数据库数据表进行记录
                    saveToDatabaseTable();
                }
                else
                {
                    parent.showLog(device.typeName + device.index + "配方保存操作执行失败");
                    MessageBox.Show("配方保存操作执行失败");
                }
                break;

            case "btn_Recipe_Read":
                rsno = CS7TCP.WriteBool(Z通讯设置.plcHandle, 0x84, device.address, 63, 1, 1);
                if (rsno == 0)
                {
                    btn_Recipe_Read.BackColor = Color.LightGreen;
                    parent.showLog(device.typeName + device.index + "配方读取操作执行成功");
                }
                else
                {
                    parent.showLog(device.typeName + device.index + "配方读取操作执行失败");
                    MessageBox.Show("配方读取操作执行失败");
                }
                break;

            case "btn_Recipe_OK":
                rsno = CS7TCP.WriteBool(Z通讯设置.plcHandle, 0x84, device.address, 63, 2, 1);
                if (rsno == 0)
                {
                    btn_Recipe_OK.BackColor = Color.LightGreen;
                    parent.showLog(device.typeName + device.index + "配方确认操作执行成功");
                    //插入数据到数据库数据表进行记录
                    saveToDatabaseTable();
                }
                else
                {
                    parent.showLog(device.typeName + device.index + "配方确认操作执行失败");
                    MessageBox.Show("配方确认操作执行失败");
                }
                break;
            }
            //按下按钮后自动开始计时
            TimerCloseRead.Enabled = true;
        }