InOutParam.cs 7.1 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
{
    /// <summary>
    /// 出入仓参数(出入库操作时传入的参数类)
    /// </summary>
    public class InOutParam
    {
        public static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        public InOutParam()
        { 
            this.WareCode = "";
            MoveP = null;   
        } 
        public InOutParam(string wareNo, string posId, string ShelfPosID, string platew = "", string plateh = "", bool urgentReel = false, bool cutReel = false, bool smallReel = false, string rfid = "", int rfidLoc = 0,int taskCount=0)
        {
            this.ShelfPosID = ShelfPosID;
            WareCode = wareNo;
            PosID = posId;
            MoveP = null;
            this.PlateW = platew;
            this.PlateH = plateh; 
            this.urgentReel = urgentReel;
            this.cutReel = cutReel;
            this.smallReel = smallReel;
            this.rfid = rfid;
            this.rfidLoc = rfidLoc;
            this.taskCount = taskCount;
        } 
        public InOutParam(string wareNo, string posId, string ShelfPosID,LineMoveP linePosition )
        { 
            WareCode = wareNo;
            this.ShelfPosID = ShelfPosID;
            PosID = posId;
            MoveP = linePosition; 
            NeedEnterShelf = false;
            NeedOutShelf = false;
            this.urgentReel = false ;
            this.cutReel = false ;
            this.smallReel = false ;
            this.rfid = "";
            this.rfidLoc = 0;
            this.taskCount = 0;
        }  
        /// <summary>
        /// 物品二维码信息
        /// </summary>
        public string WareCode { get; set; }
        /// <summary>
        /// 位置坐标名(对应配置表的位置)
        /// </summary>
        public string PosID { get; set; }
        /// <summary>
        /// 料架对应的库位号
        /// </summary>
        public string ShelfPosID = "";
        public LineMoveP MoveP { get; set; }
        /// <summary>
        /// 料盘高度
        /// </summary>
        public string  PlateH { get; set; }
        /// <summary>
        /// 料盘宽度
        /// </summary>
        public string PlateW { get; set; }
       

        /// <summary>
        /// 出入库时需要进入新料架
        /// </summary>
        public bool NeedEnterShelf = true;
        /// <summary>
        /// 出入库结束后需要将料架送出
        /// </summary>
        public bool NeedOutShelf = true;
        /// <summary>
        /// urgentReel: true 表示紧急料,需要出到料串上
        /// </summary>
        public bool urgentReel { get; set; }
        /// <summary>
        /// cutReel: true 表示分盘料,需要出到料串上
        /// </summary>
        public bool cutReel { get; set; }
        /// <summary>
        /// smallReel: true  小料(7x8),放置到小料架上
        /// </summary>
        public bool smallReel { get; set; }

        /// <summary>
        /// rfid: 分配的料架RFID
        /// </summary>
        public string rfid { get; set; }
        /// <summary>
        /// rfidLoc: 料架的架位,值为 - 1时,可以自由分配皮带线, 
        /// 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线, 
        /// 70,71,72时只能分配到3 / 4号皮带线; 
        /// 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3/ 4号皮带线
        /// </summary>
        public int rfidLoc { get; set; }
        /// <summary> 
        /// 剩余任务数量,当剩余任务 《=1时,出库完成需要送出料架
        /// 剩余任务数为0, 或者料架已放满,或者料架rfid与上一个任务不同,料架就要放出去
        /// 剩余任务数为1时, 当前的料放完就可以把料架放出去了
        ///当前料放完,料架已满,也把料架放出去
        /// </summary>
        public int taskCount { 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 " 料架号[" + ShelfPosID + "],库位号 [" + PosID + "], [" + WareCode + "], [" + PlateW + "x" + PlateH + "]" +
               "NeedEnterShelf【" +  NeedEnterShelf + "】NeedOutShelf【" +  NeedOutShelf + "】"+
                "urgentReel [" + urgentReel + "],cutReel [" + cutReel + "],smallReel [" + smallReel + "],rfid [" + rfid + "],rfidLoc [" + rfidLoc + "],taskCount ["+ taskCount + "]";
        }
        public string ToShortStr()
        {
            return "  [" + ShelfPosID + "] [" + PosID + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "]";
        }

        internal void UpdateShelfPosId(string pId)
        {
            this.ShelfPosID = pId;
            ShelfPosition sp = CSVPositionReader<ShelfPosition>.GetPositon(ShelfPosID);
            if (sp == null)
            {
                LogUtil.error(  "GetPositon[" + ShelfPosID + "]=null,没有库位不能执行出入库"); 
            }

            MoveP.InOut_P101 = sp.InoutAxis_P101;
            MoveP.UpDown_LP101 = sp.UpDownAxis_LP101;
            MoveP.UpDown_HP102 = sp.UpDownAxis_HP102;
            MoveP.Middle_P101 = sp.MiddleAxis_P101;

        }

        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.InOut_P11= position.InOutAxis_P11;

            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;
        }
    } 
    
}