using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using SystemFramework;

namespace MesWebFun_base
{
   public partial class MisWebInterface
    {

        /// <summary>
        /// 
        /// </summary>
        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 = ReceivedSignal_MobySelect( m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShowMoby" + "|" + "info");
                                }
                                break;
                            //显示操作指南√
                            case "ProcessList":
                                try
                                {
                                    responseStr = ReceivedSignal_ProcessList(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ProcessList" + "|" + "info");
                                }
                                break;
                            //显示物料√
                            case "MaterialList":
                                try
                                {
                                    responseStr = ReceivedSignal_MaterialList(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：MaterialList" + "|" + "info");
                                }
                                break;
                            //显示操作图片√
                            case "PicShow":
                                try
                                {
                                    responseStr = ReceivedSignal_PictureShow(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：PicShow" + "|" + "info");
                                }
                                break;
                            //显示拧紧位置√
                            case "ShaftPosition":
                                try
                                {
                                    responseStr = InitShowGuidCircle(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShaftPosition" + "|" + "info");
                                }
                                break;
                            //实时显示质量数据√
                            case "ShowTimelyQuality":
                                try
                                {
                                    // url: '../submit/OpName.ashx?type=ShowTimelyQuality&value=' + opName,
                                    responseStr = _MesWebFun_base.ProcessRequest("ShowTimelyQuality", m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShowTimelyQuality" + "|" + "info");
                                }
                                break;
                            //手动拧紧实时显示质量数据√
                            case "ShowTimelyQuality_Tight":
                                try
                                {
                                    // url: '../submit/OpName.ashx?type=ShowTimelyQuality&value=' + opName,
                                    responseStr = _MesWebFun_base.ProcessRequest("ShowTimelyQuality", m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ShowTimelyQuality_Tight" + "|" + "info");
                                }
                                break;
                                 
                            //√ 
                            case "OrderFormList":
                                try
                                {
                                    // ReloadOrderInfoData();
                                    //url: '../submit/OpName.ashx?type=OrderFormList&value=' + opName,
                                    responseStr = _MesWebFun_base.ProcessRequest("OrderFormList", m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：OrderFormList" + "|" + "info");
                                }
                                break;
                            //弹窗消息√ 
                            case "Notice":
                                try
                                {
                                    responseStr = ShowWindowNotice(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：Notice" + "|" + "info");
                                }
                                break;
                            //LED消息提醒√ 
                            case "ScrollNotice":
                                try
                                {
                                    responseStr = ShowLEDNotice(m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：ScrollNotice" + "|" + "info");
                                }
                                break;
                            //物料检测初始化√ 
                            case "MaterialCheckPosition":
                                responseStr = InitMaterialCheck(m_Opname);
                                break;
                            //返修质量数据显示√                 
                            case "RepairQuality":
                                try
                                {
                                    // IniQualityButtons_bgColor_byenergineID_socket(m_Value);
                                    //url: '../submit/OpName.ashx?type=QualityDataButton_bgColor_Select_ByEnergineID&value=' + opName + '&energineID=' + energineID + '&v=' + new Date().getTime(),
                                    responseStr = _MesWebFun_base.ProcessRequest("QualityDataButton_bgColor_Select_ByEnergineID", m_Opname);
                                }
                                catch (Exception exception)
                                {
                                    //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点：RepairQuality" + "|" + "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;
        }



    }
}
