Compile Function Comm_Reactor(Instruction, Parm1, Parm2)
/***********************************************************************************************************************

    Name        :   Comm_Reactor

    History     :   (Date, Initials, Notes)
        04/20/21    djs     Updated Refresh GoSub to use PickPlace instead of Dedicated and Non-Dedicated
                            reactor assignments for form color purposes.

***********************************************************************************************************************/
DECLARE SUBROUTINE Set_Property,  Set_Status, ErrMsg, Set_Property, obj_AppWindow, Set_List_Box_Data
DECLARE SUBROUTINE Btree.Extract, Send_Event, Security_Err_Msg, Forward_Event, End_Window, Start_Window, RList
DECLARE SUBROUTINE Send_Message, obj_React_Esc, Msg, Print_ReactModeLog, Create_Dialog, Print_React_mode_log_services
DECLARE FUNCTION   Get_Property, Get_Status, Popup, Send_Message, Msg, Security_Check, Create_Dialog, RowExists
DECLARE FUNCTION   Dialog_Box, obj_WO_Log, MemberOf, obj_NCR, Send_Message, MemberOf, obj_Popup, Get_Status, Msg
DECLARE FUNCTION   obj_Reactor_PM, MemberOf, Start_Window, RTI_Task_Submit

$INSERT POPUP_EQUATES
$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT REACTOR_EQUATES
$INSERT REACT_UTIL_EQU
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT WAREHOUSE_EQUATES
$INSERT TOOL_CLASS_EQUATES

EQU CRLF$	TO \0D0A\

EQU COL$MFC_CODE		TO 1
EQU COL$MFC_FUNCTION	TO 2
EQU COL$MFC_PART_NO		TO 3
EQU COL$MFC_SERIAL_NO	TO 4
EQU COL$MFC_ASM_PN		TO 5
EQU COL$MFC_RANGE		TO 6
EQU COL$MFC_FLOW		TO 7
EQU COL$MFC_INLET		TO 8
EQU COL$MFC_OUTLET		TO 9

EQU COL$RI_TYPE			TO 1
EQU COL$RI_INST_DTM		TO 2
EQU COL$RI_NO			TO 3
EQU COL$RI_SERIAL		TO 4
EQU COL$RI_RL_ID		TO 5



EQU TARGET_ACTIVELIST$	TO 5

 

ErrTitle = 'Error in Comm_Reactor'
ErrorMsg = ''

Result = ''
errCode = ''
Transition = ''

BEGIN CASE
	CASE Instruction = 'Create' 				; GOSUB Create
	CASE Instruction = 'Refresh'				; GOSUB Refresh
	CASE Instruction = 'Read'					; GOSUB Read
	CASE Instruction = 'Write'					; GOSUB Write
	CASE Instruction = 'Clear'					; GOSUB Clear
	CASE Instruction = 'Delete'					; GOSUB Delete
	CASE Instruction = 'Close'					; GOSUB Close
	CASE Instruction = 'Page'					; GOSUB Page
	CASE Instruction = 'VScroll'				; GOSUB VScroll
	CASE Instruction = 'LUReactor'				; GOSUB LUReactor
	CASE Instruction = 'LUReactType'			; GOSUB LUReactType
	CASE Instruction = 'LUTempType'				; GOSUB LUTempType
	CASE Instruction = 'LUInjType'				; GOSUB LUInjType
	CASE Instruction = 'LUArmType'				; GOSUB LUArmType
	CASE Instruction = 'LUAssignment'			; GOSUB LUAssignment
	CASE Instruction = 'LULocation'				; GOSUB LULocation
	CASE Instruction = 'WaferSizeLF'			; GOSUB WaferSizeLF
	CASE Instruction = 'MFC_DC'					; GOSUB MFC_DC
	CASE Instruction = 'ReactItemHist'			; GOSUB ReactItemHist
	CASE Instruction = 'GasesDC'				; GOSUB GasesDC
	CASE Instruction = 'CurrItemDC'				; GOSUB CurrItemDC
	CASE Instruction = 'EscClick'				; GOSUB EscClick
	CASE Instruction = 'EscHistClick'			; GOSUB EscHistClick
	CASE Instruction = 'ModeHistClick'			; GOSUB ModeHistClick
	CASE Instruction = 'AdminModeHistClick'     ; GOSUB AdminModeHistClick
	CASE Instruction = 'TubeHistClick'			; GOSUB TubeHistClick
	CASE Instruction = 'ReactorConfigClick'		; GOSUB ReactorConfigClick
	CASE Instruction = 'ReactLLClick'			; GOSUB ReactLLClick
	CASE Instruction = 'LUToolID'				; GOSUB LUToolID
	CASE Instruction = 'LUSuscPockets'			; GOSUB LUSuscPockets
	CASE Instruction = 'ViewTool'				; GOSUB ViewTool
	CASE Instruction = 'InjectorHistory'		; GOSUB InjectorHistory
	CASE Instruction = 'LUSuscConfigID'			; GOSUB LUSuscConfigID
	CASE Instruction = 'ReactState'				; GOSUB ReactState
	Case Instruction = 'ReactLLHistory'         ; GOSUB ReactLLHistory
	Case Instruction = 'ReactServHist'          ; GOSUB ReactServHist
	
	CASE 1
		ErrorMsg = 'Unknown Instruction passed to routine'
