#ifndef	_IO_PORT_H
#define	_IO_PORT_H

//logical (virtual) output	port definition
//HCB04(OP72,IP60), HCB05(OP88,IP90)

#define   MAX_PORT_COUNT 				 96
/*
#define	VIRTUAL_OUTPUT_PORT_COUNT	 MAX_PORT_COUNT
#define	VIRTUAL_INPUT_PORT_COUNT		 MAX_PORT_COUNT
#define	PHYSICAL_OUTPUT_PORT_COUNT	 MAX_PORT_COUNT
#define	PHYSICAL_INPUT_PORT_COUNT	 MAX_PORT_COUNT
*/	
#define	VOP0	0
#define	VOP1	1
#define	VOP2	2
#define	VOP3	3
#define	VOP4	4
#define	VOP5	5
#define	VOP6	6
#define	VOP7	7
#define	VOP8	8
#define	VOP9	9
#define	VOP10	10
#define	VOP11	11
#define	VOP12	12
#define	VOP13	13
#define	VOP14	14
#define	VOP15	15
#define	VOP16	16
#define	VOP17	17
#define	VOP18	18
#define	VOP19	19
#define	VOP20	20
#define	VOP21	21
#define	VOP22	22
#define	VOP23	23
#define	VOP24	24
#define	VOP25	25
#define	VOP26	26
#define	VOP27	27
#define	VOP28	28
#define	VOP29	29
#define	VOP30	30
#define	VOP31	31
#define	VOP32	32
#define	VOP33	33
#define	VOP34	34
#define	VOP35	35
#define	VOP36	36
#define	VOP37	37
#define	VOP38	38
#define	VOP39	39
#define	VOP40	40
#define	VOP41	41
#define	VOP42	42
#define	VOP43	43
#define	VOP44	44
#define	VOP45	45
#define	VOP46	46
#define	VOP47	47
#define	VOP48	48
#define	VOP49	49
#define	VOP50	50
#define	VOP51	51
#define	VOP52	52
#define	VOP53	53
#define	VOP54	54
#define	VOP55	55
#define	VOP56	56
#define	VOP57	57
#define	VOP58	58
#define	VOP59	59
#define	VOP60	60
#define	VOP61	61
#define	VOP62	62
#define	VOP63	63
#define	VOP64	64
#define	VOP65	65
#define	VOP66	66
#define	VOP67	67
#define	VOP68	68
#define	VOP69	69
#define	VOP70	70
#define	VOP71	71
#define	VOP72	72
#define	VOP73	73
#define	VOP74	74
#define	VOP75	75
#define	VOP76	76
#define	VOP77	77
#define	VOP78	78
#define	VOP79	79

//New Port PIO05
#define	VOP80	80
#define	VOP81	81
#define	VOP82	82
#define	VOP83	83
#define	VOP84	84
#define	VOP85	85
#define	VOP86	86
#define	VOP87	87
#define	VOP88	88
#define	VOP89	89
#define	VOP90	90
#define	VOP91	91
#define	VOP92	92
#define	VOP93	93
#define	VOP94	94
#define	VOP95	95



#define	VIP0	0
#define	VIP1	1
#define	VIP2	2
#define	VIP3	3
#define	VIP4	4
#define	VIP5	5
#define	VIP6	6
#define	VIP7	7
#define	VIP8	8
#define	VIP9	9
#define	VIP10	10
#define	VIP11	11
#define	VIP12	12
#define	VIP13	13
#define	VIP14	14
#define	VIP15	15
#define	VIP16	16
#define	VIP17	17
#define	VIP18	18
#define	VIP19	19
#define	VIP20	20
#define	VIP21	21
#define	VIP22	22
#define	VIP23	23
#define	VIP24	24
#define	VIP25	25
#define	VIP26	26
#define	VIP27	27
#define	VIP28	28
#define	VIP29	29
#define	VIP30	30
#define	VIP31	31
#define	VIP32	32
#define	VIP33	33
#define	VIP34	34
#define	VIP35	35
#define	VIP36	36
#define	VIP37	37
#define	VIP38	38
#define	VIP39	39
#define	VIP40	40
#define	VIP41	41
#define	VIP42	42
#define	VIP43	43
#define	VIP44	44
#define	VIP45	45
#define	VIP46	46
#define	VIP47	47
#define	VIP48	48
#define	VIP49	49
#define	VIP50	50
#define	VIP51	51
#define	VIP52	52
#define	VIP53	53
#define	VIP54	54
#define	VIP55	55
#define	VIP56	56
#define	VIP57	57
#define	VIP58	58
#define	VIP59	59
#define	VIP60	60
#define	VIP61	61
#define	VIP62	62
#define	VIP63	63
#define	VIP64	64
#define	VIP65	65
#define	VIP66	66
#define	VIP67	67
#define	VIP68	68
#define	VIP69	69
#define	VIP70	70
#define	VIP71	71
#define	VIP72	72
#define	VIP73	73
#define	VIP74	74
#define	VIP75	75
#define	VIP76	76
#define	VIP77	77
#define	VIP78	78
#define	VIP79	79

