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

/*
	Commuter module for Dialog_Unload_Susceptor window.- Cloned from COMM_DIAOLOG_LOAD_EPI_PRO
	
	06/05/2016 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status, ErrMsg, obj_RDS2, Send_Event, RDS_React_Run, Send_Info, obj_React_Run, obj_Run_Stage
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg, End_Dialog, Send_Message, obj_MAT_INBOUND, obj_WM_Wfrs, obj_React_Status
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Popup, obj_WM_In, Send_Message, obj_NCR, obj_WM_Wfrs, Set_Property, obj_WO_Mat_Wfr

EQU CRLF$	TO \0D0A\

$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT RDS_EQU
$INSERT REACT_RUN_EQUATES
$INSERT REACTOR_EQUATES
$INSERT RDS_TEST_EQUATES
$INSERT EPI_SUSCEPTOR_EQUATES
$INSERT WO_LOG_EQUATES
$INSERT EPI_PART_EQUATES
$INSERT RDS_EPILOAD
$INSERT WO_STEP_EQU
$INSERT NCR_EQU
$INSERT APPCOLORS
$INSERT WO_WFR_EQUATES

EQU COL$MI_SLOT_ID	TO 1
EQU COL$MI_WFR_ID	TO 2
EQU COL$MI_SCRIBE	TO 3

EQU COL$POCKET		TO 1
EQU COL$USAGE		TO 2
EQU COL$ZONE		TO 3
EQU COL$WAFER_TYPE	TO 4
EQU COL$IN_SLOT_ID 	TO 5
EQU COL$WFR_ID		TO 6
EQU COL$OUT_SLOT_ID	TO 7


EQU EDITABLE$			TO 4
EQU PROTECTED$			TO 8			;* Protected  - Edittable COLSTYLE constants
EQU MULTILINE_STYLE$	TO 512 			;* MultiLine Select
EQU LOCKED$				TO 8192
EQU DROPDOWN_STYLE$		TO 131072


ErrTitle = 'Error in Dialog_Unload_Susceptor commuter module'
ErrorMsg = ''
ErrCode  = ''

Result = ''

BEGIN CASE

	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close			;* This needs to be a PRECLOSE event!
			
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	CASE EntID = @WINDOW:'.UNLOAD_WAFERS'	AND Event = 'CLICK'		; GOSUB UnloadWfrs
	CASE EntID = @WINDOW:'.RELOAD_WAFERS'	AND Event = 'CLICK'		; GOSUB ReloadWfrs
	
	CASE EntID = @WINDOW:'.CANCEL_BUTTON'	AND Event = 'CLICK'		; GOSUB Cancel
	
	
	
	CASE EntID = @WINDOW:'.REACTOR_TABLE'	AND Event = 'INSERTROW'	; GOSUB ReactIR
	CASE EntID = @WINDOW:'.REACTOR_TABLE'	AND Event = 'DELETEROW'	; GOSUB ReactIR
	
	
	
	CASE 1
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg(ErrorMsg)
		
END CASE

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


RETURN Result



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

obj_AppWindow('Create')

* get the current style

Style = Get_Property(@WINDOW:'.MAT_INBOUND', 'STYLE')									

IF Style [1,2] _EQC "0x" THEN
  CONVERT @LOWER.CASE TO @UPPER.CASE IN STYLE
  Style = ICONV(Style [3,99], "MX")
END

Style = BitOr(Style, MULTILINE_STYLE$)					;* Set to Multi Line Select
Set_Property(@WINDOW:'.MAT_INBOUND', "STYLE", Style)


RDSNo		= FIELD(Parm1,@FM,1)
Stage		= FIELD(Parm1,@FM,2)
ToolID		= FIELD(Parm1,@FM,3)
CurrentLoad = FIELD(Parm1,@FM,4,99)


IF RDSNo = '' THEN 
	ErrMsg('Null RDS No passed to Dialog Box...')
	End_Dialog(@WINDOW,'')
END

RRunRec = XLATE('REACT_RUN',RDSNo,'','X')

ReactorNo	= ToolID[2,10]
ReactType	= XLATE('REACTOR',ReactorNo,REACTOR_REACT_TYPE$,'X')

WONo		= RRunRec<REACT_RUN_WO_NO$>
WOStep	 	= RRunRec<REACT_RUN_WO_STEP$>
GanRun		= RRunRec<REACT_RUN_GAN_RUN_ID$>

Ctrls  = @WINDOW:'.RDS_NO':@RM			; Props  = 'DEFPROP':@RM	; Vals  = RDSNo:@RM
Ctrls := @WINDOW:'.GAN_RUN':@RM			; Props := 'DEFPROP':@RM	; Vals := GanRun:@RM
Ctrls := @WINDOW:'.STAGE':@RM			; Props := 'DEFPROP':@RM	; Vals := Stage:@RM
Ctrls := @WINDOW:'.TOOL_ID':@RM			; Props := 'DEFPROP':@RM	; Vals := ToolID:@RM
Ctrls := @WINDOW:'.WO_NO':@RM			; Props := 'DEFPROP':@RM	; Vals := WONo:@RM
Ctrls := @WINDOW:'.WO_STEP'				; Props := 'DEFPROP'		; Vals := WOStep

Set_Property(Ctrls,Props,Vals)

LoadCnt = 0
OpenCnt = 0

RCtrl = @WINDOW:'.REACTOR_TABLE'

TestInCass = CurrentLoad<COL$WFR_ID>		;* 6/2/2009 JCH  Better test for loaded wafers added
CONVERT @VM TO '' IN TestInCass				;* 6/2/2009 JCH


IF TestInCass = '' THEN
	ErrMsg('No wafers loaded on the susceptor.')
	End_Dialog(@WINDOW,'')
	
END ELSE
	
	ProdLoadCnt = 0
	ProdUnloadCnt = 0		
			
	FOR I = 1 TO COUNT(CurrentLoad<1>,@VM) + (CurrentLoad<1> NE '')
	
		
		
		Usage	= CurrentLoad<COL$USAGE,I>
		WfrType	= CurrentLoad<COL$WAFER_TYPE,I>
		OutSlot	= CurrentLoad<COL$OUT_SLOT_ID,I>

		IF WfrType = 'PROD' AND Usage = '' AND OutSlot = '' THEN
			ProdLoadCnt += 1											;* Product wafers to be unloaded
		END
		
		IF OutSlot NE '' THEN
			ProdUnloadCnt += 1
		END
	
	
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$POCKET,I>,COL$POCKET:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$USAGE,I>,COL$USAGE:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$ZONE,I>,COL$ZONE:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$WAFER_TYPE,I>,COL$WAFER_TYPE:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$IN_SLOT_ID,I>,COL$IN_SLOT_ID:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$WFR_ID,I>,COL$WFR_ID:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$OUT_SLOT_ID,I>,COL$OUT_SLOT_ID:@FM:I)
		
	NEXT I
END

/*
IF LoadCnt = 0 AND OpenCnt = 0 THEN
	ErrMsg('LoadCnt = 0 and OpenCnt = 0, internal program error.')
	End_Dialog(@WINDOW,'')
END
*/