END CASE

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

RETURN Result



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

obj_Appwindow("Create", @WINDOW)

If Not(Security_Check("Reactor", READ$)) then
	Security_Err_Msg("Reactor", READ$)
	End_Window(@WINDOW)
	Return
end

If MemberOf(@USER4, 'SCHEDULER_ADMIN') OR MemberOf(@USER4, 'SCHEDULER_MASTER') OR MemberOf(@USER4, 'OI_ADMIN') then
   Set_Property(@Window : '.SECOND_CHAMBER', 'ENABLED', 1)
   Set_Property(@Window : '.SECOND_CHAMBER', 'BACKCOLOR', WHITE$)
end

IF MemberOf(@USER4, 'OI_SUPERUSER') THEN
	Set_Property(@WINDOW:'.CONFIG_GROUP','ENABLED',1)
END ELSE
	Set_Property(@WINDOW:'.CONFIG_GROUP','ENABLED',0)
END

If MemberOf(@USER4, 'OI_SUPERUSER') then
    Set_Property(@WINDOW:'.PUB_ADMIN_MODE_CHANGE_HIST', 'ENABLED', 1)
end else
    Set_Property(@WINDOW:'.PUB_ADMIN_MODE_CHANGE_HIST', 'ENABLED', 0)
end

IF Num(Parm1) THEN
	PassedKeys = Field(Parm1, "*", 1)
	obj_Appwindow("LoadFormKeys", @Window:@RM:PassedKeys)
END

WaferSizes = XLATE( 'LISTBOX_CONFIG','WAFERSIZE', 1, 'X' )
CONVERT @VM TO @FM IN WaferSizes

Set_Property(@WINDOW:'.WAFER_SIZE','LIST',WaferSizes)		;* This is temporary until graphite (susceptors) get added to configurations
Set_Property(@WINDOW:'.SUSC_POCKET_SIZE','LIST',WaferSizes)	;* So is this one

GoSub Refresh

RETURN


* * * * * * *
Read:
* * * * * * *

ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
ServID = ''

ReactPMHist = obj_Reactor_PM('ReactServHist',ReactNo:@RM:ServID:@RM)	;* Open + 3 year history

Set_Property(@WINDOW:'.PM_HISTORY','LIST',ReactPMHist)


GOSUB Refresh

RETURN


* * * * * * *
Write:
* * * * * * *


IF @WINDOW = 'REACTOR_RO' THEN
	ErrMsg('Changes will not be saved...')
	Focus = Get_Property( 'REACTOR_RO', "FOCUS" )
	Send_Event( Focus, "LOSTFOCUS" )
	Set_Property(@WINDOW,'SAVEWARN',0)
	Result = 0
END ELSE
	Result = 1
END


RETURN


* * * * * * *
Clear:
* * * * * * *

Send_Event(@WINDOW,'PAGE',1)

IF @WINDOW = 'REACTOR_RO' THEN
	Focus = Get_Property( 'REACTOR_RO', "FOCUS" )
	Send_Event( Focus, "LOSTFOCUS" )
	Set_Property(@WINDOW,'SAVEWARN',0)
	Result = 1
END




GOSUB Refresh

RETURN


