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

namespace MesServerWork
{
    public partial class MIS_BASE
    {

        /// <summary>
        /// 读取质量数据
        /// </summary>
        /// <param name="valueList"></param>
        public static void ReadPLC_Sync_ValueList(string opName, out Hashtable valueList)
        {
            valueList = null;
            ReadPLCData(opName, out valueList);
        }
        /// <summary>
        /// 根据工位号 同步读取数据
        /// </summary>
        /// <param name="opName">工位号</param>
        /// <param name="valueList">PLC仅仅值列表</param>
        private static void ReadPLCData(string opName, out Hashtable valueList)
        {
            valueList = new Hashtable();
 
            System.Data.DataTable dt;
            dt = MisDataFun.BaseData_tagTable_QualityData_Item_B5A();

            object tagValueStr = "0";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (opName == dt.Rows[i]["工位号"].ToString())
                {

                    DeviceDriver_BasicData.CustomeEvetnArgs qualityDataType;
                    qualityDataType = new DeviceDriver_BasicData.CustomeEvetnArgs();

                    qualityDataType.TagID = dt.Rows[i]["TagID"].ToString ();
                    qualityDataType.TagTypeID = Convert.ToInt32(dt.Rows[i]["TagTypeID"]);//变量类型
                    qualityDataType.OpName = opName;//
                    qualityDataType.IsGoodBad = 192;//
                    qualityDataType.TagQuality = 192;//
                    qualityDataType.TagValueType = Convert.ToInt32(dt.Rows[i]["变量类型代码"]);
                    qualityDataType.TagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]);
                    qualityDataType.TagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]);
                    qualityDataType.TagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]); ;//变量特点

                    MIS_BASE.Read_TagValueByTagID(qualityDataType.TagID.ToString(), out tagValueStr);

                    if (Convert.ToInt32(qualityDataType.TagTypeID)  == 18)
                    {
                        qualityDataType.TagValue = Convert.ToInt32(tagValueStr);//变量值
                    }
                    else
                    {
                        qualityDataType.TagValue = tagValueStr;//变量值
                    }
                    valueList.Add(qualityDataType.TagID, qualityDataType);
                }
            }
        }
    }

    public class QualityDataSaveList
    {
        public Hashtable valuList;
        public DataTable BasicDataTagValue;
        public DataTable BasicDataTagValueUpDown;
        public Hashtable hashtable_EngineTypeID;
        public Hashtable hashtable_tagTable_OpName_SaveData;
    }
}