BEGIN CASE
	CASE ProdLoadCnt > 0 AND ProdUnloadCnt = 0

		BriefTxt  = '{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}'
		BriefTxt := '{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\ri200\b\f0\fs20\par Unload Product from EpiPro Reactor\par'
		BriefTxt := '\b0\par'
		BriefTxt := ' 1.) Verify Outbound Slot IDs\par'
		BriefTxt := ' 2.) Unload Product into Outbound Cassette\par}'
		
		Title = 'Unload Product from susceptor'
		
		Set_Property(@WINDOW:'.UNLOAD_WAFERS','VISIBLE',1)
		Set_Property(@WINDOW:'.RELOAD_WAFERS','VISIBLE',0)
		
	CASE ProdLoadCnt = 0 AND ProdUnloadCnt > 0
		
		BriefTxt  = '{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}'
		BriefTxt := '{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\ri200\b\f0\fs20\par Return Product to EpiPro Reactor\par'
		BriefTxt := '\b0\par'
		BriefTxt := ' 1.)  Return Wafers to Reactor\par'
		BriefTxt := '\par}'
		
		Title = 'Return Product to Susceptor'
		
		Set_Property(@WINDOW:'.UNLOAD_WAFERS','VISIBLE',0)
		Set_Property(@WINDOW:'.RELOAD_WAFERS','VISIBLE',1)


	CASE 1
		
		ErrMsg('No wafers loaded in Reactor.')		;* Not yet loaded
		

END CASE

Set_Property(@WINDOW:'.BRIEF_EDITBOX','RTFTEXT',BriefTxt)

* Get list of available Outbound Slots

TestOutSlotIDs = CurrentLoad<COL$OUT_SLOT_ID>