* * * * * * *
Delete:
* * * * * * *

ErrMsg('Reactors may not be deleted.')

Result = 0	;* NOT OK to proceed with the delete

RETURN



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

IF @WINDOW = 'REACTOR_RO' THEN
	Focus = Get_Property( 'REACTOR_RO', "FOCUS" )
	Send_Event( Focus, "LOSTFOCUS" )
	Set_Property(@WINDOW,'SAVEWARN',0)
	Result = 1
	
END ELSE

	obj_Appwindow('DetailReturn')
END

RETURN 


* * * * * * *
Page:
* * * * * * *

Page = Get_Property(@WINDOW:'.TABCONTROL', 'VALUE')

Set_Property(@WINDOW,'VPOSITION', Page)

RETURN


* * * * * * *
VScroll:
* * * * * * *

Page = Parm1

Set_Property(@WINDOW:'.TABCONTROL','VALUE', Page)



RETURN



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

CurrAssign = Get_Property(@WINDOW:'.REACT_ASSIGN','TEXT')
EscStartDTM = Get_Property(@WINDOW:'.ESC_START_DTM','TEXT')



ActEscalation = Get_Property(@WINDOW:'.ACT_ESC','LIST')

EscStartDTM = ActEscalation<1,1>
IF EscStartDTM NE '' THEN
	Set_Property(@WINDOW:'.ESC_BUTTON','TEXT','De-Escalate')
	Set_Property(@WINDOW:'.ESC_LABEL','VISIBLE',1)
END ELSE
	Set_Property(@WINDOW:'.ESC_BUTTON','TEXT','Escalate')
	Set_Property(@WINDOW:'.ESC_LABEL','VISIBLE',0)
END



IF MemberOf(@USER4, 'OI_SUPERUSER') THEN
	Set_Property(@WINDOW:'.REACT_ASSIGN','ENABLED',1)
	Set_Property(@WINDOW:'.REACT_TYPE','ENABLED',1)
END ELSE
	Set_Property(@WINDOW:'.REACT_ASSIGN','ENABLED',0)
	Set_Property(@WINDOW:'.REACT_TYPE','ENABLED',0)
END
	
PickPlace     = Get_Property(@WINDOW:'.PICK_PLACE','CHECK')
RAssign       = Get_Property(@WINDOW:'.REACT_ASSIGN','DEFPROP')
ReactType     = Get_Property(@WINDOW:'.REACT_TYPE','TEXT')
NotRepairable = Get_Property(@WINDOW:'.NOT_REPAIRABLE','CHECK')
EpiPro        = (ReactType EQ 'EPP')

* BEGIN CASE
*    
*    CASE RAssign = 'O'
*		BackColor = GREY$
*		
* 	CASE Not(NotRepairable)
		BackColor = GREEN$
*		
*    CASE NotRepairable
*		BackColor = LTORANGE$
*			
* 	CASE 1
*		BackColor = GREY$
*		
* END CASE

Set_Property(@WINDOW:'.REACT_ASSIGN_DESC','BACKCOLOR',BackColor)

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


* QBF buttons

Ctrls  = @WINDOW:'.QBF_FIRST_FIX':@RM		; Props  = 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_PREV_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_ABS_FIX':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_NEXT_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_LAST_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_STOP_FIX'			; Props := 'ENABLED'

IF Get_Property(@WINDOW,'QBFLIST') = '' THEN
	Vals = 0:@RM:0:@RM:0:@RM:0:@RM:0:@RM:0
END ELSE
	Vals = 1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1
END

Set_Property(Ctrls,Props,Vals)

* Turn edit table symbolic column backgrounds to green

ETSymbolics = Get_Property(@WINDOW,'@ET_SYMBOLICS')		;* Loaded during 'Create' in obj_Appwindow

ETCtrls	= ETSymbolics<1>
ETCols	= ETSymbolics<2>

FOR I = 1 TO COUNT(ETCtrls,@VM) + (ETCtrls NE '')
	ETCtrl	= ETCtrls<1,I>
	IF ETCtrl NE 'REACTOR.LL_DISABLED_DTM' THEN
		ETList = Get_Property(ETCtrl,'LIST')
		FOR Line = 1 TO COUNT(ETList,@FM) + (ETList NE '')
			IF ETList<Line,1> NE '' THEN
				FOR N = 1 TO COUNT(ETCols<1,I>,@SVM) + (ETCols<1,I> NE '')
					stat = Send_Message(ETCtrl,'COLOR_BY_POS',ETCols<1,I,N>,Line,GREEN$)
				NEXT N
			END
		NEXT Line
	END	;* End of check for special background color
