#ifndef	_NEW_COMMON_H_
#define	_NEW_COMMON_H_

#define	NO						0
#define	YES						1

#define	OFF						0
#define	ON						1

#ifndef	NULL
	#define	NULL				0
#endif

#ifndef	FALSE
	#define	FALSE				0
#endif
#ifndef	TRUE
	#define	TRUE				1
#endif
#define	SYSTEM_LASER_COMPLEX				1
#define	SYSTEM_PC_COUNT							        1
#define	SYSTEM_HCB_COUNT						        1

#define	SYSTEM_SPB_MAX_COUNT				        8
#define	SYSTEM_SPB_CAMERA_COUNT			        	4
#define	SYSTEM_SPB_CAMERA_MAX_COUNT				  	4

#define	SYSTEM_CPB_COUNT					          32
#define	SYSTEM_CPB_MAX_COUNT					      32
#define	TPB_CPB_MAX_COUNT					      8
#define	SYSTEM_MAX_SPB_CLIENT_BOARD_COUNT		8
////// end

////// For SELMA200, Add by moon. ★☆★☆
// CPB 버전에 따라 CPB 1개당 가용할 수 있는 Core의 개수가 다름
#define CPB_VERSION_04    1
#define CPB_VERSION_05    2
////// end

////// For SELMA200, Add by moon. ★☆★☆
// 3D 카메라가 현재SPB내에 확인되는지 아닌지를 판단하는데 이용
#define SUCTION_DISK_NONE 0
#define SUCTION_DISK_NUM1 1
#define SUCTION_DISK_NUM2 2
////// end

#define	SYSTEM_TOTAL_CAMERA_COUNT				    16  // (20180208) 10 -> 16

#define	CAPTURE_INT_DELAY_50US						600		// * 50us
#define   LAMP_SUGAR_TABLET_DELAY						10		//6*50 == 300us

#define	SYSTEM_TOTAL_LED_COUNT					12
#define	SYSTEM_DISK_LED_COUNT					SYSTEM_TOTAL_LED_COUNT/2
#define	SYSTEM_MACHINE_CAPTURE_COUNT			6

#define	SYSTEM_CAMERA_WIDTH						640
#define	SYSTEM_CAMERA_HEIGHT					480
#define	SYSTEM_CAMERA_HD_WIDTH				1280
#define	SYSTEM_CAMERA_HD_HEIGHT				960

#define	SYSTEM_CAMERA_WIDTH_3D					480
#define	SYSTEM_CAMERA_HEIGHT_3D					640

#define	IMAGE_WIDTH_3D							320
#define	IMAGE_HEIGHT_3D							480

// 각 회사 개별 기능 분리를 위한 Define
#define INTERNATIONAL_MACHINE1					0  // Q사
#define INTERNATIONAL_MACHINE2					1  // ajanta

#define DOMESTIC_MACHINE1						2	// 기본
#define DOMESTIC_MACHINE2						3	// 한국콜마
#define DOMESTIC_MACHINE3						4


#define MAX_PIO5_PORT_NUM 		16
#define MAX_PIO5_PORT_OFFSET 	80

#define MAX_RECIPE_NAME_SIZE				256
#define MAX_RECIPE_DESCRIPTION_SIZE		512
#define MAX_RECIPE_COUNT					1000

#define MACHINE_TYPE_SELMA_BASIC			0
#define MACHINE_TYPE_LIMA_BASIC			1
#define MACHINE_TYPE_SELMA_ADVANCED		2
#define MACHINE_TYPE_LIMA_ADVANCED		3


#define PROGRAM_MAJOR_VERSION	7
#define PROGRAM_MINOR_VERSION	0

#define PROGRAM_TARGET_SYSTEM		0x54
#define PROGRAM_RELEASE_DATE    240801

//***********************************************************************************/
// version note
// Ajanta : 5.4.230128
//***********************************************************************************/

/************************************************************************************/
/* 변수에서	Bit값의	읽고 쓰기 위한 정의					    */
/************************************************************************************/

#define	BIT32_GET(VAR,FIELD) (unsigned int)( \
  	(VAR&##FIELD##_MASK)>>##FIELD##_SHIFT \
)

#define	BIT32_SET(VAR,FIELD,Val) VAR=(unsigned int)( \
  	(VAR&~##FIELD##_MASK)|(((unsigned int)(Val)<<##FIELD##_SHIFT)&##FIELD##_MASK) \
)

#define	BIT16_GET(VAR,FIELD) (unsigned short)( \
  	(VAR&##FIELD##_MASK)>>##FIELD##_SHIFT \
)

#define	BIT16_SET(VAR,FIELD,Val) VAR=(unsigned short)( \
  	(VAR&~##FIELD##_MASK)|(((unsigned short)(Val)<<##FIELD##_SHIFT)&##FIELD##_MASK)	\
)

#define	BIT8_GET(VAR,FIELD)	(unsigned char)( \
  	(VAR&##FIELD##_MASK)>>##FIELD##_SHIFT \
)

#define	BIT8_SET(VAR,FIELD,Val)	VAR=(unsigned char)( \
  	(VAR&~##FIELD##_MASK)|(((unsigned char)(Val)<<##FIELD##_SHIFT)&##FIELD##_MASK) \
)

#define	BOARD_ID_PC				0x8000
#define	BOARD_ID_PCI			0x4000
#define	BOARD_ID_HCB(s)			((s	& 0x03)	<< 13)	// s = 1 ~ 3
#define	BOARD_ID_SPB(s)			((s	& 0x3F)	<< 6)	// s = 1 ~ 31
#define	BOARD_ID_CPB(c)			(c & 0x3F)			// c = 1 ~ 31
#define	BOARD_ID_SPB_CPB(s,	c)	(((s) << 6)	+ (c))	// s, c	= 1	~ 31

// program ID for flash
#define	PROGRAMINFO_PROGRAMKIND_MONITOR			(('M' << 8)	| 'O')	///	4D00 | 004F	= 4D4F(01001101	01001111)
#define	PROGRAMINFO_PROGRAMKIND_APPLICATION_4		(('A' << 8)	| '4')
#define	PROGRAMINFO_PROGRAMKIND_APPLICATION_TABLET_5		(('A' << 8)	| '2')
#define	PROGRAMINFO_PROGRAMKIND_APPLICATION_CAPSULE_5		(('A' << 8)	| '3')

#define	PROGRAMINFO_BOARDKIND_HCB				'H'
#define	PROGRAMINFO_BOARDKIND_SPB				'S'
#define	PROGRAMINFO_BOARDKIND_CPB				'C'
#define	PROGRAMINFO_BOARDKIND_TPB				'T'

#define	PID_BOOT_RECORD		(('B' << 16) | ('0'	<< 8) |	'0')

#define	PID_HCB_MONITOR		((PROGRAMINFO_BOARDKIND_HCB	<< 16) | PROGRAMINFO_PROGRAMKIND_MONITOR)
#define	PID_HCB_APPLICATION_ALL_4	PID_HCB_MONITOR
#define	PID_HCB_APPLICATION_TABLET_5	((PROGRAMINFO_BOARDKIND_HCB	<< 16) | PROGRAMINFO_PROGRAMKIND_APPLICATION_TABLET_5)
#define	PID_HCB_APPLICATION_CAPSULE_5	((PROGRAMINFO_BOARDKIND_HCB	<< 16) | PROGRAMINFO_PROGRAMKIND_APPLICATION_CAPSULE_5)

#define	PID_SPB				(PROGRAMINFO_BOARDKIND_SPB << 16)
#define	PID_HCB				(PROGRAMINFO_BOARDKIND_HCB << 16)
#define	PID_CPB				(PROGRAMINFO_BOARDKIND_CPB << 16)
#define	PID_TPB				(PROGRAMINFO_BOARDKIND_TPB << 16)

#define PID_TPB_TABLET  (PID_TPB | ('0'	<< 8) |	'0')
#define PID_TPB_CAPSULE  	(PID_TPB | ('1'	<< 8) |	'0')

#define	PID_SPB_TABLET_4	  	(PID_SPB | ('0'	<< 8) |	'0')
#define	PID_SPB_CAPSULE_4	  	(PID_SPB | ('1'	<< 8) |	'0')
#define	PID_SPB_TABLET_5   		(PID_SPB | ('2'	<< 8) |	'0')
#define	PID_SPB_CAPSULE_5  		(PID_SPB | ('3'	<< 8) |	'0')

#define	PID_CPB_TABLET_4	  	(PID_CPB | ('0'	<< 8) |	'0')
#define	PID_CPB_CAPSULE_4	  	(PID_CPB | ('1'	<< 8) |	'0')
#define	PID_CPB_TABLET_5	  	(PID_CPB | ('2'	<< 8) |	'0')
#define	PID_CPB_CAPSULE_5	  	(PID_CPB | ('3'	<< 8) |	'0')

/* 3.2 정제	PID	*/
#define	PID_HCB_DB_HEADER_T_3			(('D' << 24) | ('H'	<< 16) | ('T' << 8)	| '3')
#define	PID_SPB_DB_HEADER_T_3			(('D' << 24) | ('H'	<< 16) | ('T' << 8)	| '3')
#define	PID_HCB_MS_HEADER_T_3			(('M' << 24) | ('H'	<< 16) | ('T' << 8)	| '3')
#define	PID_SYSTEM_T_3		  			(('S' << 24) | ('S'	<< 16) | ('T' << 8)	| '3')
#define	PID_ENVIRONMENT_T_3				(('E' << 24) | ('V'	<< 16) | ('T' << 8)	| '3')
#define	PID_PORT_MAP_T_3			  	(('P' << 24) | ('M'	<< 16) | ('T' << 8)	| '3')
#define	PID_MACHINE_INFO_T_3  	  	(('M' << 24) | ('I'	<< 16) | ('T' << 8)	| '3')
#define	PID_USER_MACHINE_ENV_T_3	  (('U'	<< 24) | ('E' << 16) | ('T'	<< 8) |	'3')
#define	PID_RANGER_CAMERA_BASE_T_3	(('R' << 24) | ('B'	<< 16) | ('T' << 8)	| '3')
#define	PID_RANGER_CAMERA_T_3			(('R' << 24) | ('C'	<< 16) | ('T' << 8)	| '3')
#define	PID_TERMINATION_INFO_T_3  	(('T' << 24) | ('I'	<< 16) | ('T' << 8)	| '3')

/* 5.0 정제	PID	*/
#define	PID_HCB_DB_HEADER_T_5			(('D' << 24) | ('H'	<< 16) | ('T' << 8)	| '5')
#define	PID_SPB_DB_HEADER_T_5			(('D' << 24) | ('H'	<< 16) | ('T' << 8)	| '5')
#define	PID_HCB_MS_HEADER_T_5		(('M' << 24) | ('H'	<< 16) | ('T' << 8)	| '5')
#define	PID_SYSTEM_T_5					  (('S'	<< 24) | ('S' << 16) | ('T'	<< 8) |	'5')
#define	PID_ENVIRONMENT_T_5			  (('E'	<< 24) | ('V' << 16) | ('T'	<< 8) |	'5')
#define	PID_PORT_MAP_T_5				  (('P'	<< 24) | ('M' << 16) | ('T'	<< 8) |	'5')
#define	PID_MACHINE_INFO_T_5		(('M' << 24) | ('I'	<< 16) | ('T' << 8)	| '5')
#define	PID_USER_MACHINE_ENV_T_5	(('U' << 24) | ('E'	<< 16) | ('T' << 8)	| '5')
#define	PID_RANGER_CAMERA_BASE_T_5	(('R' << 24) | ('B'	<< 16) | ('T' << 8)	| '5')
#define	PID_RANGER_CAMERA_T_5		(('R' << 24) | ('C'	<< 16) | ('T' << 8)	| '5')
#define	PID_TERMINATION_INFO_T_5	(('T' << 24) | ('I'	<< 16) | ('T' << 8)	| '5')


