InOutParam.cs 5.3 KB
 
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;


namespace OnlineStore.DeviceLibrary
{
    public class InOutParam
    {
        public MoveType paramType = MoveType.None; 
        public InOutParam(MoveType type, string posId, string code = "", int plateH = 0, int plateW = 0)
        {
            position = null;
            PosCode = code;
            PosId = posId;
            MoveP = null;
            this.PlateW = plateW;
            this.PlateH = plateH;
            this.paramType = type; 
        }

        public InOutParam(MoveType paramType, string posId, StoreMoveP linePosition, string wareNo = "")
        {
            position = null;
            PosCode = wareNo;
            PosId = posId;
            MoveP = linePosition;
            this.paramType = paramType;
        }
      
        public string ToStr()
        { 
           if (paramType.Equals(MoveType.InStore))
            {
                return "【入库:" + PosId + " ,[" + PosCode + "][" + PlateW + "X" + PlateH + "]】";
            }
            else if (paramType.Equals(MoveType.OutStore))
            {
                return "【出库:" + PosId   + ",[" + PosCode + "][" + PlateW + "X" + PlateH + "]】";
            }

            return "[" + PosId + "][" + PosCode + "][" + PlateW + "X" + PlateH + "]";
        }
        private VerticalPosition position = null;

        public VerticalPosition Position
        {
            get
            { 
                if (position == null)
                {
                    position = CSVPositionReader<VerticalPosition>.GetPositon(PosId);
                } 
                return position;
            }
        }

        /// <summary>
        /// 物品二维码信息
        /// </summary>
        public string PosCode = "";
        /// <summary>
        /// 位置坐标名(对应配置表的位置)
        /// </summary>
        public string PosId = "";
       

        public StoreMoveP MoveP { get; set; }
        /// <summary>
        /// 料盘高度
        /// </summary>
        public int PlateH = 0;
        /// <summary>
        /// 料盘宽度
        /// </summary>
        public int PlateW = 0;

      

        internal bool LoadParam(VerticalStoreConfig Config)
        {

            //加载位置
            if (MoveP == null)
            {
                StoreMoveP p = new StoreMoveP();
                VerticalPosition position = Position;
                if (position == null)
                {
                    LogUtil.error("出入库时发现param中取到的Position=null,没有库位不能执行出入库");
                    return false;
                }

                p.Middle_P2 = position.MiddleAxis_P2;
                this.MoveP = p;
                return true;
            }
            return true;
        }

        public string LogName
        {
            get
            {  

               if (paramType.Equals(MoveType.InStore))
                {
                    return "【入库:" +   PosId + "】";
                }
                else if (paramType.Equals(MoveType.OutStore))
                {
                    return "【出库:" + PosId  + "】";
                }
                else
                {
                    return PosId;
                }
            }
        }
    }

    public class StirInfo
    {
        public StirInfo()
        {
            InStirWork = false;
            StartTime = DateTime.Now;
            StopTime = DateTime.Now;
            StirParam = new InOutParam(MoveType.None, "", "");
        }

        /// <summary>
        /// 是否在搅拌中
        /// </summary>
        public bool InStirWork = false;
        /// <summary>
        /// 搅拌区状态:1=物料1已放入,2=物料2已放入,3=搅拌中,4=搅拌完成,等待取出物料,5=物料1已取出,6=物料2已取出,7=全部完成
        /// </summary>
        public int MoveStatus = 0;

        /// <summary>
        /// 开始搅拌信息
        /// </summary>
        public DateTime StartTime = DateTime.Now;
        /// <summary>
        /// 需要停止搅拌的时间
        /// </summary>
        public DateTime StopTime = DateTime.Now;
        /// <summary>
        /// 搅拌参数
        /// </summary>
        public InOutParam StirParam = null;

        public string toStr()
        {
            if (MoveStatus.Equals(0))
            {
                return "暂无搅拌信息";
            }

            string str = "等待物料放入搅拌区";
            if (MoveStatus.Equals(1))
            {
                str = "物料1已放入";
            }
            else if (MoveStatus.Equals(2))
            {
                str = "物料2已放入";
            }
            else if (MoveStatus.Equals(3))
            {
                str = "搅拌中,结束时间:"+StopTime.ToLongTimeString();
            }
            else if (MoveStatus.Equals(4))
            {
                str = "搅拌完成,等待物料回库 ";
            }
            else if (MoveStatus.Equals(5))
            {
                str = "物料1已回库";
            }
            else if (MoveStatus.Equals(6))
            {
                str = "物料2已回库";
            }

            return "[" + str + "]" + StirParam.ToStr();
        }
    }
}