CONVERT @VM TO '' IN TestOutSlotIDs

IF TestOutSlotIDs = '' THEN


	OpenSlots = obj_WO_Mat_Wfr('GetPostEpiSlots',WONo)
	OpenSlots = FIELD(OpenSlots,@FM,1,ProdLoadCnt)

	osCnt = COUNT(OpenSlots,@FM) + (Openslots NE '')

	WMOSlotKeys = ''

	FOR I = 1 TO osCnt

		SlotID		= OpenSlots<I>
		WMOSlotKey	= FieldStore(SlotID, '*', 2, 0, '1')
		
		WMOSlotKeys<1,I> = WMOSlotKey
		
	NEXT I

	obj_WM_Wfrs('LockSet','WMO_WFRS':@RM:WMOSlotKeys)	;* Setting these locks takes the slot off of the available slot list

	Set_Property(@WINDOW,'@LOCKED_WFRS',WMOSlotKeys)

	* Display open slots

	MatOut = Get_Property(@WINDOW:'.MAT_OUTBOUND','ARRAY')

	FOR I = 1 TO osCnt
		MatOut<1,I> = OpenSlots<I>
	NEXT I

	Set_Property(@WINDOW:'.MAT_OUTBOUND','DEFPROP',MatOut)
END

GOSUB Refresh

RETURN


* * * * * * *
Close:
* * * * * * *


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

RDSNo		= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
Stage		= Get_Property(@WINDOW:'.STAGE','DEFPROP')
WMOLocks	= Get_Property(@WINDOW,'@LOCKED_WFRS')

IF WMOLocks NE '' THEN
	obj_WM_Wfrs('UnlockSet','WMO_WFRS':@RM:WMOLocks)		; * Remove locks on the wafer slots
END

Set_Property(@WINDOW,'@LOCKED_WFRS','')

End_Dialog(@WINDOW,'')


* IF RDSNo NE '' THEN
* 	obj_Appwindow('LoadFormKeys','RUN_STAGE':@RM:RDSNo:'*':Stage)
* END

RETURN




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

RCtrl	= @WINDOW:'.REACTOR_TABLE'
WMICtrl = @WINDOW:'.MAT_INBOUND'

ReactorList = Get_Property(RCtrl,'LIST')
WMInList	= Get_Property(WMICtrl,'LIST')

OpenTestCnt = 0
OpenProdCnt = 0

FOR I = 1 TO COUNT(ReactorList,@FM) + (ReactorList NE '')

	IF ReactorList<I,COL$POCKET> NE '' THEN
	
		IF ReactorList<I,COL$USAGE> = 'TEST' THEN
			Send_Message(RCtrl,'COLOR_BY_POS',0,I,YELLOW$)
			IF ReactorList<I,COL$WAFER_TYPE> = '' THEN OpenTestCnt += 1
		END
		
		IF ReactorList<I,COL$USAGE> = 'DUMMY' THEN
			Send_Message(RCtrl,'COLOR_BY_POS',0,I,WHITE$)
		END
		
		IF ReactorList<I,COL$USAGE> = 'PROD' OR ReactorList<I,COL$USAGE> = '' THEN
			Set_Property(RCtrl,'CELLPOS','',COL$USAGE:@FM:I)
			Zone = ReactorList<I,COL$ZONE> 
			IF Zone = 1 THEN LineColor = RCV_BLUE$
			IF Zone = 2 THEN LineColor = PRE_BLUE$
			IF Zone = 3 THEN LineColor = INP_BLUE$
			IF Zone = 4 THEN LineColor = POS_BLUE$
			Send_Message(RCtrl,'COLOR_BY_POS',0,I,LineColor)
		END
		
		IF (ReactorList<I,COL$USAGE> = '' OR ReactorList<I,COL$USAGE> = 'PROD') AND ReactorList<I,COL$WAFER_TYPE> = '' THEN OpenProdCnt += 1
	END	
NEXT I

Set_Property(@WINDOW:'.OPEN_PROD_POCKETS','DEFPROP',OpenProdCnt)
Set_Property(@WINDOW:'.OPEN_TEST_POCKETS','DEFPROP',OpenTestCnt)


ReadyToLoad = 0

WMICnt = COUNT(WMInList,@FM) + (WMInList NE '')