/* 5.0 캡슐	PID	*/
#define	PID_HCB_DB_HEADER_C_5			(('D' << 24) | ('H'	<< 16) | ('C' << 8)	| '5')
#define	PID_SPB_DB_HEADER_C_5			(('D' << 24) | ('H'	<< 16) | ('C' << 8)	| '5')
#define	PID_HCB_MS_HEADER_C_5			(('M' << 24) | ('H'	<< 16) | ('C' << 8)	| '5')
#define	PID_SYSTEM_C_5				(('S' << 24) | ('S'	<< 16) | ('C' << 8)	| '5')
#define	PID_ENVIRONMENT_C_5			(('E' << 24) | ('V'	<< 16) | ('C' << 8)	| '5')
#define	PID_PORT_MAP_C_5			(('P' << 24) | ('M'	<< 16) | ('C' << 8)	| '5')
#define	PID_MACHINE_INFO_C_5		(('M' << 24) | ('I'	<< 16) | ('C' << 8)	| '5')
#define	PID_USER_MACHINE_ENV_C_5	(('U' << 24) | ('E'	<< 16) | ('C' << 8)	| '5')
#define	PID_RANGER_CAMERA_BASE_C_5	(('R' << 24) | ('B'	<< 16) | ('C' << 8)	| '5')
#define	PID_RANGER_CAMERA_C_5		(('R' << 24) | ('C'	<< 16) | ('C' << 8)	| '5')
#define	PID_TERMINATION_INFO_C_5	(('T' << 24) | ('I'	<< 16) | ('C' << 8)	| '5')


#ifdef VER5
	#ifdef PID_TYPE_CAPSULE
		#define	PID_HCB_DB_HEADER				PID_HCB_DB_HEADER_C_5
		#define	PID_SPB_DB_HEADER				PID_SPB_DB_HEADER_C_5
		#define	PID_HCB_MS_HEADER				PID_HCB_MS_HEADER_C_5
		#define	PID_SYSTEM					  	PID_SYSTEM_C_5
		#define	PID_ENVIRONMENT					PID_ENVIRONMENT_C_5
		#define	PID_PORT_MAP				  	PID_PORT_MAP_C_5
		#define	PID_MACHINE_INFO				PID_MACHINE_INFO_C_5
		#define	PID_USER_MACHINE_ENV		  PID_USER_MACHINE_ENV_C_5
		#define	PID_RANGER_CAMERA_BASE	  	PID_RANGER_CAMERA_BASE_C_5
		#define	PID_RANGER_CAMERA				PID_RANGER_CAMERA_C_5
		#define	PID_TERMINATION_INFO	  	PID_TERMINATION_INFO_C_5
	#else
		#define	PID_HCB_DB_HEADER				PID_HCB_DB_HEADER_T_5
		#define	PID_SPB_DB_HEADER				PID_SPB_DB_HEADER_T_5
		#define	PID_HCB_MS_HEADER				PID_HCB_MS_HEADER_T_5
		#define	PID_SYSTEM					  	PID_SYSTEM_T_5
		#define	PID_ENVIRONMENT					PID_ENVIRONMENT_T_5
		#define	PID_PORT_MAP			  		PID_PORT_MAP_T_5
		#define	PID_MACHINE_INFO				PID_MACHINE_INFO_T_5
		#define	PID_USER_MACHINE_ENV	  	PID_USER_MACHINE_ENV_T_5
		#define	PID_RANGER_CAMERA_BASE	  	PID_RANGER_CAMERA_BASE_T_5
		#define	PID_RANGER_CAMERA				PID_RANGER_CAMERA_T_5
		#define	PID_TERMINATION_INFO	  	PID_TERMINATION_INFO_T_5
	#endif
#else
	#define	PID_HCB_DB_HEADER			 PID_HCB_DB_HEADER_T_3
	#define	PID_SPB_DB_HEADER			 PID_SPB_DB_HEADER_T_3
	#define	PID_HCB_MS_HEADER			 PID_HCB_MS_HEADER_T_3
	#define	PID_SYSTEM					   PID_SYSTEM_T_3
	#define	PID_ENVIRONMENT				 PID_ENVIRONMENT_T_3
	#define	PID_PORT_MAP				   PID_PORT_MAP_T_3
	#define	PID_MACHINE_INFO			 PID_MACHINE_INFO_T_3
	#define	PID_USER_MACHINE_ENV	   PID_USER_MACHINE_ENV_T_3
	#define	PID_RANGER_CAMERA_BASE	 PID_RANGER_CAMERA_BASE_T_3
	#define	PID_RANGER_CAMERA			 PID_RANGER_CAMERA_T_3
	#define	PID_TERMINATION_INFO	   PID_TERMINATION_INFO_T_3
#endif // end if VER5

#define	PROJECT_ID_ELMA_100		(('E' << 24) | ('M'	<< 16) | ('1' << 8)	| '0')
#define	PROJECT_NAME_ELMA_100	"TVM_Applications"
#define	HCB_PROGRAM_REV			106
#define	SPB_PROGRAM_REV			105

/* Error type */
#define	ERROR_TYPE_CRITICAL			  0x0100
#define	ERROR_TYPE_WARNING			  0x0200
#define	ERROR_TYPE_MESSAGE			  0x0300
#define	ERROR_TYPE_DEBUG			    0x0400
#define	ERROR_TYPE_USER_NOTIFY		0x0500

/************************************************************************************/
/* Error Code																	                                    	*/
/************************************************************************************/
typedef	unsigned int TErrorCode;

#define	ERROR_CODE_NONE							          0x00000000

// 통신	에러 목록
#define	ERROR_CODE_CHECKSUM						        0x00000002
#define	ERROR_CODE_ALREADY_PACKET				      0x00000007
#define	ERROR_CODE_WRONG_SIZE					        0x00000008
// ProcessUnit 에러	목록
#define	ERROR_CODE_NOTMATCH						        0x00000083
// 그 외의 에러	목록
#define	ERROR_CODE_OVERFLOW						        0x00000106
#define	ERROR_CODE_FLASH_OPEN					        0x00000200
#define	ERROR_CODE_FLASH_READ					        0x00000201
#define	ERROR_CODE_FLASH_WRITE					      0x00000202
#define	ERROR_CODE_ENVIRONMENT_NOT_MATCH		  0x00000203
#define	ERROR_CODE_TIMER_OVERLAP				      0x00000204
// MCBSP error
#define	ERROR_CODE_MCBSP_WRONG_SIZE				    0x00000300
#define	ERROR_CODE_MCBSP_MULTIPLE_RESPONSE		0x00000301
#define	ERROR_CODE_MCBSP_TX_NOT_EMPTY			    0x00000302
#define	ERROR_CODE_MCBSP_TX_CANNOT_WRITE		  0x00000303
#define	ERROR_CODE_MCBSP_TRANSMIT_TIMEOUT		  0x00000304
#define	ERROR_CODE_MCBSP_BUFFER_OVERFLOW		  0x00000306
#define	ERROR_CODE_MCBSP_RETRY_COUNT_OVER		  0x00000307
// HPI error
#define	ERROR_CODE_HPI_CPB_INT_STATE			    0x00000400
#define	ERROR_CODE_HPI_READ_TIMEOUT				    0x00000401
#define	ERROR_CODE_HPI_RETRY_EXCEEDED			    0x00000402
#define	ERROR_CODE_HPI_RLI_TIMEOUT				    0x00000403
#define	ERROR_CODE_HPI_SI_TIMEOUT				      0x00000404
#define	ERROR_CODE_HPI_SLI_TIMEOUT				    0x00000405
#define	ERROR_CODE_HPI_RECEIVE					      0x00000406

// capture error
#define	ERROR_CODE_CAPTURE_TIMEOUT				    0x00000500
#define	ERROR_CODE_CAPTURE_UNWANTED_INT			  0x00000501
#define	ERROR_CODE_CAPTURE_JOB_FULL				    0x00000502
#define	ERROR_CODE_CAPTURE_DMA_TABLE_OVERFLOW	0x00000503
#define	ERROR_CODE_CAPTURE_OVERFLOW				    0x00000504

// cpb process error
#define	ERROR_CODE_CPB_BOARD_DOWN				      0x00000600
#define	ERROR_CODE_CPB_PROCESS_TIMEOUT			  0x00000601

#define	ERROR_CODE_PROCESS_RUNTIME				    0x00000700
#define	ERROR_CODE_PROCESS_WRONG_RESULT			  0x00000701

// usb error
#define	ERROR_CODE_USB_EP0_STALL				      0x00000800

// hcb
#define	ERROR_CODE_SERVO_NAK					        0x00100700
#define	ERROR_CODE_SERVO_ALRAM					      0x00100701
#define	ERROR_CODE_SERVO_COM_TIMEOUT			    0x00100702
#define	ERROR_CODE_SERVO_WRONG_CODE				    0x00100703

#define	ERROR_CODE_STEPMOTOR_BUSY				      0x00100800

// user	notify error
#define	ERROR_CODE_FEEDER_POS_NOT_READY			  0x00000001
#define	ERROR_CODE_FEEDER_NOT_STOP				    0x00000002
#define	ERROR_CODE_MACHINE_NOT_STOP				    0x00000003
#define	ERROR_CODE_MACHINE_NOT_READY			    0x00000004


/************************************************************************************/
/* StatusList 정의																	                                */
/************************************************************************************/
#define   MACHINE_STATE_INIT							  0
#define	MACHINE_STATE_STOP							  1
#define	MACHINE_STATE_RUN							     	  2
#define	MACHINE_STATE_CLEANING						  3
#define	MACHINE_STATE_ATTACHING						  4
#define	MACHINE_STATE_DETACHING						  5
#define	MACHINE_STATE_STARTING						  6
#define	MACHINE_STATE_STOPPING						  7
#define	MACHINE_STATE_WAIT_STOP						  8
#define	MACHINE_STATE_EMERGENCY_STOP				  9
#define   MACHINE_STATE_TERMINATE						  10

#define	MACHINE_SUSPEND_REASON_FEEDER_EMPTY			  0
#define	MACHINE_SUSPEND_REASON_FEEDER_TROUBLE		  1
#define	MACHINE_SUSPEND_REASON_DEFECT				      2
#define	MACHINE_SUSPEND_REASON_UNINSPECT			    3
#define	MACHINE_SUSPEND_REASON_TIMEOUT				    4
#define	MACHINE_SUSPEND_REASON_TABLET_DISAPPEAR		5
#define	MACHINE_SUSPEND_REASON_REGULATOR			    6
#define	MACHINE_SUSPEND_REASON_BLOWER_OL			    7
#define	MACHINE_SUSPEND_REASON_VD1_STALL			    8
#define	MACHINE_SUSPEND_REASON_VD2_STALL			    9
#define	MACHINE_SUSPEND_REASON_GP_COUNT_REACHED		10
#define	MACHINE_SUSPEND_REASON_BRIGHTNESS_DOWN		11
#define	MACHINE_SUSPEND_REASON_DOOR_OPEN			    12
#define	MACHINE_SUSPEND_REASON_DP_COUNT_REACHED		13
#define	MACHINE_SUSPEND_REASON_UP_COUNT_REACHED		14
#define	MACHINE_SUSPEND_REASON_VISION_SENSOR_1		15
#define	MACHINE_SUSPEND_REASON_VISION_SENSOR_2		16
#define	MACHINE_SUSPEND_REASON_TIME_OVER			    17
#define MACHINE_SUSPEND_REASON_VB_SENSOR_EMPTY		18 

#define	MACHINE_EMERGENCY_REASON_USER_SWITCH		  0
#define	MACHINE_EMERGENCY_REASON_REGULATOR_LOW		1
#define	MACHINE_EMERGENCY_REASON_RINGBLOWER			  2

#define	CPB_PROCESSING_READY			0
#define	CPB_PROCESSING_SENDDATA		1
#define	CPB_PROCESSING_READDATA		2
#define	CPB_PROCESSING_RUNNING		3
#define	CPB_PROCESSING_FINISHED		4
#define	CPB_PROCESSING_ERROR			0xFF

//************************************************************************************/
// Etc                                                                               */
//************************************************************************************/
#define	CAPTURE_MODE_NONE					    0x000
#define	CAPTURE_MODE_DEFAULT				  0x001
#define	CAPTURE_MODE_FRAME					  0x002
//#define CAPTURE_MODE_PROCESSING			0x004
#define	CAPTURE_MODE_CONTINUOUS				0x010
#define	CAPTURE_MODE_PARTIAL				  0x020
#define	CAPTURE_MODE_MACHINE_CAPTURE	0x100

#define	CAPTURE_TYPE_NONE				      0
#define	CAPTURE_TYPE_SINGLE_CAPTURE		1
#define	CAPTURE_TYPE_FULL_CAPTURE		  2
#define	CAPTURE_TYPE_PROCESSING			  3

#define	CAPTURE_KIND_FRAME				    0
#define	CAPTURE_KIND_LINE				      1

#define	HCB_SPB_COMPATIBILITY_SPB04		0
#define	HCB_SPB_COMPATIBILITY_SPB06		1

#define	SPB_BOARD_KIND_SPB04			0
#define	SPB_BOARD_KIND_SPB06			1

#define	CPB_CPU_CLOCK_KIND_900						0
#define	CPB_CPU_CLOCK_KIND_1100						1

