using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using SystemFramework;

namespace MisDataName
{
    partial  class MisData
    {
   
        void TestPlcConnectInit()
        {
            //try 
            //{
            //    DataTable dt_OpName = (DataTable)FunctionForm_HashiTable.OpName_Hash_Read("OpNameList");
            //    for (int i=0;i< dt_OpName.Rows .Count;i++)
            //    {
            //        TestPlcConnect NewPlcConnect = new TestPlcConnect(dt_OpName.Rows [i][0].ToString ());
            //        TestPlcConnect.TestPlcTimerChangedDelegate += NewPlcConnect.ExternalTimerExcute;
            //        NewPlcConnect.PlcConnect += PlcStatusChanged_Connect;
            //        NewPlcConnect.PlcBreak += PlcStatusChanged_Break;
            //        TestPlcConnect.HashTable_Write(TestPlcConnect.WorkStationTestExample, dt_OpName.Rows[i][0].ToString(), NewPlcConnect);

            //    }
            //}
            //catch (Exception err)
            //{
            //    ApplicationLog.WriteLog(err, err.Message);

            //}
        }

        public static void PlcStatusChanged_Connect(object sender, EventArgs e)
        {
            try 
            {
                //查询在线工位数量
                int i= TestPlcConnect. CalculateWorkStationCount("OnlineWorkStation");

                if (MisData.TestPlcStatusDel!=null )
            MisData.TestPlcStatusDel(i.ToString (), e);
            }
            catch (Exception err)
            {
                ApplicationLog.WriteLog(err, err.Message);

            }

        }

        public static void PlcStatusChanged_Break(object sender, EventArgs e)
        {
            try 
            {
                //查询在线工位数量
                int i = TestPlcConnect.CalculateWorkStationCount("OnlineWorkStation");

                if (MisData.TestPlcStatusDel != null)
                MisData.TestPlcStatusDel(i.ToString(), e);
            }
            catch (Exception err)
            {
                ApplicationLog.WriteLog(err, err.Message);

            }
        }

        void ListBox1_Item_Init()
        {
            listBox1.Items.Clear();
            try
            {
                if (MesDataFunction.OpcOperation.hashtable_TagType == null) return;
                foreach (var i in MesDataFunction.OpcOperation.hashtable_TagType)
                {
                    listBox1.Items.Add("MES|" + i.ToString() + "|" + WorkStationNum_Now + "|1");
                }
            }
            catch
            {

            }

        }
    }
}