FOR I = 1 TO WMICnt
	IF WMInList<I,COL$MI_SLOT_ID> NE '' THEN
		ReadyToLoad = 1
		IF WMInList<I,COL$MI_SCRIBE> = '' THEN
			Send_Message(WMICtrl,'COLOR_BY_POS',COL$MI_SCRIBE,I,GAN_BLUE$)
		END ELSE
			Send_Message(WMICtrl,'COLOR_BY_POS',COL$MI_SCRIBE,I,LTORANGE$)
		END
			
	END
	
NEXT I

IF ReadyToLoad THEN
	Set_Property(@WINDOW:'.LOAD_MATERIAL','ENABLED',1)
END ELSE
	Set_Property(@WINDOW:'.LOAD_MATERIAL','ENABLED',0)
END

RETURN



* * * * * * *
UnloadWfrs:
* * * * * * *

UnloadSlots		= Get_Property(@WINDOW:'.MAT_OUTBOUND','LIST')
ReactorList		= Get_Property(@WINDOW:'.REACTOR_TABLE','LIST')
WONo			= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStep			= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
RDSNo			= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
Stage			= Get_Property(@WINDOW:'.STAGE','DEFPROP')
ToolID			= Get_Property(@WINDOW:'.TOOL_ID','DEFPROP')


OrgColor = Set_Property('DIALOG_LOAD_SUSCEPTOR.STATUSLINE_FIX','BACKCOLOR',YELLOW$)	;* //////// Messaging