#define	SPB_IMAGE_TRANSFER_METHOD_CHECKSUM			0
#define	SPB_IMAGE_TRANSFER_METHOD_NO_CHECKSUM		1

#define	CAMERA_KIND_CIS							          0
#define	CAMERA_KIND_RANGER_3D					        1
#define CAMERA_KIND_NFA_2D				            2
#define	CAMERA_KIND_NFA_3D				            3
#define	CAMERA_KIND_NONE						0xFF
		
#define	CAMERA_DISCONNECTION				    0
#define	CAMERA_CONNECTION				        1

#define	CAMERA_POSITION_FRONT_FACE				    0
#define	CAMERA_POSITION_FRONT_FACE_BACKLIGHT	1
#define	CAMERA_POSITION_SIDE_FACE_M45			    2
#define	CAMERA_POSITION_SIDE_FACE_0				    3
#define	CAMERA_POSITION_SIDE_FACE_P45			    4
#define	CAMERA_POSITION_3D						        5
#define	CAMERA_POSITION_DISCONNECT				    6

#define	CPB_STATUS_DISABLED			0
#define	CPB_STATUS_BOOT_READY		1
#define	CPB_STATUS_BOOTING			2
#define	CPB_STATUS_IDLE				  3
#define	CPB_STATUS_PROCESSING		4

#define	MAX_SERVO_MOTOR_COUNT		5

#define	SD1_MOTOR_INDEX			0
#define	SD2_MOTOR_INDEX			1
#define	BF_ID_MOTOR_INDEX			2
#define	BF_OD_IN_MOTOR_INDEX			3
#define	BF_OD_OUT_MOTOR_INDEX			4

#define	MAX_STEP_MOTOR_COUNT			5

#define	BF_UP_DOWN_MOTOR_INDEX			0
#define	BF_IN_OUT_MOTOR_INDEX			  1
#define	VG1_UP_DOWN_MOTOR_INDEX			2
#define	VG2_UP_DOWN_MOTOR_INDEX			3
#define	SD2_LEFT_RIGHT_MOTOR_INDEX	4

#define	NC_POS_PARAM_1_MUL					(2000)
#define	NC_POS_PARAM_2_MUL					(2000)
#define	NC_POS_PARAM_3_MUL					(2000)
#define	NC_POS_PARAM_4_MUL					(2000)
#define	NC_POS_PARAM_5_MUL					(2000)

#define	NC_POS_PARAM_1_DIV					(-4)
#define	NC_POS_PARAM_2_DIV					(-3)
#define	NC_POS_PARAM_3_DIV					(2)
#define	NC_POS_PARAM_4_DIV					(2)
#define	NC_POS_PARAM_5_DIV					(3)

#define	MACHINE_LAMP_KIND_DISCONNECTED					  0
#define	MACHINE_LAMP_KIND_NORMAL_TABLET					  1
#define	MACHINE_LAMP_KIND_SUGAR_COATED_TABLET			2
#define	MACHINE_LAMP_KIND_NORMAL_CAPSULE				  3

#define	MAX_SPEED_TRAINING_MODE_MANUAL		0
#define	MAX_SPEED_TRAINING_MODE_AUTO		  1

#define	MACHINE_MODE_TEST			    0
#define	MACHINE_MODE_FREE			    1
#define	MACHINE_MODE_INTERLOCK		2
#define	MACHINE_MODE_PROTECTED		3

#define	PC_POWER_MODE_MANUAL	0
#define	PC_POWER_MODE_AUTO		1

#define	MAX_OP_TEST_COUNT				16

#define	TC_TABLE_CAPACITY		256		// 통신	interval, 초당 최대	인식 수와 연관지어 결정한다.

#define	SYSTEM_MAX_THERMOMETER_COUNT			  3
#define	SYSTEM_MAX_PRESSURE_METER_COUNT			3
#define	SYSTEM_MAX_INVERTER_COUNT				    3

#define	RS485_UNIT_COUNT				9//8

#define	HCB_TABLET_LIST_COUNT			  512		// must	be power of	2
#define	HCB_TABLET_LIST_MASK			0x1FF		// HCB_TABLET_LIST_COUNT - 1
#define	MIN_TABLET_INTERVAL				15

#define	SENSOR_STATE_NOT_PASSED			0
#define	SENSOR_STATE_PASSED				  1

#define	TABLET_STATE_READY							0
#define	TABLET_STATE_SENSOR_1_PASSED			       	1
#define	TABLET_STATE_LASER_TRIG_1_TRANSFERRED	  	2
#define	TABLET_STATE_CAPTURE_INT_1_TRANSFERRED	  	3
#define   TABLET_STATE_ILLUMINATOR_1_TRANSFERRED		4
#define	TABLET_STATE_CAPTURE_1_COMPLETE			      	5
#define	TABLET_STATE_SENSOR_2_PASSED			        	6
#define	TABLET_STATE_LASER_TRIG_2_TRANSFERRED	  	7
#define	TABLET_STATE_CAPTURE_INT_2_TRANSFERRED	  	8
#define   TABLET_STATE_ILLUMINATOR_2_TRANSFERRED		9
#define	TABLET_STATE_RESULT_WAITING				      	10
#define	TABLET_STATE_BLOW_WAITING				      	11
#define	TABLET_STATE_NC_WAITING					      	12
#define	TABLET_STATE_COMPLETE					            	13
#define	TABLET_STATE_ERROR						      	0xFF

#define LASER_STATE_NONE								0	
#define LASER_STATE_READ_ENCODER						1
#define LASER_STATE_TRIGGER_LASER						2

#define	TABLET_RESULT_NONE									              0
#define	TABLET_RESULT_GOOD									              1
#define	TABLET_RESULT_DEFECT								              2
#define	TABLET_RESULT_DEFECT_UNPRINT						          3
#define	TABLET_RESULT_DEFECT_SPB_PROCESSING_NOT_COMPLETE	4
#define	TABLET_RESULT_UNINS_SPB_TIMEOUT						        5
#define	TABLET_RESULT_UNINS_SPB_PROCESSING_NOT_COMPLETE		6
//#define TABLET_RESULT_UNINS_FROM_SPB						        7
#define	TABLET_RESULT_INSERTED								            8
#define	TABLET_RESULT_DISAPPEARED							            9
//#define TABLET_RESULT_SMALL_SIZE							          10
#define	TABLET_RESULT_CLOSED_UNINS									              11
#define	TABLET_RESULT_CLOSED_DEFECT								              12
//#define TABLET_RESULT_MISTAKEN							            13
#define	TABLET_RESULT_SENSOR_1_MISFEEDING					        13
#define	TABLET_RESULT_SENSOR_2_MISFEEDING					        14
#define	TABLET_RESULT_MULTI_TABLET_SENSOR_1					      15
#define	TABLET_RESULT_MULTI_TABLET_SENSOR_2					      16
#define	TABLET_RESULT_UNINTENDED_UNINSPECT					      17
#define	TABLET_RESULT_DEFECT_FR_MISMATCH					        18

#define	TABLET_RESULT_SPB_MASK								0x1000		// 4096

#define	IMAGE_STATE_EMPTY			    0
#define	IMAGE_STATE_ON_CAPTURE		1
#define	IMAGE_STATE_CAPTURED		  2
#define	IMAGE_STATE_PROCESSING		3
#define	IMAGE_STATE_DEFECT			  4
#define	IMAGE_STATE_UPLOADING		  5

#define	IMAGE_RESULT_NONE			    0
#define	IMAGE_RESULT_GOOD			    1
#define	IMAGE_RESULT_DEFECT			  2

#define	TABLET_EJECTION_NONE			  0
#define	TABLET_EJECTION_UNINSPECT		1
#define	TABLET_EJECTION_DEFECT			2
#define	TABLET_EJECTION_GOOD			3

#define	TABLET_EJECTION_CHECK_NONE		0
#define	TABLET_EJECTION_CHECK_EMPTY		1
#define	TABLET_EJECTION_CHECK_EXIST		2

#define	RESULT_TABLE_SIZE				512
#define	RESULT_TABLE_MASK				0x1FF

#define	SPB_TABLET_STATE_NONE						0
#define	SPB_TABLET_STATE_FINDING_BUFFER				1
#define	SPB_TABLET_STATE_NUMBERING					2
#define	SPB_TABLET_STATE_CAPTURE_READY				3
#define	SPB_TABLET_STATE_ON_CAPTURE					4
#define	SPB_TABLET_STATE_CAPTURED					5
#define SPB_TABLET_STATE_GET_POSITION				6
#define	SPB_TABLET_STATE_PROCESSING					7
#define	SPB_TABLET_STATE_PROCESSING_COMPLETE		8
#define	SPB_TABLET_STATE_ERROR						0xFF

#define	SPB_TABLET_RESULT_NONE								              0
#define	SPB_TABLET_RESULT_PROCESSING						            1
#define	SPB_TABLET_RESULT_GOOD								              2
#define	SPB_TABLET_RESULT_DEFECT							              3
#define	SPB_TABLET_RESULT_UNINS_IMAGE_BUFFER_FULL			      4
#define	SPB_TABLET_RESULT_UNINS_TABLET_NUMBER_UNDEFINED		  5
#define	SPB_TABLET_RESULT_UNINS_WRONG_TABLET_NUMBER			    6
#define	SPB_TABLET_RESULT_UNINS_CAPTURE_TIMEOUT				      7
#define	SPB_TABLET_RESULT_UNINS_CAPTURE_NOT_READY			      8
#define	SPB_TABLET_RESULT_UNINS_PROCESSING_TIMEOUT			    9
#define	SPB_TABLET_RESULT_UNINS_PROCESSING_ERROR			      10
#define	SPB_TABLET_RESULT_UNINS_CPB_FULL					          11
#define	SPB_TABLET_RESULT_UNINS_CLOSED_TABLET				        12
#define	SPB_TABLET_RESULT_UNINS_TABLET_POSITION				      13
#define	SPB_TABLET_RESULT_UNINS_BRIGHTNESS_DROPPED			    14
#define	SPB_TABLET_RESULT_UNINS_BRIGHTNESS_CHASE			      15
#define	SPB_TABLET_RESULT_PROCESSING_MASK					          0x0F
#define	SPB_TABLET_RESULT_PRINT_IS_MASK						          0x10
#define	SPB_TABLET_RESULT_PRINT_TYPE_MASK					          0x80
#define	SPB_TABLET_RESULT_FRONT_FACE_MASK					          0x20
//#define SPB_TABLET_RESULT_PRINT_MASK						          0x70
//#define SPB_TABLET_RESULT_PRINT_IS_CAM1					          0x10
//#define SPB_TABLET_RESULT_PRINT_IS_CAM2					          0x20
//#define SPB_TABLET_RESULT_PRINT_IS_CAM3					          0x40
#define	SPB_TABLET_RESULT_THICKERROR_MASK					          0x40

#define	SPB_TABLET_RESULT_PRINT_IS_SHIFT					    4
#define	SPB_TABLET_RESULT_PRINT_TYPE_SHIFT					  7
#define	SPB_TABLET_RESULT_FRONT_FACE_SHIFT					  5
#define	SPB_TABLET_RESULT_PRINT_THICKERROR_SHIFT			6

#define	TABLET_INSPECTION_STATE_NONE						      0
#define	TABLET_INSPECTION_STATE_CAPTURE_WAITING				1
#define	TABLET_INSPECTION_STATE_ON_CAPTURE					  2
#define	TABLET_INSPECTION_STATE_CAPTURED					    3
#define	TABLET_INSPECTION_STATE_PROCESSING_READY			4
#define	TABLET_INSPECTION_STATE_POSITION_READY				5
#define	TABLET_INSPECTION_STATE_POSITION_PROCESSING			6
#define	TABLET_INSPECTION_STATE_POSITION_PROCESSING_COMPLETE			7
#define	TABLET_INSPECTION_STATE_PROCESSING					  8
#define	TABLET_INSPECTION_STATE_PROCESSING_COMPLETE		9
#define	TABLET_INSPECTION_STATE_PASSED						    10
#define	TABLET_INSPECTION_STATE_CAPTURE_ERROR				  11
#define	TABLET_INSPECTION_STATE_PROCESSING_ERROR			12
#define	TABLET_INSPECTION_STATE_POSITION_PROCESSING_ERROR	13