NEXT I

RETURN


* * * * * * *
LUReactor:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Set_Status(0)

ReactorNo = Popup(@WINDOW,'','REACTORS')

IF ReactorNo = '' THEN RETURN

IF INDEX(ReactorNo,@VM,1) THEN
	CONVERT @VM TO @FM IN  ReactorNo
	Send_Event(@WINDOW,'CLEAR')
	Set_Property(@WINDOW,'QBFLIST',ReactorNo)
	Send_Event(@WINDOW,'QBFFIRST')
	GOSUB Refresh
END ELSE
	obj_Appwindow('LoadFormKeys',@WINDOW:@RM:ReactorNo)
END

RETURN


* * * * * * *
LUReactType:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

ReactType = Popup(@WINDOW,TypeOver,'REACTOR_TYPE')

IF ReactType NE '' THEN
	obj_Appwindow('LUValReturn',ReactType:@RM:FocusControl:@RM:FocusPos)
END

RETURN


* * * * * * *
LUTempType:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Result = Popup(@WINDOW,TypeOver,'REACTOR_TEMP_TYPE')

IF Result NE '' THEN
	obj_Appwindow('LUValReturn',Result:@RM:FocusControl:@RM:FocusPos)
END

RETURN


* * * * * * *
LUInjType:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Result = Popup(@WINDOW,TypeOver,'REACT_INJ_TYPE')

IF Result NE '' THEN
	obj_Appwindow('LUValReturn',Result:@RM:FocusControl:@RM:FocusPos)
END

RETURN


* * * * * * *
LUArmType:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Result = Popup(@WINDOW,TypeOver,'REACTOR_ARM_TYPE')

IF Result NE '' THEN
	obj_Appwindow('LUValReturn',Result:@RM:FocusControl:@RM:FocusPos)
END

RETURN


* * * * * * *
LUAssignment:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Assignment = Popup(@WINDOW,TypeOver,'REACT_ASSIGNMENT')

IF Assignment NE '' THEN
	Set_Property(@WINDOW:'.REACT_ASSIGN','DEFPROP',Assignment)
	Send_Event(@WINDOW:'.REACT_ASSIGN','LOSTFOCUS')
END

RETURN


* * * * * * *
LULocation:
* * * * * * *


IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Assignment = Popup(@WINDOW,TypeOver,'REACT_LOCATIONS')

IF Assignment NE '' THEN
	Set_Property(@WINDOW:'.LOCATION','DEFPROP',Assignment)
	Send_Event(@WINDOW:'.LOCATION','LOSTFOCUS')
END

RETURN


* * * * * * *
WaferSizeLF:
* * * * * * *

WaferSize = Get_Property(@WINDOW:'.WAFER_SIZE','DEFPROP')

IF WaferSize NE '' THEN
	ValidWaferSizes = Get_Property(@WINDOW:'.WAFER_SIZE','LIST')
	LOCATE WaferSize IN ValidWaferSizes USING @FM SETTING Pos ELSE
		ErrMsg('Invalid Wafer size entered.  Choose from list.')
		Set_Property(@WINDOW:'.WAFER_SIZE','DEFPROP','')
		Set_Property('SYSTEM','FOCUS',@WINDOW:'.WAFER_SIZE')
		RETURN
	END
END


RETURN


* * * * * * *
MFC_DC:
* * * * * * *

ReactorNo = Get_Property(@WINDOW:'.REACT_NO','TEXT')

CtrlEntID = @WINDOW:'.MFC_FUNC'
CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

TableList	= Get_Property(CtrlEntID,'LIST')