//New Port PIO_05 
#define	VIP80	80
#define	VIP81	81
#define	VIP82	82
#define	VIP83	83
#define	VIP84	84
#define	VIP85	85
#define	VIP86	86
#define	VIP87	87
#define	VIP88	88
#define	VIP89	89
#define	VIP90	90
#define	VIP91	91
#define	VIP92	92
#define	VIP93	93
#define	VIP94	94
#define	VIP95	95



#define	VOP_NOT_EXIST	64	//64
#define	POP_NOT_EXIST	255
#define	PIP_NOT_EXIST	255

// inverter	control
#define	OP_RB1_MIDDLE_SPEED				VOP_NOT_EXIST
#define	OP_RB1_HIGH_SPEED				VOP_NOT_EXIST


/* ==============================
//  2018.06.23 노즐 변경.
// 불량 : 28 ==> 10
// 미검 : 29 ==> 18
// 양품 : 30 ==> 27
// ------------------------------
// 새로운 노즐은 사용이 불가하여 원복 함.(2018.06.26)
// 불량 : 28 ==> 10 ==> 0
// 미검 : 29 ==> 18 ==> 1
// 양품 : 30 ==> 27 ==> 10
// HOPER_AIR : 26 => 31  => 26
// ============================= */
// solenoid	control	 
#define	OP_DEFECT_BLOWER				VOP0   //백색,30 => 28 ==> 10 ==> 0
#define	OP_UNINSPECTED_BLOWER			VOP1   //녹색,26 => 30 ==> 29 ==> 18 ==> 1
#define	OP_BF_AIR_KNIFE_BIT_0			VOP2
#define	OP_BF_AIR_KNIFE_BIT_1			VOP3
#define	OP_SD1_AIR						VOP4
#define	OP_SD2_AIR						VOP5
#define	OP_AIR_BRUSH_1_ACTUATOR			VOP6
#define	OP_AIR_BRUSH_2_ACTUATOR			VOP7
#define	OP_MISEJECT_ACTUATOR_ON			VOP8   
#define	OP_MISEJECT_ACTUATOR_OFF		VOP9 
#define	OP_GOOD_BLOWER			        VOP10   //흑색,28 => 31 => 30 ==> 27 ==> 10
#define	OP_BF_SENSOR_DUST_BLOWER		VOP11   
#define	OP_AIR_BRUSH					VOP12
#define	OP_DUST_BLOWER_1				VOP13	
#define	OP_DUST_BLOWER_2				VOP14	
#define	OP_DUST_BLOWER_3				VOP15	
#define	OP_DUST_BLOWER_4				VOP16	
#define	OP_BF_AIR_KNIFE_BIT_2			VOP17	
#define	OP_BUZZER_2_ON					VOP18	//부저 2 (Ch 3), SELMA100은 Reserved.
#define	OP_POWER_OFF					VOP19
#define	OP_RB3_ON						VOP20	//인버터3
#define	OP_TOWER_LAMP_R_ON				VOP21
#define	OP_TOWER_LAMP_Y_ON				VOP22
#define	OP_TOWER_LAMP_G_ON				VOP23
#define	OP_BUZZER_ON					VOP24
#define	OP_LIGHT_SWITCH_LAMP_ON		    VOP25

#define OP_2DISTRIBUTOR_ON              VOP26   //2분배기용.
#define OP_2DISTRIBUTOR_OFF             VOP27   //2분배기용. 호주 28, 국내 27 로 되어 있음.

