FrmIOMsg.cs 3.5 KB
using Asa.RFID;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OnlineStore.AssemblyLine
{
    internal partial class FrmIOMsg : FrmBase
    {
        public FrmIOMsg()
        {
            InitializeComponent();
        }
        
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                UpdateData();
            }
        }

        private void UpdateData()
        {
            lblMsg.Text = "自动刷新时间:" + timer1.Interval + "毫秒,最后更新时间:" + DateTime.Now.ToLongTimeString();
            //lblConInfo.Text = "IO连接信息:\r\n";
            string msg = "";
            List<string> tList = new List<string>(LineManager.Line.cioList);
            foreach (string ip in tList)
            {
                //string con = (IOManager.instance.IsConnect(ip)) ? " ✔" : " ✘";

                //msg += ("IO模块[" + ip + "]").PadLeft(26, ' ') + con + "\n";
            }
            //lblConInfo.Text += msg;

            //lblRFID.Text = "RFID信息:\r\n";
            //msg = "";
            //List<string> rfidList = new List<string>(DeviceConfig.ProRFIpMap.Values);
            //foreach (string ip in rfidList)
            //{
            //    string errorCode = "?";
            //    if (RFIDAutoReader.rfidErrorMap.ContainsKey(ip))
            //    {
            //        errorCode = "" + RFIDAutoReader.rfidErrorMap[ip];
            //    }
            //    // string con = RFIDManager.ReadRFID(ip) .NumStr() ;
            //    msg += ("RFID[" + ip + "]:").PadLeft(26, ' ') + "ErrorCode=" + errorCode + "\n";
            //}
            //lblRFID.Text += msg;


            lblBox.Text = "料仓连接信息:\r\n";
            msg = "";
            List<int> list = new List<int>(LineManager.Line.MoveEquipMap.Keys);
            
            foreach (int storeId in list)
            {
                if (LineServer. BoxConnected(storeId))
                {
                    string doorTray = "仓门口:未知";
                   BoxInfo box= LineServer.GetBoxInfo(storeId);
                    if (box != null    )
                    {
                        if (box.HasTray.Equals(1))
                        {
                            doorTray = "仓门口:有料";
                        }
                        else
                        {
                            doorTray = "仓门口:无料";
                        }
                    }

                    msg += ("BOX[" + storeId + "]").PadLeft(16, ' ') + "  ✔  "+LineServer.ClientMap[storeId].AddStr + " "+doorTray+"\n";
                }
                else
                {
                    msg += ("BOX[" + storeId + "]").PadLeft(16, ' ') + "  ✘ " + "\n";
                }
            }
            lblBox.Text += msg;
        }

        private void FrmIOMsg_Load(object sender, EventArgs e)
        {
            UpdateData();
            timer1.Start();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            this.Close();
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            UpdateData();
        }

        private void FrmIOMsg_FormClosed(object sender, FormClosedEventArgs e)
        {
            timer1.Stop();
        }
    }
}