using System;
using System.Data;
using System.Collections;

using System.Windows.Forms;
//using bizFacade;
using System.Collections.Specialized;
using MisDataFunDll;
//using MesWork;


namespace MesServerWork
{
    public partial class MIS_BASE // : Form
    {
        /// <summary>
        /// 全部数据列表
        /// </summary>
        public static DataTable BasicDataTagValue;
        /// <summary>
        /// MES_基本数据_测量范围
        /// </summary>
        public static DataTable BasicDataTagValueUpDown;
        /// <summary>
        /// 是否通过监控系统保存数据
        /// 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据
        /// </summary>
        static public Hashtable hashtable_tagTable_OpName_SaveData;
        /// <summary>
        /// 变量代码与列位置
        /// </summary>
        static public Hashtable hashtable_tagTable_TagID_TagOrderBy;
        /// <summary>
        /// 变量代码与变量排序
        /// </summary>
        static public Hashtable hashtable_tagTable_TagID_TagItemOrderBy;
        /// <summary>
        /// 变量代码与变量特点
        /// 0:没定义1：工位合格标志2：需要合格标志的测量数据3：每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8：(自动拧紧)工位合格标志
        /// </summary>
        static public Hashtable hashtable_tagTable_TagID_TagProperty;
        /// <summary>
        /// 发动机类型转换表
        /// SELECT  ID,发动机机型代码  FROM MES_计划BOM_发动机型号代码 
        /// </summary>
        public static Hashtable hashtable_EngineTypeID;

        /// <summary>
        /// 工位号与工位上下线类型
        /// （0普通工位）（1正常上线）（2正常下线）（3返修上线）（4返修下线）
        /// （5分线上线 总线）（6分线上线 分线）
        /// </summary>
        public static Hashtable hashtableOpName_OpType;
        /// <summary>
        /// 工位号与大屏幕代码
        /// 对应LED大屏幕（1，2，3，4）
        /// </summary>
        public static Hashtable hashtableOpName_LedID;
        /// <summary>
        /// 大屏幕显示产量端口(41104)
        /// </summary>
        public static Hashtable hashtableOpName_LedID_Port;

        /// <summary>
        /// 大屏幕显示Andon大屏幕代码 1
        /// </summary>
        public static Hashtable hashtableOpName_AndonID;

        /// <summary>
        /// 大屏幕显示Andon端口 (41105)
        /// </summary>
        public static Hashtable hashtableOpName_AndonID_Port;


        /// <summary>
        /// 是否有打印机(0,1)
        /// </summary>
        public static Hashtable hashtableOpName_IsPrinter;

        /// <summary>
        /// 打印机通讯端口
        /// </summary>
        public static Hashtable hashtableOpName_IsPrinter_Port;



        /// <summary>
        /// 工位号与目标循环时间
        /// </summary>
        public static Hashtable hashtableOpName_TargetTime;
        /// <summary>
        /// 工位号与线体类型
        /// </summary>
        public static Hashtable hashtableOpName_LineType;
        /// <summary>
        /// 是否有工位计算机
        /// </summary>
        public static Hashtable hashtableOpName_IsHaveComputer;
        /// <summary>
        /// 变量名称
        /// </summary>
        public static Hashtable hashtableTagID_TagName;
        /// <summary>
        /// 工位号
        /// </summary>
        public static Hashtable hashtableTagID_OpName;
        /// <summary>
        /// 数据来源
        /// </summary>
        public static Hashtable hashtableTagID_OpNameFrom;
        
        /// <summary>
        /// 工位名称
        /// </summary>
        static Hashtable hashtableTagID_OpName_Name;
        /// <summary>
        /// 测量位置
        /// </summary>
        public static Hashtable hashtableTagID_ShaftID;
        /// <summary>
        /// 测量项目
        /// </summary>
        public static Hashtable hashtableTagID_ItemVale;
        /// <summary>
        /// 变量代码与变量类型
        /// </summary>
        public static Hashtable hashtable_tagTable_TagID_TagTypeID_All;



        /// <summary>
        ///工位号与机床状态
        /// [测量数据机床状态]
        /// </summary>
        public static Hashtable m_MachineStatus_OpName;
        /// <summary>
        ///工位号与工件离开 1->0  =0 无工件或工件离开
        ///工位号与工件到位 0->1  =1 有工件或工件到达
        ///[测量数据发动机在线状态]
        /// </summary>
        public static Hashtable m_WorkStart_OpName;

