using MesWorkMqtt;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Receiving;

using bizFacade;
using MesWorkMqtt;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MQTTnet;
using System.Threading;
using DoWhatPlc;
using MesServerWork;

namespace SyUpLoad
{
    public partial class PartLoad
    {
        private void MesServerFunction1(string msgValue)
        {
            try
            {
                DoWhatPlc.ReturnValueString rv = Newtonsoft.Json.JsonConvert.DeserializeObject<DoWhatPlc.ReturnValueString>(msgValue);

                string OpName;
                string tagValue;
                string fun;
                string mesServerCode;
                string mesServerdllName;

                OpName = rv.OpName;
                switch (rv.TagValue.ToLower())
                {
                    case "false":
                        tagValue = "0";
                        break;
                    case "true":
                        tagValue = "1";
                        break;
                    default:
                        tagValue = rv.TagValue;
                        break;
                }
                switch(rv.TagTypeCodeID)
                {
                    //PLC 申请发动机编号 PartLoad
                    case "43":
                        break;
                    //PLC 传递机型 EngineTypeGetOverPLC
                    case "44":
                        break;
                    //MES 传递机型 EngineTypeGetOverMES
                    case "5":
                        break;
                    //MES 工作完成 MaterialVerifyOver
                    case "7":
                        break;
                }

            }
            catch (Exception err)
            {
                ////ApplicationLog.WriteLog(err, "MesServerFunction");
            }
        }
      

        private void fun_EngineTypeGetOverMES(object e)
        {
            DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
            string OpName = Convert.ToString(msgEvent.OpName);
            int tagValue = Convert.ToInt32(msgEvent.TagValue);
            var cb = button_ManualPartLoad;
            cb.Invoke(new Action(() => {
                if (tagValue == 1)
                {
                    cb.Enabled = false;
                }
                else
                {
                    cb.Enabled = true;
                }
            }));
            SetChekcBox(tagValue, checkBox_MesEngineTypeGetOver);

        }
       
      
      
       

        private void button_ManualPartLoad_Click(object sender, EventArgs e)
        {
            fun_PartLoadManual(OPName01);
        }
    }
}