//OP28 ~ OP31 저항 큰 포트.
#define	OP_ROOM_LAMP_ON					VOP29   //VOP29 ==> op10 ==> 29

//not connected(op32 ~ op39)
#define	OP_SERVO_1_ON					VOP32
#define	OP_SERVO_2_ON					VOP33
#define	OP_SERVO_3_ON					VOP36	//VOP65
#define	OP_SERVO_4_ON					VOP34
#define	OP_SERVO_5_ON					VOP35

#define	OP_RB1_ON						VOP40
#define	OP_RB2_ON						VOP41

//기존 op42 ~ op43 Not use
#define	OP_HOPER_AIR					VOP43   //미들호퍼용 바이브레이터 : 
												//26 => 31 => 26 => 31 (SELMA100 은 31로 되어 있음) 
												//op31을 op11 과 같이 사용하다가 
                                                //이동근 과장의 요청으로 op43으로 변경 함.

//OP44 ~ OP49                           A,B 포트
#define	OP_PC_POWER_SW					VOP44   //VOP44가 이상해서 47로 옮김. 다시 원복 함.
#define	OP_VF_ON						VOP45
#define	OP_VF2_ON						VOP46
#define OP_YU_CONTROL                   VOP47   //유유제약 
#define	OP_SAFETY_CIRCUIT_RESET			VOP48	//Q사 추가.(SELMA100 Not USE)

#define	OP_LED_1						VOP50
#define	OP_LED_2						VOP51
#define	OP_LED_3						VOP52
#define	OP_LED_4						VOP53
#define	OP_LED_5						VOP54   //정제 추가 조명 (SD1)
#define	OP_LED_6						VOP55   //배출구용 백라이트
#define	OP_LED_7						VOP56
#define	OP_LED_8						VOP57
#define	OP_LED_9						VOP58
#define	OP_LED_10						VOP59
#define	OP_LED_11						VOP60   //정제 추가 조명 (SD2)
#define	OP_LED_12						VOP61   

#define	OP_TPB_LED					VOP90

#define OP_DH_CONTROL                   VOP62   //대화제약 VOP62
#define	OP_UNLOCK_SWITCH_LAMP_ON	    VOP30	//62 => 30	
#define	OP_INTERLOCK_SOLENOID			VOP63   //64를 63로 변경, 일본에 있는 Q사 SYSTEM(1호기) 변경해야 함.
#define	OP_GETBYPASS_IP58				VOP64
#define	OP_CHANGE_LD_RELAY			VOP65
#define	OP_IONIZER_ON					VOP66
#define	OP_VARIOSCAN_POWER			VOP67
#define	OP_LASER_SHUTTER				VOP68
#define	OP_SCANHEADER_POWER			VOP69

#define	OP_SAFETY_CIRCUIT_SELECT		VOP70	//Q사 추가.(SELMA100 Not USE)
#define	OP_SD1_LASER_PRINT_TRIG		VOP71
#define	OP_SD2_LASER_PRINT_TRIG		VOP72
#define 	OP_LASERT_ENCODER_SEL		VOP76	//0: 정상모드,  1: 테스트 모드
#define 	OP_LASERT_ENCODER_POLA		VOP77	//0: 정방향,  1: 역방향
#define 	OP_LASERT_TRIG_CONTROL_MODE	VOP79	//0:프로그램 모드, 1:하드웨어 모드

#define	OP_LINK_READY 					VOP80
#define	OP_LINK_EMR					VOP81
#define	OP_LINK_ACTION					VOP82
#define	OP_LINK_APPACTION				VOP83
//#define	OP_LINK_EMR						VOP83
 
/////////////////////////////           OP88 (Last)

#define	OP_SERVO_ALARM_RESET			VOP_NOT_EXIST

// rename of op 
#define	OP_SD1_SUCTION_ON				OP_RB1_ON
#define	OP_SD2_SUCTION_ON				OP_RB2_ON
#define	OP_DUST_SUCTION_ON				OP_RB3_ON


