using System;
namespace MesWebFun_base
{
    public partial class MisWebInterface
    {
        public static MesWebFun_base _MesWebFun_base = new MesWebFun_base();
        public string WebSocket_Function(string msg)
        {
            var responseStr = "";
            try
            {
                //返回的数据msg.data，包含了协议中的4部分9
                var arrays_signal = msg.Split('|');
                var m_Source = arrays_signal[0];
                var m_Command = arrays_signal[1];
                var m_Opname = arrays_signal[2];
                var m_Value = arrays_signal[3];
                // var opName = $("#tbx_opname").val();
                switch (m_Source)
                {
                    case "MES":

                        switch (m_Command)
                        {
                            //显示托盘信息 √
                            case "ShowMoby":
                                try
                                {
                                    responseStr = MesWebFun_base.MobySelect(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShowMoby" + "|" + "info");
                                }
                                break;
                            //显示操作指南√
                            case "ProcessList":
                                try
                                {
                                    responseStr = MesWebFun_base.ProcessList(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ProcessList" + "|" + "info");
                                }
                                break;
                            //显示物料√
                            case "MaterialList":
                                try
                                {
                                    responseStr = MesWebFun_base.MaterialList(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：MaterialList" + "|" + "info");
                                }
                                break;
                            //显示操作图片√
                            case "PicShow":
                                try
                                {
                                    responseStr = MesWebFun_base.PictureShow(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：PicShow" + "|" + "info");
                                }
                                break;
                            //显示拧紧位置√
                            case "ShaftPosition":
                                try
                                {
                                    responseStr = MesWebFun_base.ShaftPotion_Select(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShaftPosition" + "|" + "info");
                                }
                                break;
                            //实时显示质量数据√
                            case "ShowTimelyQuality":
                                try
                                {
                                    responseStr = MesWebFun_base.Quality_Select(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShowTimelyQuality" + "|" + "info");
                                }
                                break;
                            //手动拧紧实时显示质量数据√
                            case "ShowTimelyQuality_Tight":
                                try
                                {
                                    responseStr = MesWebFun_base.Quality_Select(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShowTimelyQuality_Tight" + "|" + "info");
                                }
                                break;

                            //√ 
                            case "OrderFormList":
                                try
                                {
                                    responseStr = MesWebFun_base.OrderFormList(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：OrderFormList" + "|" + "info");
                                }
                                break;
                            //弹窗消息√ 
                            case "Notice":
                                try
                                {
                                    responseStr = MesWebFun_base.ShowWindowNotice(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：Notice" + "|" + "info");
                                }
                                break;
                            //LED消息提醒√ 
                            case "ScrollNotice":
                                try
                                {
                                    responseStr = MesWebFun_base.ShowLEDNotice(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ScrollNotice" + "|" + "info");
                                }
                                break;
                            //物料检测初始化√ 
                            case "MaterialCheckPosition":
                                try
                                {
                                    responseStr = MesWebFun_base.MaterialCheckPosition(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：MaterialCheckPosition" + "|" + "info");
                                }
                                break;

                            default:
                                // Web_Socket_Interface(m_Opname, msg);
                                break;
                        }
                        break;
                }
            }
            catch (Exception exception)
            {
                var error = exception.ToString();
                //ApplicationLog.WriteLog("信息提示" + "|" + "系统出现错误，接受onmessage：" + "|" + error + "|" + "info");
                responseStr = "";
            }
            return responseStr;
        }

    }
}