#define	TABLET_PROCESSING_RESULT_UNKNOWN					          0
#define	TABLET_PROCESSING_RESULT_GOOD						            1
#define	TABLET_PROCESSING_RESULT_DEFECT						          2
#define	TABLET_PROCESSING_RESULT_ERROR						          3
#define	TABLET_PROCESSING_RESULT_CPB_FULL					          4
#define	TABLET_PROCESSING_RESULT_CLOSED_TABLET				      5
#define	TABLET_PROCESSING_RESULT_UNINS_TABLET_POSITION		  6
#define	TABLET_PROCESSING_RESULT_UNINS_BRIGHTNESS_DROPPED	  7
#define	TABLET_PROCESSING_RESULT_UNINS_BRIGHTNESS_CHASE		  8
#define	TABLET_PROCESSING_RESULT_THIN_TABLET				        9
#define	TABLET_PROCESSING_RESULT_FAT_TABLET					        10

#define	SPB_TABLET_LIST_COUNT			  512
#define	SPB_TABLET_LIST_MASK			0x1FF

#define	RANGER_CAMERA_COMMAND_RESULT_NONE			      0
#define	RANGER_CAMERA_COMMAND_RESULT_OK				      1
#define	RANGER_CAMERA_COMMAND_RESULT_COM_TIMEOUT	  2
#define	RANGER_CAMERA_COMMAND_RESULT_COM_ERROR		  3

#define	TABLET_PROCESSING_MODE_NONE				          0
#define	TABLET_PROCESSING_MODE_CALIBRATION		      1
#define	TABLET_PROCESSING_MODE_STUDY			          2
#define	TABLET_PROCESSING_MODE_INSPECTION		        3

#define	MAX_TABLET_NUMBER			1000000000

#define	SPB_PROCESSING_RESULT_COUNT		8

#define	SPB_SETUP_MODE_STUDY				        0
#define	SPB_SETUP_MODE_INSPECTION			      1
#define	SPB_SETUP_MODE_GRADE_CHANGE			    2

#define	PROCESSING_SETUP_KIND_NONE			    0
#define	PROCESSING_SETUP_KIND_STUDY			    1
#define	PROCESSING_SETUP_KIND_INSPECTION	  2
#define	PROCESSING_SETUP_KIND_GRADE_CHANGE	3

#define	PROCESSING_SETUP_STEP_NONE			    0
#define	PROCESSING_SETUP_STEP_READY			    1
#define	PROCESSING_SETUP_STEP_WAITING		    2
#define	PROCESSING_SETUP_STEP_INIT			    3
#define	PROCESSING_SETUP_STEP_SETUP			    4
#define	PROCESSING_SETUP_STEP_COM_WAITING	  5
#define	PROCESSING_SETUP_STEP_CLEAR			    6
#define	PROCESSING_SETUP_STEP_COMPLETE		  7

#define	PROCESSING_SETUP_CPB_STEP_NONE		  0
#define	PROCESSING_SETUP_CPB_STEP_READY		  1
#define	PROCESSING_SETUP_CPB_STEP_COMPLETE	2
#define	PROCESSING_SETUP_CPB_STEP_FAIL		  3
#define	PROCESSING_SETUP_CPB_STEP_INVALID	  4

#define	VFINFO_LIST_COUNT		32
#define	VFINFO_LIST_MASK		31

#define	CPB_PROCESSING_TIME_LIST_COUNT		32

#define	CPB_REV_003							3
#define	CPB_REV_004							4

#define THREED_CAPTURE_DEFAULT_MODE           0
#define THREED_CAPTURE_RT_TRIGGER_MODE        1

#define UVLASER_STATU_NONE						0
#define UVLASER_STATU_READY					1
#define UVLASER_STATU_ACTIVE					2			
#define UVLASER_STATU_EMR						3
#define UVLASER_STATU_APPACTIVE				4


typedef	struct
{
	unsigned char CPBRevInfo[SYSTEM_MAX_SPB_CLIENT_BOARD_COUNT];
} TSPBSystemInfo;

#define	IDLE_PROCESS_LIST_COUNT		512
#define	IDLE_PROCESS_LIST_MASK		0x1FF

#define	ERROR_VALUE_MAX_SIZE			3			/* integer	 3			*/

////// For SELMA200, Add by moon. (20180208)
//Module1
#define SD1_2D_FRONT_FACE_CAMERA_INDEX            1
#define SD1_2D_SIDE_FACE_P45_CAMERA_INDEX         2
#define SD1_2D_SIDE_FACE_00_CAMERA_INDEX          3
#define SD1_2D_SIDE_FACE_M45_CAMERA_INDEX         4
#define SD1_3D_FRONT_FACE_CAMERA_INDEX            5
#define SD1_2D_OTHER_SIDE_FACE_P45_CAMERA_INDEX   6
#define SD1_2D_OTHER_SIDE_FACE_00_CAMERA_INDEX    7
#define SD1_2D_OTHER_SIDE_FACE_M45_CAMERA_INDEX   8
//Module2
#define SD2_2D_FRONT_FACE_CAMERA_INDEX            9
#define SD2_2D_SIDE_FACE_P45_CAMERA_INDEX         10
#define SD2_2D_SIDE_FACE_00_CAMERA_INDEX          11
#define SD2_2D_SIDE_FACE_M45_CAMERA_INDEX         12
#define SD2_3D_FRONT_FACE_CAMERA_INDEX            13
#define SD2_2D_OTHER_SIDE_FACE_P45_CAMERA_INDEX   14
#define SD2_2D_OTHER_SIDE_FACE_00_CAMERA_INDEX    15
#define SD2_2D_OTHER_SIDE_FACE_M45_CAMERA_INDEX   16
////// end

#define HALF_INSPECTION_CAMERA_INDEX  9 // Module 구분 용도로 사용
#define HALF_CAPTURE_INDEX            3 // Module 구분 용도로 사용

//---------------------------------------------------------------------------
// For SELMA200, 20180221, Add by moon.
// SPB Version 및 카메라 모델에 따라 3D 카메라가 연결되는 SPB 번호가 변경된다.
// 추후 시스템에서 설정하는 방식으로 변경될 수 있으나 현재(20180221)에는 고정값을 삽입한다.
// 0, 1, 2, 3

// SELMA100 -> NFA 카메라 적용, SPB06 R3.0 적용
//#define FST_3D_CAMERA_SPB_INDEX 0
//#define SEC_3D_CAMERA_SPB_INDEX 1

// SELMA200 -> NFA 카메라 적용, SPB06 R3.0 적용
#define FST_3D_CAMERA_SPB_INDEX 1
#define SEC_3D_CAMERA_SPB_INDEX 3

// SELMA200 -> NFA 카메라 적용, SPB07
//#define FST_3D_CAMERA_SPB_INDEX 0
//#define SEC_3D_CAMERA_SPB_INDEX 1
// end

typedef	struct
{
	unsigned int ProjectID;
	unsigned int ProgramRev;	// demands on program source code
	unsigned int reserved1[2];
	char ProjectName[16];
	char reserved2[32];
} THCBProgramHeader;		// common 64 bytes low-level header

typedef	struct
{
	unsigned int DataRev;	// demands on data structure
	unsigned int reserved1[3];
	char reserved2[16];
} THCBDBHeader;		// common 32 bytes low-level header

typedef	struct
{
	char MachineName[16];
} THCBMachineSpecificHeader;

typedef	struct
{
	unsigned int ProjectID;
	unsigned int ProgramRev;	// demands on program source code
	unsigned int reserved1[2];
	char ProjectName[16];
	char reserved2[32];
} TSPBProgramHeader;		// common 64 bytes low-level header

typedef	struct
{
	unsigned int DataRev;	// demands on data structure
	unsigned int reserved1[3];
	char reserved2[16];
} TSPBDBHeader;		// common 32 bytes low-level header

typedef	struct
{
	unsigned char VersionL;
	unsigned char VersionH;
	unsigned char reserved[2];
} TSPBFPGAVersion;

typedef	struct
{
	unsigned short Program;
	unsigned short Rivision;
	unsigned short Borad;
	unsigned short Checksum;
} THCBFPGAVersion;

typedef	struct
{
	unsigned int BREnabled;
	unsigned int ProgramID;
	unsigned int Reserved[2];
} TBootRecord;

typedef	struct
{
	unsigned int MajorVersion;
	unsigned int MinorVersion;
	unsigned int Date;
	unsigned int Type;
} TProgramVersion;

typedef	struct
{
	unsigned char SPBCompatibility;
	unsigned char reserved[3];
} THCBCompatibility;

typedef	struct
{
	unsigned char TargetSPBBoardKind;
	unsigned char reserved[3];
	unsigned int CPBAlgMajorVersion;
	unsigned int CPBAlgMinorVersion;
  unsigned int CPBAlgTargetSystem;
  unsigned int CPBAlgReleaseDate;
} TSPBCompatibility;

typedef	struct
{
	unsigned int AlgMajorVersion;
	unsigned int AlgMinorVersion;
  unsigned int AlgTargetSystem;
  unsigned int AlgReleaseDate;
} TCPBCompatibility;

typedef	struct
{
	unsigned char SPBIndex;
	unsigned char CamIndex;
	unsigned short CameraInspectPosition;
} TCameraMapInfo;

typedef	struct
{
	int	DefaultCPBProgramID;
	unsigned char CPBEnabled[SYSTEM_CPB_MAX_COUNT];
	unsigned char CPBSDRSizeType[SYSTEM_CPB_MAX_COUNT];
	int	CameraDistributionIndex[SYSTEM_CPB_MAX_COUNT];
	unsigned char CameraHardwarePosition[SYSTEM_SPB_CAMERA_MAX_COUNT];
	unsigned char InspectPosition[SYSTEM_SPB_CAMERA_MAX_COUNT];
	unsigned short GlobalCameraIndex[SYSTEM_SPB_CAMERA_MAX_COUNT];
	unsigned char CameraKind[SYSTEM_SPB_CAMERA_MAX_COUNT];
	unsigned char CamMask;
	unsigned char reserved1[3];
	unsigned char CPBClockKind[SYSTEM_CPB_MAX_COUNT];
	TCameraMapInfo CameraMapInfo[SYSTEM_TOTAL_CAMERA_COUNT];		// save	camera map to every	spb	just for data matching
	unsigned char ImageTransferMethod;
	unsigned char CPBVersion;
	unsigned char MaxProcessingCoreCount;
	unsigned char reserved2[1];
	// khd1994 - TCP서버의 주소 및 통신포트번호
	unsigned short nTcpPort;
	char     szIpAddr[32];
	char    ThreeDCaptureMethod;
	int Laser_complexer_Enable;
	int CamBootEnabled;
	float LaserPositionCalData[4];
} TSPBSystemSetupData;

typedef	struct
{
	unsigned char IsAutoScanMode;
	unsigned char Gain;
	unsigned char ThresholdCount;
	unsigned char OutputSelect;
	unsigned char Median;
	unsigned char Morphology;
	unsigned char MorphologySize;
	unsigned char reserved1[1];
	unsigned short ExposureTime2D;
	unsigned short ExposureTime3D;
	unsigned short LineScanTime;
	unsigned short StartCol;
	unsigned short ColCount;
	unsigned short StartRow;
	unsigned short RowCount;
	unsigned short Threshold1;
	unsigned short Threshold2;
	unsigned short reserved2[1];
} TRanger3DCameraInfo; // 20180208 For SELMA200, 예정

typedef	struct
{
	int	SDRSizeType;
	int	SuctionDiskNumber;
  int bCameraConnection;
  int InspectionType;
  int spbBoardID;
}
TCPBSystemSetupData;

typedef	struct
{
	unsigned char Enabled;
	unsigned char IsDown;
	unsigned char Status;
	unsigned char reserved;
} TCPBStatus;

typedef	struct
{
	char WarningExist;
	char VBFeederEmpty;
	char DefectBinFull;
	char UnInsBinFull;
	char RegulatorWarning;
	char FrontDoorOpen;
	char LeftDoorOpen;
	char RightDoorOpen;
	char BowlFeederSensorDisconnected;
	char SuctionDisk1LampDisconnected;
	char SuctionDisk2LampDisconnected;
	char dummy[5];
} TMachineWarningState;

typedef	struct
{
	char AlarmExist;
	char RegulatorError;
	char EmergencyOn;
	char Inverter1Trip;
	char Inverter2Trip;
	char Inverter3Trip;
	char Disk1SuctionLow;
	char Disk2SuctionLow;
	char ServoAlarm;
	char Interlock;
	char Disk1Stall;
	char Disk2Stall;
	char GPFull;
	char DPFull;
	char UPFull;
	char DPRatioOver;
	char UPRatioOver;
	char CritUPRatioOver;
	char CritDPRatioOver;
	char Sensor1Error;
	char Sensor2Error;
	char BrightnessDown;
	char StepMotorStall[MAX_STEP_MOTOR_COUNT];
  char EmissionSensorOn;
	char CheckMisEjector;
  char MisEjectFull;
	char TotalFull;
	char mes_status;
	char Qjp_object_status;
	char upstream_status;
	char downstream_status;
	char laser_emergency;
	char TemperatureOver[SYSTEM_MAX_THERMOMETER_COUNT];
  char CheckDistributor;
} TMachineAlarmState;

