using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace UIControl
{
    [Serializable]
    public class CItem
    {
        public Boolean Delete { get; set; }
        /// 
        /// 어떠한 포트에서 픽업 되었는지
        /// 
        public int iPort { get; set; }
        /// 
        /// 출력 포트
        /// 
        public int oPort { get; set; }
        /// 
        /// 배출여부
        /// 
        public  int ErrorOut { get; set; }
        /// 
        /// 크기는 어떠한지(7 or 13)
        /// 
        public string Size { get; set; }
        /// 
        /// 존번호 0~10
        /// 
        public int index { get; set; }
        /// 
        /// 피커에의해서 드랍된 시간
        /// 
        public DateTime DropTime { get; set; }
        /// 
        /// 차수별 일련번호
        /// 
        public UInt16 Seq { get; set; }
        public DateTime BarcodeStart { get; set; }
        public DateTime BarcodeEnd { get; set; }
        public DateTime PlcStartTime { get; set; }
        public DateTime PlcEndTime { get; set; }
        public DateTime ZoneIntime { get; set; }
        /// 
        /// 컨베이어에 들어온 시간 
        /// 피커에서 드랍되면 dropTime 과 동일하며, 외부에서 들어오면 센서가 최초 감지한 시간이 된다
        /// 
        public DateTime InTime { get; set; }
        public DateTime OutTime { get; set; }
        public Rectangle Rect { get; set; }
        /// 
        /// jobhistory에 연결되는 데이터 키
        /// 
        public string JGUID { get; set; }
        /// 
        /// 바코드 데이터와 연결되는 키값
        /// 
        public string Tag { get; set; }
        public string RID { get; set; }
        public string SID { get; set; }
        public string BarcodeRaw { get; set; }
        public string BarcodeMsg { get; set; }
        public Boolean Processing { get; set; }
        public string GUID { get; private set; }
        public int Qty { get; set; }    
        public List UnloaderMsg { get; set; }
        /// 
        /// 바코드의 완료여부, timeout 혻은 설정 되었을때 적용
        /// 
        public Boolean BarcodeDone { get; set; }
        public Boolean hasBarcode
        {
            get
            {
                return !string.IsNullOrEmpty(RID);
            }
        }
        public void AddMessage(string msg)
        {
            if (this.UnloaderMsg.Contains(msg) == false)
                UnloaderMsg.Add(msg);
        }
        public CItem()
        {
            Qty = 0;
            UnloaderMsg = new List();
            ErrorOut = 0;
            this.GUID = Guid.NewGuid().ToString();
            Tag = string.Empty;
            JGUID = string.Empty;
            Seq = 0;
            SID = string.Empty;
            BarcodeRaw = string.Empty;
            BarcodeMsg = string.Empty;
            RID = string.Empty;
            Rect = Rectangle.Empty;
            Delete = false;
            Processing = false;
            DropTime = DateTime.Parse("1982-11-23");
            BarcodeStart = DateTime.Parse("1982-11-23");
            BarcodeEnd = DateTime.Parse("1982-11-23");
            PlcStartTime = DateTime.Parse("1982-11-23");
            PlcEndTime = DateTime.Parse("1982-11-23");
            InTime = DateTime.Parse("1982-11-23");
            OutTime = DateTime.Parse("1982-11-23");
            ZoneIntime = DateTime.Parse("1982-11-23");
            index = -1;
            oPort = -1;
            iPort = -1;
            Size = string.Empty;
        }
        public CItem Clone()
        {
            var item = new CItem();
            item.Qty = Qty;
            item.Seq = Seq;//0;
            item.SID =SID;// string.Empty;
            item.BarcodeRaw = BarcodeRaw;//string.Empty;
            item.BarcodeMsg = BarcodeMsg;//string.Empty;
            item.RID = RID;//string.Empty;
            item.Rect = Rect;//Rectangle.Empty;
            item.Delete = Delete;//DropTime;//;
            item.DropTime =DropTime;// DateTime.Parse("1982-11-23");
            item.BarcodeStart =BarcodeStart;// DateTime.Parse("1982-11-23");
            item.BarcodeEnd = BarcodeEnd;//DropTime;//.Parse("1982-11-23");
            item.PlcStartTime = PlcStartTime;//DateTime.Parse("1982-11-23");
            item.PlcEndTime =PlcEndTime;// DateTime.Parse("1982-11-23");
            item.InTime = InTime;//DropTime;//.Parse("1982-11-23");
            item.OutTime = OutTime;//DateTime.Parse("1982-11-23");
            item.ZoneIntime = ZoneIntime;//DateTime.Parse("1982-11-23");
            item.index = index;
            item.oPort = oPort;
            item.iPort = iPort;
            item.Size = Size;
            return item;
        }
    }
}