using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Project
{
	public enum eWaitMessage
	{
		PX = 0,
		PZ,
		LMOVE,
		LUPDN,
		RMOVE,
		RUPDN,
		LPRINT,
		RPRINT,
		VIS0,
		VIS1,
		VIS2,
	}
	//public enum eJobResult
	//{
	//    None = 0,
	//    Error,
	//    ErrorOut,
	//    MaxCount,
	//    NotExistSID,
	//    DisableUnloader,
	//    MatchFail,
	//    NoBarcode
	//}
	public enum eCartSize
	{
		None = 0,
		Inch7 = 7,
		Inch13 = 13
	}

	public enum ePrintPutPos
	{
		None = 0,
		Top,
		Middle,
		Bottom,
	}

	public enum ePrintVac
	{
		inhalation = 0,
		exhaust,
		off,
	}

	public enum eFlag
	{
		RDY_CAMERA_L = 0,
		RDY_CAMERA_R,
		INIT_MOTIO,
		//INIT_LICENSE,
		INIT_PRINTER,

		PORT0_ENDDOWN,
		PORT1_ENDDOWN,
		PORT2_ENDDOWN,

		WAIT_PAPERDETECTL,
		WAIT_PAPERDETECTR,

		/// <summary>
		/// 프린터Z(상하)축의 ON/OFF 플래그
		/// </summary>
		RUN_PLZ_PICKON,
		RUN_PRZ_PICKON,
		RUN_PLZ_PICKOF,
		RUN_PRZ_PICKOF,

		/// <summary>
		/// 프린터Y(이동)축의 ON/OFF 플래그
		/// </summary>
		RUN_PLM_PICKON,
		RUN_PLM_PICKOF,
		RUN_PRM_PICKON,
		RUN_PRM_PICKOF,

		/// <summary>
		/// 이값이 설정되면 프린트시에 상단좌표값으로 이동합니다.
		/// </summary>
		//PRL_PUTPOSITIONH,
		/// <summary>
		/// 이값이 설정되면 프린트시에 상단좌표값으로 이동합니다.
		/// </summary>
		//PRR_PUTPOSITIONH,

		WAT_MAGNET0,
		WAT_MAGNET1,
		WAT_MAGNET2,

		RDY_VISION0,
		RDY_VISION1,
		RDY_VISION2,

		END_VISION0,
		END_VISION1,
		END_VISION2,

		/// <summary>
		/// 비젼을 처리완료 했는가
		/// </summary>
		PRC_VISION0,
		PRC_VISION1,
		PRC_VISION2,

		MOVE_PICKER,
		JOYSTICK,

		/// <summary>
		/// Y축이 Front로 가지러 가기로 함
		/// </summary>
		CMD_YP_LPICKON,
		CMD_YP_LPICKOF,
		CMD_YP_RPICKON,
		CMD_YP_RPICKOF,

		//피커의 X축이 일을 하러 갔는가?        
		RDY_PX_PICKON,
		RDY_PX_PICKONWAITL,
		RDY_PX_PICKONWAITR,
		RDY_PX_LPICKOF,
		RDY_PX_RPICKOF,

		//X축이 이동한후 해당 언로더에 자료를 셋팅했는가?
		SET_DATA_PORT0,
		SET_DATA_PORT2,

		RDY_PZ_PICKON,
		RDY_PZ_LPICKOF,
		RDY_PZ_RPICKOF,

		RUN_PRINTL,
		RUN_PRINTR,

		OK_PRINTL,
		OK_PRINTR,

		/// <summary>
		/// 해당 포트의 자재 준비여부
		/// </summary>
		RDY_PORT_PL,
		RDY_PORT_PC,
		RDY_PORT_PR,



		/// <summary>
		/// 자재를 PICK 했다
		/// </summary>
		PK_ITEMON,
		PL_ITEMON,
		PR_ITEMON,

		/// <summary>
		/// 포트에 아이템이 있는가? 
		/// 1번의 경우 Detect 센서가 들어오면 ItemON 설정을 한다.
		/// 0,2번의 경우 피커가 아이템을 놓을때 설정한다
		/// 실제로는 ITEMON 과 Align =1, 일때 촬영이가능하게한다
		/// </summary>
		PORTL_ITEMON,
		PORTR_ITEMON,

		WAIT_LOADERINFO,
		/// <summary>
		/// 작업시작화면
		/// </summary>
		SCR_JOBSELECT,
		/// <summary>
		/// 작업종료화면
		/// </summary>
		//SCR_JOBFINISH,
		/// <summary>
		/// 작업완료
		/// </summary>
		JOB_END,

		UserStepCheck,
		MINSPACE,
		DEBUG,
		//RUN_INIT,
	}

	public enum eRunSequence
	{
		COMMON = 0,
		PICKERZ,
		PRINTL,
		PRINTR,
		PRINTLZ,
		PRINTRZ,
		VISION0,
		VISION1,
		VISION2,

		//common timevalue
		COM_PKX,
		COM_PKZ,
		COM_PLM,
		COM_PLZ,
		COM_PRM,
		COM_PRZ,
		COM_PT0,
		COM_PT1,
		COM_PT2,
		COM_VS0,
		COM_VS1,
		COM_VS2,
		COM_PRL,
		COM_PRR,
	}

	public enum eJobType : byte
	{
		Sorter = 0,
		Dryrun,
	}

	public enum eHeaderHandler
	{
		Ping = 0,
		RequestData,
		RequstSeqNo,
		RequstInputReel,
		JobEnd,
		JobDelete,
	}
	public struct sVisionDMResult
	{
		public Boolean iSystemErr { get; set; }
		public Boolean isError { get; set; }
		public string DM { get; set; }
		public System.Drawing.Rectangle ROS { get; set; }

		public System.Drawing.PointF DMCenter { get; set; }
		public List<System.Drawing.PointF> DMCorner { get; set; }
		public string DMMessage { get; set; }
	}
	public struct sObjectDetectResult
	{
		public string Message { get; set; }
		public List<System.Drawing.Rectangle> Rect { get; set; }
		public List<uint> Areas { get; set; }
		public Boolean OK
		{
			get
			{
				if (Areas == null || Areas.Count < 1) return false;
				else return true;
			}
		}
	}

	public enum ePickZPosition
	{
		UNKNOWN = 0,
		READY,
		PICKON,
		PICKOFFL,
		PICKOFFR,
		DROP,
		LIMITP,
		LIMITN,
		HOME,
		ERROR,
	}

	public enum ePickYPosition
	{
		UNKNOWN = 0,		
		READYL,
		READYR,
		PICKON,
		PICKOFFL,
		PICKOFFR,
		LIMITP,
		LIMITN,
		HOME,
		ERROR,
	}
	public enum ePrintYPosition
	{
		UNKNOWN = 0,
		READY,
		//Pick,
		PRINTH07,
		PRINTL07,
		PRINTM07,   //중간위치추가 210205

		PRINTH13,
		PRINTL13,
		PRINTM13,   //중간위치추가 210205

		LIMITP,
		LIMITN,
		HOME,
		ERROR,
	}

	public enum ePrintZPosition
	{
		UNKNOWN = 0,
		READY,
		PICKON,
		PICKOFF,
		LIMITP,
		LIMITN,
		HOME,
		ERROR,
	}

	public enum eThetaPosition
	{
		UNKNOWN = 0,
		READY,
		LIMITP,
		LIMITN,
		HOME,
		ERROR,
	}

	/// <summary>
	/// 모션 축 정보
	/// </summary>
	public enum eAxis : byte
	{
		X_PICKER = 0,
		Z_PICKER,
		PL_MOVE,
		PL_UPDN,
		PR_MOVE,
		PR_UPDN,
		Z_THETA,
	}

	public enum eAxisPXPos : byte
	{
		READYL = 0,
		READYR,
		PICKON,
		PICKOFFL,
		PICKOFFR,
	}

	public enum eAxisPZPos : byte
	{
		READY = 0,
		PICKON,
		PICKOFFL,
		PICKOFFR,
	}

	public enum eAxisPTPos : byte
	{
		READY = 0,
	}

	public enum eAxisPLMovePos : byte
	{
		READY = 0,
		PRINTH07,
		PRINTL07,
		PRINTM07,
		PRINTH13,
		PRINTL13,
		PRINTM13,
	}
	public enum eAxisPLUPDNPos : byte
	{
		READY = 0,
		PICKON,
		PICKOFF,
	}
	public enum eAxisPRMovePos : byte
	{
		READY = 0,
		PRINTH07,
		PRINTL07,
		PRINTM07,
		PRINTH13,
		PRINTL13,
		PRINTM13,
	}
	public enum eAxisPRUPDNPos : byte
	{
		READY = 0,
		PICKON,
		PICKOFF,
	}
	public struct sSmInfo
	{
		public eRunStep bStep;
		public eRunStep oStep;
		public Boolean bUse;
		public Boolean bOUse;
		public Boolean bItemOn;
		public Boolean bOItemOn;

		public ePickYPosition cPoint;
		public ePickYPosition oPoint;
	}

	public struct sVisionDetectResult
	{
		public string Message { get; set; }
		public System.Drawing.Rectangle Rect { get; set; }
		public float PixelCount { get; set; }
		public Boolean OK { get; set; }
	}
	public struct sVisionOrientResult
	{
		public Boolean isError { get; set; }
		public string Message { get; set; }
		public System.Drawing.Size PatternSize { get; set; }
		public double Score { get; set; }
		public Point UnitTermOffset { get; set; }
		public System.Drawing.Rectangle ROS { get; set; }
		public System.Drawing.PointF CenterPoint { get; set; }
		public Boolean OK { get; set; }
		public System.Drawing.PointF Offset { get; set; }
		public void Clear()
		{
			Message = "Not Set";
			PatternSize = System.Drawing.Size.Empty;
			Score = 0.0;
			ROS = Rectangle.Empty;
			UnitTermOffset = Point.Empty;
			CenterPoint = PointF.Empty;
			OK = false;
			Offset = PointF.Empty;
			PatternSize = Size.Empty;
			isError = false;
		}
	}
	public struct sVisionDotResult
	{
		public Boolean VisionDotOK { get; set; }     //성공여부
		public string VisionDotMessage { get; set; } //메세지
		public int VisionDotCount { get; set; } //검출된 DOT영역갯수
		public List<System.Drawing.RectangleF> VisionDotArea; //검출될 dot영역의 위치값
		public List<uint> VisionDotRunCount;//검출된 dot영역의 질량
		public List<System.Drawing.SizeF> VisionDotCicleSize;
	}
	public struct sIOCheckResult
	{
		public Boolean Complete { get; set; }
		public Boolean TimeOut { get; set; }
		public string Message { get; set; }
	}
	public enum eMKBinType
	{
		NewMarking = 0,
		RejectMarking
	}



	public enum eGridValue
	{
		/// <summary>
		/// 아직 처리 전(기본 초기화된 상태)
		/// </summary>
		NotSet = 0,

		/// <summary>
		/// 원점검사에서 오류 발생
		/// </summary>
		OrientError,

		/// <summary>
		/// 아이템검출에서 실패됨
		/// </summary>
		NoItem,

		/// <summary>
		/// 아이템검출성공, 데이터매트릭스 검출 실패
		/// </summary>
		NewItem,

		/// <summary>
		/// 데이터매트릭스 읽기 실패
		/// </summary>
		DMReadError,

		/// <summary>
		/// 데이터매트릭스 관리 횟수가 기준횟수(10) 미만 (아직 정상)
		/// </summary>
		DMNotmalCount,

		/// <summary>
		/// 데이터매트릭스 관리 횟수가 기준횟수(10)를 초과한 경우
		/// </summary>
		DMOverCount,



	}

	public enum eRoiSeq
	{
		Area = 0,
		DataMatrix,
		Orient,
		DetectUnit,
		DetectDM
	}
	public enum eWaitType : byte
	{
		TryLock = 0,
		TryUnLock,
		AirBlowOn,
		AirBlowOff,
		AirBlowDustOn,
		AirBlowDustOff,
		PrintPickLOff,
		PrintPickLOn,
		PrintPickROff,
		PrintPickROn,
		PickOff,
		PickOn,
		AirBlowCoverDn,
		AirBlowCoverUp,
		UnloaderUp,
		UnloaderDn,
		LiftUp,
		LiftDn,
	}

	public enum eSensorState : byte
	{
		Off = 0,
		On = 1,
		InComplete = 2,
	}
	public enum eIOCheckResult
	{
		Wait = 0,
		Complete,
		Timeout
	}

	public enum eVar_Date
	{
		MGZSafty11o = 0,
		MGZSafty12o,
		MGZSafty21o,
		MGZSafty22o,
		MGZSafty31o,
		MGZSafty32o,
		MGZSafty41o,
		MGZSafty42o,
		SaftyConvIno,
		SaftyConvOuto,

		MGZSafty11f,
		MGZSafty12f,
		MGZSafty21f,
		MGZSafty22f,
		MGZSafty31f,
		MGZSafty32f,
		MGZSafty41f,
		MGZSafty42f,
		SaftyConvInf,
		SaftyConvOutf,

	}


	public enum ePort
	{
		Left = 0,
		Right,
	}

	public enum eRunResult
	{
		Wait = 0,
		Complete,
		Error,
	}
	enum eResultStringType
	{
		Nomal = 0,
		Attention,
		Error,
	}
	public enum eMotDir
	{
		Stop = 0,
		CW = 1,
		CCW = 2
	}

	/// <summary>
	/// RUN중일 때 사용되는 세부 시퀀스
	/// </summary>
	public enum eRunStep : byte
	{
		NOTSET = 0,

		/// <summary>
		/// 프로그램 체크
		/// </summary>
		STARTCHKSW,
		/// <summary>
		/// 하드웨어 체크
		/// </summary>
		STARTCHKHW,

		/// <summary>
		/// 기계장치를 작업 시작 전 상태로 이동합니다
		/// </summary>
		INITIALHW,

		/// <summary>
		/// 안전지대(비활성화된경우 발생)
		/// </summary>
		SAFTYZONE_GO,
		SAFTYZONE_RDY,

		BEGINLOAD,
		/// <summary>
		/// 트레이를 로딩하기 위한 로더 이동 및 트레이 추출
		/// </summary>
		PORTLOAD,


		/// <summary>
		/// 비젼촬영을위한 위치로 이동
		/// </summary>
		BEGINPICK,
		ENDPICK,

		OVERLOAD,
		SAVEDATA,

		/// <summary>
		/// 모션 원위치
		/// </summary>
		BARCODE,

		/// <summary>
		/// AIR/BLOW 위치 이동 및 작업
		/// </summary>
		AIRBLOW,
		REELOUT,
		TRAYOUT,

		/// <summary>
		/// 언로드위치로 셔틀을 이동
		/// </summary>
		BEGINUNLOADER,
		/// <summary>
		/// 트레이 언로드 작업
		/// </summary>
		TRAYUNLOAD,

		/// <summary>
		/// 언로딩하고 다시 로딩존으로 이동하는 시퀀스
		/// </summary>
		MOVE_TO_LOAD,

	}


	public enum ePLCIPin : byte
	{
		X00, X01, X02, X03, X04, X05, X06, X07, X08, X09, X0A,
		X10, X11, X12, X13, X14, X15, X16, X17, X18, X19, X1A
	}
	public enum ePLCOPin : byte
	{
		Y00, Y01, Y02, Y03, Y04, Y05, Y06, Y07, Y08, Y09, Y0A,
		Y10, Y11, Y12, Y13, Y14, Y15, Y16, Y17, Y18, Y19, Y1A
	}
	public enum ePLCITitle : byte
	{
		Run, Cart_Status_01, Cart_Status_02, Cart_Status_03, Cart_Status_04,
		Machine_Confirm = 19
	}
	public enum ePLCOTitle : byte
	{
		Cart_No_Setting = 0,
		Handler_Confirm = 19,
	}


	public enum eVarTime
	{
		DET5ON,
		DET4ON,
		PORT0,
		PORT1,
		PORT2,
		MAGNET2,
		MAGNET1,
		MAGNET0,
		QRCHECK0,
		QRCHECK2,
		LIVEVIEW0,
		LIVEVIEW1,
		LIVEVIEW2,
		CHK_POSRSTCONVTIME,
		PRINTL,
		PRINTR,
		CMDTIME_MOTYP,
		CMDTIME_MOTZL,
		CMDTIME_MOTZR,
		JOB_END,
		SMRUNERROR,
	}

	
	public enum eDIPin : byte
	{
		X00, X01, X02, X03, X04, X05, X06, X07,
		X08, X09, X0A, X0B, X0C, X0D, X0E, X0F,
		X10, X11, X12, X13, X14, X15, X16, X17,
		X18, X19, X1A, X1B, X1C, X1D, X1E, X1F,
		X20, X21, X22, X23, X24, X25, X26, X27,
		X28, X29, X2A, X2B, X2C, X2D, X2E, X2F,
		X30, X31, X32, X33, X34, X35, X36, X37,
		X38, X39, X3A, X3B, X3C, X3D, X3E, X3F
	}

	public enum eDIName : byte
	{
		BUT_STARTF = 0x00, BUT_STOPF, BUT_RESETF, BUT_EMGF, BUT_AIRF,
		AIR_DETECT = 0x05, PICKER_SAFE = 0x08,

		DOORF1 = 0x0A, DOORF2, DOORF3,
		DOORR1 = 0x0D, DOORR2, DOORR3,

		PORT0_SIZE_07 = 0x1A, PORT0_SIZE_13, PORT0_LIM_UP, PORT0_LIM_DN, PORT0_DET_UP,
		PORT1_SIZE_07 = 0x10, PORT1_SIZE_13, PORT1_LIM_UP, PORT1_LIM_DN, PORT1_DET_UP,
		PORT2_SIZE_07 = 0x15, PORT2_SIZE_13, PORT2_LIM_UP, PORT2_LIM_DN, PORT2_DET_UP,

		R_PICK_BW = 0x20, R_PICK_FW, R_PICK_VAC,
		L_PICK_BW = 0x24, L_PICK_FW, L_PICK_VAC,
	}

	public enum eDOPin : byte
	{
		Y00, Y01, Y02, Y03, Y04, Y05, Y06, Y07,
		Y08, Y09, Y0A, Y0B, Y0C, Y0D, Y0E, Y0F,
		Y10, Y11, Y12, Y13, Y14, Y15, Y16, Y17,
		Y18, Y19, Y1A, Y1B, Y1C, Y1D, Y1E, Y1F,
		Y20, Y21, Y22, Y23, Y24, Y25, Y26, Y27,
		Y28, Y29, Y2A, Y2B, Y2C, Y2D, Y2E, Y2F,
		Y30, Y31, Y32, Y33, Y34, Y35, Y36, Y37,
		Y38, Y39, Y3A, Y3B, Y3C, Y3D, Y3E, Y3F
	}

	public enum eDOName : byte
	{
		BUT_STARTF = 0x00, BUT_STOPF, BUT_RESETF, BUT_EMGF, BUT_AIRF,

		SOL_AIR = 0x07, BUZZER,
		LAMPON1 = 0x0A,

		TWR_GRNF = 0x0D, TWR_YELF, TWR_REDF,

		PORT0_MOT_RUN = 0x1A, PORT0_MOT_DIR, CART_MAG0,
		PORT1_MOT_RUN = 0x10, PORT1_MOT_DIR, CART_MAG1,
		PORT2_MOT_RUN = 0x14, PORT2_MOT_DIR, CART_MAG2,

		PRINTL_FWD = 0x1D,
		PRINTL_VACO = 0x1E, PRINTL_VACI,
		PRINTR_FWD = 0x17,
		PRINTR_VACO = 0x18, PRINTR_VACI,

		PRINTL_AIRON = 0x20, PRINTR_AIRON,

		PICK_VAC1 = 0x23, PICK_VAC2, PICK_VAC3, PICK_VAC4,

		SVR_PWR_0 = 0x28, SVR_PWR_1, SVR_PWR_2, SVR_PWR_3, SVR_PWR_4, SVR_PWR_5, SVR_PWR_6,
		SVR_EMG_0 = 0x30, SVR_EMG_1, SVR_EMG_2, SVR_EMG_3, SVR_EMG_4, SVR_EMG_5, SVR_EMG_6,
	}

	public enum eResult : byte
	{
		NOERROR,
		EMERGENCY,
		SAFTY,
		SETUP,
		HARDWARE,
		SENSOR,
		MOTION,
		OPERATION,
		COMMUNICATION,
		TIMEOUT,
		UNLOADER,
	}


	public enum eECode : byte
	{
		VISCONF,
		RDYPORTC,
		noerror,
		portoverload,
		emergency,
		nomodelv,
		nomodelm,
		ITEMNODROPL,
		NOPRINTLDATA,
		NOPRINTRDATA,
		NOSIDREF,
		PRINTL,
		PRINTR,
		CAM_CONN,
		CAM_LEFT,
		CAM_RIGHT,
		VISION_DATA,
		EVISION_CONN,
		CAM_NOBARCODEU,
		CAM_NOBARCODEL,
		BARCODEVALIDERR,

		DOORF,
		DOORR,

		NOPUTPOSITION,
		NOREELSIZEL,
		NOREELSIZER,

		LICENSE,
		PRINTER,

		CARTERROR,

		CARTL,
		CARTC,
		CARTR,

		CARTLMATCH,
		CARTCMATCH,
		CARTRMATCH,

		RIDDUPL,
		RIDDUPR,

		SIDERR103,
		SIDERR106,
		SIDERR101,

		//FINISH,
		HOME_TIMEOUT,
		PICKOVL,
		saftyport,
		airnoout,
		dooff,
		doon,
		dioff,
		dion,
		azininit,
		extin,

		MOT_INIT,
		MOT_HSET,
		MOT_SVALM,
		MOT_SVOFF,
		MOT_HSEARCH,
		MOT_MOVE,
		MOTX_SAFETY,
		MOT_CMD,
		MNBR,
		MOTION_MODEL,

		NOITEM,
		USER_STOP,
	}

	public enum eNextStep : byte
	{
		nothing = 0,
		pause,
		pauseNoMessage,
		error
	}
	public enum eILockPKX
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		ZL_POS,
		ZR_POS,
		ZMOVE,
		PKZPOS,
	}

	public enum eILockPKZ
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		Y_POS,
		YMOVE,
		PORTRUN0,
		PORTRUN1,
		PORTRUN2
	}

	public enum eILockPKT
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		Y_POS,
		Y_MOVE,
		PortRun
	}


	/// <summary>
	/// PRINT MOVE AXIS (L+R)
	/// </summary>
	public enum eILockPRM
	{
		Emergency = 0,
		Pause,
		HomeSet,
		Safty,
		Disable,
		ZMOVE,
		FORWARD,
		ITEMON,
		PKXPOS,
		PRNZPOS,
	}

	public enum eILockPRZ
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		YMOVE,
		ITEMON,
		PRNYPOS,
	}
	public enum eILockPRL
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		PRNYPOS,
		PRNZPOS,
	}
	public enum eILockPRR
	{
		EMG = 0,
		PAUSE,
		HomeSet,
		DOOR,
		Disable,
		PRNYPOS,
		PRNZPOS,
	}
	public enum eILockVS0
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		PORTRDY,
		PKXPOS,  //피커의 위치
		PRNYPOS,  //프린터Y축 위치
	}
	public enum eILockVS1
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		PORTRDY,
		PKXPOS,
	}
	public enum eILockVS2
	{
		EMG = 0,
		PAUSE,
		HOMESET,
		DOOR,
		Disable,
		PORTRDY,
		PKXPOS,  //피커의 위치
		PRNYPOS,  //프린터Y축 위치
	}
}