typedef	struct
{
	char AlarmExist;
	char GPFull;
	char DPFull;
	char UPFull;
	char DPRatioOver;
	char UPRatioOver;
	char CritUPRatioOver;
	char CritDPRatioOver;
	char Sensor1Error;
	char Sensor2Error;
	char BrightnessDown;
	char Timeout;
	char MisEjectCheck;
	char MisEjecMultiAction;
	char TotalFull;
	char DistributorDown;
} TInspectionAlarmState;

typedef	struct
{
	int	BaseSpeed;
	int	AccTime;
	int	DecTime;
	int	Dir;
} TServoMotorData;

typedef	struct
{
	int	Activated;
	int	SensingTime;
	int	Ejector1Delay;
	int	Ejector1RunTime;
	int	Ejector2Delay;
	int	Ejector2RunTime;
	int	GuideInTime;
	int	GuideOutTime;
} TRecoveryInfo1;

typedef	struct
{
	int	Activated;
	int	SensingTime;
	int	Ejector1Delay;
	int	Ejector1RunTime;
	int	Ejector2Delay;
	int	Ejector2RunTime;
	int	FeederStopTime;
	int	ReverseMoveAccTime;
	int	ReverseMoveSpeed;
	int	ReverseMoveRunTime;
} TRecoveryInfo2;

typedef	struct
{
	int	Activated;
	int	SensingTime;
	int	FeederStopTime;
	int	ForceMoveAccTime;
	int	ForceMoveSpeed;
	int	ForceMoveRunTime;
} TRecoveryInfo3;

typedef	struct
{
	int	CaptureDelay[SYSTEM_MACHINE_CAPTURE_COUNT];
	int	IlluminatorMask[SYSTEM_MACHINE_CAPTURE_COUNT];
	int	IlluminatorDelay[SYSTEM_MACHINE_CAPTURE_COUNT];
	int	IlluminatorTime[SYSTEM_MACHINE_CAPTURE_COUNT];
	int	CamMask[SYSTEM_MACHINE_CAPTURE_COUNT];
	int	SensorSPBMask[2];
} TMachineCaptureInfo;

typedef	struct
{
	int	DefectEjectorDelay;
	int   DefectEjectorLength;
	int	UnInsEjectorDelay;
	int   UnInsEjectorLength;
	int	GoodEjectorDelay;
	int   GoodEjectorLength;	
	int	MisejectActive;
	int	MisejectActiveDelay;
	int	Special_InspectionActive;
	int	Blowinterval;
	int	Blowstart;
	int	Blowlength;
	int	UninsBlowCheck;
	int EjectorWindStrength;
	int EjectorDefaultMode;
	int	SpModeGoodTabletCollectCount1; // SELMA 200 Special Mode 양품 수거갯수 , 이 값을 기준으로 노즐에서 바람부는 위치가 바뀐다.
	int	SpModeGoodTabletCollectCount2;    
	int DistributorGoodTabletCount1;   //한국콜마 용 3분배기
	int DistributorGoodTabletCount2;
	int DistributorGoodTabletCount3;
	int TPB_MisejectActive;
	int TPB_MisejectOpenDelay;
	int TPB_MisejectOpenRunTime;
	int TPB_MisCmdValidCnt;
	int IgnoreMultiMisejectAction;
	int TPB_MisejectOperationMode;
} TEjectorInfo;

typedef struct
{
	int Machine_type;
	int Laser_deley_time;
	int Laser_complexer_Enable;
	int Laser_Trig_mode;
} TLasercomplexerInfo;

typedef	struct
{
	int	EmptySensorActiveRatio;
	int	FullSensorActiveRatio;
	int	StartSpeed;
	int	MaxSpeedTrainingMode;

	int	ManualMaxSpeed;
	int	ManualModeSensorIndex;
	int	ManualModeSensorActiveRatio;
	int	ManualLimitSpeed;
	int	ManualModeLimitSensorIndex;
	int	ManualModeLimitSensorActiveRatio;
	int	MechanicalMinSpeed;
	int	MechanicalMaxSpeed;

  int FeederEmptyAlarmDelayTime;
} TVibrationFeederInfo;

typedef	struct
{
	int	DoorInterlockEnabled;
	int	NCInterlockAValue;
  int ACdomesticMode; 
} TInterlockInfo;

typedef	struct
{
	unsigned short BuzzerContinuousOn;
	unsigned short BuzzerOnTime;
} TBuzzerInfo;

typedef	struct
{
	int	EyeProtectionModeEnabled;
	int	LEDOnTime;
	int	LEDOffDelay;
} TLEDInfo;

typedef	struct
{
	int	PressureAlarmLevel;
	int	VacuumAlarmLevel1;
	int	VacuumAlarmLevel2;
	int	TemperatureAlarmLevel1;
	int	TemperatureAlarmLevel2;
	int	TemperatureAlarmLevel3;
	int	reserved[2];
} TAlarmSetupInfo;

typedef struct
{
	int OutSigOnFlag;
	int OutSigStartDelayFlag;	
	int OutSigStartDelayTime;
	int OutSigDelayTime;
	int OutSigOnTime;	
	int OutSigOnTimeLength;	
	int OutSigState;
	int InSigOffTimeLength;	
	int InSigOffTime;
	int InSigOffFlag;
	int WaitChangeBarrelTime;
}TDistributorCtrl;

typedef struct
{
	int DisStep;
}TDistributorMonitor;

typedef struct
{
	int Disk1current_Encoder_value_L;
	int Disk1current_Encoder_value_H;
	int Disk2current_Encoder_value_L;
	int Disk2current_Encoder_value_H;
}TEncoderMonitor;

/* ini Read Write
   HCB DATA ALIGN 8
   사이즈 8배수 맞춰서 작업*/
typedef	struct
{
	int	MachineDataVersion;
	int	MachineMode;
	int	PC_Power_Mode;
	TMachineCaptureInfo	MachineCaptureInfo;
	TEjectorInfo EjectorInfo;
	TVibrationFeederInfo VFInfo;
	unsigned int SensorIntervalA;
	unsigned int SensorIntervalB;
	TInterlockInfo InterlockInfo;
	TBuzzerInfo	BuzzerInfo;
	TLEDInfo LEDControlInfo;
	double ZeroPositionValue[MAX_STEP_MOTOR_COUNT];
	TServoMotorData	ServoMotorData[MAX_SERVO_MOTOR_COUNT];
	TAlarmSetupInfo	AlarmSetupInfo;
	TLasercomplexerInfo LasercomplexerInfo;
  unsigned int HopperEmptyEnable;
  int SuctionDiskGearRatio;
  unsigned int reserved[9];
// khd1994 - HCB TCP서버의 주소 및 통신포트번호
  unsigned short nHCB_TcpPort;
  char     szHCB_IpAddr[32];
  int     CompanyID;
  int    BowlFeederSensorOption;
  int SafetyCircuitMode;
  int DiskStartDelay;
  int Qualis_Machine1_CutomOption;
  int SimpleSpeedControlOption;
  unsigned int IPB_BoardCount;
  int MachineType;
  int AutoDemper;
  TDistributorCtrl DistributorCtrl;
  int InverterType;
} TMachineSetupData;

typedef	struct
{
	int	Enabled;
	int	DustBlower1Interval;
	int	DustBlower2Interval;
	int	DustBlower3Interval;
	int	DustBlower4Interval;
	int	DustBlower5Interval;
	int	DustBlower1Delay;
	int	DustBlower2Delay;
	int	DustBlower3Delay;
	int	DustBlower4Delay;
	int	DustBlower5Delay;
	int	DustBlower1BlowTime;
	int	DustBlower2BlowTime;
	int	DustBlower3BlowTime;
	int	DustBlower4BlowTime;
	int	DustBlower5BlowTime;
} TUserMachineEnv;

typedef	struct
{
	int	IlluminatorMask[SYSTEM_MACHINE_CAPTURE_COUNT];
	float TabletLength;
	int	SuctionDiskSpeed;
	int	StudiedTabletSensorLength;
	int 	TabletSideThick;
  int CaptureOption;
} TMachineCaptureSetupData;

typedef	struct
{
	int	CountingMode;
	unsigned int Counter;
	unsigned int SubCounter[2];
	unsigned int ElapsedTime;
	float CPS;
	int	CPM;
	int	IndexTable[TC_TABLE_CAPACITY];
	int	OffInterval[TC_TABLE_CAPACITY];
	int	OnInterval[TC_TABLE_CAPACITY];
	int	CurrentTableIndex;
} TTabletCounter;

typedef	struct
{
	unsigned int Counter;
	unsigned int ElapsedTime;
	unsigned int LastCheckingTime;
	unsigned int ElapsedTimeInterval;
	unsigned int IntervalCounter;
	int	CPM;
} TSimpleTabletCounter;

typedef	struct
{
	int	TestCount;
	unsigned char OPList[MAX_OP_TEST_COUNT];
	unsigned char IsPhysicalPort[MAX_OP_TEST_COUNT];
	int	DelayIntervalList[MAX_OP_TEST_COUNT];
	int	OnIntervalList[MAX_OP_TEST_COUNT];
	int	OffIntervalList[MAX_OP_TEST_COUNT];
} TOPTestData;

typedef	struct
{
	short TemperatureData[SYSTEM_MAX_THERMOMETER_COUNT];
	short HumidityData[SYSTEM_MAX_THERMOMETER_COUNT];
	short Pressure[SYSTEM_MAX_PRESSURE_METER_COUNT];
	short DotPos[SYSTEM_MAX_PRESSURE_METER_COUNT];
	short InverterRPM[SYSTEM_MAX_INVERTER_COUNT];
} TMonitoringInfo;

typedef	struct
{
	unsigned int WrongAddressCount[RS485_UNIT_COUNT];
	unsigned int CRCErrorCount[RS485_UNIT_COUNT];
	unsigned int SizeErrorCount[RS485_UNIT_COUNT];
	unsigned int ReceiveTOCount[RS485_UNIT_COUNT];
	unsigned int TXCount[RS485_UNIT_COUNT];
} TRS485DebugInfo;

typedef	struct
{
	int	TabletNumber;
	int	InspectionResult;
	int	State;
	int Sensor1Time;
	int CaptureIntTime;
	int CaptureIntEncoder;
	int EstimatedSensor2Time;
	int Disk1Encoder;
	int LaserPrintState;
	unsigned int SensorOnEncoder;
	unsigned int LaserTriggerEncoderL;
	unsigned int LaserTriggerEncoderH;
	unsigned int LaserTriggerEncoder;	
	int	Sensor1Length;
	int	IsLEDOn[SYSTEM_MACHINE_CAPTURE_COUNT];
} THCBDisk1TabletUnit;

typedef	struct
{
	int	TabletNumber;
	int	InspectionResult;
	int	InspectionResult_SPB[SYSTEM_SPB_MAX_COUNT];
	int	State;
	int   Sensor1Time;
	int   LaserPrintingTime;
	int   CaptureIntTime;
	int   CaptureIntEncoder;
	int   EstimatedSensor2Time;
	int   Sensor2Time;
	int   EstimatedSensor3Time;
	int   Sensor3Time;
	int	Sensor1Length;
	int	Sensor2Length;
	int	Sensor3Length;
	int	IsLEDOn[SYSTEM_MACHINE_CAPTURE_COUNT];
	int   DefectEjectorTime;
	int   UnInsEjectorTime;
	int   GoodEjectorTime;	
	int   DefectEjectorLength;
	int   UnInsEjectorLength;
	int   GoodEjectorLength;	
	int	Ejection;
	int	EjectionCheck;
	int   Disk2Encoder;
	int   Disk2EncoderLength;
} THCBDisk2TabletUnit;

typedef	struct
{
	unsigned int Sensor3Time;
	int	State;
	int	Sensor3Length;
} THCBCounterTabletUnit;
typedef	struct
{
	THCBDisk1TabletUnit	Disk1TabletList[HCB_TABLET_LIST_COUNT];
	THCBDisk2TabletUnit	Disk2TabletList[HCB_TABLET_LIST_COUNT];
	THCBCounterTabletUnit CounterTabletList[HCB_TABLET_LIST_COUNT];

	int	CurrentTabletNumber;

	int	CurrentSensor1ListIndex;
	int	CurrentSensor2ListIndex;
	int	CurrentSensor3ListIndex;
	int	CurrentRelatedDisk1TabletListIndex;
	int	CurrentRelatedDisk2TabletListIndex;
	int 	CurrentSersorCheckCount;

	int	CurrentInt1ListIndex;
	int	CurrentInt2ListIndex;

	int	CurrentCapture1ListIndex;
	int	CurrentCapture2ListIndex;

	int	CurrentLaser1ListIndex;
	int	CurrentLaser2ListIndex;
	
	int	PollingResultTabletIndex;
	int	PollingBlowTabletIndex;

	int	CounterCheckListIndex;

	unsigned int CounterSensorInsertTimeList[HCB_TABLET_LIST_COUNT];
	unsigned int CounterSensorInsertLengthList[HCB_TABLET_LIST_COUNT];
} TTabletInfo;

