using CowainHmi.S1;
using PCHMI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CowainHmi
{
    public partial class S1生产画面 : S1公共背景
    {

        public S1生产画面()
        {
            InitializeComponent();
        }

        private void btnSafeSignal_MouseDown(object sender, MouseEventArgs e)
        {
            DlgS1安全.GetInstance().Show();
            DlgS1安全.GetInstance().Activate();
        }

        private void 标签3_TextChanged(object sender, EventArgs e)
        {
            //配方名称改变时，发送给PLC
            //PCHMI.RT.SEND_SIEMENS_STRING(0, "U:S1_ProductName", this.txtName.Text.Trim());
            StringHelper.SendSiemensString(0, "U:S1_ProductName", 15, this.txtName.Text.Trim());
            for (int i = 0; i < 3; i++)
            {
                new PCHMI.配方().CALL_TECH("配方OP2020", this.txtName.Text.Trim());
            }
           
        }

        private void S1生产画面_Load(object sender, EventArgs e)
        {
            state = this.标签4.Value;
            this.timer1.Enabled = true;
        }
        private ulong state = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (state != this.标签4.Value && isChangeState)
            {
                PCHMI.OPTLOG.WLOG($"手动修改了零件加工状态，修改前={state},修改后={this.标签4.Value}");
                state = this.标签4.Value;
                isChangeState = false;
            }
        }
        private bool isChangeState = false;



        private void 标签4_MouseUp(object sender, MouseEventArgs e)
        {
            isChangeState = true;
        }
      
    }

}