IF CurrCol = COL$MFC_CODE THEN

	CurrMfcCodes = Get_Property(CtrlEntID,'ARRAY')<COL$MFC_CODE>	;* Existing MFC codes in edit table
	CurrMfcCodesTrimmed = ''
	FOR I = 1 TO COUNT(CurrMfcCodes,@VM) + (CurrMfcCodes NE '')
		IF CurrMfcCodes<1,I> NE '' THEN
			CurrMfcCodesTrimmed<1,I> = CurrMfcCodes<1,I>
		END
	NEXT I
	CurrMfcCodes			= CurrMfcCodesTrimmed
	CurrMfcCodePositions	= obj_Popup('CodePosition','REACT_MFC_FUNC':@RM:CurrMfcCodes)
	
	MfcCodes				= Popup(@WINDOW,'','MFC_LOC')
	
	IF MfcCodes	= '' THEN RETURN
	
	NewMfcCodePositions		= obj_Popup('CodePosition','REACT_MFC_FUNC':@RM:MfcCodes)
	
	FOR I = 1 TO COUNT(NewMfcCodePositions,@VM) + (NewMfcCodePositions NE '')
		NewMFcCodePosition = NewMfcCodePositions<1,I>
		MfcCode = MfcCodes<1,I>
		LOCATE NewMfcCodePosition IN CurrMfcCodePositions  BY 'AR' USING @VM SETTING POS ELSE
			CurrMfcCodePositions = INSERT(CurrMfcCodePositions,1,POS,0,NewMfcCodePosition)
			
			Send_Message(CtrlEntID,'INSERT',POS,MfcCode:@VM:@VM)
		END
		
	NEXT I
	Send_Event(@WINDOW:'.MFC_FUNC','CALCULATE',COL$MFC_FUNCTION)
		
	GOSUB Refresh
END	;* End of MfcCode column



IF CurrCol = COL$MFC_PART_NO THEN
	
	MFCPartNo	= TableList<CurrRow,COL$MFC_PART_NO>
	MFCCode		= TableList<CurrRow,COL$MFC_CODE>
	
	IF MFCCode NE '' THEN

		Retval = Popup(@WINDOW,TypeOver,'ASM_MFC')

		IF RetVal = '' THEN RETURN

		obj_AppWindow('LUValReturn',RetVal:@RM:CtrlEntID:@RM:CurrPos)
	END
END


	
IF CurrCol = COL$MFC_SERIAL_NO THEN
	
	MFCSerial	= TableList<CurrRow,COL$MFC_SERIAL_NO>
	MFCCode		= TableList<CurrRow,COL$MFC_CODE>
	MFCPartNo	= TableList<CurrRow,COL$MFC_PART_NO>
	
	IF MFCCode NE '' THEN
		IF MFCSerial = '' THEN
			IF MFCPartNo = '' THEN
				Gases = XLATE('MFC_LOC',MFCCode,2,'X')
				SearchString	= 'GAS':@VM:Gases:@FM
			END ELSE
				SearchString = 'ASM_PN':@VM:MFCPartNo:@FM
			END
			
			Table			= 'MFC'
			Option			= ''
			Flag			= ''
			MFCKeys			= ''
			
			OPEN 'DICT.MFC' TO DictVar THEN
				Btree.Extract(SearchString, Table, DictVar, MFCKeys, Option, Flag)
				IF Get_Status(errCode) THEN
					ErrMsg(errCode)
					RETURN
				END
			END ELSE
				ErrMsg('Unable to open DICT.MFC for Btree.Extract routine.')
				RETURN
			END
			IF MFCKeys = '' THEN RETURN
			
			TypeOver = ''
			TypeOver<PMODE$> = 'K'
			TypeOver<PDISPLAY$> = MFCKeys
			MFCKey = Popup(@WINDOW,TypeOver,'MASS_FLOW_CONTROLLERS')
			
			IF Get_Status(errCode) THEN
				ErrMsg(errCode)
				RETURN
			END
			
			IF MFCKey NE '' THEN
				obj_AppWindow('LUValReturn',MFCKey:@RM:CtrlEntID:@RM:CurrPos)
			END
			
		END ELSE
			IF Get_Property(@WINDOW,'QBFLIST') = '' THEN
				Send_Event(@WINDOW,'WRITE')
			END
			
			DetWindow	= 'MFC'
			DetKeys		= MFCSerial
			DefaultRec	= ''
			RetKey		= ReactorNo
			RetPage		= 2
			RetCtrl		= CtrlEntID
			RetPos		= CurrPos
			
			oAParms = DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos

			obj_AppWindow('ViewNewDetail',oAParms)
			IF Get_Status(errCode) THEN
				ErrMsg(errCode)
			END
		
		END
	END
	