typedef	struct
{
	int	Disk1TabletCount;
	int	Disk2TabletCount;
	int	TotalTabletCount;
	int	GoodTabletCount;
	int	DefectTabletCount;
	int	UnInsTabletCount;
 	int	UnPrintTabletCount;
	int	PrintMisMatchCount;
	int	SPBProcessingNCTabletCount;
	int	SPBTOTabletCount;
	int	SPBUnInsTabletCount;
	int	DisappearedTabletCount;
	int	InsertedTabletCount;
	int	ClosedTabletUninsCount;
	int	ClosedTabletDefectCount;
	int	ClosedTabletCount;
	int	WrongNumberTabletCount;
	int	NumberUndefTabletCount;
	int	CaptureNotReadyTabletCount;
	int	BufferFullTabletCount;
	int	CaptureTimoutTabletCount;
	int	ProcessingTimoutTabletCount;
	int	CPBFullTabletCount;
	int	ProcessingErrorTabletCount;
	int	UnInsTabletPositionCount;
	int	UnInsBrightnessDropCount;
	int	UnInsBrightnessChaseCount;
	int	Sensor1MisFeedingTabletCount;
	int	Sensor2MisFeedingTabletCount;
	int	Sensor1MultiTabletCount;
	int	Sensor2MultiTabletCount;
	int	CounterSensorTabletCount;
	int	MisejectActiveCount;
	int	GoodTabletLostCount;
	int	MisejectTabletInsertCount;
	int	MisejectDefectTabletCount;
	int	MisejectUnInsTabletCount;
	int	FRMismatchTabletCount;
	int   NozzErrorDefectTabletCount;
	int	NozzErrorUnInsTabletCount;
  int SPGoodTabletDropIndex; // SELMA 200 스페셜모드 통 번호 //HCB -> UI 로 UI상에 현재 받고 있는 통을 표시 하기 위해서.
  int LastDisStep;//마지막 분배기통 번호 저장 
} TTabletInspectInfo;

typedef	struct
{
	int	InspectionMode;
	int	SPBMask;
	float TabletLength;
	int	MachineStopActivated;
	int	MachineStopDefectRatio;
	int	MachineStopUnInsRatio;
	int	CameraMapInfo_SPB[SYSTEM_TOTAL_CAMERA_COUNT];
	int	CameraMapInfo_CAM[SYSTEM_TOTAL_CAMERA_COUNT];
	int	CheckUnPrint;
	int	CheckFrontRear;
	int	InspectionNCAsDefect;
	int	DesiredGPCount;
	int	MachineStopDPCount;
	int	MachineStopUPCount;
	int	InspectionID;
	int	SuctionDiskSpeed;
	int	StudiedTabletSensor1Length;
	int	StudiedTabletSensor2Length;
	int	StudiedTabletSensor3Length;
	int	StudiedSensorIntervalA;
	int	StudiedSensorIntervalB;
  unsigned int UnPrintInspectionType;
  int CaptureMode;

  /*********  Eject	Information	*********/
  int EjectMode;
  int BlowInterval;
  int BlowStart;
  int BlowLength;
  int UnInsBlowCheck;
  int SPModeGoodTabletCollectCount1; // 스페셜 모드 시 양품 수집 카운트에 따른 노즐 조작 변경
  int SPModeGoodTabletCollectCount2; // 스페셜 모드 시 양품 수집 카운트에 따른 노즐 조작 변경
#ifdef SHINIL
  int CountMode;
#endif
  int DHSpecialInsCheckbox; 
  int DHSpecialInsCount[6];
  int DHCountCheck[6];

  int DistributorCheck;            // 한국콜마용 3분배기 사용 유무
  int DistributorGoodTabletCount1; // 한국콜마용 3분배기용 양품 카운트 1
  int DistributorGoodTabletCount2; // 한국콜마용 3분배기용 양품 카운트 2
  int DistributorGoodTabletCount3; // 한국콜마용 3분배기용 양품 카운트 3
  int StartType;				   //공압 2분배기 검사시작 종류.(뉴트리용/한국콜마)
  int MachineStopTotalCount;
  int QMachineMisejectActiveLimitCount;
  float MisejectActiveTime; // 일단은 Acrocia 기준
  int ipb_count;
  int TabletSideThick;
  int DistributorConveyerEnable;
  int LaserStatus;
  int SendCompleteSigDistributor;
} THCBInspectionOption;

typedef	struct
{
	int	TabletNumber;
	int	Result;
	int EjectOnTime;
} TInspectionResultTableUnit;

typedef	struct
{
  int InspectionQuantity;
  double InspectionYield;
  int InspectionSpeed;  
}TInspectionAdditionalInfo;

typedef	struct
{
	TInspectionResultTableUnit Table[RESULT_TABLE_SIZE];
	int	CurrentIndex;
} TInspectionResultTable;

typedef	struct
{
	int	RangeLeft[SYSTEM_TOTAL_CAMERA_COUNT];
	int	RangeTop[SYSTEM_TOTAL_CAMERA_COUNT];
	int	RangeRight[SYSTEM_TOTAL_CAMERA_COUNT];
	int	RangeBottom[SYSTEM_TOTAL_CAMERA_COUNT];
} TTabletCaptureSetupData;

typedef	struct
{
	int	ImageCount;
	unsigned char ImageStatus[2048];
} TProcessingImageBufferData;

typedef	struct
{
	unsigned int CaptureMode;
	unsigned char CameraMask;
	unsigned char CaptureKind;
	unsigned char dummy[1];
  unsigned char SubsamplingMode[SYSTEM_SPB_CAMERA_MAX_COUNT];
	unsigned short ShutterSpeed[SYSTEM_SPB_CAMERA_MAX_COUNT]; // (20180208) [4] -> [SYSTEM_SPB_CAMERA_MAX_COUNT]
	unsigned short ShutterDelay[SYSTEM_SPB_CAMERA_MAX_COUNT]; // (20180208) [4] -> [SYSTEM_SPB_CAMERA_MAX_COUNT]
	unsigned short CaptureStartX;
	unsigned short CaptureLengthX;
	unsigned short CaptureStartY;
	unsigned short CaptureLengthY;
	int	FrameBufferCount;
	int	FrameHeight;
} TCaptureCommandParam; // For SELMA200, Rev by moon.

//20201106 cjg added 3d camera param
//****************************************************************************
//20201020 cjg 3D camera param control
//****************************************************************************
typedef	struct
{
	int Cam_Init_Offset[16];	
	int Cma_Sys_Gain[16];	
	int Cam_Calib_Mode;	
	int CutOff_Level;
	int Gain_Level;
	int COG_Threshold;
	int COG_Gain;
	int COG_Offset;
} TCameraInitParam;

typedef	struct
{
	int Cam_Init_Offset[16];	
	int Cma_Sys_Gain[16];	
	int Cam_Calib_Mode;	
} TCamera3D_CalOffsetParam;

typedef	struct
{
	int CutOff_Level;
	int Gain_Level;
	int COG_Threshold;
	int COG_Gain;
	int COG_Offset;
} TCamera3D_CalCOGParam;

typedef struct
{
	int Cam_Index;
	int Cam_Ver_Major; 
	int Cam_Ver_Minor;  
}T3DCameraVersion;

typedef struct
{
	int Cam_Index;
	int Cam_ADC_Resolution; 
}T3DCamera_ADC_Resolution;

typedef struct
{
	int CamTimeOutStauts;	
}TCheckCamTimeOut;
//****************************************************************************

typedef	struct
{
	unsigned int CaptureType;		// single, multi
	unsigned int CaptureMode;
	unsigned char CameraMask;
	unsigned char ContainParams;
  unsigned char SubsamplingMode[SYSTEM_SPB_CAMERA_MAX_COUNT];
	unsigned char dummy[1];
	unsigned short ShutterSpeed[SYSTEM_SPB_CAMERA_MAX_COUNT]; // (20180208) [4] -> [SYSTEM_SPB_CAMERA_MAX_COUNT]
	unsigned short ShutterDelay[SYSTEM_SPB_CAMERA_MAX_COUNT]; // (20180208) [4] -> [SYSTEM_SPB_CAMERA_MAX_COUNT]
	unsigned short TriggerFreq[SYSTEM_SPB_CAMERA_MAX_COUNT];  // (20180208) [4] -> [SYSTEM_SPB_CAMERA_MAX_COUNT]
	int	FrameBufferCount;
	int TabletType;
	int SensorLength;
} TCaptureSetupData; // For SELMA200, Rev by moon.

typedef	struct
{
	int TabletLength;
	int TabletWidth;
  int WhiteBalance[3];
  int InsAreaLeft;
  int InsAreaRight;
  int InsAreaTop;
  int InsAreaBottom;
  int CaptureUploadOption;
  int Threshold;
  int CaptureDelay_Min;
  int CaptureDelay_Max;
} TTPBInspectionData; // For SELMA200, Rev by moon.


typedef	enum
{
  SD1 =	0
  ,	SD2	= 1
} TSuctionDiscPos;

typedef	struct
{
	int	State;
	int	Result;
	int	ImageFrameIndex;
	int	ResultReported;
	unsigned char *CaptureImagePtr[SYSTEM_SPB_CAMERA_COUNT];
	int	CalibCaptureFrameIndex[SYSTEM_SPB_CAMERA_COUNT];
	int	CaptureStatus[SYSTEM_SPB_CAMERA_COUNT];
	unsigned int TabletNumber;
	unsigned int CaptureIntTime;
	unsigned int ProcessingStartTime[SYSTEM_SPB_CAMERA_COUNT];
	int	InspectionState[SYSTEM_SPB_CAMERA_COUNT];
	int	ProcessingResult[SYSTEM_SPB_CAMERA_COUNT];
	int	PrintResult[SYSTEM_SPB_CAMERA_COUNT];
	int	PrintType[SYSTEM_SPB_CAMERA_COUNT];
	int	ThickErrorSW[SYSTEM_SPB_CAMERA_COUNT];
	int	Front_Rear[SYSTEM_SPB_CAMERA_COUNT];
	TSuctionDiscPos 	SuctionDiscPos;
	int LaserTrigerTime;
} TSPBTabletUnit;

typedef	struct
{
	TSPBTabletUnit TabletList[SPB_TABLET_LIST_COUNT];
	unsigned int ExpectedNextTabletNumber[2];
	int	NextCaptureListIndex;
	int	FindingBufferListIndex;
	int	NumberingCaptureListIndex;
	int	PollingCaptureListIndex;
	int	processingPositionListIndex[SYSTEM_SPB_CAMERA_COUNT];
	int	ProcessingAllPositionListIndex;
	int	PollingCaptureEndListIndex[SYSTEM_SPB_CAMERA_COUNT];
	int	PollingCaptureAllEndListIndex;
	int	ProcessingTabletListIndex[SYSTEM_SPB_CAMERA_COUNT];
	int	ProcessingAllTabletListIndex;
	int	ProcessingResultListIndex[SYSTEM_SPB_CAMERA_COUNT];
	int	ProcessingResultCheckingListIndex;
	int	ProcessingResultReportingListIndex;
	int	DiscBaseSpeed[2];
	int	DiscTargetSpeed[2];
	int	CaptureMode;
	int	ProcessingMode;
	int	TabletNumberRequestOn[2];
	int	TabletNumberReceived[2];
	unsigned int ReceivedTabletNumber[2];
} TSPBTabletProcessInfo;

typedef	struct
{
	unsigned char CompleteCount;
	unsigned char ProcessingResult[SPB_PROCESSING_RESULT_COUNT];
	unsigned char DiskPosition[SPB_PROCESSING_RESULT_COUNT];
	int	ProcessedTabletNumber[SPB_PROCESSING_RESULT_COUNT];
} TSPBProcessingResultData;

