HYEquipBase.cs 5.8 KB
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnlineStore.DeviceLibrary
{
    public abstract   class  HYEquipBase : EquipBase
    {
        public HYEquip_Config Config;

        /// <summary>
        /// 当前设备对应的横移出口的设备ID
        /// </summary>
        private int HyOutDeviceId = 0;
        /// <summary>
        /// 当前设备对应的横移入口的设备ID
        /// </summary>
        private int HyInDeviceId = 0;
        public static  HYEquipBase GetHY(string cid, HYEquip_Config config)
        {
            int hynum = (config.Id % 100);

            List<int> workList = new List<int>() { 1, 2, 20,21 };
            List<int> jNumList = new List<int>() { 10,12,17};
            List<int> oNumList = new List<int>() { 5, 7, 14 };
            //List<int> cNumList = new List<int>() { 10, 12, 17 };
            if (workList.Contains(hynum))
            {
                return new HY_C1_SLStation(cid, config);
            }
            if (jNumList.Contains(hynum))
            {
                return new HY_Coveryor(cid, config);

            }else if (oNumList.Contains(hynum))
            { 
                return new HY_OutLine(cid, config);
            }
            else
            { 
                return new HY_C1Line(cid, config);
            }
        }

        public HYEquipBase(string cid, HYEquip_Config config)
        {
            this.DeviceID = config.Id;
            this.Config = config;
            baseConfig = config;
            IsDebug = config.IsDebug.Equals(1);
            Name = ("_HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + "_").ToUpper();

            Init();
            MoveInfo = new LineMoveInfo(DeviceID, "[" + Name.Trim() + "-Move]");
            SecondMoveInfo = new LineMoveInfo(DeviceID, "[" + Name.Trim() + "-SMove]");
            UseAxis = config.UpDownUseAxis.Equals(1);
            if (UseAxis)
            {
                UpdownAxis = new AxisBean(config.UpDown_Axis, Name);
            }
            HyOutDeviceId = 0;
            HyInDeviceId = 0;

            if (DeviceID.Equals(201))
            {
                HyInDeviceId = 202;
            }
            else if (DeviceID.Equals(202))
            {
                HyOutDeviceId = 201;
            }
            else if (DeviceID.Equals(220))
            {
                HyOutDeviceId = 221;
            }
            else if (DeviceID.Equals(221))
            {
                HyInDeviceId = 220;
            }

            else if (DeviceID.Equals(204))
            {
                HyOutDeviceId  = 203;
            }
            else if (DeviceID.Equals(203))
            {
                HyInDeviceId  = 204;
            }

            else if (DeviceID.Equals(209))
            {
                HyOutDeviceId = 208;
            }
            else if (DeviceID.Equals(208))
            {
                HyInDeviceId = 209;
            }

            else if (DeviceID.Equals(215))
            {
                HyOutDeviceId = 216;
            }
            else if (DeviceID.Equals(216))
            {
                HyInDeviceId = 215;
            }
            else if (DeviceID.Equals(218))
            {
                HyOutDeviceId = 219;
            }
            else if (DeviceID.Equals(219))
            {
                HyInDeviceId = 218;
            }
        }


        public string GetHYDesc()
        {
            StringBuilder buf = new StringBuilder();
            buf.Append("    所在流水线:" + Config.LineName+"\r\n");
            string dName = "暂无";
            if (Config.WorkDevice>0&&LineManager.Line.AllEquipMap.ContainsKey(Config.WorkDevice))
            {
                dName = LineManager.Line.AllEquipMap[Config.WorkDevice].Name;
            }
             buf.Append("    取放料设备:" + dName + "\r\n");
            if (Config.IsSideWayIn.Equals(1))
            {
                buf.Append("C1线横移入口:✔" + "\r\n");
            }
            if (Config.IsSideWayOut.Equals(1))
            {
                buf.Append("C1线横移出口:✔" + "\r\n");
            }
            if (Config.IsOutLineIn.Equals(1))
            {
                buf.Append(" 出料托盘入口:✔" + "\r\n");
            }
            if (Config.IsOutLineOut.Equals(1))
            {
                buf.Append(" 出料托盘出口:✔" + "\r\n");
            }
            int hynum = (this.Config.Id % 100);
            List<int> jNumList = new List<int>() { 10, 12, 17 };
            if (hynum.Equals(17))
            {
                buf.Append("     NG料工位:✔" + "\r\n");
            }
          else  if (jNumList.Contains(hynum))
            {
                buf.Append("    接驳台工位:✔" + "\r\n");
            }
            return buf.ToString();
        }
         

        protected HYEquipBase GetHyOutEquip()
        {
            if (HyOutDeviceId > 0)
            {
                return LineManager.Line.HYEquipMap[HyOutDeviceId];
            }
            return null;
        }
        protected HYEquipBase GetHyInEquip()
        {
            if (HyInDeviceId > 0)
            {
                return LineManager.Line.HYEquipMap[HyInDeviceId];
            }
            return null;
        }

        internal virtual  bool TrayIsReady()
        {
            return false;
        }

        internal virtual  void TrayCanLeave()
        {
        } 
          
        

        public override bool StartInStoreMove(InOutParam param)
        {
            return false;
        }

        public override bool StartOutStoreMove(InOutParam param)
        {
            return false;
        } 
        protected override void InStoreProcess()
        { 
        }

        protected override void OutStoreProcess()
        { 
        }

      
    }
}