Shelves.cs 2.9 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CtuDeviceLib
{
    /// <summary>
    /// 货架
    /// </summary>
    public class Shelves
    {
        /// <summary>
        /// 货架号
        /// </summary>
        public string PosId { get; set; }

        /// <summary>
        /// 楼层
        /// </summary>
        public int Floor { get; set; }
        /// <summary>
        /// 巷道编码
        /// </summary>
        public string Lanway { get; set; }
        /// <summary>
        /// 库位在车头的左侧/右侧
        /// </summary>
        public char Side { get; set; }
        /// <summary>
        /// 地面点位编码
        /// </summary>
        public uint PointCode { get; set; }
        /// <summary>
        /// 所在层
        /// </summary>
        public int Row { get; set; }
        /// <summary>
        /// 升降高度
        /// </summary>
        public int UpDownHeight { get; set; }
        /// <summary>
        /// 进出深度
        /// </summary>
        public int InoutDepth { get; set; }
        /// <summary>
        /// 料箱码读码偏移距离
        /// </summary>
        public int ScanCodeShift { get; set; }
        /// <summary>
        /// 料箱宽度
        /// </summary>
        public int ContainerWidth { get; set; }
        //描述
        public string Desc { get; set; }
        /// <summary>
        /// 货架码
        /// 16位
        /// </summary>
        /// <param name="posid"></param>
        public Shelves(string posid, string pointcode, int updown, int inout, int scancode, int containerWidth)
        {
            if (string.IsNullOrEmpty(posid))
                return;
            if (posid.Length < 16)
            {
                posid = "";
                Lanway = "";
                if (!string.IsNullOrEmpty(pointcode))
                {
                    PointCode = uint.Parse(pointcode);
                }
                InoutDepth = inout;
                ScanCodeShift = scancode;
                ContainerWidth = containerWidth;
                return;
            }
            PosId = posid;
            string floor = posid.Substring(0, 1);
            string laneway = posid.Substring(1, 3);
            string side = posid.Substring(4, 1);
            string pointCode = posid.Substring(5, 8);
            if (!string.IsNullOrEmpty(pointcode))
            {
                pointCode = pointcode;
            }
            string row = posid.Substring(14);

            int.TryParse(floor, out int val);
            Floor = val;
            Lanway = laneway;
            Side = side[0];
            PointCode = uint.Parse(pointCode);
            Row = int.Parse(row);
            UpDownHeight = updown;
            InoutDepth = inout;
            ScanCodeShift = scancode;
            ContainerWidth = containerWidth;
        }
    }
}