typedef	struct
{
	int	TabletNumber;
	unsigned int CaptureStartTime[SYSTEM_SPB_CAMERA_COUNT];
	unsigned int CaptureEndTime[SYSTEM_SPB_CAMERA_COUNT];
	unsigned int ImageSendStartTime[SYSTEM_SPB_CAMERA_COUNT];
	unsigned int ProcessingStartTime[SYSTEM_SPB_CAMERA_COUNT];
	unsigned int BeforePollingTime[SYSTEM_SPB_CAMERA_COUNT];
	unsigned int ProcessingEndTime[SYSTEM_SPB_CAMERA_COUNT];
	int	ProcessingCPB[SYSTEM_SPB_CAMERA_COUNT];
	unsigned int CompleteTime;
} TProcessingTime;

typedef	struct
{
	char SetupKind;
	char SetupStep;
	char AvailCPBCount;
	char SetupCPBCount;
	char FailCPBCount;
	char CurrentCPBIndex;
	char dummy[2];
	char CPBStep[SYSTEM_CPB_MAX_COUNT];
	unsigned int WaitingStartTime;
} TSPBProcessingSetupInfo;

typedef	struct
{
	short VFSpeedList[VFINFO_LIST_COUNT];
	short VFMaxSpeedList[VFINFO_LIST_COUNT];
	short VFLimitSpeedList[VFINFO_LIST_COUNT];
	short VFSensor1RatioList[VFINFO_LIST_COUNT];
	short VFSensor2RatioList[VFINFO_LIST_COUNT];
 	short NowSpeedList[VFINFO_LIST_COUNT];
	short AverageSpeedList[VFINFO_LIST_COUNT];
	short AverageSensor1RatioList[VFINFO_LIST_COUNT];
	short AverageSensor2RatioList[VFINFO_LIST_COUNT];
	int	CurrentListIndex;
	int	SetRatio1;
	int	SetRatio2;
	int	Sensor1ON_NowRatio;
	int	Sensor2ON_NowRatio;
	int	test;
	int	test1;
	int	test2;
	int	test3;
	int	VFMode;
	int	BeforeSensor1Ratio;
	int	BeforeSensor2Ratio;
	int	AverageSensor1Ratio;
	int	AverageSensor2Ratio;
	unsigned short NowSpeed;
} TVibratorInfo;

typedef	struct
{
 	int	Change_Ratio;
} TChul_VFData;

typedef	struct
{
	int	DataValid;
	int	InspectionID;
	TTabletInspectInfo InspectionInfo;
} TTerminationInfo;

typedef	struct
{
	int	DefectExists;
	int	DefectTabletNumber;
	int	DefectCameraMask[SYSTEM_SPB_CAMERA_COUNT];
} TDefectImageInfo;

typedef	struct
{
	int	ProcessingTimeList[CPB_PROCESSING_TIME_LIST_COUNT];

} TCPBProcessingInfo;

typedef	struct
{
	unsigned short Version;
	unsigned short PartNumber;
	unsigned short Manufacturer;
	unsigned char InfoValid;
	unsigned char IsC64PlusDevice;
} TCPBDeviceInfo;

typedef	struct
{
	int	Length;
	char Data[4092];
} TRangerCameraParamData;

typedef	struct
{
	int	CurrentIndex;
	unsigned int CurrentTime;
	unsigned int Time[IDLE_PROCESS_LIST_COUNT];
	unsigned int TimeCounter[IDLE_PROCESS_LIST_COUNT];
	unsigned int Min50usCount[IDLE_PROCESS_LIST_COUNT];
	unsigned int Max50usCount[IDLE_PROCESS_LIST_COUNT];
} TIdleProcessData;

typedef	struct
{
	unsigned char Activated;
	unsigned char InspectionStopBuzzerOn;
	unsigned char InspectionStopMachinePowerOff;
	unsigned char TimerEnabled;
	unsigned int MachinePowerOffDelay;
	unsigned int BuzzerOnTime;
	unsigned int InspectionStopTimer;
} TUnmanedOperationData;

typedef	struct
{
	unsigned short 	troubleBoard;
	unsigned short 	type;
	unsigned int	time;
	unsigned int 	code;							/* error code */
	unsigned int 	value[ERROR_VALUE_MAX_SIZE];
} TErrorUnit;

typedef struct{
	unsigned char Enabled;
	unsigned char IsDown;
	unsigned char Step;
}TVirtualCPBStatus;

typedef struct{
  char Ready;
  char Active;
  char EMR;
  char InsRestart_ActiveStatus;
  char InsForm_Active;
  char NotChangeRecipeFlag;
  char APPActive;
  char NotRunFlag;
  char DLLLoadStatus;

  char StartCommandApply;
  char RestartCommandApply;
  char ResumeCommandApply;
  char EMStopCommandApply;
  char StopCommandApply;
  char WaitStop1CommandApply;
  char WaitStop2CommandApply;
  char DischargeResetCommandApply;
  char AjustTimeCommandApply;
  char ProductDataClearApply;
}TTUVLaserPortStatus;

typedef struct{
  char InsReady;
  char InsActive;
  char EMR;
  char APPActive;
}TPcUiFlag;

typedef struct{
  TTUVLaserPortStatus SELMAStatus;
  TTUVLaserPortStatus UVLaserStatus;
  unsigned short		DLL_Command;
}TUVLaserStatus;


typedef struct{
  unsigned int		ReceiveDLLCommand;
  unsigned int		SendDLLCommand;
  unsigned int		Tablet_count;
  unsigned int		InspectionStatus;
  unsigned int		LaserStatus;
  unsigned int 		LaserMachineStatus;
  unsigned int		LaserMackingTime;
}TNFALaserInfo;

typedef struct
{
	unsigned short IPMask;
	unsigned short OPMask;
} PortStatusInfo;

typedef struct
{
	int startTime[256];
	int endTime[256];
	int period[256];
	int cpbIndex[256];
	int checkcount;
}TTPBTimeInfoCopy;

typedef struct
{
	int ProcessStep[TPB_CPB_MAX_COUNT];
	int ProcessCount[TPB_CPB_MAX_COUNT];
	TTPBTimeInfoCopy imagesendTime[TPB_CPB_MAX_COUNT];
	TTPBTimeInfoCopy ProcessingTime[TPB_CPB_MAX_COUNT];
	int cpbIndex[TPB_CPB_MAX_COUNT];
	int cpbStatus[TPB_CPB_MAX_COUNT];
}TTBPProcessInfoCopy;

// ROI, Shutter, Gain, Threshold는 제품정보에 따라 바뀌게 되는 정보
//---------------------------------------------------------------------------
// Camera Packet
#define CAMERA_DATA_HEADER  0xA1

#define CAMERA_DATA_CMD_BINNING_MODE_L          0x6C // Binning 모드 설정
#define CAMERA_DATA_CMD_BINNING_MODE_H          0x20

#define CAMERA_DATA_CMD_SUBSAMPLING_MODE_L      0x6C // Sub Sampling 모드 설정
#define CAMERA_DATA_CMD_SUBSAMPLING_MODE_H      0x22

#define CAMERA_DATA_CMD_ROI_L                   0x6C // ROI 설정
#define CAMERA_DATA_CMD_ROI_H                   0x26 // R|W Length 서로다름 (PC To SPB)

#define CAMERA_DATA_CMD_SHUTTER_L               0x6C // Shutter Speed 설정
#define CAMERA_DATA_CMD_SHUTTER_H               0x46 // R|W Length 서로다름 (PC To SPB)

#define CAMERA_DATA_CMD_WB_L                    0x6C // White Balance 설정
#define CAMERA_DATA_CMD_WB_H                    0x70 // R|W Length 서로다름 (PC To SPB)

#define CAMERA_DATA_CMD_A_GAIN_L                0x6C // Analog Gain
#define CAMERA_DATA_CMD_A_GAIN_H                0xCC

#define CAMERA_DATA_CMD_D_GAIN_L                0x6C // Digital Gain
#define CAMERA_DATA_CMD_D_GAIN_H                0xC2 // R|W Length 서로다름 (PC To SPB)

#define CAMERA_DATA_CMD_TR_L                    0x6C // IMAGE TRANSFER SPEED
#define CAMERA_DATA_CMD_TR_H                    0x44

#define CAMERA_DATA_CMD_3D_IMAGE_MODE_L         0x6C // 3D 카메라 출력 모드
#define CAMERA_DATA_CMD_3D_IMAGE_MODE_H         0x74

#define CAMERA_DATA_CMD_THR_L                   0x6C // 어떻게 적용해야하는지 모르겠음...(2018-10-01)
#define CAMERA_DATA_CMD_THR_H                   0x36

#define CAMERA_DATA_WAVE_TABLE_L                0x6C
#define CAMERA_DATA_WAVE_TABLE_H                0x0A

#define CAMERA_DATA_CMD_ACTIVE_WINDOW_L         0x6C // ROI 설정
#define CAMERA_DATA_CMD_ACTIVE_WINDOW_H         0x24 // R|W Length 서로다름 (PC To SPB)

#define CAMERA_DATA_CMD_TRIGGER_MODE_L          0x6C
#define CAMERA_DATA_CMD_TRIGGER_MODE_H          0xC0
//---------------------------------------------------------------------------
// 추가되어야할 사항
#define CAMERA_DATA_CMD_IMG_FORMAT_L            0x6C // 1픽셀 10bit or 8bit 처리
#define CAMERA_DATA_CMD_IMG_FORMAT_H            0x18

#define CAMERA_DATA_FLASH_WRITE_L               0x6C
#define CAMERA_DATA_FLASH_WRITE_H               0x10

//---------------------------------------------------------------------------
#define MAX_2D_CAMERA_DATA_INDEX  17
#define MAX_3D_CAMERA_DATA_INDEX  11

#define FULL_SCALE_IMAGE_WIDTH  640
#define FULL_SCALE_IMAGE_HEIGHT 1024


typedef enum
{
  ECAMERA_PARAM_2D_BINNING_MODE,
  ECAMERA_PARAM_2D_SAMPLING_MODE,
  ECAMERA_PARAM_2D_ROI_START_X,
  ECAMERA_PARAM_2D_ROI_END_X,
  ECAMERA_PARAM_2D_ROI_START_Y,
  ECAMERA_PARAM_2D_ROI_END_Y,
  ECAMERA_PARAM_2D_SHUTTER_TIME,
  ECAMERA_PARAM_2D_ANALOG_GAIN,
  ECAMERA_PARAM_2D_DIGIT_GAIN1,
  ECAMERA_PARAM_2D_DIGIT_GAIN2,
  ECAMERA_PARAM_2D_WHITE_BALANCE_B,
  ECAMERA_PARAM_2D_WHITE_BALANCE_G1,
  ECAMERA_PARAM_2D_WHITE_BALANCE_G2,
  ECAMERA_PARAM_2D_WHITE_BALANCE_R,
  ECAMERA_PARAM_2D_DATA_TRANSFER_RATE,
  ECAMERA_PARAM_2D_IMAGE_FORMAT,
  ECAMERA_PARAM_2D_TRIGGER_MODE
} ETwoDCameraParameter;

typedef enum
{
  ECAMERA_PARAM_3D_WAVE_TABLE,
  ECAMERA_PARAM_3D_ROI_START_X,
  ECAMERA_PARAM_3D_ROI_END_X,
  ECAMERA_PARAM_3D_ROI_START_Y,
  ECAMERA_PARAM_3D_ROI_END_Y,
  ECAMERA_PARAM_3D_SHUTTER_TIME,
  ECAMERA_PARAM_3D_THRESHOLD,
  ECAMERA_PARAM_3D_ANALOG_GAIN,
  ECAMERA_PARAM_3D_IMAGE_MODE,
  ECAMERA_PARAM_3D_BINNING_MODE,
  ECAMERA_PARAM_3D_TRIGGER_MODE
} EThreeDCameraParameter;

/*
typedef struct
{
  //int Data[MAX_2D_CAMERA_DATA_INDEX];

  // 이미지 출력 모드
  int BinningMode;
  int SubSamplingMode;

  // 관심영역 설정
  // 기본값
  int ROIStartX;  // 0 ~ 159 (1280 / 8 = 160)
  int ROIEndX;    // 0 ~ 159 (1280 / 8 = 160)
  int ROIStartY;  // 0 ~ 1023
  int ROIEndY;    // 0 ~ 1023

  // 이미지 밝기
  int ShutterTime;

  int AnalogCameraGain;
  int DigitalCameraGain1;
  int DigitalCameraGain2;

  // 영상 보정
  int WhiteBalance[3]; // BGR

  // SPB - CAMERA 간 이미지 전송 속도
  int ImageTransferRate; // 이미지 전송속도를 1/4 로 줄여주는 상태값

} TTwoDCameraInformation;
*/