// rename of input port
#define	IP_POWER_ON							VIP0
#define	IP_EMER_ON							VIP1
#define	IP_MONITOR_SWITCH_ON				VIP2
#define	IP_BF_SENSOR_1						VIP3
#define	IP_BF_SENSOR_2						VIP4
#define	IP_BF_SENSOR_CONNECTED				VIP5
#define	IP_BUZZER_RESET     				VIP6    //Q사, SELMA100은 Reserved.
#define	IP_DISK_1_CAPTURE_SENSOR			VIP7
#define	IP_DISK_1_CAPTURE_LAMP1_CONNECTED	VIP8
#define	IP_DISK_2_CAPTURE_SENSOR			VIP9
#define	IP_DISK_2_CAPTURE_LAMP1_CONNECTED	VIP10
#define	IP_COUNTER_SENSOR_ON				VIP11
#define	IP_DISK_1_CAPTURE_LAMP2_CONNECTED	VIP12
#define	IP_DISK_2_CAPTURE_LAMP2_CONNECTED	VIP13
#define	IP_HOPPER_EMPTY_SENSOR				VIP14
#define	IP_FRONT_DOOR_SENSOR				VIP15
#define	IP_EMISSION_SENSOR			        VIP16
#define	IP_RB_1_OL							VIP17
#define	IP_RB_2_OL							VIP18
#define	IP_RB_3_OL							VIP19	//인버터3. // 200 
#define	IP_LASER_SHUTTER_SENSOR			VIP20

#define	IP_NC_1_LIMIT_L						VIP24   //RP26
#define	IP_NC_1_HOME						VIP25   //RP25
#define	IP_NC_1_LIMIT_H						VIP26   //RP24
#define	IP_NC_2_LIMIT_L						VIP27
#define	IP_NC_2_HOME						VIP28
#define	IP_NC_2_LIMIT_H						VIP29
#define	IP_NC_3_LIMIT_L						VIP30
#define	IP_NC_3_HOME						VIP33
#define	IP_NC_3_LIMIT_H						VIP32
#define	IP_NC_4_LIMIT_L						VIP34   //RP34
#define	IP_NC_4_HOME						VIP35   //RP35
#define	IP_NC_4_LIMIT_H						VIP36   //RP36
#define	IP_NC_5_LIMIT_L						VIP37   //RP37
#define	IP_NC_5_HOME						VIP38   //RP38
#define	IP_NC_5_LIMIT_H						VIP39   //RP39

#define	IP_ME_ENABLE						VIP40
#define	IP_ME_AXIS_BIT_0					VIP41
#define	IP_ME_AXIS_BIT_1					VIP42
#define	IP_ME_AXIS_BIT_2					VIP43
#define	IP_ME_FEED_BIT_0					VIP44
#define	IP_ME_FEED_BIT_1					VIP45
#define	IP_ME_EMERGENCY_OFF					VIP46

#define	IP_ALARM_RESET     				    VIP47    //Q사, SELMA100은 Reserved.
#define	IP_DISK_1_CAPTURE_SENSOR_B			VIP48
#define	IP_DISK_2_CAPTURE_SENSOR_B			VIP49

#define	IP_INTERLOCK_SWITCH_ON_OFF_EVENT	VIP50   //Q사  200
#define	IP_POWERMETER_SENSOR				VIP51    //LASER POWER METER SENSOR 
#define	IP_PC_ON							VIP52   //PC POWER PCP-PCM
#define	IP_INTERLOCK_1						VIP53   //Q사, SELMA100은 Reserved.
#define	IP_INTERLOCK_2						VIP54   //Q사, SELMA100은 Reserved. 
#define	IP_COUNTER_SENSOR_B_ON				VIP55
#define	IP_COUNTER_SENSOR_B_ON				VIP55
#define	IP_MISEJECT_CHECK_SENEOR_A 			VIP56   // Q사200 
#define	IP_MISEJECT_CHECK_SENEOR_B			VIP57   // Q사200
#define	IP_BYPASS_OP64  					VIP58
#define IP_DH_CONTROL                       VIP60   //분배기 입력.(and N24)

#define	IP_VB_SENSOR   						VIP59   // 200 

#define	IP_LINK_READY 						VIP80   // Q사200
#define	IP_LINK_EMR							VIP81   // Q사200
#define	IP_LINK_ACTION						VIP82   // Q사200
#define	IP_LINK_APPACTION					VIP83   // Q사200

//#define	IP_LINK_EMR							VIP67
///////////////////////////////             IP90 (Last)



typedef	struct
{
	unsigned char OPStatus[MAX_PORT_COUNT];
	unsigned char IPStatus[MAX_PORT_COUNT];
} TPortStatus;



#endif