        /// <summary>
        ///工位号与工件到位时间
        ///工位号与工件到位 0->1
        ///[测量数据发动机在线状态]
        /// </summary>
        public static Hashtable m_WorkStart_OpName_Time;

        /// <summary>
        ///工位号与工件到位时间
        ///工位号与工件到位 0->1，零件运动方向
        /// </summary>
        public static Hashtable m_WorkStart_OpName_PartMoveDirection;


        /// <summary>
        ///工位号与发动机号
        /// </summary>
        public static Hashtable m_EngineTrace_OpName;
        /// <summary>
        ///工位号与发动机号_时间
        /// </summary>
        public static Hashtable m_EngineTrace_OpName_Time;
        /// <summary>
        ///工位号与合格标志
        ///[测量数据发动机在线状态]
        /// </summary>
        public static Hashtable m_QualityMask_OpName;

        /// <summary>
        ///工位号与机型
        ///[测量数据发动机在线状态]
        /// </summary>
        public static Hashtable m_EngineNumberType_OpName;
        /// <summary>
        ///工位号与发动机号
        ///[测量数据发动机在线状态]
        /// </summary>
        public static Hashtable m_EngineNumber_OpName;

        /// <summary>
        ///工位号与订单号
        ///[测量数据发动机在线状态]
        /// </summary>
        public static Hashtable m_OrderForm_OpName;
        /// <summary>
        ///工位号与操作者工号
        ///[测量数据发动机在线状态]
        /// </summary>
        public static Hashtable m_OperatorCode_OpName;


        /// <summary>
        /// 测量合格标志
        /// 全部测量数据的测量工位
        /// 全部测量数据的测量工位的数据来源
        /// 全部测量数据的测量工位的数据来源的测量变量
        /// </summary>
        public static Hashtable hashtable_QualityData_GoodBad_MIS_OpName;
        /// <summary>
        /// 列位置
        /// </summary>
        public static Hashtable hashtable_QualityData_GoodBad_Index;

        /// <summary>
        /// MesServerCode
        /// </summary>
        public static Hashtable hashtable_MesServerCode;
        /// <summary>
        /// MesDll
        /// </summary>
        public static Hashtable hashtable_MesDll;
        /// <summary>
        /// 各个工位是否允许工作
        /// </summary>
        public static Hashtable hashtable_IsAllowWork;

        /// <summary>
        /// 返修工位是否需要强制合格放行
        /// //20141104 ljl
        /// </summary>
        public static Hashtable hashtable_IsConfirmOkGo;


        /// <summary>
        /// 工步属性哈西表
        /// </summary>
        public static Hashtable hashtable_workStepProperty;

        /// <summary>
        /// 工作顺序哈西表
        /// </summary>
        public static Hashtable hashtable_WorkGroupIndex;

        /// <summary>
        /// 返修工位哈西表
        /// </summary>
        public static Hashtable hashtable_OpNameRepair;

        /// <summary>
        /// 记录工件到位的发动机机型代码
        /// </summary>
        public static Hashtable hashtable_EngineGetOver_EngineTypeID;
        /// <summary>
        /// 记录工件到位的发动机机型
        /// </summary>
        public static Hashtable hashtable_EngineGetOver_EngineType;
        /// <summary>
        /// 记录工件到位的发动机号
        /// </summary>
        public static Hashtable hashtable_EngineGetOver_EngineID;
        /// <summary>
        /// 记录工件到位的订单号
        /// </summary>
        public static Hashtable hashtable_EngineGetOver_OrderForm;

        /// <summary>
        /// 拧紧/压装过程中的合格标志
        /// </summary>
        public static Hashtable hashtable_QualityMesRead;


        /// <summary>
        /// 物料检测哈希表
        /// </summary>
        public static Hashtable hashtable_CheckMaterial;

        /// <summary>
        /// 托盘状态哈希表
        /// </summary>
        public static Hashtable hashtable_PalletInfo;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位机床上电开始时间
        ///机床上电产生 0->1
        ///机床上电解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusPutOn_OpName_Time;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位循环开始 开始时间
        ///循环开始产生 0->1
        ///循环开始解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusWorkOn_OpName_Time;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位机床故障开始时间
        ///机床故障产生 0->1
        ///机床故障解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusAlarm_OpName_Time;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位上料无件开始时间
        ///上料无件产生 0->1
        ///上料无件解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusNoPart_OpName_Time;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位下料堵塞开始时间
        ///下料堵塞产生 0->1
        ///下料堵塞解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusBlock_OpName_Time;

