FrmIOTest.cs 5.8 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.CompilerServices;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices;
using OnlineStore.DeviceLibrary;
using log4net;
using System.Reflection;
using UserFromControl;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;


namespace OnlineStore.AssemblyLine
{
    internal partial class FrmIOTest : FrmBase
    {  
         internal FrmIOTest()
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
        } 
   
        private void LoadIOList(int subType,Label lblDI,Label lblDO,Label lblDes)
        {  
            List<ConfigIO> DIList = new List<ConfigIO>();
            List<ConfigIO> DOList = new List<ConfigIO>();
            DIList =new List<ConfigIO> ( DeviceConfig.SubDIList[subType].Values);
             DOList = new List<ConfigIO>(DeviceConfig.SubDOList[subType].Values);


            lblDI.Text = "";
            lblDO.Text = "";
            foreach (ConfigIO ioValue in DIList)
            {
                lblDI.Text+= ioValue.ElectricalDefinition + "_" + ioValue.Explain +"_"+ioValue.ProName+"\r\n";
               
            }
          
            foreach (ConfigIO ioValue in DOList)
            {
                lblDO.Text += ioValue.ElectricalDefinition + "_" + ioValue.Explain + "_" + ioValue.ProName + "\r\n";
            }

            if (LineManager.Line.HYEquipMap.ContainsKey(subType))
            {
                lblDes.Text = LineManager.Line.HYEquipMap[subType].GetHYDesc();
            }
            else
            {
                lblDes.Text = "";
            }

            this.SuspendLayout();    //此处为不闪屏,一定要有的!  
        }
       

        private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
        {
           // KNDAIManager.NeedShow = false;
            try
            {
                if (this.timer1.Enabled)
                {
                    this.timer1.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, "Exception(异常)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogUtil.error("",ex);
            }
        }

        private Dictionary<int, string> deviceList = new Dictionary<int, string>();
        private void FrmStoreIOStatus_Load(object sender, EventArgs e)
        {
            // KNDAIManager.NeedShow = true;
            //tabControl1.TabPages.RemoveAt(1);

            comboBox1.Items.Clear();
            deviceList = new Dictionary<int, string>();
            deviceList.Add(0, "C1环形线");
            for(int i = 1; i <= 24; i++)
            {
                int Dvalue = (i +1)/ 2;
                int mo = i % 2;
                if (mo == 0)
                {
                    mo = 2;
                }
                if (Dvalue >= 7)
                {
                    if (mo == 1)
                    {
                        mo = 2;
                    }
                    else
                    {
                        mo = 1;
                    }
                }
                deviceList.Add(i, "D"+Dvalue+"-"+mo+"移栽_" + i);
            }
            for (int i = 1; i <= 5; i++)
            { 
                deviceList.Add(100+i, "上料模块_T"   + i);
            }
            for (int i = 1; i <= 21; i++)
            {
                deviceList.Add(200+i, "横移_HY" + i);
            } 
            foreach (string key in deviceList.Values)
            {
                comboBox1.Items.Add(key);
                comboBox2.Items.Add(key);
                comboBox3.Items.Add(key);
                comboBox4.Items.Add(key);
            }
            comboBox1.SelectedIndex = 0; 
            comboBox2.SelectedIndex = 1;
            comboBox3.SelectedIndex = 2;
            comboBox4.SelectedIndex = 3;

            LoadIOList(0,lblDI1,lblDO1,lblDes1);
            LoadIOList(1, lblDI2, lblDO2,lblDes2);
            LoadIOList(2, lblDI3, lblDO3,lblDes3);
            LoadIOList(3, lblDI4, lblDO4,lblDes4);
        }
     
        
        private void FrmIOStatus_Shown(object sender, EventArgs e)
        {  
            timer1.Start();
        }
      

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex >= 0)
            {
                List<int> list = new List<int>(deviceList.Keys);
                int subType = list[comboBox1.SelectedIndex];
                LoadIOList(subType,lblDI1,lblDO1, lblDes1);
            }
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox2.SelectedIndex >= 0)
            {
                List<int> list = new List<int>(deviceList.Keys);
                int subType = list[comboBox2.SelectedIndex];
                LoadIOList(subType,lblDI2,lblDO2, lblDes2);
            }
        }

        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox4.SelectedIndex >= 0)
            {
                List<int> list = new List<int>(deviceList.Keys);
                int subType = list[comboBox4.SelectedIndex];
                LoadIOList(subType, lblDI4, lblDO4, lblDes4);
            }
        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox3.SelectedIndex >= 0)
            {
                List<int> list = new List<int>(deviceList.Keys);
                int subType = list[comboBox3.SelectedIndex];
                LoadIOList(subType, lblDI3, lblDO3, lblDes3);
            }

        }
    }
}