typedef struct
{
  // 이미지 출력 모드
  int BiningMode;

  // ROI
  int ROIStartX;  // 0 ~ 159 (1280 / 8 = 160)
  int ROIWidth;   // 640 (640 / 8)
  int ROIStartY;  // 0 ~ 1023
  int ROIHeight;  // 128

  // 3D 카메라 조리개 Open 시간
  int ExposureTime;

  // 영상 노이즈 제거
  int Thresold3D;
  int AnalogCameraGain;
  int TriggerMode;

  // Profiling Image or One Frame Image
  int ImageOutputMode;

  // Wave Table...
  int WaveTableIndex;

  int DataSettingSW;

} TThreeDCameraDefaultInformation;

#define CAMERA_WRITE_MASK_2D_SH                      	0x1<<0
#define CAMERA_WRITE_MASK_3D_SH                      	0x1<<1
#define CAMERA_WRITE_MASK_TH                           		0x1<<2
#define CAMERA_WRITE_MASK_2D_ROI                           0x1<<3
#define CAMERA_WRITE_MASK_3D_ROI                           0x1<<4
#define CAMERA_WRITE_MASK_2D_SUBSAMPLING_MODE 0x1<<5
#define CAMERA_WRITE_MASK_2D_ANALOG_GAIN           0x1<<6
#define CAMERA_WRITE_MASK_2D_DIGITALGAIN             0x1<<7

#define UNIT_CONVERT_CONSTANT_VALUE_FOR_3D 16.99f
#define ROW_COUNT_FOR_HIGH_SPEED  90 // 80 -> 90, 20171121 이미지 노이즈 발생
#define SUB_ROI_COUNT             12
#define HARD_TILTING_STD_TABLET_LENGTH  15.0f

typedef struct
{
  int ShutterSpeed;

  int Threshold;

  int ROIStartX;
  int ROIEndX;
  int ROIStartY;
  int ROIEndY;

  int TrigFreq;

  int SubSamplingMode;
  int Gain;
} TVariableCameraInformation;

typedef struct
{
  int StartX;
  int EndX;
  int StartY;
  int EndY;
} TROIInfo;

typedef struct
{
  int BColorInfo;
  int GColorInfo;
  int RColorInfo;

} TWhiteBalanceInfo;


#define NFACAMCHECK_CAPTURE_TIME 10000		//ms

typedef struct
{
	int StartX;
	int EndX;
	int StartY;
	int EndY;
} TNFACamCheckROI;

typedef struct
{
	int SubSampling;
	int ShutterSpeed;
	int AnalogGain;
	int DigitalGain[2];	
	TNFACamCheckROI ROI;
	int WaveTable;
	int OutPutMode3D;
} TNFACamCheckSetting;
				
typedef struct
{
	int main_Step;
	int sub_Step;
	int CamIndex;
	int CheckResult;
	int CheckResult_sub;
	int CheckStartTime;
      TNFACamCheckSetting CamSet[SYSTEM_SPB_CAMERA_MAX_COUNT];
	TNFACamCheckSetting CamGet[SYSTEM_SPB_CAMERA_MAX_COUNT];
} TNFACamCheckInfo;

#define MAX_IMAGE_BLOCK_INDEX			1024		

typedef struct
{
	int cpbSendIndex;
	int Status;
	int inspection_result;
	int workedCoreIndex;
  int TPBMinX1;
  int TPBMaxX1;
  int TPBMinY1;
  int TPBMaxY1;	
  int TPBMinX2;	
	int TPBMinX3;
	int TPBMinY3;
	int TPBMaxX3;	
	int TPBMaxY3;	 
} TTPBMonitorInsData;

typedef struct	
{	
	int currentCaptureIndex;
	int capturePeriod;
	int process_startTime;
	int process_period;
	int process_checkcount;
}TTPBInsProcessInfoCopy;	

enum NFACAMCHECK_PROCESS
{
	NFA_CAM_CHECK_NONE,
	NFA_CAM_CHECK_INIT,
	NFA_CAM_CHECK_LINK,
	NFA_CAM_CHECK_SET_PARAM,
	NFA_CAM_CHECK_GET_PARAM,
	NFA_CAM_CHECK_PARAM_MODIFY,
	NFA_CAM_CHECK_CAPTURE
};
enum NFACAMCHECK_PROCESS_SUB
{
	NFACAMCHECK_PROCESS_SUB_NONE,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_ROI,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_SUBSAMPING,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_ANALOGGAIN,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_DIGITALGAIN,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_SHUTTERSPEED,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_WAVETABLE,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_OUTPUTMODE3D,
	NFACAMCHECK_PROCESS_SUB_SETPARAM_COMPLETE,
	NFACAMCHECK_PROCESS_SUB_CAPTURE_INIT,
	NFACAMCHECK_PROCESS_SUB_CAPTURE_START,
	NFACAMCHECK_PROCESS_SUB_CAPTURE_STOP,
	NFACAMCHECK_PROCESS_SUB_CAPTURE_MODIFY
};

enum NFACAMCHECK_RESULT
{
	NFA_CAM_CHECK_RESULT_NONE,
	NFA_CAM_CHECK_RESULT_INIT_FAIL,
	NFA_CAM_CHECK_RESULT_LINK_FAIL,	
	NFA_CAM_CHECK_RESULT_SETPARM_FAIL,
	NFA_CAM_CHECK_RESULT_CAPTURE_FAIL,
	NFA_CAM_CHECK_RESULT_SUCCESS
};

enum NFACAMCHECK_RESULT_SUB
{
	NFA_CAM_CHECK_RESULT_SUB_NONE,
	NFA_CAM_CHECK_RESULT_SETPARM_ROI,
	NFA_CAM_CHECK_RESULT_SETPARM_SUBSAMPING,
	NFA_CAM_CHECK_RESULT_SETPARM_ANALOGGAIN,	
	NFA_CAM_CHECK_RESULT_SETPARM_DIGITALGAIN,
	NFA_CAM_CHECK_RESULT_SETPARM_SHUTTERSPEED,
	NFA_CAM_CHECK_RESULT_SETPARM_WAVETABLE,
	NFA_CAM_CHECK_RESULT_SETPARM_OUTPUTMODE3D,
	NFA_CAM_CHECK_RESULT_CAPTURE_INIT,
	NFA_CAM_CHECK_RESULT_CAPTURE_TIMEOUT,
	NFA_CAM_CHECK_RESULT_CAPTURE_COUNT,
	NFA_CAM_CHECK_RESULT_CAPTURE_INTERRUPT
};



/************************************************************************************/
/*Q사 Dll 관련 선언																                                */
/************************************************************************************/
enum eStatust
{
	STATUS_Undefine = 0x0000,
	STATUS_Ready = 0x0001,
  STATUS_ReStartRedy = 0x0002,
	STATUS_Run = 0x0004,
	STATUS_WaitStop = 0x0008,
	STATUS_Emergency = 0x0010,
	//STATUS_Manual = 0x0010,
	STATUS_UsInterlockMode = 0x0100,
  STATUS_DsInterlockMode = 0x0200,
	STATUS_Warning = 0x1000,
	STATUS_MiddleAlarm = 0x2000,
	STATUS_HeavyAlarm = 0x4000
};

// object status
enum eObjStatus
{
	OBJ_STATUS_undefine			= 0x0000,
	OBJ_STATUS_NotRun			= 0x0001,	// for MES
	OBJ_STATUS_NotChangeRecipe  = 0x0002,	// for MES
  OBJ_STATUS_UpStreamNotReady =  0x0010,
  OBJ_STATUS_DownStreamNotReady =  0x0020,
	OBJ_STATUS_MesError = 0x1000,			// MES Comm error
	OBJ_STATUS_UpstreamError	= 0x2000,
	OBJ_STATUS_DownstreamError	= 0x4000,
  OBJ_STATUS_QjpobjectError = 0x8000
};


// command
enum eCommand
{
	COMMAND_None = 0,
	COMMAND_Start,							// start
	COMMAND_ReStart,						// restart
	COMMAND_Resume,							// resume from waitstop
	COMMAND_EmergencyStop = 10,				// not use
	COMMAND_Stop,
	COMMAND_WaitStop1,						// blower non stop
	COMMAND_WaitStop2,						// blower stop
	COMMAND_DischargeCountReset = 100,		// counter reset
	COMMAND_AjustTime,						// time adjustment
  COMMAND_ProductDataClear = 200						
};

enum SeqType
{
	SEQ_UpStreem = 0x0001,
	SEQ_DownStreem = 0x0002,
	SEQ_Mes = 0x0004,
	SEQ_All = SEQ_UpStreem | SEQ_DownStreem | SEQ_Mes
};

/************************************************************************************/
/*AMTec Dll 관련 선언																                       */
/************************************************************************************/


enum MachineStatus
{
	MachineStatus_None = 0,			// 초기 상태 (프로그램도 실행되지 않은 상태)
	MachineStatus_Stop,				// 장비 대기중 상태
	MachineStatus_Starting,			// 장비 시작중 상태
	MachineStatus_Run,				// 장비 동작중 상태
	MachineStatus_Stoping,			// 장비 정지중 상태
	MachineStatus_Emergency		// 작비 동작중 에러 발생으로 장비가 정지되는 상태.

};

enum LaserStatus
{
	LaserStatus_None = 0,			// 초기 상태 (프로그램도 실행되지 않은 상태)
	LaserStatus_Stop,				// 프로그램은 실행되어있으나 온더플라이모드가 아닌상태.
	LaserStatus_Ready,				// 레시피 로드가 완료되어 CMD_MACHINE_START 명령으로 온더플라이모드가 실행 가능한 상태.
	LaserStatus_Run,				// 프로그램에서 온더플라이모드가 실행되어 있는 상태.
	LaserStatus_Emergency			// 에러 발생으로 온더플라이모드 동작중 중지되어야 하는 상태. 
};

enum LaserMachineStatus
{
	LaserMachineStatus_None = 0,	// 초기 상태 (프로그램이 실행되지 않아 알수없는 상태)
	LaserMachineStatus_WarmUp,		// 레이저 WarmUP중.
	LaserMachineStatus_Run,		// 레이저 On 상태(WarmUP은 완료되고 ON되어 있는 상태)
	LaserMachineStatus_Stop,		// 레이저 STOP 상태(WarmUP은 완료되고 OFF되어 있는 상태)
	LaserMachineStatus_Error		// 레이저 Error 상태(레이저에 문제가 생겨 인쇄가 안되는 상태)
};


enum DllObjStatus
{
	DllStatus_Wait=0,
	DllStatus_Run,
	DllStatus_Error
};

enum LaserComplexerCmd
{
	CMD_MACHINE_NONE,					
	CMD_MACHINE_STOP,					
	CMD_MACHINE_START,					
	CMD_MACHINE_PRODUCT_SELECT,			
	CMD_MACHINE_INSPECTION_UI_OPEN,		
	CMD_MACHINE_INSPECTION_UI_CLOSE,		
	CMD_MACHINE_COUNT_RESET,			
	CMD_LASER_STOP,						//LASER_START 기능 추가(NFA UI -> Laser 프로그램으로 전달)
	CMD_LASER_START,						//LASER_STOP 기능 추가(NFA UI -> Laser 프로그램으로 전달)
	CMD_LASER_COUNT_RESET,					
	CMD_LASER_RECIPE_SELECT,				
};

enum MachineUIStatus
{
	Inspection_Not_Ready = 0,
	Inspection_Ready
};
enum LaserComplexerRunMdoe
{
	MODE_EACH_ACTION,
	MODE_JOIN_ACTION
};

enum LaserComplexerErrorList
{
	LASER_COMPLEXER_ERROR_CODE_NONE,
	LASER_COMPLEXER_ERROR_CODE_STOP_ERROR,			
	LASER_COMPLEXER_ERROR_CODE_START_ERROR,
	LASER_COMPLEXER_ERROR_CODE_COUNT_RESET_ERROR,
	LASER_COMPLEXER_ERROR_CODE_PRODUCTNAME_NOT_EXISTS,	
	LASER_COMPLEXER_ERROR_CODE_RECIPENAME_NOT_EXISTS
};

/************************************************************************************/
/*TPB Miseject Mode															                       */
/************************************************************************************/

#define TPB_MISEJECT_NO_INSPECTION_MODE	1
#define TPB_MISEJECT_NORMAL_MODE				0

//----------------------------------------------------------------------------------------------

/************************************************************************************/
/* Common Function																	                 */
/************************************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

unsigned int CheckSum(unsigned int *src, unsigned int len);
unsigned int ImageCheckSum(unsigned char* src, int left, int top, int width, int height, int ImageWidth, int size);
int	SizeOfWord(int size);
int Chk_IP_Addr_Validation(char *nIP_Addr);

#ifdef __cplusplus
}
#endif

#endif