        /// <summary>
        ///工位号与托盘离开 1->0
        ///工位号与托盘到位 0->1
        ///[测量数据_监控系统_托盘到位]
        /// </summary>
        public static Hashtable m_PartPalletStatus_OpName;
        /// <summary>
        ///工位号与托盘离开 1->0
        ///工位号与托盘到位 0->1
        ///[测量数据_监控系统_托盘到位]
        /// </summary>
        public static Hashtable m_PartPalletStatus_OpName_Time;
        /// <summary>
        /// 托盘到位(1)托盘离开(0) (DBX101.7)(13)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位机床上电开始时间
        ///机床上电产生 0->1
        ///机床上电解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusPutOn_OpName;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位循环开始 开始时间
        ///循环开始产生 0->1
        ///循环开始解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusWorkOn_OpName;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位机床故障开始时间
        ///机床故障产生 0->1
        ///机床故障解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusAlarm_OpName;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位上料无件开始时间
        ///上料无件产生 0->1
        ///上料无件解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusNoPart_OpName;
        /// <summary>
        ///[测量数据机床状态_分拆统计]
        ///各个工位下料堵塞开始时间
        ///下料堵塞产生 0->1
        ///下料堵塞解除 1->0
        /// </summary>
        public static Hashtable m_MachineStatusBlock_OpName;

        public static NameValueCollection hashtable_TagTypeDataType ;
        public static NameValueCollection hashtable_TagType;
        /// <summary>
        /// 托盘代码(DBB86)(80)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        /// <summary>
        /// 创建MesServerCode哈西表
        /// </summary>
        static public void InitHashtable_MesServerCode()
        {
            hashtable_MesServerCode = new Hashtable();
            hashtable_IsAllowWork = new Hashtable();
            hashtable_WorkGroupIndex = new Hashtable();
            hashtable_EngineGetOver_EngineTypeID = new Hashtable();
            hashtable_EngineGetOver_EngineType = new Hashtable();
            hashtable_EngineGetOver_EngineID = new Hashtable();
            hashtable_EngineGetOver_OrderForm = new Hashtable();
            hashtable_QualityMesRead = new Hashtable();
            hashtable_CheckMaterial = new Hashtable();
            hashtable_PalletInfo = new Hashtable();
            hashtable_IsConfirmOkGo = new Hashtable();
            hashtable_MesDll = new Hashtable();

            string OpName;
            string MesServerCode;
            string MesDll;
            string workStepProperty;
            string OpNameRepair;
            DataTable dt;
            dt = MisDataFun.GetMesServerCodeFromMIS();
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    OpName = dt.Rows[i]["工位号"].ToString();
                    MesServerCode = dt.Rows[i]["MesServerCode"].ToString();
                    MesDll = dt.Rows[i]["MesDll"].ToString();
                    hashtable_MesDll.Add(OpName, MesDll);
                    hashtable_MesServerCode.Add(OpName, MesServerCode);
                    hashtable_IsAllowWork.Add(OpName, 1);
                    hashtable_IsConfirmOkGo.Add(OpName, 0);//20141104 ljl
                    hashtable_PalletInfo.Add(OpName, 0);//20141104 ljl
                    hashtable_WorkGroupIndex.Add(OpName, 1);
                    hashtable_EngineGetOver_EngineTypeID.Add(OpName, 0);
                    hashtable_EngineGetOver_EngineType.Add(OpName, "");
                    hashtable_EngineGetOver_EngineID.Add(OpName, "");
                    hashtable_EngineGetOver_OrderForm.Add(OpName, "");
                    hashtable_QualityMesRead.Add(OpName, 0);
                    hashtable_CheckMaterial.Add(OpName, new bool[16]);
                }
            }
            HashtableList.hashtable_MesServerCode_Temp = hashtable_MesServerCode;
            HashtableList.hashtable_MesDll_Temp = hashtable_MesDll;

            HashtableList.hashtable_EngineGetOver_EngineID_Temp = hashtable_EngineGetOver_EngineID;
            HashtableList.hashtable_EngineGetOver_EngineTypeID_Temp = hashtable_EngineGetOver_EngineTypeID;
            HashtableList.hashtable_EngineGetOver_EngineType_Temp = hashtable_EngineGetOver_EngineType;
            HashtableList.hashtable_EngineGetOver_OrderForm_Temp = hashtable_EngineGetOver_OrderForm;

