DischargeLine.cs 1.8 KB
using System;
using System.Threading;
using common = DoubleLine.Common;
using IOSta = Asa.IOModule.Box_Sta;

namespace BLL
{
    /// <summary>
    /// 出料皮带线
    /// </summary>
    public class LineDischarge
    {
        public delegate void StatusEvent(int idx);
        public event StatusEvent Status;


        public LineDischarge()
        {
        }

        internal void Start()
        {
            common.log.OutInfo("开启出料线");
            IO_Open();
        }

        internal void Exit()
        {
            IO_Close();
            common.log.OutInfo("关闭出料线");
        }

        private void IO_Open()
        {
            try
            {
                bool ready = true;
                for (int i = 4; i < 6; i++)
                {
                    common.IO_Info[i].Box.Connect();
                    bool rtn = common.IO_Info[i].Box.IsConn;
                    ready &= rtn;
                    common.log.OutInfo(common.IO_Info[i].Name + " Open=" + rtn.ToString());
                    Status?.Invoke(i);
                    Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                IO_Close();
                common.log.OutError(ex);
            }
        }

        private void IO_Close()
        {
            try
            {
                if (common.IO_Info[4] != null)
                    common.IO_Info[4].Box.Close();
                if (common.IO_Info[5] != null)
                    common.IO_Info[5].Box.Close();
            }
            catch (Exception ex)
            {
                common.log.OutError(ex);
            }

        }

    }

    internal enum IO26_DI : int
    {
        X670, X671, X672, X673
    }

    internal enum IO27_DI : int
    {
        X680, X681, X682, X683
    }



}