END	;* End of QuoteNo column



RETURN



* * * * * * *
GasesDC:
* * * * * * *

ReactorNo = Get_Property(@WINDOW:'.REACT_NO','TEXT')

CtrlEntID = @WINDOW:'.GASES'
CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

CurrGases = Get_Property(CtrlEntID,'ARRAY')	;* Existing MFC codes in edit table
CurrGasesTrimmed = ''
FOR I = 1 TO COUNT(CurrGases,@VM) + (CurrGases NE '')
	IF CurrGases<1,I> NE '' THEN
		CurrGasesTrimmed<1,I> = CurrGases<1,I>
	END
NEXT I

CurrGases = CurrGasesTrimmed
CurrGasesPositions	= obj_Popup('CodePosition','REACTOR_GASES':@RM:CurrGases)

Gases = Popup(@WINDOW,'','REACTOR_GASES')

IF Gases = '' THEN RETURN

NewGasesPositions = obj_Popup('CodePosition','REACTOR_GASES':@RM:Gases)

FOR I = 1 TO COUNT(NewGasesPositions,@VM) + (NewGasesPositions NE '')
	NewGasesPosition = NewGasesPositions<1,I>
	Gas = Gases<1,I>
	LOCATE NewGasesPosition IN CurrGasesPositions  BY 'AR' USING @VM SETTING POS ELSE
		CurrGasesPositions = INSERT(CurrGasesPositions,1,POS,0,NewGasesPosition)
		
		Send_Message(CtrlEntID,'INSERT',POS,Gas)
	END
	
NEXT I
*Send_Event(@WINDOW:'.MFC_FUNC','CALCULATE',COL$MFC_FUNCTION)
	
GOSUB Refresh

RETURN


* * * * * * *
CurrItemDC:
* * * * * * *


ReactorNo = Get_Property(@WINDOW:'.REACT_NO','TEXT')

CtrlEntID = @WINDOW:'.CURR_RI_TYPE'
CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

TableList	= Get_Property(CtrlEntID,'LIST')


IF CurrCol = COL$RI_NO THEN
	RINo = TableList<CurrRow,COL$RI_NO>

	IF RINo NE '' THEN
		obj_Appwindow('ViewRelated','REACT_ITEM':@RM:RINo)
	END
END

IF CurrCol = COL$RI_RL_ID THEN
	RLId = TableList<CurrRow,COL$RI_RL_ID>

	IF RLId NE '' THEN
		obj_Appwindow('ViewRelated','REACTOR_LOG':@RM:RLId)
	END
END

RETURN


* * * * * * *
ReactItemHist:
* * * * * * *

ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
AtRecord = Get_Property(@WINDOW,'ATRECORD')

CurrItemKeys = AtRecord<REACTOR_CURR_INST_ITEMS$>

void = Create_Dialog('DIALOG_REACT_ITEM_HIST', @WINDOW, 0, '')

Send_Event(@WINDOW,'READ')

RETURN

* * * * * * *
ReactServHist:
* * * * * * *

ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')

void = Create_Dialog('DIALOG_SERVICE_HISTORY', @WINDOW, 0, ReactNo)

Send_Event(@WINDOW,'READ')

RETURN

* * * * * * *
InjectorHistory:
* * * * * * * 

ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')


IF ReactNo NE '' THEN

	TypeOver            = ''
	TypeOver<PDISPLAY$> = 'WITH REACTOR_NO = ':ReactNo:' BY-DSND INJ_SET_DTM'

	void = Popup(@WINDOW,TypeOver,'REACT_INJ_SETTINGS')
	
END

RETURN



* * * * * * *
EscClick:
* * * * * * *

Ctrls = @WINDOW:'.REACT_NO':@RM:@WINDOW:'.ACT_ESC'
Props = 'TEXT':@RM:'LIST'

Vals = Get_Property(Ctrls,Props)

ReactNo			= Vals[1,@RM]
ActEscString	= Vals[COL2()+1,@RM]

IF ReactNo = '' THEN RETURN

StartDTM = ActEscString<1,1>

IF StartDTM = '' THEN Transition = 'ESC' ELSE Transition = 'D-ESC'