            //初始化工步属性
            hashtable_workStepProperty = new Hashtable();
            dt = MisDataFun.GetworkStepPropertyFromMIS();
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    OpName = dt.Rows[i]["工位号"].ToString();
                    workStepProperty = dt.Rows[i]["工步属性"].ToString();
                    hashtable_workStepProperty.Add(OpName, workStepProperty);
                }
            }

            //返修工位
            hashtable_OpNameRepair = new Hashtable();
            dt = MisDataFun.GetOpNameRepairFromMIS();
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    OpName = dt.Rows[i]["工位号"].ToString();
                    OpNameRepair = dt.Rows[i]["返修工位号"].ToString();
                    hashtable_OpNameRepair.Add(OpName, OpNameRepair);
                }
            }

            HashtableList.hashtable_OpNameRepair_Temp = hashtable_OpNameRepair;
            HashtableList.hashtable_workStepProperty_Temp = hashtable_workStepProperty;
            HashtableList.hashtable_QualityMesRead_Temp = hashtable_QualityMesRead;
            HashtableList.hashtable_IsAllowWork_Temp = hashtable_IsAllowWork;
            HashtableList.hashtable_WorkGroupIndex_Temp = hashtable_WorkGroupIndex;



        }


        /// <summary>
        /// 创建合格标志哈西表
        /// </summary>
        private static void InitHashtable_QualityData_GoodBad()
        {
            //列位置
            string index;
            //
            int tagID;
            DataTable dt ;
            dt = MisDataFun.BaseData_tagTable_All_B5A();

            hashtable_QualityData_GoodBad_Index = new Hashtable();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                tagID = Convert.ToInt32(dt.Rows[i]["TagID"]);
                index = (dt.Rows[i]["列位置"]).ToString();
                hashtable_QualityData_GoodBad_Index.Add(tagID, index);
            }

            hashtable_EngineTypeID = new Hashtable();
            dt = MisDataFun.BaseData_tagTable_QualityData_EngineTypeID();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                tagID = Convert.ToInt32(dt.Rows[i]["发动机机型代码"]);
                index = (dt.Rows[i]["ID"]).ToString();
                hashtable_EngineTypeID.Add(tagID, index);
            }
            //工位号
            DataTable dt_OpName;
            //工位号数据来源
            DataTable dt_OpNameFrom;
            //数据来源对应的TagID
            DataTable dt_OpNameTagID;
            string opName;
            string opNameFrom;
            hashtable_QualityData_GoodBad_MIS_OpName = new Hashtable();
            // 测量合格标志
            // 全部测量数据的测量工位的数据来源
            Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom;

            // 测量合格标志
            // 全部测量数据的测量工位的数据来源的测量变量
            Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID;
            dt_OpName = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName_B5A();
            if (dt_OpName != null)
            {
                //有不合格标志的测量工位
                for (int i = 0; i < dt_OpName.Rows.Count; i++)
                {
                    //有不合格标志的测量工位 对应的 数据来源工位号
                    hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom = new Hashtable();
                    opName = dt_OpName.Rows[i]["工位号"].ToString();
                    dt_OpNameFrom = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName);
                    if (dt_OpNameFrom != null)
                    {
                        for (int j = 0; j < dt_OpNameFrom.Rows.Count; j++)
                        {
                            opNameFrom = dt_OpNameFrom.Rows[j]["数据来源"].ToString();
                            dt_OpNameTagID = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName, opNameFrom);
                            //
                            hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID = new Hashtable();
                            if (dt_OpNameTagID != null)
                            {
                                for (int k = 0; k < dt_OpNameTagID.Rows.Count; k++)
                                {
                                    tagID = Convert.ToInt32(dt_OpNameTagID.Rows[k]["TagID"]);
                                    hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID.Add(tagID, tagID);
                                }
                            }
                            tagID = Convert.ToInt32(dt_OpNameFrom.Rows[j]["TagID"]);
                            //全部测量数据的测量工位的数据来源的测量变量
                            hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom.Add(tagID, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID);
                        }
                    }
                    hashtable_QualityData_GoodBad_MIS_OpName.Add(opName, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom);
                }
            }
        }


        public static NameValueCollection hashtable_TagTypeID_OpName_ToTagID;

        /// <summary>
        /// 变量代码与其他字段的对应关系
        /// </summary>
        public static void InitHashtableTagID()
        {
            //变量代码
            string tagID;
            //变量名称
            string tagName;
            //工位号
            string opNmae;
            //测量位置
            string shaftID;
            //测量项目
            string itemVale;
            //变量排序
            int tagItemOrderBy;
            //变量特点
            // 0:没定义1：工位合格标志2：需要合格标志的测量数据3：每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8：(自动拧紧)工位合格标志
            int tagProperty;
            //列位置
            int tagOrderBy;
            InitHashtable_QualityData_GoodBad();
            //MesServerCode哈希表创建
            InitHashtable_MesServerCode();
            //列位置
            hashtable_tagTable_TagID_TagOrderBy = new Hashtable();
            // 变量代码与变量排序
            hashtable_tagTable_TagID_TagItemOrderBy = new Hashtable();
            // 变量代码与变量特点
            // 0:没定义1：工位合格标志2：需要合格标志的测量数据3：每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8：(自动拧紧)工位合格标志
            hashtable_tagTable_TagID_TagProperty = new Hashtable();
            hashtable_tagTable_OpName_SaveData = new Hashtable();
            //工位号与机床状态
            //[测量数据发动机在线状态]
            m_MachineStatus_OpName = new Hashtable();
            ////工位号与工件离开 0
            ////工位号与工件到位 1
            ////[测量数据发动机在线状态]
            //m_WorkStart_OpName = new Hashtable();
            ////工位号与工件到位时间
            ////工位号与工件到位 0->1
            ////[测量数据发动机在线状态]
            //m_WorkStart_OpName_Time = new Hashtable();
            //工位号与发动机号
            //[测量数据发动机在线状态]
            m_EngineTrace_OpName = new Hashtable();
            m_EngineTrace_OpName_Time = new Hashtable();
            //工位号与合格标志
            //[测量数据发动机在线状态]
            m_QualityMask_OpName = new Hashtable();
            //工位号与目标循环时间
            hashtableOpName_TargetTime = new Hashtable();
            //工位号与线体类型
            hashtableOpName_LineType = new Hashtable();
            //是否有工位计算机
            hashtableOpName_IsHaveComputer = new Hashtable();

            //工位号与机型
            //[测量数据发动机在线状态]
            m_EngineNumberType_OpName = new Hashtable();
            //工位号与发动机号
            //[测量数据发动机在线状态]
            m_EngineNumber_OpName = new Hashtable();
            //工位号与订单号
            //[测量数据发动机在线状态]
            m_OrderForm_OpName = new Hashtable();
            //工位号与操作者工号
            //[测量数据发动机在线状态]
            m_OperatorCode_OpName = new Hashtable();


            // <summary>
            // 变量名称
            // </summary>
            hashtableTagID_TagName = new Hashtable();
            // <summary>
            // 工位号
            // </summary>
            hashtableTagID_OpName = new Hashtable();
            // <summary>
            // 数据来源
            // </summary>
            hashtableTagID_OpNameFrom = new Hashtable();
            // <summary>
            // 工位名称
            // </summary>
            hashtableTagID_OpName_Name = new Hashtable();
            // <summary>
            // 测量位置
            // </summary>
            hashtableTagID_ShaftID = new Hashtable();
            // <summary>
            // 测量项目
            // </summary>
            hashtableTagID_ItemVale = new Hashtable();

            hashtable_tagTable_TagID_TagTypeID_All = new Hashtable();

            // 工位号与工位上下线类型
            // （0普通工位）（1正常上线）（2正常下线）（3返修上线）（4返修下线）
            //  (5 分线上线 总线)  （6  分线上线  总线）
            hashtableOpName_OpType = new Hashtable();
            // 工位号与大屏幕代码
            // 对应LED大屏幕（1，2，3，4）
            hashtableOpName_LedID = new Hashtable();




            // 大屏幕显示产量端口(41104)
            hashtableOpName_LedID_Port = new Hashtable();
            // 大屏幕显示Andon大屏幕代码 1
            hashtableOpName_AndonID = new Hashtable();
            // 大屏幕显示Andon端口 (41105)
            hashtableOpName_AndonID_Port = new Hashtable();
            // 是否有打印机(0,1)
            hashtableOpName_IsPrinter = new Hashtable();
            // 打印机通讯端口 （缸盖打印机 41101） （发动机上线打印机 41102） （发动机下线打印机 41103）
            hashtableOpName_IsPrinter_Port = new Hashtable();

            m_WorkStart_OpName_Time = new Hashtable();
            m_WorkStart_OpName = new Hashtable();


            m_MachineStatusPutOn_OpName_Time = new Hashtable();
            m_MachineStatusPutOn_OpName = new Hashtable();
            m_MachineStatusWorkOn_OpName_Time = new Hashtable();
            m_MachineStatusWorkOn_OpName = new Hashtable();
            m_MachineStatusAlarm_OpName_Time = new Hashtable();
            m_MachineStatusAlarm_OpName = new Hashtable();
            m_MachineStatusNoPart_OpName_Time = new Hashtable();
            m_MachineStatusNoPart_OpName = new Hashtable();
            m_MachineStatusBlock_OpName_Time = new Hashtable();
            m_MachineStatusBlock_OpName = new Hashtable();




            m_WorkStart_OpName_PartMoveDirection = new Hashtable();
            m_PartPalletStatus_OpName_Time = new Hashtable();
            m_PartPalletStatus_OpName = new Hashtable();

            hashtable_TagTypeID_OpName_ToTagID = new NameValueCollection();



            DataTable dt;
            DateTime dateTime;
            dateTime = DateTime.Now;
            dt = MisDataFun.BaseData_tagTable_All();

            //变量类型代码
            int TagTypeID;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                tagID = dt.Rows[i]["TagID"].ToString ();
                tagName = Convert.ToString(dt.Rows[i]["TagName"]);
                opNmae = Convert.ToString(dt.Rows[i]["工位号"]);
                shaftID = Convert.ToString(dt.Rows[i]["测量位置"]);
                itemVale = Convert.ToString(dt.Rows[i]["测量项目"]);
                TagTypeID = Convert.ToInt32(dt.Rows[i]["变量类型代码"]);
                tagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]);
                tagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]);
                tagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]);

                hashtableTagID_TagName.Add(tagID, tagName);
                hashtableTagID_OpName.Add(tagID, opNmae);
                hashtableTagID_ShaftID.Add(tagID, shaftID);
                hashtableTagID_ItemVale.Add(tagID, itemVale);//列位置
                hashtable_tagTable_TagID_TagTypeID_All.Add(tagID, TagTypeID);
                hashtable_tagTable_TagID_TagItemOrderBy.Add(tagID, tagItemOrderBy);
                hashtable_tagTable_TagID_TagProperty.Add(tagID, tagProperty);
                hashtable_tagTable_TagID_TagOrderBy.Add(tagID, tagOrderBy);

                
            }
            dt = MisDataFun.BaseData_tagTable_OpName();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //是否通过监控系统保存数据  
                // 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据
                hashtable_tagTable_OpName_SaveData.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否通过监控系统保存数据"]));

                hashtableOpName_TargetTime.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["目标循环时间"]));
                hashtableOpName_LineType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["线体类型"]));
                hashtableOpName_IsHaveComputer.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["是否有工位计算机"]));
                //用于LED显示
                // [MES_计划BOM_工位与名称]
                // 工位上下线类型
                //（0普通工位）（1正常上线）（2正常下线）（3返修上线）（4返修下线）
                hashtableOpName_OpType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["工位上下线类型"]));
                hashtableOpName_LedID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕代码"]));
                m_WorkStart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
                m_WorkStart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);


                m_MachineStatusPutOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
                m_MachineStatusPutOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
                m_MachineStatusWorkOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
                m_MachineStatusWorkOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
                m_MachineStatusAlarm_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
                m_MachineStatusAlarm_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
                m_MachineStatusNoPart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
                m_MachineStatusNoPart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
                m_MachineStatusBlock_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
                m_MachineStatusBlock_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
        
                
                
                m_WorkStart_OpName_PartMoveDirection.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
                
                    
                m_PartPalletStatus_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
                m_PartPalletStatus_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
                try
                {
                    hashtableOpName_LedID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示产量端口"]));
                }
                catch { }
                try
                {
                    hashtableOpName_AndonID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon大屏幕代码"]));
                }
                catch { }
                try
                {
                    hashtableOpName_AndonID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon端口"]));
                }
                catch { }
                try { hashtableOpName_IsPrinter.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否有打印机"])); }
                catch { }
                try
                {
                    hashtableOpName_IsPrinter_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["打印机通讯端口"]));
                }
                catch { }
            }


            //20170310 CLB新加
            dt = MisDataFun.BaseData_tagTable_OpcServerMES_ALL_CF();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    hashtable_TagTypeID_OpName_ToTagID.Add(Convert.ToString(dt.Rows[i]["工位号"]) + "_" + Convert.ToString(dt.Rows[i]["变量类型代码"]), Convert.ToString(dt.Rows[i]["TagID"]));
                    //hashtable_TagTypeID_OpName_ToTagID;
                }
                catch(Exception err)
                {

                }
            }




        }
    }
}
