using System;
using System.Threading;
//using SystemFramework;
using MesServerWork;
using MisDataFunDll;

namespace MesServerFunctions
{
    partial class FunctionMES
    {
        /// <summary>
        /// 申请上线(针对上线工位)
        /// </summary>
        /// <param name="OpName"></param>
        /// <param name="tagValue"></param>
        private void PartLoad(object e)
        {
            try
            {
                DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
                string OpName = Convert.ToString(msgEvent.OpName);
                int tagValue = Convert.ToInt32(msgEvent.TagValue);

                // 清空MOBY表中所有数据
                MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.WorkStart, "0");
                MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.EngineTypeGetOverPLC, "0");
                MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.PartLoad, "0");
                MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "0");
                MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesReadOver, "0");
                MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.FixAllow, "0");
                Thread.Sleep(500);
                // 按照生产排序顺序获取订单相关数据
                // 获取到数据 显示 申请上线、传递机型、允许工作三个点位
                // 显示对应物料信息、

                if (tagValue == 1)
                {
                    
                }
                else
                {
                    ////上线工位清MES传递机型信号
                    //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
                    //// 清除报警
                }
            }
            catch (Exception err)
            {
                // 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码
                MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1053", err);
                ////ApplicationLog.WriteLog(err, "Function08:MesReadOver");
            }
        }
    }
}
