using MesServerWork;
using MisDataFunDll;
using System;

namespace MesServerFunctions
{
    partial class FunctionMES
    {
        /// <summary>
        /// 允许AGV举升
        /// </summary>
        /// <param name="e"></param>
        private void AllowAGVRaise(object e)
        {
            try
            {
                DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
                string OpName = Convert.ToString(msgEvent.OpName);
                int tagValue = Convert.ToInt32(msgEvent.TagValue);
                if (tagValue == 1)
                {
                    string msg;

                    // PLC允许AGV举升信号被置位后，应调用AGV允许举升接口
                    MIS_BASE.Read_EngineID(OpName, out string EngineID);
                    bool isOk = MisDataSaveDate.AGV_BusinessLogic.PassAgvInOut(OpName, EngineID, "raise");

                    if (isOk)
                    {
                        msg = $"【{OpName}】允许AGV举升成功!";
                    }
                    else
                    {
                        msg = $"【{OpName}】允许AGV举升失败！请注意！";
                    }

                    SendMessage.AsyncSendMessage_Notice(OpName, msg);
                    MyLog4Net.MyLogHelper.Info("AllowAGVRaise", msg);
                }
                else
                {
                    MisDataFun.Location_MIS_MOBY_Insert(OpName, "AllowAGVRaise", "0");
                }
            }
            catch (Exception err)
            {
                MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1054", err);
            }
        }
    }
}
