InOutParam.cs 4.2 KB
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
 

namespace OnlineStore.DeviceLibrary
{ 
    public class InOutParam
    {
        public InOutParam(string wareNo="", string posId="",   string platew = "", string plateh = "")
        { 
            WareCode = wareNo;
            PosID = posId;
            MoveP = null;
            this.PlateW = platew;
            this.PlateH = plateh;  
        } 
        public InOutParam(string wareNo, string posId, string ShelfPosID,LineMoveP linePosition )
        { 
            WareCode = wareNo; 
            PosID = posId;
            MoveP = linePosition;  

        }  
        public InOutParam NewParam()
        {
            InOutParam newp = new InOutParam(WareCode,PosID, PlateW, PlateH);
            return newp;
        }
        /// <summary>
        /// 物品二维码信息
        /// </summary>
        public string WareCode { get; set; }
        /// <summary>
        /// 位置坐标名(对应配置表的位置)
        /// </summary>
        public string PosID { get; set; }
      
        public LineMoveP MoveP { get; set; }
        /// <summary>
        /// 料盘高度
        /// </summary>
        public string  PlateH { get; set; }
        /// <summary>
        /// 料盘宽度
        /// </summary>
        public string PlateW { get; set; }
        
        /// <summary>
        /// 根据PosId获取对应的料仓ID,若PosId=="",返回-1
        /// </summary>
        /// <returns></returns>
        public int GetStoreId()
        {
            return GetPosStoreId(PosID);
        }
        public static int GetPosStoreId(string posId)
        {
            if (!posId.Equals(""))
            {
                try
                {
                    string[] arr = posId.Split('#');
                    if (arr.Length >= 2)
                    {
                        return int.Parse(arr[0]); 
                    }
                    else
                    {
                        return int.Parse(posId.Substring(2, 2));
                    }
                }
                catch (Exception ex)
                {

                }
            }
            return -1;
        }
        public string ToStr()
        {
            return " 库位 [" + PosID + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ";
        } 

        internal void UpdatePosId(string message, string posId, string plateW, string plateH,int comP2,int comP3)
        {
            this.WareCode = message;
            this.PosID = posId;
            this.PlateH = plateH;
            this.PlateW = plateW;

            ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
            if (position == null)
            {
                LogUtil.error( "GetPositon[" + posId + "] =null,没有库位不能执行出入库"); 
            } 
             

            MoveP.ComPress_P2 = comP2;
            MoveP.ComPress_P3 = comP3;
            MoveP.InOut_P3 = position.InoutAxis_P3;
            MoveP.Middle_P2 = position.MiddleAxis_P2;
            MoveP.UpDown_P3 = position.UpdownAxis_IH_P3;
            MoveP.UpDown_P4 = position.UpdownAxis_IL_P4;
            MoveP.UpDown_P5 = position.UpdownAxis_OH_P5;
            MoveP.UpDown_P6 = position.UpdownAxis_OL_P6;
        }

        internal void UpdatePosIdAndShelfId(string wareNo,string rfid,string posId )
        {
            WareCode = wareNo; 
         
            PosID = posId;
            ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
            if (position == null)
            {
                LogUtil.error("GetPositon[" + posId + "] =null,没有库位不能执行出入库");
            }


            //MoveP.ComPress_P2 = comP2;
            //MoveP.ComPress_P3 = comP3;
            MoveP.InOut_P3 = position.InoutAxis_P3;
            MoveP.Middle_P2 = position.MiddleAxis_P2;
            MoveP.UpDown_P3 = position.UpdownAxis_IH_P3;
            MoveP.UpDown_P4 = position.UpdownAxis_IL_P4;
            MoveP.UpDown_P5 = position.UpdownAxis_OH_P5;
            MoveP.UpDown_P6 = position.UpdownAxis_OL_P6;

        }
    } 
    
}