EscData = Dialog_Box('DIALOG_HOLD',@WINDOW,Transition:@FM:'Reactor')

IF EscData = 'Cancel' THEN RETURN

Send_Event(@WINDOW,'WRITE')

UserID = EscData<1>
Reason = EscData<2>

CurrDate = OCONV(Date(),'D4/')
CurrTime = OCONV(Time(),'MTH')
CurrDTM = CurrDate:' ':CurrTime

SelectSent = 'SELECT REACT_UTIL WITH REACTOR = ':QUOTE(ReactNo):' AND WITH MODE = "P" BY-DSND END_DATE BY-DSND END_TIME'

Set_Status(0)

Def = ""
Def<MTEXT$> = "Finding Last Production Mode Change..."
Def<MTYPE$> = "U"
MsgUp = Msg(@WINDOW, Def)   ;* display the processing message

Set_Status(0)

RList(SelectSent, TARGET_ACTIVELIST$, '', '', '')
IF Get_Status(errCode) THEN
	Msg(@WINDOW, MsgUp)
	ErrMsg(errCode)
	RETURN
END

OutOfProdDTM = ''

OPEN 'REACT_UTIL' TO ReactUtilTable THEN
	Done = 0
	LOOP
		READNEXT ReactUtilKey ELSE Done = 1
	UNTIL Done OR OutOfProdDTM NE ''
		READ ReactUtilRec FROM ReactUtilTable,ReactUtilKey THEN
			EndDt = ReactUtilRec<REACT_UTIL_END_DATE$>
			EndTm = ReactUtilRec<REACT_UTIL_END_TIME$>
			OutOfProdDTM = OCONV(EndDt,'D4/'):' ':OCONV(EndTm,'MTS')
		END
	
	REPEAT
END

Msg(@WINDOW, MsgUp)


IF StartDTM = '' THEN

	* Place Reactor into Escalation
	
	obj_React_Esc('Create',ReactNo:@RM:CurrDTM:@RM:UserID:@RM:Reason:@RM:OutOfProdDTM)
	
END ELSE
	* Take Reactor out of Escalation
	
	obj_React_Esc('Close',ReactNo:@RM:StartDTM:@RM:CurrDTM:@RM:UserID:@RM:Reason)
	
END

obj_AppWindow('LoadFormKeys',@WINDOW:@RM:ReactNo)

RETURN


* * * * * * *
EscHistClick:
* * * * * * *

IF @WINDOW = 'WO_DAILY_SCHED_SINGLE' THEN
	ReactNo = Get_Property(@WINDOW,'@REACTOR')
END ELSE
	ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
END

IF ReactNo NE '' THEN
	OPEN 'DICT.REACT_ESC' TO DictVar THEN
		SearchString = 'REACT_NO':@VM:ReactNo:@FM
		Option = ''
		Flag = ''
		BTREE.EXTRACT(SearchString,'REACT_ESC',DictVar,REKeys,Option,Flag)
		
		IF Get_Status(errCode) THEN
			ErrMsg(errCode)
			RETURN
		END
		
		IF REKeys = '' THEN
			ErrMsg('No Escalation History on file for this reactor.!')
			RETURN
		END
		
		TypeOver = ''
		TypeOver<PDISPLAY$> = REKeys
		TypeOver<PSELECT$> = 2
		
		EscKeys = Popup(@WINDOW,TypeOVer,'REACT_ESC_HISTORY')
		
		obj_AppWindow('ViewRelated','REACT_ESC':@RM:EscKeys)
	END
END

RETURN


* * * * * * *
ModeHistClick:
* * * * * * *
//Added new Reactor Mode Report 6/23/2022

IF @WINDOW = 'WO_DAILY_SCHED_SINGLE' THEN
	ReactNo = Get_Property(@WINDOW,'@REACTOR')
	StopDt = Date() - 60
END ELSE
	ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
	StopDt = ''
END


IF ReactNo = '' THEN RETURN

	DaysToReport =  Msg(@WINDOW,TypeOver,'REPORT_DAYS')
	If Num(DaysToReport) then
	    Start_Window('REACTOR_MODE_HISTORY','', ReactNo:char(244):DaysToReport)
	end

RETURN
	

