using bizFacade;
using MesServerWork;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MesServerFunctions
{
    partial class FunctionMES
    {
        /// <summary>
        /// MES与PLC心跳监听
        /// </summary>
        /// <param name="OpName"></param>
        /// <param name="tagValue"></param>
        private void HeartBeat(object e)
        {
            try
            {
                DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
                string OpName = Convert.ToString(msgEvent.OpName);
                int tagValue = Convert.ToInt32(msgEvent.TagValue);

                //返写在MES心跳中
                //MIS_BASE.WritePLC(15, OpName, tagValue);

                if (OpName == "J07MA010")
                {
                    // 给MA010工位推送实时温度
                    SendMessageFun.SendInfomation("MA010Temperature", MIS_BASE.ReadPLC(110, OpName).ToString(), OpName);
                    // 读取MA010MES写入温度发送到码块
                    DataTable dt;
                    BaseDataSystemMES.Get_TempData(OpName, "温度", out dt);
                    MIS_BASE.WritePLC(111, OpName, dt.Rows[0]["数值"]);
                }

                // 获取登录状态
                if (tagValue == 1)
                {
                    //DataTable tempDt;
                    //BaseDataSystemMES.Get_TempData(OpName, "登陆状态", out tempDt);
                    //if (tempDt.Rows.Count > 0) MIS_BASE.WritePLC(54, OpName, tempDt.Rows[0]["数值"]);
                }
            }
            catch (Exception err)
            {
                ////ApplicationLog.WriteLog(err, "Function02:FalseGO");
            }
        }
    }
}