Set_Status(0)
obj_React_Run('UnloadMat',RDSNo:@RM:ToolID:@RM:ReactorList:@RM:UnloadSlots)		;* obj_REACT_RUN('UnloadMat'

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

WMOLocks = Get_Property(@WINDOW,'@LOCKED_WFRS')

IF WMOLocks NE '' THEN
	obj_WM_Wfrs('UnlockSet','WMO_WFRS':@RM:WMOLocks)		; * Remove locks on the wafer slots
END

Set_Property(@WINDOW,'@LOCKED_WFRS','')


obj_Run_Stage('SetIASig',RDSNo:@RM:Stage:@RM:'UNLOAD')

End_Dialog(@WINDOW,'')

obj_Appwindow('LoadFormKeys','RUN_STAGE':@RM:RDSNo:'*':Stage)

RETURN



* * * * * * *
ReloadWfrs:
* * * * * * *

ReactorList		= Get_Property(@WINDOW:'.REACTOR_TABLE','LIST')
WONo			= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStep			= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
RDSNo			= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
Stage			= Get_Property(@WINDOW:'.STAGE','DEFPROP')
ToolID			= Get_Property(@WINDOW:'.TOOL_ID','DEFPROP')

IF RDSNo = '' THEN RETURN

OrgColor = Set_Property('DIALOG_LOAD_EPI_PRO.STATUSLINE_FIX','BACKCOLOR',YELLOW$)	;* //////// Messaging


Set_Status(0)
obj_React_Run('ReloadMat',RDSNo:@RM:ToolID)


Send_Info(STR(' ',60))															;** - Messaging - **
Dummy = Set_Property('DIALOG_LOAD_EPI_PRO.STATUSLINE_FIX','BACKCOLOR',OrgColor)	;** - Messaging - **

IF Get_Status(ErrCode) THEN
	ErrMsg(ErrCode)
END



WMOLocks = Get_Property(@WINDOW,'@LOCKED_WFRS')

IF WMOLocks NE '' THEN
	obj_WM_Wfrs('UnlockSet','WMO_WFRS':@RM:WMOLocks)		; * Remove locks on the wafer slots
END

Set_Property(@WINDOW,'@LOCKED_WFRS','')

End_Dialog(@WINDOW,'')

obj_Appwindow('LoadFormKeys','RUN_STAGE':@RM:RDSNo:'*':Stage)



RETURN


* * * * * * *
ReactIR:
* * * * * * *

RowIndex = Parm1

IF RowIndex = '' THEN RETURN

CtrlID = @WINDOW:'.REACTOR_TABLE'

Dummy = Send_Message(CtrlID,'DELETE',RowIndex)

GOSUB Refresh

RETURN



* * * * * * *
ReactDR:
* * * * * * *

RowIndex = Parm1
RowData = Parm2

IF RowIndex = '' THEN RETURN

CtrlID = @WINDOW:'.REACTOR_TABLE'

Dummy = Send_Message(CtrlID, "INSERT", RowIndex, RowData)

GOSUB Refresh

RETURN


* * * * * * *
TestRun:
* * * * * * *

ReactorArray = Get_Property(@WINDOW:'.REACTOR_TABLE','ARRAY')

Usage = ReactorArray<COL$USAGE>

IF INDEX(Usage,'PROD',1) = 0 THEN
	LineCnt = COUNT(Usage,@VM) + (Usage NE '')
	FOR I = 1 To LineCnt
		IF ReactorArray<COL$POCKET,I> NE '' AND Usage<1,I> = '' THEN
			ReactorArray<COL$USAGE,I> = 'DUMMY'
		END
		Set_Property(@WINDOW:'.REACTOR_TABLE','ARRAY',ReactorArray)
	NEXT I
END

GOSUB Refresh

RETURN


* * * * * * *
ConfigComp:
* * * * * * *

GOSUB Refresh

WONo = Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStep = Get_Property(@WINDOW:'.WO_STEP','DEFPROP')

CComp = Get_Property(@WINDOW:'.CONFIG_COMPLETE','CHECK')

IF CComp THEN

	* Check for more pockets configured than avaible inbound wafers  *
	
	WONo = Get_Property(@WINDOW:'.WO_NO','DEFPROP')
	WOStep = Get_Property(@WINDOW:'.WO_STEP','DEFPROP')

	RemainingWafers = obj_WO_Mat_Wfr('GetPreEpiWfrs',WONo)
	
	RWCnt = COUNT(RemainingWafers,@FM) + (RemainingWafers NE '')

	OpenProdPockets = Get_Property(@WINDOW:'.OPEN_PROD_POCKETS','DEFPROP')
	OpenTestPockets = Get_Property(@WINDOW:'.OPEN_TEST_POCKETS','DEFPROP')

	OpenPockets  = OpenProdPockets + OpenTestPockets
	
	IF OpenPockets > RWCnt THEN
		Title	 = 'Susceptor Load Configuration'
		Message  = 'There are more slots configured for loading (':OpenPockets:') than Inbound wafers remaining to load (':RWCnt:').':CRLF$:CRLF$
		Message := 'Change ':(OpenPockets - RWCnt):' additional pockets to DUMMY load to correct.'
		
		TypeOver = ''
		TypeOver<MICON$> = '*'
		
		Msg(@WINDOW,TypeOver,'OK','',Title:@FM:Message)
		
		Set_Property(@WINDOW:'.CONFIG_COMPLETE','CHECK',0)
		
		RETURN
		
	END	;* End of check for more open slots than WMI wafers remaining to be used.
	
	
	* "lock down" reactor setup fields from further changes *
	
	ReactorStyles = Send_Message(@WINDOW:'.REACTOR_TABLE','COLSTYLE',0,'')
		
	ReactorStyles<COL$USAGE>		= BitAnd(ReactorStyles<COL$USAGE>,BitNot(DROPDOWN_STYLE$))
	ReactorStyles<COL$WAFER_TYPE>	= BitAnd(ReactorStyles<COL$WAFER_TYPE>,BitNot(DROPDOWN_STYLE$))
	
	ReactorStyles<COL$POCKET>		= BitOr(ReactorStyles<COL$POCKET>,PROTECTED$)
	ReactorStyles<COL$USAGE>		= BitOr(ReactorStyles<COL$USAGE>,PROTECTED$)
	ReactorStyles<COL$ZONE>			= BitOr(ReactorStyles<COL$ZONE>,PROTECTED$)
	
	ReactorStyles<COL$IN_SLOT_ID>	= BitOr(ReactorStyles<COL$IN_SLOT_ID>,PROTECTED$)
	ReactorStyles<COL$WFR_ID>		= BitOr(ReactorStyles<COL$WFR_ID>,PROTECTED$)
	ReactorStyles<COL$OUT_SLOT_ID>	= BitOr(ReactorStyles<COL$OUT_SLOT_ID>,PROTECTED$)
	
	ReactorStyles<COL$WAFER_TYPE>	= BitOr(ReactorStyles<COL$WAFER_TYPE>,PROTECTED$)
	
	Send_Message(@WINDOW:'.REACTOR_TABLE','COLFORMAT',COL$USAGE,'')
	Send_Message(@WINDOW:'.REACTOR_TABLE','COLFORMAT',COL$WAFER_TYPE,'')

	Send_Message(@WINDOW:'.REACTOR_TABLE','COLSTYLE',0,ReactorStyles)
	
	Set_Property(@WINDOW:'.TEST_RUN','VISIBLE',0)
	

	* Build list of Inbound wafers to load *
	

	NeededProduct = FIELD(RemainingWafers,@FM,1,OpenPockets)
	
	SlotKeys = ''
	SlotCnt = COUNT(NeededProduct,@FM) + (NeededProduct NE '')
	
	FOR I = 1 TO SlotCnt
	
		* Build List of WMI style keys for use by the Wafer Loading process locking routine
		
		SlotKey = NeededProduct<I,1>
		SlotKey = FIELDSTORE(SlotKey,'*',2,0,WOStep)					;* Insert WOStep into key to use the WMI_WFRS routine
		SlotKeys<1,I> = SlotKey
		
		WfrID = NeededProduct<I,2>
		NeededProduct<I,3> = XLATE('WO_WFR',WfrID,WO_WFR_SCRIBE$,'X')	;* Added existing Scribe value for WO_WFR - probably empty at this point
	NEXT I
	

	Set_Status(0)
	LockedSlotKeys = obj_WM_Wfrs('LockSet','WMI_WFRS':@RM:SlotKeys)		;* Keeps these wafers from being displayed in the Available Inbound wafers list

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		RETURN
	END ELSE
		Set_Property(@WINDOW,'@LOCKED_WFRS',LockedSlotKeys)
	END


	FOR M = 1 TO OpenPockets
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS',NeededProduct<M,1>,COL$MI_SLOT_ID:@FM:M)
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS',NeededProduct<M,2>,COL$MI_WFR_ID:@FM:M)
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS',NeededProduct<M,3>,COL$MI_SCRIBE:@FM:M)
	NEXT M
	

	FOR M = OpenPockets + 1 TO 25
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS','',COL$MI_SLOT_ID:@FM:M)
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS','',COL$MI_WFR_ID:@FM:M)
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS','',COL$MI_SCRIBE:@FM:M)
	NEXT M
	

END ELSE

	ReactorStyles = Send_Message(@WINDOW:'.REACTOR_TABLE','COLSTYLE',0,'')
		
	ReactorStyles<COL$USAGE>		= BitOr(ReactorStyles<COL$USAGE>,DROPDOWN_STYLE$)
	ReactorStyles<COL$WAFER_TYPE>	= BitOr(ReactorStyles<COL$WAFER_TYPE>,DROPDOWN_STYLE$)
	
	ReactorStyles<COL$POCKET>		= BitAnd(ReactorStyles<COL$POCKET>,BitNot(PROTECTED$))
	ReactorStyles<COL$USAGE>		= BitAnd(ReactorStyles<COL$USAGE>,BitNot(PROTECTED$))
	ReactorStyles<COL$ZONE>			= BitAnd(ReactorStyles<COL$ZONE>,BitNot(PROTECTED$))
	ReactorStyles<COL$IN_SLOT_ID>	= BitAnd(ReactorStyles<COL$IN_SLOT_ID>,BitNot(PROTECTED$))
	ReactorStyles<COL$WFR_ID>		= BitAnd(ReactorStyles<COL$WFR_ID>,BitNot(PROTECTED$))
	ReactorStyles<COL$OUT_SLOT_ID>	= BitAnd(ReactorStyles<COL$OUT_SLOT_ID>,BitNot(PROTECTED$))
	ReactorStyles<COL$WAFER_TYPE>	= BitAnd(ReactorStyles<COL$WAFER_TYPE>,BitNot(PROTECTED$))
	
	Send_Message(@WINDOW:'.REACTOR_TABLE','COLFORMAT',COL$USAGE,'TEST':@VM:'PROD':@VM:'DUMMY')
	Send_Message(@WINDOW:'.REACTOR_TABLE','COLFORMAT',COL$WAFER_TYPE,'':@VM:'TEST')

	Send_Message(@WINDOW:'.REACTOR_TABLE','COLSTYLE',0,ReactorStyles)
	
	Set_Property(@WINDOW:'.TEST_RUN','VISIBLE',1)
	
	LockedWMIKeys = Get_Property(@WINDOW,'@LOCKED_WFRS')
	
	Set_Status(0)
	obj_WM_Wfrs('UnlockSet','WMI_WFRS':@RM:LockedWMIKeys)

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		RETURN
	END ELSE
		Set_Property(@WINDOW,'@LOCKED_WFRS','')
	END

	FOR M = 1 TO 25
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS','',1:@FM:M)
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS','',2:@FM:M)
		Set_Property(@WINDOW:'.MAT_INBOUND','CELLPOS','',3:@FM:M)
		
	NEXT M

END

GOSUB Refresh

RETURN






