COMPILE FUNCTION Comm_React_Run_Ver(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)

/*
	Commuter module for React_Run_Ver collector  window
	
	05/01/2012 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, obj_WO_Mat
DECLARE SUBROUTINE ErrMsg, Set_Property, obj_AppWindow, Send_Event

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, obj_Popup
DECLARE FUNCTION Msg, obj_WO_Mat, Send_Message


$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT REACT_RUN_EQUATES
$INSERT WO_MAT_EQUATES
$INSERT PROD_SPEC_EQUATES

EQU CRLF$	TO \0D0A\
EQU TAB$	TO \09\


EQU COL$MET_TEST		TO 1	;* Columns in QA Metrology Edit Table
EQU COL$MET_TEST_DESC	TO 2
EQU COL$MET_SLOT		TO 3
EQU COL$MET_SLOT_DESC	TO 4
EQU COL$MET_SLOT_TEST	TO 5
EQU COL$MET_MIN			TO 6
EQU COL$MET_MAX			TO 7
EQU COL$MET_RESULT		TO 8
EQU COL$MET_SIG			TO 9
EQU COL$MET_SIG_DTM		TO 10



ErrTitle = 'Error in Comm_React_Run_Ver'
ErrorMsg = ''

Result = ''


BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Cancel
			
		END CASE
		
	CASE EntID = @WINDOW:'.SIGN' AND Event = 'CLICK'	 			; GOSUB Sign
	CASE EntID = @WINDOW:'.CANCEL' AND Event = 'CLICK'				; GOSUB Cancel
	
	
	CASE 1
	
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		
END CASE

IF ErrorMsg NE '' THEN
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
END

RETURN Result



* * * * * * *
Create:
* * * * * * *

obj_Appwindow('Create',@WINDOW)

Vals = Parm1

CONVERT @FM TO @RM IN Vals

WONo		= Parm1[1,@FM]
WOStep		= Parm1[COL2()+1,@FM]
CassNo		= Parm1[COL2()+1,@FM]
RDSNo		= Parm1[COL2()+1,@FM]
ReactType	= Parm1[COL2()+1,@FM]
RunStep		= Parm1[COL2()+1,@FM]
StepComment	= Parm1[COL2()+1,@FM]


BEGIN CASE
	CASE RunStep = 'VER'	; RunStepDesc = 'Verify Cassette Wafer Quantity'
	CASE RunStep = 'LOAD'	; RunStepDesc = 'Load Reactor'
	CASE RunStep = 'UNLOAD'	; RunStepDesc = 'Unload Reactor'
	CASE 1					; RunStepDesc = 'Unknown Run Step!':QUOTE(RunStep)
END Case

Title = Get_Property(@WINDOW,'TEXT'):' - ':RunStepDesc

Set_Property(@WINDOW,'TEXT',Title)


Ctrls  = @WINDOW:'.WO_NO':@RM			; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.PROC_STEP_NO':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.OUT_CASS_NO':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.RDS_NO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.REACT_TYPE':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.RUN_STEP':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.STEP_COMMENT'		; Props := 'DEFPROP'

Set_Property(Ctrls,Props,Vals)


BEGIN CASE
	CASE RunStep = 'VER'
		ActiveCtrls  = @WINDOW:'.WFR_QTY_LABEL':@RM
		ActiveCtrls := @WINDOW:'.WFR_QTY'
		
		Props = 'VISIBLE':@RM:'VISIBLE'
		Vals = '1':@RM:'1'

	CASE RunStep = 'LOAD'
	
		ActiveCtrls  = @WINDOW:'.WFR_QTY_LABEL':@RM
		ActiveCtrls := @WINDOW:'.WFR_QTY':@RM
		ActiveCtrls := @WINDOW:'.SUPP_GROUP':@RM
		ActiveCtrls := @WINDOW:'.SUPPPLEMENT':@RM
		ActiveCtrls := @WINDOW:'.SUPP_ID_LABEL':@RM
		ActiveCtrls := @WINDOW:'.SUPP_ENTRY_ID':@RM
		ActiveCtrls := @WINDOW:'.SUPP_ENTRY_DTM':@RM
		ActiveCtrls := @WINDOW:'.SUPP_SIG_LABEL':@RM
		ActiveCtrls := @WINDOW:'.SUPP_SIG':@RM
		ActiveCtrls := @WINDOW:'.SUPP_SIG_DTM':@RM
		ActiveCtrls := @WINDOW:'.SUPP_SIG_BUTTON'
		
		Props  = 'VISIBLE':@RM:'VISIBLE':@RM:'VISIBLE':@RM:'VISIBLE':@RM:'VISIBLE':@RM:'VISIBLE'
		Props := @RM:'VISIBLE':@RM:'VISIBLE':@RM:'VISIBLE':@RM:'VISIBLE':@RM:'VISIBLE'
		
		Vals = 1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1
		
		IF ReactType = 'High Thruput' OR ReactType = 'ASM+' THEN
		
			ActiveCtrls := @RM:@WINDOW:'.ASMLL_GROUP'
			ActiveCtrls := @RM:@WINDOW:'.LOAD_LOCK_SIDE'
			
			Props := @RM:'VISIBLE':@RM:'VISIBLE'
			Vals := @RM:1:@RM:1
			
		END
	
	CASE RunStep = 'UNLOAD'
		ActiveCtrls  = @WINDOW:'.MET_TEST_GROUP':@RM
		ActiveCtrls := @WINDOW:'.MET_TEST'
		
		Props = 'VISIBLE':@RM:'VISIBLE'
		Vals = '1':@RM:'1'
	
	CASE 1
		Set_Property(@WINDOW:'.MET_TEST','VISIBLE',0)
		Set_Property(@WINDOW:'.WFR_QTY_LABEL','VISIBLE',0)
		Set_Property(@WINDOW:'.WFR_QTY','VISIBLE',0)
		Set_Property(@WINDOW:'.ASMLL_GROUP','VISIBLE',0)
		Set_Property(@WINDOW:'.LOAD_LOCK_SIDE','VISIBLE',0)
		
END CASE

Set_Property(ActiveCtrls,Props,Vals)

GOSUB Refresh

RETURN


* * * * * * *
Refresh:
* * * * * * *

WONo	= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStep	= Get_Property(@WINDOW:'.PROC_STEP_NO','DEFPROP')
CassNo	= Get_Property(@WINDOW:'.OUT_CASS_NO','DEFPROP')
RunStep	= Get_Property(@WINDOW:'.RUN_STEP','DEFPROP')
RDSNo	= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

WOMatRec = XLATE('WO_MAT',WONo:'*':CassNo,'','X')
PSNo	 = XLATE('WO_STEP',WONo:'*':WOStep,1,'X')


BEGIN CASE
	CASE RunStep = 'VER'
		VerInst = XLATE('PROD_SPEC',PSNo,PROD_SPEC_PRE_EPI_VER_INST$,'X')
		
	CASE RunStep = 'LOAD'
		VerInst = XLATE('PROD_SPEC',PSNo,PROD_SPEC_LOAD_VER_INST$,'X')
		
		ReactRunRec = XLATE('REACT_RUN',RDSNo,'','X')
		
		Set_Property(@WINDOW:'.SUPPLEMENT','DEFPROP',ReactRunRec<REACT_RUN_SUPP_INST$>)
		Set_Property(@WINDOW:'.SUPP_ENTRY_ID','DEFPROP',ReactRunRec<REACT_RUN_SUPP_ENTRY_ID$>)
		Set_Property(@WINDOW:'.SUPP_ENTRY_DTM','DEFPROP',ReactRunRec<REACT_RUN_SUPP_ENTRY_DTM$>)
		Set_Property(@WINDOW:'.SUPP_SIG','DEFPROP',ReactRunRec<REACT_RUN_SUPP_SIG$>)
		Set_Property(@WINDOW:'.SUPP_SIG_DTM','DEFPROP',ReactRunRec<REACT_RUN_SUPP_SIG_DTM$ >)
		
		
	CASE RunStep = 'UNLOAD'
		VerInst = XLATE('PROD_SPEC',PSNo,PROD_SPEC_UNLOAD_VER_INST$,'X')
		
	CASE 1
		VerInst = ''
		
END CASE

IF VerInst NE '' THEN
	VerInst = FMT(VerInst,'T#70')
	Set_Property(@WINDOW:'.VER_INST','DEFPROP',VerInst)
END


CurrSigProf = WOStep:RunStep

LOCATE CurrSigProf IN WOMatRec<WO_MAT_SIG_PROFILE$> USING @VM SETTING SigPos THEN
	CurrSig		= WOMatRec<WO_MAT_SIGNATURE$,SigPos>
	CurrSigDTM	= WOMatRec<WO_MAT_SIG_DTM$,SigPos>
	
	CurrSigDTM	= OCONV(CurrSigDTM,'DT4/^HS')

	Set_Property(@WINDOW:'.STEP_SIG','DEFPROP',CurrSig)
	Set_Property(@WINDOW:'.STEP_SIG_DTM','DEFPROP',CurrSigDTM)
END

IF Get_Property(@WINDOW:'.WFR_QTY','VISIBLE') THEN

	BEGIN CASE
	 	CASE RunStep = 'VER' 
	 		WfrQty = XLATE('REACT_RUN',RDSNo,REACT_RUN_VER_WFR_CNT$,'X')
	 	CASE RunStep = 'LOAD'
			WfrQty = XLATE('REACT_RUN',RDSNo,REACT_RUN_LOAD_WFR_CNT$,'X')
		CASE 1
			WfrQty = ''
	END CASE
	 
	 IF WfrQty NE '' THEN
	 	Set_Property(@WINDOW:'.WFR_QTY','DEFPROP',WfrQty)
	 END
	 
END

IF Get_Property(@WINDOW:'..ASMLL_GROUP','VISIBLE') THEN
	LLSide = XLATE('REACT_RUN',RDSNo,REACT_RUN_LOAD_LOCK_SIDE$,'X')
	Set_Property(@WINDOW:'.LOAD_LOCK_SIDE','DEFPROP',LLSide)
END


IF Get_Property(@WINDOW:'.MET_TEST','VISIBLE') THEN

	wmParms	 = WONo:'*':@RM			;* Cass ID
	wmParms := WOMatRec:@RM			;* WOMat Record
	wmParms := WOStep:@RM			;* WO Step
	wmParms := RunStep:@RM			;* Reactor Run Step
	wmParms := ''					;* ALL eQA Met fields returdn in default order for Run Step

	StepQAData = obj_WO_Mat('GetQAMet',wmParms)

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
	END

	QAMetArray = ''
	QAMetArray<COL$MET_TEST>		= StepQAData<1>	;* Test ID's w/o the WO Step
	QAMetArray<COL$MET_TEST_DESC>	= obj_Popup('CodeDesc','QA_MET_TEST':@RM:QAMetArray<COL$MET_TEST>)
	QAMetArray<COL$MET_SLOT>		= StepQAData<6>
	QAMetArray<COL$MET_SLOT_DESC>	= obj_Popup('CodeDesc','TEST_SLOTS':@RM:QAMetArray<COL$MET_SLOT>)
	QAMetArray<COL$MET_SLOT_TEST>	= StepQAData<9>
	QAMetArray<COL$MET_MIN>			= StepQAData<3>
	QAMetArray<COL$MET_MAX>			= StepQAData<4>
	QAMetArray<COL$MET_RESULT>		= StepQAData<5>
	QAMetArray<COL$MET_SIG>			= StepQAData<7>
	QAMetArray<COL$MET_SIG_DTM>		= StepQAData<8>

	Set_Property(@WINDOW:'.MET_TEST','DEFPROP',QAMetArray)
END

RETURN

* * * * * * *
Sign:
* * * * * * *

Valid = Dialog_Box('NDW_VERIFY_USER', @Window, @User4)
Valid = Valid<1>

IF Valid THEN
	ScanUser	= @USER4
	ScanDTM		= OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTHS')
	
	Ctrls  = @WINDOW:'.WO_NO':@RM			; Props  = 'DEFPROP':@RM
	Ctrls := @WINDOW:'.PROC_STEP_NO':@RM	; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.OUT_CASS_NO':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.RDS_NO':@RM			; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.MET_RESULT':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.MET_TEST':@RM		; Props := 'DEFPROP':@RM
	Ctrls := @WINDOW:'.RUN_STEP'			; Props := 'DEFPROP'
	
	Vals = Get_Property(Ctrls,Props)
	
	WONo		= Vals[1,@RM]
	WOStep		= Vals[COL2()+1,@RM]
	CassNo		= Vals[COL2()+1,@RM]
	RDSNo		= Vals[COL2()+1,@RM]
	MetResult	= Vals[COL2()+1,@RM]
	SigKey		= Vals[COL2()+1,@RM]
	RunStep		= Vals[COL2()+1,@RM]
	
	ScanUser	= @USER4
	ScanDTM		= OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTHS')
	
	BEGIN CASE
		CASE RDSNo = '' 		; Send_Event('WM_OUT','WRITE')
		CASE RunStep = 'UNLOAD'	; Send_Event('RDS_UNLOAD','WRITE')
		CASE RunStep = 'QA'		; Send_Event('RDS_POST_EPI','WRITE')
	END CASE
	
	
	owmParms = WONo:@RM:CassNo:@RM:WOStep:@RM:SigKey:@RM:ScanUser:@RM:ScanDTM:@RM:MetResult:@RM:RunStep
	*obj_WO_Mat('SetSignature',owmParms)				;* This stores results in the WO_MAT record
		
	IF Get_Status(errCode) THEN
	
		ErrMsg(errCode)
		
	END ELSE
	
		BEGIN CASE
			CASE RDSNo = '' 		; obj_Appwindow('LoadFormKeys','WM_OUT':@RM:WONo:'*':WOStep:'*':CassNo)
			CASE RunStep = 'UNLOAD'	; obj_Appwindow('LoadFormKeys','RDS_UNLOAD':@RM:RDSNo)
			CASE RunStep = 'QA'		; obj_Appwindow('LoadFormKeys','RDS_POST_EPI':@RM:RDSNo)
		END CASE 
		
		End_Dialog('REACT_RUN_VER','')
		
	END
END	;* End of check for Valid Signature

RETURN

* * * * * * *
Cancel:
* * * * * * *

RDSNo = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

obj_Appwindow('LoadFormKeys','REACT_RUN':@RM:RDSNo)

End_Dialog('REACT_RUN_VER','')


RETURN