* * * * * * * * * *
AdminModeHistClick:
* * * * * * * * * *

    ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
    Create_Dialog('NDW_EDIT_MODE_CHANGE_HIST', @Window, '', ReactNo)

RETURN


* * * * * * *
TubeHistClick:
* * * * * * *

ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')

IF ReactNo NE '' THEN
	obj_Appwindow('ViewRelated','REACT_TUBE':@RM:ReactNo)
END

RETURN


* * * * * * *
ReactorConfigClick:
* * * * * * * 

IF @WINDOW = 'WO_DAILY_SCHED_SINGLE' THEN
	ReactNo = Get_Property(@WINDOW,'@REACTOR')
END ELSE
	ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
END

obj_AppWindow('ViewRelated','REACTOR_RO':@RM:ReactNo)

RETURN


* * * * * * *
ReactLLClick:
* * * * * * * 

IF @WINDOW = 'WO_DAILY_SCHED_SINGLE' THEN

	ReactNo = Get_Property(@WINDOW,'@REACTOR')
	
	ReactLLDisabled = Dialog_Box('DIALOG_REACT_LL', @WINDOW, ReactNo)

	BEGIN CASE
		CASE ReactLLDisabled = ''
			ReactLLText = ''
			
		CASE ReactLLDisabled = 'R'
			ReactLLText = 'Right Load Lock Disabled'
			
		CASE ReactLLDisabled = 'L'
			ReactLLText = 'Left Load Lock Disabled'

		CASE 1
			ReactLLText = ''

	END CASE

	Set_Property(@WINDOW:'.REACT_LL_STATUS','TEXT',ReactLLText)

END ELSE
	ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
	ReactLLDisabled = Dialog_Box('DIALOG_REACT_LL', @WINDOW, ReactNo)
END

RETURN





* * * * * * *
LUToolID:
* * * * * * *

ReactorTools = XLATE('TOOL_CLASS','REACTOR',TOOL_CLASS_TOOL$,'X')

TypeOver = ''
TypeOver<PMODE$>	= 'K'
TypeOver<PDISPLAY$> = ReactorTools

ToolID = Popup(@WINDOW,TypeOver,'TOOLS')

IF Get_Status(errCode) THEN ErrMsg(errCode)

IF ToolID NE '' AND ToolID NE CHAR(27) THEN
	obj_AppWindow('LUValReturn',ToolID:@RM:@WINDOW:'.TOOL_ID')
END

RETURN


* * * * * * *
ViewTool:
* * * * * * *

ToolID = Get_Property(@WINDOW:'.TOOL_ID','DEFPROP')

IF ToolID NE '' THEN
	obj_Appwindow('ViewRelated','TOOL':@RM:ToolID)
END


RETURN

* * * * * * *
LUSuscPockets:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

ReactType = Popup(@WINDOW,'','SUSCEPTOR_POCKETS')

IF ReactType NE '' THEN
	obj_Appwindow('LUValReturn',ReactType:@RM:FocusControl:@RM:FocusPos)
END

RETURN


* * * * * * *
LUSuscConfigID:
* * * * * * *


IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl	= Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos		= Parm2

EpiSuscID = Popup(@WINDOW,'','EPI_SUSCEPTOR')
IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

IF EpiSuscID NE '' THEN
	obj_Appwindow('LUValReturn',EpiSuscID:@RM:FocusControl:@RM:FocusPos)
END

RETURN


* * * * * * *
ReactState:
* * * * * * * 

IF @WINDOW = 'WO_DAILY_SCHED_SINGLE' THEN
	ReactNo = Get_Property(@WINDOW,'@REACTOR')
END ELSE
	ReactNo = Get_Property(@WINDOW:'.REACT_NO','DEFPROP')
END

IF ReactNo NE '' THEN
	obj_AppWindow('ViewRelated','REACT_STATE':@RM:ReactNo)
END

RETURN

* * * * * * * * *
ReactLLHistory:
* * * * * * * * *
    //IF @USER4 EQ 'JONATHAN_O' then debug
    IF @WINDOW = 'WO_DAILY_SCHED_SINGLE' THEN
	    ReactNo = Get_Property(@WINDOW,'@REACTOR')
    END
    LLHistoryWindow = Start_Window('REACT_LL_HISTORY', @Window, ReactNo, '', '')
return









